mirror of
https://github.com/alexandrebobkov/ESP-Nodes.git
synced 2025-08-08 03:22:21 +00:00
.
This commit is contained in:
@@ -48,6 +48,9 @@ static const char *TAG = "ESP32-Nodes Rainmaker Switch";
|
||||
static float a_light;
|
||||
static TimerHandle_t sensor_timer;
|
||||
|
||||
/*
|
||||
* AMBIENT LIGHT SENSOR FUNCTIONS
|
||||
*/
|
||||
static void light_sensor_init(void) {
|
||||
ESP_LOGI(TAG, "Initializing sensor ...");
|
||||
}
|
||||
@@ -60,6 +63,17 @@ static void light_sensor_update(TimerHandle_t handle) {
|
||||
esp_rmaker_device_get_param_by_type(switch_device, ESP_RMAKER_PARAM_TEMPERATURE),
|
||||
esp_rmaker_float(a_light));
|
||||
}
|
||||
esp_err_t app_sensor_init(void) {
|
||||
a_light = 15.0;
|
||||
sensor_timer = xTimerCreate("ambient_light_sensor_update_timer", (REPORTING_PERIOD*1000) / portTICK_PERIOD_MS,
|
||||
pdTRUE, NULL, light_sensor_update);
|
||||
|
||||
if (sensor_timer) {
|
||||
xTimerStart(sensor_timer, 0);
|
||||
return ESP_OK;
|
||||
}
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
static void app_bme280_init() {}
|
||||
|
||||
@@ -141,6 +155,8 @@ void app_driver_init()
|
||||
sensor_io_conf.pin_bit_mask = (uint64_t)1 << LIGHT_SENSOR;
|
||||
gpio_config(&sensor_io_conf);
|
||||
light_sensor_init();
|
||||
|
||||
app_sensor_init();
|
||||
}
|
||||
|
||||
int IRAM_ATTR app_driver_set_state(bool state)
|
||||
|
@@ -10,6 +10,8 @@
|
||||
#include <stdbool.h>
|
||||
|
||||
#define DEFAULT_POWER true
|
||||
#define REPORTING_PERIOD 60
|
||||
|
||||
extern esp_rmaker_device_t *switch_device;
|
||||
void app_driver_init(void);
|
||||
int app_driver_set_state(bool state);
|
||||
|
Reference in New Issue
Block a user