Fixed several issues:

- ADC has now averaging
- Pause screen added
- Fixed display glitches for most parts

git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@258 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
mmi
2017-10-19 15:24:24 +00:00
parent 51ffde94d7
commit 92bd68d8ba
18 changed files with 257 additions and 99 deletions

View File

@@ -52,6 +52,7 @@
#define MENU_HAS_CURSOR (true)
#define MENU_HAS_NO_CURSOR (false)
#define REPAIRMENU_POPUPSCREEN_TIME (3)
// -----------------------------------------------------------------------------
// Type definitions
@@ -103,6 +104,7 @@ static void repairMenu_solenoidLock(struct RepairMenu* self, int cursorIndex);
static void repairMenu_solenoidUnlock(struct RepairMenu* self, int cursorIndex);
static void repairMenu_startRepairProcess(struct RepairMenu* self, int cursorIndex);
static void repairMenu_stopRepairProcess(struct RepairMenu* self, int cursorIndex);
static void repairMenu_abortRepairProcessAndGotoMainMenu(struct RepairMenu* self, int cursorIndex);
static ErrorStatus repairMenu_createMenu(struct RepairMenu* self);
static ErrorStatus repairMenu_createMenuPage (struct MenuPage* self, bool hasCursor, int maxNumberOfRows);
@@ -218,6 +220,8 @@ static void repairMenu_task(void* parameters)
repairMenu_printMenu(self);
// Add cursor if necessary
repairMenu_printCursor(self);
int tempScreenCounter;
T_MenuState tempMenuState;
while(self->runTask)
{
@@ -239,11 +243,16 @@ static void repairMenu_task(void* parameters)
else if (self->menuState == REPAIR_RUNNING)
{
// Check the remaining repair time
struct Time remainingTime = repairProcess_getRemainingRepairTime(repairProcesses_getMainRepairProcess());
if ((remainingTime.hours == 0) && (remainingTime.minutes == 0) && (remainingTime.seconds == 0))
uint32_t remainingTime = repairProcess_getRemainingRepairTime(repairProcesses_getMainRepairProcess());
if (remainingTime > REPAIRMENU_POPUPSCREEN_TIME)
{
tempScreenCounter = remainingTime - REPAIRMENU_POPUPSCREEN_TIME;
tempMenuState = self->menuState;
}
if (remainingTime == 0)
{
// repair is finished
repairMenu_changeState(self, FINISH);
repairMenu_changeState(self, FINISH_CONTROL);
}
else
{
@@ -253,15 +262,26 @@ static void repairMenu_task(void* parameters)
}
else if (self->menuState == REPAIR_ASK_PAUSE)
{
uint32_t remainingTime = repairProcess_getRemainingRepairTime(repairProcesses_getMainRepairProcess());
if (tempScreenCounter >= remainingTime)
{
// POPUP screen time is over, return to previous state
repairMenu_changeState(self, tempMenuState);
}
repairMenu_printAskPause(self);
}
else if (self->menuState == REPAIR_PAUSE)
{
repairMenu_printPause(self);
}
else if (self->menuState == FINISH)
else if (self->menuState == FINISH_CONTROL)
{
repairMenu_stopRepairProcess(self, 0);
repairMenu_changeState(self, FINISH);
}
else if (self->menuState == FINISH)
{
repairMenu_printFinish(self);
}
@@ -317,9 +337,10 @@ static void repairMenu_printRepair(struct RepairMenu* self)
}
else
{
struct Time remainingTime = repairProcess_getRemainingRepairTime(repairProcesses_getMainRepairProcess());
struct Time remainingTime;
RTC_calculateTimeFromSeconds(repairProcess_getRemainingRepairTime(repairProcesses_getMainRepairProcess()), &remainingTime);
snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), " %02d:%02d:%02d remain", remainingTime.hours, remainingTime.minutes, remainingTime.seconds);
snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), " %02d:%02d:%02d remain ", remainingTime.hours, remainingTime.minutes, remainingTime.seconds);
Display_write(self->display, buffer, strlen(buffer), 1, 1);
// Regulation is unique for each row
@@ -346,7 +367,7 @@ static void repairMenu_printRepair(struct RepairMenu* self)
static void repairMenu_printAskPause(struct RepairMenu* self)
{
Display_write(self->display, "REPAIR BUSY", strlen("REPAIR BUSY"), 2, 6);
Display_write(self->display, "Hit X to RESET", strlen("Hit X to RESET"), 3, 2);
Display_write(self->display, "Hit X to PAUSE", strlen("Hit X to RESET"), 3, 2);
}
@@ -571,58 +592,19 @@ static void repairMenu_startRepairProcess(struct RepairMenu* self, int cursorInd
self->rpParameters.dacRow2 = &max5715->dac[1];
self->rpParameters.dacRow3 = &max5715->dac[2];
// First, Lock the cover
if (returnValue == SUCCESS)
{
hsb_solenoidLock();
}
if (returnValue == SUCCESS)
{
// Check for INTERLOCK CLOSE
if (Interlock_isClosed(interlock))
{
// Enable Interrupt for interlock switch
Interlock_setEXTI(interlock, ENABLE);
}
else
{
Error_postError(INTERLOCK_COMMON_FAIL);
returnValue = ERROR;
}
}
if (returnValue == SUCCESS)
{
// TESLA has a second interlock that must be closed
if (PCBA_getInstance()->pcba == Tesla)
{
if (Interlock_isClosed(teslalock))
{
// Enable Interrupt for tesla interlock switch
Interlock_setEXTI(teslalock, ENABLE);
}
else
{
Error_postError(INTERLOCK_TESLA_FAIL);
returnValue = ERROR;
}
}
}
// if Interlock(s) closed, continue procedure
if (returnValue == SUCCESS)
{
// Power the circuit
if (GPIO_setValue(power6v5Enable, false) != SUCCESS)
{
Error_postError(POWERENABLE_FAIL);
}
// Enable all safety features of the HSB setup
returnValue = hsb_enableSafety();
}
if (returnValue == SUCCESS)
{
// For MCP/Cathode, the right settings must be made
if (PCBA_getInstance()->pcba == CathodeMCP)
{
}
///TODO
}
@@ -652,6 +634,14 @@ static void repairMenu_stopRepairProcess(struct RepairMenu* self, int cursorInde
{
repairProcesses_mainRepairProcessRemoveObserver(self->observer);
repairProcesses_abortMainRepairProcess();
hsb_disableSafety();
}
static void repairMenu_abortRepairProcessAndGotoMainMenu(struct RepairMenu* self, int cursorIndex)
{
repairMenu_stopRepairProcess(self, cursorIndex);
repairMenu_changeState(self, MAINMENU);
}
@@ -733,6 +723,7 @@ static ErrorStatus repairMenu_createMenu(struct RepairMenu* self)
repairMenu_addKeyAction_GOTOSTATE(&self->menuArray[REPAIR_ASK_PAUSE], 'X', PRESSED, REPAIR_PAUSE);
repairMenu_createMenuPage(&self->menuArray[REPAIR_PAUSE], MENU_HAS_NO_CURSOR, 4);
repairMenu_addKeyAction_EXECUTEFUNCTION(&self->menuArray[REPAIR_PAUSE], 'X', PRESSED, repairMenu_abortRepairProcessAndGotoMainMenu);
repairMenu_addKeyAction_GOTOSTATE(&self->menuArray[REPAIR_PAUSE], 'E', PRESSED, REPAIR_RUNNING);
repairMenu_createMenuPage(&self->menuArray[FINISH], MENU_HAS_NO_CURSOR, 4);