EDF - OnePIC MCU  v1.1.0
source/base/OnePIC_mtouch.c
Go to the documentation of this file.
00001 
00011 #include "OnePIC_mtouch.h"
00012 #ifdef __PIC24FJ256GA106__
00013 #include "mTouch.h"
00014 #elif defined (__PICC__)
00015 #include "mTouchCVD.h"
00016 #elif defined (__PIC32MX__)
00017 #include "mTouchCapAPI.h"
00018 #include "mTouchConfig.h"
00019 #include "mTouchCapLED.h"
00020 #include "mTouchCapApp_DirectKeys.h"
00021 typedef unsigned char uint8_t; 
00022 #endif
00023 #include <stdint.h>
00024 #include "bsp.h"
00025 #include "OnePIC_led.h"
00026 //#include "OnePIC_lcd.h" //requried for LCDUpdate
00027 //#include "OnePIC_rtcc.h" //requried for _time_str
00028 
00029 
00038 BANNER_STATE _bannerState;
00039 uint8_t *p_capString; 
00040 uint8_t p_capStringUp[] = "Up"; 
00041 uint8_t p_capStringDown[] = "Down"; 
00042 uint8_t p_capStringLeft[] = "Left"; 
00043 uint8_t p_capStringRight[] = "Right"; 
00044 uint8_t p_capStringEnter[] = "Enter"; 
00045 uint8_t p_capStringBlank[] = " "; 
00047 uint8_t printed = 0; //this is so the LCD will print even the SLIGHTEST touch press
00053 void EDF_mTouchPoll(void) {
00054 #ifdef __PICC__
00055     if (mTouch_isDataReady()) { // Is new information ready?
00056         mTouch_Service();
00057 #elif defined __PIC24FJ256GA106__
00058     if (MTouchIsDataReady()) {
00059         //MTouchDecode();
00060 #else
00061         {
00062 #endif
00063         if (EDF_CapTouchGetButtonState(CAP_UP) == EDF_MTOUCH_PRESSED) {
00064             p_capString = p_capStringUp;
00065             _bannerState = BANNER_CAP;
00066             EDF_LEDSet(LED_UP);
00067             EDF_LEDClr(LED_RIGHT);
00068             EDF_LEDClr(LED_DOWN);
00069             EDF_LEDClr(LED_LEFT);
00070             printed = 2;
00071 
00072         } else if (EDF_CapTouchGetButtonState(CAP_DOWN) == EDF_MTOUCH_PRESSED) {
00073             p_capString = p_capStringDown;
00074             _bannerState = BANNER_CAP;
00075             EDF_LEDSet(LED_DOWN);
00076             EDF_LEDClr(LED_UP);
00077             EDF_LEDClr(LED_RIGHT);
00078             EDF_LEDClr(LED_LEFT);
00079             printed = 2;
00080 
00081         } else if (EDF_CapTouchGetButtonState(CAP_LEFT) == EDF_MTOUCH_PRESSED) {
00082             p_capString = p_capStringLeft;
00083             _bannerState = BANNER_CAP;
00084             EDF_LEDSet(LED_LEFT);
00085             EDF_LEDClr(LED_UP);
00086             EDF_LEDClr(LED_RIGHT);
00087             EDF_LEDClr(LED_DOWN);
00088             printed = 2;
00089 
00090         } else if (EDF_CapTouchGetButtonState(CAP_RIGHT) == EDF_MTOUCH_PRESSED) {
00091             p_capString = p_capStringRight;
00092             _bannerState = BANNER_CAP;
00093             EDF_LEDSet(LED_RIGHT);
00094             EDF_LEDClr(LED_UP);
00095             EDF_LEDClr(LED_DOWN);
00096             EDF_LEDClr(LED_LEFT);
00097             printed = 2;
00098 
00099         } else if (EDF_CapTouchGetButtonState(CAP_ENTER) == EDF_MTOUCH_PRESSED) {
00100             p_capString = p_capStringEnter;
00101             _bannerState = BANNER_CAP;
00102             EDF_LEDSet(LED_UP);
00103             EDF_LEDSet(LED_RIGHT);
00104             EDF_LEDSet(LED_LEFT);
00105             EDF_LEDSet(LED_DOWN);
00106             printed = 2;
00107 
00108         } else {
00109             if (printed == 0) {
00110                 _bannerState = BANNER_POT;
00111                 p_capString = p_capStringBlank;
00112             }
00113             EDF_LEDClr(LED_UP);
00114             EDF_LEDClr(LED_RIGHT);
00115             EDF_LEDClr(LED_DOWN);
00116             EDF_LEDClr(LED_LEFT);
00117         }
00118 
00119 
00120     }
00121 }