Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of SolarNanoGridv3 by
Hmi/Hmi.h@11:87ab310924f0, 2016-06-08 (annotated)
- Committer:
- epgmdm
- Date:
- Wed Jun 08 22:12:52 2016 +0000
- Revision:
- 11:87ab310924f0
- Child:
- 13:de43f28c0365
Utility up
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
epgmdm | 11:87ab310924f0 | 1 | /** |
epgmdm | 11:87ab310924f0 | 2 | *@section DESCRIPTION |
epgmdm | 11:87ab310924f0 | 3 | * mbed SolarNanogrid Library |
epgmdm | 11:87ab310924f0 | 4 | * Hmi extends SolarNanoGrid. |
epgmdm | 11:87ab310924f0 | 5 | * Hmi does the human interface and talks to the lockers. |
epgmdm | 11:87ab310924f0 | 6 | * The ID must be in FF 00. |
epgmdm | 11:87ab310924f0 | 7 | *@section LICENSE |
epgmdm | 11:87ab310924f0 | 8 | * Copyright (c) 2016, Malcolm McCulloch |
epgmdm | 11:87ab310924f0 | 9 | * |
epgmdm | 11:87ab310924f0 | 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
epgmdm | 11:87ab310924f0 | 11 | * of this software and associated documentation files (the "Software"), to deal |
epgmdm | 11:87ab310924f0 | 12 | * in the Software without restriction, including without limitation the rights |
epgmdm | 11:87ab310924f0 | 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
epgmdm | 11:87ab310924f0 | 14 | * copies of the Software, and to permit persons to whom the Software is |
epgmdm | 11:87ab310924f0 | 15 | * furnished to do so, subject to the following conditions: |
epgmdm | 11:87ab310924f0 | 16 | * |
epgmdm | 11:87ab310924f0 | 17 | * The above copyright notice and this permission notice shall be included in |
epgmdm | 11:87ab310924f0 | 18 | * all copies or substantial portions of the Software. |
epgmdm | 11:87ab310924f0 | 19 | * |
epgmdm | 11:87ab310924f0 | 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
epgmdm | 11:87ab310924f0 | 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
epgmdm | 11:87ab310924f0 | 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
epgmdm | 11:87ab310924f0 | 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
epgmdm | 11:87ab310924f0 | 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
epgmdm | 11:87ab310924f0 | 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
epgmdm | 11:87ab310924f0 | 26 | * THE SOFTWARE. |
epgmdm | 11:87ab310924f0 | 27 | * @file "Hmi.h" |
epgmdm | 11:87ab310924f0 | 28 | */ |
epgmdm | 11:87ab310924f0 | 29 | |
epgmdm | 11:87ab310924f0 | 30 | //#ifndef HMI_H |
epgmdm | 11:87ab310924f0 | 31 | //#define HMI_H |
epgmdm | 11:87ab310924f0 | 32 | #include "mbed.h" |
epgmdm | 11:87ab310924f0 | 33 | //#include "NRF2401P.h" |
epgmdm | 11:87ab310924f0 | 34 | //#include "nRF24l01.h" |
epgmdm | 11:87ab310924f0 | 35 | #include "MFRC522.h" |
epgmdm | 11:87ab310924f0 | 36 | #include "SPI_TFT_ILI9341.h" |
epgmdm | 11:87ab310924f0 | 37 | #include "Arial24x23.h" |
epgmdm | 11:87ab310924f0 | 38 | //#include "SDFileSystem.h" |
epgmdm | 11:87ab310924f0 | 39 | #include "HubUser.h" |
epgmdm | 11:87ab310924f0 | 40 | #include "HubLogging.h" |
epgmdm | 11:87ab310924f0 | 41 | #include "SolarNanoGrid.h" |
epgmdm | 11:87ab310924f0 | 42 | |
epgmdm | 11:87ab310924f0 | 43 | #define FUNCNAME "HMI" |
epgmdm | 11:87ab310924f0 | 44 | #include "defs.h" |
epgmdm | 11:87ab310924f0 | 45 | |
epgmdm | 11:87ab310924f0 | 46 | |
epgmdm | 11:87ab310924f0 | 47 | /** \brief Hmi manages the human interface and talks to the lockers. |
epgmdm | 11:87ab310924f0 | 48 | * |
epgmdm | 11:87ab310924f0 | 49 | * ## Config file |
epgmdm | 11:87ab310924f0 | 50 | * The config.ini must start with H |
epgmdm | 11:87ab310924f0 | 51 | * poshoInit.txt |
epgmdm | 11:87ab310924f0 | 52 | * |
epgmdm | 11:87ab310924f0 | 53 | * ## Hardware |
epgmdm | 11:87ab310924f0 | 54 | * ### Buttons |
epgmdm | 11:87ab310924f0 | 55 | * - Button one interrupt (PTC3) |
epgmdm | 11:87ab310924f0 | 56 | * - Button two interrupt (PTC2) |
epgmdm | 11:87ab310924f0 | 57 | * - Button three interrupt (PTA2) |
epgmdm | 11:87ab310924f0 | 58 | * - Button four interrupt (PTB23) |
epgmdm | 11:87ab310924f0 | 59 | * |
epgmdm | 11:87ab310924f0 | 60 | * ### RFID (SPI_MOSI, SPI_MISO, SPI_SCLK, SPI_CS, MF_RESET) |
epgmdm | 11:87ab310924f0 | 61 | * - Battery reader : (PTD2, PTD3, PTD1, PTB2, PTB3) |
epgmdm | 11:87ab310924f0 | 62 | * - Posho reader : (PTD2, PTD3, PTD1, PTB10, PTB11); |
epgmdm | 11:87ab310924f0 | 63 | * - Incubator : (PTD2, PTD3, PTD1, PTC11, PTC10) |
epgmdm | 11:87ab310924f0 | 64 | * |
epgmdm | 11:87ab310924f0 | 65 | * ### Screen SPI_TFT_ILI9341 |
epgmdm | 11:87ab310924f0 | 66 | * - (PTD2, PTD3, PTD1, PTE25, PTB20, PTB18,"TFT") |
epgmdm | 11:87ab310924f0 | 67 | * |
epgmdm | 11:87ab310924f0 | 68 | */ |
epgmdm | 11:87ab310924f0 | 69 | class Hmi : public SolarNanoGrid |
epgmdm | 11:87ab310924f0 | 70 | { |
epgmdm | 11:87ab310924f0 | 71 | public: |
epgmdm | 11:87ab310924f0 | 72 | |
epgmdm | 11:87ab310924f0 | 73 | // ********************* |
epgmdm | 11:87ab310924f0 | 74 | // * Public variables: * |
epgmdm | 11:87ab310924f0 | 75 | // ********************* |
epgmdm | 11:87ab310924f0 | 76 | |
epgmdm | 11:87ab310924f0 | 77 | |
epgmdm | 11:87ab310924f0 | 78 | // ********************* |
epgmdm | 11:87ab310924f0 | 79 | // * Public functions: * |
epgmdm | 11:87ab310924f0 | 80 | // ********************* |
epgmdm | 11:87ab310924f0 | 81 | /** |
epgmdm | 11:87ab310924f0 | 82 | * Constructor |
epgmdm | 11:87ab310924f0 | 83 | * param: fp is the link to the config file. |
epgmdm | 11:87ab310924f0 | 84 | */ |
epgmdm | 11:87ab310924f0 | 85 | Hmi(FILE* fp, Serial *pc); |
epgmdm | 11:87ab310924f0 | 86 | /** |
epgmdm | 11:87ab310924f0 | 87 | * Loops through slow routines |
epgmdm | 11:87ab310924f0 | 88 | */ |
epgmdm | 11:87ab310924f0 | 89 | |
epgmdm | 11:87ab310924f0 | 90 | void loopHub(); |
epgmdm | 11:87ab310924f0 | 91 | |
epgmdm | 11:87ab310924f0 | 92 | |
epgmdm | 11:87ab310924f0 | 93 | |
epgmdm | 11:87ab310924f0 | 94 | protected: |
epgmdm | 11:87ab310924f0 | 95 | // ********************* |
epgmdm | 11:87ab310924f0 | 96 | // * Protected hardware: * |
epgmdm | 11:87ab310924f0 | 97 | // ********************* |
epgmdm | 11:87ab310924f0 | 98 | |
epgmdm | 11:87ab310924f0 | 99 | |
epgmdm | 11:87ab310924f0 | 100 | // RFID Readers MFRC522 RfChip (SPI_MOSI, SPI_MISO, SPI_SCLK, SPI_CS, MF_RESET); |
epgmdm | 11:87ab310924f0 | 101 | MFRC522 *BatteryRfChipH; /**< Battery Rfid */ |
epgmdm | 11:87ab310924f0 | 102 | MFRC522 *PoshoRfChipH; /**< Posho Rfid */ |
epgmdm | 11:87ab310924f0 | 103 | MFRC522 *IncubatorRfChipH; /**< Incubator Rfid */ |
epgmdm | 11:87ab310924f0 | 104 | |
epgmdm | 11:87ab310924f0 | 105 | InterruptIn *buttonOneH; /**< Button one interrupt (PTC3) */ |
epgmdm | 11:87ab310924f0 | 106 | InterruptIn *buttonTwoH; /**< Button two interrupt (PTC2)*/ |
epgmdm | 11:87ab310924f0 | 107 | InterruptIn *buttonThreeH; /**< Button three interrupt (PTA2) */ |
epgmdm | 11:87ab310924f0 | 108 | InterruptIn *buttonFourH; /**< Button four interrupt (PTB23)*/ |
epgmdm | 11:87ab310924f0 | 109 | |
epgmdm | 11:87ab310924f0 | 110 | |
epgmdm | 11:87ab310924f0 | 111 | SPI_TFT_ILI9341 *TFT_H; /**< LCD Display */ |
epgmdm | 11:87ab310924f0 | 112 | |
epgmdm | 11:87ab310924f0 | 113 | // Tickers |
epgmdm | 11:87ab310924f0 | 114 | Ticker *tick1sHub; /**< Every second time check */ |
epgmdm | 11:87ab310924f0 | 115 | Ticker *tickBatteryRfidH; /**< Battery Rfid check */ |
epgmdm | 11:87ab310924f0 | 116 | Ticker *tickIncubatorRfidH; /**< Incubator Rfid check */ |
epgmdm | 11:87ab310924f0 | 117 | Ticker *tickPoshoRfidH; /**< Posho Rfid check */ |
epgmdm | 11:87ab310924f0 | 118 | Ticker *tickTimeCheckH; /**< Time check for terminal display */ |
epgmdm | 11:87ab310924f0 | 119 | Ticker *tickerUpdateUserTableH; /**< Update user table to SD card ticker (every 30 min) */ |
epgmdm | 11:87ab310924f0 | 120 | |
epgmdm | 11:87ab310924f0 | 121 | // ********************* |
epgmdm | 11:87ab310924f0 | 122 | // * Protected flags: * |
epgmdm | 11:87ab310924f0 | 123 | // ********************* |
epgmdm | 11:87ab310924f0 | 124 | |
epgmdm | 11:87ab310924f0 | 125 | char flagBatteryRfidH; /**< Battery Rfid flag */ |
epgmdm | 11:87ab310924f0 | 126 | char flagButtonOneH; /**< Button one flag */ |
epgmdm | 11:87ab310924f0 | 127 | char flagButtonTwoH; /**< Button two flag */ |
epgmdm | 11:87ab310924f0 | 128 | char flagButtonThreeH; /**< Button three flag */ |
epgmdm | 11:87ab310924f0 | 129 | char flagButtonFourH; /**< Button four flag */ |
epgmdm | 11:87ab310924f0 | 130 | |
epgmdm | 11:87ab310924f0 | 131 | char flagPoshoRfidH; /**< Posho Rfid flag */ |
epgmdm | 11:87ab310924f0 | 132 | char flagIncubatorRfidH; /**< Incubator Rfid flag */ |
epgmdm | 11:87ab310924f0 | 133 | char flagTimeCheckH; /**< Time check flag */ |
epgmdm | 11:87ab310924f0 | 134 | char flagUpdateUserTableH; /**< Update user table to SD card ticker */ |
epgmdm | 11:87ab310924f0 | 135 | unsigned char flag1sH; /**< Every second flag */ |
epgmdm | 11:87ab310924f0 | 136 | |
epgmdm | 11:87ab310924f0 | 137 | //State |
epgmdm | 11:87ab310924f0 | 138 | /* |
epgmdm | 11:87ab310924f0 | 139 | * The hub display screen can involve multiple stages that are enumerated here. |
epgmdm | 11:87ab310924f0 | 140 | * All user action waiting stages also listen for the user selecting to cancel/exit |
epgmdm | 11:87ab310924f0 | 141 | */ |
epgmdm | 11:87ab310924f0 | 142 | enum HubScreenStageH { |
epgmdm | 11:87ab310924f0 | 143 | initialScanRfid, /**< Waiting for RFID with clearing and text display */ |
epgmdm | 11:87ab310924f0 | 144 | waitForRfid, /**< Listening for all interrupts */ |
epgmdm | 11:87ab310924f0 | 145 | batterySelectAction, /**< Listening for either battery drop off or pick up */ |
epgmdm | 11:87ab310924f0 | 146 | batterySelectNumberForPickup, /**< Listening for number of batteries to drop off */ |
epgmdm | 11:87ab310924f0 | 147 | batterySelectNumberForDropoff, /**< Listening for number of batteries to pick up */ |
epgmdm | 11:87ab310924f0 | 148 | poshoSelectKilograms /**< Listening for number of kgs of material to posho */ |
epgmdm | 11:87ab310924f0 | 149 | }; |
epgmdm | 11:87ab310924f0 | 150 | |
epgmdm | 11:87ab310924f0 | 151 | |
epgmdm | 11:87ab310924f0 | 152 | enum HubScreenStageH currentScreenH ; /**< Globally accessible screen selector */ |
epgmdm | 11:87ab310924f0 | 153 | |
epgmdm | 11:87ab310924f0 | 154 | // ********************* |
epgmdm | 11:87ab310924f0 | 155 | // * Protected variables: * |
epgmdm | 11:87ab310924f0 | 156 | // ********************* |
epgmdm | 11:87ab310924f0 | 157 | |
epgmdm | 11:87ab310924f0 | 158 | float currentMaxH; /**< Maximum current that each cube can consume. */ |
epgmdm | 11:87ab310924f0 | 159 | |
epgmdm | 11:87ab310924f0 | 160 | HubUser *allUsersH; /**< Array to be dynamically allocated storing all users */ |
epgmdm | 11:87ab310924f0 | 161 | int userCountH; /**< Number of active users on this hub mbed */ |
epgmdm | 11:87ab310924f0 | 162 | int currentUserH; /**< Index of the current user */ |
epgmdm | 11:87ab310924f0 | 163 | |
epgmdm | 11:87ab310924f0 | 164 | int poshoPricePerKgH; /**< price per kg of material to be used with the posho */ |
epgmdm | 11:87ab310924f0 | 165 | int timeForOneKgH; /**< time for one kg of material to be used with the posho */ |
epgmdm | 11:87ab310924f0 | 166 | int timeForTwoKgH; /**< time for two kg of material to be used with the posho */ |
epgmdm | 11:87ab310924f0 | 167 | int timeForThreeKgH; /**< time for three kg of material to be used with the posho */ |
epgmdm | 11:87ab310924f0 | 168 | |
epgmdm | 11:87ab310924f0 | 169 | Ticker tickPoshoInUseClearH; /**< ticker to clear posho in use flag after a specific time */ |
epgmdm | 11:87ab310924f0 | 170 | char flagPoshoAlreadyInUseH; |
epgmdm | 11:87ab310924f0 | 171 | |
epgmdm | 11:87ab310924f0 | 172 | long long baseAddr; /**< Base address of community to tell for pickup or drop off*/ |
epgmdm | 11:87ab310924f0 | 173 | long long lockerAddr; /**< Address of locker to transmit to tell for pickup or drop off*/ |
epgmdm | 11:87ab310924f0 | 174 | long long utilityAddr; /**< Address of locker to transmit to tell for pickup or drop off*/ |
epgmdm | 11:87ab310924f0 | 175 | |
epgmdm | 11:87ab310924f0 | 176 | // ********************* |
epgmdm | 11:87ab310924f0 | 177 | // * Protected functions: * |
epgmdm | 11:87ab310924f0 | 178 | // ********************* |
epgmdm | 11:87ab310924f0 | 179 | |
epgmdm | 11:87ab310924f0 | 180 | /** |
epgmdm | 11:87ab310924f0 | 181 | * Creates a new user by defining user attributes. |
epgmdm | 11:87ab310924f0 | 182 | * @param rfid - uint32_t corresponding to unique id of the RFID tag |
epgmdm | 11:87ab310924f0 | 183 | * @param accountCredit - int32 for user account balance (can be negative) |
epgmdm | 11:87ab310924f0 | 184 | * @param locker - int32_t for which locker (originaly 1-4) user is assigned |
epgmdm | 11:87ab310924f0 | 185 | * @param batterySubscription - int32_t max batteries user can get (can be 0) |
epgmdm | 11:87ab310924f0 | 186 | * @param batteriesOut - int32_t number of batteries user has out (usually 0 initially) |
epgmdm | 11:87ab310924f0 | 187 | * @param pod - int32_t pod associated with the user (originally 0-15) *must be 0 indexed* |
epgmdm | 11:87ab310924f0 | 188 | */ |
epgmdm | 11:87ab310924f0 | 189 | void createNewUserH(uint32_t rfid, int32_t accountCredit, int32_t locker, |
epgmdm | 11:87ab310924f0 | 190 | int32_t batterySubscription, int32_t batteriesOut, int32_t pod, char* name); |
epgmdm | 11:87ab310924f0 | 191 | /** |
epgmdm | 11:87ab310924f0 | 192 | * Initialize Global User Table Variable with malloc |
epgmdm | 11:87ab310924f0 | 193 | * @param users - int representing how many users you want the system to hold |
epgmdm | 11:87ab310924f0 | 194 | */ |
epgmdm | 11:87ab310924f0 | 195 | void initializeGlobalUserTableH(int users); |
epgmdm | 11:87ab310924f0 | 196 | /** |
epgmdm | 11:87ab310924f0 | 197 | * Initialize posho functionality |
epgmdm | 11:87ab310924f0 | 198 | */ |
epgmdm | 11:87ab310924f0 | 199 | void initializePoshoFunctionalityH(); |
epgmdm | 11:87ab310924f0 | 200 | /** |
epgmdm | 11:87ab310924f0 | 201 | * Initialize system with users from users.txt on SD card |
epgmdm | 11:87ab310924f0 | 202 | */ |
epgmdm | 11:87ab310924f0 | 203 | void initializeUsersFromSD_H(); |
epgmdm | 11:87ab310924f0 | 204 | |
epgmdm | 11:87ab310924f0 | 205 | |
epgmdm | 11:87ab310924f0 | 206 | /* ************************************************************************************************/ |
epgmdm | 11:87ab310924f0 | 207 | /* Set a flag when an interrupt is detected */ |
epgmdm | 11:87ab310924f0 | 208 | /* ************************************************************************************************/ |
epgmdm | 11:87ab310924f0 | 209 | |
epgmdm | 11:87ab310924f0 | 210 | /** |
epgmdm | 11:87ab310924f0 | 211 | * Time check interrupt |
epgmdm | 11:87ab310924f0 | 212 | */ |
epgmdm | 11:87ab310924f0 | 213 | void interruptTimeCheckH(); |
epgmdm | 11:87ab310924f0 | 214 | /** |
epgmdm | 11:87ab310924f0 | 215 | * Update user table interrupt |
epgmdm | 11:87ab310924f0 | 216 | */ |
epgmdm | 11:87ab310924f0 | 217 | void interruptUpdateUserTableH(); |
epgmdm | 11:87ab310924f0 | 218 | /** |
epgmdm | 11:87ab310924f0 | 219 | * Battery RFID reader interrupt |
epgmdm | 11:87ab310924f0 | 220 | */ |
epgmdm | 11:87ab310924f0 | 221 | void interruptBatteryRfidH(); |
epgmdm | 11:87ab310924f0 | 222 | /** |
epgmdm | 11:87ab310924f0 | 223 | * Posho RFID reader interrupt |
epgmdm | 11:87ab310924f0 | 224 | */ |
epgmdm | 11:87ab310924f0 | 225 | void interruptPoshoRfidH(); |
epgmdm | 11:87ab310924f0 | 226 | /** |
epgmdm | 11:87ab310924f0 | 227 | * Incubator RFID reader interrupt |
epgmdm | 11:87ab310924f0 | 228 | */ |
epgmdm | 11:87ab310924f0 | 229 | void interruptIncubatorRfidH(); |
epgmdm | 11:87ab310924f0 | 230 | /** |
epgmdm | 11:87ab310924f0 | 231 | * button one interrupt |
epgmdm | 11:87ab310924f0 | 232 | */ |
epgmdm | 11:87ab310924f0 | 233 | void interruptButtonOneH(); |
epgmdm | 11:87ab310924f0 | 234 | /** |
epgmdm | 11:87ab310924f0 | 235 | * button two interrupt |
epgmdm | 11:87ab310924f0 | 236 | */ |
epgmdm | 11:87ab310924f0 | 237 | void interruptButtonTwoH(); |
epgmdm | 11:87ab310924f0 | 238 | /** |
epgmdm | 11:87ab310924f0 | 239 | * button three interrupt |
epgmdm | 11:87ab310924f0 | 240 | */ |
epgmdm | 11:87ab310924f0 | 241 | void interruptButtonThreeH(); |
epgmdm | 11:87ab310924f0 | 242 | /** |
epgmdm | 11:87ab310924f0 | 243 | * button four interrupt |
epgmdm | 11:87ab310924f0 | 244 | */ |
epgmdm | 11:87ab310924f0 | 245 | void interruptButtonFourH(); |
epgmdm | 11:87ab310924f0 | 246 | /** |
epgmdm | 11:87ab310924f0 | 247 | * Fast interrupt routine for every 1 second |
epgmdm | 11:87ab310924f0 | 248 | */ |
epgmdm | 11:87ab310924f0 | 249 | void int1sH(); |
epgmdm | 11:87ab310924f0 | 250 | /** |
epgmdm | 11:87ab310924f0 | 251 | * interrupt to clear the posho is in use flag after a designated time |
epgmdm | 11:87ab310924f0 | 252 | */ |
epgmdm | 11:87ab310924f0 | 253 | void interruptPoshoInUseClearH(); |
epgmdm | 11:87ab310924f0 | 254 | |
epgmdm | 11:87ab310924f0 | 255 | /*************************************************************************************************/ |
epgmdm | 11:87ab310924f0 | 256 | /* |
epgmdm | 11:87ab310924f0 | 257 | * Reset all user initiated flags. Useful after sequences of events where flags may have |
epgmdm | 11:87ab310924f0 | 258 | * piled up from misc inputs and you don't want the system to act seemingly sporadically. |
epgmdm | 11:87ab310924f0 | 259 | */ |
epgmdm | 11:87ab310924f0 | 260 | void clearAllUserInitiatedFlagsH(); |
epgmdm | 11:87ab310924f0 | 261 | |
epgmdm | 11:87ab310924f0 | 262 | |
epgmdm | 11:87ab310924f0 | 263 | |
epgmdm | 11:87ab310924f0 | 264 | /* |
epgmdm | 11:87ab310924f0 | 265 | * User presses the button corresponding to an exit. Returns to home screen |
epgmdm | 11:87ab310924f0 | 266 | * after logging the action. |
epgmdm | 11:87ab310924f0 | 267 | * @param userIndex - int representing index of user in user table |
epgmdm | 11:87ab310924f0 | 268 | */ |
epgmdm | 11:87ab310924f0 | 269 | void cancelPressedH(int userIndex); |
epgmdm | 11:87ab310924f0 | 270 | /** |
epgmdm | 11:87ab310924f0 | 271 | * Do if time check flag is set |
epgmdm | 11:87ab310924f0 | 272 | * reads the unix time, converts into human readable format, and displays on PC |
epgmdm | 11:87ab310924f0 | 273 | */ |
epgmdm | 11:87ab310924f0 | 274 | void doTimeCheckH(); |
epgmdm | 11:87ab310924f0 | 275 | /** |
epgmdm | 11:87ab310924f0 | 276 | * Do if update user table flag is set |
epgmdm | 11:87ab310924f0 | 277 | */ |
epgmdm | 11:87ab310924f0 | 278 | void doUpdateUserTableH(); |
epgmdm | 11:87ab310924f0 | 279 | |
epgmdm | 11:87ab310924f0 | 280 | /* ************************************************************************************************/ |
epgmdm | 11:87ab310924f0 | 281 | /* RFID support */ |
epgmdm | 11:87ab310924f0 | 282 | /* ************************************************************************************************/ |
epgmdm | 11:87ab310924f0 | 283 | /* |
epgmdm | 11:87ab310924f0 | 284 | * Read Rfid card and parse out the tag id into a single integer. Log if tag is either known |
epgmdm | 11:87ab310924f0 | 285 | * or unknown. Sets the global variable for the current user if a user is found. |
epgmdm | 11:87ab310924f0 | 286 | * @param rfidReader - MFRC522* of the RFID reader |
epgmdm | 11:87ab310924f0 | 287 | * @param source - HubLoggingRfidSource enum for which RFID reader (battery, posho, incubator) |
epgmdm | 11:87ab310924f0 | 288 | * @return int representing the userIndex of the HubUser found by the RFID tag. If no user is |
epgmdm | 11:87ab310924f0 | 289 | found, returns a -1. |
epgmdm | 11:87ab310924f0 | 290 | */ |
epgmdm | 11:87ab310924f0 | 291 | int rfidReadHelper(MFRC522 *rfidReader, enum HubLoggingRfidSource source); |
epgmdm | 11:87ab310924f0 | 292 | /*************************************************************************************************/ |
epgmdm | 11:87ab310924f0 | 293 | /* Battery Services */ |
epgmdm | 11:87ab310924f0 | 294 | /*************************************************************************************************/ |
epgmdm | 11:87ab310924f0 | 295 | /** |
epgmdm | 11:87ab310924f0 | 296 | * Do if Battery RFID flag is set. Read RFID tag and check user status. |
epgmdm | 11:87ab310924f0 | 297 | * If there's a valid battery subscription, display drop off and/or pick up. |
epgmdm | 11:87ab310924f0 | 298 | * Otherwise, returns to initial screen. |
epgmdm | 11:87ab310924f0 | 299 | */ |
epgmdm | 11:87ab310924f0 | 300 | void doBatteryRfidH(); |
epgmdm | 11:87ab310924f0 | 301 | /** |
epgmdm | 11:87ab310924f0 | 302 | * Do if user selects to pickup a battery. Determines how many batteries |
epgmdm | 11:87ab310924f0 | 303 | * a user can pickup based off user info and displays corresponding text |
epgmdm | 11:87ab310924f0 | 304 | * @param userIndex - int representing index of user in user table |
epgmdm | 11:87ab310924f0 | 305 | */ |
epgmdm | 11:87ab310924f0 | 306 | void batteryPickUpScreenH(int userIndex); |
epgmdm | 11:87ab310924f0 | 307 | /** |
epgmdm | 11:87ab310924f0 | 308 | * Do if user selects to dropoff a battery. Determines how many batteries |
epgmdm | 11:87ab310924f0 | 309 | * a user can pickup based off user info and displays corresponding text |
epgmdm | 11:87ab310924f0 | 310 | * @param userIndex - int representing index of user in user table |
epgmdm | 11:87ab310924f0 | 311 | */ |
epgmdm | 11:87ab310924f0 | 312 | void batteryDropOffScreenH(int userIndex); |
epgmdm | 11:87ab310924f0 | 313 | |
epgmdm | 11:87ab310924f0 | 314 | /** |
epgmdm | 11:87ab310924f0 | 315 | * Do after user selects number of batteries to drop off. |
epgmdm | 11:87ab310924f0 | 316 | * Logs the action, changes user info, transmits instructions to other systems |
epgmdm | 11:87ab310924f0 | 317 | * @param numBatteries - int for number of batteries selected to drop off |
epgmdm | 11:87ab310924f0 | 318 | * @param userIndex - int representing index of user in user table |
epgmdm | 11:87ab310924f0 | 319 | */ |
epgmdm | 11:87ab310924f0 | 320 | void batteryDropOffH(int numBatteries, int userIndex); |
epgmdm | 11:87ab310924f0 | 321 | /** |
epgmdm | 11:87ab310924f0 | 322 | * Do after user selects number of batteries to pick up. |
epgmdm | 11:87ab310924f0 | 323 | * Logs the action, changes user info, transmits instructions to other systems |
epgmdm | 11:87ab310924f0 | 324 | * @param numBatteries - int for number of batteries selected to pick up |
epgmdm | 11:87ab310924f0 | 325 | * @param userIndex - int representing index of user in user table |
epgmdm | 11:87ab310924f0 | 326 | */ |
epgmdm | 11:87ab310924f0 | 327 | void batteryPickUpH(int numBatteries, int userIndex); |
epgmdm | 11:87ab310924f0 | 328 | |
epgmdm | 11:87ab310924f0 | 329 | /* ************************************************************************************************/ |
epgmdm | 11:87ab310924f0 | 330 | /* Misc Services */ |
epgmdm | 11:87ab310924f0 | 331 | /* ************************************************************************************************/ |
epgmdm | 11:87ab310924f0 | 332 | /** |
epgmdm | 11:87ab310924f0 | 333 | * Do if Posho RFID flag is set. Reads rfid and checks user table for a positive balance |
epgmdm | 11:87ab310924f0 | 334 | * capable of paying for the posho. Displays screen info for selecting posho amount to process. |
epgmdm | 11:87ab310924f0 | 335 | */ |
epgmdm | 11:87ab310924f0 | 336 | void doPoshoRfidH(); |
epgmdm | 11:87ab310924f0 | 337 | |
epgmdm | 11:87ab310924f0 | 338 | /** |
epgmdm | 11:87ab310924f0 | 339 | * Prepare to active the posho and husker for serial use. Change user balance as necessary |
epgmdm | 11:87ab310924f0 | 340 | * and send corresponding signal. Also sets posho flag to in use and sets an interrupt |
epgmdm | 11:87ab310924f0 | 341 | * to clear that flag after a specified time. |
epgmdm | 11:87ab310924f0 | 342 | * @param numKilograms - int for number of kilograms to be processed |
epgmdm | 11:87ab310924f0 | 343 | * @param userIndex - int representing index of user in user table |
epgmdm | 11:87ab310924f0 | 344 | */ |
epgmdm | 11:87ab310924f0 | 345 | void poshoSerialUseH(int numKilograms, int userIndex); |
epgmdm | 11:87ab310924f0 | 346 | /** |
epgmdm | 11:87ab310924f0 | 347 | * Do if Incubator RFID flag is set. Add incubator functionality later. |
epgmdm | 11:87ab310924f0 | 348 | */ |
epgmdm | 11:87ab310924f0 | 349 | void doIncubatorRfidH(); |
epgmdm | 11:87ab310924f0 | 350 | |
epgmdm | 11:87ab310924f0 | 351 | |
epgmdm | 11:87ab310924f0 | 352 | void logActionWithUserInfo(enum HubActionForLogging action, HubUser *user); |
epgmdm | 11:87ab310924f0 | 353 | void logErrorUnknownRfidScanned(uint32_t unknownRfid, enum HubLoggingRfidSource source); |
epgmdm | 11:87ab310924f0 | 354 | |
epgmdm | 11:87ab310924f0 | 355 | /** |
epgmdm | 11:87ab310924f0 | 356 | * Sends a signal to a locker that the current user is picking up numBatteries batteries |
epgmdm | 11:87ab310924f0 | 357 | * @param userid - the numer in the all users array. |
epgmdm | 11:87ab310924f0 | 358 | * @param numBatteries - int representing number of batteries user is picking up |
epgmdm | 11:87ab310924f0 | 359 | */ |
epgmdm | 11:87ab310924f0 | 360 | void txBatteryPickUp(int usedid, int numBatteries); |
epgmdm | 11:87ab310924f0 | 361 | |
epgmdm | 11:87ab310924f0 | 362 | /** |
epgmdm | 11:87ab310924f0 | 363 | * Sends a signal to a locker that the current user is dropping off numBatteries batteries |
epgmdm | 11:87ab310924f0 | 364 | * @param userid - the numer in the all users array. |
epgmdm | 11:87ab310924f0 | 365 | * @param numBatteries - int representing number of batteries user is dropping off |
epgmdm | 11:87ab310924f0 | 366 | */ |
epgmdm | 11:87ab310924f0 | 367 | void txBatteryDropOff(int usedid, int numBatteries); |
epgmdm | 11:87ab310924f0 | 368 | |
epgmdm | 11:87ab310924f0 | 369 | /** |
epgmdm | 11:87ab310924f0 | 370 | * Sends a signal to a services mbed to schedule the posho/husker for use for x kilograms |
epgmdm | 11:87ab310924f0 | 371 | * @param numKilograms - int representing number of kilograms user is processing |
epgmdm | 11:87ab310924f0 | 372 | */ |
epgmdm | 11:87ab310924f0 | 373 | void txPoshoSerialUse(int numKilograms); |
epgmdm | 11:87ab310924f0 | 374 | |
epgmdm | 11:87ab310924f0 | 375 | |
epgmdm | 11:87ab310924f0 | 376 | }; |
epgmdm | 11:87ab310924f0 | 377 | |
epgmdm | 11:87ab310924f0 | 378 | |
epgmdm | 11:87ab310924f0 | 379 | //#endif |