wip:
This commit is contained in:
@@ -52,10 +52,13 @@ void app_main(void)
|
||||
encoder_init_config.a_gpio_number = GPIO_NUM_27;
|
||||
encoder_init_config.b_gpio_number = GPIO_NUM_26;
|
||||
// encoder_init_config.encoder_min_value = -10; // Just for example.
|
||||
// encoder_init_config.encoder_max_value = 10; // Just for example.
|
||||
// encoder_init_config.encoder_max_value = 20; // Just for example.
|
||||
// encoder_init_config.encoder_step = 0.1; // Just for example.
|
||||
encoder_init_config.encoder_number = 1;
|
||||
zh_encoder_init(&encoder_init_config, &encoder_handle);
|
||||
double position = 0;
|
||||
zh_encoder_get(&encoder_handle, &position);
|
||||
printf("Encoder position %0.2f.\n", position); // For ESP8266 first disable "Component config -> Newlib -> Enable ‘nano’ formatting options for printf/scanf family" via menuconfig.
|
||||
// zh_encoder_set(&encoder_handle, 5); // Just for example.
|
||||
// zh_encoder_reset(&encoder_handle); // Just for example.
|
||||
}
|
||||
@@ -63,6 +66,6 @@ void app_main(void)
|
||||
void zh_encoder_event_handler(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data)
|
||||
{
|
||||
zh_encoder_event_on_isr_t *event = event_data;
|
||||
printf("Encoder number %d position %.2f.\n", event->encoder_number, event->encoder_position);
|
||||
printf("Encoder number %d position %.2f.\n", event->encoder_number, event->encoder_position); // For ESP8266 first disable "Component config -> Newlib -> Enable ‘nano’ formatting options for printf/scanf family" via menuconfig.
|
||||
}
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user