2 This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl).
3 Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
4 Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
5 You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>.
9 #include "mbed.h" // mbed.h lib
12 void lcdbang_writenibble(I2C i2c
, char c
, bool command
= false){
13 const int addr
= 0x40;
18 if(!command
) c
|= 0x02;
22 i2c
.write(addr
, cmd
, 2);
24 i2c
.write(addr
, cmd
, 2);
26 i2c
.write(addr
, cmd
, 2);
30 void lcdbang_write(I2C i2c
, char c
, bool command
= false){
32 lcdbang_writenibble(i2c
, c
, command
);
34 lcdbang_writenibble(i2c
, c
>> 4, command
);
35 lcdbang_writenibble(i2c
, c
, command
);
39 void lcdbang_init(I2C i2c
){
40 const int addr
= 0x40;
44 i2c
.write(addr
, cmd
, 2);
46 lcdbang_write(i2c
, 0x3, true);
48 lcdbang_write(i2c
, 0x3, true);
50 lcdbang_write(i2c
, 0x3, true);
52 lcdbang_write(i2c
, 0x2, true);
55 lcdbang_write(i2c
, 0x2, true);
56 lcdbang_write(i2c
, 0x8, true);
59 lcdbang_write(i2c
, 0x0, true);
60 lcdbang_write(i2c
, 0x8, true);
63 lcdbang_write(i2c
, 0x0, true);
64 lcdbang_write(i2c
, 0x1, true);
67 lcdbang_write(i2c
, 0x0, true);
68 lcdbang_write(i2c
, 0x6, true);
71 lcdbang_write(i2c
, 0x0, true);
72 lcdbang_write(i2c
, 0x2, true);
75 lcdbang_write(i2c
, 0x0, true);
76 lcdbang_write(i2c
, 0xC, true);
80 void lcdbang_print(I2C i2c
, const char* msg
){
81 for(int i
=0;msg
[i
];i
++){
82 lcdbang_write(i2c
, msg
[i
]);
86 void lcdbang_contrast(I2C i2c
, int contrast
){
87 // set dac pins as output and set dac
90 i2cbang_write(i2c
, 0xC0);
91 i2cbang_write(i2c
, 0x60);
92 i2cbang_write(i2c
, contrast
>> 8);
93 i2cbang_write(i2c
, (contrast
<< 8) & 0xF0 );