废话不多说,先上图诱惑下大家下
然后自拍了个视频,效果可能不是很好,不要介意哈~
哈~看起来不错吧,下面上程序。
首先说明下我在structure.c做了点接口BIT位的小改动。为的是适应板子。好了,上程序。下面是主函数
- /*
- * main.c
- *
- * Created on: 2012-8-12
- * Author: maswell_xiao
- */
- #include "CTS_Layer.h"
- #include
- #define CS BIT0
- #define SID BIT7
- #define SCLK BIT6
- extern void LCDInit(void);
- extern void LCDShow(unsigned char Addr,char *s);
- struct CAPMSG
- {
- unsigned int Up;
- unsigned int Right;
- unsigned int Down;
- unsigned int Left;
- unsigned int Middle;
- unsigned int proximity;
- };
- void main(void)
- {
- struct CAPMSG MSG;
- WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
- BCSCTL1 = CALBC1_1MHZ; // Set DCO to 1, 8, 12 or 16MHz
- DCOCTL = CALDCO_1MHZ;
- BCSCTL2 |= DIVS_2; // divide SMCLK by 4 for 2Mhz
- BCSCTL3 |= LFXT1S_2; // LFXT1 = VLO
- P2DIR = 0xFF;
- P2SEL = 0;
- P2SEL2 = 0;
- P2OUT = 0;
- LCDInit();
- LCDShow(0x80,"欢迎使用电容式触");
- LCDShow(0x90,"摸摁键。");
- LCDShow(0x88," ");
- LCDShow(0x98,"maxwell xiao");
- _delay_cycles(500000);
- TI_CAPT_Init_Baseline(&middle_button);
- TI_CAPT_Init_Baseline(&wheel);
- TI_CAPT_Init_Baseline(&proximity_sensor);
- while (1)
- {
- do
- {
- TACCR0 = 100;
- TACTL = TASSEL_1 + MC_1;
- TACCTL0 |= CCIE;
- __bis_SR_register(LPM3_bits+GIE);
- TACCTL0 &= ~CCIE;
- TI_CAPT_Custom(&proximity_sensor,&MSG.proximity);
- }
- while (MSG.proximity <= 100);
- TI_CAPT_Custom(&middle_button,&MSG.Middle);
- TI_CAPT_Custom(&wheel,&MSG.Up);//传个地址就行,首地址。
- if(MSG.Middle > 1000)
- {
- LCDShow(0x88,"摁下了中键");
- }
- if(MSG.Down > 1000)
- {
- LCDShow(0x88,"摁下了下键");
- }
- if(MSG.Left > 1000)
- {
- LCDShow(0x88,"摁下了左键");
- }
- if(MSG.Right > 1000)
- {
- LCDShow(0x88,"摁下了右键");
- }
- if(MSG.Up > 1000)
- {
- LCDShow(0x88,"摁下了上键");
- }
- __no_operation();
- }
- }
- #pragma vector = TIMER0_A0_VECTOR
- __interrupt void Timer_A0_ISR(void)
- {
- __bic_SR_register_on_exit(LPM3_bits+GIE);
- }
复制代码还有个12864的驱动。
顺便贴上吧 。休眠模式没调出来,害羞啊,脸红啊。。。
。
OK,就这样了。