Compare commits

...

32 Commits

Author SHA1 Message Date
zwsd 6d8e81882d update 3 years ago
zwsd ef595a4f9a update 3 years ago
zwsd 0fe1d3923d update 3 years ago
zwsd 739ad5e1ae update 3 years ago
zwsd b19ca9c72d update 3 years ago
zwsd 9b8c523466 update 3 years ago
zwsd 2705fd865c update 3 years ago
zwsd d5f5e5c605 update 3 years ago
zwsd 25f4a61de9 update 3 years ago
zwsd 01569c5a8e update 3 years ago
zwsd 32e34ad48d update 3 years ago
zwsd a4d327921f update distribution_network 3 years ago
zwsd 8d42c013b4 update 3 years ago
zwsd 5721e81cc4 update 3 years ago
zwsd 07ec16ee53 update 3 years ago
zwsd 85eccd8661 update 3 years ago
zwsd 9e946d9b4e update 3 years ago
zwsd a054fd5337 update 3 years ago
zwsd 1954899f7c update 3 years ago
zwsd 680a7920f6 update 3 years ago
zwsd 908550b1c2 update 3 years ago
zwsd dd0144697d update 3 years ago
zwsd f6c04d2849 update 3 years ago
zwsd 155943875f update 3 years ago
zwsd 72c221c4ce update 3 years ago
zwsd 1df265cb46 update 3 years ago
zwsd 852ca20f58 update 3 years ago
zwsd 7738fb55c2 update 3 years ago
zwsd 3e482bfd10 update 3 years ago
zwsd f18b200071 update 3 years ago
zwsd c5bbadf73b update 3 years ago
zwsd 330f2d3e07 update 3 years ago
  1. 4
      .vscode/settings.json
  2. 6
      main/CMakeLists.txt
  3. 177
      main/app_main.cpp
  4. 4
      main/beep.c
  5. 5
      main/beep.h
  6. 28
      main/camera.cpp
  7. 7
      main/camera.h
  8. 7
      main/cover.c
  9. 5
      main/cover.h
  10. 91
      main/heating_plate.c
  11. 18
      main/heating_plate.h
  12. 85
      main/key.c
  13. 20
      main/key.h
  14. 136
      main/light.c
  15. 43
      main/light.h
  16. 11
      main/port.c
  17. 14
      main/temp.c
  18. 5
      main/temp.h
  19. 32
      main/wifi.c
  20. 18
      main/wifi.h

4
.vscode/settings.json

@ -9,6 +9,8 @@
"ble_spp_server_demo.h": "c",
"esp_bt_main.h": "c",
"esp_bt_defs.h": "c",
"camera.h": "c"
"camera.h": "c",
"key.h": "c",
"heating_plate.h": "c"
}
}

6
main/CMakeLists.txt

@ -3,6 +3,12 @@ set(srcs "app_main.cpp" #
"camera.cpp"
"light.c"
"port.c"
"key.c"
"wifi.c"
"heating_plate.c"
"temp.c"
"cover.c"
"beep.c"
)
idf_component_register(SRCS "${srcs}"#

177
main/app_main.cpp

@ -1,15 +1,42 @@
#include "camera.h"
#include <stdbool.h>
//
#include "camera.h"
extern "C"
{
#include "ble_spp_server_demo.h"
#include "light.h"
#include "key.h"
#include "wifi.h"
#include "heating_plate.h"
#include "temp.h"
#include "port.h"
#include "cover.h"
#include "beep.h"
}
#define REACTION_TIME_MS 10 * 60 * 1000
typedef struct
{
bool reaction_start_flag;
uint32_t reaction_start_time;
} reaction_structer_t;
typedef struct
{
bool device_standby_start_flag;
uint32_t device_standby_start_time;
} this_device_standby_t;
/***********************************************************************************************************************
* *******************************************************light******************************************************* *
***********************************************************************************************************************/
power_state_light_structer_t power_state_light_structer = {
.state = ShutDown,
.change_flag = false,
};
heating_state_light_structer_t heating_state_light_structer = {
heating_plate_state_light_structer_t heating_plate_state_light_structer = {
.state = NoHeat,
.change_flag = false,
};
@ -22,24 +49,166 @@ wifi_state_light_structer_t wifi_state_light_structer = {
.change_flag = false,
};
/***********************************************************************************************************************
* ********************************************************key******************************************************** *
***********************************************************************************************************************/
T_key_structer_t T_key_structer = {
.key_before_state = false,
.key_now_state = false,
.key_press_down_keep_time = 0,
};
/***********************************************************************************************************************
* ***************************************************heating_plate*************************************************** *
***********************************************************************************************************************/
heating_plate_structer_t heating_plate_structer = {
.heating_plate_preheat_start_flag = false,
.heating_plate_preheat_finished_flag = false,
};
/***********************************************************************************************************************
* *****************************************************reaction****************************************************** *
***********************************************************************************************************************/
reaction_structer_t reaction_structer = {
.reaction_start_flag = false,
.reaction_start_time = 0,
};
/***********************************************************************************************************************
* *******************************************************wifi******************************************************** *
***********************************************************************************************************************/
wifi_structer_t wifi_structer = {
.wifi_connect_flag = false,
.wifi_distribution_network_flag = false,
.wifi_max_connect_num = 10,
};
/***********************************************************************************************************************
* ****************************************************this_device**************************************************** *
***********************************************************************************************************************/
this_device_standby_t this_device_standby_structer = {
.device_standby_start_flag = false,
.device_standby_start_time = 0,
};
static void T_all_light_init(void)
{
T_power_light_init(&power_state_light_structer);
T_heating_state_light_init(&heating_state_light_structer);
T_heating_plate_state_light_init(&heating_plate_state_light_structer);
T_reaction_state_light_init(&reaction_state_light_structer);
T_wifi_state_light_init(&wifi_state_light_structer);
}
void process_short_key_event(void)
{
/* 加热完成 */
if (heating_plate_structer.heating_plate_preheat_finished_flag)
{
/* 识别有反应板放入 */
if (camera_recognition_reaction_plate())
{
/* 未开始反应 */
if (!reaction_structer.reaction_start_flag)
{
reaction_structer.reaction_start_flag = true;
reaction_structer.reaction_start_time = port_get_ticket();
T_reaction_light_change_state(Reacting);
}
/* 反应中 */
else
{
}
}
/* 识别没有反应板放入 */
else
{
}
}
/* 加热未完成 */
else
{
T_heating_plate_start();
T_heating_plate_light_set_rgb_by_state(Heating);
}
}
void process_key_long_press_event(void)
{
/* 配网 */
if (!wifi_structer.wifi_distribution_network_flag)
{
T_wifi_light_change_state(Connecting);
if (T_wifi_distribution_network())
{
wifi_structer.wifi_distribution_network_flag = true;
T_wifi_light_change_state(ConnectionComplete);
}
}
}
void T_reaction_schedule(void)
{
if (reaction_structer.reaction_start_flag)
{
/* 反应完成 */
if ((port_get_ticket() - reaction_structer.reaction_start_time) >= REACTION_TIME_MS)
{
beep_set_level(true);
reaction_structer.reaction_start_flag = false;
T_reaction_light_change_state(ReactionComplete);
}
}
if ((heating_plate_structer.heating_plate_preheat_finished_flag == true) && //
(!camera_recognition_reaction_plate()) && !this_device_standby_structer.device_standby_start_flag)
{
this_device_standby_structer.device_standby_start_flag = true;
this_device_standby_structer.device_standby_start_time = port_get_ticket();
}
else
{
this_device_standby_structer.device_standby_start_flag = false;
}
}
void T_this_device_standby_schedule(void)
{
if (this_device_standby_structer.device_standby_start_flag)
{
if ((port_get_ticket() - this_device_standby_structer.device_standby_start_time) >= 600000)
{
T_heating_plate_stop();
T_heating_plate_light_set_rgb_by_state(NoHeat);
T_reaction_light_change_state(NoReaction);
T_wifi_light_change_state(NotConnected);
this_device_standby_structer.device_standby_start_flag = false;
}
}
}
extern "C" void app_main(void)
{
T_debug_light_init();
T_all_light_init();
ble_spp_server_init();
camera_motion_detection_init();
camera_init();
T_key_init(&T_key_structer);
T_wifi_init(&wifi_structer);
T_temp_init();
T_heating_plate_init(&heating_plate_structer);
cover_init();
beep_init();
T_key_registered_cb(process_short_key_event, process_key_long_press_event);
T_wifi_registered_cb();
T_heating_plate_registered_cb(T_temp_get_data);
while (true)
{
T_debug_light_schedule();
T_light_schedule();
T_key_schedule();
T_heating_plate_schedule();
T_reaction_schedule();
T_this_device_standby_schedule();
}
}

4
main/beep.c

@ -0,0 +1,4 @@
#include "beep.h"
void beep_init(void) {}
void beep_set_level(bool level) {}

5
main/beep.h

@ -0,0 +1,5 @@
#pragma once
#include <stdbool.h>
void beep_init(void);
void beep_set_level(bool level);

28
main/camera.cpp

@ -1,7 +1,18 @@
/**
* @file camera.cpp
* @author Finny (tianjialong0106@163.com)
* @brief
* @version 0.1
* @date 2022-09-26
*
* @copyright Copyright (c) 2022
*
*/
#include "camera.h"
#include "who_camera.h"
#include "who_motion_detection.hpp"
#include "who_lcd.h"
#include "light.h"
static QueueHandle_t xQueueAIFrame = NULL;
static QueueHandle_t xQueueLCDFrame = NULL;
@ -14,4 +25,19 @@ void camera_motion_detection_init(void)
register_camera(PIXFORMAT_RGB565, FRAMESIZE_240X240, 2, xQueueAIFrame);
register_motion_detection(xQueueAIFrame, NULL, NULL, xQueueLCDFrame);
register_lcd(xQueueLCDFrame, NULL, true);
}
}
void camera_init(void) {}
void camera_registered_cb(void) {}
void camera_taking_pictures(void)
{
//打开补光灯
T_camera_fill_light_set_level(true);
//关闭补光灯
T_camera_fill_light_set_level(false);
}
bool camera_recognition_reaction_plate(void) { return false; }

7
main/camera.h

@ -1,2 +1,7 @@
#pragma once
void camera_motion_detection_init(void);
void camera_motion_detection_init(void);
void camera_init(void);
void camera_registered_cb(void);
void camera_taking_pictures(void);
bool camera_recognition_reaction_plate(void);

7
main/cover.c

@ -0,0 +1,7 @@
#include "cover.h"
void cover_init(void) {}
bool cover_get_level(void)
{
return false;
}

5
main/cover.h

@ -0,0 +1,5 @@
#pragma once
#include <stdbool.h>
void cover_init(void);
bool cover_get_level(void);

91
main/heating_plate.c

@ -0,0 +1,91 @@
/**
* @file heating_plate.c
* @author Finny (tianjialong0106@163.com)
* @brief
* @version 0.1
* @date 2022-09-26
*
* @copyright Copyright (c) 2022
*
*/
#include "heating_plate.h"
#include "driver/ledc.h"
#include "esp_err.h"
#include "light.h"
#include "beep.h"
#define LEDC_TIMER LEDC_TIMER_0 //
#define LEDC_MODE LEDC_LOW_SPEED_MODE //
#define LEDC_OUTPUT_IO (20) // Define the output GPIO
#define LEDC_CHANNEL LEDC_CHANNEL_0 //
#define LEDC_DUTY_RES LEDC_TIMER_13_BIT // Set duty resolution to 13 bits
#define LEDC_DUTY (4095) // Set duty to 50%. ((2 ** 13) - 1) * 50% = 4095
#define LEDC_FREQUENCY (5000) // Frequency in Hertz. Set frequency at 5 kHz
#define heating_plate_target_temp 48.0
#define heating_plate_variable_temperature_range 0.5
static heating_plate_structer_t *heating_plate_structer_s;
static get_temp_callback_t get_temp_cb_s;
void T_heating_plate_init(heating_plate_structer_t *heating_plate_structer)
{
heating_plate_structer_s = heating_plate_structer;
// Prepare and then apply the LEDC PWM timer configuration
ledc_timer_config_t ledc_timer = {
.speed_mode = LEDC_MODE,
.timer_num = LEDC_TIMER,
.duty_resolution = LEDC_DUTY_RES,
.freq_hz = LEDC_FREQUENCY, // Set output frequency at 5 kHz
.clk_cfg = LEDC_AUTO_CLK};
ESP_ERROR_CHECK(ledc_timer_config(&ledc_timer));
// Prepare and then apply the LEDC PWM channel configuration
ledc_channel_config_t ledc_channel = {
.speed_mode = LEDC_MODE,
.channel = LEDC_CHANNEL,
.timer_sel = LEDC_TIMER,
.intr_type = LEDC_INTR_DISABLE,
.gpio_num = LEDC_OUTPUT_IO,
.duty = 0, // Set duty to 0%
.hpoint = 0};
ESP_ERROR_CHECK(ledc_channel_config(&ledc_channel));
}
void T_heating_plate_registered_cb(get_temp_callback_t cb) { get_temp_cb_s = cb; }
void T_heating_plate_start(void)
{
T_heating_plate_set_and_update_duty(LEDC_DUTY);
}
void T_heating_plate_stop(void)
{
T_heating_plate_set_and_update_duty(0);
}
void T_heating_plate_schedule(void)
{
if (heating_plate_structer_s->heating_plate_preheat_start_flag)
{
if (get_temp_cb_s() >= heating_plate_target_temp + heating_plate_variable_temperature_range)
{
T_heating_plate_stop();
beep_set_level(true);
T_heating_plate_light_set_rgb_by_state(HeatComplete);
}
else if (get_temp_cb_s() <= heating_plate_target_temp - heating_plate_variable_temperature_range)
{
T_heating_plate_start();
}
}
}
void T_heating_plate_set_and_update_duty(uint32_t duty)
{
// Set duty
ESP_ERROR_CHECK(ledc_set_duty(LEDC_MODE, LEDC_CHANNEL, duty));
// Update duty to apply the new value
ESP_ERROR_CHECK(ledc_update_duty(LEDC_MODE, LEDC_CHANNEL));
}

18
main/heating_plate.h

@ -0,0 +1,18 @@
#pragma once
#include <stdbool.h>
#include <stdint.h>
typedef struct
{
bool heating_plate_preheat_start_flag;
bool heating_plate_preheat_finished_flag;
} heating_plate_structer_t;
typedef double (*get_temp_callback_t)(void);
void T_heating_plate_init(heating_plate_structer_t *heating_plate_structer);
void T_heating_plate_registered_cb(get_temp_callback_t cb);
void T_heating_plate_start(void);
void T_heating_plate_stop(void);
void T_heating_plate_schedule(void);
void T_heating_plate_set_and_update_duty(uint32_t duty);

85
main/key.c

@ -0,0 +1,85 @@
/**
* @file key.c
* @author Finny (tianjialong0106@163.com)
* @brief
* @version 0.1
* @date 2022-09-26
*
* @copyright Copyright (c) 2022
*
*/
#include "key.h"
#include "port.h"
#include "cover.h"
#define key_long_press_time_ms 5000
static T_key_structer_t *T_key_structer_s;
static key_event_cb short_press_event_cb_s;
static key_event_cb long_press_event_cb_s;
void T_key_init(T_key_structer_t *T_key_structer)
{
T_key_structer_s = T_key_structer;
}
void T_key_registered_cb(key_event_cb short_press_event_cb, key_event_cb long_press_event_cb)
{
short_press_event_cb_s = short_press_event_cb;
long_press_event_cb_s = long_press_event_cb;
}
void T_key_on_event(void)
{
}
void T_key_schedule(void)
{
static uint32_t key_start_press_down_time = 0;
T_key_structer_s->key_now_state = T_key_get_level();
/* 检查是否盖上盖 */
if (cover_get_level())
{
/* 上升沿 */
if ((T_key_structer_s->key_before_state != T_key_structer_s->key_now_state) && (T_key_structer_s->key_now_state == true))
{
if (T_key_structer_s->key_press_down_keep_time != 0)
{
T_key_structer_s->key_press_down_keep_time = 0;
}
key_start_press_down_time = port_get_ticket();
}
/* 下降沿 */
if ((T_key_structer_s->key_before_state != T_key_structer_s->key_now_state) && (T_key_structer_s->key_now_state == false))
{
T_key_structer_s->key_press_down_keep_time = port_get_ticket() - key_start_press_down_time;
}
/* 20ms消抖 */
if ((T_key_structer_s->key_press_down_keep_time > 20) && (key_start_press_down_time != 0))
{
if (T_key_structer_s->key_press_down_keep_time < 500)
{
short_press_event_cb_s();
}
else if (T_key_structer_s->key_press_down_keep_time >= 3000)
{
long_press_event_cb_s();
}
key_start_press_down_time = 0;
T_key_structer_s->key_press_down_keep_time = 0;
}
}
else
{
}
T_key_structer_s->key_before_state = T_key_structer_s->key_now_state;
}
bool T_key_get_level(void)
{
return false;
}

20
main/key.h

@ -0,0 +1,20 @@
#pragma once
#include <stdbool.h>
#include <stdint.h>
typedef struct
{
bool key_before_state;
bool key_now_state;
uint32_t key_press_down_keep_time;
} T_key_structer_t;
typedef bool (*key_camera_cb)(void);
typedef void (*key_event_cb)(void);
void T_key_init(T_key_structer_t *T_key_structer);
void T_key_registered_cb(key_event_cb short_press_event_cb, key_event_cb long_press_event_cb);
void T_key_on_event(void);
void T_key_schedule(void);
bool T_key_get_level(void);

136
main/light.c

@ -1,17 +1,30 @@
/**
* @file light.c
* @author Finny (tianjialong0106@163.com)
* @brief Project micro shape photometer light control
* @version 0.1
* @date 2022-09-25
*
* @copyright Copyright (c) 2022
*
*/
#include "light.h"
#include "driver/gpio.h"
#include "esp_log.h"
#include "port.h"
#define DEBUG_LIGHT_TOGGLE_TIME 300
#define OTHER_LIGHT_TOGGLE_TIME 500
#define GPIO_DEBUG_LIGHT 12
#define GPIO_POWER_LIGHT 12
#define GPIO_HEATING_STATE_LIGHT 12
#define GPIO_HEATING_PLATE_STATE_LIGHT 12
#define GPIO_REACTION_STATE_LIGHT 12
#define GPIO_WIFI_STATE_LIGHT 12
static power_state_light_structer_t *power_state_light_structer_s;
static heating_state_light_structer_t *heating_state_light_structer_s;
static heating_plate_state_light_structer_t *heating_plate_state_light_structer_s;
static reaction_state_light_structer_t *reaction_state_light_structer_s;
static wifi_state_light_structer_t *wifi_state_light_structer_s;
@ -29,9 +42,9 @@ void T_debug_light_init(void)
gpio_config(&gpio_debug_light_init_structer);
}
void T_debug_light_toggle_level(void)
void T_light_toggle_level(uint8_t io_num)
{
gpio_set_level(GPIO_DEBUG_LIGHT, !gpio_get_level(GPIO_DEBUG_LIGHT));
gpio_set_level(io_num, !gpio_get_level(GPIO_DEBUG_LIGHT));
}
// Power light
@ -50,18 +63,36 @@ void T_power_light_init(power_state_light_structer_t *power_state_light_structer
}
// Heating state light
void T_heating_state_light_init(heating_state_light_structer_t *heating_state_light_structer)
void T_heating_plate_state_light_init(heating_plate_state_light_structer_t *heating_plate_state_light_structer)
{
heating_state_light_structer_s = heating_state_light_structer;
gpio_config_t gpio_heating_state_light_init_structer;
heating_plate_state_light_structer_s = heating_plate_state_light_structer;
gpio_config_t gpio_heating_plate_state_light_init_structer;
gpio_heating_plate_state_light_init_structer.intr_type = GPIO_INTR_DISABLE;
gpio_heating_plate_state_light_init_structer.mode = GPIO_MODE_INPUT_OUTPUT;
gpio_heating_plate_state_light_init_structer.pin_bit_mask = (1ULL << GPIO_HEATING_PLATE_STATE_LIGHT);
gpio_heating_plate_state_light_init_structer.pull_down_en = 0;
gpio_heating_plate_state_light_init_structer.pull_up_en = 0;
gpio_heating_state_light_init_structer.intr_type = GPIO_INTR_DISABLE;
gpio_heating_state_light_init_structer.mode = GPIO_MODE_INPUT_OUTPUT;
gpio_heating_state_light_init_structer.pin_bit_mask = (1ULL << GPIO_HEATING_STATE_LIGHT);
gpio_heating_state_light_init_structer.pull_down_en = 0;
gpio_heating_state_light_init_structer.pull_up_en = 0;
gpio_config(&gpio_heating_plate_state_light_init_structer);
}
void T_heating_plate_light_change_state(heating_plate_state_t change_state)
{
heating_plate_state_light_structer_s->state = change_state;
heating_plate_state_light_structer_s->change_flag = true;
}
gpio_config(&gpio_heating_state_light_init_structer);
void T_heating_plate_light_set_rgb_by_state(heating_plate_state_t state)
{
if (state == NoHeat)
{
gpio_set_level(GPIO_HEATING_PLATE_STATE_LIGHT, 0);
}
else if (state == HeatComplete)
{
gpio_set_level(GPIO_HEATING_PLATE_STATE_LIGHT, 1);
}
}
// Reaction state light
@ -79,6 +110,24 @@ void T_reaction_state_light_init(reaction_state_light_structer_t *reaction_state
gpio_config(&gpio_reaction_state_light_init_structer);
}
void T_reaction_light_change_state(reaction_state_t change_state)
{
reaction_state_light_structer_s->state = change_state;
reaction_state_light_structer_s->change_flag = true;
}
void T_reaction_light_set_rgb_by_state(reaction_state_t state)
{
if (state == NoReaction)
{
gpio_set_level(GPIO_REACTION_STATE_LIGHT, 0);
}
else if (state == ReactionComplete)
{
gpio_set_level(GPIO_REACTION_STATE_LIGHT, 1);
}
}
// WIFI state light
void T_wifi_state_light_init(wifi_state_light_structer_t *wifi_state_light_structer)
{
@ -94,28 +143,75 @@ void T_wifi_state_light_init(wifi_state_light_structer_t *wifi_state_light_struc
gpio_config(&gpio_wifi_state_light_init_structer);
}
void T_wifi_light_change_state(wifi_state_t change_state)
{
wifi_state_light_structer_s->state = change_state;
wifi_state_light_structer_s->change_flag = true;
}
void T_wifi_light_set_rgb_by_state(wifi_state_t state)
{
if (state == NotConnected)
{
gpio_set_level(GPIO_WIFI_STATE_LIGHT, 0);
}
else if (state == ConnectionComplete)
{
gpio_set_level(GPIO_WIFI_STATE_LIGHT, 1);
}
}
// Camera fill light
void T_camera_fill_light_init(camera_fill_light_structer_t *camera_fill_light_structer) {}
void T_camera_fill_light_set_level(bool level) {}
// Schedule
void T_debug_light_schedule(void)
{
static uint32_t debug_light_time;
if (port_haspassedms(debug_light_time) > 300)
if (port_haspassedms(debug_light_time) > DEBUG_LIGHT_TOGGLE_TIME)
{
T_debug_light_toggle_level();
T_light_toggle_level(GPIO_DEBUG_LIGHT);
debug_light_time = port_get_ticket();
}
}
void T_light_schedule(void)
{
if (power_state_light_structer_s->change_flag)
{
}
if (heating_state_light_structer_s->change_flag)
static uint32_t light_ticket;
if (heating_plate_state_light_structer_s->change_flag)
{
T_heating_plate_light_set_rgb_by_state(heating_plate_state_light_structer_s->state);
heating_plate_state_light_structer_s->change_flag = false;
}
if (reaction_state_light_structer_s->change_flag)
{
T_reaction_light_set_rgb_by_state(reaction_state_light_structer_s->state);
reaction_state_light_structer_s->change_flag = false;
}
if (wifi_state_light_structer_s->change_flag)
{
T_reaction_light_set_rgb_by_state(wifi_state_light_structer_s->state);
wifi_state_light_structer_s->change_flag = false;
}
}
if (port_haspassedms(light_ticket) > OTHER_LIGHT_TOGGLE_TIME)
{
if (heating_plate_state_light_structer_s->state == Heating)
{
T_light_toggle_level(GPIO_HEATING_PLATE_STATE_LIGHT);
}
if (reaction_state_light_structer_s->state == Reacting)
{
T_light_toggle_level(GPIO_REACTION_STATE_LIGHT);
}
if (wifi_state_light_structer_s->state == Connecting)
{
T_light_toggle_level(GPIO_WIFI_STATE_LIGHT);
}
light_ticket = port_get_ticket();
}
}

43
main/light.h

@ -1,16 +1,7 @@
/**
* @file light.h
* @author Finny (tianjialong0106@163.com)
* @brief Project micro shape photometer light control
* @version 0.1
* @date 2022-09-25
*
* @copyright Copyright (c) 2022
*
*/
#pragma once
#include <stdbool.h>
#include <stdint.h>
typedef enum
{
@ -23,7 +14,7 @@ typedef enum
NoHeat = 1, //
Heating, //
HeatComplete, //
} heating_state_t;
} heating_plate_state_t;
typedef enum
{
@ -39,6 +30,12 @@ typedef enum
ConnectionComplete, //
} wifi_state_t;
typedef enum
{
closeCameraFillLight = 1, //
openCameraFillLight, //
} camera_fill_light_t;
typedef struct
{
power_state_t state;
@ -47,9 +44,9 @@ typedef struct
typedef struct
{
heating_state_t state;
heating_plate_state_t state;
bool change_flag;
} heating_state_light_structer_t;
} heating_plate_state_light_structer_t;
typedef struct
{
@ -63,21 +60,37 @@ typedef struct
bool change_flag;
} wifi_state_light_structer_t;
typedef struct
{
camera_fill_light_t state;
bool change_flag;
} camera_fill_light_structer_t;
// Debug light
void T_debug_light_init(void);
void T_debug_light_toggle_level(void);
void T_light_toggle_level(uint8_t io_num);
// Power light
void T_power_light_init(power_state_light_structer_t *power_state_light_structer);
// Heating state light
void T_heating_state_light_init(heating_state_light_structer_t *heating_state_light_structer);
void T_heating_plate_state_light_init(heating_plate_state_light_structer_t *heating_plate_state_light_structer);
void T_heating_plate_light_change_state(heating_plate_state_t change_state);
void T_heating_plate_light_set_rgb_by_state(heating_plate_state_t state);
// Reaction state light
void T_reaction_state_light_init(reaction_state_light_structer_t *reaction_state_light_structer);
void T_reaction_light_change_state(reaction_state_t change_state);
void T_reaction_light_set_rgb_by_state(reaction_state_t state);
// WIFI state light
void T_wifi_state_light_init(wifi_state_light_structer_t *wifi_state_light_structer);
void T_wifi_light_change_state(wifi_state_t change_state);
void T_wifi_light_set_rgb_by_state(wifi_state_t state);
// Camera fill light
void T_camera_fill_light_init(camera_fill_light_structer_t *camera_fill_light_structer);
void T_camera_fill_light_set_level(bool level);
// Schedule
void T_debug_light_schedule(void);

11
main/port.c

@ -1,3 +1,14 @@
/**
* @file port.c
* @author Finny (tianjialong0106@163.com)
* @brief
* @version 0.1
* @date 2022-09-26
*
* @copyright Copyright (c) 2022
*
*/
#include "port.h"
#include "driver/gpio.h"

14
main/temp.c

@ -0,0 +1,14 @@
/**
* @file temp.c
* @author Finny (tianjialong0106@163.com)
* @brief Temperature sensor
* @version 0.1
* @date 2022-09-26
*
* @copyright Copyright (c) 2022
*
*/
#include "temp.h"
void T_temp_init(void) {}
double T_temp_get_data(void) { return 0.0; }

5
main/temp.h

@ -0,0 +1,5 @@
#pragma once
#include "stdlib.h"
void T_temp_init(void);
double T_temp_get_data(void);

32
main/wifi.c

@ -0,0 +1,32 @@
/**
* @file wifi.c
* @author Finny (tianjialong0106@163.com)
* @brief
* @version 0.1
* @date 2022-09-26
*
* @copyright Copyright (c) 2022
*
*/
#include "wifi.h"
#define WIFI_SSID 1
#define WIFI_NAME "ZWSD_ESP32"
#define WIFI_PASSWORD "zwsdzwsd"
static wifi_structer_t *wifi_structer_s;
void T_wifi_init(wifi_structer_t *wifi_structer) { wifi_structer_s = wifi_structer; }
void T_wifi_registered_cb(void) {}
void T_wifi_connect(void) {}
void T_wifi_disconnect(void) {}
bool T_wifi_connect_timeout(void) { return true; }
void T_wifi_send_data(void) {}
bool T_wifi_distribution_network(void) { return false; }

18
main/wifi.h

@ -0,0 +1,18 @@
#pragma once
#include <stdbool.h>
#include <stdint.h>
typedef struct
{
bool wifi_connect_flag;
bool wifi_distribution_network_flag;
uint8_t wifi_max_connect_num;
} wifi_structer_t;
void T_wifi_init(wifi_structer_t *wifi_structer);
void T_wifi_registered_cb(void);
void T_wifi_connect(void);
void T_wifi_disconnect(void);
bool T_wifi_connect_timeout(void);
void T_wifi_send_data(void);
bool T_wifi_distribution_network(void);
Loading…
Cancel
Save