main/co2meter.c

changeset 7
6eafc4c2bf3d
parent 6
06a5028dbcdf
child 8
c6bbd1380f22
--- a/main/co2meter.c	Wed Oct 09 21:00:27 2019 +0200
+++ b/main/co2meter.c	Wed Oct 09 22:51:37 2019 +0200
@@ -72,7 +72,7 @@
             ESP_LOGI(TAG, "Starting from hard reset");
     }
 
-    const int wakeup_time_sec = 20;
+    const int wakeup_time_sec = 55;
     ESP_LOGI(TAG, "Enabling timer wakeup, %ds", wakeup_time_sec);
     esp_sleep_enable_timer_wakeup(wakeup_time_sec * 1000000);
 
@@ -109,11 +109,7 @@
     u8g2_esp32_hal_init(u8g2_esp32_hal);
 
     u8g2_t u8g2; // a structure which will contain all the data for one display
-    u8g2_Setup_sh1106_i2c_128x64_noname_f(
-	&u8g2,
-	U8G2_R0,
-	u8g2_esp32_i2c_byte_cb,
-	u8g2_esp32_gpio_and_delay_cb);  // init u8g2 structure
+    u8g2_Setup_sh1106_i2c_128x64_noname_f(&u8g2, U8G2_R0, u8g2_esp32_i2c_byte_cb, u8g2_esp32_gpio_and_delay_cb);  // init u8g2 structure
     u8x8_SetI2CAddress(&u8g2.u8x8, 0x78);
     ESP_LOGI(TAG, "u8g2_InitDisplay");
     u8g2_InitDisplay(&u8g2); // send init sequence to the display, display is in sleep mode after this,
@@ -203,23 +199,26 @@
     esp_log_level_set("wifi", ESP_LOG_ERROR);
     xTaskCreate(&task_wifi,    "task_wifi",     4096, NULL, 3, &xTaskWifi);
     vTaskDelay(10 / portTICK_PERIOD_MS);
+    esp_log_level_set("MQTT_CLIENT", ESP_LOG_ERROR);
     xTaskCreate(&task_mqtt,    "task_mqtt",     4096, NULL, 5, &xTaskMQTT);
 
-    // esp32-rotary-encoder requires that the GPIO ISR service is installed before calling rotary_encoder_register()
-//    ESP_ERROR_CHECK(gpio_install_isr_service(0));
-
-    // Initialise the rotary encoder device with the GPIOs for A and B signals
-//    rotary_encoder_info_t info = { 0 };
-//    ESP_ERROR_CHECK(rotary_encoder_init(&info, ROT_ENC_A_GPIO, ROT_ENC_B_GPIO));
-//    ESP_ERROR_CHECK(rotary_encoder_enable_half_steps(&info, ENABLE_HALF_STEPS));
+    /*
+     * Setup the Rotary Encoder.
+     * esp32-rotary-encoder requires that the GPIO ISR service is 
+     * installed before calling rotary_encoder_register()
+     */
+    ESP_ERROR_CHECK(gpio_install_isr_service(0));
+    rotary_encoder_info_t rinfo = { 0 };
+    ESP_ERROR_CHECK(rotary_encoder_init(&rinfo, ROT_ENC_A_GPIO, ROT_ENC_B_GPIO));
+//    ESP_ERROR_CHECK(rotary_encoder_enable_half_steps(&rinfo, ENABLE_HALF_STEPS));
 #ifdef FLIP_DIRECTION
-//    ESP_ERROR_CHECK(rotary_encoder_flip_direction(&info));
+//    ESP_ERROR_CHECK(rotary_encoder_flip_direction(&rinfo));
 #endif
 
     // Create a queue for events from the rotary encoder driver.
     // Tasks can read from this queue to receive up to date position information.
 //    QueueHandle_t event_queue = rotary_encoder_create_queue();
-//    ESP_ERROR_CHECK(rotary_encoder_set_queue(&info, event_queue));
+//    ESP_ERROR_CHECK(rotary_encoder_set_queue(&rinfo, event_queue));
 
 
     /*

mercurial