Aa

Dependents:   EMBEED_III_zad_4 mbed3 mbed_3 MBED3_zad4

Keyboard.cpp

Committer:
krzysiek99
Date:
2020-06-13
Revision:
1:374a3d1fe780

File content as of revision 1:374a3d1fe780:

#include "Keyboard.h"

Keyboard::Keyboard(unsigned char ucColumnMode)
{
    ts.Init(240, 320);
    ucTouchscreenColumn = 80*ucColumnMode;
}

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