Skip to content

Commit

Permalink
formatting a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
Rubberazer committed Jul 2, 2024
1 parent f5289a1 commit 26c7244
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 39 deletions.
18 changes: 0 additions & 18 deletions EXAMPLES_C++/lcd_i2c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ void send_command(unsigned handle, unsigned i2cAddr, unsigned command){
buffer2 &= 0xFB;
buffer2 |= 0x08;
i2cWriteByteData(handle, i2cAddr, buffer2, 0x0);

buffer = (command & 0x0F) << 4;
buffer |= 0x04;
buffer2 = buffer;
Expand All @@ -35,18 +34,13 @@ void send_data(unsigned handle, unsigned i2cAddr, unsigned data){
buffer |= 0x05;
unsigned buffer2 = buffer;
buffer |= 0x08;
//i2cWriteByteData(handle, i2cAddr, buffer, 0);
//usleep(2000);
buffer2 &= 0xFB;
buffer2 |= 0x08;
i2cWriteByteData(handle, i2cAddr, buffer, buffer2);

buffer = (data & 0x0F) << 4;
buffer |= 0x05;
buffer2 = buffer;
buffer |= 0x08;
//i2cWriteByteData(handle, i2cAddr, buffer, 0);
//usleep(2000);
buffer2 &= 0xFB;
buffer2 |= 0x08;
i2cWriteByteData(handle, i2cAddr, buffer, buffer2);
Expand All @@ -66,31 +60,19 @@ int main(int argc, char *argv[]){

// Now setting stuff up, device has not register map, all characters are sent as is, not to a specific register address
// the trick here is to send the same stuff twice for commands and for characters just once and then a 0, which does nothing

send_command(lcd, LCD_SLAVE_ADDRESS, 0x33);

usleep(5000);

send_command(lcd, LCD_SLAVE_ADDRESS, 0x32);

usleep(5000);

send_command(lcd, LCD_SLAVE_ADDRESS, 0x28);

usleep(5000);

send_command(lcd, LCD_SLAVE_ADDRESS, 0x0C);

usleep(5000);

send_command(lcd, LCD_SLAVE_ADDRESS, 0x01);

usleep(5000);

i2cWriteByteData(lcd, LCD_SLAVE_ADDRESS, 0x08, 0x0);

//Now can start writing to the lcd screen, starting at position 0,0 first line ot the left

char message[16] = {"Jetgpio"};
char message2[16] = {" by Rubberazer"};

Expand Down
22 changes: 1 addition & 21 deletions EXAMPLES_C/lcd_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ void send_command(unsigned handle, unsigned i2cAddr, unsigned command){
buffer2 &= 0xFB;
buffer2 |= 0x08;
i2cWriteByteData(handle, i2cAddr, buffer2, 0x0);

buffer = (command & 0x0F) << 4;
buffer |= 0x04;
buffer2 = buffer;
Expand All @@ -37,18 +36,13 @@ void send_data(unsigned handle, unsigned i2cAddr, unsigned data){
buffer |= 0x05;
unsigned buffer2 = buffer;
buffer |= 0x08;
//i2cWriteByteData(handle, i2cAddr, buffer, 0);
//usleep(2000);
buffer2 &= 0xFB;
buffer2 |= 0x08;
i2cWriteByteData(handle, i2cAddr, buffer, buffer2);

buffer = (data & 0x0F) << 4;
buffer |= 0x05;
buffer2 = buffer;
buffer |= 0x08;
//i2cWriteByteData(handle, i2cAddr, buffer, 0);
//usleep(2000);
buffer2 &= 0xFB;
buffer2 |= 0x08;
i2cWriteByteData(handle, i2cAddr, buffer, buffer2);
Expand All @@ -68,31 +62,19 @@ int main(int argc, char *argv[]){

// Now setting stuff up, device has not register map, all characters are sent as is, not to a specific register address
// the trick here is to send the same stuff twice for commands and for characters just once and then a 0, which does nothing

send_command(lcd, LCD_SLAVE_ADDRESS, 0x33);

send_command(lcd, LCD_SLAVE_ADDRESS, 0x33);
usleep(5000);

send_command(lcd, LCD_SLAVE_ADDRESS, 0x32);

usleep(5000);

send_command(lcd, LCD_SLAVE_ADDRESS, 0x28);

usleep(5000);

send_command(lcd, LCD_SLAVE_ADDRESS, 0x0C);

usleep(5000);

send_command(lcd, LCD_SLAVE_ADDRESS, 0x01);

usleep(5000);

i2cWriteByteData(lcd, LCD_SLAVE_ADDRESS, 0x08, 0x0);

//Now can start writing to the lcd screen, starting at position 0,0 first line ot the left

char message[16] = {"Jetgpio"};
char message2[16] = {" by Rubberazer"};

Expand All @@ -107,11 +89,9 @@ int main(int argc, char *argv[]){
}

// Closing i2c connection

i2cClose(lcd);

// Terminating library

gpioTerminate();

exit(0);
Expand Down

0 comments on commit 26c7244

Please sign in to comment.