Release 1.01

Committer:
foxbrianr
Date:
Thu Sep 12 11:27:59 2019 +0000
Revision:
1:86f6ebbe4fd1
Parent:
0:b6d729ae4f27
Child:
2:1d5204d29bc5
beta1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
foxbrianr 0:b6d729ae4f27 1 #ifndef _BUTTON_CONTROLLER_
foxbrianr 0:b6d729ae4f27 2 #define _BUTTON_CONTROLLER_
foxbrianr 0:b6d729ae4f27 3
foxbrianr 0:b6d729ae4f27 4 #include "mbed.h"
foxbrianr 0:b6d729ae4f27 5 #include "rtos.h"
foxbrianr 0:b6d729ae4f27 6 #include "mcp23s08.h"
foxbrianr 0:b6d729ae4f27 7 #include "Menu.h"
foxbrianr 0:b6d729ae4f27 8
foxbrianr 0:b6d729ae4f27 9 /**
foxbrianr 0:b6d729ae4f27 10 * service to manage the external GPIO expander board.
foxbrianr 0:b6d729ae4f27 11 */
foxbrianr 0:b6d729ae4f27 12 typedef enum
foxbrianr 0:b6d729ae4f27 13 {
foxbrianr 0:b6d729ae4f27 14 NO_BUTTON = 27,
foxbrianr 0:b6d729ae4f27 15 BUTTON_UP = 26,
foxbrianr 0:b6d729ae4f27 16 BUTTON_DOWN = 25,
foxbrianr 0:b6d729ae4f27 17 BUTTON_MODE = 19,
foxbrianr 0:b6d729ae4f27 18 BUTTON_SET = 11,
foxbrianr 0:b6d729ae4f27 19 BUTTON_CLEAR = 0
foxbrianr 0:b6d729ae4f27 20 } tButtonValue ;
foxbrianr 0:b6d729ae4f27 21
foxbrianr 0:b6d729ae4f27 22 typedef void (*t_ButtonPressCallback)(void);
foxbrianr 0:b6d729ae4f27 23
foxbrianr 0:b6d729ae4f27 24
foxbrianr 0:b6d729ae4f27 25 /***
foxbrianr 0:b6d729ae4f27 26 *
foxbrianr 0:b6d729ae4f27 27 * This class wrapps the communication with the GPIO expander over SPI bus.
foxbrianr 0:b6d729ae4f27 28 * PIN 0 : Up
foxbrianr 0:b6d729ae4f27 29 * PIN 1 : Down
foxbrianr 0:b6d729ae4f27 30 * PIN 2 : Clear
foxbrianr 0:b6d729ae4f27 31 * PIN 3 : Mode
foxbrianr 0:b6d729ae4f27 32 * PIN 4 : Set
foxbrianr 0:b6d729ae4f27 33 * PIN 5 : Enable Audio
foxbrianr 0:b6d729ae4f27 34 * PIN 6 : na
foxbrianr 0:b6d729ae4f27 35 * PIN 7 : na
foxbrianr 0:b6d729ae4f27 36 *
foxbrianr 0:b6d729ae4f27 37 * MASK = 0x1F;
foxbrianr 0:b6d729ae4f27 38 *
foxbrianr 0:b6d729ae4f27 39 */
foxbrianr 0:b6d729ae4f27 40 class ButtonController
foxbrianr 0:b6d729ae4f27 41 {
foxbrianr 0:b6d729ae4f27 42 public :
foxbrianr 0:b6d729ae4f27 43
foxbrianr 0:b6d729ae4f27 44 mcp23s08 * spi_io_exp;
foxbrianr 0:b6d729ae4f27 45 Mutex _mutex;
foxbrianr 0:b6d729ae4f27 46 unsigned char currentValue;
foxbrianr 0:b6d729ae4f27 47 unsigned char prevValue;
foxbrianr 0:b6d729ae4f27 48 unsigned char confirmedValue;
foxbrianr 0:b6d729ae4f27 49 unsigned int countsSinceChange;
foxbrianr 0:b6d729ae4f27 50 unsigned char isServiced;
foxbrianr 0:b6d729ae4f27 51 unsigned char isHeld;
foxbrianr 0:b6d729ae4f27 52
foxbrianr 0:b6d729ae4f27 53
foxbrianr 0:b6d729ae4f27 54 CircularBuffer<uint8_t, 64> cmd_queue;
foxbrianr 0:b6d729ae4f27 55
foxbrianr 1:86f6ebbe4fd1 56 ButtonController();
foxbrianr 0:b6d729ae4f27 57 ~ButtonController();
foxbrianr 0:b6d729ae4f27 58
foxbrianr 0:b6d729ae4f27 59 void pressButtonUp(void);
foxbrianr 0:b6d729ae4f27 60 void pressButtonDown(void);
foxbrianr 0:b6d729ae4f27 61 void pressButtonClear(void);
foxbrianr 0:b6d729ae4f27 62 void pressButtonMode(void);
foxbrianr 0:b6d729ae4f27 63 void pressButtonSet(void);
foxbrianr 0:b6d729ae4f27 64 void releaseButton(void);
foxbrianr 0:b6d729ae4f27 65
foxbrianr 0:b6d729ae4f27 66 void init(void);
foxbrianr 0:b6d729ae4f27 67 void update(void);
foxbrianr 1:86f6ebbe4fd1 68 void processCmdQueue(Menu * activeMenu);
foxbrianr 0:b6d729ae4f27 69
foxbrianr 0:b6d729ae4f27 70 uint8_t getCurrentState ();
foxbrianr 0:b6d729ae4f27 71 };
foxbrianr 0:b6d729ae4f27 72
foxbrianr 0:b6d729ae4f27 73
foxbrianr 0:b6d729ae4f27 74 #endif