|
|
|
|
@@ -44,23 +44,72 @@
|
|
|
|
|
// Constant and macro definitions
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//static const char menuMain[4][20] =
|
|
|
|
|
// " 1.Tube repair"
|
|
|
|
|
// " 2.Operator"
|
|
|
|
|
// " 3.Calibration";
|
|
|
|
|
#define MENU_HAS_CURSOR (true)
|
|
|
|
|
#define MENU_HAS_NO_CURSOR (false)
|
|
|
|
|
#define REPAIRMENU_MAX_NUMBER_OF_ROWS (11)
|
|
|
|
|
#define REPAIRMENU_MAX_NUMBER_OF_KEYS (16)
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
// Type definitions
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
typedef void (*RepairMenuFunctionCall)(struct RepairMenu* self, int cursorIndex);
|
|
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
|
{
|
|
|
|
|
NO_ACTION = 0,
|
|
|
|
|
HOTKEY_SELECT,
|
|
|
|
|
SELECT,
|
|
|
|
|
SCROLL_UP,
|
|
|
|
|
SCROLL_DOWN,
|
|
|
|
|
DIGIT_INSERT
|
|
|
|
|
} T_KeyAction;
|
|
|
|
|
|
|
|
|
|
struct MenuRow
|
|
|
|
|
{
|
|
|
|
|
char text[20];
|
|
|
|
|
int newState;
|
|
|
|
|
RepairMenuFunctionCall actionPointer;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct KeyActionBinding
|
|
|
|
|
{
|
|
|
|
|
char key;
|
|
|
|
|
T_KeyAction action;
|
|
|
|
|
int argument;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct MenuPage
|
|
|
|
|
{
|
|
|
|
|
bool hasCursor;
|
|
|
|
|
int numberOfRows;
|
|
|
|
|
struct MenuRow row[REPAIRMENU_MAX_NUMBER_OF_ROWS];
|
|
|
|
|
struct KeyActionBinding keyActionBinding[REPAIRMENU_MAX_NUMBER_OF_KEYS];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
// File-scope variables
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
//TODO THIS IS UGLY
|
|
|
|
|
static struct RepairProcess* rp = NULL;
|
|
|
|
|
static const char cursorValue = 0x7E;
|
|
|
|
|
|
|
|
|
|
static struct MenuPage menuArray[NUMBER_OF_MENUS];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TEMPORARY PRESET STORAGE
|
|
|
|
|
static const struct RepairPreset preset1 = {.numberOfStages = 1, .preset[0].softstartDuration = 100, .preset[0].duration = 200, .preset[0].voltage = 100};
|
|
|
|
|
static const struct RepairPreset preset2 = {.numberOfStages = 1, .preset[0].softstartDuration = 200, .preset[0].duration = 400, .preset[0].voltage = 200};
|
|
|
|
|
static const struct RepairPreset preset3 = {.numberOfStages = 1, .preset[0].softstartDuration = 300, .preset[0].duration = 600, .preset[0].voltage = 300};
|
|
|
|
|
static const struct RepairPreset preset4 = {.numberOfStages = 1, .preset[0].softstartDuration = 400, .preset[0].duration = 800, .preset[0].voltage = 400};
|
|
|
|
|
static const struct RepairPreset preset5 = {.numberOfStages = 1, .preset[0].softstartDuration = 500, .preset[0].duration = 1000, .preset[0].voltage = 500};
|
|
|
|
|
static const struct RepairPreset preset6 = {.numberOfStages = 1, .preset[0].softstartDuration = 600, .preset[0].duration = 1200, .preset[0].voltage = 600};
|
|
|
|
|
static const struct RepairPreset preset7 = {.numberOfStages = 1, .preset[0].softstartDuration = 700, .preset[0].duration = 1400, .preset[0].voltage = 700};
|
|
|
|
|
static const struct RepairPreset preset8 = {.numberOfStages = 1, .preset[0].softstartDuration = 800, .preset[0].duration = 1600, .preset[0].voltage = 800};
|
|
|
|
|
static const struct RepairPreset preset9 = {.numberOfStages = 1, .preset[0].softstartDuration = 900, .preset[0].duration = 1800, .preset[0].voltage = 900};
|
|
|
|
|
static const struct RepairPreset* presetArray[9] = {&preset1, &preset2, &preset3, &preset4, &preset5, &preset6, &preset7, &preset8, &preset9};
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
// Function declarations
|
|
|
|
|
@@ -68,42 +117,146 @@
|
|
|
|
|
|
|
|
|
|
static void repairMenu_task(void* parameters);
|
|
|
|
|
|
|
|
|
|
static void repairMenu_selectMenu(struct RepairMenu* self, char key);
|
|
|
|
|
static void repairMenu_printMenu(struct RepairMenu* self);
|
|
|
|
|
static void repairMenu_printCursor(struct RepairMenu* self);
|
|
|
|
|
static void repairMenu_performAction(struct RepairMenu* self, char key);
|
|
|
|
|
static struct KeyActionBinding repairMenu_findKeyAction(struct RepairMenu* self, char key);
|
|
|
|
|
static void repairMenu_scrollIndexHandlerReset (struct RepairMenu* self);
|
|
|
|
|
static void repairMenu_scrollUpIndexHandler(struct RepairMenu* self);
|
|
|
|
|
static void repairMenu_scrollDownIndexHandler(struct RepairMenu* self);
|
|
|
|
|
static void repairMenu_startRepairProcess(struct RepairMenu* self, int cursorIndex);
|
|
|
|
|
static ErrorStatus repairMenu_feedProcessSecondsCounter(const void* const data);
|
|
|
|
|
|
|
|
|
|
static void repairMenu_selectPreset(struct RepairMenu* self, int cursorIndex);
|
|
|
|
|
|
|
|
|
|
static void repairMenu_createMenuPage (struct MenuPage* self, bool hasCursor, int numberOfRows);
|
|
|
|
|
static void repairMenu_addMenuPageRow (struct MenuPage* self, int rowIndex, char* text, int newState, RepairMenuFunctionCall actionCall);
|
|
|
|
|
static void repairMenu_addMenuPageKeyAction (struct MenuPage* self, int keyActionIndex, char key, T_KeyAction action, int argument);
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
// Function definitions
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ErrorStatus repairMenu_construct(struct RepairMenu* self, struct Display* display, int taskPriority, uint16_t stackSize)
|
|
|
|
|
ErrorStatus repairMenu_construct(struct RepairMenu* self, struct Display* display, struct KeyboardDevice* keyboardDevice, int taskPriority, uint16_t stackSize, Keypad_KeyState keyStateTrigger)
|
|
|
|
|
{
|
|
|
|
|
ErrorStatus returnValue = SUCCESS;
|
|
|
|
|
|
|
|
|
|
if (!self->initialized)
|
|
|
|
|
{
|
|
|
|
|
// Create a semaphore to sync access to the display shadow
|
|
|
|
|
vSemaphoreCreateBinary(self->secondsSyncronisation);
|
|
|
|
|
xSemaphoreGive(self->secondsSyncronisation);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BaseType_t rv = xTaskCreate(repairMenu_task, "RepairMenu", stackSize, self, taskPriority, &self->taskHandle);
|
|
|
|
|
if (rv != pdTRUE)
|
|
|
|
|
if (returnValue == SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
returnValue = ERROR;
|
|
|
|
|
if (display->initialized)
|
|
|
|
|
{
|
|
|
|
|
self->display = display;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
returnValue = ERROR;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (returnValue == SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
LOGGER_INFO(mainLog, "Repair Menu task started");
|
|
|
|
|
self->runTask = true;
|
|
|
|
|
self->initialized = true;
|
|
|
|
|
self->display = display;
|
|
|
|
|
self->menuState = MAINMENU;
|
|
|
|
|
if (keyboardDevice->initialized)
|
|
|
|
|
{
|
|
|
|
|
self->keyboardDevice = keyboardDevice;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
returnValue = ERROR;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
|
|
|
|
|
if (returnValue == SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
LOGGER_ERROR(mainLog, "FAILED to start repair Menu with code %d", (int)rv);
|
|
|
|
|
// Create a semaphore to sync access to the display shadow
|
|
|
|
|
vSemaphoreCreateBinary(self->secondsSyncronisation);
|
|
|
|
|
xSemaphoreGive(self->secondsSyncronisation);
|
|
|
|
|
|
|
|
|
|
// Construct the menu based on PCBA information
|
|
|
|
|
repairMenu_createMenuPage(&menuArray[MAINMENU], MENU_HAS_CURSOR, 4);
|
|
|
|
|
repairMenu_addMenuPageRow(&menuArray[MAINMENU], 0, PCBA_getInstance()->name, MAINMENU, NULL);
|
|
|
|
|
repairMenu_addMenuPageRow(&menuArray[MAINMENU], 1, " 1.Tube repair", REPAIRMENU, NULL);
|
|
|
|
|
repairMenu_addMenuPageRow(&menuArray[MAINMENU], 2, " 2.Administrator", ADMINMENU, NULL);
|
|
|
|
|
repairMenu_addMenuPageRow(&menuArray[MAINMENU], 3, " 3.Calibration", CALIBRATIONMENU, NULL);
|
|
|
|
|
repairMenu_addMenuPageKeyAction(&menuArray[MAINMENU], 0, 'U', SCROLL_UP, 0);
|
|
|
|
|
repairMenu_addMenuPageKeyAction(&menuArray[MAINMENU], 1, 'D', SCROLL_DOWN, 0);
|
|
|
|
|
repairMenu_addMenuPageKeyAction(&menuArray[MAINMENU], 2, 'E', SELECT, 0);
|
|
|
|
|
repairMenu_addMenuPageKeyAction(&menuArray[MAINMENU], 3, '1', HOTKEY_SELECT, 1);
|
|
|
|
|
repairMenu_addMenuPageKeyAction(&menuArray[MAINMENU], 4, '2', HOTKEY_SELECT, 2);
|
|
|
|
|
repairMenu_addMenuPageKeyAction(&menuArray[MAINMENU], 5, '3', HOTKEY_SELECT, 3);
|
|
|
|
|
|
|
|
|
|
repairMenu_createMenuPage(&menuArray[REPAIRMENU], MENU_HAS_CURSOR, 4);
|
|
|
|
|
repairMenu_addMenuPageRow(&menuArray[REPAIRMENU], 0, "Tube repair", REPAIRMENU, NULL);
|
|
|
|
|
repairMenu_addMenuPageRow(&menuArray[REPAIRMENU], 1, " 1.Select preset", PRESETMENU, NULL);
|
|
|
|
|
repairMenu_addMenuPageRow(&menuArray[REPAIRMENU], 2, " 2.Start", START_REPAIR, repairMenu_startRepairProcess);
|
|
|
|
|
repairMenu_addMenuPageRow(&menuArray[REPAIRMENU], 3, " 3.To main menu", MAINMENU, NULL);
|
|
|
|
|
repairMenu_addMenuPageKeyAction(&menuArray[REPAIRMENU], 0, 'U', SCROLL_UP, 0);
|
|
|
|
|
repairMenu_addMenuPageKeyAction(&menuArray[REPAIRMENU], 1, 'D', SCROLL_DOWN, 0);
|
|
|
|
|
repairMenu_addMenuPageKeyAction(&menuArray[REPAIRMENU], 2, 'E', SELECT, 0);
|
|
|
|
|
repairMenu_addMenuPageKeyAction(&menuArray[REPAIRMENU], 3, '1', HOTKEY_SELECT, 1);
|
|
|
|
|
repairMenu_addMenuPageKeyAction(&menuArray[REPAIRMENU], 4, '2', HOTKEY_SELECT, 2);
|
|
|
|
|
repairMenu_addMenuPageKeyAction(&menuArray[REPAIRMENU], 5, 'X', HOTKEY_SELECT, 3);
|
|
|
|
|
|
|
|
|
|
repairMenu_createMenuPage(&menuArray[ADMINMENU], MENU_HAS_NO_CURSOR, 2);
|
|
|
|
|
repairMenu_addMenuPageRow(&menuArray[ADMINMENU], 0, "Administration", ADMINMENU, NULL);
|
|
|
|
|
repairMenu_addMenuPageRow(&menuArray[ADMINMENU], 1, " 1.To main menu", MAINMENU, NULL);
|
|
|
|
|
repairMenu_addMenuPageKeyAction(&menuArray[ADMINMENU], 0, 'E', SELECT, 0);
|
|
|
|
|
repairMenu_addMenuPageKeyAction(&menuArray[ADMINMENU], 1, '1', HOTKEY_SELECT, 1);
|
|
|
|
|
repairMenu_addMenuPageKeyAction(&menuArray[ADMINMENU], 2, 'X', HOTKEY_SELECT, 1);
|
|
|
|
|
|
|
|
|
|
repairMenu_createMenuPage(&menuArray[CALIBRATIONMENU], MENU_HAS_NO_CURSOR, 2);
|
|
|
|
|
repairMenu_addMenuPageRow(&menuArray[CALIBRATIONMENU], 0, "Calibration", CALIBRATIONMENU, NULL);
|
|
|
|
|
repairMenu_addMenuPageRow(&menuArray[CALIBRATIONMENU], 1, " 1.To main menu", MAINMENU, NULL);
|
|
|
|
|
repairMenu_addMenuPageKeyAction(&menuArray[CALIBRATIONMENU], 0, 'E', SELECT, 0);
|
|
|
|
|
repairMenu_addMenuPageKeyAction(&menuArray[CALIBRATIONMENU], 1, '1', HOTKEY_SELECT, 1);
|
|
|
|
|
repairMenu_addMenuPageKeyAction(&menuArray[CALIBRATIONMENU], 2, 'X', HOTKEY_SELECT, 1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
repairMenu_createMenuPage(&menuArray[PRESETMENU], MENU_HAS_CURSOR, 11);
|
|
|
|
|
repairMenu_addMenuPageRow(&menuArray[PRESETMENU], 0, "Select preset", PRESETMENU, NULL);
|
|
|
|
|
repairMenu_addMenuPageRow(&menuArray[PRESETMENU], 1, " 1.Preset1", REPAIRMENU, repairMenu_selectPreset);
|
|
|
|
|
repairMenu_addMenuPageRow(&menuArray[PRESETMENU], 2, " 2.Preset2", REPAIRMENU, repairMenu_selectPreset);
|
|
|
|
|
repairMenu_addMenuPageRow(&menuArray[PRESETMENU], 3, " 3.Preset3", REPAIRMENU, repairMenu_selectPreset);
|
|
|
|
|
repairMenu_addMenuPageRow(&menuArray[PRESETMENU], 4, " 4.Preset4", REPAIRMENU, repairMenu_selectPreset);
|
|
|
|
|
repairMenu_addMenuPageRow(&menuArray[PRESETMENU], 5, " 5.Preset5", REPAIRMENU, repairMenu_selectPreset);
|
|
|
|
|
repairMenu_addMenuPageRow(&menuArray[PRESETMENU], 6, " 6.Preset6", REPAIRMENU, repairMenu_selectPreset);
|
|
|
|
|
repairMenu_addMenuPageRow(&menuArray[PRESETMENU], 7, " 7.Preset7", REPAIRMENU, repairMenu_selectPreset);
|
|
|
|
|
repairMenu_addMenuPageRow(&menuArray[PRESETMENU], 8, " 8.Preset8", REPAIRMENU, repairMenu_selectPreset);
|
|
|
|
|
repairMenu_addMenuPageRow(&menuArray[PRESETMENU], 9, " 9.Preset9", REPAIRMENU, repairMenu_selectPreset);
|
|
|
|
|
repairMenu_addMenuPageRow(&menuArray[PRESETMENU], 10, " 10.To repair menu", REPAIRMENU, NULL);
|
|
|
|
|
repairMenu_addMenuPageKeyAction(&menuArray[PRESETMENU], 0, 'U', SCROLL_UP, 0);
|
|
|
|
|
repairMenu_addMenuPageKeyAction(&menuArray[PRESETMENU], 1, 'D', SCROLL_DOWN, 0);
|
|
|
|
|
repairMenu_addMenuPageKeyAction(&menuArray[PRESETMENU], 2, 'E', SELECT, 0);
|
|
|
|
|
repairMenu_addMenuPageKeyAction(&menuArray[PRESETMENU], 3, '1', HOTKEY_SELECT, 1);
|
|
|
|
|
repairMenu_addMenuPageKeyAction(&menuArray[PRESETMENU], 4, '2', HOTKEY_SELECT, 2);
|
|
|
|
|
repairMenu_addMenuPageKeyAction(&menuArray[PRESETMENU], 5, '3', HOTKEY_SELECT, 3);
|
|
|
|
|
repairMenu_addMenuPageKeyAction(&menuArray[PRESETMENU], 6, '4', HOTKEY_SELECT, 4);
|
|
|
|
|
repairMenu_addMenuPageKeyAction(&menuArray[PRESETMENU], 7, '5', HOTKEY_SELECT, 5);
|
|
|
|
|
repairMenu_addMenuPageKeyAction(&menuArray[PRESETMENU], 8, '6', HOTKEY_SELECT, 6);
|
|
|
|
|
repairMenu_addMenuPageKeyAction(&menuArray[PRESETMENU], 9, '7', HOTKEY_SELECT, 7);
|
|
|
|
|
repairMenu_addMenuPageKeyAction(&menuArray[PRESETMENU], 10, '8', HOTKEY_SELECT, 8);
|
|
|
|
|
repairMenu_addMenuPageKeyAction(&menuArray[PRESETMENU], 11, '9', HOTKEY_SELECT, 9);
|
|
|
|
|
repairMenu_addMenuPageKeyAction(&menuArray[PRESETMENU], 12, 'X', HOTKEY_SELECT, 10);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self->menuState = MAINMENU;
|
|
|
|
|
self->runTask = true;
|
|
|
|
|
|
|
|
|
|
BaseType_t rv = xTaskCreate(repairMenu_task, "RepairMenu", stackSize, self, taskPriority, &self->taskHandle);
|
|
|
|
|
if (rv != pdTRUE)
|
|
|
|
|
{
|
|
|
|
|
returnValue = ERROR;
|
|
|
|
|
LOGGER_ERROR(mainLog, "FAILED to start repair Menu with code %d", (int)rv);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
self->initialized = true;
|
|
|
|
|
self->cursorIndex = 1;
|
|
|
|
|
self->scrollOffset = 0;
|
|
|
|
|
LOGGER_INFO(mainLog, "Repair Menu task started");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
@@ -155,20 +308,24 @@ static void repairMenu_task(void* parameters)
|
|
|
|
|
char key;
|
|
|
|
|
Keypad_KeyState keyState;
|
|
|
|
|
|
|
|
|
|
// Get a new key from keyboard
|
|
|
|
|
if (KeyboardDevice_read(&storm700->keyboardDevice, &key, &keyState) == SUCCESS)
|
|
|
|
|
// Clear the screen for a new menu
|
|
|
|
|
Display_clearScreen(self->display);
|
|
|
|
|
// Print menu content to output device
|
|
|
|
|
repairMenu_printMenu(self);
|
|
|
|
|
// Add cursor if necessary
|
|
|
|
|
repairMenu_printCursor(self);
|
|
|
|
|
|
|
|
|
|
while (KeyboardDevice_read(&storm700->keyboardDevice, &key, &keyState) != SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
// New key read
|
|
|
|
|
if (keyState == RELEASED)
|
|
|
|
|
{
|
|
|
|
|
LOGGER_INFO(mainLog, "Key %c is released", key);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
LOGGER_INFO(mainLog, "Key %c is pressed", key);
|
|
|
|
|
}
|
|
|
|
|
vTaskDelay(10);
|
|
|
|
|
}
|
|
|
|
|
vTaskDelay(100);
|
|
|
|
|
|
|
|
|
|
if (keyState == self->keyStateTrigger)
|
|
|
|
|
{
|
|
|
|
|
repairMenu_performAction(self, key);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LOGGER_INFO(mainLog, "Deleting RepairMenu task");
|
|
|
|
|
@@ -176,35 +333,213 @@ static void repairMenu_task(void* parameters)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void repairMenu_selectMenu(struct RepairMenu* self, char key)
|
|
|
|
|
{
|
|
|
|
|
switch (self->menuState)
|
|
|
|
|
{
|
|
|
|
|
case MAINMENU:
|
|
|
|
|
{
|
|
|
|
|
repairMenu_printMenu(self);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case REPAIRMENU:
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void repairMenu_printMenu(struct RepairMenu* self)
|
|
|
|
|
{
|
|
|
|
|
switch (self->menuState)
|
|
|
|
|
int loopCounter;
|
|
|
|
|
|
|
|
|
|
// Always print Row1 (index0), ignoring the scrolling index
|
|
|
|
|
Display_write(self->display, menuArray[self->menuState].row[0].text, strlen(menuArray[self->menuState].row[0].text), 1, 1);
|
|
|
|
|
|
|
|
|
|
for (loopCounter = 1 ; loopCounter < self->display->displayDevice->parameters.numberOfRows; loopCounter++)
|
|
|
|
|
{
|
|
|
|
|
case MAINMENU:
|
|
|
|
|
Display_write(self->display, menuArray[self->menuState].row[loopCounter + self->scrollOffset].text, strlen(menuArray[self->menuState].row[loopCounter + self->scrollOffset].text), loopCounter + 1, 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void repairMenu_printCursor(struct RepairMenu* self)
|
|
|
|
|
{
|
|
|
|
|
if (menuArray[self->menuState].hasCursor)
|
|
|
|
|
{
|
|
|
|
|
Display_write(self->display, &cursorValue, 1, 1 + self->cursorIndex - self->scrollOffset, 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void repairMenu_performAction(struct RepairMenu* self, char key)
|
|
|
|
|
{
|
|
|
|
|
struct KeyActionBinding keyAction = repairMenu_findKeyAction(self, key);
|
|
|
|
|
LOGGER_DEBUG(mainLog, "Action: received key %c, action to perform %d,", key, keyAction.action);
|
|
|
|
|
|
|
|
|
|
switch (keyAction.action)
|
|
|
|
|
{
|
|
|
|
|
case NO_ACTION:
|
|
|
|
|
{
|
|
|
|
|
Display_write(self->display, PCBA_getInstance()->name, strlen(PCBA_getInstance()->name), 1, 1);
|
|
|
|
|
LOGGER_INFO(mainLog, "This button has no action");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case REPAIRMENU:
|
|
|
|
|
|
|
|
|
|
case HOTKEY_SELECT:
|
|
|
|
|
{
|
|
|
|
|
LOGGER_INFO(mainLog, "HOTKEY SELECT ITEM: char %c, argument %d - Going to state %d", keyAction.key, keyAction.argument, menuArray[self->menuState].row[keyAction.argument].newState);
|
|
|
|
|
if (menuArray[self->menuState].row[keyAction.argument].actionPointer != NULL)
|
|
|
|
|
{
|
|
|
|
|
menuArray[self->menuState].row[keyAction.argument].actionPointer(self, keyAction.argument);
|
|
|
|
|
}
|
|
|
|
|
self->menuState = menuArray[self->menuState].row[keyAction.argument].newState;
|
|
|
|
|
repairMenu_scrollIndexHandlerReset(self);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case SELECT:
|
|
|
|
|
{
|
|
|
|
|
LOGGER_INFO(mainLog, "SELECT ITEM %d - going to state %d", self->cursorIndex, menuArray[self->menuState].row[self->cursorIndex].newState);
|
|
|
|
|
if (menuArray[self->menuState].row[self->cursorIndex].actionPointer != NULL)
|
|
|
|
|
{
|
|
|
|
|
menuArray[self->menuState].row[self->cursorIndex].actionPointer(self, self->cursorIndex);
|
|
|
|
|
}
|
|
|
|
|
self->menuState = menuArray[self->menuState].row[self->cursorIndex].newState;
|
|
|
|
|
repairMenu_scrollIndexHandlerReset(self);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case SCROLL_UP:
|
|
|
|
|
{
|
|
|
|
|
LOGGER_INFO(mainLog, "Scrolling up");
|
|
|
|
|
repairMenu_scrollUpIndexHandler(self);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case SCROLL_DOWN:
|
|
|
|
|
{
|
|
|
|
|
LOGGER_INFO(mainLog, "Scrolling down");
|
|
|
|
|
repairMenu_scrollDownIndexHandler(self);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case DIGIT_INSERT:
|
|
|
|
|
{
|
|
|
|
|
LOGGER_INFO(mainLog, "Key is allowed as insert");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static struct KeyActionBinding repairMenu_findKeyAction(struct RepairMenu* self, char key)
|
|
|
|
|
{
|
|
|
|
|
int loopCounter;
|
|
|
|
|
struct KeyActionBinding returnValue;
|
|
|
|
|
returnValue.action = NO_ACTION;
|
|
|
|
|
|
|
|
|
|
for (loopCounter = 0; loopCounter < REPAIRMENU_MAX_NUMBER_OF_KEYS; loopCounter++)
|
|
|
|
|
{
|
|
|
|
|
if (menuArray[self->menuState].keyActionBinding[loopCounter].key == key)
|
|
|
|
|
{
|
|
|
|
|
returnValue = menuArray[self->menuState].keyActionBinding[loopCounter];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return returnValue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void repairMenu_scrollIndexHandlerReset (struct RepairMenu* self)
|
|
|
|
|
{
|
|
|
|
|
self->cursorIndex = 1;
|
|
|
|
|
self->scrollOffset = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void repairMenu_scrollUpIndexHandler(struct RepairMenu* self)
|
|
|
|
|
{
|
|
|
|
|
if (self->cursorIndex - self->scrollOffset > 1)
|
|
|
|
|
{
|
|
|
|
|
if (self->cursorIndex > 1)
|
|
|
|
|
{
|
|
|
|
|
self->cursorIndex--;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (self->cursorIndex > 1)
|
|
|
|
|
{
|
|
|
|
|
self->cursorIndex--;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (self->scrollOffset > 0)
|
|
|
|
|
{
|
|
|
|
|
self->scrollOffset--;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void repairMenu_scrollDownIndexHandler(struct RepairMenu* self)
|
|
|
|
|
{
|
|
|
|
|
if (self->cursorIndex < self->display->displayDevice->parameters.numberOfRows - 1)
|
|
|
|
|
{
|
|
|
|
|
if (self->cursorIndex < menuArray[self->menuState].numberOfRows - 1)
|
|
|
|
|
{
|
|
|
|
|
self->cursorIndex++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (self->cursorIndex < menuArray[self->menuState].numberOfRows - 1)
|
|
|
|
|
{
|
|
|
|
|
self->cursorIndex++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (self->scrollOffset < (menuArray[self->menuState].numberOfRows - self->display->displayDevice->parameters.numberOfRows))
|
|
|
|
|
{
|
|
|
|
|
self->scrollOffset++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void repairMenu_startRepairProcess(struct RepairMenu* self, int cursorIndex)
|
|
|
|
|
{
|
|
|
|
|
self->rpParameters.adcRow1 = &adc1->channel[0];
|
|
|
|
|
self->rpParameters.adcRow2 = &adc1->channel[1];
|
|
|
|
|
self->rpParameters.adcRow3 = &adc1->channel[2];
|
|
|
|
|
self->rpParameters.dacRow1 = &max5715->dac[0];
|
|
|
|
|
self->rpParameters.dacRow2 = &max5715->dac[1];
|
|
|
|
|
self->rpParameters.dacRow3 = &max5715->dac[2];
|
|
|
|
|
|
|
|
|
|
rp = &self->repairProcess;
|
|
|
|
|
Observable_addObserver(RTC_getObservable(rtc), repairMenu_feedProcessSecondsCounter);
|
|
|
|
|
repairProcess_construct(&self->repairProcess, &self->rpParameters, self->repairPreset, 2, 1024);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static ErrorStatus repairMenu_feedProcessSecondsCounter(const void* const data)
|
|
|
|
|
{
|
|
|
|
|
repairProcess_feedSecondsCounterFromISR(rp);
|
|
|
|
|
return SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void repairMenu_selectPreset(struct RepairMenu* self, int cursorIndex)
|
|
|
|
|
{
|
|
|
|
|
self->repairPreset = presetArray[cursorIndex - 1];
|
|
|
|
|
LOGGER_INFO(mainLog, "Preset %d selected", cursorIndex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void repairMenu_createMenuPage (struct MenuPage* self, bool hasCursor, int numberOfRows)
|
|
|
|
|
{
|
|
|
|
|
self->hasCursor = hasCursor;
|
|
|
|
|
if (numberOfRows <= REPAIRMENU_MAX_NUMBER_OF_ROWS)
|
|
|
|
|
{
|
|
|
|
|
self->numberOfRows = numberOfRows;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void repairMenu_addMenuPageRow (struct MenuPage* self, int rowIndex, char* text, int newState, RepairMenuFunctionCall actionCall)
|
|
|
|
|
{
|
|
|
|
|
if (rowIndex < self->numberOfRows)
|
|
|
|
|
{
|
|
|
|
|
memcpy(self->row[rowIndex].text, text, 20);
|
|
|
|
|
self->row[rowIndex].newState = newState;
|
|
|
|
|
self->row[rowIndex].actionPointer = actionCall;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void repairMenu_addMenuPageKeyAction (struct MenuPage* self, int keyActionIndex, char key, T_KeyAction action, int argument)
|
|
|
|
|
{
|
|
|
|
|
if (keyActionIndex < REPAIRMENU_MAX_NUMBER_OF_KEYS)
|
|
|
|
|
{
|
|
|
|
|
self->keyActionBinding[keyActionIndex].key = key;
|
|
|
|
|
self->keyActionBinding[keyActionIndex].argument = argument;
|
|
|
|
|
self->keyActionBinding[keyActionIndex].action = action;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|