summaryrefslogtreecommitdiffstats
path: root/source/Concept/Framework/keyboard.h
diff options
context:
space:
mode:
authorsicarius <devnull@localhost>2007-02-17 14:42:00 +0100
committersicarius <devnull@localhost>2007-02-17 14:42:00 +0100
commit803027cbb45ebe01e4f8b427a7cc95728d6e5f47 (patch)
treebbb3bd0a042e75e4d01d2e13faf1fe30851eadbc /source/Concept/Framework/keyboard.h
parent4a2ba4b7105d168932163cbd07a062fdf2ba00e9 (diff)
downloadrc2007-soccer-803027cbb45ebe01e4f8b427a7cc95728d6e5f47.tar
rc2007-soccer-803027cbb45ebe01e4f8b427a7cc95728d6e5f47.zip
+++ enhanced framework hardware interface
Diffstat (limited to 'source/Concept/Framework/keyboard.h')
-rw-r--r--source/Concept/Framework/keyboard.h87
1 files changed, 87 insertions, 0 deletions
diff --git a/source/Concept/Framework/keyboard.h b/source/Concept/Framework/keyboard.h
new file mode 100644
index 0000000..d984586
--- /dev/null
+++ b/source/Concept/Framework/keyboard.h
@@ -0,0 +1,87 @@
+#ifndef _KEYBOARD_H
+#define _KEYBOARD_H
+
+#include "stdafx.h"
+
+class Keyboard : public IO_Module
+{
+public:
+ Keyboard()
+ {
+ this->parent = NULL;
+ this->moduleId = 0;
+ this->commandSetting = 0;
+ this->settingClearBuffer = 0;
+ }
+
+ Keyboard(uint32 keyboardId)
+ {
+ this->parent = NULL;
+ this->moduleId = keyboardId;
+
+ switch(keyboardId)
+ {
+ case IO_KEYBOARD_MAIN:
+ this->commandSetting = 27;
+ this->settingClearBuffer = 123;
+ break;
+ default:
+ this->commandSetting = 0;
+ this->settingClearBuffer = 0;
+ break;
+ }
+ }
+
+protected:
+ //Commands
+ uint8 commandSetting;
+ //Settings
+ uint8 settingClearBuffer;
+
+ void SendCommand(uint8 newCommand)
+ {
+ switch(moduleId)
+ {
+ case IO_KEYBOARD_MAIN:
+ uart1_putc(newCommand);
+ break;
+ default:
+ break;
+ }
+ }
+
+public:
+ uint8 GetInput()
+ {
+ uint16 input = uart1_getc();
+
+ if(input == 0x100)//no data
+ {
+ return 0xEE;//empty
+ }
+ else if(input >= '0' && input <= '9')
+ {
+ return (uint8)(input - '0');
+ }
+ else if(input == '*')
+ {
+ return 10;
+ }
+ else if(input == '#')
+ {
+ return 11;
+ }
+ else
+ {
+ return 0xFF;//unknown
+ }
+ }
+
+ void ClearKeyBuffer()
+ {
+ SendCommand(commandSetting);
+ SendCommand(settingClearBuffer);
+ }
+};
+
+#endif