Emiel Estiévenart
/
QT1070_copy
Schoolproject, Emulates a QT1070 from a touchberry
Diff: QT1070.cpp
- Revision:
- 0:b7b55b8a4d2b
- Child:
- 1:f4caacc4df1b
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QT1070.cpp Thu Nov 10 13:28:23 2016 +0000 @@ -0,0 +1,69 @@ +#include "mbed.h" +#include "QT1070.h" +DigitalIn btnUp(p15); //28 +DigitalIn btnRight(p16); //30 +DigitalIn btnDown(p12); // 31 +DigitalIn btnLeft(p13); // 22 +DigitalIn btnCenter(p14); //14 + +extern "C" void mbed_reset(); + + +namespace QT1070touchemulator +{ + +QT1070::QT1070() +{ + id_firmware = 0x00; + id_chip = 0x01; +} + +char QT1070::getFirmware() +{ + return id_firmware; +} + +char QT1070::getChipID() +{ + return id_chip; +} + +int QT1070::getKeystate() +{ + int createdData = 0x00; + if (btnDown==1) { + createdData = createdData | 0x01; + } else { + createdData= createdData & ~ 0x01; + } + if (!btnUp) { + createdData = createdData | 0x02; + } else { + createdData= createdData & ~ 0x02; + } + if (!btnRight) { + createdData = createdData | 0x04; + } else { + createdData= createdData & ~ 0x04; + } + if (!btnLeft) { + createdData = createdData | 0x08; + } else { + createdData= createdData & ~ 0x08; + } + if (!btnCenter) { + createdData = createdData | 0x10; + } else { + createdData= createdData & ~ 0x10; + } + + return createdData; + +} + +void QT1070::resetMbed() +{ + mbed_reset(); +} + +};