mbed3

Dependencies:   LCD_DISCO_F429ZI mbed TS_DISCO_F429ZI BSP_DISCO_F429ZI

Keyboard.cpp

Committer:
wolve265
Date:
2020-05-25
Revision:
2:aebba5ba280a
Parent:
Keyboard_Ts.cpp@ 0:6d0b62cb7525

File content as of revision 2:aebba5ba280a:

#include "Keyboard.h"

Keyboard::Keyboard(unsigned char ucColumn){
    ucKeyPosXLeft = ucColumn*80;
    ucKeyPosXRight = (ucColumn+1)*80;
}

enum KeyboardState Keyboard::eRead(){
    ts.GetState(&TS_State);      
    if(TS_State.TouchDetected){
        if(TS_State.X > ucKeyPosXLeft && TS_State.X < ucKeyPosXRight){
            if(TS_State.Y < 80){
                return BUTTON_0;
            }
            else if(TS_State.Y < 160){
                return BUTTON_1;
            }
            else if(TS_State.Y < 240){
                return BUTTON_2;
            }
            else{
                return BUTTON_3;
            }
        }
        else{
            return RELEASED;
        }
    }
    else{
        return RELEASED;
    }
}