// ----------------------------------------------------------------------------- /// @file repairMenu.h /// @brief File description // ----------------------------------------------------------------------------- // Micro-Key bv // Industrieweg 28, 9804 TG Noordhorn // Postbus 92, 9800 AB Zuidhorn // The Netherlands // Tel: +31 594 503020 // Fax: +31 594 505825 // Email: support@microkey.nl // Web: www.microkey.nl // ----------------------------------------------------------------------------- /// $Revision$ /// $Author$ /// $Date$ // (c) 2015 Micro-Key bv // ----------------------------------------------------------------------------- /// @defgroup {group_name} {group_description} /// Description /// @file repairMenu.h /// @ingroup {group_name} #ifndef INC_REPAIRMENU_H_ #define INC_REPAIRMENU_H_ // ----------------------------------------------------------------------------- // Include files // ----------------------------------------------------------------------------- #include #include "FreeRTOS.h" #include "task.h" #include "semphr.h" #include "stm32f10x.h" #include "repairPreset.h" #include "repairProcess.h" #include "Interlock.h" #include "keypadMatrix.h" #include "Observable.h" #include "rtc.h" // ----------------------------------------------------------------------------- // Constant and macro definitions // ----------------------------------------------------------------------------- #define REPAIRMENU_MAX_NUMBER_OF_ROWS (11) #define REPAIRMENU_MAX_NUMBER_OF_KEYS (16) // ----------------------------------------------------------------------------- // Type definitions. // ----------------------------------------------------------------------------- typedef enum { MAINMENU = 0, RM_CATHODEMCP_SELECT, REPAIRMENU, ADMINMENU, CALIBRATIONMENU, PRESETMENU, START_REPAIR, REPAIR_RUNNING, REPAIR_ASK_PAUSE, REPAIR_PAUSE, FINISH_CONTROL, FINISH, ERROR_STATE, WARNING_STATE, NO_MENU, NUMBER_OF_MENUS } T_MenuState; struct RepairMenu; typedef void (*RepairMenuFunctionCall)(struct RepairMenu* self, int cursorIndex); typedef enum { NO_ACTION = 0, HOTKEY_SELECT, SELECT, GOTO_STATE, EXECUTE_FUNCTION, SCROLL_UP, SCROLL_DOWN, DIGIT_INSERT } T_KeyAction; struct MenuRow { char text[20]; int newState; RepairMenuFunctionCall actionPointer; }; struct KeyActionBinding { char key; Keypad_KeyState keyState; T_KeyAction action; int argument; RepairMenuFunctionCall actionPointer; }; struct MenuPage { bool hasCursor; int numberOfRows; int maxNumberOfRows; int numberOfKeys; int maxNumberOfKeys; struct MenuRow row[REPAIRMENU_MAX_NUMBER_OF_ROWS]; struct KeyActionBinding keyActionBinding[NUMBER_OF_KEY_EVENTS * REPAIRMENU_MAX_NUMBER_OF_KEYS]; }; struct RepairMenu { TaskHandle_t taskHandle; int TaskPriority; uint16_t stackSize; bool runTask; bool initialized; struct Display* display; struct KeyboardDevice* keyboardDevice; T_MenuState menuState; int cursorIndex; int scrollOffset; SemaphoreHandle_t repairScreenUpdateSemaphore; const struct RepairPreset* repairPreset; struct RepairProcessParameters rpParameters; struct MenuPage menuArray[NUMBER_OF_MENUS]; char errorMessage[20]; char warningMessage[20]; Observer observer; }; // ----------------------------------------------------------------------------- // Function declarations // ----------------------------------------------------------------------------- /** ---------------------------------------------------------------------------- * repairMenu_construct * Description of function * * @param self * @param display * @param keyboardDevice * @param taskPriority * @param stackSize * @param repairScreenUpdateObserver * * @return ErrorStatus * * @todo * ----------------------------------------------------------------------------- */ extern ErrorStatus repairMenu_construct(struct RepairMenu* self, struct Display* display, struct KeyboardDevice* keyboardDevice, int taskPriority, uint16_t stackSize, Observer repairScreenUpdateObserver); /** ---------------------------------------------------------------------------- * repairMenu_destruct * Destructor for self * * @param self * * @return void * * @todo * ----------------------------------------------------------------------------- */ extern void repairMenu_destruct(struct RepairMenu* self); /** ---------------------------------------------------------------------------- * repairMenu_feedSecondsCounter * Feeds the seconds counter of the repair process. * The process is designed to be run every second, so this feed function should * be called every second. * * @param self The repair menu object * * @return void * * @todo * ----------------------------------------------------------------------------- */ extern void repairMenu_feedSecondsCounter(struct RepairMenu* self); /** ---------------------------------------------------------------------------- * repairMenu_feedSecondsCounterFromISR * Feeds the seconds counter of the repair process. * This function should be called in an ISR context * The process is designed to be run every second, so this feed function should * be called every second. * * @param self The repair menu object * * @return void * * @todo * ----------------------------------------------------------------------------- */ extern void repairMenu_feedSecondsCounterFromISR(struct RepairMenu* self); /** ---------------------------------------------------------------------------- * repairMenu_interlockFailed * Interlock verification failed * * @param self The repair menu object * @param interlockID 0 for common interlock * !0 for the tesla interlock * * @return void * * @todo * ----------------------------------------------------------------------------- */ extern void repairMenu_interlockFailed(struct RepairMenu* self, T_INTERLOCK_ID interlockID); extern void repairMenu_processFailed(struct RepairMenu* self); #endif /* INC_REPAIRMENU_H_ */