Merge pull request 'master' (#11) from define/firmware_violet_zf:master into master

Reviewed-on: http://git.isthmus.tk:441/btl143/firmware_violet_zf/pulls/11
This commit is contained in:
2024-01-05 16:04:22 +08:00
14 changed files with 309 additions and 225 deletions

View File

@@ -12,11 +12,13 @@ void by_pwm_init(void)
void by_pwm_update_duty(uint32_t update_pwm_duty) void by_pwm_update_duty(uint32_t update_pwm_duty)
{ {
if (7000UL > update_pwm_duty) { if (4000UL < update_pwm_duty) {
update_pwm_duty = 7000UL; update_pwm_duty = 4000UL;
} }
pwm_set_duty(TIM4_PWM_MAP1_CH1_D12, update_pwm_duty); 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_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) void by_pwm_power_duty(uint32_t power_pwm_duty_l, uint32_t power_pwm_duty_r)

View File

@@ -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

View File

@@ -1,7 +1,7 @@
#include "by_pt_button.h" #include "by_rt_button.h"
#include "zf_common_headfile.h" #include "zf_common_headfile.h"
#include "by_imu.h" #include "by_imu.h"
uint8_t potate_button; uint8_t rotate_button;
void by_gpio_init(void) void by_gpio_init(void)
{ {
@@ -11,21 +11,26 @@ void by_gpio_init(void)
void by_exit_init(void) void by_exit_init(void)
{ {
exti_init(E9, EXTI_TRIGGER_FALLING); exti_init(E9, EXTI_TRIGGER_FALLING);
exti_init(E11, EXTI_TRIGGER_FALLING); exti_init(E11, EXTI_TRIGGER_BOTH);
} }
uint8_t by_get_pb_statu(void) /**
* @brief -
*
* @return uint8_t
*/
uint8_t by_get_rb_status(void)
{ {
uint8_t temp_s = potate_button; uint8_t temp_s = rotate_button;
potate_button = 0; rotate_button = 0;
return temp_s; return temp_s;
} }
void by_ips_show(void) void by_ips_show(void)
{ {
ips200_show_string(0, 0, "button statu:"); ips200_show_string(0, 0, "button status:");
// ips200_show_uint(104, 0, by_get_pb_statu(), 1); // ips200_show_uint(104, 0, by_get_rb_status(), 1);
switch (by_get_pb_statu()) { switch (by_get_rb_status()) {
case 1: case 1:
ips200_show_string(104, 0, "press"); ips200_show_string(104, 0, "press");
break; break;

21
app/by_rt_button.h Normal file
View File

@@ -0,0 +1,21 @@
#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

View File

@@ -2,11 +2,11 @@
* CH32V307VCT6 Opensourec Library 即CH32V307VCT6 开源库)是一个基于官方 SDK 接口的第三方开源库 * CH32V307VCT6 Opensourec Library 即CH32V307VCT6 开源库)是一个基于官方 SDK 接口的第三方开源库
* Copyright (c) 2022 SEEKFREE 逐飞科技 * Copyright (c) 2022 SEEKFREE 逐飞科技
* *
* 本文件是CH32V307VCT6 开源库的一部分 * 本文件是 CH32V307VCT6 开源库的一部分
* *
* CH32V307VCT6 开源库 是免费软件 * CH32V307VCT6 开源库 是免费软件
* 您可以根据自由软件基金会发布的 GPLGNU General Public License即 GNU通用公共许可证的条款 * 您可以根据自由软件基金会发布的 GPLGNU General Public License即 GNU 通用公共许可证)的条款
* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它 * 即 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 "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 NMI_Handler(void) __attribute__((interrupt()));
void HardFault_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 == EXTI_GetITStatus(EXTI_Line9)) {
if (SET == gpio_get_level(E10)) { if (SET == gpio_get_level(E10)) {
potate_button = POTATE_BUTTOM_BACKWARD; rotate_button = rotate_button_backward;
} else { } else {
potate_button = POTATE_BUTTOM_FOREWARD; rotate_button = rotate_button_forward;
} }
EXTI_ClearITPendingBit(EXTI_Line9); EXTI_ClearITPendingBit(EXTI_Line9);
} }
@@ -217,10 +218,24 @@ void EXTI15_10_IRQHandler(void)
EXTI_ClearITPendingBit(EXTI_Line10); EXTI_ClearITPendingBit(EXTI_Line10);
} }
if (SET == EXTI_GetITStatus(EXTI_Line11)) { if (SET == EXTI_GetITStatus(EXTI_Line11)) {
static uint64_t time_via = 0;
if (RESET == gpio_get_level(E11)) {
system_delay_us(200); system_delay_us(200);
if (SET == !gpio_get_level(E11)) { if (RESET == gpio_get_level(E11)) {
potate_button = POTATE_BUTTOM_PRESS; time_via = system_get_tick();
}
EXTI_ClearITPendingBit(EXTI_Line11);
} else {
system_delay_us(200);
if (SET == gpio_get_level(E11)) {
time_via = system_get_tick() - time_via;
if (time_via > LONG_PRESS_THRESHOLD_TICK) {
rotate_button = rotate_button_press_long;
} else {
rotate_button = rotate_button_press_short;
}
time_via = 0;
} }
EXTI_ClearITPendingBit(EXTI_Line11); EXTI_ClearITPendingBit(EXTI_Line11);
} }
@@ -249,6 +264,7 @@ void EXTI15_10_IRQHandler(void)
// -----------------* DM1XA 声/反馈信号 预置中断处理函数 *----------------- // -----------------* DM1XA 声/反馈信号 预置中断处理函数 *-----------------
EXTI_ClearITPendingBit(EXTI_Line15); EXTI_ClearITPendingBit(EXTI_Line15);
} }
}
} }
void TIM1_UP_IRQHandler(void) void TIM1_UP_IRQHandler(void)

View File

@@ -1,29 +1,29 @@
/********************************************************************************************************************* /*********************************************************************************************************************
* CH32V307VCT6 Opensourec Library 即CH32V307VCT6 开源库)是一个基于官方 SDK 接口的第三方开源库 * CH32V307VCT6 Opensourec Library 即CH32V307VCT6 开源库)是一个基于官方 SDK 接口的第三方开源库
* Copyright (c) 2022 SEEKFREE 逐飞科技 * Copyright (c) 2022 SEEKFREE 逐飞科技
* *
* 本文件是 CH32V307VCT6 开源库的一部分 * 本文件是 CH32V307VCT6 开源库的一部分
* *
* CH32V307VCT6 开源库 是免费软件 * CH32V307VCT6 开源库 是免费软件
* 您可以根据自由软件基金会发布的 GPLGNU General Public License即 GNU 通用公共许可证)的条款 * 您可以根据自由软件基金会发布的 GPLGNU General Public License即 GNU 通用公共许可证)的条款
* 即 GPL 的第 3 版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它 * 即 GPL 的第 3 版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
* *
* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证 * 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
* 甚至没有隐含的适销性或适合特定用途的保证 * 甚至没有隐含的适销性或适合特定用途的保证
* 更多细节请参见 GPL * 更多细节请参见 GPL
* *
* 您应该在收到本开源库的同时收到一份 GPL 的副本 * 您应该在收到本开源库的同时收到一份 GPL 的副本
* 如果没有,请参阅<https://www.gnu.org/licenses/> * 如果没有,请参阅<https://www.gnu.org/licenses/>
* *
* 额外注明: * 额外注明:
* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本 * 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中 * 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件 * 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明) * 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
********************************************************************************************************************/ ********************************************************************************************************************/
#include "zf_common_headfile.h" #include "zf_common_headfile.h"
#include "gl_headfile.h" #include "gl_headfile.h"
#include "by_pt_button.h" #include "by_rt_button.h"
#include "by_fan_control.h" #include "by_fan_control.h"
#include "cw_servo.h" #include "cw_servo.h"
#include "./page/cw_page.h" #include "./page/cw_page.h"
@@ -71,25 +71,45 @@ enum track_type_e track_type = TRACK_RIGHT;
int frame_count = 0; int frame_count = 0;
uint16_t pwm_cnt = 500;
void img_processing(); void img_processing();
void get_corners(); void get_corners();
int main(void) int main(void)
{ {
clock_init(SYSTEM_CLOCK_120M); clock_init(SYSTEM_CLOCK_120M);
system_delay_init();
debug_init(); debug_init();
mt9v03x_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); ips200_init(IPS200_TYPE_SPI);
by_gpio_init(); by_gpio_init();
by_exit_init(); by_exit_init();
by_pwm_init(); by_pwm_init();
cw_servo_init(); // cw_servo_init();
// while (imu660ra_init()) // while (imu660ra_init())
// ; // ;
Page_Init(); Page_Init();
while (1) { 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(); Page_Run();
if (mt9v03x_finish_flag) { if (mt9v03x_finish_flag) {

View File

@@ -1,5 +1,7 @@
#include "cw_page.h" #include "cw_page.h"
#include "by_rt_button.h"
PAGE_LIST pagelist[page_max]; PAGE_LIST pagelist[page_max];
static uint8_t page_busy = 0; static uint8_t page_busy = 0;
static int8_t now_page = page_menu; static int8_t now_page = page_menu;
@@ -17,7 +19,8 @@ static int8_t new_page = page_menu;
*/ */
void Page_Register(uint8_t pageID, char *pageText, void Page_Register(uint8_t pageID, char *pageText,
CallbackFunction_t setupCallback, CallbackFunction_t loopCallback, CallbackFunction_t setupCallback, CallbackFunction_t loopCallback,
CallbackFunction_t exitCallback, EventFunction_t eventCallback) { CallbackFunction_t exitCallback, EventFunction_t eventCallback)
{
pagelist[pageID].Text = pageText; pagelist[pageID].Text = pageText;
pagelist[pageID].SetupCallback = setupCallback; pagelist[pageID].SetupCallback = setupCallback;
pagelist[pageID].LoopCallback = loopCallback; pagelist[pageID].LoopCallback = loopCallback;
@@ -30,7 +33,8 @@ void Page_Register(uint8_t pageID, char *pageText,
* @param event: 事件编号 * @param event: 事件编号
* @retval 无 * @retval 无
*/ */
void Page_EventTransmit(unsigned char event) { void Page_EventTransmit(unsigned char event)
{
/*将事件传递到当前页面*/ /*将事件传递到当前页面*/
if (pagelist[now_page].EventCallback != 0) if (pagelist[now_page].EventCallback != 0)
pagelist[now_page].EventCallback(event); pagelist[now_page].EventCallback(event);
@@ -41,7 +45,8 @@ void Page_EventTransmit(unsigned char event) {
* @param pageID页面号 * @param pageID页面号
* @retval 1成功 0失败 * @retval 1成功 0失败
*/ */
void Page_Shift(unsigned char pageID) { void Page_Shift(unsigned char pageID)
{
if (page_busy == 0) { if (page_busy == 0) {
new_page = pageID; new_page = pageID;
} }
@@ -51,7 +56,8 @@ void Page_Shift(unsigned char pageID) {
* @brief 关闭当前页面 * @brief 关闭当前页面
* *
*/ */
void Page_CloseCurrentPage() { void Page_CloseCurrentPage()
{
pagelist[now_page].ExitCallback(); pagelist[now_page].ExitCallback();
} }
@@ -59,16 +65,18 @@ void Page_CloseCurrentPage() {
* @brief 打开当前页面 * @brief 打开当前页面
* *
*/ */
void Page_OpenCurrentPage() { void Page_OpenCurrentPage()
{
pagelist[now_page].SetupCallback(); pagelist[now_page].SetupCallback();
} }
/** /**
* @brief 获取页面状态 * @brief 获取页面状态
* *
* @return uint8_t 页面忙返回1 空闲返回0 * @return uint8_t 页面忙返回 1 空闲返回 0
*/ */
uint8_t Page_GetStatus(void) { uint8_t Page_GetStatus(void)
{
if (page_busy) if (page_busy)
return 1; return 1;
else else
@@ -79,18 +87,23 @@ uint8_t Page_GetStatus(void) {
* @brief 页面运行函数 * @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 (now_page != new_page) {
if (new_page >= page_max && new_page < page_menu) { if (new_page >= page_max && new_page < page_menu) {
new_page = page_menu; new_page = page_menu;
} }
//执行当前页面退出回调函数 // 执行当前页面退出回调函数
if ((pagelist[now_page].ExitCallback != 0)) { if ((pagelist[now_page].ExitCallback != 0)) {
pagelist[now_page].ExitCallback(); pagelist[now_page].ExitCallback();
} }
//执行新页面构造回调函数 // 执行新页面构造回调函数
if (pagelist[new_page].SetupCallback != 0) { if (pagelist[new_page].SetupCallback != 0) {
pagelist[new_page].SetupCallback(); pagelist[new_page].SetupCallback();
} }
@@ -99,7 +112,7 @@ void Page_Run(void) {
} }
if (page_busy == 0) { if (page_busy == 0) {
//执行循环函数 // 执行循环函数
pagelist[now_page].LoopCallback(); pagelist[now_page].LoopCallback();
} }
} }
@@ -108,13 +121,15 @@ void Page_Run(void) {
* @brief 页面初始化(注册,构建) //ATTENTION 在此处添加新加入的页面 * @brief 页面初始化(注册,构建) //ATTENTION 在此处添加新加入的页面
* *
*/ */
void Page_Init(void) { void Page_Init(void)
{
PAGE_REG(page_menu); PAGE_REG(page_menu);
PAGE_REG(page_rtcam);
// PAGE_REG(page_argv); // PAGE_REG(page_argv);
// PAGE_REG(page_sys); // PAGE_REG(page_sys);
// PAGE_REG(page_run); // PAGE_REG(page_run);
Page_Shift(page_menu); Page_Shift(page_menu);
pagelist[now_page].SetupCallback(); //先构建一遍 pagelist[now_page].SetupCallback(); // 先构建一遍
} }

View File

@@ -13,10 +13,13 @@
#include "zf_common_headfile.h" #include "zf_common_headfile.h"
#include "by_rt_button.h"
enum PageID { enum PageID {
PAGE_NULL = -1, PAGE_NULL = -1,
//...... //......
page_menu, page_menu,
page_rtcam,
// page_argv, // page_argv,
// page_sys, // page_sys,
// page_run, // page_run,
@@ -25,9 +28,10 @@ enum PageID {
}; };
typedef enum page_event{ typedef enum page_event{
page_event_forward, page_event_forward = rotate_button_forward,
page_event_backward, page_event_backward = rotate_button_backward,
page_event_press page_event_press_short = rotate_button_press_short,
page_event_press_long = rotate_button_press_long,
} page_event; } page_event;
typedef void (*CallbackFunction_t)(void); typedef void (*CallbackFunction_t)(void);

View File

@@ -7,8 +7,8 @@
static char Text[] = "Menu"; static char Text[] = "Menu";
static int8_t Curser = 1; // 定义光标位置 static int8_t Curser = LINE_HEAD; // 定义光标位置
static int8_t Curser_Last = 1; // 定义光标位置 static int8_t Curser_Last = LINE_HEAD; // 定义光标位置
static void Print_Menu_p(void); static void Print_Menu_p(void);
/*************************************************************************************** /***************************************************************************************
* *
@@ -23,7 +23,7 @@ static void Print_Menu_p(void);
*/ */
static void Setup() static void Setup()
{ {
ips114_clear(); ips200_clear();
Print_Menu_p(); Print_Menu_p();
Print_Curser(Curser, Curser_Last); Print_Curser(Curser, Curser_Last);
} }
@@ -44,7 +44,6 @@ static void Exit()
*/ */
static void Loop() static void Loop()
{ {
Show_Marked_Image();
} }
/** /**
@@ -61,7 +60,7 @@ static void Event(page_event event)
Curser--; // 光标上移 Curser--; // 光标上移
} else if (page_event_backward == event) { } else if (page_event_backward == event) {
Curser++; // 光标下移 Curser++; // 光标下移
} else if (page_event_press == event) { } else if (page_event_press_short == event) {
if (page_max > Curser && page_menu < Curser) { if (page_max > Curser && page_menu < Curser) {
Page_Shift(Curser); // 切换到光标选中的页面 Page_Shift(Curser); // 切换到光标选中的页面
} }
@@ -101,7 +100,7 @@ static void Print_Menu_p(void)
// SCREEN_showstr_style(5 * 8, 0, RED, WHITE, "#### MAIN MENU ####"); // SCREEN_showstr_style(5 * 8, 0, RED, WHITE, "#### MAIN MENU ####");
ips200_show_string(0, 0, Text); ips200_show_string(0, 0, Text);
for (uint8_t i = page_menu + 1; i < page_max; i++) { 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); // SCREEN_showstr(8, i, pagelist[i].Text);
} }
} }

View File

@@ -2,13 +2,13 @@
#include "cw_page_ui_widget.h" #include "cw_page_ui_widget.h"
#include "cw_page.h" #include "cw_page.h"
#define LINE_HEAD 1 #define LINE_HEAD 11
#define LINE_END 7 #define LINE_END 18
static char Text[] = "RealTime Image"; static char Text[] = "RealTime Image";
static int8_t Curser = 1; // 定义光标位置 static int8_t Curser = LINE_HEAD; // 定义光标位置
static int8_t Curser_Last = 1; // 定义光标位置 static int8_t Curser_Last = LINE_HEAD; // 定义光标位置
static void Print_Menu_p(void); static void Print_Menu_p(void);
/*************************************************************************************** /***************************************************************************************
* *
@@ -23,7 +23,7 @@ static void Print_Menu_p(void);
*/ */
static void Setup() static void Setup()
{ {
ips114_clear(); ips200_clear();
Print_Menu_p(); Print_Menu_p();
Print_Curser(Curser, Curser_Last); Print_Curser(Curser, Curser_Last);
} }
@@ -44,6 +44,7 @@ static void Exit()
*/ */
static void Loop() static void Loop()
{ {
Show_Marked_Image();
} }
/** /**
@@ -60,10 +61,10 @@ static void Event(page_event event)
Curser--; // 光标上移 Curser--; // 光标上移
} else if (page_event_backward == event) { } else if (page_event_backward == event) {
Curser++; // 光标下移 Curser++; // 光标下移
} else if (page_event_press == event) { } else if (page_event_press_short == event) {
if (page_max > Curser && page_menu < Curser) {
Page_Shift(Curser); // 切换到光标选中的页面 } else if (page_event_press_long == event) {
} Page_Shift(page_menu);
} }
if (Curser < LINE_HEAD) { if (Curser < LINE_HEAD) {
@@ -99,8 +100,4 @@ static void Print_Menu_p(void)
{ {
// SCREEN_showstr_style(5 * 8, 0, RED, WHITE, "#### MAIN MENU ####"); // SCREEN_showstr_style(5 * 8, 0, RED, WHITE, "#### MAIN MENU ####");
ips200_show_string(0, 0, Text); 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);
}
} }

View File

@@ -2,11 +2,11 @@
* CH32V307VCT6 Opensourec Library 即CH32V307VCT6 开源库)是一个基于官方 SDK 接口的第三方开源库 * CH32V307VCT6 Opensourec Library 即CH32V307VCT6 开源库)是一个基于官方 SDK 接口的第三方开源库
* Copyright (c) 2022 SEEKFREE 逐飞科技 * Copyright (c) 2022 SEEKFREE 逐飞科技
* *
* 本文件是CH32V307VCT6 开源库的一部分 * 本文件是 CH32V307VCT6 开源库的一部分
* *
* CH32V307VCT6 开源库 是免费软件 * CH32V307VCT6 开源库 是免费软件
* 您可以根据自由软件基金会发布的 GPLGNU General Public License即 GNU通用公共许可证的条款 * 您可以根据自由软件基金会发布的 GPLGNU General Public License即 GNU 通用公共许可证)的条款
* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它 * 即 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" #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,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 {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 {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 {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 {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 {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 // 阴码、逐行式、顺向 16*16
//------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------
const uint8 chinese_test[8][16] = const uint8 chinese_test[8][16] =
@@ -290,7 +291,7 @@ const uint8 chinese_test[8][16] =
}; };
//------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------
// 使用PCtoLCD2002软件取模 // 使用 PCtoLCD2002 软件取模
// 阴码、列行式、逆向 16*16 // 阴码、列行式、逆向 16*16
//------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------
const uint8 oled_16x16_chinese[][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*/ {0x04,0x44,0x82,0x7F,0x01,0x80,0x80,0x40,0x43,0x2C,0x10,0x28,0x46,0x81,0x80,0x00},/*"技",3*/
}; };
//16BMP 240*80 逐飞科技logo图像取模数据 //16BMP 240*80 逐飞科技 logo 图像取模数据
//Image2LCD取模选项设置 //Image2LCD 取模选项设置
//水平扫描 //水平扫描
//16位 //16
//240*80 //240*80
//不包含图像头数据 //不包含图像头数据
//自左至右 //自左至右

View File

@@ -115,8 +115,8 @@
// --------------------双排 SPI 接口两寸屏幕引脚定义--------------------// // --------------------双排 SPI 接口两寸屏幕引脚定义--------------------//
#define IPS200_DEFAULT_DISPLAY_DIR (IPS200_PORTAIT) // 默认的显示方向 #define IPS200_DEFAULT_DISPLAY_DIR (IPS200_PORTAIT) // 默认的显示方向
#define IPS200_DEFAULT_PENCOLOR (RGB565_RED ) // 默认的画笔颜色 #define IPS200_DEFAULT_PENCOLOR (RGB565_BLACK ) // 默认的画笔颜色
#define IPS200_DEFAULT_BGCOLOR (RGB565_WHITE ) // 默认的背景颜色 #define IPS200_DEFAULT_BGCOLOR (RGB565_YELLOW ) // 默认的背景颜色
#define IPS200_DEFAULT_DISPLAY_FONT (IPS200_8X16_FONT) // 默认的字体模式 #define IPS200_DEFAULT_DISPLAY_FONT (IPS200_8X16_FONT) // 默认的字体模式
// 控制语句 // 控制语句

View File

@@ -1,37 +1,37 @@
/********************************************************************************************************************* /*********************************************************************************************************************
* CH32V307VCT6 Opensourec Library 即CH32V307VCT6 开源库)是一个基于官方 SDK 接口的第三方开源库 * CH32V307VCT6 Opensourec Library 即CH32V307VCT6 开源库)是一个基于官方 SDK 接口的第三方开源库
* Copyright (c) 2022 SEEKFREE 逐飞科技 * Copyright (c) 2022 SEEKFREE 逐飞科技
* *
* 本文件是CH32V307VCT6 开源库的一部分 * 本文件是 CH32V307VCT6 开源库的一部分
* *
* CH32V307VCT6 开源库 是免费软件 * CH32V307VCT6 开源库 是免费软件
* 您可以根据自由软件基金会发布的 GPLGNU General Public License即 GNU通用公共许可证的条款 * 您可以根据自由软件基金会发布的 GPLGNU General Public License即 GNU 通用公共许可证)的条款
* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它 * 即 GPL 的第 3 版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
* *
* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证 * 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
* 甚至没有隐含的适销性或适合特定用途的保证 * 甚至没有隐含的适销性或适合特定用途的保证
* 更多细节请参见 GPL * 更多细节请参见 GPL
* *
* 您应该在收到本开源库的同时收到一份 GPL 的副本 * 您应该在收到本开源库的同时收到一份 GPL 的副本
* 如果没有,请参阅<https://www.gnu.org/licenses/> * 如果没有,请参阅<https://www.gnu.org/licenses/>
* *
* 额外注明: * 额外注明:
* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本 * 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中 * 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件 * 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明) * 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
* *
* 文件名称 zf_driver_delay * 文件名称 zf_driver_delay
* 公司名称 成都逐飞科技有限公司 * 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明 * 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
* 开发环境 MounRiver Studio V1.8.1 * 开发环境 MounRiver Studio V1.8.1
* 适用平台 CH32V307VCT6 * 适用平台 CH32V307VCT6
* 店铺链接 https://seekfree.taobao.com/ * 店铺链接 https://seekfree.taobao.com/
* *
* 修改记录 * 修改记录
* 日期 作者 备注 * 日期 作者 备注
* 2022-09-15 大W first version * 2022-09-15 大 W first version
********************************************************************************************************************/ ********************************************************************************************************************/
#include "ch32v30x.h" #include "ch32v30x.h"
@@ -46,21 +46,23 @@
// 使用示例 system_delay_ms(100); // 使用示例 system_delay_ms(100);
// 备注信息 // 备注信息
//------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------
void system_delay_ms (uint32 num) void system_delay_ms(uint32 num)
{ {
SysTick->SR &= ~(1 << 0); // SysTick->SR &= ~(1 << 0);
// SysTick->CMP = (uint64_t)(system_clock / 8000) * num;
// SysTick->CTLR |= (1 << 4);
// SysTick->CTLR |= (1 << 5) | (1 << 0);
SysTick->CMP = (uint64_t)(system_clock/8000) * num; // while ((SysTick->SR & (1 << 0)) != (1 << 0))
SysTick->CTLR |= (1 << 4); // ;
SysTick->CTLR |= (1 << 5) | (1 << 0);
while((SysTick->SR & (1 << 0)) != (1 << 0)); // SysTick->CTLR &= ~(1 << 0);
while (num--) {
SysTick->CTLR &= ~(1 << 0); system_delay_us(1000);
}
} }
//------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------
// 函数简介 system 延时函数 us 级别 // 函数简介 system 延时函数 us 级别
// 参数说明 time 需要延时的时间 us 级别 // 参数说明 time 需要延时的时间 us 级别
@@ -68,18 +70,32 @@ void system_delay_ms (uint32 num)
// 使用示例 system_delay_us(100); // 使用示例 system_delay_us(100);
// 备注信息 受限于程序运行跳转 此延时会比输入值高出一些 // 备注信息 受限于程序运行跳转 此延时会比输入值高出一些
//------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------
void system_delay_us (uint32 num) void system_delay_us(uint32 num)
{ {
SysTick->SR &= ~(1 << 0); // SysTick->SR &= ~(1 << 0);
// SysTick->CMP = (uint64_t)(system_clock/8000000) * num;
// SysTick->CTLR |= (1 << 4);
// SysTick->CTLR |= (1 << 5) | (1 << 0);
SysTick->CMP = (uint64_t)(system_clock/8000000) * num; // while((SysTick->SR & (1 << 0)) != (1 << 0));
SysTick->CTLR |= (1 << 4);
SysTick->CTLR |= (1 << 5) | (1 << 0);
while((SysTick->SR & (1 << 0)) != (1 << 0)); // SysTick->CTLR &= ~(1 << 0);
SysTick->CTLR &= ~(1 << 0); uint64_t time_start = SysTick->CNT;
uint64_t time_delta = (uint64_t)num * (uint64_t)(system_clock / 8000000);
while (time_delta > (SysTick->CNT - time_start)) {
}
} }
uint64_t system_get_tick(void)
{
uint64_t time_temp = SysTick->CNT;
return (time_temp);
}
void system_delay_init(void)
{
SysTick->CTLR |= 0x21;
}

View File

@@ -1,37 +1,37 @@
/********************************************************************************************************************* /*********************************************************************************************************************
* CH32V307VCT6 Opensourec Library 即CH32V307VCT6 开源库)是一个基于官方 SDK 接口的第三方开源库 * CH32V307VCT6 Opensourec Library 即CH32V307VCT6 开源库)是一个基于官方 SDK 接口的第三方开源库
* Copyright (c) 2022 SEEKFREE 逐飞科技 * Copyright (c) 2022 SEEKFREE 逐飞科技
* *
* 本文件是CH32V307VCT6 开源库的一部分 * 本文件是CH32V307VCT6 开源库的一部分
* *
* CH32V307VCT6 开源库 是免费软件 * CH32V307VCT6 开源库 是免费软件
* 您可以根据自由软件基金会发布的 GPLGNU General Public License即 GNU通用公共许可证的条款 * 您可以根据自由软件基金会发布的 GPLGNU General Public License即 GNU通用公共许可证的条款
* 即 GPL 的第3版即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它 * 即 GPL 的第3版即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
* *
* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证 * 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
* 甚至没有隐含的适销性或适合特定用途的保证 * 甚至没有隐含的适销性或适合特定用途的保证
* 更多细节请参见 GPL * 更多细节请参见 GPL
* *
* 您应该在收到本开源库的同时收到一份 GPL 的副本 * 您应该在收到本开源库的同时收到一份 GPL 的副本
* 如果没有,请参阅<https://www.gnu.org/licenses/> * 如果没有,请参阅<https://www.gnu.org/licenses/>
* *
* 额外注明: * 额外注明:
* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本 * 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中 * 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件 * 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明) * 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
* *
* 文件名称 zf_driver_delay * 文件名称 zf_driver_delay
* 公司名称 成都逐飞科技有限公司 * 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明 * 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
* 开发环境 MounRiver Studio V1.8.1 * 开发环境 MounRiver Studio V1.8.1
* 适用平台 CH32V307VCT6 * 适用平台 CH32V307VCT6
* 店铺链接 https://seekfree.taobao.com/ * 店铺链接 https://seekfree.taobao.com/
* *
* 修改记录 * 修改记录
* 日期 作者 备注 * 日期 作者 备注
* 2022-09-15 大W first version * 2022-09-15 大W first version
********************************************************************************************************************/ ********************************************************************************************************************/
#ifndef _zf_driver_delay_h #ifndef _zf_driver_delay_h
#define _zf_driver_delay_h #define _zf_driver_delay_h
@@ -39,7 +39,12 @@
#include "zf_common_clock.h" #include "zf_common_clock.h"
#include "zf_common_typedef.h" #include "zf_common_typedef.h"
void system_delay_ms (uint32 time); #define LONG_PRESS_THRESHOLD_MS (300ULL)
void system_delay_us (uint32 time); #define LONG_PRESS_THRESHOLD_TICK (LONG_PRESS_THRESHOLD_MS * 18000ULL)
void system_delay_ms(uint32 time);
void system_delay_us(uint32 time);
uint64_t system_get_tick(void);
void system_delay_init(void);
#endif #endif