Libraries and Example of mbed parallel bus using I2C port expanders
Dependencies: HDSP253X mbed PCF8574_Bus
Diff: Keyboard.h
- Revision:
- 2:1dab1089c332
- Child:
- 4:745fbbd5e4e5
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Keyboard.h Sat Aug 20 12:49:44 2011 +0000 @@ -0,0 +1,63 @@ +/* Keyboard - Keyboard and Fire Switch control + * + * Copyright (c) 2011 Wim Huiskamp + * + * Released under the MIT License: http://mbed.org/license/mit + * + * version 0.2 Initial Release +*/ +#ifndef _KEYBOARD_H +#define _KEYBOARD_H + +/*****************************************************************************/ +/********************* DEFINITIONS FOR KEYBOARD ***************************/ +/*****************************************************************************/ + +// Definitions for Keyboard Latch +// NOTE: NEED TO CHECK THESE !!!! +#define D_KEYBOARD_NONE 0x00 +#define D_KEYBOARD_MODE 0x01 +#define D_KEYBOARD_EDIT_PATH 0x02 +#define D_KEYBOARD_BRIGHT 0x03 +#define D_KEYBOARD_NOTUSED_4 0x04 +#define D_KEYBOARD_GRAT_RT 0x05 +#define D_KEYBOARD_F_L_UP 0x06 +#define D_KEYBOARD_NOTUSED_7 0x07 + +// Masks for keyboard codes, bit 7 not used +#define D_KEYBOARD_MASK 0x7F + +//Enums for Keyboard codes +enum Key_Code { KEY_NONE, KEY_MODE, KEY_EDIT_PATH, KEY_BRIGHT, KEY_GRAT_RT, KEY_F_L_UP, KEY_FIRE }; + + +/** Create a Keyboard object connected to the proper busses + * + * @param PCF8574_DataBus data databus to connect to + * @param PCF8574_EnableBus enable enablebus to connect to + * @param MBED_ControlBus control controlbus to connect to +*/ +class Keyboard { +public: + Keyboard(PCF8574_DataBus &databus, + PCF8574_EnableBus &enablebus, MBED_ControlBus &controlbus); + bool readable (); + Key_Code getkey(); + +protected: + PCF8574_DataBus &_databus; + PCF8574_EnableBus &_enablebus; + MBED_ControlBus &_controlbus; + bool _KeyReady; + Key_Code _KeyCode; + + uint8_t _read(); + void _init(); +}; + + +#endif +/*****************************************************************************/ +/****************************** END OF FILE ********************************/ +/*****************************************************************************/ +