This project allows for the sending of MIDI messages, and setting of variable resistances, controlled by a distance sensor. MIDI input messages can also be used to set the variable resistance.
Dependencies: N5110 PinDetect SRF08 USBDevice mbed PowerControl
main.h@1:802453187acf, 2015-05-11 (annotated)
- Committer:
- el13tjoc
- Date:
- Mon May 11 11:14:59 2015 +0000
- Revision:
- 1:802453187acf
- Parent:
- 0:39399720eaeb
Added Ethernet Powerdown;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
el13tjoc | 0:39399720eaeb | 1 | /** |
el13tjoc | 0:39399720eaeb | 2 | @file main.h |
el13tjoc | 0:39399720eaeb | 3 | @brief Header file containing functions prototypes, defines and global variables. |
el13tjoc | 0:39399720eaeb | 4 | @brief Revision 6.0. |
el13tjoc | 0:39399720eaeb | 5 | @author Toby O'Connell |
el13tjoc | 0:39399720eaeb | 6 | @date May 2015 |
el13tjoc | 0:39399720eaeb | 7 | */ |
el13tjoc | 0:39399720eaeb | 8 | |
el13tjoc | 0:39399720eaeb | 9 | #include "mbed.h" |
el13tjoc | 0:39399720eaeb | 10 | #include "N5110.h" |
el13tjoc | 0:39399720eaeb | 11 | #include "SRF08.h" |
el13tjoc | 0:39399720eaeb | 12 | #include <string> |
el13tjoc | 0:39399720eaeb | 13 | #include "PinDetect.h" |
el13tjoc | 0:39399720eaeb | 14 | #include "USBMIDI.h" |
el13tjoc | 0:39399720eaeb | 15 | #include <fstream> |
el13tjoc | 0:39399720eaeb | 16 | #include <sstream> |
el13tjoc | 0:39399720eaeb | 17 | #include <vector> |
el13tjoc | 1:802453187acf | 18 | #include "PowerControl/PowerControl.h" |
el13tjoc | 1:802453187acf | 19 | #include "PowerControl/EthernetPowerControl.h" |
el13tjoc | 0:39399720eaeb | 20 | |
el13tjoc | 0:39399720eaeb | 21 | #ifndef MAIN_H |
el13tjoc | 0:39399720eaeb | 22 | #define MAIN_H |
el13tjoc | 0:39399720eaeb | 23 | |
el13tjoc | 0:39399720eaeb | 24 | /** |
el13tjoc | 0:39399720eaeb | 25 | @namespace SRF08 |
el13tjoc | 0:39399720eaeb | 26 | @brief SRF08 ultrasonic range finder setup |
el13tjoc | 0:39399720eaeb | 27 | */ |
el13tjoc | 0:39399720eaeb | 28 | SRF08 SRF08(p28, p27, 0xE2); |
el13tjoc | 0:39399720eaeb | 29 | /** |
el13tjoc | 0:39399720eaeb | 30 | @namespace MCP4151 |
el13tjoc | 0:39399720eaeb | 31 | @brief SPI setup for MCP4151 digital potentiometer |
el13tjoc | 0:39399720eaeb | 32 | */ |
el13tjoc | 0:39399720eaeb | 33 | SPI MCP4151(p5, NC, p7); // SPI pins for MCP4151 (MOSI, MISO, SCLK) |
el13tjoc | 0:39399720eaeb | 34 | /** |
el13tjoc | 0:39399720eaeb | 35 | @namespace CS |
el13tjoc | 0:39399720eaeb | 36 | @brief GPIO output for MCP4151 chip select |
el13tjoc | 0:39399720eaeb | 37 | */ |
el13tjoc | 0:39399720eaeb | 38 | DigitalOut CS(p8); |
el13tjoc | 0:39399720eaeb | 39 | /** |
el13tjoc | 0:39399720eaeb | 40 | @namespace buttonA |
el13tjoc | 0:39399720eaeb | 41 | @brief GPIO input for button A |
el13tjoc | 0:39399720eaeb | 42 | */ |
el13tjoc | 0:39399720eaeb | 43 | /** |
el13tjoc | 0:39399720eaeb | 44 | @namespace buttonB |
el13tjoc | 0:39399720eaeb | 45 | @brief GPIO input for button B |
el13tjoc | 0:39399720eaeb | 46 | */ |
el13tjoc | 0:39399720eaeb | 47 | /** |
el13tjoc | 0:39399720eaeb | 48 | @namespace buttonC |
el13tjoc | 0:39399720eaeb | 49 | @brief GPIO input for button C |
el13tjoc | 0:39399720eaeb | 50 | */ |
el13tjoc | 0:39399720eaeb | 51 | /** |
el13tjoc | 0:39399720eaeb | 52 | @namespace buttonD |
el13tjoc | 0:39399720eaeb | 53 | @brief GPIO input for button D |
el13tjoc | 0:39399720eaeb | 54 | */ |
el13tjoc | 0:39399720eaeb | 55 | PinDetect buttonA(p15), buttonB(p16), buttonC(p17), buttonD(p18); //Use PinDetect for debounced interupts |
el13tjoc | 0:39399720eaeb | 56 | /** |
el13tjoc | 0:39399720eaeb | 57 | @namespace lcd |
el13tjoc | 0:39399720eaeb | 58 | @brief N5110 LCD screen setup |
el13tjoc | 0:39399720eaeb | 59 | */ |
el13tjoc | 0:39399720eaeb | 60 | N5110 lcd(p14,p9,p10,p11,p13,p21); |
el13tjoc | 0:39399720eaeb | 61 | /** |
el13tjoc | 0:39399720eaeb | 62 | @namespace midi |
el13tjoc | 0:39399720eaeb | 63 | @brief USBMIDI object for MIDI send/receive |
el13tjoc | 0:39399720eaeb | 64 | */ |
el13tjoc | 0:39399720eaeb | 65 | USBMIDI midi; |
el13tjoc | 0:39399720eaeb | 66 | /** |
el13tjoc | 0:39399720eaeb | 67 | @namespace startRangingTicker |
el13tjoc | 0:39399720eaeb | 68 | @brief Ticker object to start the SRF08 ranging at regular intervals |
el13tjoc | 0:39399720eaeb | 69 | */ |
el13tjoc | 0:39399720eaeb | 70 | Ticker startRangingTicker; |
el13tjoc | 0:39399720eaeb | 71 | /** |
el13tjoc | 0:39399720eaeb | 72 | @namespace getRangeTimeout |
el13tjoc | 0:39399720eaeb | 73 | @brief Timeout object to read the SRF08 range after a set interval |
el13tjoc | 0:39399720eaeb | 74 | */ |
el13tjoc | 0:39399720eaeb | 75 | Timeout getRangeTimeout; |
el13tjoc | 0:39399720eaeb | 76 | /** |
el13tjoc | 0:39399720eaeb | 77 | @namespace local |
el13tjoc | 0:39399720eaeb | 78 | @brief Setup the local file system |
el13tjoc | 0:39399720eaeb | 79 | */ |
el13tjoc | 0:39399720eaeb | 80 | LocalFileSystem local("local"); |
el13tjoc | 0:39399720eaeb | 81 | |
el13tjoc | 0:39399720eaeb | 82 | unsigned char imgbuffer[3*84*48]; /*!< Stores the pixel data from the buttons.bmp image */ |
el13tjoc | 0:39399720eaeb | 83 | FILE *img; /*!< Stores the the buttons.bmp image */ |
el13tjoc | 0:39399720eaeb | 84 | vector<float> smoothingValues; /*!< Stores previous distance fractions */ |
el13tjoc | 0:39399720eaeb | 85 | int oldValue; /*!< Parameter value stored when entering a parameter editing screen */ |
el13tjoc | 0:39399720eaeb | 86 | int measuredDistance; /*!< Distance read from the SRF08 in CM */ |
el13tjoc | 0:39399720eaeb | 87 | float distanceFraction; /*!< Fraction representing distance between minDistance and maxDistance */ |
el13tjoc | 0:39399720eaeb | 88 | int receivedMIDIValue; /*!< Control change value read in through USB MIDI port */ |
el13tjoc | 0:39399720eaeb | 89 | string valueLists[1][3] = {{"Sensor","MIDI","None"}}; /*!< Stores list type value contents */ |
el13tjoc | 0:39399720eaeb | 90 | int maxNumberValues[6] = {10000, 3, 6000, 8, 15, 127}; /*!< Defines limits for number type values */ |
el13tjoc | 0:39399720eaeb | 91 | int numberValues[11]; /*!< Stores number type values */ |
el13tjoc | 0:39399720eaeb | 92 | int increment; /*!< Set to '1' or '-1' depending the on corresponding button press.*/ |
el13tjoc | 0:39399720eaeb | 93 | int valLen; /*!< The length of the string containing the parameter value */ |
el13tjoc | 0:39399720eaeb | 94 | int maxValLen; /*!< The length of the string containing the value limit */ |
el13tjoc | 0:39399720eaeb | 95 | int state = 0; /*!< Finite state machine state */ |
el13tjoc | 0:39399720eaeb | 96 | int menuArrowPosition = 0; /*!< Selection arrow pointer for menu system */ |
el13tjoc | 0:39399720eaeb | 97 | int digitArrowPosition = 0; /*!< Selection arrow pointer for digit increment/decrement */ |
el13tjoc | 0:39399720eaeb | 98 | int aButtonFlag = 0; /*!< Flag when button A is pressed */ |
el13tjoc | 0:39399720eaeb | 99 | int bButtonFlag = 0; /*!< Flag when button B is pressed */ |
el13tjoc | 0:39399720eaeb | 100 | int cButtonFlag = 0; /*!< Flag when button C is pressed */ |
el13tjoc | 0:39399720eaeb | 101 | int dButtonFlag = 0; /*!< Flag when button D is pressed */ |
el13tjoc | 0:39399720eaeb | 102 | int rangingStartFlag = 0; /*!< Flag when startRangingTicker triggers */ |
el13tjoc | 0:39399720eaeb | 103 | int rangeGetFlag = 0; /*!< Flag when getRangeTimeout triggers */ |
el13tjoc | 0:39399720eaeb | 104 | int receivedMIDIFlag = 0; /*!< Flag when MIDI message is received for the correct control change and channel */ |
el13tjoc | 0:39399720eaeb | 105 | int measuredDistanceFlag = 0; /*!< Flag when a distance measurement is made */ |
el13tjoc | 0:39399720eaeb | 106 | |
el13tjoc | 0:39399720eaeb | 107 | /** |
el13tjoc | 0:39399720eaeb | 108 | Reads numatic varaiables from the VALS.csv file |
el13tjoc | 0:39399720eaeb | 109 | */ |
el13tjoc | 0:39399720eaeb | 110 | void readNumberValuesFromFile(); |
el13tjoc | 0:39399720eaeb | 111 | /** |
el13tjoc | 0:39399720eaeb | 112 | Writes numatic varaiables to the VALS.csv file |
el13tjoc | 0:39399720eaeb | 113 | */ |
el13tjoc | 0:39399720eaeb | 114 | void writeNumberValuesToFile(); |
el13tjoc | 0:39399720eaeb | 115 | /** |
el13tjoc | 0:39399720eaeb | 116 | Raises startRangingFlag |
el13tjoc | 0:39399720eaeb | 117 | */ |
el13tjoc | 0:39399720eaeb | 118 | void startRangingFlag(); |
el13tjoc | 0:39399720eaeb | 119 | /** |
el13tjoc | 0:39399720eaeb | 120 | Raises getRangeFlags |
el13tjoc | 0:39399720eaeb | 121 | */ |
el13tjoc | 0:39399720eaeb | 122 | void getRangeFlag(); |
el13tjoc | 0:39399720eaeb | 123 | /** |
el13tjoc | 0:39399720eaeb | 124 | Starts the SRF08 ranging and attaches a ticker to read the range |
el13tjoc | 0:39399720eaeb | 125 | */ |
el13tjoc | 0:39399720eaeb | 126 | void rangingStart(); |
el13tjoc | 0:39399720eaeb | 127 | /** |
el13tjoc | 0:39399720eaeb | 128 | Converts the measured distance to a float between 0 and 1 |
el13tjoc | 0:39399720eaeb | 129 | */ |
el13tjoc | 0:39399720eaeb | 130 | void rangeGet(); |
el13tjoc | 0:39399720eaeb | 131 | /** |
el13tjoc | 0:39399720eaeb | 132 | * Returns the relevant parameter to its previous value if it is greater than its limit |
el13tjoc | 0:39399720eaeb | 133 | * |
el13tjoc | 0:39399720eaeb | 134 | * Ensures the minimum distance is less than the maximum distance |
el13tjoc | 0:39399720eaeb | 135 | * |
el13tjoc | 0:39399720eaeb | 136 | * Ensures the minimum resistance is less than the maximum resistance |
el13tjoc | 0:39399720eaeb | 137 | */ |
el13tjoc | 0:39399720eaeb | 138 | void checkValidity(); |
el13tjoc | 0:39399720eaeb | 139 | /** |
el13tjoc | 0:39399720eaeb | 140 | Sets the range of the SRF08 and resises the smoothing values vector |
el13tjoc | 0:39399720eaeb | 141 | */ |
el13tjoc | 0:39399720eaeb | 142 | void immediateUpdates(); |
el13tjoc | 0:39399720eaeb | 143 | /** |
el13tjoc | 0:39399720eaeb | 144 | Converts a float between 0 and 1 to an integer between 0 and 255 before writing it to the MCP4151 digital potentiometer |
el13tjoc | 0:39399720eaeb | 145 | @param value - float between 0 and 1 |
el13tjoc | 0:39399720eaeb | 146 | */ |
el13tjoc | 0:39399720eaeb | 147 | void writeMCP4151(float value); |
el13tjoc | 0:39399720eaeb | 148 | /** |
el13tjoc | 0:39399720eaeb | 149 | * Converts a float between 0 and 1 to an integer between 0 and 127 |
el13tjoc | 0:39399720eaeb | 150 | * |
el13tjoc | 0:39399720eaeb | 151 | * Sends control change MIDI message |
el13tjoc | 0:39399720eaeb | 152 | @param value - float between 0 and 1 |
el13tjoc | 0:39399720eaeb | 153 | */ |
el13tjoc | 0:39399720eaeb | 154 | void writeMIDI(float value); |
el13tjoc | 0:39399720eaeb | 155 | /** |
el13tjoc | 0:39399720eaeb | 156 | * Catches MIDI input messages and stores them if they match the input control change and input channel |
el13tjoc | 0:39399720eaeb | 157 | * |
el13tjoc | 0:39399720eaeb | 158 | * Raises receivedMIDIFlag |
el13tjoc | 0:39399720eaeb | 159 | @param value - float between 0 and 1 |
el13tjoc | 0:39399720eaeb | 160 | */ |
el13tjoc | 0:39399720eaeb | 161 | void receivedMIDI(MIDIMessage); |
el13tjoc | 0:39399720eaeb | 162 | /** |
el13tjoc | 0:39399720eaeb | 163 | * Stores previous distance fractions for average smoothing |
el13tjoc | 0:39399720eaeb | 164 | @param value - float between 0 and 1 |
el13tjoc | 0:39399720eaeb | 165 | @returns smoothed distance fraction |
el13tjoc | 0:39399720eaeb | 166 | */ |
el13tjoc | 0:39399720eaeb | 167 | float smooth(float value); |
el13tjoc | 0:39399720eaeb | 168 | /** |
el13tjoc | 0:39399720eaeb | 169 | Raises aButtonFlag |
el13tjoc | 0:39399720eaeb | 170 | */ |
el13tjoc | 0:39399720eaeb | 171 | |
el13tjoc | 0:39399720eaeb | 172 | void aPressed(); |
el13tjoc | 0:39399720eaeb | 173 | /** |
el13tjoc | 0:39399720eaeb | 174 | Raises bButtonFlag |
el13tjoc | 0:39399720eaeb | 175 | */ |
el13tjoc | 0:39399720eaeb | 176 | void bPressed(); |
el13tjoc | 0:39399720eaeb | 177 | /** |
el13tjoc | 0:39399720eaeb | 178 | Raises cButtonFlag |
el13tjoc | 0:39399720eaeb | 179 | */ |
el13tjoc | 0:39399720eaeb | 180 | void cPressed(); |
el13tjoc | 0:39399720eaeb | 181 | /** |
el13tjoc | 0:39399720eaeb | 182 | Raises dButtonFlag |
el13tjoc | 0:39399720eaeb | 183 | */ |
el13tjoc | 0:39399720eaeb | 184 | void dPressed(); |
el13tjoc | 0:39399720eaeb | 185 | /** |
el13tjoc | 0:39399720eaeb | 186 | * Saves the initial parameter to oldValue when entering a parameter editing page |
el13tjoc | 0:39399720eaeb | 187 | * |
el13tjoc | 0:39399720eaeb | 188 | * Calls checkValidity(), writeNumberValuesToFile() and immediateUpdates() before leaving a parameter editing page |
el13tjoc | 0:39399720eaeb | 189 | * |
el13tjoc | 0:39399720eaeb | 190 | * Changes the FSM state |
el13tjoc | 0:39399720eaeb | 191 | * |
el13tjoc | 0:39399720eaeb | 192 | * Resets menu and digit pointer positions |
el13tjoc | 0:39399720eaeb | 193 | * |
el13tjoc | 0:39399720eaeb | 194 | * calls showScreen() |
el13tjoc | 0:39399720eaeb | 195 | */ |
el13tjoc | 0:39399720eaeb | 196 | void screenSelect(); |
el13tjoc | 0:39399720eaeb | 197 | /** |
el13tjoc | 0:39399720eaeb | 198 | * Revets relevant parameter to oldValue if leaving a parameter editing page |
el13tjoc | 0:39399720eaeb | 199 | * |
el13tjoc | 0:39399720eaeb | 200 | * Changes the FSM state |
el13tjoc | 0:39399720eaeb | 201 | * |
el13tjoc | 0:39399720eaeb | 202 | * Resets menu and digit pointer positions |
el13tjoc | 0:39399720eaeb | 203 | * |
el13tjoc | 0:39399720eaeb | 204 | * calls showScreen() |
el13tjoc | 0:39399720eaeb | 205 | */ |
el13tjoc | 0:39399720eaeb | 206 | void screenBack(); |
el13tjoc | 0:39399720eaeb | 207 | /** |
el13tjoc | 0:39399720eaeb | 208 | moves the menu pointer position up |
el13tjoc | 0:39399720eaeb | 209 | calls showScreen() |
el13tjoc | 0:39399720eaeb | 210 | */ |
el13tjoc | 0:39399720eaeb | 211 | void menuUp(); |
el13tjoc | 0:39399720eaeb | 212 | /** |
el13tjoc | 0:39399720eaeb | 213 | moves the menu pointer position down |
el13tjoc | 0:39399720eaeb | 214 | calls showScreen() |
el13tjoc | 0:39399720eaeb | 215 | */ |
el13tjoc | 0:39399720eaeb | 216 | void menuDown(); |
el13tjoc | 0:39399720eaeb | 217 | /** |
el13tjoc | 0:39399720eaeb | 218 | moves the digit pointer position right |
el13tjoc | 0:39399720eaeb | 219 | calls showScreen() |
el13tjoc | 0:39399720eaeb | 220 | */ |
el13tjoc | 0:39399720eaeb | 221 | void incrementDigitArrowPos(); |
el13tjoc | 0:39399720eaeb | 222 | /** |
el13tjoc | 0:39399720eaeb | 223 | moves the digit pointer position left |
el13tjoc | 0:39399720eaeb | 224 | calls showScreen() |
el13tjoc | 0:39399720eaeb | 225 | */ |
el13tjoc | 0:39399720eaeb | 226 | void decrementDigitArrowPos(); |
el13tjoc | 0:39399720eaeb | 227 | /** |
el13tjoc | 0:39399720eaeb | 228 | Makes the increment variable equal 1 |
el13tjoc | 0:39399720eaeb | 229 | calls amendValue() |
el13tjoc | 0:39399720eaeb | 230 | */ |
el13tjoc | 0:39399720eaeb | 231 | void incrementValue(); |
el13tjoc | 0:39399720eaeb | 232 | /** |
el13tjoc | 0:39399720eaeb | 233 | Makes the increment variable equal -1 |
el13tjoc | 0:39399720eaeb | 234 | calls amendValue() |
el13tjoc | 0:39399720eaeb | 235 | */ |
el13tjoc | 0:39399720eaeb | 236 | void decrementValue(); |
el13tjoc | 0:39399720eaeb | 237 | /** |
el13tjoc | 0:39399720eaeb | 238 | Increments or decrements the relevant parameter based on its how it is used and the increment value. |
el13tjoc | 0:39399720eaeb | 239 | */ |
el13tjoc | 0:39399720eaeb | 240 | void amendValue(); |
el13tjoc | 0:39399720eaeb | 241 | /** |
el13tjoc | 0:39399720eaeb | 242 | Increments or decrements the digit pointed to by the digit pointer |
el13tjoc | 0:39399720eaeb | 243 | @param value - Integer to be incremented / decremented |
el13tjoc | 0:39399720eaeb | 244 | @returns incremented / decremented integer |
el13tjoc | 0:39399720eaeb | 245 | */ |
el13tjoc | 0:39399720eaeb | 246 | int amendNumberValue(int value); |
el13tjoc | 0:39399720eaeb | 247 | /** |
el13tjoc | 0:39399720eaeb | 248 | Displays numeric values and fills unused digit spaces with zeros |
el13tjoc | 0:39399720eaeb | 249 | @param value - Integer to be displayed |
el13tjoc | 0:39399720eaeb | 250 | @param maxValue - Maximum value the integer can be |
el13tjoc | 0:39399720eaeb | 251 | */ |
el13tjoc | 0:39399720eaeb | 252 | void displayNumber(int value, int maxValue); |
el13tjoc | 0:39399720eaeb | 253 | /** |
el13tjoc | 0:39399720eaeb | 254 | Displays values from a list |
el13tjoc | 0:39399720eaeb | 255 | @param list[] - The array storing the list items |
el13tjoc | 0:39399720eaeb | 256 | @param listIndex - The index of the list item to be displayed |
el13tjoc | 0:39399720eaeb | 257 | */ |
el13tjoc | 0:39399720eaeb | 258 | void displayList(string list[], int listIndex); |
el13tjoc | 0:39399720eaeb | 259 | /** |
el13tjoc | 0:39399720eaeb | 260 | Displays boolean type values |
el13tjoc | 0:39399720eaeb | 261 | @param toggle - The boolean type value to be displayed |
el13tjoc | 0:39399720eaeb | 262 | */ |
el13tjoc | 0:39399720eaeb | 263 | void displayBool(bool toggle); |
el13tjoc | 0:39399720eaeb | 264 | /** |
el13tjoc | 0:39399720eaeb | 265 | Displays the incoming SRF08 distance, the MIDI input value, the MIDI output value and the resistance output value |
el13tjoc | 0:39399720eaeb | 266 | */ |
el13tjoc | 0:39399720eaeb | 267 | void displayMeasured(); |
el13tjoc | 0:39399720eaeb | 268 | /** |
el13tjoc | 0:39399720eaeb | 269 | * Clears the display |
el13tjoc | 0:39399720eaeb | 270 | * |
el13tjoc | 0:39399720eaeb | 271 | * Prints the title |
el13tjoc | 0:39399720eaeb | 272 | * |
el13tjoc | 0:39399720eaeb | 273 | * Prints menu items if the state is a menu screen |
el13tjoc | 0:39399720eaeb | 274 | * |
el13tjoc | 0:39399720eaeb | 275 | * Calls displayNumber(), displayList() or displayBool() if the state is a parameter screen |
el13tjoc | 0:39399720eaeb | 276 | * |
el13tjoc | 0:39399720eaeb | 277 | * Calls displayMeasured() if the state is the measurements display screen |
el13tjoc | 0:39399720eaeb | 278 | * |
el13tjoc | 0:39399720eaeb | 279 | * Calls drawBMP() |
el13tjoc | 0:39399720eaeb | 280 | */ |
el13tjoc | 0:39399720eaeb | 281 | void showScreen(); |
el13tjoc | 0:39399720eaeb | 282 | /** |
el13tjoc | 0:39399720eaeb | 283 | Draws the image buffer to the screen |
el13tjoc | 0:39399720eaeb | 284 | */ |
el13tjoc | 0:39399720eaeb | 285 | void drawBMP(); |
el13tjoc | 0:39399720eaeb | 286 | |
el13tjoc | 0:39399720eaeb | 287 | enum {INT, INDEX, BOOL}; |
el13tjoc | 0:39399720eaeb | 288 | |
el13tjoc | 0:39399720eaeb | 289 | /** |
el13tjoc | 0:39399720eaeb | 290 | Defines the FSM state parameters |
el13tjoc | 0:39399720eaeb | 291 | */ |
el13tjoc | 0:39399720eaeb | 292 | struct State { |
el13tjoc | 0:39399720eaeb | 293 | char *title; /*!< Menu title*/ |
el13tjoc | 0:39399720eaeb | 294 | char *list[4]; /*!< Menu options list*/ |
el13tjoc | 0:39399720eaeb | 295 | int listLength; /*!< Menu options list length*/ |
el13tjoc | 0:39399720eaeb | 296 | int previousState; /*!< Previous FSM state*/ |
el13tjoc | 0:39399720eaeb | 297 | int nextState[4]; /*!< Next FSM states*/ |
el13tjoc | 0:39399720eaeb | 298 | int screenType; /*!< Type of screen*/ |
el13tjoc | 0:39399720eaeb | 299 | |
el13tjoc | 0:39399720eaeb | 300 | int associatedValueType; /*!< Usage type of the parameter associated with parameter editing page*/ |
el13tjoc | 0:39399720eaeb | 301 | int associatedValueIndex; /*!< Index of parameter associated with certain parameter editing pages*/ |
el13tjoc | 0:39399720eaeb | 302 | int associatedMaxValueIndex; /*!< Index of parameter limit associated with certain parameter editing pages*/ |
el13tjoc | 0:39399720eaeb | 303 | int associatedValueList; /*!< List associated with certain parameter editing pages*/ |
el13tjoc | 0:39399720eaeb | 304 | }; |
el13tjoc | 0:39399720eaeb | 305 | typedef const struct State Menu; |
el13tjoc | 0:39399720eaeb | 306 | |
el13tjoc | 0:39399720eaeb | 307 | enum {menuType, pageType, displayType}; |
el13tjoc | 0:39399720eaeb | 308 | enum {resistanceLimit, resistanceSourceIndexLimit, distanceLimit, distanceSmoothingLimit, MIDIChannelLimit, MIDIControllerLimit}; |
el13tjoc | 0:39399720eaeb | 309 | enum {resistanceSource}; |
el13tjoc | 0:39399720eaeb | 310 | enum {sensorSource, MIDISource, noSource}; |
el13tjoc | 0:39399720eaeb | 311 | enum { |
el13tjoc | 0:39399720eaeb | 312 | mainMenu, |
el13tjoc | 0:39399720eaeb | 313 | resistanceMenu, |
el13tjoc | 0:39399720eaeb | 314 | distanceMenu, |
el13tjoc | 0:39399720eaeb | 315 | MIDIMenu, |
el13tjoc | 0:39399720eaeb | 316 | displayPage, |
el13tjoc | 0:39399720eaeb | 317 | maxResistancePage, |
el13tjoc | 0:39399720eaeb | 318 | minResistancePage, |
el13tjoc | 0:39399720eaeb | 319 | resistanceSourcePage, |
el13tjoc | 0:39399720eaeb | 320 | maxDistancePage, |
el13tjoc | 0:39399720eaeb | 321 | minDistancePage, |
el13tjoc | 0:39399720eaeb | 322 | distanceSmoothingPage, |
el13tjoc | 0:39399720eaeb | 323 | MIDIInputMenu, |
el13tjoc | 0:39399720eaeb | 324 | MIDIOutputMenu, |
el13tjoc | 0:39399720eaeb | 325 | MIDIInputChannelPage, |
el13tjoc | 0:39399720eaeb | 326 | MIDIInputControllerPage, |
el13tjoc | 0:39399720eaeb | 327 | MIDIOutputChannelPage, |
el13tjoc | 0:39399720eaeb | 328 | MIDIOutputControllerPage, |
el13tjoc | 0:39399720eaeb | 329 | MIDIOutputOnPage |
el13tjoc | 0:39399720eaeb | 330 | }; |
el13tjoc | 0:39399720eaeb | 331 | enum { |
el13tjoc | 0:39399720eaeb | 332 | maxResistance, |
el13tjoc | 0:39399720eaeb | 333 | minResistance, |
el13tjoc | 0:39399720eaeb | 334 | resistanceSourceIndex, |
el13tjoc | 0:39399720eaeb | 335 | maxDistance, |
el13tjoc | 0:39399720eaeb | 336 | minDistance, |
el13tjoc | 0:39399720eaeb | 337 | distanceSmoothing, |
el13tjoc | 0:39399720eaeb | 338 | MIDIInputChannel, |
el13tjoc | 0:39399720eaeb | 339 | MIDIInputController, |
el13tjoc | 0:39399720eaeb | 340 | MIDIOutputChannel, |
el13tjoc | 0:39399720eaeb | 341 | MIDIOutputController, |
el13tjoc | 0:39399720eaeb | 342 | MIDIOutputOn |
el13tjoc | 0:39399720eaeb | 343 | }; |
el13tjoc | 0:39399720eaeb | 344 | |
el13tjoc | 0:39399720eaeb | 345 | |
el13tjoc | 0:39399720eaeb | 346 | Menu menu[23] = { |
el13tjoc | 0:39399720eaeb | 347 | {"MAIN MENU",{"Resistance", "Distance", "MIDI", "Display"},4,mainMenu,{resistanceMenu,distanceMenu,MIDIMenu,displayPage},menuType,NULL,NULL,NULL,NULL}, |
el13tjoc | 0:39399720eaeb | 348 | |
el13tjoc | 0:39399720eaeb | 349 | {"RESISTANCE",{"Maximum", "Minimum", "Source", ""},3,mainMenu,{maxResistancePage,minResistancePage,resistanceSourcePage,NULL},menuType,NULL,NULL,NULL,NULL}, |
el13tjoc | 0:39399720eaeb | 350 | {"DISTANCE",{"Maximum", "Minimum", "Smoothing", ""},3,mainMenu,{maxDistancePage,minDistancePage,distanceSmoothingPage,NULL},menuType,NULL,NULL,NULL,NULL}, |
el13tjoc | 0:39399720eaeb | 351 | {"MIDI",{"Input", "Output", "", ""},2,mainMenu,{MIDIInputMenu,MIDIOutputMenu,0,0},menuType,NULL,NULL,NULL,NULL}, |
el13tjoc | 0:39399720eaeb | 352 | {"DISPLAY",{"", "", "", ""},NULL,mainMenu,{mainMenu,NULL,NULL,NULL},displayType,NULL,NULL,NULL,NULL}, |
el13tjoc | 0:39399720eaeb | 353 | |
el13tjoc | 0:39399720eaeb | 354 | {"MAXIMUM (OHM)",{"", "", "", ""},NULL,resistanceMenu,{resistanceMenu,NULL,NULL,NULL},pageType,INT,maxResistance,resistanceLimit,NULL}, //Maximum Resistance |
el13tjoc | 0:39399720eaeb | 355 | {"MINIMUM (OHM)",{"", "", "", ""},NULL,resistanceMenu,{resistanceMenu,NULL,NULL,NULL},pageType,INT,minResistance,resistanceLimit,NULL}, //Minimum Resistance |
el13tjoc | 0:39399720eaeb | 356 | {"SOURCE",{"", "", "", ""},NULL,resistanceMenu,{resistanceMenu,NULL,NULL,NULL},pageType,INDEX,resistanceSourceIndex,resistanceSourceIndexLimit,NULL}, //Resistance input source |
el13tjoc | 0:39399720eaeb | 357 | |
el13tjoc | 0:39399720eaeb | 358 | {"MAXIMUM (mm)",{"", "", "", ""},NULL,distanceMenu,{distanceMenu,NULL,NULL,NULL},pageType,INT,maxDistance,distanceLimit,NULL}, |
el13tjoc | 0:39399720eaeb | 359 | {"MINIMUM (mm)",{"", "", "", ""},NULL,distanceMenu,{distanceMenu,NULL,NULL,NULL},pageType,INT,minDistance,distanceLimit,NULL}, |
el13tjoc | 0:39399720eaeb | 360 | {"SMOOTHING",{"", "", "", ""},NULL,distanceMenu,{distanceMenu,NULL,NULL,NULL},pageType,INT,distanceSmoothing,distanceSmoothingLimit,NULL}, |
el13tjoc | 0:39399720eaeb | 361 | |
el13tjoc | 0:39399720eaeb | 362 | {"INPUT",{"Channel", "Controller", "", ""},2,MIDIMenu,{MIDIInputChannelPage,MIDIInputControllerPage,NULL,NULL},menuType,NULL,NULL,NULL,NULL}, //12 |
el13tjoc | 0:39399720eaeb | 363 | {"OUTPUT",{"Channel", "Controller", "On/Off", ""},3,MIDIMenu,{MIDIOutputChannelPage,MIDIOutputControllerPage,MIDIOutputOnPage,NULL},menuType,NULL,NULL,NULL,NULL}, //12 |
el13tjoc | 0:39399720eaeb | 364 | |
el13tjoc | 0:39399720eaeb | 365 | {"CHANNEL",{"", "", "", ""},NULL,MIDIInputMenu,{MIDIInputMenu,NULL,NULL,NULL},pageType,INT,MIDIInputChannel,MIDIChannelLimit,NULL}, |
el13tjoc | 0:39399720eaeb | 366 | {"CONTROLLER",{"", "", "", ""},NULL,MIDIInputMenu,{MIDIInputMenu,NULL,NULL,NULL},pageType,INT,MIDIInputController,MIDIControllerLimit,NULL}, |
el13tjoc | 0:39399720eaeb | 367 | |
el13tjoc | 0:39399720eaeb | 368 | {"CHANNEL",{"", "", "", ""},NULL,MIDIOutputMenu,{MIDIOutputMenu,NULL,NULL,NULL},pageType,INT,MIDIOutputChannel,MIDIChannelLimit,NULL}, |
el13tjoc | 0:39399720eaeb | 369 | {"CONTROLLER",{"", "", "", ""},NULL,MIDIOutputMenu,{MIDIOutputMenu,NULL,NULL,NULL},pageType,INT,MIDIOutputController,MIDIControllerLimit,NULL}, |
el13tjoc | 0:39399720eaeb | 370 | {"ON/OFF",{"", "", "", ""},NULL,MIDIOutputMenu,{MIDIOutputMenu,NULL,NULL,NULL},pageType,BOOL,MIDIOutputOn,NULL,NULL}, |
el13tjoc | 0:39399720eaeb | 371 | }; /*!< Finite state machine */ |
el13tjoc | 0:39399720eaeb | 372 | |
el13tjoc | 0:39399720eaeb | 373 | #endif |