a

Dependencies:   BSP_DISCO_F429ZI LCD_DISCO_F429ZI TS_DISCO_F429ZI mbed

Committer:
pbl96
Date:
Mon Apr 24 15:31:03 2017 +0000
Revision:
0:9d0b60394104
a

Who changed what in which revision?

UserRevisionLine numberNew contents of line
pbl96 0:9d0b60394104 1 #include "TS_DISCO_F429ZI.h"
pbl96 0:9d0b60394104 2 #include "Keyboard_TS.h"
pbl96 0:9d0b60394104 3
pbl96 0:9d0b60394104 4 TS_DISCO_F429ZI ts;
pbl96 0:9d0b60394104 5
pbl96 0:9d0b60394104 6
pbl96 0:9d0b60394104 7
pbl96 0:9d0b60394104 8 KeyboardTs::KeyboardTs(uint8_t colnum) {
pbl96 0:9d0b60394104 9 ts.Init(240,320);
pbl96 0:9d0b60394104 10 if(colnum>=1 && colnum<=3)
pbl96 0:9d0b60394104 11 column=colnum;
pbl96 0:9d0b60394104 12 else
pbl96 0:9d0b60394104 13 column=1;
pbl96 0:9d0b60394104 14 }
pbl96 0:9d0b60394104 15
pbl96 0:9d0b60394104 16 enum KeyboardState KeyboardTs::eRead(void){
pbl96 0:9d0b60394104 17 TS_StateTypeDef TS_State;
pbl96 0:9d0b60394104 18 ts.GetState(&TS_State);
pbl96 0:9d0b60394104 19
pbl96 0:9d0b60394104 20 if (TS_State.TouchDetected && TS_State.X>(80*(column-1)) && TS_State.X<80*column && TS_State.Y <80){
pbl96 0:9d0b60394104 21 return BUTTON_0;
pbl96 0:9d0b60394104 22 }
pbl96 0:9d0b60394104 23 else if(TS_State.TouchDetected && TS_State.X>(80*(column-1)) && TS_State.X<80*column && TS_State.Y>=80 && TS_State.Y <160){
pbl96 0:9d0b60394104 24 return BUTTON_1;
pbl96 0:9d0b60394104 25 }
pbl96 0:9d0b60394104 26 else if (TS_State.TouchDetected && TS_State.X>(80*(column-1)) && TS_State.X<80*column && TS_State.Y>=160 && TS_State.Y <240){
pbl96 0:9d0b60394104 27 return BUTTON_2;
pbl96 0:9d0b60394104 28 }
pbl96 0:9d0b60394104 29 else if (TS_State.TouchDetected && TS_State.X>(80*(column-1)) && TS_State.X<80*column && TS_State.Y>=240 && TS_State.Y <320){
pbl96 0:9d0b60394104 30 return BUTTON_3;
pbl96 0:9d0b60394104 31 }
pbl96 0:9d0b60394104 32 else{
pbl96 0:9d0b60394104 33 return RELASED;
pbl96 0:9d0b60394104 34 }
pbl96 0:9d0b60394104 35
pbl96 0:9d0b60394104 36
pbl96 0:9d0b60394104 37 void KeyboardTs::On(uint8_t ButtonNum) {
pbl96 0:9d0b60394104 38
pbl96 0:9d0b60394104 39 uint8_t x_pos;
pbl96 0:9d0b60394104 40
pbl96 0:9d0b60394104 41 switch(column) {
pbl96 0:9d0b60394104 42 case 1: x_pos=0; break;
pbl96 0:9d0b60394104 43 case 2: x_pos=79; break;
pbl96 0:9d0b60394104 44 case 3: x_pos=159; break;
pbl96 0:9d0b60394104 45 }
pbl96 0:9d0b60394104 46
pbl96 0:9d0b60394104 47
pbl96 0:9d0b60394104 48 ButtonNoPushed(x_pos,0,80,80);
pbl96 0:9d0b60394104 49 ButtonNoPushed(x_pos,79,80,80);
pbl96 0:9d0b60394104 50 ButtonNoPushed(x_pos,159,80,80);
pbl96 0:9d0b60394104 51 ButtonNoPushed(x_pos,239,80,80);
pbl96 0:9d0b60394104 52
pbl96 0:9d0b60394104 53 if(ButtonNum==0) {
pbl96 0:9d0b60394104 54 ButtonPushed(x_pos,0,80,80);
pbl96 0:9d0b60394104 55 }
pbl96 0:9d0b60394104 56 else if(ButtonNum==1) {
pbl96 0:9d0b60394104 57 ButtonPushed(x_pos,79,80,80);
pbl96 0:9d0b60394104 58 }
pbl96 0:9d0b60394104 59 else if(ButtonNum==2) {
pbl96 0:9d0b60394104 60 ButtonPushed(x_pos,159,80,80);
pbl96 0:9d0b60394104 61 }
pbl96 0:9d0b60394104 62 else if(ButtonNum==3) {
pbl96 0:9d0b60394104 63 ButtonPushed(x_pos,239,80,80);
pbl96 0:9d0b60394104 64 }
pbl96 0:9d0b60394104 65 else if(ButtonNum==4) {
pbl96 0:9d0b60394104 66 }
pbl96 0:9d0b60394104 67
pbl96 0:9d0b60394104 68 SetString(x_pos,0,(uint8_t *)"0",LEFT_MODE);
pbl96 0:9d0b60394104 69 SetString(x_pos,79,(uint8_t *)"1",LEFT_MODE);
pbl96 0:9d0b60394104 70 SetString(x_pos,159,(uint8_t *)"2",LEFT_MODE);
pbl96 0:9d0b60394104 71 SetString(x_pos,239,(uint8_t *)"3",LEFT_MODE);
pbl96 0:9d0b60394104 72 }
pbl96 0:9d0b60394104 73
pbl96 0:9d0b60394104 74 }
pbl96 0:9d0b60394104 75