mirror of
https://gitee.com/Polarix/simplegui.git
synced 2025-06-17 21:47:52 +00:00
2018-01-15:移植演示工程按键处理,使用串口代替键盘模拟发送键码。
This commit is contained in:
parent
4af1935944
commit
00a6db3f0a
@ -70,7 +70,6 @@ HMI_ENGINE_RESULT HMI_DemoRealGraph_ProcessEvent(HMI_EVENT_TYPE eEventType, cons
|
|||||||
HMI_ENGINE_RESULT eProcessResult;
|
HMI_ENGINE_RESULT eProcessResult;
|
||||||
SGUI_INT iNewValue;
|
SGUI_INT iNewValue;
|
||||||
SGUI_UINT16* parrKeyValue;
|
SGUI_UINT16* parrKeyValue;
|
||||||
static SGUI_UINT uiTimer = 3;
|
|
||||||
|
|
||||||
/*----------------------------------*/
|
/*----------------------------------*/
|
||||||
/* Initialize */
|
/* Initialize */
|
||||||
@ -101,17 +100,9 @@ HMI_ENGINE_RESULT HMI_DemoRealGraph_ProcessEvent(HMI_EVENT_TYPE eEventType, cons
|
|||||||
}
|
}
|
||||||
case HMI_ENGINE_ACTION_ON_TIMER:
|
case HMI_ENGINE_ACTION_ON_TIMER:
|
||||||
{
|
{
|
||||||
if(uiTimer > 0)
|
|
||||||
{
|
|
||||||
uiTimer--;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
uiTimer = 5;
|
|
||||||
iNewValue = *((SGUI_INT*)pstEvent->Data);
|
iNewValue = *((SGUI_INT*)pstEvent->Data);
|
||||||
SGUI_RealtimeGraph_AppendValue(&s_stRealtimeGraph, iNewValue);
|
SGUI_RealtimeGraph_AppendValue(&s_stRealtimeGraph, iNewValue);
|
||||||
HMI_DemoRealGraph_RefreshScreen(NULL);
|
HMI_DemoRealGraph_RefreshScreen(NULL);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -133,7 +133,6 @@ HMI_ENGINE_RESULT HMI_DemoScrollingText_ProcessEvent(HMI_EVENT_TYPE eEventType,
|
|||||||
/* Variable Declaration */
|
/* Variable Declaration */
|
||||||
/*----------------------------------*/
|
/*----------------------------------*/
|
||||||
HMI_ENGINE_RESULT eProcessResult;
|
HMI_ENGINE_RESULT eProcessResult;
|
||||||
static SGUI_UINT uiTimer = 1;
|
|
||||||
SGUI_UINT16* parrKeyValue;
|
SGUI_UINT16* parrKeyValue;
|
||||||
|
|
||||||
/*----------------------------------*/
|
/*----------------------------------*/
|
||||||
@ -165,13 +164,7 @@ HMI_ENGINE_RESULT HMI_DemoScrollingText_ProcessEvent(HMI_EVENT_TYPE eEventType,
|
|||||||
}
|
}
|
||||||
case HMI_ENGINE_ACTION_ON_TIMER:
|
case HMI_ENGINE_ACTION_ON_TIMER:
|
||||||
{
|
{
|
||||||
if(uiTimer > 0)
|
//SGUI_Frame_DrawFullScreenFrame(&s_stTextFrame);
|
||||||
{
|
|
||||||
uiTimer--;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SGUI_Frame_DrawFullScreenFrame(&s_stTextFrame);
|
|
||||||
SGUI_Text_DrawMultipleLinesText(s_szDemoText, SGUI_FONT_SIZE_H12, &s_stTextDisplayArea, s_iTextOffset, SGUI_DRAW_NORMAL);
|
SGUI_Text_DrawMultipleLinesText(s_szDemoText, SGUI_FONT_SIZE_H12, &s_stTextDisplayArea, s_iTextOffset, SGUI_DRAW_NORMAL);
|
||||||
if(s_iTextOffset + s_iTextHeight == 0)
|
if(s_iTextOffset + s_iTextHeight == 0)
|
||||||
{
|
{
|
||||||
@ -181,8 +174,6 @@ HMI_ENGINE_RESULT HMI_DemoScrollingText_ProcessEvent(HMI_EVENT_TYPE eEventType,
|
|||||||
{
|
{
|
||||||
s_iTextOffset--;
|
s_iTextOffset--;
|
||||||
}
|
}
|
||||||
uiTimer = 1;
|
|
||||||
}
|
|
||||||
eProcessResult = HMI_RET_NOACTION;
|
eProcessResult = HMI_RET_NOACTION;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
#ifndef __INCLUDE_USART_KEY_H__
|
#ifndef __INCLUDE_DEMOACTIONS_H__
|
||||||
#define __INCLUDE_USART_KEY_H__
|
#define __INCLUDE_DEMOACTIONS_H__
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#define KEY_NONE (0x00)
|
||||||
// Key value definition.
|
// Key value definition.
|
||||||
#define KEY_VALUE_TAB (0x01)
|
#define KEY_VALUE_TAB (0x01)
|
||||||
#define KEY_VALUE_ENTER (0x02)
|
#define KEY_VALUE_ENTER (0x02)
|
||||||
@ -12,9 +15,12 @@
|
|||||||
#define KEY_VALUE_DOWN (0x08)
|
#define KEY_VALUE_DOWN (0x08)
|
||||||
|
|
||||||
// User option flag value define
|
// User option flag value define
|
||||||
#define KEY_OPTION_NONE (0x00)
|
|
||||||
#define KEY_OPTION_CTRL (0x10)
|
#define KEY_OPTION_CTRL (0x10)
|
||||||
#define KEY_OPTION_ALT (0x20)
|
#define KEY_OPTION_ALT (0x20)
|
||||||
#define KEY_OPTION_SHIFT (0x40)
|
#define KEY_OPTION_SHIFT (0x40)
|
||||||
|
|
||||||
#endif /* __INCLUDE_USART_KEY_H__ */
|
void DemoAction_InitializeUsart1(void);
|
||||||
|
void DemoAction_TimerEvent(void);
|
||||||
|
void DemoAction_UsartReceiveEvent(uint8_t cbReceiveByte);
|
||||||
|
|
||||||
|
#endif /* __INCLUDE_DEMOACTIONS_H__ */
|
@ -8,7 +8,7 @@
|
|||||||
使用方法以及运作机理,在演示过程中,您可以通过串口发送特定字节模拟键盘\
|
使用方法以及运作机理,在演示过程中,您可以通过串口发送特定字节模拟键盘\
|
||||||
输入与SimpleGUI演示工程进行交互,以实现与模拟器中类似的效果。每字节高\
|
输入与SimpleGUI演示工程进行交互,以实现与模拟器中类似的效果。每字节高\
|
||||||
四位为控制键码,低四位为主键码。\n\
|
四位为控制键码,低四位为主键码。\n\
|
||||||
使用串口发送0x02开始演示,串口配置为115200/N/8/1。"\
|
使用串口发送0x04开始演示,串口配置为115200/N/8/1。"\
|
||||||
)
|
)
|
||||||
|
|
||||||
/* Screen 2: List*/
|
/* Screen 2: List*/
|
||||||
|
99
DemoProject/STM32F1/Demo/src/DemoActions.c
Normal file
99
DemoProject/STM32F1/Demo/src/DemoActions.c
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
#include "stm32f10x_usart.h"
|
||||||
|
#include "stm32f10x_rcc.h"
|
||||||
|
#include "DemoActions.h"
|
||||||
|
#include "DemoProc.h"
|
||||||
|
#include "HMI_Engine.h"
|
||||||
|
#include "SGUI_Basic.h"
|
||||||
|
#include "GPIO.h"
|
||||||
|
#include "Usart.h"
|
||||||
|
|
||||||
|
SGUI_INT s_GraphDemoData[72] = {
|
||||||
|
// 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90,
|
||||||
|
4, 9, 13, 17, 21, 25, 29, 32, 35, 38, 41, 43, 45, 47, 48, 49, 50, 50,
|
||||||
|
|
||||||
|
// 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150, 155, 160, 165, 170, 175, 180,
|
||||||
|
50, 49, 48, 47, 45, 43, 41, 38, 35, 32, 29, 25, 21, 17, 13, 9, 4, 0,
|
||||||
|
|
||||||
|
// 185, 190, 195, 200, 205, 210, 215, 220, 225, 230, 235, 240, 245, 250, 255, 260, 265, 270,
|
||||||
|
-4, -9, -13, -17, -21, -25, -29, -32, -35, -38, -41, -43, -45, -47, -48, -49, -50, -50,
|
||||||
|
|
||||||
|
// 275, 280, 285, 290, 295, 300, 305, 310, 315, 320, 325, 330, 335, 340, 345, 350, 355, 360,
|
||||||
|
-50, -49, -48, -47, -45, -43, -41, -38, -35, -32, -29, -25, -21, -17, -13, -9, -4, 0
|
||||||
|
};
|
||||||
|
|
||||||
|
GPIO_OBJECT_STRUCT astUSART1GPIO[] =
|
||||||
|
{
|
||||||
|
{RCC_APB2Periph_GPIOA, GPIOA, GPIO_Pin_9, GPIO_Mode_AF_PP, GPIO_Speed_2MHz, GPIO_STATE_HIGH},
|
||||||
|
{RCC_APB2Periph_GPIOA, GPIOA, GPIO_Pin_10, GPIO_Mode_IN_FLOATING, GPIO_Speed_2MHz, GPIO_STATE_HIGH},
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
void DemoAction_InitializeUsart1(void)
|
||||||
|
{
|
||||||
|
NVIC_InitTypeDef NVIC_InitStructure;
|
||||||
|
|
||||||
|
/* Configure USART1 GPIO */
|
||||||
|
GPIO_Initialize(astUSART1GPIO, 2);
|
||||||
|
|
||||||
|
/* Configure Usart1 interrupt. */
|
||||||
|
NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn;
|
||||||
|
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=2 ;//抢占优先级3
|
||||||
|
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2; //子优先级3
|
||||||
|
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //IRQ通道使能
|
||||||
|
NVIC_Init(&NVIC_InitStructure);
|
||||||
|
|
||||||
|
/* Configure USART1 controller */
|
||||||
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE); //Enable USART device clock.
|
||||||
|
USART_Config(USART1, 115200, true); //Initialize USART and enable USART interrupt.
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DemoAction_TimerEvent(void)
|
||||||
|
{
|
||||||
|
/*----------------------------------*/
|
||||||
|
/* Variable Declaration */
|
||||||
|
/*----------------------------------*/
|
||||||
|
HMI_EVENT stEvent;
|
||||||
|
static SGUI_INT iDemoGraphDataIndex = 0;
|
||||||
|
|
||||||
|
/*----------------------------------*/
|
||||||
|
/* Initialize */
|
||||||
|
/*----------------------------------*/
|
||||||
|
stEvent.Action = HMI_ENGINE_ACTION_ON_TIMER;
|
||||||
|
stEvent.Data = NULL;
|
||||||
|
|
||||||
|
/*----------------------------------*/
|
||||||
|
/* Process */
|
||||||
|
/*----------------------------------*/
|
||||||
|
stEvent.Data = (SGUI_BYTE*)(&s_GraphDemoData[iDemoGraphDataIndex]);
|
||||||
|
iDemoGraphDataIndex++;
|
||||||
|
iDemoGraphDataIndex = iDemoGraphDataIndex % 72;
|
||||||
|
// Post timer event.
|
||||||
|
EventProcess(HMI_ENGINE_EVENT_ACTION, &stEvent);
|
||||||
|
SGUI_Basic_RefreshDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DemoAction_UsartReceiveEvent(uint8_t cbReceiveByte)
|
||||||
|
{
|
||||||
|
/*----------------------------------*/
|
||||||
|
/* Variable Declaration */
|
||||||
|
/*----------------------------------*/
|
||||||
|
SGUI_UINT16 arruiPressedKey[HMI_EVENT_KEY_VALUE_LENGTH_MAX];
|
||||||
|
HMI_EVENT stEvent;
|
||||||
|
|
||||||
|
/*----------------------------------*/
|
||||||
|
/* Initialize */
|
||||||
|
/*----------------------------------*/
|
||||||
|
arruiPressedKey[0] = KEY_NONE;
|
||||||
|
stEvent.Action = HMI_ENGINE_ACTION_KEY_PRESS;
|
||||||
|
arruiPressedKey[0] = cbReceiveByte & 0xF0;
|
||||||
|
arruiPressedKey[1] = cbReceiveByte & 0x0F;
|
||||||
|
stEvent.Data = (SGUI_BYTE*)arruiPressedKey;
|
||||||
|
/*----------------------------------*/
|
||||||
|
/* Process */
|
||||||
|
/*----------------------------------*/
|
||||||
|
// Call demo process.
|
||||||
|
EventProcess(HMI_ENGINE_EVENT_ACTION, &stEvent);
|
||||||
|
SGUI_Basic_RefreshDisplay();
|
||||||
|
}
|
||||||
|
|
@ -117,7 +117,11 @@
|
|||||||
<Unit filename="..\..\Core\inc\core_cm3.h" />
|
<Unit filename="..\..\Core\inc\core_cm3.h" />
|
||||||
<Unit filename="..\..\Core\inc\core_cmFunc.h" />
|
<Unit filename="..\..\Core\inc\core_cmFunc.h" />
|
||||||
<Unit filename="..\..\Core\inc\core_cmInstr.h" />
|
<Unit filename="..\..\Core\inc\core_cmInstr.h" />
|
||||||
|
<Unit filename="..\..\Demo\inc\DemoActions.h" />
|
||||||
<Unit filename="..\..\Demo\inc\DemoResource_GB2312.h" />
|
<Unit filename="..\..\Demo\inc\DemoResource_GB2312.h" />
|
||||||
|
<Unit filename="..\..\Demo\src\DemoActions.c">
|
||||||
|
<Option compilerVar="CC" />
|
||||||
|
</Unit>
|
||||||
<Unit filename="..\..\Device\inc\ASCII_Font8Pix.h" />
|
<Unit filename="..\..\Device\inc\ASCII_Font8Pix.h" />
|
||||||
<Unit filename="..\..\Device\inc\OLED.h" />
|
<Unit filename="..\..\Device\inc\OLED.h" />
|
||||||
<Unit filename="..\..\Device\inc\SSD1306_SPI.h" />
|
<Unit filename="..\..\Device\inc\SSD1306_SPI.h" />
|
||||||
@ -238,7 +242,6 @@
|
|||||||
<Unit filename="..\..\System\inc\Systick.h" />
|
<Unit filename="..\..\System\inc\Systick.h" />
|
||||||
<Unit filename="..\..\System\inc\Timer.h" />
|
<Unit filename="..\..\System\inc\Timer.h" />
|
||||||
<Unit filename="..\..\System\inc\Usart.h" />
|
<Unit filename="..\..\System\inc\Usart.h" />
|
||||||
<Unit filename="..\..\System\inc\UsartKey.h" />
|
|
||||||
<Unit filename="..\..\System\src\Delay.c">
|
<Unit filename="..\..\System\src\Delay.c">
|
||||||
<Option compilerVar="CC" />
|
<Option compilerVar="CC" />
|
||||||
</Unit>
|
</Unit>
|
||||||
@ -272,7 +275,6 @@
|
|||||||
<Unit filename="..\..\User\inc\stm32f10x.h" />
|
<Unit filename="..\..\User\inc\stm32f10x.h" />
|
||||||
<Unit filename="..\..\User\inc\stm32f10x_conf.h" />
|
<Unit filename="..\..\User\inc\stm32f10x_conf.h" />
|
||||||
<Unit filename="..\..\User\inc\system_stm32f10x.h" />
|
<Unit filename="..\..\User\inc\system_stm32f10x.h" />
|
||||||
<Unit filename="..\..\User\inc\Typedefine.h" />
|
|
||||||
<Unit filename="..\..\User\inc\usart_io.h" />
|
<Unit filename="..\..\User\inc\usart_io.h" />
|
||||||
<Unit filename="..\..\User\src\main.c">
|
<Unit filename="..\..\User\src\main.c">
|
||||||
<Option compilerVar="CC" />
|
<Option compilerVar="CC" />
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
#ifndef _INCLUDE_SYSTEM_SYSTICK_H_
|
#ifndef __INCLUDE_SYSTEM_SYSTICK_H__
|
||||||
#define _INCLUDE_SYSTEM_SYSTICK_H_
|
#define __INCLUDE_SYSTEM_SYSTICK_H__
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
#include "stm32f10x.h"
|
#include "stm32f10x.h"
|
||||||
#include "core_cm3.h"
|
#include "core_cm3.h"
|
||||||
|
|
||||||
#include "Typedefine.h"
|
|
||||||
|
|
||||||
#ifndef SYSTICK_MAXCOUNT
|
#ifndef SYSTICK_MAXCOUNT
|
||||||
#define SYSTICK_MAXCOUNT 16777216
|
#define SYSTICK_MAXCOUNT 16777216
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
#ifndef __INCLUDE_TIMER_H__
|
#ifndef __INCLUDE_TIMER_H__
|
||||||
#define __INCLUDE_TIMER_H__
|
#define __INCLUDE_TIMER_H__
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include "stm32f10x_tim.h"
|
#include "stm32f10x_tim.h"
|
||||||
|
|
||||||
void TIM3_Int_Init(TIM_TypeDef* pstTimerBase, uint16_t uiReloadValue, uint16_t uiPrescaler);
|
void TIMBase_Int_Init(TIM_TypeDef* pstTimerBase, uint16_t uiReloadValue, uint16_t uiPrescaler);
|
||||||
|
bool GetTimerTriggered(void);
|
||||||
|
void ResetTimerTriggered(void);
|
||||||
|
|
||||||
#endif /* __INCLUDE_TIMER_H__ */
|
#endif /* __INCLUDE_TIMER_H__ */
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
#ifndef _INCLUDE_SYSTEM_USART_H_
|
#ifndef __INCLUDE_SYSTEM_USART_H__
|
||||||
#define _INCLUDE_SYSTEM_USART_H_
|
#define __INCLUDE_SYSTEM_USART_H__
|
||||||
|
#include <stdbool.h>
|
||||||
#include "stm32f10x_usart.h"
|
#include "stm32f10x_usart.h"
|
||||||
#include "Typedefine.h"
|
|
||||||
|
|
||||||
void USART_Config(USART_TypeDef* st_USARTx, uint32_t ui_Baudrate, bool b_Enable);
|
void USART_Config(USART_TypeDef* st_USARTx, uint32_t ui_Baudrate, bool b_Enable);
|
||||||
void USART_SendByte(USART_TypeDef* pstUSARTx, uint16_t uiByte);
|
void USART_SendByte(USART_TypeDef* pstUSARTx, uint16_t uiByte);
|
||||||
|
uint8_t GetReveivedByte(void);
|
||||||
|
void ResetReveivedByte(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -36,13 +36,10 @@ void GPIO_Initialize(const GPIO_OBJECT_STRUCT* pstGPIODataList, uint16_t uiArray
|
|||||||
{
|
{
|
||||||
GPIO_SetBits(pstGPIODataList[i].Port, pstGPIODataList[i].Pin);
|
GPIO_SetBits(pstGPIODataList[i].Port, pstGPIODataList[i].Pin);
|
||||||
}
|
}
|
||||||
// Default to LOW when initialized.
|
|
||||||
/**
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GPIO_ResetBits(pstGPIODataList[i].Port, pstGPIODataList[i].Pin);
|
GPIO_ResetBits(pstGPIODataList[i].Port, pstGPIODataList[i].Pin);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
#include "stm32f10x.h"
|
|
||||||
#include "core_cm3.h"
|
|
||||||
#include "Typedefine.h"
|
|
||||||
#include "Systick.h"
|
#include "Systick.h"
|
||||||
#include "Delay.h"
|
#include "Delay.h"
|
||||||
|
|
||||||
@ -24,7 +21,7 @@ ErrorStatus Systick_Initialize(uint32_t ui_Ticks, bool b_EnableInterrupt)
|
|||||||
SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK); //设置Systick时钟源为HCLK
|
SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK); //设置Systick时钟源为HCLK
|
||||||
Systick_SetReload(ui_Ticks); //设置Systick重装载值
|
Systick_SetReload(ui_Ticks); //设置Systick重装载值
|
||||||
Systick_SetValue(0x000000); //设置Systick初值
|
Systick_SetValue(0x000000); //设置Systick初值
|
||||||
if(b_EnableInterrupt == TRUE)
|
if(b_EnableInterrupt == true)
|
||||||
{
|
{
|
||||||
NVIC_SetPriority(SysTick_IRQn, 0); //配置Systick中断优先级
|
NVIC_SetPriority(SysTick_IRQn, 0); //配置Systick中断优先级
|
||||||
SystickInt_Enable(); //使能Systick中断
|
SystickInt_Enable(); //使能Systick中断
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
#include "Timer.h"
|
#include "Timer.h"
|
||||||
#include "DemoProc.h"
|
#include "DemoActions.h"
|
||||||
#include "SGUI_Basic.h"
|
|
||||||
|
|
||||||
void PostTimerEvent(void);
|
static bool s_bTimerTriggered = false;
|
||||||
|
|
||||||
void TIM3_Int_Init(TIM_TypeDef* pstTimerBase, uint16_t uiReloadValue, uint16_t uiPrescaler)
|
void TIMBase_Int_Init(TIM_TypeDef* pstTimerBase, uint16_t uiReloadValue, uint16_t uiPrescaler)
|
||||||
{
|
{
|
||||||
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
|
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
|
||||||
NVIC_InitTypeDef NVIC_InitStructure;
|
NVIC_InitTypeDef NVIC_InitStructure;
|
||||||
@ -28,40 +27,24 @@ void TIM3_Int_Init(TIM_TypeDef* pstTimerBase, uint16_t uiReloadValue, uint16_t u
|
|||||||
NVIC_Init(&NVIC_InitStructure); //初始化NVIC寄存器
|
NVIC_Init(&NVIC_InitStructure); //初始化NVIC寄存器
|
||||||
|
|
||||||
|
|
||||||
TIM_Cmd(pstTimerBase, ENABLE); //使能TIMx
|
TIM_Cmd(pstTimerBase, ENABLE);
|
||||||
}
|
}
|
||||||
//定时器3中断服务程序
|
|
||||||
void TIM3_IRQHandler(void) //TIM3中断
|
/* Timer-3 interrupt service interface. */
|
||||||
|
void TIM3_IRQHandler(void)
|
||||||
{
|
{
|
||||||
if (TIM_GetITStatus(TIM3, TIM_IT_Update) != RESET) //检查TIM3更新中断发生与否
|
if (TIM_GetITStatus(TIM3, TIM_IT_Update) != RESET)
|
||||||
{
|
{
|
||||||
TIM_ClearITPendingBit(TIM3, TIM_IT_Update ); //清除TIMx更新中断标志
|
TIM_ClearITPendingBit(TIM3, TIM_IT_Update );
|
||||||
// Timer process.
|
s_bTimerTriggered = true;
|
||||||
PostTimerEvent();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GetTimerTriggered(void)
|
||||||
void PostTimerEvent(void)
|
|
||||||
{
|
{
|
||||||
/*----------------------------------*/
|
return s_bTimerTriggered;
|
||||||
/* Variable Declaration */
|
}
|
||||||
/*----------------------------------*/
|
void ResetTimerTriggered(void)
|
||||||
HMI_EVENT stEvent;
|
{
|
||||||
SGUI_INT iRandomNumber;
|
s_bTimerTriggered = false;
|
||||||
|
|
||||||
/*----------------------------------*/
|
|
||||||
/* Initialize */
|
|
||||||
/*----------------------------------*/
|
|
||||||
stEvent.Action = HMI_ENGINE_ACTION_ON_TIMER;
|
|
||||||
stEvent.Data = NULL;
|
|
||||||
|
|
||||||
/*----------------------------------*/
|
|
||||||
/* Process */
|
|
||||||
/*----------------------------------*/
|
|
||||||
iRandomNumber = 10;
|
|
||||||
stEvent.Data = (SGUI_BYTE*)(&iRandomNumber);
|
|
||||||
// Post timer event.
|
|
||||||
EventProcess(HMI_ENGINE_EVENT_ACTION, &stEvent);
|
|
||||||
SGUI_Basic_RefreshDisplay();
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
#include "stm32f10x_usart.h"
|
#include "stm32f10x_usart.h"
|
||||||
#include "Typedefine.h"
|
|
||||||
#include "Usart.h"
|
#include "Usart.h"
|
||||||
#include "usart_io.h"
|
#include "DemoActions.h"
|
||||||
|
|
||||||
|
static uint8_t s_cbReceivedByte = KEY_NONE;
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
/** Function Name: USART_Config. **/
|
/** Function Name: USART_Config. **/
|
||||||
@ -24,7 +25,7 @@ void USART_Config(USART_TypeDef* pstUSARTx, uint32_t ui_Baudrate, bool b_Enable)
|
|||||||
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; // RX/TX mode.
|
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; // RX/TX mode.
|
||||||
USART_Init(pstUSARTx, &USART_InitStructure); // Configuration USART controler.
|
USART_Init(pstUSARTx, &USART_InitStructure); // Configuration USART controler.
|
||||||
|
|
||||||
if(b_Enable == TRUE)
|
if(b_Enable == true)
|
||||||
{
|
{
|
||||||
USART_ITConfig(pstUSARTx, USART_IT_RXNE, ENABLE); // Enable USART interrupt.
|
USART_ITConfig(pstUSARTx, USART_IT_RXNE, ENABLE); // Enable USART interrupt.
|
||||||
}
|
}
|
||||||
@ -35,8 +36,32 @@ void USART_Config(USART_TypeDef* pstUSARTx, uint32_t ui_Baudrate, bool b_Enable)
|
|||||||
|
|
||||||
void USART_SendByte(USART_TypeDef* pstUSARTx, uint16_t uiByte)
|
void USART_SendByte(USART_TypeDef* pstUSARTx, uint16_t uiByte)
|
||||||
{
|
{
|
||||||
|
USART_ClearFlag(pstUSARTx,USART_FLAG_TC);
|
||||||
// Send data.
|
// Send data.
|
||||||
USART_SendData(pstUSARTx, uiByte);
|
USART_SendData(pstUSARTx, uiByte);
|
||||||
// Wait for send complete.
|
// Wait for send complete.
|
||||||
while(USART_GetFlagStatus(pstUSARTx, USART_FLAG_TXE) == RESET);
|
//while(USART_GetFlagStatus(pstUSARTx, USART_FLAG_TXE) == RESET);
|
||||||
|
while(USART_GetFlagStatus(pstUSARTx, USART_FLAG_TC) != SET);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* USART-1 receive interrupt function. */
|
||||||
|
void USART1_IRQHandler(void)
|
||||||
|
{
|
||||||
|
uint8_t cbReceiveByte;
|
||||||
|
|
||||||
|
if(USART_GetITStatus(USART1, USART_IT_RXNE) != RESET)
|
||||||
|
{
|
||||||
|
cbReceiveByte = USART_ReceiveData(USART1);
|
||||||
|
s_cbReceivedByte = cbReceiveByte;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t GetReveivedByte(void)
|
||||||
|
{
|
||||||
|
return s_cbReceivedByte;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ResetReveivedByte(void)
|
||||||
|
{
|
||||||
|
s_cbReceivedByte = KEY_NONE;
|
||||||
}
|
}
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
#ifndef _TYPEDEFINE_H_
|
|
||||||
#define _TYPEDEFINE_H_
|
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
FALSE = 0,
|
|
||||||
TRUE =!FALSE
|
|
||||||
}bool;
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef _INCLUDE_USART_IO_H_
|
#ifndef _INCLUDE_USART_IO_H_
|
||||||
#define _INCLUDE_USART_IO_H_
|
#define _INCLUDE_USART_IO_H_
|
||||||
|
#include <stdbool.h>
|
||||||
#include "stm32f10x_usart.h"
|
#include "stm32f10x_usart.h"
|
||||||
#include "Typedefine.h"
|
|
||||||
#include "GPIO.h"
|
#include "GPIO.h"
|
||||||
|
|
||||||
void USART_Config(USART_TypeDef* st_USARTx, uint32_t ui_Baudrate, bool b_Enable);
|
void USART_Config(USART_TypeDef* st_USARTx, uint32_t ui_Baudrate, bool b_Enable);
|
||||||
|
@ -21,8 +21,8 @@
|
|||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
/* Includes ------------------------------------------------------------------*/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdbool.h>
|
||||||
#include "stm32f10x.h"
|
#include "stm32f10x.h"
|
||||||
#include "Typedefine.h"
|
|
||||||
#include "usart_io.h"
|
#include "usart_io.h"
|
||||||
#include "Initialize.h"
|
#include "Initialize.h"
|
||||||
#include "stm32f10x_gpio.h"
|
#include "stm32f10x_gpio.h"
|
||||||
@ -32,12 +32,11 @@
|
|||||||
|
|
||||||
#include "GPIO.h"
|
#include "GPIO.h"
|
||||||
#include "RTC.h"
|
#include "RTC.h"
|
||||||
|
#include "Usart.h"
|
||||||
#include "ExternalInterrupt.h"
|
#include "ExternalInterrupt.h"
|
||||||
#include "SSD1306_SPI.h"
|
#include "SSD1306_SPI.h"
|
||||||
|
|
||||||
#include "SGUI_Basic.h"
|
#include "DemoActions.h"
|
||||||
#include "SGUI_Text.h"
|
|
||||||
|
|
||||||
#include "DemoProc.h"
|
#include "DemoProc.h"
|
||||||
|
|
||||||
char szOutputBuffer[64] = {0x00};
|
char szOutputBuffer[64] = {0x00};
|
||||||
@ -46,16 +45,18 @@ void UpdateRTC(void);
|
|||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
|
uint8_t cbReceivedByte;
|
||||||
HSEClocks_Initialize(RCC_PLLMul_9);
|
HSEClocks_Initialize(RCC_PLLMul_9);
|
||||||
NVIC_Initialize(NVIC_PriorityGroup_2);
|
NVIC_Initialize(NVIC_PriorityGroup_2);
|
||||||
DebugPort_Initialize(DEBUG_SWD);
|
DebugPort_Initialize(DEBUG_SWD);
|
||||||
DebugSerialPort_Initialize(115200);
|
|
||||||
printf("Debug output Initialized.\r\n");
|
//DebugSerialPort_Initialize(115200);
|
||||||
|
DemoAction_InitializeUsart1();
|
||||||
|
|
||||||
RTC_Initialize();
|
RTC_Initialize();
|
||||||
printf("RTC Initialized.\r\n");
|
printf("RTC Initialized.\r\n");
|
||||||
|
|
||||||
Systick_Initialize(72, TRUE);
|
Systick_Initialize(72, true);
|
||||||
printf("Systick timer Initialized.\r\n");
|
printf("Systick timer Initialized.\r\n");
|
||||||
|
|
||||||
GPIO_Initialize(astGPIOInitData, 2);
|
GPIO_Initialize(astGPIOInitData, 2);
|
||||||
@ -69,14 +70,27 @@ int main(void)
|
|||||||
InitializeEngine();
|
InitializeEngine();
|
||||||
printf("HMI engine Initialized.\r\n");
|
printf("HMI engine Initialized.\r\n");
|
||||||
|
|
||||||
TIM3_Int_Init(TIM3, 9, 7199);
|
TIMBase_Int_Init(TIM3, 9, 719);
|
||||||
printf("General Timer-3 Initialized.\r\n");
|
printf("General Timer3 Initialized.\r\n");
|
||||||
|
|
||||||
|
|
||||||
printf("System Initialize finished.\r\n");
|
printf("System Initialize finished.\r\n");
|
||||||
|
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
|
if(true == GetTimerTriggered())
|
||||||
|
{
|
||||||
|
DemoAction_TimerEvent();
|
||||||
|
ResetTimerTriggered();
|
||||||
|
}
|
||||||
|
|
||||||
|
cbReceivedByte = GetReveivedByte();
|
||||||
|
if(KEY_NONE != cbReceivedByte)
|
||||||
|
{
|
||||||
|
printf("Received virtual key value 0x%02X.\r\n", cbReceivedByte);
|
||||||
|
DemoAction_UsartReceiveEvent(cbReceivedByte);
|
||||||
|
ResetReveivedByte();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "stm32f10x.h"
|
#include "stm32f10x.h"
|
||||||
#include "stm32f10x_usart.h"
|
|
||||||
#include "Typedefine.h"
|
|
||||||
#include "Usart.h"
|
#include "Usart.h"
|
||||||
#include "usart_io.h"
|
#include "usart_io.h"
|
||||||
|
|
||||||
@ -32,7 +30,7 @@ void DebugSerialPort_Initialize(uint32_t Baudrate)
|
|||||||
|
|
||||||
/* Configure USART1 controller */
|
/* Configure USART1 controller */
|
||||||
RCC_APB2PeriphClockCmd(DEBUG_IO_DEVICE_CLOCK, ENABLE); //Enable USART device clock.
|
RCC_APB2PeriphClockCmd(DEBUG_IO_DEVICE_CLOCK, ENABLE); //Enable USART device clock.
|
||||||
USART_Config(DEBUG_IO_DEVICE, Baudrate, FALSE); //Initialize USART and disable USART interrupt.
|
USART_Config(DEBUG_IO_DEVICE, Baudrate, false); //Initialize USART and disable USART interrupt.
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#else
|
#else
|
||||||
// Include your device driver interface here.
|
// Include your device driver interface here.
|
||||||
#include "OLED.h"
|
#include "OLED.h"
|
||||||
#include "UsartKey.h"
|
#include "DemoActions.h"
|
||||||
#endif //_SIMPLE_GUI_ENABLE_SIMULATOR_
|
#endif //_SIMPLE_GUI_ENABLE_SIMULATOR_
|
||||||
|
|
||||||
//=======================================================================//
|
//=======================================================================//
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#else
|
#else
|
||||||
// Include MMU interface header file here.
|
// Include MMU interface header file here.
|
||||||
|
#include <string.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//=======================================================================//
|
//=======================================================================//
|
||||||
@ -629,7 +630,8 @@ void* SGUI_Common_MemoryCopy(void* pDest, const void* pSrc, SGUI_UINT uiSize)
|
|||||||
#if (_SIMPLE_GUI_VIRTUAL_ENVIRONMENT_SIMULATOR_ > 0)
|
#if (_SIMPLE_GUI_VIRTUAL_ENVIRONMENT_SIMULATOR_ > 0)
|
||||||
pCopiedMemory = memcpy(pDest, pSrc, uiSize);
|
pCopiedMemory = memcpy(pDest, pSrc, uiSize);
|
||||||
#else
|
#else
|
||||||
// Add RTC time process here;
|
// Add memory block copy process here;
|
||||||
|
pCopiedMemory = memcpy(pDest, pSrc, uiSize);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -698,6 +700,7 @@ SGUI_SIZE SGUI_Common_StringLength(SGUI_PCSZSTR szString)
|
|||||||
uiStringLength = strlen(szString);
|
uiStringLength = strlen(szString);
|
||||||
#else
|
#else
|
||||||
// Add RTC time process here;
|
// Add RTC time process here;
|
||||||
|
uiStringLength = strlen(szString);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -734,6 +737,7 @@ SGUI_PSZSTR SGUI_Common_StringCopy(SGUI_PSZSTR szDest, SGUI_PCSZSTR szSrc)
|
|||||||
szDestPtr = strcpy(szDest, szSrc);
|
szDestPtr = strcpy(szDest, szSrc);
|
||||||
#else
|
#else
|
||||||
// Add RTC time process here;
|
// Add RTC time process here;
|
||||||
|
szDestPtr = strcpy(szDest, szSrc);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -771,6 +775,7 @@ SGUI_PSZSTR SGUI_Common_StringLengthCopy(SGUI_PSZSTR szDest, SGUI_PCSZSTR szSrc,
|
|||||||
szDestPtr = strncpy(szDest, szSrc, uiSize);
|
szDestPtr = strncpy(szDest, szSrc, uiSize);
|
||||||
#else
|
#else
|
||||||
// Add RTC time process here;
|
// Add RTC time process here;
|
||||||
|
szDestPtr = strncpy(szDest, szSrc, uiSize);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,7 +327,7 @@ void LCDFrame::OnUpdateUI(wxUpdateUIEvent& clsEventObject)
|
|||||||
_setStatusText(_T("Initialzied."));
|
_setStatusText(_T("Initialzied."));
|
||||||
bInitialized = true;
|
bInitialized = true;
|
||||||
_initializeTimer();
|
_initializeTimer();
|
||||||
_startTimer(1);
|
_startTimer(50);
|
||||||
|
|
||||||
UAIF_OnInitialize();
|
UAIF_OnInitialize();
|
||||||
m_pclsCtrlPaintPanel->RefreshDisplay();
|
m_pclsCtrlPaintPanel->RefreshDisplay();
|
||||||
@ -481,9 +481,27 @@ uint32_t LCDFrame::GetLCDPixel(uint32_t uiPosX, uint32_t uiPosY)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LCDFrame::OnTimerEvent(wxTimerEvent& event)
|
void LCDFrame::OnTimerEvent(wxTimerEvent& event)
|
||||||
|
{
|
||||||
|
/*----------------------------------*/
|
||||||
|
/* Variable Declaration */
|
||||||
|
/*----------------------------------*/
|
||||||
|
static bool bInitialized = false;
|
||||||
|
|
||||||
|
/*----------------------------------*/
|
||||||
|
/* Process */
|
||||||
|
/*----------------------------------*/
|
||||||
|
if(false == bInitialized)
|
||||||
|
{
|
||||||
|
// Initialize HMI engine.
|
||||||
|
bInitialized = true;
|
||||||
|
UAIF_OnInitialize();
|
||||||
|
m_pclsCtrlPaintPanel->RefreshDisplay();
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
UAIF_OnTimerEventProcess();
|
UAIF_OnTimerEventProcess();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void LCDFrame::OnRTCUpdate(wxTimerEvent& event)
|
void LCDFrame::OnRTCUpdate(wxTimerEvent& event)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user