Sat, 13 Jun 2020 22:07:22 +0200
Added DS18B20 error counters. Bigger font for the error counters screen and added the DS18B20 counter. Patched the u8g2_esp32_hal to fix the sudden system reboots.
main/task_ds18b20.c | file | annotate | diff | comparison | revisions | |
main/task_user.c | file | annotate | diff | comparison | revisions | |
main/u8g2_esp32_hal.c | file | annotate | diff | comparison | revisions |
--- a/main/task_ds18b20.c Fri Apr 10 11:51:40 2020 +0200 +++ b/main/task_ds18b20.c Sat Jun 13 22:07:22 2020 +0200 @@ -23,6 +23,7 @@ EventGroupHandle_t xEventGroupDS18B20; ///< Events DS18B20 task DS18B20_State *ds18b20_state; ///< Public state for other tasks +extern uint32_t err_temp; const int TASK_DS18B20_REQUEST_TEMPS = BIT0; ///< Request temperature measurements const int TASK_DS18B20_REQUEST_DONE = BIT1; ///< Request is completed @@ -146,10 +147,12 @@ ds18b20_state->sensor[i].error = DS18B20_ERR_READ; // All other errors ds18b20_state->valid = false; ds18b20_state->sensor[i].temperature = 0.0; + err_temp++; } else if (readings[i] == 85.0) { // Error value ds18b20_state->sensor[i].error = DS18B20_ERR_READ; ds18b20_state->valid = false; ds18b20_state->sensor[i].temperature = 0.0; + err_temp++; } else { ds18b20_state->sensor[i].error = DS18B20_ERR_NONE; ds18b20_state->sensor[i].temperature = readings[i];
--- a/main/task_user.c Fri Apr 10 11:51:40 2020 +0200 +++ b/main/task_user.c Sat Jun 13 22:07:22 2020 +0200 @@ -30,7 +30,7 @@ char sensors[DS18B20_MAX][17]; ///< Sensors to select uint32_t err_connect = 0; ///< Connect error count uint32_t err_alarm = 0; ///< Alarm watchdog error count - +uint32_t err_temp = 0; ///< DS18B20 read errors extern const esp_app_desc_t *app_desc; ///< App description extern unit_t units[3]; ///< Pressure test units @@ -714,9 +714,15 @@ */ void screen_counters() { - screen_top("Software tellers"); - menu_line(0, 1, 25, "Network %d", err_connect); - menu_line(0, 1, 37, "Watchdog %d", err_alarm); + char buf[65]; + + screen_top("Software fouten"); + snprintf(buf, 64, "Network %4d", err_connect); + u8g2_DrawStr(&u8g2, 1, 28, buf); + snprintf(buf, 64, "Watchdog %4d", err_alarm); + u8g2_DrawStr(&u8g2, 1, 43, buf); + snprintf(buf, 64, "DS18B20 %4d", err_temp); + u8g2_DrawStr(&u8g2, 1, 59, buf); u8g2_SendBuffer(&u8g2); }
--- a/main/u8g2_esp32_hal.c Fri Apr 10 11:51:40 2020 +0200 +++ b/main/u8g2_esp32_hal.c Sat Jun 13 22:07:22 2020 +0200 @@ -10,11 +10,12 @@ #include "u8g2_esp32_hal.h" static const char *TAG = "u8g2_hal"; -static const unsigned int I2C_TIMEOUT_MS = 5000; +static const unsigned int I2C_TIMEOUT_MS = 1000; static spi_device_handle_t handle_spi; // SPI handle. static i2c_cmd_handle_t handle_i2c; // I2C handle. static u8g2_esp32_hal_t u8g2_esp32_hal; // HAL state data. +static bool initialized = false; #undef ESP_ERROR_CHECK #define ESP_ERROR_CHECK(x) do { esp_err_t rc = (x); if (rc != ESP_OK) { ESP_LOGE("err", "esp_err_t = %d", rc); assert(0 && #x);} } while(0); @@ -111,21 +112,27 @@ case U8X8_MSG_BYTE_INIT: { if (u8g2_esp32_hal.sda == U8G2_ESP32_HAL_UNDEFINED || - u8g2_esp32_hal.scl == U8G2_ESP32_HAL_UNDEFINED) { + u8g2_esp32_hal.scl == U8G2_ESP32_HAL_UNDEFINED || initialized) { // here i test if already initialized, if it's the case don't do it again! break; } i2c_config_t conf; conf.mode = I2C_MODE_MASTER; + ESP_LOGI(TAG, "sda_io_num %d", u8g2_esp32_hal.sda); conf.sda_io_num = u8g2_esp32_hal.sda; conf.sda_pullup_en = GPIO_PULLUP_ENABLE; + ESP_LOGI(TAG, "scl_io_num %d", u8g2_esp32_hal.scl); conf.scl_io_num = u8g2_esp32_hal.scl; conf.scl_pullup_en = GPIO_PULLUP_ENABLE; + ESP_LOGI(TAG, "clk_speed %d", I2C_MASTER_FREQ_HZ); conf.master.clk_speed = I2C_MASTER_FREQ_HZ; + ESP_LOGI(TAG, "i2c_param_config %d", conf.mode); ESP_ERROR_CHECK(i2c_param_config(I2C_MASTER_NUM, &conf)); + ESP_LOGI(TAG, "i2c_driver_install %d", I2C_MASTER_NUM); ESP_LOGI(TAG, "I2C gpio_sda: %d gpio_scl: %d clk_speed: %d master_num: %d", u8g2_esp32_hal.sda, u8g2_esp32_hal.scl, I2C_MASTER_FREQ_HZ, I2C_MASTER_NUM); ESP_ERROR_CHECK(i2c_driver_install(I2C_MASTER_NUM, conf.mode, I2C_MASTER_RX_BUF_DISABLE, I2C_MASTER_TX_BUF_DISABLE, 0)); + initialized=true; break; }