Release 1.01
ButtonController.h@2:1d5204d29bc5, 2019-09-17 (annotated)
- Committer:
- foxbrianr
- Date:
- Tue Sep 17 13:48:28 2019 +0000
- Revision:
- 2:1d5204d29bc5
- Parent:
- 1:86f6ebbe4fd1
Beta 2
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
foxbrianr | 2:1d5204d29bc5 | 1 | /**************************************************************************//** |
foxbrianr | 2:1d5204d29bc5 | 2 | * @file ButtonController.h |
foxbrianr | 2:1d5204d29bc5 | 3 | * @brief Base class for wrapping the interface with the GPIO Extender. |
foxbrianr | 2:1d5204d29bc5 | 4 | * @version: V1.0 |
foxbrianr | 2:1d5204d29bc5 | 5 | * @date: 9/17/2019 |
foxbrianr | 2:1d5204d29bc5 | 6 | |
foxbrianr | 2:1d5204d29bc5 | 7 | * |
foxbrianr | 2:1d5204d29bc5 | 8 | * @note |
foxbrianr | 2:1d5204d29bc5 | 9 | * Copyright (C) 2019 E3 Design. All rights reserved. |
foxbrianr | 2:1d5204d29bc5 | 10 | * |
foxbrianr | 2:1d5204d29bc5 | 11 | * @par |
foxbrianr | 2:1d5204d29bc5 | 12 | * E3 Designers LLC is supplying this software for use with Cortex-M3 LPC1768 |
foxbrianr | 2:1d5204d29bc5 | 13 | * processor based microcontroller for the ESCM 2000 Monitor and Display. |
foxbrianr | 2:1d5204d29bc5 | 14 | * * |
foxbrianr | 2:1d5204d29bc5 | 15 | * @par |
foxbrianr | 2:1d5204d29bc5 | 16 | * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED |
foxbrianr | 2:1d5204d29bc5 | 17 | * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF |
foxbrianr | 2:1d5204d29bc5 | 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. |
foxbrianr | 2:1d5204d29bc5 | 19 | * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR |
foxbrianr | 2:1d5204d29bc5 | 20 | * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. |
foxbrianr | 2:1d5204d29bc5 | 21 | * |
foxbrianr | 2:1d5204d29bc5 | 22 | ******************************************************************************/ |
foxbrianr | 2:1d5204d29bc5 | 23 | |
foxbrianr | 2:1d5204d29bc5 | 24 | #ifndef _BUTTON_CONTROLLER_ |
foxbrianr | 0:b6d729ae4f27 | 25 | #define _BUTTON_CONTROLLER_ |
foxbrianr | 0:b6d729ae4f27 | 26 | |
foxbrianr | 0:b6d729ae4f27 | 27 | #include "mbed.h" |
foxbrianr | 0:b6d729ae4f27 | 28 | #include "rtos.h" |
foxbrianr | 0:b6d729ae4f27 | 29 | #include "mcp23s08.h" |
foxbrianr | 0:b6d729ae4f27 | 30 | #include "Menu.h" |
foxbrianr | 0:b6d729ae4f27 | 31 | |
foxbrianr | 0:b6d729ae4f27 | 32 | /** |
foxbrianr | 0:b6d729ae4f27 | 33 | * service to manage the external GPIO expander board. |
foxbrianr | 0:b6d729ae4f27 | 34 | */ |
foxbrianr | 0:b6d729ae4f27 | 35 | typedef enum |
foxbrianr | 0:b6d729ae4f27 | 36 | { |
foxbrianr | 0:b6d729ae4f27 | 37 | NO_BUTTON = 27, |
foxbrianr | 0:b6d729ae4f27 | 38 | BUTTON_UP = 26, |
foxbrianr | 0:b6d729ae4f27 | 39 | BUTTON_DOWN = 25, |
foxbrianr | 0:b6d729ae4f27 | 40 | BUTTON_MODE = 19, |
foxbrianr | 0:b6d729ae4f27 | 41 | BUTTON_SET = 11, |
foxbrianr | 0:b6d729ae4f27 | 42 | BUTTON_CLEAR = 0 |
foxbrianr | 0:b6d729ae4f27 | 43 | } tButtonValue ; |
foxbrianr | 0:b6d729ae4f27 | 44 | |
foxbrianr | 0:b6d729ae4f27 | 45 | typedef void (*t_ButtonPressCallback)(void); |
foxbrianr | 0:b6d729ae4f27 | 46 | |
foxbrianr | 0:b6d729ae4f27 | 47 | |
foxbrianr | 0:b6d729ae4f27 | 48 | /*** |
foxbrianr | 0:b6d729ae4f27 | 49 | * |
foxbrianr | 0:b6d729ae4f27 | 50 | * This class wrapps the communication with the GPIO expander over SPI bus. |
foxbrianr | 0:b6d729ae4f27 | 51 | * PIN 0 : Up |
foxbrianr | 0:b6d729ae4f27 | 52 | * PIN 1 : Down |
foxbrianr | 0:b6d729ae4f27 | 53 | * PIN 2 : Clear |
foxbrianr | 0:b6d729ae4f27 | 54 | * PIN 3 : Mode |
foxbrianr | 0:b6d729ae4f27 | 55 | * PIN 4 : Set |
foxbrianr | 0:b6d729ae4f27 | 56 | * PIN 5 : Enable Audio |
foxbrianr | 0:b6d729ae4f27 | 57 | * PIN 6 : na |
foxbrianr | 0:b6d729ae4f27 | 58 | * PIN 7 : na |
foxbrianr | 0:b6d729ae4f27 | 59 | * |
foxbrianr | 0:b6d729ae4f27 | 60 | * MASK = 0x1F; |
foxbrianr | 0:b6d729ae4f27 | 61 | * |
foxbrianr | 0:b6d729ae4f27 | 62 | */ |
foxbrianr | 0:b6d729ae4f27 | 63 | class ButtonController |
foxbrianr | 0:b6d729ae4f27 | 64 | { |
foxbrianr | 0:b6d729ae4f27 | 65 | public : |
foxbrianr | 0:b6d729ae4f27 | 66 | |
foxbrianr | 0:b6d729ae4f27 | 67 | mcp23s08 * spi_io_exp; |
foxbrianr | 0:b6d729ae4f27 | 68 | Mutex _mutex; |
foxbrianr | 0:b6d729ae4f27 | 69 | unsigned char currentValue; |
foxbrianr | 0:b6d729ae4f27 | 70 | unsigned char prevValue; |
foxbrianr | 0:b6d729ae4f27 | 71 | unsigned char confirmedValue; |
foxbrianr | 0:b6d729ae4f27 | 72 | unsigned int countsSinceChange; |
foxbrianr | 0:b6d729ae4f27 | 73 | unsigned char isServiced; |
foxbrianr | 0:b6d729ae4f27 | 74 | unsigned char isHeld; |
foxbrianr | 0:b6d729ae4f27 | 75 | |
foxbrianr | 0:b6d729ae4f27 | 76 | |
foxbrianr | 0:b6d729ae4f27 | 77 | CircularBuffer<uint8_t, 64> cmd_queue; |
foxbrianr | 0:b6d729ae4f27 | 78 | |
foxbrianr | 1:86f6ebbe4fd1 | 79 | ButtonController(); |
foxbrianr | 0:b6d729ae4f27 | 80 | ~ButtonController(); |
foxbrianr | 0:b6d729ae4f27 | 81 | |
foxbrianr | 0:b6d729ae4f27 | 82 | void pressButtonUp(void); |
foxbrianr | 0:b6d729ae4f27 | 83 | void pressButtonDown(void); |
foxbrianr | 0:b6d729ae4f27 | 84 | void pressButtonClear(void); |
foxbrianr | 0:b6d729ae4f27 | 85 | void pressButtonMode(void); |
foxbrianr | 0:b6d729ae4f27 | 86 | void pressButtonSet(void); |
foxbrianr | 0:b6d729ae4f27 | 87 | void releaseButton(void); |
foxbrianr | 0:b6d729ae4f27 | 88 | |
foxbrianr | 0:b6d729ae4f27 | 89 | void init(void); |
foxbrianr | 0:b6d729ae4f27 | 90 | void update(void); |
foxbrianr | 1:86f6ebbe4fd1 | 91 | void processCmdQueue(Menu * activeMenu); |
foxbrianr | 0:b6d729ae4f27 | 92 | |
foxbrianr | 0:b6d729ae4f27 | 93 | uint8_t getCurrentState (); |
foxbrianr | 0:b6d729ae4f27 | 94 | }; |
foxbrianr | 0:b6d729ae4f27 | 95 | |
foxbrianr | 0:b6d729ae4f27 | 96 | |
foxbrianr | 0:b6d729ae4f27 | 97 | #endif |