Release 1.01

ButtonController.h

Committer:
foxbrianr
Date:
2019-09-17
Revision:
2:1d5204d29bc5
Parent:
1:86f6ebbe4fd1

File content as of revision 2:1d5204d29bc5:

/**************************************************************************//**
 * @file     ButtonController.h
 * @brief    Base class for wrapping the interface with the GPIO Extender.
 * @version: V1.0
 * @date:    9/17/2019

 *
 * @note
 * Copyright (C) 2019 E3 Design. All rights reserved.
 *
 * @par
 * E3 Designers LLC is supplying this software for use with Cortex-M3 LPC1768
 * processor based microcontroller for the ESCM 2000 Monitor and Display.  
 *  *
 * @par
 * THIS SOFTWARE IS PROVIDED "AS IS".  NO WARRANTIES, WHETHER EXPRESS, IMPLIED
 * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
 * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
 * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
 *
 ******************************************************************************/
 
 #ifndef _BUTTON_CONTROLLER_
#define _BUTTON_CONTROLLER_

#include "mbed.h"
#include "rtos.h"
#include "mcp23s08.h"
#include "Menu.h"

/**
 * service to manage the external GPIO expander board.
 */
typedef enum
{
    NO_BUTTON    = 27,
    BUTTON_UP    = 26,
    BUTTON_DOWN  = 25,
    BUTTON_MODE  = 19,
    BUTTON_SET   = 11,
    BUTTON_CLEAR = 0
} tButtonValue ;

typedef void (*t_ButtonPressCallback)(void);


/***
*
* This class wrapps the communication with the GPIO expander over SPI bus.
*  PIN 0 : Up
*  PIN 1 : Down
*  PIN 2 : Clear
*  PIN 3 : Mode
*  PIN 4 : Set
*  PIN 5 : Enable Audio
*  PIN 6 : na
*  PIN 7 : na 
*  
*  MASK = 0x1F;
*  
*/
class ButtonController 
{
    public :
        
        mcp23s08 *      spi_io_exp;
        Mutex           _mutex;
        unsigned char   currentValue;
        unsigned char   prevValue;
        unsigned char   confirmedValue;
        unsigned int    countsSinceChange;
        unsigned char   isServiced;
        unsigned char   isHeld;
        
        
        CircularBuffer<uint8_t, 64> cmd_queue;
        
        ButtonController();
        ~ButtonController();
        
        void  pressButtonUp(void);
        void  pressButtonDown(void);
        void  pressButtonClear(void);
        void  pressButtonMode(void);
        void  pressButtonSet(void);
        void  releaseButton(void);
        
        void init(void);
        void update(void);
        void processCmdQueue(Menu * activeMenu);
        
        uint8_t getCurrentState ();
};


#endif