Migrated ADC converter to isp-idf v5.1

Tue, 26 Sep 2023 14:56:04 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Tue, 26 Sep 2023 14:56:04 +0200
changeset 71
995557380e5f
parent 70
e82bb707c671
child 72
acc1904cd70d

Migrated ADC converter to isp-idf v5.1

main/task_user.c file | annotate | diff | comparison | revisions
--- a/main/task_user.c	Tue Sep 26 14:51:37 2023 +0200
+++ b/main/task_user.c	Tue Sep 26 14:56:04 2023 +0200
@@ -21,12 +21,12 @@
 rotary_encoder_info_t			rinfo = { 0 };			///< Rotary encoder record
 rotary_encoder_event_t			event = { 0 };			///< Rotary encoder events
 QueueHandle_t				event_queue;			///< Events queue
-static xQueueHandle                     gpio_evt_queue = NULL;          ///< Rotary pushbutton queue
+QueueHandle_t				gpio_evt_queue = NULL;		///< Rotary pushbutton queue
 static int				PushDuration = 0;		///< Duration of the pushed button
-struct strStations			APs[10];			///< List of APs we know
+wifiStation_t				APs[10];			///< List of APs we know
 int					edit_ssid = 0;			///< SSID being edited
 int					num_ssids = 0;			///< Number of SSIDs we know
-struct strStations			editAP;				///< Data of station to edit
+wifiStation_t				editAP;				///< Data of station to edit
 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
@@ -45,6 +45,8 @@
 extern int				Main_Loop1;			///< Main measure loop
 extern int				update_running;			///< If update is running
 extern int				num_sensors;			///< Detected DS18B20 sensors
+extern strConfig_t			config;
+extern wifiStation_t			wifiStation;
 
 const int TASK_USER_COLD = BIT0;					///< System cold start
 const int TASK_USER_WAKEUP = BIT1;					///< System wakeup from deepsleep
@@ -550,14 +552,14 @@
 void screen_list_aps(int sub, int offset)
 {
     int			i;
-    struct strStations	ap;
+    wifiStation_t	ap;
     uint8_t		*dst = (uint8_t *)&ap;
     FILE		*f;
     size_t		bytes;
 
     num_ssids = 0;
     memset(dst, 0, sizeof(ap));
-    f = fopen("/spiffs/etc/stations.conf", "r+");
+    f = fopen("/spiffs/stations.conf", "r");
     if (f) {
 	while (1) {
 	    bytes = fread(dst, 1, sizeof(ap), f);
@@ -717,11 +719,11 @@
     char        buf[65];
 
     screen_top("Software fouten");
-    snprintf(buf, 64, "Network  %4d", err_connect);
+    snprintf(buf, 64, "Network  %4lu", err_connect);
     u8g2_DrawStr(&u8g2, 1, 28, buf);
-    snprintf(buf, 64, "Watchdog %4d", err_alarm);
+    snprintf(buf, 64, "Watchdog %4lu", err_alarm);
     u8g2_DrawStr(&u8g2, 1, 43, buf);
-    snprintf(buf, 64, "DS18B20  %4d", err_temp);
+    snprintf(buf, 64, "DS18B20  %4lu", err_temp);
     u8g2_DrawStr(&u8g2, 1, 59, buf);
     u8g2_SendBuffer(&u8g2);
 }
@@ -761,7 +763,7 @@
 		    }
 		}
 	    } else {
-            	ESP_LOGE(TAG, "GPIO[%d] unknown intr, val: %d", io_num, gpio_get_level(io_num));
+            	ESP_LOGE(TAG, "GPIO[%lu] unknown intr, val: %d", io_num, gpio_get_level(io_num));
 	    }
 	    UserTimer = INACTIVITY;
         }
@@ -1010,7 +1012,7 @@
 				    screen_network_setup(SubMenu);
 				break;
 	default:
-				ESP_LOGI(TAG, "Event: position %d, direction %s", event.state.position,
+				ESP_LOGI(TAG, "Event: position %ld, direction %s", event.state.position,
 				    event.state.direction ? (event.state.direction == ROTARY_ENCODER_DIRECTION_CLOCKWISE ? "CW":"CCW"):"NOT_SET");
     }
 }
@@ -1079,7 +1081,7 @@
 			if (adc_state->Pressure[idx].voltage > 165 && adc_state->Pressure[idx].voltage < 660) {
 			    units[idx].pressure_zero = adc_state->Pressure[idx].voltage / (adc_state->Batt_voltage / 1000);
 			    write_units();
-			    ESP_LOGI(TAG, "Zero set unit %d, %d mV set %d", idx, adc_state->Pressure[idx].voltage, units[idx].pressure_zero);
+			    ESP_LOGI(TAG, "Zero set unit %d, %lu mV set %lu", idx, adc_state->Pressure[idx].voltage, units[idx].pressure_zero);
 		    	}
 			xSemaphoreGive(xSemaphoreADC);
 			xSemaphoreGive(xSemaphoreUnits);
@@ -1150,6 +1152,7 @@
 		break;
 
 	case ML2_EDIT_AP:
+		ESP_LOGI(TAG, " ML2_EDIT_AP: SubMenu %d  edit_ssid %d", SubMenu, edit_ssid);
 		if (SubMenu == 0) {
 		    rotary_editer("SSID", editAP.SSID, "", 16, EDIT_TYPE_TEXT);
 		    screen_edit_ap(SubMenu);
@@ -1158,23 +1161,11 @@
                     screen_edit_ap(SubMenu);
 		} else if (SubMenu == 2 || SubMenu == 3) {
 		    update_running = 1; // Block measurements
-		    int timeout = 600;
 		    if (edit_ssid < 0)
                         New_Loop2 = ML2_SETUP_WIFI;
                     else
                         New_Loop2 = ML2_LIST_APS;
 
-    		    for (;;) {
-        		vTaskDelay(100 / portTICK_PERIOD_MS);
-        		if (Main_Loop1 == ML1_DONE)
-        		    break;
-        		if (timeout)
-        		    timeout--;
-        		else {
-        		    ESP_LOGE(TAG, "Timout request stop");
-        		    goto saveerr;
-        		}
-    		    }
 		    if (edit_ssid >= 0) {
 			ESP_LOGI(TAG, "Remove %s", APs[edit_ssid].SSID);
                     	remove_station((uint8_t *)APs[edit_ssid].SSID);
@@ -1184,7 +1175,6 @@
 		    	add_station((uint8_t *)editAP.SSID, (uint8_t *)editAP.Password);
 		    }
 		}
-saveerr:
 		update_running = 0;
 		break;
 
@@ -1272,7 +1262,7 @@
     ESP_ERROR_CHECK(rotary_encoder_enable_half_steps(&rinfo, false));
 
     gpio_config_t io_conf;
-    io_conf.intr_type = GPIO_PIN_INTR_ANYEDGE;
+    io_conf.intr_type = GPIO_INTR_ANYEDGE;
     io_conf.pin_bit_mask = (1ULL << ROT_ENC_SW_GPIO);
     io_conf.mode = GPIO_MODE_INPUT;
     gpio_config(&io_conf);

mercurial