Updated memory storage functionality
- cachedStorage is functional - Presets can be loaded from FLASH - CRC32 added and applied - Presets with corrputed data will be replaced by default preset Next: Preset update functionality from menu git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@269 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
#include "stdio.h"
|
||||
#include "string.h"
|
||||
#include "repairMenu.h"
|
||||
#include "RepairPreset.h"
|
||||
#include "repairProcess.h"
|
||||
#include "repairProcesses.h"
|
||||
|
||||
@@ -72,38 +73,6 @@
|
||||
static const char cursorValue[2] = {0x7E, '\0'};
|
||||
|
||||
|
||||
// TEMPORARY PRESET STORAGE
|
||||
static const struct RepairPreset preset1t = {.presetNumber = 1, .numberOfStages = 1, .preset[0].softstartDuration = 100, .preset[0].duration = 200, .preset[0].voltage = 1000};
|
||||
static const struct RepairPreset preset2t = {.presetNumber = 2, .numberOfStages = 1, .preset[0].softstartDuration = 200, .preset[0].duration = 400, .preset[0].voltage = 3000};
|
||||
static const struct RepairPreset preset3t = {.presetNumber = 3, .numberOfStages = 1, .preset[0].softstartDuration = 300, .preset[0].duration = 600, .preset[0].voltage = 300};
|
||||
static const struct RepairPreset preset4t = {.presetNumber = 4, .numberOfStages = 1, .preset[0].softstartDuration = 400, .preset[0].duration = 800, .preset[0].voltage = 400};
|
||||
static const struct RepairPreset preset5t = {.presetNumber = 5, .numberOfStages = 1, .preset[0].softstartDuration = 500, .preset[0].duration = 1000, .preset[0].voltage = 500};
|
||||
static const struct RepairPreset preset6t = {.presetNumber = 6, .numberOfStages = 1, .preset[0].softstartDuration = 120, .preset[0].duration = 240, .preset[0].voltage = 800};
|
||||
static const struct RepairPreset preset7t = {.presetNumber = 7, .numberOfStages = 1, .preset[0].softstartDuration = 700, .preset[0].duration = 1400, .preset[0].voltage = 700};
|
||||
static const struct RepairPreset preset8t = {.presetNumber = 8, .numberOfStages = 1, .preset[0].softstartDuration = 120, .preset[0].duration = 300, .preset[0].voltage = 4000};
|
||||
static const struct RepairPreset preset9t = {.presetNumber = 9, .numberOfStages = 2, .preset[0].softstartDuration = 900, .preset[0].duration = 1800, .preset[0].voltage = 4000, .preset[1].softstartDuration = 100, .preset[1].duration = 1800, .preset[1].voltage = 5000};
|
||||
|
||||
static const struct RepairPreset preset1a = {.presetNumber = 1, .numberOfStages = 1, .preset[0].softstartDuration = 000, .preset[0].duration = 200, .preset[0].voltage = 1000};
|
||||
static const struct RepairPreset preset2a = {.presetNumber = 2, .numberOfStages = 1, .preset[0].softstartDuration = 200, .preset[0].duration = 400, .preset[0].voltage = 3000};
|
||||
static const struct RepairPreset preset3a = {.presetNumber = 3, .numberOfStages = 1, .preset[0].softstartDuration = 300, .preset[0].duration = 600, .preset[0].voltage = 300};
|
||||
static const struct RepairPreset preset4a = {.presetNumber = 4, .numberOfStages = 1, .preset[0].softstartDuration = 400, .preset[0].duration = 800, .preset[0].voltage = 400};
|
||||
static const struct RepairPreset preset5a = {.presetNumber = 5, .numberOfStages = 1, .preset[0].softstartDuration = 500, .preset[0].duration = 1000, .preset[0].voltage = 500};
|
||||
static const struct RepairPreset preset6a = {.presetNumber = 6, .numberOfStages = 1, .preset[0].softstartDuration = 600, .preset[0].duration = 1200, .preset[0].voltage = 8000};
|
||||
static const struct RepairPreset preset7a = {.presetNumber = 7, .numberOfStages = 1, .preset[0].softstartDuration = 200, .preset[0].duration = 600, .preset[0].voltage = 10000};
|
||||
static const struct RepairPreset preset8a = {.presetNumber = 8, .numberOfStages = 1, .preset[0].softstartDuration = 120, .preset[0].duration = 300, .preset[0].voltage = 6000};
|
||||
static const struct RepairPreset preset9a = {.presetNumber = 9, .numberOfStages = 2, .preset[0].softstartDuration = 900, .preset[0].duration = 1800, .preset[0].voltage = 6000, .preset[1].softstartDuration = 100, .preset[1].duration = 1800, .preset[1].voltage = 8000};
|
||||
|
||||
static const struct RepairPreset preset1n = {.presetNumber = 1, .numberOfStages = 1, .preset[0].softstartDuration = 100, .preset[0].duration = 200, .preset[0].voltage = -1000};
|
||||
static const struct RepairPreset preset2n = {.presetNumber = 2, .numberOfStages = 1, .preset[0].softstartDuration = 200, .preset[0].duration = 400, .preset[0].voltage = -1800};
|
||||
static const struct RepairPreset preset3n = {.presetNumber = 3, .numberOfStages = 1, .preset[0].softstartDuration = 300, .preset[0].duration = 600, .preset[0].voltage = -300};
|
||||
static const struct RepairPreset preset4n = {.presetNumber = 4, .numberOfStages = 1, .preset[0].softstartDuration = 400, .preset[0].duration = 800, .preset[0].voltage = -400};
|
||||
static const struct RepairPreset preset5n = {.presetNumber = 5, .numberOfStages = 1, .preset[0].softstartDuration = 500, .preset[0].duration = 1000, .preset[0].voltage = -500};
|
||||
static const struct RepairPreset preset6n = {.presetNumber = 6, .numberOfStages = 1, .preset[0].softstartDuration = 600, .preset[0].duration = 1200, .preset[0].voltage = -600};
|
||||
static const struct RepairPreset preset7n = {.presetNumber = 7, .numberOfStages = 1, .preset[0].softstartDuration = 700, .preset[0].duration = 1400, .preset[0].voltage = -700};
|
||||
static const struct RepairPreset preset8n = {.presetNumber = 8, .numberOfStages = 1, .preset[0].softstartDuration = 120, .preset[0].duration = 300, .preset[0].voltage = -1800};
|
||||
static const struct RepairPreset preset9n = {.presetNumber = 9, .numberOfStages = 2, .preset[0].softstartDuration = 900, .preset[0].duration = 1800, .preset[0].voltage = -1200, .preset[1].softstartDuration = 100, .preset[1].duration = 1800, .preset[1].voltage = -1600};
|
||||
static const struct RepairPreset* presetArray[9];
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -152,7 +121,7 @@ static ErrorStatus repairMenu_addKeyAction_SCROLLDOWN (struct MenuPage* self, ch
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
ErrorStatus repairMenu_construct(struct RepairMenu* self, struct Display* display, struct KeyboardDevice* keyboardDevice, int taskPriority, uint16_t stackSize, Observer repairScreenUpdateObserver)
|
||||
ErrorStatus repairMenu_construct(struct RepairMenu* self, struct Display* display, struct KeyboardDevice* keyboardDevice, struct MemoryDevice* memoryDevice, int taskPriority, uint16_t stackSize, Observer repairScreenUpdateObserver)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
@@ -182,43 +151,35 @@ ErrorStatus repairMenu_construct(struct RepairMenu* self, struct Display* displa
|
||||
}
|
||||
}
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
if (memoryDevice->initialized)
|
||||
{
|
||||
self->memoryDevice = memoryDevice;
|
||||
self->presetStorage.initialized = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
returnValue = ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
if (PCBA_getInstance()->pcba == PCBA_CathodeMCP)
|
||||
{
|
||||
presetArray[0] = &preset1n;
|
||||
presetArray[1] = &preset2n;
|
||||
presetArray[2] = &preset3n;
|
||||
presetArray[3] = &preset4n;
|
||||
presetArray[4] = &preset5n;
|
||||
presetArray[5] = &preset6n;
|
||||
presetArray[6] = &preset7n;
|
||||
presetArray[7] = &preset8n;
|
||||
presetArray[8] = &preset9n;
|
||||
// Loading of presets is done when selecting either Cathode or MCP repair
|
||||
|
||||
}
|
||||
else if (PCBA_getInstance()->pcba == PCBA_Anode)
|
||||
{
|
||||
presetArray[0] = &preset1a;
|
||||
presetArray[1] = &preset2a;
|
||||
presetArray[2] = &preset3a;
|
||||
presetArray[3] = &preset4a;
|
||||
presetArray[4] = &preset5a;
|
||||
presetArray[5] = &preset6a;
|
||||
presetArray[6] = &preset7a;
|
||||
presetArray[7] = &preset8a;
|
||||
presetArray[8] = &preset9a;
|
||||
RepairPresets_loadPresets(REPAIR_PRESETS_ANODE);
|
||||
self->repairPreset = RepairPresets_getPreset(1);
|
||||
}
|
||||
else if (PCBA_getInstance()->pcba == PCBA_Tesla)
|
||||
{
|
||||
presetArray[0] = &preset1t;
|
||||
presetArray[1] = &preset2t;
|
||||
presetArray[2] = &preset3t;
|
||||
presetArray[3] = &preset4t;
|
||||
presetArray[4] = &preset5t;
|
||||
presetArray[5] = &preset6t;
|
||||
presetArray[6] = &preset7t;
|
||||
presetArray[7] = &preset8t;
|
||||
presetArray[8] = &preset9t;
|
||||
RepairPresets_loadPresets(REPAIR_PRESETS_TESLA);
|
||||
self->repairPreset = RepairPresets_getPreset(1);
|
||||
}
|
||||
|
||||
// Construct the menu based on PCBA information
|
||||
@@ -239,7 +200,6 @@ ErrorStatus repairMenu_construct(struct RepairMenu* self, struct Display* displa
|
||||
vSemaphoreCreateBinary(self->repairScreenUpdateSemaphore);
|
||||
self->observer = repairScreenUpdateObserver;
|
||||
self->initialized = true;
|
||||
self->repairPreset = presetArray[0];
|
||||
self->cursorIndex = 1;
|
||||
self->scrollOffset = 0;
|
||||
LOGGER_INFO(mainLog, "Repair Menu task started");
|
||||
@@ -490,6 +450,7 @@ static void repairMenu_printPreset(struct RepairMenu* self)
|
||||
{
|
||||
int loopCounter;
|
||||
char buffer[self->display->displayDevice->parameters.numberOfColumns];
|
||||
// Print the preset information of the current preset under the cursor, NOT the preset that is currently selected
|
||||
snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "Preset %d info", self->cursorIndex);
|
||||
// Always print Row1 (index0), ignoring the scrolling index
|
||||
Display_write(self->display, buffer, 1, 1);
|
||||
@@ -501,15 +462,15 @@ static void repairMenu_printPreset(struct RepairMenu* self)
|
||||
snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "Volt:");
|
||||
Display_write(self->display, buffer, 4, 1);
|
||||
|
||||
for (loopCounter = 0; loopCounter < presetArray[self->cursorIndex - 1]->numberOfStages; loopCounter++)
|
||||
for (loopCounter = 0; loopCounter < RepairPresets_getPreset(self->cursorIndex)->numberOfStages; loopCounter++)
|
||||
{
|
||||
snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "%5dm", (presetArray[self->cursorIndex - 1]->preset[loopCounter].softstartDuration / 60));
|
||||
snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "%5dm", (RepairPresets_getPreset(self->cursorIndex)->preset[loopCounter].softstartDuration / 60));
|
||||
Display_write(self->display, buffer, 2, 8 + loopCounter * 7);
|
||||
|
||||
snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "%5dm", (presetArray[self->cursorIndex - 1]->preset[loopCounter].duration / 60));
|
||||
snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "%5dm", (RepairPresets_getPreset(self->cursorIndex)->preset[loopCounter].duration / 60));
|
||||
Display_write(self->display, buffer, 3, 8 + loopCounter * 7);
|
||||
|
||||
snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "%5dV", presetArray[self->cursorIndex - 1]->preset[loopCounter].voltage);
|
||||
snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "%5dV", RepairPresets_getPreset(self->cursorIndex)->preset[loopCounter].voltage);
|
||||
Display_write(self->display, buffer, 4, 8 + loopCounter * 7);
|
||||
}
|
||||
|
||||
@@ -694,26 +655,29 @@ static void repairMenu_scrollDownIndexHandler(struct RepairMenu* self)
|
||||
|
||||
static void repairMenu_selectCathodeRepair(struct RepairMenu* self, int cursorIndex)
|
||||
{
|
||||
RepairPresets_loadPresets(REPAIR_PRESETS_CATHODE);
|
||||
self->repairPreset = RepairPresets_getPreset(1);
|
||||
CathodeMCP_switchToCathode();
|
||||
}
|
||||
|
||||
|
||||
static void repairMenu_selectMCPRepair(struct RepairMenu* self, int cursorIndex)
|
||||
{
|
||||
RepairPresets_loadPresets(REPAIR_PRESETS_MCP);
|
||||
self->repairPreset = RepairPresets_getPreset(1);
|
||||
CathodeMCP_switchToMCP();
|
||||
}
|
||||
|
||||
|
||||
static void repairMenu_selectPreset(struct RepairMenu* self, int cursorIndex)
|
||||
{
|
||||
self->repairPreset = presetArray[cursorIndex - 1];
|
||||
self->repairPreset = RepairPresets_getPreset(cursorIndex);
|
||||
LOGGER_INFO(mainLog, "Preset %d selected", cursorIndex);
|
||||
|
||||
Display_clearScreen(self->display);
|
||||
char buffer[20];
|
||||
snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "Preset %d", cursorIndex);
|
||||
Display_write(self->display, buffer, 2, 7);
|
||||
Display_write(self->display, "Selected", 3, 6);
|
||||
snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "Preset %d selected", cursorIndex);
|
||||
Display_write(self->display, buffer, 2, 2);
|
||||
vTaskDelay(2000);
|
||||
}
|
||||
|
||||
@@ -919,10 +883,8 @@ static ErrorStatus repairMenu_createMenu(struct RepairMenu* self)
|
||||
repairMenu_addKeyAction_GOTOSTATE(&self->menuArray[PRESETMENU], 'R', PRESSED, RM_PRESET_PRINT);
|
||||
|
||||
repairMenu_createMenuPage(&self->menuArray[RM_PRESET_PRINT], MENU_HAS_NO_CURSOR, 10);
|
||||
repairMenu_addKeyAction_SCROLLUP(&self->menuArray[RM_PRESET_PRINT], 'U', PRESSED);
|
||||
repairMenu_addKeyAction_SCROLLDOWN(&self->menuArray[RM_PRESET_PRINT], 'D', PRESSED);
|
||||
repairMenu_addKeyAction_GOTOSTATE(&self->menuArray[RM_PRESET_PRINT], 'X', PRESSED, PRESETMENU);
|
||||
repairMenu_addKeyAction_GOTOSTATE(&self->menuArray[PRESETMENU], 'L', PRESSED, PRESETMENU);
|
||||
repairMenu_addKeyAction_GOTOSTATE(&self->menuArray[RM_PRESET_PRINT], 'L', PRESSED, PRESETMENU);
|
||||
|
||||
repairMenu_createMenuPage(&self->menuArray[REPAIR_RUNNING], MENU_HAS_NO_CURSOR, 4);
|
||||
repairMenu_addKeyAction_GOTOSTATE(&self->menuArray[REPAIR_RUNNING], 'X', PRESSED, REPAIR_ASK_PAUSE);
|
||||
|
||||
Reference in New Issue
Block a user