From: jweigele Date: Thu, 11 Apr 2024 00:50:28 +0000 (-0700) Subject: configurable LED display, and select either CO2 or AQI in menuconfig X-Git-Url: http://git.hexthepla.net/?a=commitdiff_plain;h=d13ea366396fa2b67ee3cd432c44e53cea44216b;p=esp32projects configurable LED display, and select either CO2 or AQI in menuconfig --- diff --git a/aqi/main/Kconfig b/aqi/main/Kconfig index be79340..308e358 100644 --- a/aqi/main/Kconfig +++ b/aqi/main/Kconfig @@ -85,6 +85,22 @@ config LED_ENABLED default n help Gets passed and used later for includes +config LED_GPIO_CLK + int "if using LED, which pin is used for clock?" + default 0 + depends on LED_ENABLED +config LED_GPIO_DIO + int "if using LED, which pin is used for DIO?" + default 1 + depends on LED_ENABLED +config LED_AQI + bool "Display AQI over LED" + default n + depends on LED_ENABLED +config LED_CO2 + bool "Display CO2 PPM over LED" + default n + depends on LED_ENABLED config MOTION_FIRST_ENABLED bool "Are we using a PIR motion sensor (first)?" default n diff --git a/aqi/main/aqi.c b/aqi/main/aqi.c index e2873db..dc7ddf3 100644 --- a/aqi/main/aqi.c +++ b/aqi/main/aqi.c @@ -454,7 +454,7 @@ void erase_data_hook(void){ #ifdef CONFIG_LED_ENABLED void init_led(){ led = tm1637_init(LED_GPIO_CLK, LED_GPIO_DIO); - tm1637_set_brightness(led, 0x02); + tm1637_set_brightness(led, 0x07); } @@ -909,6 +909,19 @@ static void send_report_summary(report_data_t report_data){ // enforce access while making changes xSemaphoreTake(report_data.mutex, portMAX_DELAY); + +#ifdef CONFIG_LED_CO2 + ESP_LOGI(TAG, "setting led value to %d", report_data.co2_ppm); + tm1637_set_number(led, report_data.co2_ppm); +#endif +#ifdef CONFIG_LED_AQI + int aqi_int = (int)report_data.aqi; + ESP_LOGI(TAG, "setting led value to %d", aqi_int); + tm1637_set_number(led, aqi_int); + +#endif + + ESP_LOGI(TAG, "send_report_summary was called!"); cJSON *root; root = cJSON_CreateObject(); @@ -1505,11 +1518,7 @@ static void monitoring_task(void* discard) report_data.pm25 = cur_pm.pm25; report_data.aqi = set_aqi; xSemaphoreGive(report_data.mutex); -#ifdef CONFIG_LED_ENABLED - ESP_LOGI(TAG, "setting led value to %d", set_aqi); - tm1637_set_number(led, set_aqi); -#endif #ifdef CONFIG_INDICATOR_ENABLED int i = get_lookup_highest(cur_pm.pm10, cur_pm.pm25); ESP_LOGI(TAG, "setting indicator color to row %d", i); diff --git a/aqi/main/aqi.h b/aqi/main/aqi.h index 06087f0..1389310 100644 --- a/aqi/main/aqi.h +++ b/aqi/main/aqi.h @@ -119,8 +119,8 @@ static const char *TAG = "aqi"; #ifdef CONFIG_LED_ENABLED //#include "tm1637_hw.h" #include "tm1637.h" -#define LED_GPIO_CLK (GPIO_NUM_0) -#define LED_GPIO_DIO (GPIO_NUM_1) +#define LED_GPIO_CLK (CONFIG_LED_GPIO_CLK) +#define LED_GPIO_DIO (CONFIG_LED_GPIO_DIO) #endif #define MAXDEVS 1