Mbed touchscreed project. To be corrected

Dependencies:   LCD_DISCO_F429ZI mbed TS_DISCO_F429ZI BSP_DISCO_F429ZI

Keyboard_Ts.cpp

Committer:
piotrlopata
Date:
2020-05-08
Revision:
1:55e05d2aa9cd
Child:
4:35b2f0e76b02

File content as of revision 1:55e05d2aa9cd:

#include "Keyboard_Ts.h"

TS_DISCO_F429ZI ts;
TS_StateTypeDef TS_State;

KeyboardTs::KeyboardTs(unsigned char columnNumber){
    ColumnX = columnNumber*80;
}

enum Buttons KeyboardTs::eRead(void) {
    uint16_t x;
    uint16_t y;
    ts.GetState(&TS_State);
    x = TS_State.X;
    y = TS_State.Y;
    if((! TS_State.TouchDetected) || !((x>ColumnX) && (x<ColumnX+80)) ) return OTHER;
    else if( (y>0) && (y<80) ) return BUTTON_0;
    else if( (y>80) && (y<160) ) return BUTTON_1;
    else if( (y>160) && (y<240) ) return BUTTON_2;
    else return BUTTON_3;
}