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