Skip to content

Commit

Permalink
fix commands to work with lcd v1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
devbis committed Oct 19, 2023
1 parent 56f1686 commit f34cc64
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 27 deletions.
4 changes: 2 additions & 2 deletions src/app_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
_attribute_data_retention_ bool i2c_sending;

void init_i2c(){
i2c_gpio_set(I2C_GPIO_GROUP_C2C3);
i2c_master_init((u8)(CLOCK_SYS_CLOCK_HZ/(4*400000)) );
i2c_gpio_set(I2C_GPIO_GROUP);
drv_i2c_master_init(I2C_CLOCK);
}

void send_i2c(u8 device_id, const u8 *buffer, int dataLen){
Expand Down
13 changes: 2 additions & 11 deletions src/board_8258_03mmc.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,8 @@ extern "C" {
#define PA6_INPUT_ENABLE 1
#define PULL_WAKEUP_SRC_PA6 PM_PIN_PULLUP_1M

// LED
// #define LED1 GPIO_PD3
// #define LED1 GPIO_PD3
// #define PD3_FUNC AS_GPIO
// #define PD3_OUTPUT_ENABLE 1
// #define PD3_INPUT_ENABLE 0

// #define LED3 GPIO_PD4
// #define PD4_FUNC AS_GPIO
// #define PD4_OUTPUT_ENABLE 1
// #define PD4_INPUT_ENABLE 0
#define I2C_CLOCK 100000
#define I2C_GPIO_GROUP I2C_GPIO_GROUP_C2C3

#define PM_WAKEUP_LEVEL PM_WAKEUP_LEVEL_LOW

Expand Down
18 changes: 4 additions & 14 deletions src/lcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,9 @@ void init_lcd(bool clear){
init_lcd_deepsleep();

}else if(lcd_version == 2){// B1.9 Hardware
send_i2c(i2c_address_lcd,(u8 *)0xEA, 1);
sleep_us(240);
send_i2c(i2c_address_lcd, (u8 *)0xA4, 1);
send_i2c(i2c_address_lcd, (u8 *)0x9c, 1);
send_i2c(i2c_address_lcd, (u8 *)0xac, 1);
send_i2c(i2c_address_lcd, (u8 *)0xbc, 1);
send_i2c(i2c_address_lcd, (u8 *)0xf0, 1);
send_i2c(i2c_address_lcd, (u8 *)0xfc, 1);

u8 lcd_3E_init_segments[] = {0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
u8 lcd_3E_init_segments[] = {0xEA, 0xA4, 0xac, 0xbc, 0xf0,0xfc,0xc8,0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
send_i2c(i2c_address_lcd,lcd_3E_init_segments, sizeof(lcd_3E_init_segments));
send_i2c(i2c_address_lcd,lcd_3E_init_segments, sizeof(lcd_3E_init_segments));

send_i2c(i2c_address_lcd, (u8 *)0xc8, 1);
return;
}
if (clear)
Expand Down Expand Up @@ -130,7 +120,7 @@ void send_to_lcd_long(u8 byte1, u8 byte2, u8 byte3, u8 byte4, u8 byte5, u8 byte6
}else if(lcd_version == 1){// B1.6 Hardware
uart_send_lcd(byte1,byte2,byte3,byte4,byte5,byte6);
}else if(lcd_version == 2){// B1.9 Hardware
u8 lcd_set_segments[] = {0x04,reverse(byte1),reverse(byte2),0x00,0x00,reverse(byte3),reverse(byte4),0x00,0x00,reverse(byte5),reverse(byte6)};
u8 lcd_set_segments[] = {0x04,reverse(byte1),reverse(byte2),0x00,0x00,reverse(byte3),reverse(byte4),0x00,0x00,reverse(byte5),reverse(byte6), 0xc8};
send_i2c(i2c_address_lcd,lcd_set_segments, sizeof(lcd_set_segments));
}
}
Expand All @@ -142,7 +132,7 @@ void send_to_lcd(u8 byte1, u8 byte2, u8 byte3, u8 byte4, u8 byte5, u8 byte6){
}else if(lcd_version == 1){// B1.6 Hardware
uart_send_lcd(byte1,byte2,byte3,byte4,byte5,byte6);
}else if(lcd_version == 2){// B1.9 Hardware
u8 lcd_set_segments[] = {0x04,reverse(byte1),reverse(byte2),0x00,0x00,reverse(byte3),reverse(byte4),0x00,0x00,reverse(byte5),reverse(byte6)};
u8 lcd_set_segments[] = {0x04,reverse(byte1),reverse(byte2),0x00,0x00,reverse(byte3),reverse(byte4),0x00,0x00,reverse(byte5),reverse(byte6), 0xc8};
send_i2c(i2c_address_lcd,lcd_set_segments, sizeof(lcd_set_segments));
}
}
Expand Down

0 comments on commit f34cc64

Please sign in to comment.