main/co2meter.c

Wed, 04 Oct 2023 11:28:49 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Wed, 04 Oct 2023 11:28:49 +0200
changeset 80
715785443a95
parent 79
332e85569339
permissions
-rw-r--r--

Version 0.3.1. Remove obsolete files from spiffs filesystem. Removed obsolete wifi stations.conf file and functions. Removed obsolete user screens.

17
f9eca4a55911 More menus development.
Michiel Broek <mbroek@mbse.eu>
parents: 16
diff changeset
1 /**
f9eca4a55911 More menus development.
Michiel Broek <mbroek@mbse.eu>
parents: 16
diff changeset
2 * @file co2meter.c
f9eca4a55911 More menus development.
Michiel Broek <mbroek@mbse.eu>
parents: 16
diff changeset
3 * @brief co2meter project.
0
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 */
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 #include "config.h"
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 static const char *TAG = "co2meter";
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9
16
e38ffa806e84 Initial code for the rotary switch and some menus. Changed default pushbutton pin from 12 to 14 and swapped the rotary pins. Disabled always create a new units file, it should be safe to keep it now.
Michiel Broek <mbroek@mbse.eu>
parents: 14
diff changeset
10
21
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents: 20
diff changeset
11 const esp_app_desc_t *app_desc = NULL; ///< Application description
16
e38ffa806e84 Initial code for the rotary switch and some menus. Changed default pushbutton pin from 12 to 14 and swapped the rotary pins. Disabled always create a new units file, it should be safe to keep it now.
Michiel Broek <mbroek@mbse.eu>
parents: 14
diff changeset
12 int Main_Loop1 = ML1_INIT; ///< Loop 1 init
34
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
13 int num_sensors = 0; ///< Detected DS18B20 sensors
0
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 static TaskHandle_t xTaskDS18B20 = NULL;
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 static TaskHandle_t xTaskADC = NULL;
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 static TaskHandle_t xTaskWifi = NULL;
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 static TaskHandle_t xTaskMQTT = NULL;
21
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents: 20
diff changeset
18 static TaskHandle_t xTaskUser = NULL;
0
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19
4
2a57c466bf45 FreeRTOS scheduler from 100 Hz to 200 Hz. All units data is now protected with a semaphore.
Michiel Broek <mbroek@mbse.eu>
parents: 2
diff changeset
20 extern unit_t units[3]; ///< Pressure test units
2a57c466bf45 FreeRTOS scheduler from 100 Hz to 200 Hz. All units data is now protected with a semaphore.
Michiel Broek <mbroek@mbse.eu>
parents: 2
diff changeset
21 extern SemaphoreHandle_t xSemaphoreUnits; ///< Units lock semaphore
0
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22 extern DS18B20_State *ds18b20_state; ///< DS18B20 state
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23 extern SemaphoreHandle_t xSemaphoreDS18B20; ///< DS18B20 lock semaphore
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
24 extern ADC_State *adc_state; ///< ADC state
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25 extern SemaphoreHandle_t xSemaphoreADC; ///< ADC lock semaphore
47
1ab1f4a8c328 Version 0.2.2 Changed to use a permanent network and WiFi connection. Removed three mainloop stages. Removed MQTT sequence counter that was not used. Update WiFi rssi status during eacht measure cycle. Changed FreeRTOS schedulng to 500 Hz.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
26 extern SemaphoreHandle_t xSemaphoreWiFi;
20
7c1dacafed03 Attempt to create a rotary editor
Michiel Broek <mbroek@mbse.eu>
parents: 19
diff changeset
27 extern WIFI_State *wifi_state; ///< WiFi state
21
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents: 20
diff changeset
28 extern EventGroupHandle_t xEventGroupUser;
77
15dc572a7fcb Version 0.3.0. Backported network code from experimental roaming project. Will now connect after reset to the strongest AP. Id the signal level drops below -67, extra scans are done to see for a better AP. Nothing is done yet. Removed config.conf file, all info is taken from the project menu and live tests. Better log the board type and send it via json mqtt. Send bssid and current channel too.
Michiel Broek <mbroek@mbse.eu>
parents: 74
diff changeset
29 extern bool _wifi_ScanDone;
15dc572a7fcb Version 0.3.0. Backported network code from experimental roaming project. Will now connect after reset to the strongest AP. Id the signal level drops below -67, extra scans are done to see for a better AP. Nothing is done yet. Removed config.conf file, all info is taken from the project menu and live tests. Better log the board type and send it via json mqtt. Send bssid and current channel too.
Michiel Broek <mbroek@mbse.eu>
parents: 74
diff changeset
30 extern int8_t _wifi_RSSI;
16
e38ffa806e84 Initial code for the rotary switch and some menus. Changed default pushbutton pin from 12 to 14 and swapped the rotary pins. Disabled always create a new units file, it should be safe to keep it now.
Michiel Broek <mbroek@mbse.eu>
parents: 14
diff changeset
31 extern int count_pub; ///< Published MQTT messages in transit
78
e03d729aecb8 Changes in the main timing loop and corrected the loop time.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
32 extern uint32_t LoopTimer; ///< Loop timer
52
90a36619b07b Added screen with software error counters.
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
33 extern uint32_t err_connect; ///< Connect error counter
18
d969e0fe05dc Added splash screen and unit zero set menu.
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
34
77
15dc572a7fcb Version 0.3.0. Backported network code from experimental roaming project. Will now connect after reset to the strongest AP. Id the signal level drops below -67, extra scans are done to see for a better AP. Nothing is done yet. Removed config.conf file, all info is taken from the project menu and live tests. Better log the board type and send it via json mqtt. Send bssid and current channel too.
Michiel Broek <mbroek@mbse.eu>
parents: 74
diff changeset
35 char hostname[32];
15dc572a7fcb Version 0.3.0. Backported network code from experimental roaming project. Will now connect after reset to the strongest AP. Id the signal level drops below -67, extra scans are done to see for a better AP. Nothing is done yet. Removed config.conf file, all info is taken from the project menu and live tests. Better log the board type and send it via json mqtt. Send bssid and current channel too.
Michiel Broek <mbroek@mbse.eu>
parents: 74
diff changeset
36 char uuid[37];
15dc572a7fcb Version 0.3.0. Backported network code from experimental roaming project. Will now connect after reset to the strongest AP. Id the signal level drops below -67, extra scans are done to see for a better AP. Nothing is done yet. Removed config.conf file, all info is taken from the project menu and live tests. Better log the board type and send it via json mqtt. Send bssid and current channel too.
Michiel Broek <mbroek@mbse.eu>
parents: 74
diff changeset
37
19
4fb9ed228a23 Added code comments.
Michiel Broek <mbroek@mbse.eu>
parents: 18
diff changeset
38
57
232f318a6b51 Code cleanup, doxygen comments added.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
39 /**
232f318a6b51 Code cleanup, doxygen comments added.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
40 * @brief Main program entry
232f318a6b51 Code cleanup, doxygen comments added.
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
41 */
0
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
42 void app_main()
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
43 {
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
44 esp_err_t ret;
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
45
16
e38ffa806e84 Initial code for the rotary switch and some menus. Changed default pushbutton pin from 12 to 14 and swapped the rotary pins. Disabled always create a new units file, it should be safe to keep it now.
Michiel Broek <mbroek@mbse.eu>
parents: 14
diff changeset
46 Main_Loop1 = ML1_INIT;
77
15dc572a7fcb Version 0.3.0. Backported network code from experimental roaming project. Will now connect after reset to the strongest AP. Id the signal level drops below -67, extra scans are done to see for a better AP. Nothing is done yet. Removed config.conf file, all info is taken from the project menu and live tests. Better log the board type and send it via json mqtt. Send bssid and current channel too.
Michiel Broek <mbroek@mbse.eu>
parents: 74
diff changeset
47 app_desc = esp_app_get_description();
38
46e2c385e9de Removed all the deepsleep code since there will be no battery operation.
Michiel Broek <mbroek@mbse.eu>
parents: 37
diff changeset
48 /*
46e2c385e9de Removed all the deepsleep code since there will be no battery operation.
Michiel Broek <mbroek@mbse.eu>
parents: 37
diff changeset
49 * event handler and event group for the user interface
46e2c385e9de Removed all the deepsleep code since there will be no battery operation.
Michiel Broek <mbroek@mbse.eu>
parents: 37
diff changeset
50 */
21
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents: 20
diff changeset
51 xEventGroupUser = xEventGroupCreate();
38
46e2c385e9de Removed all the deepsleep code since there will be no battery operation.
Michiel Broek <mbroek@mbse.eu>
parents: 37
diff changeset
52 user_cold();
0
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
53
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
54 /*
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
55 * Initialize NVS
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
56 */
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
57 ret = nvs_flash_init();
77
15dc572a7fcb Version 0.3.0. Backported network code from experimental roaming project. Will now connect after reset to the strongest AP. Id the signal level drops below -67, extra scans are done to see for a better AP. Nothing is done yet. Removed config.conf file, all info is taken from the project menu and live tests. Better log the board type and send it via json mqtt. Send bssid and current channel too.
Michiel Broek <mbroek@mbse.eu>
parents: 74
diff changeset
58 if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
0
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
59 ESP_ERROR_CHECK(nvs_flash_erase());
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
60 ret = nvs_flash_init();
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
61 }
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
62 ESP_ERROR_CHECK(ret);
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
63
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
64 /*
6
06a5028dbcdf Hookup OLED I2C display to temorary display some data.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
65 * Setup SPIFFS filesystem
06a5028dbcdf Hookup OLED I2C display to temorary display some data.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
66 */
0
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
67 ESP_LOGI(TAG, "Initializing SPIFFS");
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
68 esp_vfs_spiffs_conf_t conf = {
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
69 .base_path = "/spiffs",
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
70 .partition_label = NULL,
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
71 .max_files = 5,
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
72 .format_if_mount_failed = true
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
73 };
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
74
6
06a5028dbcdf Hookup OLED I2C display to temorary display some data.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
75 /*
06a5028dbcdf Hookup OLED I2C display to temorary display some data.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
76 * Use settings defined above to initialize and mount SPIFFS filesystem.
06a5028dbcdf Hookup OLED I2C display to temorary display some data.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
77 * Note: esp_vfs_spiffs_register is an all-in-one convenience function.
06a5028dbcdf Hookup OLED I2C display to temorary display some data.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
78 */
0
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
79 ret = esp_vfs_spiffs_register(&conf);
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
80
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
81 if (ret != ESP_OK) {
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
82 if (ret == ESP_FAIL) {
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
83 ESP_LOGE(TAG, "Failed to mount or format filesystem");
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
84 } else if (ret == ESP_ERR_NOT_FOUND) {
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
85 ESP_LOGE(TAG, "Failed to find SPIFFS partition");
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
86 } else {
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
87 ESP_LOGE(TAG, "Failed to initialize SPIFFS (%d)", ret);
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
88 }
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
89 return; // Stop application.
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
90 }
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
91
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
92 size_t total = 0, used = 0;
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
93 ret = esp_spiffs_info(NULL, &total, &used);
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
94 if (ret != ESP_OK) {
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
95 ESP_LOGE(TAG, "Failed to get SPIFFS partition information");
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
96 return; // Stop application.
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
97 } else {
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
98 ESP_LOGI(TAG, "Partition size: %d, used: %d - %d%%", total, used, (used * 100) / total);
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
99 }
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
100
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
101 // Just to debug, list the /spiffs filesystem.
6
06a5028dbcdf Hookup OLED I2C display to temorary display some data.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
102 #if 0
0
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
103 DIR *dir = opendir("/spiffs");
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
104 struct dirent* de = readdir(dir);
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
105 while (de) {
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
106 if (de->d_type == DT_REG) {
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
107 printf("F ");
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
108 }
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
109 if (de->d_type == DT_DIR) {
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
110 printf("D ");
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
111 }
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
112 printf("%s\n", de->d_name);
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
113 de = readdir(dir);
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
114 }
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
115 closedir(dir);
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
116 #endif
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
117
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
118 /*
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
119 * Read or create configuration
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
120 */
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
121 read_units();
59
52d9405474e1 Better check for a corrupted units file. Added a small boot delay to prevent units file corruption.
Michiel Broek <mbroek@mbse.eu>
parents: 58
diff changeset
122 vTaskDelay(500 / portTICK_PERIOD_MS);
0
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
123
77
15dc572a7fcb Version 0.3.0. Backported network code from experimental roaming project. Will now connect after reset to the strongest AP. Id the signal level drops below -67, extra scans are done to see for a better AP. Nothing is done yet. Removed config.conf file, all info is taken from the project menu and live tests. Better log the board type and send it via json mqtt. Send bssid and current channel too.
Michiel Broek <mbroek@mbse.eu>
parents: 74
diff changeset
124 uint8_t mac_addr[8] = {0};
15dc572a7fcb Version 0.3.0. Backported network code from experimental roaming project. Will now connect after reset to the strongest AP. Id the signal level drops below -67, extra scans are done to see for a better AP. Nothing is done yet. Removed config.conf file, all info is taken from the project menu and live tests. Better log the board type and send it via json mqtt. Send bssid and current channel too.
Michiel Broek <mbroek@mbse.eu>
parents: 74
diff changeset
125 // Set the configured hostname for the dhcp client.
15dc572a7fcb Version 0.3.0. Backported network code from experimental roaming project. Will now connect after reset to the strongest AP. Id the signal level drops below -67, extra scans are done to see for a better AP. Nothing is done yet. Removed config.conf file, all info is taken from the project menu and live tests. Better log the board type and send it via json mqtt. Send bssid and current channel too.
Michiel Broek <mbroek@mbse.eu>
parents: 74
diff changeset
126 esp_efuse_mac_get_default(mac_addr);
15dc572a7fcb Version 0.3.0. Backported network code from experimental roaming project. Will now connect after reset to the strongest AP. Id the signal level drops below -67, extra scans are done to see for a better AP. Nothing is done yet. Removed config.conf file, all info is taken from the project menu and live tests. Better log the board type and send it via json mqtt. Send bssid and current channel too.
Michiel Broek <mbroek@mbse.eu>
parents: 74
diff changeset
127 sprintf(hostname, "co2meter-%02x%02x%02x", mac_addr[3], mac_addr[4], mac_addr[5]);
15dc572a7fcb Version 0.3.0. Backported network code from experimental roaming project. Will now connect after reset to the strongest AP. Id the signal level drops below -67, extra scans are done to see for a better AP. Nothing is done yet. Removed config.conf file, all info is taken from the project menu and live tests. Better log the board type and send it via json mqtt. Send bssid and current channel too.
Michiel Broek <mbroek@mbse.eu>
parents: 74
diff changeset
128 sprintf(uuid, "c0ffeeee-dead-beef-cafe-%02x%02x%02x%02x%02x%02x", mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5]);
15dc572a7fcb Version 0.3.0. Backported network code from experimental roaming project. Will now connect after reset to the strongest AP. Id the signal level drops below -67, extra scans are done to see for a better AP. Nothing is done yet. Removed config.conf file, all info is taken from the project menu and live tests. Better log the board type and send it via json mqtt. Send bssid and current channel too.
Michiel Broek <mbroek@mbse.eu>
parents: 74
diff changeset
129
6
06a5028dbcdf Hookup OLED I2C display to temorary display some data.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
130 /*
06a5028dbcdf Hookup OLED I2C display to temorary display some data.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
131 * Create FreeRTOS tasks
06a5028dbcdf Hookup OLED I2C display to temorary display some data.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
132 */
0
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
133 xSemaphoreDS18B20 = xSemaphoreCreateMutex();
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
134 xSemaphoreADC = xSemaphoreCreateMutex();
4
2a57c466bf45 FreeRTOS scheduler from 100 Hz to 200 Hz. All units data is now protected with a semaphore.
Michiel Broek <mbroek@mbse.eu>
parents: 2
diff changeset
135 xSemaphoreUnits = xSemaphoreCreateMutex();
0
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
136
26
8a3696620c0a Increaded stacksize for the user process. Implemented the network update using the proven brewboard code. Reverted the lock release and display sendbuffer lines to the previous code. The networks status screen uses the wifi lock.
Michiel Broek <mbroek@mbse.eu>
parents: 24
diff changeset
137 xTaskCreate(&task_user, "task_user", 4096, NULL,10, &xTaskUser);
0
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
138 xTaskCreate(&task_ds18b20, "task_ds18b20", 2560, NULL, 8, &xTaskDS18B20);
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
139 xTaskCreate(&task_adc, "task_adc", 2560, NULL, 8, &xTaskADC);
47
1ab1f4a8c328 Version 0.2.2 Changed to use a permanent network and WiFi connection. Removed three mainloop stages. Removed MQTT sequence counter that was not used. Update WiFi rssi status during eacht measure cycle. Changed FreeRTOS schedulng to 500 Hz.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
140 xTaskCreate(&task_mqtt, "task_mqtt", 4096, NULL, 5, &xTaskMQTT);
0
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
141 esp_log_level_set("wifi", ESP_LOG_ERROR);
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
142 xTaskCreate(&task_wifi, "task_wifi", 4096, NULL, 3, &xTaskWifi);
77
15dc572a7fcb Version 0.3.0. Backported network code from experimental roaming project. Will now connect after reset to the strongest AP. Id the signal level drops below -67, extra scans are done to see for a better AP. Nothing is done yet. Removed config.conf file, all info is taken from the project menu and live tests. Better log the board type and send it via json mqtt. Send bssid and current channel too.
Michiel Broek <mbroek@mbse.eu>
parents: 74
diff changeset
143
47
1ab1f4a8c328 Version 0.2.2 Changed to use a permanent network and WiFi connection. Removed three mainloop stages. Removed MQTT sequence counter that was not used. Update WiFi rssi status during eacht measure cycle. Changed FreeRTOS schedulng to 500 Hz.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
144 int wait = 150;
1ab1f4a8c328 Version 0.2.2 Changed to use a permanent network and WiFi connection. Removed three mainloop stages. Removed MQTT sequence counter that was not used. Update WiFi rssi status during eacht measure cycle. Changed FreeRTOS schedulng to 500 Hz.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
145 while (wait) {
77
15dc572a7fcb Version 0.3.0. Backported network code from experimental roaming project. Will now connect after reset to the strongest AP. Id the signal level drops below -67, extra scans are done to see for a better AP. Nothing is done yet. Removed config.conf file, all info is taken from the project menu and live tests. Better log the board type and send it via json mqtt. Send bssid and current channel too.
Michiel Broek <mbroek@mbse.eu>
parents: 74
diff changeset
146 vTaskDelay(100 / portTICK_PERIOD_MS);
47
1ab1f4a8c328 Version 0.2.2 Changed to use a permanent network and WiFi connection. Removed three mainloop stages. Removed MQTT sequence counter that was not used. Update WiFi rssi status during eacht measure cycle. Changed FreeRTOS schedulng to 500 Hz.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
147 if (ready_WiFi()) {
1ab1f4a8c328 Version 0.2.2 Changed to use a permanent network and WiFi connection. Removed three mainloop stages. Removed MQTT sequence counter that was not used. Update WiFi rssi status during eacht measure cycle. Changed FreeRTOS schedulng to 500 Hz.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
148 ESP_LOGI(TAG, "Online in %.1f seconds", (150 - wait) / 10.0);
1ab1f4a8c328 Version 0.2.2 Changed to use a permanent network and WiFi connection. Removed three mainloop stages. Removed MQTT sequence counter that was not used. Update WiFi rssi status during eacht measure cycle. Changed FreeRTOS schedulng to 500 Hz.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
149 wait = 0;
1ab1f4a8c328 Version 0.2.2 Changed to use a permanent network and WiFi connection. Removed three mainloop stages. Removed MQTT sequence counter that was not used. Update WiFi rssi status during eacht measure cycle. Changed FreeRTOS schedulng to 500 Hz.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
150 } else {
1ab1f4a8c328 Version 0.2.2 Changed to use a permanent network and WiFi connection. Removed three mainloop stages. Removed MQTT sequence counter that was not used. Update WiFi rssi status during eacht measure cycle. Changed FreeRTOS schedulng to 500 Hz.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
151 wait--;
1ab1f4a8c328 Version 0.2.2 Changed to use a permanent network and WiFi connection. Removed three mainloop stages. Removed MQTT sequence counter that was not used. Update WiFi rssi status during eacht measure cycle. Changed FreeRTOS schedulng to 500 Hz.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
152 if (wait < 1)
1ab1f4a8c328 Version 0.2.2 Changed to use a permanent network and WiFi connection. Removed three mainloop stages. Removed MQTT sequence counter that was not used. Update WiFi rssi status during eacht measure cycle. Changed FreeRTOS schedulng to 500 Hz.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
153 ESP_LOGE(TAG, "Timeout network connection");
1ab1f4a8c328 Version 0.2.2 Changed to use a permanent network and WiFi connection. Removed three mainloop stages. Removed MQTT sequence counter that was not used. Update WiFi rssi status during eacht measure cycle. Changed FreeRTOS schedulng to 500 Hz.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
154 }
1ab1f4a8c328 Version 0.2.2 Changed to use a permanent network and WiFi connection. Removed three mainloop stages. Removed MQTT sequence counter that was not used. Update WiFi rssi status during eacht measure cycle. Changed FreeRTOS schedulng to 500 Hz.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
155 }
0
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
156
7
6eafc4c2bf3d Sleep time is now 55 seconds. Code cleanup. Decrease MQTT library logging to Error.
Michiel Broek <mbroek@mbse.eu>
parents: 6
diff changeset
157 /*
0
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
158 * Main application loop.
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
159 */
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
160 while (1) {
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
161
37
358bbd5b608e menuconfig settings now work for I2C display setup. Lot's of code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents: 34
diff changeset
162 ESP_LOGI(TAG, "Entered Main loop");
0
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
163
21
043ae27633f8 Moved the user interface into a separate task. Added a real seconds timer to this task.
Michiel Broek <mbroek@mbse.eu>
parents: 20
diff changeset
164 /* Measure process */
0
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
165 while (1) {
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
166 switch (Main_Loop1) {
16
e38ffa806e84 Initial code for the rotary switch and some menus. Changed default pushbutton pin from 12 to 14 and swapped the rotary pins. Disabled always create a new units file, it should be safe to keep it now.
Michiel Broek <mbroek@mbse.eu>
parents: 14
diff changeset
167 case ML1_INIT:
e38ffa806e84 Initial code for the rotary switch and some menus. Changed default pushbutton pin from 12 to 14 and swapped the rotary pins. Disabled always create a new units file, it should be safe to keep it now.
Michiel Broek <mbroek@mbse.eu>
parents: 14
diff changeset
168 Main_Loop1 = ML1_CONNECT;
0
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
169 request_ds18b20();
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
170 request_adc();
78
e03d729aecb8 Changes in the main timing loop and corrected the loop time.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
171 LoopTimer = MAINLOOP_TIMER;
50
aae0056bc20b Version 0.2.3 Added WiFi reconnect.
Michiel Broek <mbroek@mbse.eu>
parents: 47
diff changeset
172 if (! ready_WiFi()) { /* If WiFi was lost, try a new connection */
aae0056bc20b Version 0.2.3 Added WiFi reconnect.
Michiel Broek <mbroek@mbse.eu>
parents: 47
diff changeset
173 ESP_LOGI(TAG, "Try WiFi restore");
aae0056bc20b Version 0.2.3 Added WiFi reconnect.
Michiel Broek <mbroek@mbse.eu>
parents: 47
diff changeset
174 request_WiFi();
52
90a36619b07b Added screen with software error counters.
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
175 err_connect++;
50
aae0056bc20b Version 0.2.3 Added WiFi reconnect.
Michiel Broek <mbroek@mbse.eu>
parents: 47
diff changeset
176 }
77
15dc572a7fcb Version 0.3.0. Backported network code from experimental roaming project. Will now connect after reset to the strongest AP. Id the signal level drops below -67, extra scans are done to see for a better AP. Nothing is done yet. Removed config.conf file, all info is taken from the project menu and live tests. Better log the board type and send it via json mqtt. Send bssid and current channel too.
Michiel Broek <mbroek@mbse.eu>
parents: 74
diff changeset
177 ESP_LOGI(TAG, "Loop => ML1_CONNECT");
0
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
178 break;
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
179
16
e38ffa806e84 Initial code for the rotary switch and some menus. Changed default pushbutton pin from 12 to 14 and swapped the rotary pins. Disabled always create a new units file, it should be safe to keep it now.
Michiel Broek <mbroek@mbse.eu>
parents: 14
diff changeset
180 case ML1_CONNECT:
20
7c1dacafed03 Attempt to create a rotary editor
Michiel Broek <mbroek@mbse.eu>
parents: 19
diff changeset
181 if (ready_WiFi()) {
16
e38ffa806e84 Initial code for the rotary switch and some menus. Changed default pushbutton pin from 12 to 14 and swapped the rotary pins. Disabled always create a new units file, it should be safe to keep it now.
Michiel Broek <mbroek@mbse.eu>
parents: 14
diff changeset
182 Main_Loop1 = ML1_MQTT_CONNECT;
22
cceb36fd3a2a Better update of the user screens. Added more internal documentation.
Michiel Broek <mbroek@mbse.eu>
parents: 21
diff changeset
183 user_refresh();
47
1ab1f4a8c328 Version 0.2.2 Changed to use a permanent network and WiFi connection. Removed three mainloop stages. Removed MQTT sequence counter that was not used. Update WiFi rssi status during eacht measure cycle. Changed FreeRTOS schedulng to 500 Hz.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
184 if (! ready_mqtt())
1ab1f4a8c328 Version 0.2.2 Changed to use a permanent network and WiFi connection. Removed three mainloop stages. Removed MQTT sequence counter that was not used. Update WiFi rssi status during eacht measure cycle. Changed FreeRTOS schedulng to 500 Hz.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
185 connect_mqtt(true);
80
715785443a95 Version 0.3.1. Remove obsolete files from spiffs filesystem. Removed obsolete wifi stations.conf file and functions. Removed obsolete user screens.
Michiel Broek <mbroek@mbse.eu>
parents: 79
diff changeset
186 ESP_LOGD(TAG, "Loop => ML1_MQTT_CONNECT");
20
7c1dacafed03 Attempt to create a rotary editor
Michiel Broek <mbroek@mbse.eu>
parents: 19
diff changeset
187 }
0
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
188 break;
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
189
16
e38ffa806e84 Initial code for the rotary switch and some menus. Changed default pushbutton pin from 12 to 14 and swapped the rotary pins. Disabled always create a new units file, it should be safe to keep it now.
Michiel Broek <mbroek@mbse.eu>
parents: 14
diff changeset
190 case ML1_MQTT_CONNECT:
0
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
191 if (ready_ds18b20() && ready_adc()) {
16
e38ffa806e84 Initial code for the rotary switch and some menus. Changed default pushbutton pin from 12 to 14 and swapped the rotary pins. Disabled always create a new units file, it should be safe to keep it now.
Michiel Broek <mbroek@mbse.eu>
parents: 14
diff changeset
192 Main_Loop1 = ML1_WAITCON;
0
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
193
31
1f507aba6561 Search DS18B20 sensor for the right pressure unit.
Michiel Broek <mbroek@mbse.eu>
parents: 28
diff changeset
194 uint32_t temp[DS18B20_MAX];
34
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
195 int state[DS18B20_MAX], i;
31
1f507aba6561 Search DS18B20 sensor for the right pressure unit.
Michiel Broek <mbroek@mbse.eu>
parents: 28
diff changeset
196 char rom_code[DS18B20_MAX][17];
1f507aba6561 Search DS18B20 sensor for the right pressure unit.
Michiel Broek <mbroek@mbse.eu>
parents: 28
diff changeset
197 for (i = 0; i < DS18B20_MAX; i++) {
1f507aba6561 Search DS18B20 sensor for the right pressure unit.
Michiel Broek <mbroek@mbse.eu>
parents: 28
diff changeset
198 temp[i] = 0;
1f507aba6561 Search DS18B20 sensor for the right pressure unit.
Michiel Broek <mbroek@mbse.eu>
parents: 28
diff changeset
199 state[i] = 0;
1f507aba6561 Search DS18B20 sensor for the right pressure unit.
Michiel Broek <mbroek@mbse.eu>
parents: 28
diff changeset
200 rom_code[i][0] = '\0';
1f507aba6561 Search DS18B20 sensor for the right pressure unit.
Michiel Broek <mbroek@mbse.eu>
parents: 28
diff changeset
201 }
1f507aba6561 Search DS18B20 sensor for the right pressure unit.
Michiel Broek <mbroek@mbse.eu>
parents: 28
diff changeset
202 /* Copy results from all connected DS18B20 sensors */
34
495b7eafbf5a Temporary white splash screen. Select DS18B20 sensor per unit. Changed units result logging
Michiel Broek <mbroek@mbse.eu>
parents: 33
diff changeset
203 num_sensors = 0;
0
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
204 if (xSemaphoreTake(xSemaphoreDS18B20, 10) == pdTRUE) {
31
1f507aba6561 Search DS18B20 sensor for the right pressure unit.
Michiel Broek <mbroek@mbse.eu>
parents: 28
diff changeset
205 num_sensors = ds18b20_state->num_sensors;
1f507aba6561 Search DS18B20 sensor for the right pressure unit.
Michiel Broek <mbroek@mbse.eu>
parents: 28
diff changeset
206 for (i = 0; i < num_sensors; i++) {
1f507aba6561 Search DS18B20 sensor for the right pressure unit.
Michiel Broek <mbroek@mbse.eu>
parents: 28
diff changeset
207 temp[i] = (ds18b20_state->sensor[i].temperature * 1000);
1f507aba6561 Search DS18B20 sensor for the right pressure unit.
Michiel Broek <mbroek@mbse.eu>
parents: 28
diff changeset
208 state[i] = (ds18b20_state->sensor[i].error == 0) ? 0:1;
1f507aba6561 Search DS18B20 sensor for the right pressure unit.
Michiel Broek <mbroek@mbse.eu>
parents: 28
diff changeset
209 strncpy(rom_code[i], ds18b20_state->sensor[i].rom_code, 17);
1f507aba6561 Search DS18B20 sensor for the right pressure unit.
Michiel Broek <mbroek@mbse.eu>
parents: 28
diff changeset
210 rom_code[i][16] = '\0';
1f507aba6561 Search DS18B20 sensor for the right pressure unit.
Michiel Broek <mbroek@mbse.eu>
parents: 28
diff changeset
211 }
0
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
212 xSemaphoreGive(xSemaphoreDS18B20);
23
58a328e91881 Added error logging for failed locks
Michiel Broek <mbroek@mbse.eu>
parents: 22
diff changeset
213 } else {
58a328e91881 Added error logging for failed locks
Michiel Broek <mbroek@mbse.eu>
parents: 22
diff changeset
214 ESP_LOGE(TAG, "ML1_MQTT_CONNECT DS18B20 lock error");
58a328e91881 Added error logging for failed locks
Michiel Broek <mbroek@mbse.eu>
parents: 22
diff changeset
215 }
6
06a5028dbcdf Hookup OLED I2C display to temorary display some data.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
216
0
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
217 /* Copy measured data and calculate results */
31
1f507aba6561 Search DS18B20 sensor for the right pressure unit.
Michiel Broek <mbroek@mbse.eu>
parents: 28
diff changeset
218 for (i = 0; i < 3; i++) {
24
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
219 if (xSemaphoreTake(xSemaphoreUnits, 25) == pdTRUE) {
31
1f507aba6561 Search DS18B20 sensor for the right pressure unit.
Michiel Broek <mbroek@mbse.eu>
parents: 28
diff changeset
220 /* Search configured temperature sensor for this unit */
1f507aba6561 Search DS18B20 sensor for the right pressure unit.
Michiel Broek <mbroek@mbse.eu>
parents: 28
diff changeset
221 for (int j = 0; j < num_sensors; j++) {
1f507aba6561 Search DS18B20 sensor for the right pressure unit.
Michiel Broek <mbroek@mbse.eu>
parents: 28
diff changeset
222 if (strcmp(rom_code[j], units[i].temperature_rom_code) == 0) {
1f507aba6561 Search DS18B20 sensor for the right pressure unit.
Michiel Broek <mbroek@mbse.eu>
parents: 28
diff changeset
223 units[i].temperature = temp[j];
1f507aba6561 Search DS18B20 sensor for the right pressure unit.
Michiel Broek <mbroek@mbse.eu>
parents: 28
diff changeset
224 units[i].temperature_state = state[j];
1f507aba6561 Search DS18B20 sensor for the right pressure unit.
Michiel Broek <mbroek@mbse.eu>
parents: 28
diff changeset
225 units[i].alarm = 0;
1f507aba6561 Search DS18B20 sensor for the right pressure unit.
Michiel Broek <mbroek@mbse.eu>
parents: 28
diff changeset
226 if (state[j])
1f507aba6561 Search DS18B20 sensor for the right pressure unit.
Michiel Broek <mbroek@mbse.eu>
parents: 28
diff changeset
227 units[i].alarm |= ALARM_SYS_TEMPERATURE & ALARM_UNIT_TEMPERATURE;
1f507aba6561 Search DS18B20 sensor for the right pressure unit.
Michiel Broek <mbroek@mbse.eu>
parents: 28
diff changeset
228 break;
1f507aba6561 Search DS18B20 sensor for the right pressure unit.
Michiel Broek <mbroek@mbse.eu>
parents: 28
diff changeset
229 }
1f507aba6561 Search DS18B20 sensor for the right pressure unit.
Michiel Broek <mbroek@mbse.eu>
parents: 28
diff changeset
230 }
24
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
231
31
1f507aba6561 Search DS18B20 sensor for the right pressure unit.
Michiel Broek <mbroek@mbse.eu>
parents: 28
diff changeset
232 /* Get the ADC results */
4
2a57c466bf45 FreeRTOS scheduler from 100 Hz to 200 Hz. All units data is now protected with a semaphore.
Michiel Broek <mbroek@mbse.eu>
parents: 2
diff changeset
233 if (xSemaphoreTake(xSemaphoreADC, 10) == pdTRUE) {
2a57c466bf45 FreeRTOS scheduler from 100 Hz to 200 Hz. All units data is now protected with a semaphore.
Michiel Broek <mbroek@mbse.eu>
parents: 2
diff changeset
234 units[i].pressure_state = adc_state->Pressure[i].error;
2a57c466bf45 FreeRTOS scheduler from 100 Hz to 200 Hz. All units data is now protected with a semaphore.
Michiel Broek <mbroek@mbse.eu>
parents: 2
diff changeset
235 units[i].pressure_channel = adc_state->Pressure[i].channel;
2a57c466bf45 FreeRTOS scheduler from 100 Hz to 200 Hz. All units data is now protected with a semaphore.
Michiel Broek <mbroek@mbse.eu>
parents: 2
diff changeset
236 units[i].pressure_voltage = adc_state->Pressure[i].voltage;
8
c6bbd1380f22 Added alarm flag for units.
Michiel Broek <mbroek@mbse.eu>
parents: 7
diff changeset
237 if (units[i].pressure_state || units[i].pressure_voltage < 80)
c6bbd1380f22 Added alarm flag for units.
Michiel Broek <mbroek@mbse.eu>
parents: 7
diff changeset
238 units[i].alarm |= ALARM_UNIT_PRESSURE;
4
2a57c466bf45 FreeRTOS scheduler from 100 Hz to 200 Hz. All units data is now protected with a semaphore.
Michiel Broek <mbroek@mbse.eu>
parents: 2
diff changeset
239 int P = (units[i].pressure_voltage / (adc_state->Batt_voltage / 1000) - units[i].pressure_zero) * 14; // in bar
2a57c466bf45 FreeRTOS scheduler from 100 Hz to 200 Hz. All units data is now protected with a semaphore.
Michiel Broek <mbroek@mbse.eu>
parents: 2
diff changeset
240 if (P < 0)
2a57c466bf45 FreeRTOS scheduler from 100 Hz to 200 Hz. All units data is now protected with a semaphore.
Michiel Broek <mbroek@mbse.eu>
parents: 2
diff changeset
241 P = 0;
2a57c466bf45 FreeRTOS scheduler from 100 Hz to 200 Hz. All units data is now protected with a semaphore.
Michiel Broek <mbroek@mbse.eu>
parents: 2
diff changeset
242 units[i].pressure = P;
74
34da2d2b12d5 Migrated to isp-idf v5.1
Michiel Broek <mbroek@mbse.eu>
parents: 59
diff changeset
243 ESP_LOGI(TAG, "%d vb:%.3f vp:%.3f zero:%lu scale:%3lu mbar:%4d alm: %lu t:%6.3f %s",
34da2d2b12d5 Migrated to isp-idf v5.1
Michiel Broek <mbroek@mbse.eu>
parents: 59
diff changeset
244 i, (adc_state->Batt_voltage / 1000.0), (units[i].pressure_voltage / 1000.0), units[i].pressure_zero,
34da2d2b12d5 Migrated to isp-idf v5.1
Michiel Broek <mbroek@mbse.eu>
parents: 59
diff changeset
245 (units[i].pressure_voltage / (adc_state->Batt_voltage / 1000) - units[i].pressure_zero), P, units[i].alarm,
34da2d2b12d5 Migrated to isp-idf v5.1
Michiel Broek <mbroek@mbse.eu>
parents: 59
diff changeset
246 (double)(units[i].temperature / 1000.0), units[i].temperature_rom_code);
4
2a57c466bf45 FreeRTOS scheduler from 100 Hz to 200 Hz. All units data is now protected with a semaphore.
Michiel Broek <mbroek@mbse.eu>
parents: 2
diff changeset
247 xSemaphoreGive(xSemaphoreADC);
23
58a328e91881 Added error logging for failed locks
Michiel Broek <mbroek@mbse.eu>
parents: 22
diff changeset
248 } else {
24
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
249 ESP_LOGE(TAG, "ML1_MQTT_CONNECT ADC[%d] lock error", i);
23
58a328e91881 Added error logging for failed locks
Michiel Broek <mbroek@mbse.eu>
parents: 22
diff changeset
250 }
24
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
251 xSemaphoreGive(xSemaphoreUnits);
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
252 } else {
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
253 ESP_LOGE(TAG, "ML1_MQTT_CONNECT units[%d] lock error", i);
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
254 }
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
255 }
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
256 if (xSemaphoreTake(xSemaphoreUnits, 25) == pdTRUE) {
4
2a57c466bf45 FreeRTOS scheduler from 100 Hz to 200 Hz. All units data is now protected with a semaphore.
Michiel Broek <mbroek@mbse.eu>
parents: 2
diff changeset
257 write_units();
2a57c466bf45 FreeRTOS scheduler from 100 Hz to 200 Hz. All units data is now protected with a semaphore.
Michiel Broek <mbroek@mbse.eu>
parents: 2
diff changeset
258 xSemaphoreGive(xSemaphoreUnits);
23
58a328e91881 Added error logging for failed locks
Michiel Broek <mbroek@mbse.eu>
parents: 22
diff changeset
259 } else {
24
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
260 ESP_LOGE(TAG, "ML1_MQTT_CONNECT write_units lock error");
0
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
261 }
24
64078aa15512 Finished the editor using the rotary switch. Added editing of the MQTT server parameters.
Michiel Broek <mbroek@mbse.eu>
parents: 23
diff changeset
262 user_refresh();
80
715785443a95 Version 0.3.1. Remove obsolete files from spiffs filesystem. Removed obsolete wifi stations.conf file and functions. Removed obsolete user screens.
Michiel Broek <mbroek@mbse.eu>
parents: 79
diff changeset
263 ESP_LOGD(TAG, "Loop => ML1_MQTT_WAITCON");
0
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
264 }
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
265 break;
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
266
16
e38ffa806e84 Initial code for the rotary switch and some menus. Changed default pushbutton pin from 12 to 14 and swapped the rotary pins. Disabled always create a new units file, it should be safe to keep it now.
Michiel Broek <mbroek@mbse.eu>
parents: 14
diff changeset
267 case ML1_WAITCON:
77
15dc572a7fcb Version 0.3.0. Backported network code from experimental roaming project. Will now connect after reset to the strongest AP. Id the signal level drops below -67, extra scans are done to see for a better AP. Nothing is done yet. Removed config.conf file, all info is taken from the project menu and live tests. Better log the board type and send it via json mqtt. Send bssid and current channel too.
Michiel Broek <mbroek@mbse.eu>
parents: 74
diff changeset
268 if (ready_mqtt()) {
16
e38ffa806e84 Initial code for the rotary switch and some menus. Changed default pushbutton pin from 12 to 14 and swapped the rotary pins. Disabled always create a new units file, it should be safe to keep it now.
Michiel Broek <mbroek@mbse.eu>
parents: 14
diff changeset
269 Main_Loop1 = ML1_SEND;
80
715785443a95 Version 0.3.1. Remove obsolete files from spiffs filesystem. Removed obsolete wifi stations.conf file and functions. Removed obsolete user screens.
Michiel Broek <mbroek@mbse.eu>
parents: 79
diff changeset
270 ESP_LOGD(TAG, "Loop => ML1_SEND");
77
15dc572a7fcb Version 0.3.0. Backported network code from experimental roaming project. Will now connect after reset to the strongest AP. Id the signal level drops below -67, extra scans are done to see for a better AP. Nothing is done yet. Removed config.conf file, all info is taken from the project menu and live tests. Better log the board type and send it via json mqtt. Send bssid and current channel too.
Michiel Broek <mbroek@mbse.eu>
parents: 74
diff changeset
271 }
0
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
272 break;
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
273
16
e38ffa806e84 Initial code for the rotary switch and some menus. Changed default pushbutton pin from 12 to 14 and swapped the rotary pins. Disabled always create a new units file, it should be safe to keep it now.
Michiel Broek <mbroek@mbse.eu>
parents: 14
diff changeset
274 case ML1_SEND:
0
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
275 publishNode();
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
276 publishUnits();
9
a85995941d0d Added publish logs. Another fix for DS18B20 rom address copy.
Michiel Broek <mbroek@mbse.eu>
parents: 8
diff changeset
277 publishLogs();
16
e38ffa806e84 Initial code for the rotary switch and some menus. Changed default pushbutton pin from 12 to 14 and swapped the rotary pins. Disabled always create a new units file, it should be safe to keep it now.
Michiel Broek <mbroek@mbse.eu>
parents: 14
diff changeset
278 Main_Loop1 = ML1_WAITACK;
80
715785443a95 Version 0.3.1. Remove obsolete files from spiffs filesystem. Removed obsolete wifi stations.conf file and functions. Removed obsolete user screens.
Michiel Broek <mbroek@mbse.eu>
parents: 79
diff changeset
279 ESP_LOGD(TAG, "Loop => ML1_WAITACK");
0
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
280 break;
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
281
16
e38ffa806e84 Initial code for the rotary switch and some menus. Changed default pushbutton pin from 12 to 14 and swapped the rotary pins. Disabled always create a new units file, it should be safe to keep it now.
Michiel Broek <mbroek@mbse.eu>
parents: 14
diff changeset
282 case ML1_WAITACK:
47
1ab1f4a8c328 Version 0.2.2 Changed to use a permanent network and WiFi connection. Removed three mainloop stages. Removed MQTT sequence counter that was not used. Update WiFi rssi status during eacht measure cycle. Changed FreeRTOS schedulng to 500 Hz.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
283 if (count_pub == 0) { // Wait until all published messages are sent.
77
15dc572a7fcb Version 0.3.0. Backported network code from experimental roaming project. Will now connect after reset to the strongest AP. Id the signal level drops below -67, extra scans are done to see for a better AP. Nothing is done yet. Removed config.conf file, all info is taken from the project menu and live tests. Better log the board type and send it via json mqtt. Send bssid and current channel too.
Michiel Broek <mbroek@mbse.eu>
parents: 74
diff changeset
284 status_WiFi();
58
e949f41034eb Lower loglevel for one message.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
285 ESP_LOGD(TAG, "Main loop: Done, user busy: %s", user_busy() ? "true":"false");
77
15dc572a7fcb Version 0.3.0. Backported network code from experimental roaming project. Will now connect after reset to the strongest AP. Id the signal level drops below -67, extra scans are done to see for a better AP. Nothing is done yet. Removed config.conf file, all info is taken from the project menu and live tests. Better log the board type and send it via json mqtt. Send bssid and current channel too.
Michiel Broek <mbroek@mbse.eu>
parents: 74
diff changeset
286 Main_Loop1 = ML1_STATUS;
47
1ab1f4a8c328 Version 0.2.2 Changed to use a permanent network and WiFi connection. Removed three mainloop stages. Removed MQTT sequence counter that was not used. Update WiFi rssi status during eacht measure cycle. Changed FreeRTOS schedulng to 500 Hz.
Michiel Broek <mbroek@mbse.eu>
parents: 38
diff changeset
287 user_refresh();
80
715785443a95 Version 0.3.1. Remove obsolete files from spiffs filesystem. Removed obsolete wifi stations.conf file and functions. Removed obsolete user screens.
Michiel Broek <mbroek@mbse.eu>
parents: 79
diff changeset
288 ESP_LOGD(TAG, "Loop => ML1_STATUS");
0
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
289 }
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
290 break;
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
291
77
15dc572a7fcb Version 0.3.0. Backported network code from experimental roaming project. Will now connect after reset to the strongest AP. Id the signal level drops below -67, extra scans are done to see for a better AP. Nothing is done yet. Removed config.conf file, all info is taken from the project menu and live tests. Better log the board type and send it via json mqtt. Send bssid and current channel too.
Michiel Broek <mbroek@mbse.eu>
parents: 74
diff changeset
292 case ML1_STATUS:
15dc572a7fcb Version 0.3.0. Backported network code from experimental roaming project. Will now connect after reset to the strongest AP. Id the signal level drops below -67, extra scans are done to see for a better AP. Nothing is done yet. Removed config.conf file, all info is taken from the project menu and live tests. Better log the board type and send it via json mqtt. Send bssid and current channel too.
Michiel Broek <mbroek@mbse.eu>
parents: 74
diff changeset
293 /*
15dc572a7fcb Version 0.3.0. Backported network code from experimental roaming project. Will now connect after reset to the strongest AP. Id the signal level drops below -67, extra scans are done to see for a better AP. Nothing is done yet. Removed config.conf file, all info is taken from the project menu and live tests. Better log the board type and send it via json mqtt. Send bssid and current channel too.
Michiel Broek <mbroek@mbse.eu>
parents: 74
diff changeset
294 * If rssi is too low, scan for beter AP.
15dc572a7fcb Version 0.3.0. Backported network code from experimental roaming project. Will now connect after reset to the strongest AP. Id the signal level drops below -67, extra scans are done to see for a better AP. Nothing is done yet. Removed config.conf file, all info is taken from the project menu and live tests. Better log the board type and send it via json mqtt. Send bssid and current channel too.
Michiel Broek <mbroek@mbse.eu>
parents: 74
diff changeset
295 */
15dc572a7fcb Version 0.3.0. Backported network code from experimental roaming project. Will now connect after reset to the strongest AP. Id the signal level drops below -67, extra scans are done to see for a better AP. Nothing is done yet. Removed config.conf file, all info is taken from the project menu and live tests. Better log the board type and send it via json mqtt. Send bssid and current channel too.
Michiel Broek <mbroek@mbse.eu>
parents: 74
diff changeset
296 if (_wifi_RSSI < CONFIG_ESP_WIFI_ROAMING_LEVEL) {
15dc572a7fcb Version 0.3.0. Backported network code from experimental roaming project. Will now connect after reset to the strongest AP. Id the signal level drops below -67, extra scans are done to see for a better AP. Nothing is done yet. Removed config.conf file, all info is taken from the project menu and live tests. Better log the board type and send it via json mqtt. Send bssid and current channel too.
Michiel Broek <mbroek@mbse.eu>
parents: 74
diff changeset
297 scan_WiFi();
15dc572a7fcb Version 0.3.0. Backported network code from experimental roaming project. Will now connect after reset to the strongest AP. Id the signal level drops below -67, extra scans are done to see for a better AP. Nothing is done yet. Removed config.conf file, all info is taken from the project menu and live tests. Better log the board type and send it via json mqtt. Send bssid and current channel too.
Michiel Broek <mbroek@mbse.eu>
parents: 74
diff changeset
298 Main_Loop1 = ML1_SCAN;
15dc572a7fcb Version 0.3.0. Backported network code from experimental roaming project. Will now connect after reset to the strongest AP. Id the signal level drops below -67, extra scans are done to see for a better AP. Nothing is done yet. Removed config.conf file, all info is taken from the project menu and live tests. Better log the board type and send it via json mqtt. Send bssid and current channel too.
Michiel Broek <mbroek@mbse.eu>
parents: 74
diff changeset
299 ESP_LOGI(TAG, "Loop => ML1_SCAN");
15dc572a7fcb Version 0.3.0. Backported network code from experimental roaming project. Will now connect after reset to the strongest AP. Id the signal level drops below -67, extra scans are done to see for a better AP. Nothing is done yet. Removed config.conf file, all info is taken from the project menu and live tests. Better log the board type and send it via json mqtt. Send bssid and current channel too.
Michiel Broek <mbroek@mbse.eu>
parents: 74
diff changeset
300 } else {
15dc572a7fcb Version 0.3.0. Backported network code from experimental roaming project. Will now connect after reset to the strongest AP. Id the signal level drops below -67, extra scans are done to see for a better AP. Nothing is done yet. Removed config.conf file, all info is taken from the project menu and live tests. Better log the board type and send it via json mqtt. Send bssid and current channel too.
Michiel Broek <mbroek@mbse.eu>
parents: 74
diff changeset
301 Main_Loop1 = ML1_DONE;
80
715785443a95 Version 0.3.1. Remove obsolete files from spiffs filesystem. Removed obsolete wifi stations.conf file and functions. Removed obsolete user screens.
Michiel Broek <mbroek@mbse.eu>
parents: 79
diff changeset
302 ESP_LOGD(TAG, "Loop => ML1_DONE");
77
15dc572a7fcb Version 0.3.0. Backported network code from experimental roaming project. Will now connect after reset to the strongest AP. Id the signal level drops below -67, extra scans are done to see for a better AP. Nothing is done yet. Removed config.conf file, all info is taken from the project menu and live tests. Better log the board type and send it via json mqtt. Send bssid and current channel too.
Michiel Broek <mbroek@mbse.eu>
parents: 74
diff changeset
303 }
15dc572a7fcb Version 0.3.0. Backported network code from experimental roaming project. Will now connect after reset to the strongest AP. Id the signal level drops below -67, extra scans are done to see for a better AP. Nothing is done yet. Removed config.conf file, all info is taken from the project menu and live tests. Better log the board type and send it via json mqtt. Send bssid and current channel too.
Michiel Broek <mbroek@mbse.eu>
parents: 74
diff changeset
304 break;
15dc572a7fcb Version 0.3.0. Backported network code from experimental roaming project. Will now connect after reset to the strongest AP. Id the signal level drops below -67, extra scans are done to see for a better AP. Nothing is done yet. Removed config.conf file, all info is taken from the project menu and live tests. Better log the board type and send it via json mqtt. Send bssid and current channel too.
Michiel Broek <mbroek@mbse.eu>
parents: 74
diff changeset
305
15dc572a7fcb Version 0.3.0. Backported network code from experimental roaming project. Will now connect after reset to the strongest AP. Id the signal level drops below -67, extra scans are done to see for a better AP. Nothing is done yet. Removed config.conf file, all info is taken from the project menu and live tests. Better log the board type and send it via json mqtt. Send bssid and current channel too.
Michiel Broek <mbroek@mbse.eu>
parents: 74
diff changeset
306 case ML1_SCAN:
15dc572a7fcb Version 0.3.0. Backported network code from experimental roaming project. Will now connect after reset to the strongest AP. Id the signal level drops below -67, extra scans are done to see for a better AP. Nothing is done yet. Removed config.conf file, all info is taken from the project menu and live tests. Better log the board type and send it via json mqtt. Send bssid and current channel too.
Michiel Broek <mbroek@mbse.eu>
parents: 74
diff changeset
307 if (_wifi_ScanDone == true) {
15dc572a7fcb Version 0.3.0. Backported network code from experimental roaming project. Will now connect after reset to the strongest AP. Id the signal level drops below -67, extra scans are done to see for a better AP. Nothing is done yet. Removed config.conf file, all info is taken from the project menu and live tests. Better log the board type and send it via json mqtt. Send bssid and current channel too.
Michiel Broek <mbroek@mbse.eu>
parents: 74
diff changeset
308 Main_Loop1 = ML1_DONE;
80
715785443a95 Version 0.3.1. Remove obsolete files from spiffs filesystem. Removed obsolete wifi stations.conf file and functions. Removed obsolete user screens.
Michiel Broek <mbroek@mbse.eu>
parents: 79
diff changeset
309 ESP_LOGD(TAG, "Loop => ML1_DONE");
77
15dc572a7fcb Version 0.3.0. Backported network code from experimental roaming project. Will now connect after reset to the strongest AP. Id the signal level drops below -67, extra scans are done to see for a better AP. Nothing is done yet. Removed config.conf file, all info is taken from the project menu and live tests. Better log the board type and send it via json mqtt. Send bssid and current channel too.
Michiel Broek <mbroek@mbse.eu>
parents: 74
diff changeset
310 }
15dc572a7fcb Version 0.3.0. Backported network code from experimental roaming project. Will now connect after reset to the strongest AP. Id the signal level drops below -67, extra scans are done to see for a better AP. Nothing is done yet. Removed config.conf file, all info is taken from the project menu and live tests. Better log the board type and send it via json mqtt. Send bssid and current channel too.
Michiel Broek <mbroek@mbse.eu>
parents: 74
diff changeset
311 break;
15dc572a7fcb Version 0.3.0. Backported network code from experimental roaming project. Will now connect after reset to the strongest AP. Id the signal level drops below -67, extra scans are done to see for a better AP. Nothing is done yet. Removed config.conf file, all info is taken from the project menu and live tests. Better log the board type and send it via json mqtt. Send bssid and current channel too.
Michiel Broek <mbroek@mbse.eu>
parents: 74
diff changeset
312
16
e38ffa806e84 Initial code for the rotary switch and some menus. Changed default pushbutton pin from 12 to 14 and swapped the rotary pins. Disabled always create a new units file, it should be safe to keep it now.
Michiel Broek <mbroek@mbse.eu>
parents: 14
diff changeset
313 case ML1_DONE:
38
46e2c385e9de Removed all the deepsleep code since there will be no battery operation.
Michiel Broek <mbroek@mbse.eu>
parents: 37
diff changeset
314 /* Wait here until the timer resets the loop */
0
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
315 break;
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
316 }
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
317 vTaskDelay(10 / portTICK_PERIOD_MS);
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
318 }
6
06a5028dbcdf Hookup OLED I2C display to temorary display some data.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
319
16
e38ffa806e84 Initial code for the rotary switch and some menus. Changed default pushbutton pin from 12 to 14 and swapped the rotary pins. Disabled always create a new units file, it should be safe to keep it now.
Michiel Broek <mbroek@mbse.eu>
parents: 14
diff changeset
320 Main_Loop1 = ML1_INIT;
0
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
321 }
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
322 }
88d965579617 Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
323

mercurial