From bd9ea4b09ee29aadefeaee2e9accfffcb9141b8c Mon Sep 17 00:00:00 2001 From: CaoWangrenbo Date: Wed, 31 Jan 2024 17:43:48 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0LED=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E6=8C=87=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/by_led.c | 29 +++++++++++++++++++++++++++++ app/by_led.h | 8 ++++++++ app/by_rt_button.c | 26 -------------------------- app/by_rt_button.h | 21 --------------------- app/isr.c | 1 - app/main.c | 6 +++++- 6 files changed, 42 insertions(+), 49 deletions(-) create mode 100644 app/by_led.c create mode 100644 app/by_led.h delete mode 100644 app/by_rt_button.c delete mode 100644 app/by_rt_button.h diff --git a/app/by_led.c b/app/by_led.c new file mode 100644 index 0000000..852349f --- /dev/null +++ b/app/by_led.c @@ -0,0 +1,29 @@ +#include "by_led.h" + +#include "zf_common_headfile.h" + +#define LED_WARN_PIN E9 +#define LED_INFO_PIN E8 + +uint8_t led_warn_status = 1; +uint8_t led_info_status = 1; + +// TODO 将队列抽象出去,具有 blink 属性的设备均可使用 + +void by_led_init(void) +{ + gpio_init(LED_WARN_PIN, GPO, 0, GPO_PUSH_PULL); + gpio_init(LED_INFO_PIN, GPO, 0, GPO_PUSH_PULL); +} + +void by_led_warn_blink(void) +{ + led_warn_status = !led_warn_status; + gpio_set_level(LED_WARN_PIN, led_warn_status); +} + +void by_led_info_blink(void) +{ + led_info_status = !led_info_status; + gpio_set_level(LED_INFO_PIN, led_info_status); +} diff --git a/app/by_led.h b/app/by_led.h new file mode 100644 index 0000000..e1b6703 --- /dev/null +++ b/app/by_led.h @@ -0,0 +1,8 @@ +#ifndef _BY_LED_H__ +#define _BY_LED_H__ + +extern void by_led_init(void); +extern void by_led_warn_blink(void); +extern void by_led_info_blink(void); + +#endif \ No newline at end of file diff --git a/app/by_rt_button.c b/app/by_rt_button.c deleted file mode 100644 index d14c013..0000000 --- a/app/by_rt_button.c +++ /dev/null @@ -1,26 +0,0 @@ -#include "by_rt_button.h" -#include "zf_common_headfile.h" -uint8_t rotate_button; - -void by_gpio_init(void) -{ - gpio_init(E10, GPI, GPIO_HIGH, GPI_PULL_UP); -} - -void by_exit_init(void) -{ - exti_init(E9, EXTI_TRIGGER_FALLING); - exti_init(E11, EXTI_TRIGGER_BOTH); -} - -/** - * @brief 查询旋钮状态 - 查询后状态归零 - * - * @return uint8_t 当前旋钮状态 - */ -uint8_t by_get_rb_status(void) -{ - uint8_t temp_s = rotate_button; - rotate_button = 0; - return temp_s; -} \ No newline at end of file diff --git a/app/by_rt_button.h b/app/by_rt_button.h deleted file mode 100644 index 714e02f..0000000 --- a/app/by_rt_button.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef _BY_RT_BUTTON_H__ -#define _BY_RT_BUTTON_H__ - -#include "stdio.h" -#include "ch32v30x.h" - -typedef enum rotate_button_event { - rotate_button_press_short = 1, - rotate_button_press_long = 2, - rotate_button_forward = 3, - rotate_button_backward = 4, -} rotate_button_event; - -extern uint8_t rotate_button; - -extern void by_exit_init(void); -extern void by_gpio_init(void); -extern uint8_t by_get_rb_status(void); -extern void by_ips_show(void); - -#endif \ No newline at end of file diff --git a/app/isr.c b/app/isr.c index 137e5f6..4c57fb0 100644 --- a/app/isr.c +++ b/app/isr.c @@ -34,7 +34,6 @@ ********************************************************************************************************************/ #include "zf_common_headfile.h" -#include "by_rt_button.h" #include "by_button.h" #include "by_buzzer.h" diff --git a/app/main.c b/app/main.c index f08a31a..557eba4 100644 --- a/app/main.c +++ b/app/main.c @@ -25,6 +25,7 @@ #include "./page/page.h" #include "jj_param.h" #include "by_buzzer.h" +#include "by_led.h" int main(void) { @@ -34,8 +35,11 @@ int main(void) // mt9v03x_init(); ips200_init(IPS200_TYPE_SPI); usb_cdc_init(); + + by_led_init(); by_buzzer_init(); by_button_init(); + // while (imu660ra_init()) // ; // jj_param_eeprom_init(); @@ -51,7 +55,7 @@ int main(void) // adaptiveThreshold((uint8_t*)mt9v03x_image_copy, (uint8_t*)mt9v03x_image_copy, 188, 120, 7, 17); // ips200_show_gray_image(0, 0, mt9v03x_image_copy[0], MT9V03X_W, MT9V03X_H, MT9V03X_W, MT9V03X_H, 0); mt9v03x_finish_flag = 0; - + by_led_info_blink(); state_type = COMMON_STATE; img_processing(); get_corners();