Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
68ee6431fc | |||
eee073c742 | |||
5e492f9304 |
@@ -89,7 +89,7 @@ void app_main(void)
|
|||||||
#else
|
#else
|
||||||
pcf8574_init_config.i2c_handle = i2c_bus_handle;
|
pcf8574_init_config.i2c_handle = i2c_bus_handle;
|
||||||
#endif
|
#endif
|
||||||
pcf8574_init_config.i2c_address = 0x38;
|
pcf8574_init_config.i2c_address = 0x27;
|
||||||
zh_pcf8574_init(&pcf8574_init_config, &lcd_1602a_handle);
|
zh_pcf8574_init(&pcf8574_init_config, &lcd_1602a_handle);
|
||||||
zh_1602a_init(&lcd_1602a_handle);
|
zh_1602a_init(&lcd_1602a_handle);
|
||||||
for (;;)
|
for (;;)
|
||||||
@@ -107,6 +107,7 @@ void app_main(void)
|
|||||||
zh_1602a_print_int(&lcd_1602a_handle, i);
|
zh_1602a_print_int(&lcd_1602a_handle, i);
|
||||||
zh_1602a_print_char(&lcd_1602a_handle, "%");
|
zh_1602a_print_char(&lcd_1602a_handle, "%");
|
||||||
zh_1602a_print_progress_bar(&lcd_1602a_handle, 1, i);
|
zh_1602a_print_progress_bar(&lcd_1602a_handle, 1, i);
|
||||||
|
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||||
}
|
}
|
||||||
vTaskDelay(5000 / portTICK_PERIOD_MS);
|
vTaskDelay(5000 / portTICK_PERIOD_MS);
|
||||||
zh_1602a_lcd_clear(&lcd_1602a_handle);
|
zh_1602a_lcd_clear(&lcd_1602a_handle);
|
||||||
|
@@ -1 +1 @@
|
|||||||
1.0.0
|
1.0.2
|
@@ -14,11 +14,17 @@ static const char *TAG = "zh_1602a_i2c";
|
|||||||
return err; \
|
return err; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_IDF_TARGET_ESP8266
|
||||||
|
#define esp_delay_us(x) os_delay_us(x)
|
||||||
|
#else
|
||||||
|
#define esp_delay_us(x) esp_rom_delay_us(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
#define LCD_1602A_PULSE \
|
#define LCD_1602A_PULSE \
|
||||||
zh_pcf8574_write_gpio(handle, 2, true); \
|
zh_pcf8574_write_gpio(handle, 2, true); \
|
||||||
vTaskDelay(10 / portTICK_PERIOD_MS); \
|
esp_delay_us(300); \
|
||||||
zh_pcf8574_write_gpio(handle, 2, false); \
|
zh_pcf8574_write_gpio(handle, 2, false); \
|
||||||
vTaskDelay(10 / portTICK_PERIOD_MS);
|
esp_delay_us(400);
|
||||||
|
|
||||||
static void _zh_1602a_lcd_init(zh_pcf8574_handle_t *handle);
|
static void _zh_1602a_lcd_init(zh_pcf8574_handle_t *handle);
|
||||||
static void _zh_1602a_send_command(zh_pcf8574_handle_t *handle, uint8_t command);
|
static void _zh_1602a_send_command(zh_pcf8574_handle_t *handle, uint8_t command);
|
||||||
@@ -150,16 +156,16 @@ static void _zh_1602a_lcd_init(zh_pcf8574_handle_t *handle)
|
|||||||
|
|
||||||
static void _zh_1602a_send_command(zh_pcf8574_handle_t *handle, uint8_t command)
|
static void _zh_1602a_send_command(zh_pcf8574_handle_t *handle, uint8_t command)
|
||||||
{
|
{
|
||||||
zh_pcf8574_write(handle, (command & 0xF0));
|
zh_pcf8574_write(handle, (command & 0xF0) | 0x08);
|
||||||
LCD_1602A_PULSE;
|
LCD_1602A_PULSE;
|
||||||
zh_pcf8574_write(handle, command << 4);
|
zh_pcf8574_write(handle, (command << 4) | 0x08);
|
||||||
LCD_1602A_PULSE;
|
LCD_1602A_PULSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _zh_1602a_send_data(zh_pcf8574_handle_t *handle, uint8_t data)
|
static void _zh_1602a_send_data(zh_pcf8574_handle_t *handle, uint8_t data)
|
||||||
{
|
{
|
||||||
zh_pcf8574_write(handle, (data & 0xF0) | 0x01);
|
zh_pcf8574_write(handle, (data & 0xF0) | 0x09);
|
||||||
LCD_1602A_PULSE;
|
LCD_1602A_PULSE;
|
||||||
zh_pcf8574_write(handle, (data << 4) | 0x01);
|
zh_pcf8574_write(handle, (data << 4) | 0x09);
|
||||||
LCD_1602A_PULSE;
|
LCD_1602A_PULSE;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user