Libraries and Example of mbed parallel bus using I2C port expanders

Dependencies:   HDSP253X mbed PCF8574_Bus

Keyboard.h

Committer:
wim
Date:
2011-08-26
Revision:
5:38b853bb1afa
Parent:
4:745fbbd5e4e5

File content as of revision 5:38b853bb1afa:

/* 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 4-7 not used
#define D_KEYBOARD_MASK             0x0F 

//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();
    Key_Code getswitch();    
            
protected:
    PCF8574_DataBus &_databus;
    PCF8574_EnableBus &_enablebus;
    MBED_ControlBus &_controlbus;   
    bool _KeyReady;      
    Key_Code _KeyCode;

    uint8_t _read();   
    void _init();          
};


#endif
/*****************************************************************************/
/******************************  END OF FILE  ********************************/
/*****************************************************************************/