我在EBS003 IOT扩展版例程TOUCHKEY_SLIDE_NBK_RD8x3x_EBS003做了修改。
原理图:
代码:#include "SC_Init.h" // MCU initialization header file, including all firmware library header files
#include "SC_it.h"
#include "..\Drivers\SCDriver_list.h"
#include "HeadFiles\SysFunVarDefine.h"
/**************************************Generated by EasyCodeCube*************************************/
/*************************************.Generated by EasyCodeCube.************************************/
/*****************************************************************************************************
* Function Name: main
* Description : This function implements main function.
* Arguments : None
* Return Value : None
******************************************************************************************************/
void main(void)
{
/*<Generated by EasyCodeCube begin>*/
/*<UserCodeStart>*//*<SinOne-Tag><36>*/
IcResourceInit();
/*<UserCodeEnd>*//*<SinOne-Tag><36>*/
/*<UserCodeStart>*//*<SinOne-Tag><101>*/
OLED_Init();
OLED_Clear();
OLED_ShowCHinese(0,0,0); //按
OLED_ShowCHinese(18,0,1); //键
OLED_ShowCHinese(36,0,2); //:
OLED_ShowCHinese(0,2,3); //挡
OLED_ShowCHinese(18,2,4); //位
OLED_ShowCHinese(36,2,5); //值
OLED_ShowCHinese(54,2,2); //:
OLED_ShowCHinese(0,6,13); //比
OLED_ShowCHinese(18,6,14); //神
OLED_ShowCHinese(36,6,15); //乐
P1CON |= 0X80;
P17 = 1;
/*<UserCodeEnd>*//*<SinOne-Tag><101>*/
/*<UserCodeStart>*//*<SinOne-Tag><121>*/
TouchKeyInit();
/*<UserCodeEnd>*//*<SinOne-Tag><121>*/
/*<UserCodeStart>*//*<SinOne-Tag><4>*/
/*****MainLoop*****/
while(1)
{
/*<UserCodeStart>*//*<SinOne-Tag><123>*/
if(SOCAPI_TouchKeyStatus & 0x80)
{
/*<UserCodeStart>*//*<SinOne-Tag><124>*/
SOCAPI_TouchKeyStatus &= 0x7f;
/*<UserCodeEnd>*//*<SinOne-Tag><124>*/
/*<UserCodeStart>*//*<SinOne-Tag><125>*/
exKeyValueFlag = TouchKeyScan();
/*<UserCodeEnd>*//*<SinOne-Tag><125>*/
/*<UserCodeStart>*//*<SinOne-Tag><126>*/
Slider_value = TKSlideModulePCBArray[0].OutValue;
/*<UserCodeEnd>*//*<SinOne-Tag><126>*/
/*<UserCodeStart>*//*<SinOne-Tag><127>*/
UserCodeDealKey();
/*<UserCodeEnd>*//*<SinOne-Tag><127>*/
/*<UserCodeStart>*//*<SinOne-Tag><128>*/
UserCodeDealSlider();
/*<UserCodeEnd>*//*<SinOne-Tag><128>*/
/*<UserCodeStart>*//*<SinOne-Tag><129>*/
TouchKeyRestart();
/*<UserCodeEnd>*//*<SinOne-Tag><129>*/
/*<Begin-Inserted by EasyCodeCube for Condition>*/
}
/*<UserCodeEnd>*//*<SinOne-Tag><123>*/
/*<Begin-Inserted by EasyCodeCube for Condition>*/
}
/*<UserCodeEnd>*//*<SinOne-Tag><4>*/
/*<Generated by EasyCodeCube end>*/
}
效果图:
|