configurable LED display, and select either CO2 or AQI in menuconfig
authorjweigele <jweigele@local>
Thu, 11 Apr 2024 00:50:28 +0000 (17:50 -0700)
committerjweigele <jweigele@local>
Thu, 11 Apr 2024 00:50:28 +0000 (17:50 -0700)
aqi/main/Kconfig
aqi/main/aqi.c
aqi/main/aqi.h

index be793409dec8059e05a9a72d620e0d3e329209fb..308e35817821590bc90e546b0561fb6ee2c25638 100644 (file)
@@ -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
index e2873db2e505f5f910fac4d63bdd3cdf17f92ad7..dc7ddf3dda742a05678c32b833f5207505f439aa 100644 (file)
@@ -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);
index 06087f078c0483a93d6f10808d2c6fb93d840494..138931079b3283b51032f23bb363f92e375fa43a 100644 (file)
@@ -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