Fleshing out some more parts
This commit is contained in:
38
main/main.c
38
main/main.c
@@ -20,36 +20,41 @@ static const char* TAG = "YASPAM";
|
||||
static volatile bool run_dht = true;
|
||||
static volatile bool run_pms5003 = true;
|
||||
|
||||
static TaskHandle_t dht22_handle;
|
||||
static TaskHandle_t pms5003_handle;
|
||||
|
||||
#ifdef CONFIG_PMS5003_ENABLED
|
||||
#include "pms5003.h"
|
||||
|
||||
void
|
||||
read_from_pms5003()
|
||||
{
|
||||
TickType_t xLastWakeTime;
|
||||
xLastWakeTime = xTaskGetTickCount();
|
||||
while (run_pms5003) {
|
||||
// TODO - actually collect some data
|
||||
// TODO: actually collect some data
|
||||
ESP_LOGI(TAG, "Got PMS5003 data!");
|
||||
vTaskDelayUntil(&xLastWakeTime,
|
||||
pdMS_TO_TICKS(1000)); // TODO: make this a config check
|
||||
// TODO: Write the data out somewhere
|
||||
vTaskDelay(pdMS_TO_TICKS(CONFIG_PMS5003_PERIOD_POLL));
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_PMS5003_ENABLED */
|
||||
|
||||
#ifdef CONFIG_DHT22_ENABLED
|
||||
#include "dht22.h"
|
||||
|
||||
void
|
||||
read_from_dht22()
|
||||
{
|
||||
TickType_t xLastWakeTime;
|
||||
xLastWakeTime = xTaskGetTickCount();
|
||||
|
||||
while (run_dht) {
|
||||
// Data reading is based on time, so need to block interrups etc
|
||||
portDISABLE_INTERRUPTS();
|
||||
int ret = dht22_read();
|
||||
portENABLE_INTERRUPTS();
|
||||
ESP_LOGI(TAG, "Got DHT22 data!");
|
||||
//vTaskDelayUntil(&xLastWakeTime,
|
||||
// pdMS_TO_TICKS(500)); // TODO: make this a config check
|
||||
vTaskDelay(pdMS_TO_TICKS(500));
|
||||
// TODO: Write the data out somewhere - into RAM maybe?
|
||||
vTaskDelay(pdMS_TO_TICKS(CONFIG_DHT22_PERIOD_POLL));
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG DHT22_ENABLED */
|
||||
|
||||
void
|
||||
app_main(void)
|
||||
@@ -62,17 +67,24 @@ app_main(void)
|
||||
}
|
||||
ESP_ERROR_CHECK(ret);
|
||||
|
||||
#ifdef CONFIG_DHT22_ENABLED
|
||||
xTaskCreate(read_from_dht22,
|
||||
"DHT22",
|
||||
4 * 1024, // honestly I have _no_ idea
|
||||
NULL,
|
||||
5, // no idea either
|
||||
NULL); // will probably change this so that I can cancel the delay
|
||||
&dht22_handle);
|
||||
|
||||
#endif /* CONFIG_DHT22_ENABLED */
|
||||
|
||||
#ifdef CONFIG_PMS5003_ENABLED
|
||||
|
||||
xTaskCreate(read_from_pms5003,
|
||||
"PMS5003",
|
||||
4 * 1024, // honestly I have _no_ idea
|
||||
NULL,
|
||||
5, // no idea either
|
||||
NULL); // will probably change this so that I can cancel the delay
|
||||
&pms5003_handle);
|
||||
|
||||
#endif /* CONFIG_PMS5003_ENABLED */
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user