I can't get this task stuff working
Going to try simplify it by not using group bits
This commit is contained in:
13
main/main.c
13
main/main.c
@@ -43,6 +43,8 @@ static volatile bool run_data_collection = true;
|
||||
|
||||
// TODO - figure out how to continually call this, maybe make a task for it?
|
||||
void save_measurements() {
|
||||
TickType_t xLastWakeTime;
|
||||
xLastWakeTime = xTaskGetTickCount ();
|
||||
while (run_data_collection) {
|
||||
EventBits_t bits = xEventGroupWaitBits(
|
||||
s_monitor_event_group,
|
||||
@@ -65,13 +67,15 @@ void save_measurements() {
|
||||
// TODO
|
||||
xEventGroupClearBitsFromISR(s_monitor_event_group, SENSOR_PMS5003_BIT);
|
||||
}
|
||||
vTaskDelay(pdMS_TO_TICKS(100));
|
||||
vTaskDelayUntil(&xLastWakeTime, pdMS_TO_TICKS(100));
|
||||
}
|
||||
}
|
||||
|
||||
void read_from_pms5003() {
|
||||
BaseType_t xHigherPriorityTaskWoken, xResult;
|
||||
xHigherPriorityTaskWoken = pdFALSE;
|
||||
TickType_t xLastWakeTime;
|
||||
xLastWakeTime = xTaskGetTickCount ();
|
||||
while (run_pms5003) {
|
||||
// TODO - actually collect some data
|
||||
ESP_LOGI(TAG, "Got PMS5003 data! Setting PMS bit now!");
|
||||
@@ -79,13 +83,15 @@ void read_from_pms5003() {
|
||||
if (xResult) {
|
||||
portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
|
||||
}
|
||||
vTaskDelay(pdMS_TO_TICKS(1000)); // TODO: make this a config check
|
||||
vTaskDelayUntil(&xLastWakeTime, pdMS_TO_TICKS(1000)); // TODO: make this a config check
|
||||
}
|
||||
}
|
||||
|
||||
void read_from_dht22() {
|
||||
BaseType_t xHigherPriorityTaskWoken, xResult;
|
||||
xHigherPriorityTaskWoken = pdFALSE;
|
||||
TickType_t xLastWakeTime;
|
||||
xLastWakeTime = xTaskGetTickCount ();
|
||||
while (run_dht) {
|
||||
// Data reading is based on time, so need to block interrups etc
|
||||
portDISABLE_INTERRUPTS();
|
||||
@@ -97,7 +103,8 @@ void read_from_dht22() {
|
||||
portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
|
||||
}
|
||||
ESP_LOGI(TAG, "Hello");
|
||||
vTaskDelay(pdMS_TO_TICKS(500)); // TODO: make this a config check
|
||||
vTaskDelayUntil(&xLastWakeTime, pdMS_TO_TICKS(500)); // TODO: make this a config check
|
||||
ESP_LOGI(TAG, "hello1");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user