Fleshing out some more parts

This commit is contained in:
2023-10-25 21:43:47 +01:00
parent 916e551d39
commit ce0de58466
7 changed files with 54 additions and 13 deletions

2
.gitignore vendored
View File

@@ -1,3 +1,5 @@
build/
.cache/
sdkconfig
sdkconfig.old
compile_commands.json

View File

@@ -1,6 +1,15 @@
menu "DHT22"
config DHT22_ENABLED
bool "DHT22 Enabled"
default y
config DHT22_DATA_GPIO
int "DHT22 Data GPIO Pin"
default -1
depends on DHT22_ENABLED
config DHT22_PERIOD_POLL
int "Period to poll the DHT22 in ms"
default 2000
depends on DHT22_ENABLED
endmenu

View File

@@ -0,0 +1,3 @@
idf_component_register(SRCS "pms5003.c"
INCLUDE_DIRS "."
REQUIRES driver)

View File

@@ -0,0 +1,15 @@
menu "PMS5003"
config PMS5003_ENABLED
bool "PMS5003 Enabled"
default y
config PMS5003_UART
int "PMS5003 UART Port"
default 1
depends on PMS5003_ENABLED
config PMS5003_PERIOD_POLL
int "Period to poll the PMS5003 in ms"
default 8000
depends on PMS5003_ENABLED
endmenu

View File

View File

View File

@@ -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 */
}