Compare commits
merge into: tianjialong:master
tianjialong:Finny_test
tianjialong:master
pull from: tianjialong:Finny_test
tianjialong:Finny_test
tianjialong:master
32 Commits
master
...
Finny_test
Author | SHA1 | Message | Date |
---|---|---|---|
|
6d8e81882d |
update
|
3 years ago |
|
ef595a4f9a |
update
|
3 years ago |
|
0fe1d3923d |
update
|
3 years ago |
|
739ad5e1ae |
update
|
3 years ago |
|
b19ca9c72d |
update
|
3 years ago |
|
9b8c523466 |
update
|
3 years ago |
|
2705fd865c |
update
|
3 years ago |
|
d5f5e5c605 |
update
|
3 years ago |
|
25f4a61de9 |
update
|
3 years ago |
|
01569c5a8e |
update
|
3 years ago |
|
32e34ad48d |
update
|
3 years ago |
|
a4d327921f |
update distribution_network
|
3 years ago |
|
8d42c013b4 |
update
|
3 years ago |
|
5721e81cc4 |
update
|
3 years ago |
|
07ec16ee53 |
update
|
3 years ago |
|
85eccd8661 |
update
|
3 years ago |
|
9e946d9b4e |
update
|
3 years ago |
|
a054fd5337 |
update
|
3 years ago |
|
1954899f7c |
update
|
3 years ago |
|
680a7920f6 |
update
|
3 years ago |
|
908550b1c2 |
update
|
3 years ago |
|
dd0144697d |
update
|
3 years ago |
|
f6c04d2849 |
update
|
3 years ago |
|
155943875f |
update
|
3 years ago |
|
72c221c4ce |
update
|
3 years ago |
|
1df265cb46 |
update
|
3 years ago |
|
852ca20f58 |
update
|
3 years ago |
|
7738fb55c2 |
update
|
3 years ago |
|
3e482bfd10 |
update
|
3 years ago |
|
f18b200071 |
update
|
3 years ago |
|
c5bbadf73b |
update
|
3 years ago |
|
330f2d3e07 |
update
|
3 years ago |
20 changed files with 674 additions and 42 deletions
-
4.vscode/settings.json
-
6main/CMakeLists.txt
-
177main/app_main.cpp
-
4main/beep.c
-
5main/beep.h
-
28main/camera.cpp
-
7main/camera.h
-
7main/cover.c
-
5main/cover.h
-
91main/heating_plate.c
-
18main/heating_plate.h
-
85main/key.c
-
20main/key.h
-
136main/light.c
-
43main/light.h
-
11main/port.c
-
14main/temp.c
-
5main/temp.h
-
32main/wifi.c
-
18main/wifi.h
@ -0,0 +1,4 @@ |
|||
#include "beep.h" |
|||
|
|||
void beep_init(void) {} |
|||
void beep_set_level(bool level) {} |
@ -0,0 +1,5 @@ |
|||
#pragma once |
|||
#include <stdbool.h> |
|||
|
|||
void beep_init(void); |
|||
void beep_set_level(bool level); |
@ -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); |
@ -0,0 +1,7 @@ |
|||
#include "cover.h" |
|||
|
|||
void cover_init(void) {} |
|||
bool cover_get_level(void) |
|||
{ |
|||
return false; |
|||
} |
@ -0,0 +1,5 @@ |
|||
#pragma once |
|||
#include <stdbool.h> |
|||
|
|||
void cover_init(void); |
|||
bool cover_get_level(void); |
@ -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)); |
|||
} |
@ -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); |
@ -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; |
|||
} |
@ -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); |
@ -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; } |
@ -0,0 +1,5 @@ |
|||
#pragma once |
|||
#include "stdlib.h" |
|||
|
|||
void T_temp_init(void); |
|||
double T_temp_get_data(void); |
@ -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; } |
@ -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); |
Write
Preview
Loading…
Cancel
Save
Reference in new issue