Fleshing out some more parts
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,3 +1,5 @@
|
|||||||
build/
|
build/
|
||||||
|
.cache/
|
||||||
sdkconfig
|
sdkconfig
|
||||||
sdkconfig.old
|
sdkconfig.old
|
||||||
|
compile_commands.json
|
||||||
|
|||||||
@@ -1,6 +1,15 @@
|
|||||||
menu "DHT22"
|
menu "DHT22"
|
||||||
|
config DHT22_ENABLED
|
||||||
|
bool "DHT22 Enabled"
|
||||||
|
default y
|
||||||
|
|
||||||
config DHT22_DATA_GPIO
|
config DHT22_DATA_GPIO
|
||||||
int "DHT22 Data GPIO Pin"
|
int "DHT22 Data GPIO Pin"
|
||||||
default -1
|
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
|
endmenu
|
||||||
3
components/pms5003/CMakeLists.txt
Normal file
3
components/pms5003/CMakeLists.txt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
idf_component_register(SRCS "pms5003.c"
|
||||||
|
INCLUDE_DIRS "."
|
||||||
|
REQUIRES driver)
|
||||||
15
components/pms5003/Kconfig.projbuild
Normal file
15
components/pms5003/Kconfig.projbuild
Normal 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
|
||||||
0
components/pms5003/pms5003.c
Normal file
0
components/pms5003/pms5003.c
Normal file
0
components/pms5003/pms5003.h
Normal file
0
components/pms5003/pms5003.h
Normal file
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_dht = true;
|
||||||
static volatile bool run_pms5003 = 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
|
void
|
||||||
read_from_pms5003()
|
read_from_pms5003()
|
||||||
{
|
{
|
||||||
TickType_t xLastWakeTime;
|
|
||||||
xLastWakeTime = xTaskGetTickCount();
|
|
||||||
while (run_pms5003) {
|
while (run_pms5003) {
|
||||||
// TODO - actually collect some data
|
// TODO: actually collect some data
|
||||||
ESP_LOGI(TAG, "Got PMS5003 data!");
|
ESP_LOGI(TAG, "Got PMS5003 data!");
|
||||||
vTaskDelayUntil(&xLastWakeTime,
|
// TODO: Write the data out somewhere
|
||||||
pdMS_TO_TICKS(1000)); // TODO: make this a config check
|
vTaskDelay(pdMS_TO_TICKS(CONFIG_PMS5003_PERIOD_POLL));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif /* CONFIG_PMS5003_ENABLED */
|
||||||
|
|
||||||
|
#ifdef CONFIG_DHT22_ENABLED
|
||||||
|
#include "dht22.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
read_from_dht22()
|
read_from_dht22()
|
||||||
{
|
{
|
||||||
TickType_t xLastWakeTime;
|
|
||||||
xLastWakeTime = xTaskGetTickCount();
|
|
||||||
|
|
||||||
while (run_dht) {
|
while (run_dht) {
|
||||||
// Data reading is based on time, so need to block interrups etc
|
// Data reading is based on time, so need to block interrups etc
|
||||||
portDISABLE_INTERRUPTS();
|
portDISABLE_INTERRUPTS();
|
||||||
int ret = dht22_read();
|
int ret = dht22_read();
|
||||||
portENABLE_INTERRUPTS();
|
portENABLE_INTERRUPTS();
|
||||||
ESP_LOGI(TAG, "Got DHT22 data!");
|
ESP_LOGI(TAG, "Got DHT22 data!");
|
||||||
//vTaskDelayUntil(&xLastWakeTime,
|
// TODO: Write the data out somewhere - into RAM maybe?
|
||||||
// pdMS_TO_TICKS(500)); // TODO: make this a config check
|
vTaskDelay(pdMS_TO_TICKS(CONFIG_DHT22_PERIOD_POLL));
|
||||||
vTaskDelay(pdMS_TO_TICKS(500));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif /* CONFIG DHT22_ENABLED */
|
||||||
|
|
||||||
void
|
void
|
||||||
app_main(void)
|
app_main(void)
|
||||||
@@ -62,17 +67,24 @@ app_main(void)
|
|||||||
}
|
}
|
||||||
ESP_ERROR_CHECK(ret);
|
ESP_ERROR_CHECK(ret);
|
||||||
|
|
||||||
|
#ifdef CONFIG_DHT22_ENABLED
|
||||||
xTaskCreate(read_from_dht22,
|
xTaskCreate(read_from_dht22,
|
||||||
"DHT22",
|
"DHT22",
|
||||||
4 * 1024, // honestly I have _no_ idea
|
4 * 1024, // honestly I have _no_ idea
|
||||||
NULL,
|
NULL,
|
||||||
5, // no idea either
|
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,
|
xTaskCreate(read_from_pms5003,
|
||||||
"PMS5003",
|
"PMS5003",
|
||||||
4 * 1024, // honestly I have _no_ idea
|
4 * 1024, // honestly I have _no_ idea
|
||||||
NULL,
|
NULL,
|
||||||
5, // no idea either
|
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