Advertisement
larsima

Revised & working

Jan 12th, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 17.82 KB | None | 0 0
  1. #include <SPI.h>
  2. #include "Adafruit_GFX.h"
  3. #include "Adafruit_RA8875.h"
  4. #include <MemoryFree.h>
  5. #define RA8875_INT     3
  6. #define RA8875_CS      10
  7. #define RA8875_RESET   9
  8.  
  9. unsigned short boardType = 0; // 0 = keyboard, 1 = numpad
  10. const char alphaKeys[] = "QWERTYUIOPASDFGHJKLZXCVBNM";
  11.  
  12. Adafruit_RA8875 tft = Adafruit_RA8875(RA8875_CS, RA8875_RESET);
  13. tsPoint_t       _tsLCDPoints[3];
  14. tsPoint_t       _tsTSPoints[3];
  15. tsMatrix_t      _tsMatrix;
  16.  
  17. /**************************************************************************/
  18. /*!
  19.     @brief Calculates the difference between the touch screen and the
  20.            actual screen co-ordinates, taking into account misalignment
  21.            and any physical offset of the touch screen.
  22.     @note  This is based on the public domain touch screen calibration code
  23.            written by Carlos E. Vidales (copyright (c) 2001).
  24.            For more information, see the following app notes:
  25.            - AN2173 - Touch Screen Control and Calibration
  26.              Svyatoslav Paliy, Cypress Microsystems
  27.            - Calibration in touch-screen systems
  28.              Wendy Fang and Tony Chang,
  29.              Analog Applications Journal, 3Q 2007 (Texas Instruments)
  30. */
  31. /**************************************************************************/
  32. int setCalibrationMatrix( tsPoint_t * displayPtr, tsPoint_t * screenPtr, tsMatrix_t * matrixPtr)
  33. {
  34.   int  retValue = 0;
  35.  
  36.   matrixPtr->Divider = ((screenPtr[0].x - screenPtr[2].x) * (screenPtr[1].y - screenPtr[2].y)) -
  37.                        ((screenPtr[1].x - screenPtr[2].x) * (screenPtr[0].y - screenPtr[2].y)) ;
  38.  
  39.   if( matrixPtr->Divider == 0 )
  40.   {
  41.     retValue = -1 ;
  42.   }
  43.   else
  44.   {
  45.     matrixPtr->An = ((displayPtr[0].x - displayPtr[2].x) * (screenPtr[1].y - screenPtr[2].y)) -
  46.                     ((displayPtr[1].x - displayPtr[2].x) * (screenPtr[0].y - screenPtr[2].y)) ;
  47.  
  48.     matrixPtr->Bn = ((screenPtr[0].x - screenPtr[2].x) * (displayPtr[1].x - displayPtr[2].x)) -
  49.                     ((displayPtr[0].x - displayPtr[2].x) * (screenPtr[1].x - screenPtr[2].x)) ;
  50.  
  51.     matrixPtr->Cn = (screenPtr[2].x * displayPtr[1].x - screenPtr[1].x * displayPtr[2].x) * screenPtr[0].y +
  52.                     (screenPtr[0].x * displayPtr[2].x - screenPtr[2].x * displayPtr[0].x) * screenPtr[1].y +
  53.                     (screenPtr[1].x * displayPtr[0].x - screenPtr[0].x * displayPtr[1].x) * screenPtr[2].y ;
  54.  
  55.     matrixPtr->Dn = ((displayPtr[0].y - displayPtr[2].y) * (screenPtr[1].y - screenPtr[2].y)) -
  56.                     ((displayPtr[1].y - displayPtr[2].y) * (screenPtr[0].y - screenPtr[2].y)) ;
  57.  
  58.     matrixPtr->En = ((screenPtr[0].x - screenPtr[2].x) * (displayPtr[1].y - displayPtr[2].y)) -
  59.                     ((displayPtr[0].y - displayPtr[2].y) * (screenPtr[1].x - screenPtr[2].x)) ;
  60.  
  61.     matrixPtr->Fn = (screenPtr[2].x * displayPtr[1].y - screenPtr[1].x * displayPtr[2].y) * screenPtr[0].y +
  62.                     (screenPtr[0].x * displayPtr[2].y - screenPtr[2].x * displayPtr[0].y) * screenPtr[1].y +
  63.                     (screenPtr[1].x * displayPtr[0].y - screenPtr[0].x * displayPtr[1].y) * screenPtr[2].y ;
  64.  
  65.     // Persist data to EEPROM
  66.     /*eepromWriteS32(CFG_EEPROM_TOUCHSCREEN_CAL_AN, matrixPtr->An);
  67.     eepromWriteS32(CFG_EEPROM_TOUCHSCREEN_CAL_BN, matrixPtr->Bn);
  68.     eepromWriteS32(CFG_EEPROM_TOUCHSCREEN_CAL_CN, matrixPtr->Cn);
  69.     eepromWriteS32(CFG_EEPROM_TOUCHSCREEN_CAL_DN, matrixPtr->Dn);
  70.     eepromWriteS32(CFG_EEPROM_TOUCHSCREEN_CAL_EN, matrixPtr->En);
  71.     eepromWriteS32(CFG_EEPROM_TOUCHSCREEN_CAL_FN, matrixPtr->Fn);
  72.     eepromWriteS32(CFG_EEPROM_TOUCHSCREEN_CAL_DIVIDER, matrixPtr->Divider);
  73.     eepromWriteU8(CFG_EEPROM_TOUCHSCREEN_CALIBRATED, 1);*/
  74.   }
  75.  
  76.   return( retValue ) ;
  77. }
  78.  
  79. /**************************************************************************/
  80. /*!
  81.     @brief  Converts raw touch screen locations (screenPtr) into actual
  82.             pixel locations on the display (displayPtr) using the
  83.             supplied matrix.
  84.            
  85.     @param[out] displayPtr  Pointer to the tsPoint_t object that will hold
  86.                             the compensated pixel location on the display
  87.     @param[in]  screenPtr   Pointer to the tsPoint_t object that contains the
  88.                             raw touch screen co-ordinates (before the
  89.                             calibration calculations are made)
  90.     @param[in]  matrixPtr   Pointer to the calibration matrix coefficients
  91.                             used during the calibration process (calculated
  92.                             via the tsCalibrate() helper function)
  93.     @note  This is based on the public domain touch screen calibration code
  94.            written by Carlos E. Vidales (copyright (c) 2001).
  95. */
  96. /**************************************************************************/
  97. int calibrateTSPoint( tsPoint_t * displayPtr, tsPoint_t * screenPtr, tsMatrix_t * matrixPtr )
  98. {
  99.   int  retValue = 0 ;
  100.  
  101.   if( matrixPtr->Divider != 0 )
  102.   {
  103.     displayPtr->x = ( (matrixPtr->An * screenPtr->x) +
  104.                       (matrixPtr->Bn * screenPtr->y) +
  105.                        matrixPtr->Cn
  106.                     ) / matrixPtr->Divider ;
  107.  
  108.     displayPtr->y = ( (matrixPtr->Dn * screenPtr->x) +
  109.                       (matrixPtr->En * screenPtr->y) +
  110.                        matrixPtr->Fn
  111.                     ) / matrixPtr->Divider ;
  112.   }
  113.   else
  114.   {
  115.     return -1;
  116.   }
  117.  
  118.   return( retValue );
  119. }
  120.  
  121. /**************************************************************************/
  122. /*!
  123.     @brief  Waits for a touch event
  124. */
  125. /**************************************************************************/
  126. void waitForTouchEvent(tsPoint_t * point)
  127. {
  128.   /* Clear the touch data object and placeholder variables */
  129.   memset(point, 0, sizeof(tsPoint_t));
  130.  
  131.   /* Clear any previous interrupts to avoid false buffered reads */
  132.   uint16_t x, y;
  133.   tft.touchRead(&x, &y);
  134.   delay(1);
  135.   /* Wait around for a new touch event (INT pin goes low) */ // MODIFIED ARG: From arg "digitalRead(RA8875_INT)" to "!tft.touched()"
  136.   while (!tft.touched()){
  137.   }
  138.  
  139.   /* Make sure this is really a touch event */
  140.   if (tft.touched())
  141.   {
  142.     tft.touchRead(&x, &y);
  143.     point->x = x;
  144.     point->y = y;
  145.     //Serial.print("Touch: ");
  146.     //Serial.print(point->x); Serial.print(", "); Serial.println(point->y);
  147.   }
  148.   else
  149.   {
  150.     point->x = 0;
  151.     point->y = 0;
  152.   }
  153. }
  154.  
  155. /**************************************************************************/
  156. /*!
  157.     @brief  Renders the calibration screen with an appropriately
  158.             placed test point and waits for a touch event
  159. */
  160. /**************************************************************************/
  161. tsPoint_t renderCalibrationScreen(uint16_t x, uint16_t y, uint16_t radius)
  162. {
  163.   tft.fillScreen(RA8875_WHITE);
  164.   tft.drawCircle(x, y, radius, RA8875_RED);
  165.   tft.drawCircle(x, y, radius + 2, 0x8410);  /* 50% Gray */
  166.  
  167.   // Wait for a valid touch events
  168.   tsPoint_t point = { 0, 0 };
  169.  
  170.   /* Keep polling until the TS event flag is valid */
  171.   bool valid = false;
  172.   while (!valid)
  173.   {
  174.     waitForTouchEvent(&point);
  175.     if (point.x || point.y)
  176.     {
  177.       valid = true;
  178.     }
  179.   }
  180.  
  181.   return point;
  182. }
  183.  
  184. /**************************************************************************/
  185. /*!
  186.     @brief  Starts the screen calibration process.  Each corner will be
  187.             tested, meaning that each boundary (top, left, right and
  188.             bottom) will be tested twice and the readings averaged.
  189. */
  190. /**************************************************************************/
  191. void tsCalibrate(void)
  192. {
  193.   tsPoint_t data;
  194.  
  195.   /* --------------- Welcome Screen --------------- */
  196.   Serial.println("Starting the calibration process");
  197.   data = renderCalibrationScreen(tft.width() / 2, tft.height() / 2, 5);
  198.   delay(250);
  199.  
  200.   /* ----------------- First Dot ------------------ */
  201.   // 10% over and 10% down
  202.   data = renderCalibrationScreen(tft.width() / 10, tft.height() / 10, 5);
  203.   _tsLCDPoints[0].x = tft.width() / 10;
  204.   _tsLCDPoints[0].y = tft.height() / 10;
  205.   _tsTSPoints[0].x = data.x;
  206.   _tsTSPoints[0].y = data.y;
  207.   Serial.print("Point 1 - LCD");
  208.   Serial.print(" X: ");
  209.   Serial.print(_tsLCDPoints[0].x);
  210.   Serial.print(" Y: ");
  211.   Serial.print(_tsLCDPoints[0].y);
  212.   Serial.print(" TS X: ");
  213.   Serial.print(_tsTSPoints[0].x);
  214.   Serial.print(" Y: ");
  215.   Serial.println(_tsTSPoints[0].y);
  216.   delay(250);
  217.  
  218.   /* ---------------- Second Dot ------------------ */
  219.   // 50% over and 90% down
  220.   data = renderCalibrationScreen(tft.width() / 2, tft.height() - tft.height() / 10, 5);
  221.   _tsLCDPoints[1].x = tft.width() / 2;
  222.   _tsLCDPoints[1].y = tft.height() - tft.height() / 10;
  223.   _tsTSPoints[1].x = data.x;
  224.   _tsTSPoints[1].y = data.y;
  225.   Serial.print("Point 2 - LCD");
  226.   Serial.print(" X: ");
  227.   Serial.print(_tsLCDPoints[1].x);
  228.   Serial.print(" Y: ");
  229.   Serial.print(_tsLCDPoints[1].y);
  230.   Serial.print(" TS X: ");
  231.   Serial.print(_tsTSPoints[1].x);
  232.   Serial.print(" Y: ");
  233.   Serial.println(_tsTSPoints[1].y);
  234.   delay(250);
  235.  
  236.   /* ---------------- Third Dot ------------------- */
  237.   // 90% over and 50% down
  238.   data = renderCalibrationScreen(tft.width() - tft.width() / 10, tft.height() / 2, 5);
  239.   _tsLCDPoints[2].x = tft.width() - tft.width() / 10;
  240.   _tsLCDPoints[2].y = tft.height() / 2;
  241.   _tsTSPoints[2].x = data.x;
  242.   _tsTSPoints[2].y = data.y;
  243.   Serial.print("Point 3 - LCD");
  244.   Serial.print(" X: ");
  245.   Serial.print(_tsLCDPoints[2].x);
  246.   Serial.print(" Y: ");
  247.   Serial.print(_tsLCDPoints[2].y);
  248.   Serial.print(" TS X: ");
  249.   Serial.print(_tsTSPoints[2].x);
  250.   Serial.print(" Y: ");
  251.   Serial.println(_tsTSPoints[2].y);
  252.   delay(250);
  253.  
  254.   /* Clear the screen */
  255.   tft.fillScreen(RA8875_WHITE);
  256.  
  257.   // Do matrix calculations for calibration and store to EEPROM
  258.   setCalibrationMatrix(&_tsLCDPoints[0], &_tsTSPoints[0], &_tsMatrix);
  259. }
  260.  
  261. void setup(){
  262.   tft.begin(RA8875_800x480);
  263.   Serial.begin(9600);
  264.   delay(100);
  265.  
  266.   tft.displayOn(true);
  267.   tft.GPIOX(true);
  268.   tft.PWM1config(true, RA8875_PWM_CLK_DIV1024);
  269.   tft.PWM1out(255);
  270.  
  271.   pinMode(RA8875_INT, INPUT);
  272.   digitalWrite(RA8875_INT, HIGH);
  273.   tft.touchEnable(true);
  274.  
  275.   tsCalibrate();
  276.  
  277.   tft.fillScreen(RA8875_WHITE);
  278.   tft.fillRoundRect(10,200,780,80,15,0xAD35);
  279.   tft.textMode();
  280.   tft.textSetCursor(27,220);
  281.   tft.textTransparent(RA8875_BLACK);
  282.   tft.textEnlarge(1);
  283.   tft.textWrite(" Digital Air Brake Pressure Monitoring System");
  284.   tft.textSetCursor(70,290);
  285.   tft.textEnlarge(3);
  286.   tft.textWrite("(c) Chris Kuhn, 2018");
  287.  
  288.   delay(500);
  289.  
  290.   tft.graphicsMode();
  291.   tft.fillScreen(0xCE39); // HEX RGB565 Control Panel Gray
  292.   tft.drawFastHLine(0,80,800,RA8875_BLACK);
  293.   tft.fillRect(0,0,800,79,0xAD36);
  294.   tft.textMode();
  295.   tft.textSetCursor(10,10);
  296.   tft.textEnlarge(3);
  297.   tft.textTransparent(RA8875_BLACK);
  298.   tft.textWrite("Enter Channel ID below:");
  299.  
  300.   tft.textSetCursor(220,120);
  301.   tft.textEnlarge(3);
  302.   tft.textTransparent(0xAD35);
  303.   tft.textWrite("A B C D 1 2");
  304.   tft.textSetCursor(218,140);
  305.   tft.textTransparent(RA8875_BLACK);
  306.   tft.textWrite("_ _ _ _ _ _");
  307.   char targetChannel[12] = "           ";
  308.   channelEntryHandler(targetChannel);
  309.   Serial.print("CHANNEL ID: ");
  310.   Serial.println(targetChannel);
  311. }
  312.  
  313.  
  314. void loop() {
  315. }
  316.  
  317. void drawKeyboard(){
  318.   short xRow2[] = {31, 121, 211, 301, 389, 477, 566, 655, 744};
  319.   short xRow3[] = {46, 160, 274, 387, 504, 617, 731};
  320.  
  321.   tft.graphicsMode();
  322.   tft.drawFastHLine(0,255,800,RA8875_BLACK); // Row 1
  323.   tft.drawFastHLine(0,330,800,RA8875_BLACK); // Row 2
  324.   tft.drawFastHLine(0,405,800,RA8875_BLACK); // Row 3
  325.   tft.drawFastVLine(160,80,175,RA8875_BLACK); // Action 1
  326.   tft.drawFastVLine(640,80,175,RA8875_BLACK); // Action 2
  327.  
  328.  
  329.   for(short i = 1; i < 10; i++){ // Row 1 columns
  330.     tft.drawFastVLine(80*i,255,75,RA8875_BLACK);
  331.   }
  332.  
  333.   for(short i = 1; i < 9; i++){ // Row 2 columns
  334.     tft.drawFastVLine(88.888*i,330,75,RA8875_BLACK);
  335.   }
  336.  
  337.   for(short i = 1; i < 7; i++){ // Row 3 columns
  338.     tft.drawFastVLine(114.285714*i,405,75,RA8875_BLACK);
  339.   }
  340.  
  341.   tft.textMode();
  342.   tft.textEnlarge(2);
  343.  
  344.   for(short i = 0; i < 10; i++){
  345.     tft.textSetCursor(29+(80*i),265);
  346.     tft.textWrite(&alphaKeys[i], 1);
  347.   }
  348.  
  349.   for(short i = 0; i < 9; i++){
  350.     tft.textSetCursor(xRow2[i],340);
  351.     tft.textWrite(&alphaKeys[i+10], 1);
  352.   }
  353.  
  354.   for(short i = 0; i < 7; i++){
  355.     tft.textSetCursor(xRow3[i],415);
  356.     tft.textWrite(&alphaKeys[i+19], 1);
  357.   }
  358. }
  359.  
  360. void drawNumpad(){
  361.   tft.graphicsMode();
  362.   tft.drawFastHLine(0,255,800
  363. }
  364.  
  365. void drawClear(){
  366.   tft.graphicsMode();
  367.   tft.fillRect(641,81,159,173,0xCE39);
  368.   tft.fillRect(660,100,120,100,RA8875_RED);
  369.   tft.fillTriangle(665,100,720,145,775,100,0xCE39);
  370.   tft.fillTriangle(660,105,715,150,660,195,0xCE39);
  371.   tft.fillTriangle(665,200,720,155,775,200,0xCE39);
  372.   tft.fillTriangle(780,195,725,150,780,105,0xCE39);
  373.   tft.textMode();
  374.   tft.textEnlarge(1);
  375.   tft.textTransparent(RA8875_BLACK);
  376.   tft.textSetCursor(683,220);
  377.   tft.textWrite("Clear");
  378.   return;
  379. }
  380.  
  381. void drawBackspace(){
  382.   tft.graphicsMode();
  383.   tft.fillRect(0,81,159,173,0xCE39);
  384.   tft.fillTriangle(20,150,80,200,80,100,RA8875_RED);
  385.   tft.fillTriangle(30,150,90,200,90,100,0xCE39);
  386.   tft.fillRect(30,147,107,7,RA8875_RED);
  387.   tft.textMode();
  388.   tft.textSetCursor(8,220);
  389.   tft.textEnlarge(1);
  390.   tft.textTransparent(RA8875_BLACK);
  391.   tft.textWrite("Backspace");
  392.   return;
  393. }
  394.  
  395. void drawEnter(){
  396.   tft.graphicsMode();
  397.   tft.fillRect(641,81,159,173,0xCE39);
  398.   tft.fillTriangle(780,150,720,200,720,100,RA8875_GREEN);
  399.   tft.fillTriangle(770,150,710,200,710,100,0xCE39);
  400.   tft.fillRect(663,147,107,7,RA8875_GREEN);
  401.   tft.textMode();
  402.   tft.textEnlarge(1);
  403.   tft.textTransparent(RA8875_BLACK);
  404.   tft.textSetCursor(683,220);
  405.   tft.textWrite("Enter");
  406.   return;
  407. }
  408.  
  409. void channelEntryHandler(char* outPtr){
  410.   drawKeyboard();
  411.   drawBackspace();
  412.   drawClear();
  413.  
  414.   tft.textSetCursor(223,120);
  415.   tft.textEnlarge(3);
  416.   tft.textTransparent(0xAD35);
  417.   tft.textWrite("A B C D 1 2");
  418.   tft.textSetCursor(221,140);
  419.   tft.textTransparent(RA8875_BLACK);
  420.   tft.textWrite("_ _ _ _ _ _");
  421.  
  422.   short cursorPtr = 0;
  423.   boolean alphaInputMode = true;
  424.   boolean firstEntry = true;
  425.  
  426.   while(true){
  427.     while(cursorPtr < 8){
  428.       Serial.print("Channel Entry to Date: ");
  429.       for(short i = 0; i < 10; i++){
  430.         Serial.print(outPtr[i]);
  431.       }
  432.       Serial.println(". ");
  433.       if(alphaInputMode == false){
  434.         drawKeyboard();
  435.         alphaInputMode = true;
  436.       }
  437.       char nextInput = handleAlphaEntry();
  438.       if(nextInput == ('!')){
  439.         cursorPtr = 0;
  440.         drawEntry(outPtr, cursorPtr);
  441.       }else if(nextInput == ('`')){
  442.         cursorPtr -= 2;
  443.         if(cursorPtr < 0){
  444.           cursorPtr = 0;
  445.         }
  446.         drawEntry(outPtr, cursorPtr);
  447.       }else{
  448.         if(firstEntry == true){
  449.           firstEntry = false;
  450.           tft.graphicsMode();
  451.           tft.fillRect(223,120,400,19,0xCE39);
  452.         }
  453.         if(nextInput != ('*')){
  454.           outPtr[cursorPtr] = nextInput;
  455.           cursorPtr += 2;
  456.           drawEntry(outPtr, cursorPtr);
  457.         }
  458.       }
  459.     }
  460.  
  461.     while(cursorPtr >= 8 && cursorPtr < 11){
  462.       Serial.print("Channel Entry to Date: ");
  463.       for(short i = 0; i < 10; i+=2){
  464.         Serial.print(outPtr[i]);
  465.       }
  466.       Serial.println(". ");
  467.       if(alphaInputMode == true){
  468.         drawKeyboard();
  469.         alphaInputMode = false;
  470.       }
  471.       char nextInput = handleNumEntry();
  472.       if(nextInput == ('!')){
  473.         cursorPtr = 0;
  474.         drawEntry(outPtr, cursorPtr);
  475.       }else if(nextInput == ('`')){
  476.         cursorPtr -= 2;
  477.         drawEntry(outPtr, cursorPtr);
  478.       }else{
  479.         if(nextInput != ('*')){
  480.           outPtr[cursorPtr] = nextInput;
  481.           cursorPtr += 2;
  482.           drawEntry(outPtr, cursorPtr);
  483.         }
  484.       }
  485.     }
  486.  
  487.     while(cursorPtr == 11){
  488.       Serial.print("Channel Entry to Date: ");
  489.       for(short i = 0; i < 10; i+=2){
  490.         Serial.print(outPtr[i]);
  491.       }
  492.       Serial.println(". ");
  493.       boolean enter = handleEntryConfirmation();
  494.       if(enter == true){
  495.         return;
  496.       }else{
  497.         cursorPtr = 10;
  498.         drawEntry(outPtr, cursorPtr);
  499.       }
  500.     }
  501.   }
  502.   return;
  503. }
  504.  
  505. void drawEntry(char *entryToDate, short cursorPtr){
  506.   tft.fillRect(220,120,400,60,0xCE39);
  507.   tft.textMode();
  508.   tft.textEnlarge(3);
  509.   tft.textTransparent(RA8875_BLACK);
  510.   tft.textSetCursor(220,120);
  511.   if(cursorPtr == 0){
  512.     return;
  513.   }
  514.   tft.textWrite(entryToDate, cursorPtr);
  515. }
  516.  
  517. char handleAlphaEntry(){
  518.   if(boardType != 0){
  519.     drawKeyboard();
  520.   }
  521.  
  522.   Serial.println("handleAlphaEntry start success, init if pass");
  523.   tsPoint_t raw;
  524.   tsPoint_t cal;
  525.   waitForTouchEvent(&raw);
  526.   Serial.println("Point accepted");
  527.   calibrateTSPoint(&cal, &raw, &_tsMatrix);
  528.   Serial.println("Point accepted and calibrated");
  529.   delay(250);
  530.  
  531.   if(cal.y > 80){
  532.     if(cal.y < 255){
  533.       if(cal.x < 160){
  534.         Serial.println("Backspace returned");
  535.         return '`';
  536.       }else if(cal.x > 640){
  537.         Serial.println("Clear returned");
  538.         return '!';
  539.       }
  540.     }else if(cal.y < 330 && cal.x >= 0 && cal.x <= 800){
  541.       return alphaKeys[((short)(cal.x/80))];
  542.     }else if(cal.y < 405){
  543.       return alphaKeys[(((short)(cal.x/88.888))+10)];
  544.     }else if(cal.y < 801){
  545.       return alphaKeys[(((short)(cal.x/114.285714))+19)];
  546.     }
  547.   }
  548.   return '*';
  549. }
  550.  
  551. char handleNumEntry(){
  552.   if(boardType != 1){
  553.     drawNumpad();
  554.   }
  555.  
  556.   tsPoint_t raw;
  557.   tsPoint_t cal;
  558.   waitForTouchEvent(&raw);
  559.   calibrateTSPoint(&cal, &raw, &_tsMatrix);
  560.   return '*';
  561. }
  562.  
  563. boolean handleEntryConfirmation(){
  564.   drawEnter();
  565.   while(true){
  566.     tsPoint_t raw;
  567.     tsPoint_t cal;
  568.     waitForTouchEvent(&raw);
  569.     calibrateTSPoint(&cal, &raw, &_tsMatrix);
  570.  
  571.     if(cal.y > 80){ // Below header
  572.       if(cal.y < 255){ // Action buttons
  573.         if(cal.x < 160){ // Backspace
  574.           drawClear();
  575.           return false;
  576.         }else if(cal.x > 640){ // Enter
  577.           return true;
  578.         }
  579.       }
  580.     }
  581.   }
  582. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement