refactor: added gpio enumeration
This commit is contained in:
20
README.md
20
README.md
@@ -88,12 +88,12 @@ void app_main(void)
|
||||
i2c_new_master_bus(&i2c_bus_config, &i2c_bus_handle);
|
||||
esp_event_loop_create_default();
|
||||
esp_event_handler_instance_register(ZH_PCF8574, ESP_EVENT_ANY_ID, &zh_pcf8574_event_handler, NULL, NULL);
|
||||
zh_pcf8574_init_config_t pcf8574_init_config = ZH_PCF8574_INIT_CONFIG_DEFAULT();
|
||||
pcf8574_init_config.i2c_handle = i2c_bus_handle;
|
||||
pcf8574_init_config.i2c_address = 0x38;
|
||||
pcf8574_init_config.p0_gpio_work_mode = true;
|
||||
pcf8574_init_config.interrupt_gpio = GPIO_NUM_14;
|
||||
zh_pcf8574_init(&pcf8574_init_config, &pcf8574_handle);
|
||||
zh_pcf8574_init_config_t config = ZH_PCF8574_INIT_CONFIG_DEFAULT();
|
||||
config.i2c_handle = i2c_bus_handle;
|
||||
config.i2c_address = 0x38;
|
||||
config.p0_gpio_work_mode = ZH_PCF8574_GPIO_INPUT;
|
||||
config.interrupt_gpio = GPIO_NUM_14;
|
||||
zh_pcf8574_init(&config, &pcf8574_handle);
|
||||
uint8_t reg = 0;
|
||||
zh_pcf8574_read(&pcf8574_handle, ®);
|
||||
print_gpio_status("GPIO status: ", reg);
|
||||
@@ -102,13 +102,13 @@ void app_main(void)
|
||||
zh_pcf8574_read(&pcf8574_handle, ®);
|
||||
print_gpio_status("GPIO status: ", reg);
|
||||
printf("Sets P0 to 0.\n");
|
||||
zh_pcf8574_write_gpio(&pcf8574_handle, 0, false);
|
||||
zh_pcf8574_write_gpio(&pcf8574_handle, ZH_PCF8574_GPIO_NUM_P0, ZH_PCF8574_GPIO_LOW);
|
||||
bool gpio = 0;
|
||||
zh_pcf8574_read_gpio(&pcf8574_handle, 0, &gpio);
|
||||
zh_pcf8574_read_gpio(&pcf8574_handle, ZH_PCF8574_GPIO_NUM_P0, &gpio);
|
||||
printf("P0 status: %d.\n", gpio);
|
||||
printf("Set P1 to 0.\n");
|
||||
zh_pcf8574_write_gpio(&pcf8574_handle, 1, false);
|
||||
zh_pcf8574_read_gpio(&pcf8574_handle, 1, &gpio);
|
||||
zh_pcf8574_write_gpio(&pcf8574_handle, ZH_PCF8574_GPIO_NUM_P1, ZH_PCF8574_GPIO_LOW);
|
||||
zh_pcf8574_read_gpio(&pcf8574_handle, ZH_PCF8574_GPIO_NUM_P1, &gpio);
|
||||
printf("P1 status: %d.\n", gpio);
|
||||
zh_pcf8574_read(&pcf8574_handle, ®);
|
||||
print_gpio_status("GPIO status: ", reg);
|
||||
|
||||
Reference in New Issue
Block a user