diff --git a/app/by_fan_control.c b/app/by_fan_control.c
index ad7ccc5..66d2b11 100644
--- a/app/by_fan_control.c
+++ b/app/by_fan_control.c
@@ -12,11 +12,13 @@ void by_pwm_init(void)
void by_pwm_update_duty(uint32_t update_pwm_duty)
{
- if (7000UL > update_pwm_duty) {
- update_pwm_duty = 7000UL;
+ if (4000UL < update_pwm_duty) {
+ update_pwm_duty = 4000UL;
}
pwm_set_duty(TIM4_PWM_MAP1_CH1_D12, update_pwm_duty);
pwm_set_duty(TIM4_PWM_MAP1_CH2_D13, update_pwm_duty);
+ // pwm_set_duty(TIM4_PWM_MAP1_CH3_D14, update_pwm_duty);
+ // pwm_set_duty(TIM4_PWM_MAP1_CH4_D15, update_pwm_duty);
}
void by_pwm_power_duty(uint32_t power_pwm_duty_l, uint32_t power_pwm_duty_r)
diff --git a/app/by_pt_button.h b/app/by_pt_button.h
deleted file mode 100644
index 0a7202f..0000000
--- a/app/by_pt_button.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef _BY_PT_BUTTON_H__
-#define _BY_PT_BUTTON_H__
-
-#include "stdio.h"
-#include "ch32v30x.h"
-#define POTATE_BUTTOM_PRESS 1
-#define POTATE_BUTTOM_FOREWARD 2
-#define POTATE_BUTTOM_BACKWARD 3
-extern uint8_t potate_button;
-
-
-extern void by_exit_init(void);
-extern void by_gpio_init(void);
-extern uint8_t by_get_statu(void);
-extern void by_ips_show(void);
-
-#endif
\ No newline at end of file
diff --git a/app/by_pt_button.c b/app/by_rt_button.c
similarity index 72%
rename from app/by_pt_button.c
rename to app/by_rt_button.c
index 549478d..c9147cd 100644
--- a/app/by_pt_button.c
+++ b/app/by_rt_button.c
@@ -1,7 +1,7 @@
-#include "by_pt_button.h"
+#include "by_rt_button.h"
#include "zf_common_headfile.h"
#include "by_imu.h"
-uint8_t potate_button;
+uint8_t rotate_button;
void by_gpio_init(void)
{
@@ -14,18 +14,23 @@ void by_exit_init(void)
exti_init(E11, EXTI_TRIGGER_FALLING);
}
-uint8_t by_get_pb_statu(void)
+/**
+ * @brief 查询旋钮状态 - 查询后状态归零
+ *
+ * @return uint8_t 当前旋钮状态
+ */
+uint8_t by_get_rb_status(void)
{
- uint8_t temp_s = potate_button;
- potate_button = 0;
+ uint8_t temp_s = rotate_button;
+ rotate_button = 0;
return temp_s;
}
void by_ips_show(void)
{
- ips200_show_string(0, 0, "button statu:");
- // ips200_show_uint(104, 0, by_get_pb_statu(), 1);
- switch (by_get_pb_statu()) {
+ ips200_show_string(0, 0, "button status:");
+ // ips200_show_uint(104, 0, by_get_rb_status(), 1);
+ switch (by_get_rb_status()) {
case 1:
ips200_show_string(104, 0, "press");
break;
@@ -45,7 +50,7 @@ void by_ips_show(void)
ips200_show_float(46, 32, eulerAngle.pitch, 3, 2);
ips200_show_float(46, 48, eulerAngle.roll, 3, 2);
ips200_show_float(46, 64, eulerAngle.yaw, 3, 2);
- // ips200_show_float(46 , 32, icm_data.gyro_x, 2, 2);
+ // ips200_show_float(46 , 32, icm_data.gyro_x, 2, 2);
// ips200_show_float(106, 32, icm_data.gyro_y, 2, 2);
// ips200_show_float(166, 32, icm_data.gyro_z, 2, 2);
ips200_show_float(46, 80, imu660ra_temperature, 2, 2);
diff --git a/app/by_rt_button.h b/app/by_rt_button.h
new file mode 100644
index 0000000..25e5699
--- /dev/null
+++ b/app/by_rt_button.h
@@ -0,0 +1,17 @@
+#ifndef _BY_RT_BUTTON_H__
+#define _BY_RT_BUTTON_H__
+
+#include "stdio.h"
+#include "ch32v30x.h"
+#define ROTATE_BUTTON_PRESS 1
+#define ROTATE_BUTTON_FORWARD 2
+#define ROTATE_BUTTON_BACKWARD 3
+
+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 ce1e22e..4fe8bd1 100644
--- a/app/isr.c
+++ b/app/isr.c
@@ -2,11 +2,11 @@
* CH32V307VCT6 Opensourec Library CH32V307VCT6 Դ⣩һڹٷ SDK ӿڵĵԴ
* Copyright (c) 2022 SEEKFREE ɿƼ
*
- * ļCH32V307VCT6 Դһ
+ * ļ CH32V307VCT6 Դһ
*
* CH32V307VCT6 Դ
- * Ըᷢ GPLGNU General Public License GNUͨù֤
- * GPL ĵ3棨 GPL3.0ѡģκκİ汾·/
+ * Ըᷢ GPLGNU General Public License GNU ͨù֤
+ * GPL ĵ 3 棨 GPL3.0ѡģκκİ汾·/
*
* Դķϣܷãδκεı֤
* ûԻʺض;ı֤
@@ -30,11 +30,12 @@
*
* ļ¼
* ע
- * 2022-09-15 W first version
+ * 2022-09-15 W first version
********************************************************************************************************************/
#include "zf_common_headfile.h"
-#include "by_pt_button.h"
+#include "by_rt_button.h"
+#include "by_imu.h"
void NMI_Handler(void) __attribute__((interrupt()));
void HardFault_Handler(void) __attribute__((interrupt()));
@@ -197,10 +198,10 @@ void EXTI9_5_IRQHandler(void)
if (SET == EXTI_GetITStatus(EXTI_Line9)) {
if (SET == gpio_get_level(E10)) {
- potate_button = POTATE_BUTTOM_BACKWARD;
+ rotate_button = ROTATE_BUTTON_BACKWARD;
} else {
- potate_button = POTATE_BUTTOM_FOREWARD;
+ rotate_button = ROTATE_BUTTON_FORWARD;
}
EXTI_ClearITPendingBit(EXTI_Line9);
}
@@ -220,7 +221,7 @@ void EXTI15_10_IRQHandler(void)
system_delay_us(200);
if (SET == !gpio_get_level(E11)) {
- potate_button = POTATE_BUTTOM_PRESS;
+ rotate_button = ROTATE_BUTTON_PRESS;
}
EXTI_ClearITPendingBit(EXTI_Line11);
}
diff --git a/app/main.c b/app/main.c
index ba8a864..2883964 100644
--- a/app/main.c
+++ b/app/main.c
@@ -1,29 +1,29 @@
/*********************************************************************************************************************
-* CH32V307VCT6 Opensourec Library 即(CH32V307VCT6 开源库)是一个基于官方 SDK 接口的第三方开源库
-* Copyright (c) 2022 SEEKFREE 逐飞科技
-*
-* 本文件是 CH32V307VCT6 开源库的一部分
-*
-* CH32V307VCT6 开源库 是免费软件
-* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU 通用公共许可证)的条款
-* 即 GPL 的第 3 版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
-*
-* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
-* 甚至没有隐含的适销性或适合特定用途的保证
-* 更多细节请参见 GPL
-*
-* 您应该在收到本开源库的同时收到一份 GPL 的副本
-* 如果没有,请参阅
-*
-* 额外注明:
-* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
-* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
-* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
-* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
-********************************************************************************************************************/
+ * CH32V307VCT6 Opensourec Library 即(CH32V307VCT6 开源库)是一个基于官方 SDK 接口的第三方开源库
+ * Copyright (c) 2022 SEEKFREE 逐飞科技
+ *
+ * 本文件是 CH32V307VCT6 开源库的一部分
+ *
+ * CH32V307VCT6 开源库 是免费软件
+ * 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU 通用公共许可证)的条款
+ * 即 GPL 的第 3 版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+ *
+ * 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+ * 甚至没有隐含的适销性或适合特定用途的保证
+ * 更多细节请参见 GPL
+ *
+ * 您应该在收到本开源库的同时收到一份 GPL 的副本
+ * 如果没有,请参阅
+ *
+ * 额外注明:
+ * 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+ * 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+ * 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+ * 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+ ********************************************************************************************************************/
#include "zf_common_headfile.h"
#include "gl_headfile.h"
-#include "by_pt_button.h"
+#include "by_rt_button.h"
#include "by_fan_control.h"
#include "cw_servo.h"
#include "./page/cw_page.h"
@@ -71,6 +71,8 @@ enum track_type_e track_type = TRACK_RIGHT;
int frame_count = 0;
+uint16_t pwm_cnt = 500;
+
void img_processing();
void get_corners();
@@ -79,19 +81,36 @@ int main(void)
clock_init(SYSTEM_CLOCK_120M);
debug_init();
mt9v03x_init();
+ pwm_init(TIM2_PWM_MAP0_CH1_A0, 50, 1000);
+ pwm_init(TIM2_PWM_MAP0_CH2_A1, 50, 1000);
ips200_init(IPS200_TYPE_SPI);
by_gpio_init();
by_exit_init();
by_pwm_init();
- cw_servo_init();
+ // cw_servo_init();
// while (imu660ra_init())
// ;
Page_Init();
while (1) {
+ // ips200_show_uint(0, 0, pwm_cnt, 6);
+ // uint8_t temp_status = by_get_rb_status();
+ // if (2 == temp_status) {
+ // pwm_cnt += 50;
+ // } else if (3 == temp_status) {
+ // pwm_cnt -= 50;
+ // }
+
+ // pwm_cnt = (uint16_t)clip(pwm_cnt, 500, 1000);
+ // by_pwm_update_duty(4000);
+ // pwm_set_duty(TIM2_PWM_MAP0_CH1_A0, pwm_cnt);
+ // pwm_set_duty(TIM2_PWM_MAP0_CH2_A1, pwm_cnt);
+
+ // by_pwm_update_duty(pwm_cnt);
+
Page_Run();
-
+
if (mt9v03x_finish_flag) {
memcpy(mt9v03x_image_copy[0], mt9v03x_image[0], (sizeof(mt9v03x_image_copy) / sizeof(uint8_t)));
mt9v03x_finish_flag = 0;
diff --git a/app/page/cw_page.c b/app/page/cw_page.c
index d948d63..8716b8e 100644
--- a/app/page/cw_page.c
+++ b/app/page/cw_page.c
@@ -1,9 +1,11 @@
#include "cw_page.h"
+#include "by_rt_button.h"
+
PAGE_LIST pagelist[page_max];
static uint8_t page_busy = 0;
-static int8_t now_page = page_menu;
-static int8_t new_page = page_menu;
+static int8_t now_page = page_menu;
+static int8_t new_page = page_menu;
/**
* @brief 注册一个基本页面,包含一个初始化函数,循环函数,退出函数,事件函数
@@ -16,12 +18,13 @@ static int8_t new_page = page_menu;
* @retval 无
*/
void Page_Register(uint8_t pageID, char *pageText,
- CallbackFunction_t setupCallback, CallbackFunction_t loopCallback,
- CallbackFunction_t exitCallback, EventFunction_t eventCallback) {
- pagelist[pageID].Text = pageText;
+ CallbackFunction_t setupCallback, CallbackFunction_t loopCallback,
+ CallbackFunction_t exitCallback, EventFunction_t eventCallback)
+{
+ pagelist[pageID].Text = pageText;
pagelist[pageID].SetupCallback = setupCallback;
- pagelist[pageID].LoopCallback = loopCallback;
- pagelist[pageID].ExitCallback = exitCallback;
+ pagelist[pageID].LoopCallback = loopCallback;
+ pagelist[pageID].ExitCallback = exitCallback;
pagelist[pageID].EventCallback = eventCallback;
}
@@ -30,7 +33,8 @@ void Page_Register(uint8_t pageID, char *pageText,
* @param event: 事件编号
* @retval 无
*/
-void Page_EventTransmit(unsigned char event) {
+void Page_EventTransmit(unsigned char event)
+{
/*将事件传递到当前页面*/
if (pagelist[now_page].EventCallback != 0)
pagelist[now_page].EventCallback(event);
@@ -41,7 +45,8 @@ void Page_EventTransmit(unsigned char event) {
* @param pageID:页面号
* @retval 1:成功 0:失败
*/
-void Page_Shift(unsigned char pageID) {
+void Page_Shift(unsigned char pageID)
+{
if (page_busy == 0) {
new_page = pageID;
}
@@ -51,7 +56,8 @@ void Page_Shift(unsigned char pageID) {
* @brief 关闭当前页面
*
*/
-void Page_CloseCurrentPage() {
+void Page_CloseCurrentPage()
+{
pagelist[now_page].ExitCallback();
}
@@ -59,16 +65,18 @@ void Page_CloseCurrentPage() {
* @brief 打开当前页面
*
*/
-void Page_OpenCurrentPage() {
+void Page_OpenCurrentPage()
+{
pagelist[now_page].SetupCallback();
}
/**
* @brief 获取页面状态
*
- * @return uint8_t 页面忙返回1 空闲返回0
+ * @return uint8_t 页面忙返回 1 空闲返回 0
*/
-uint8_t Page_GetStatus(void) {
+uint8_t Page_GetStatus(void)
+{
if (page_busy)
return 1;
else
@@ -79,18 +87,23 @@ uint8_t Page_GetStatus(void) {
* @brief 页面运行函数
*
*/
-void Page_Run(void) {
+void Page_Run(void)
+{
+ uint8_t temp_status = by_get_rb_status(); // 轮询旋钮状态
+ if(temp_status){
+ pagelist[now_page].EventCallback(temp_status);
+ }
if (now_page != new_page) {
if (new_page >= page_max && new_page < page_menu) {
new_page = page_menu;
}
- //执行当前页面退出回调函数
+ // 执行当前页面退出回调函数
if ((pagelist[now_page].ExitCallback != 0)) {
pagelist[now_page].ExitCallback();
}
- //执行新页面构造回调函数
+ // 执行新页面构造回调函数
if (pagelist[new_page].SetupCallback != 0) {
pagelist[new_page].SetupCallback();
}
@@ -99,7 +112,7 @@ void Page_Run(void) {
}
if (page_busy == 0) {
- //执行循环函数
+ // 执行循环函数
pagelist[now_page].LoopCallback();
}
}
@@ -108,13 +121,15 @@ void Page_Run(void) {
* @brief 页面初始化(注册,构建) //ATTENTION 在此处添加新加入的页面
*
*/
-void Page_Init(void) {
+void Page_Init(void)
+{
PAGE_REG(page_menu);
+ PAGE_REG(page_rtcam);
// PAGE_REG(page_argv);
// PAGE_REG(page_sys);
// PAGE_REG(page_run);
Page_Shift(page_menu);
- pagelist[now_page].SetupCallback(); //先构建一遍
+ pagelist[now_page].SetupCallback(); // 先构建一遍
}
diff --git a/app/page/cw_page.h b/app/page/cw_page.h
index cd4f20e..dc9e15f 100644
--- a/app/page/cw_page.h
+++ b/app/page/cw_page.h
@@ -13,10 +13,13 @@
#include "zf_common_headfile.h"
+#include "by_rt_button.h"
+
enum PageID {
PAGE_NULL = -1,
//......
page_menu,
+ page_rtcam,
// page_argv,
// page_sys,
// page_run,
@@ -25,9 +28,9 @@ enum PageID {
};
typedef enum page_event{
- page_event_forward,
- page_event_backward,
- page_event_press
+ page_event_forward = ROTATE_BUTTON_FORWARD,
+ page_event_backward = ROTATE_BUTTON_BACKWARD,
+ page_event_press = ROTATE_BUTTON_PRESS
} page_event;
typedef void (*CallbackFunction_t)(void);
diff --git a/app/page/cw_page_menu.c b/app/page/cw_page_menu.c
index 4296ba6..ea5b939 100644
--- a/app/page/cw_page_menu.c
+++ b/app/page/cw_page_menu.c
@@ -7,8 +7,8 @@
static char Text[] = "Menu";
-static int8_t Curser = 1; // 定义光标位置
-static int8_t Curser_Last = 1; // 定义光标位置
+static int8_t Curser = LINE_HEAD; // 定义光标位置
+static int8_t Curser_Last = LINE_HEAD; // 定义光标位置
static void Print_Menu_p(void);
/***************************************************************************************
*
@@ -44,7 +44,6 @@ static void Exit()
*/
static void Loop()
{
- Show_Marked_Image();
}
/**
@@ -101,7 +100,7 @@ static void Print_Menu_p(void)
// SCREEN_showstr_style(5 * 8, 0, RED, WHITE, "#### MAIN MENU ####");
ips200_show_string(0, 0, Text);
for (uint8_t i = page_menu + 1; i < page_max; i++) {
- ips200_show_string(8, i, pagelist[i].Text);
+ ips200_show_string(10, i * 16, pagelist[i].Text);
// SCREEN_showstr(8, i, pagelist[i].Text);
}
}
diff --git a/app/page/cw_page_rtcam.c b/app/page/cw_page_rtcam.c
index 969963d..d23ccfa 100644
--- a/app/page/cw_page_rtcam.c
+++ b/app/page/cw_page_rtcam.c
@@ -2,13 +2,13 @@
#include "cw_page_ui_widget.h"
#include "cw_page.h"
-#define LINE_HEAD 1
-#define LINE_END 7
+#define LINE_HEAD 11
+#define LINE_END 18
static char Text[] = "RealTime Image";
-static int8_t Curser = 1; // 定义光标位置
-static int8_t Curser_Last = 1; // 定义光标位置
+static int8_t Curser = LINE_HEAD; // 定义光标位置
+static int8_t Curser_Last = LINE_HEAD; // 定义光标位置
static void Print_Menu_p(void);
/***************************************************************************************
*
@@ -23,7 +23,7 @@ static void Print_Menu_p(void);
*/
static void Setup()
{
- ips114_clear();
+ ips200_clear();
Print_Menu_p();
Print_Curser(Curser, Curser_Last);
}
@@ -44,6 +44,7 @@ static void Exit()
*/
static void Loop()
{
+ Show_Marked_Image();
}
/**
@@ -99,8 +100,4 @@ static void Print_Menu_p(void)
{
// SCREEN_showstr_style(5 * 8, 0, RED, WHITE, "#### MAIN MENU ####");
ips200_show_string(0, 0, Text);
- for (uint8_t i = page_menu + 1; i < page_max; i++) {
- ips200_show_string(8, i, pagelist[i].Text);
- // SCREEN_showstr(8, i, pagelist[i].Text);
- }
}
diff --git a/libraries/zf_common/zf_common_font.c b/libraries/zf_common/zf_common_font.c
index 094730a..e4e6515 100644
--- a/libraries/zf_common/zf_common_font.c
+++ b/libraries/zf_common/zf_common_font.c
@@ -2,11 +2,11 @@
* CH32V307VCT6 Opensourec Library CH32V307VCT6 Դ⣩һڹٷ SDK ӿڵĵԴ
* Copyright (c) 2022 SEEKFREE ɿƼ
*
-* ļCH32V307VCT6 Դһ
+* ļ CH32V307VCT6 Դһ
*
* CH32V307VCT6 Դ
-* Ըᷢ GPLGNU General Public License GNUͨù֤
-* GPL ĵ3棨 GPL3.0ѡģκκİ汾·/
+* Ըᷢ GPLGNU General Public License GNU ͨù֤
+* GPL ĵ 3 棨 GPL3.0ѡģκκİ汾·/
*
* Դķϣܷãδκεı֤
* ûԻʺض;ı֤
@@ -30,7 +30,7 @@
*
* ļ¼
* ע
-* 2022-09-15 W first version
+* 2022-09-15 W first version
********************************************************************************************************************/
#include "zf_common_font.h"
@@ -93,7 +93,8 @@ const uint8 ascii_font_8x16[][16]=
{0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x60,0x00,0x00,0x00,0x00}, // ; 27
{0x00,0x00,0x80,0x40,0x20,0x10,0x08,0x00,0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x00}, // < 28
{0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00}, // = 29
- {0x00,0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x00,0x20,0x10,0x08,0x04,0x02,0x01,0x00}, // > 30
+// {0x00,0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x00,0x20,0x10,0x08,0x04,0x02,0x01,0x00}, // > 30
+ {0xFE,0xFC,0xF8,0xF0,0xE0,0xC0,0x80,0x00,0x7F,0x3F,0x1F,0x0F,0x07,0x03,0x01,0x00}, // > 30
{0x00,0x70,0x48,0x08,0x08,0x08,0xF0,0x00,0x00,0x00,0x00,0x30,0x36,0x01,0x00,0x00}, // ? 31
{0xC0,0x30,0xC8,0x28,0xE8,0x10,0xE0,0x00,0x07,0x18,0x27,0x24,0x23,0x14,0x0B,0x00}, // @ 32
{0x00,0x00,0xC0,0x38,0xE0,0x00,0x00,0x00,0x20,0x3C,0x23,0x02,0x02,0x27,0x38,0x20}, // A 33
@@ -274,7 +275,7 @@ const uint8 ascii_font_6x8[][6] =
};
//-------------------------------------------------------------------------------------------------------------------
-// ʹPCtoLCD2002ȡģ
+// ʹ PCtoLCD2002 ȡģ
// 롢ʽ˳ 16*16
//-------------------------------------------------------------------------------------------------------------------
const uint8 chinese_test[8][16] =
@@ -290,7 +291,7 @@ const uint8 chinese_test[8][16] =
};
//-------------------------------------------------------------------------------------------------------------------
-// ʹPCtoLCD2002ȡģ
+// ʹ PCtoLCD2002 ȡģ
// 롢ʽ 16*16
//-------------------------------------------------------------------------------------------------------------------
const uint8 oled_16x16_chinese[][16]=
@@ -305,10 +306,10 @@ const uint8 oled_16x16_chinese[][16]=
{0x04,0x44,0x82,0x7F,0x01,0x80,0x80,0x40,0x43,0x2C,0x10,0x28,0x46,0x81,0x80,0x00},/*"",3*/
};
-//16λBMP 240*80 ɿƼlogoͼȡģ
-//Image2LCDȡģѡ
+//16 λ BMP 240*80 ɿƼ logo ͼȡģ
+//Image2LCD ȡģѡ
//ˮƽɨ
-//16λ
+//16 λ
//240*80
//ͼͷ
//