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:
@@ -103,4 +103,7 @@ extern ErrorStatus hsb_solenoidLock (void);
|
||||
*/
|
||||
extern ErrorStatus hsb_solenoidUnlock (void);
|
||||
|
||||
|
||||
extern ErrorStatus hsb_enableSafety(void);
|
||||
extern ErrorStatus hsb_disableSafety(void);
|
||||
#endif /* HSB_MRTS_H_ */
|
||||
|
||||
@@ -71,6 +71,7 @@ typedef enum
|
||||
REPAIR_RUNNING,
|
||||
REPAIR_ASK_PAUSE,
|
||||
REPAIR_PAUSE,
|
||||
FINISH_CONTROL,
|
||||
FINISH,
|
||||
ERROR_STATE,
|
||||
WARNING_STATE,
|
||||
|
||||
@@ -94,6 +94,7 @@ struct RepairProcess
|
||||
int TaskPriority;
|
||||
uint16_t stackSize;
|
||||
bool runTask;
|
||||
bool taskIsDeleted;
|
||||
SemaphoreHandle_t secondsSyncronisation;
|
||||
uint32_t startTime;
|
||||
uint32_t secondsCounter;
|
||||
@@ -181,16 +182,16 @@ extern void repairProcess_feedSecondsCounterFromISR(struct RepairProcess* self);
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* repairProcess_getRemainingRepairTime
|
||||
* Returns the currently remaining repair time in a struct Time
|
||||
* Returns the currently remaining repair time in seconds
|
||||
*
|
||||
* @param self The repair process object
|
||||
*
|
||||
* @return struct Time The remaining repair time
|
||||
* @return uint32_t The remaining repair time
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern struct Time repairProcess_getRemainingRepairTime(const struct RepairProcess* self);
|
||||
extern uint32_t repairProcess_getRemainingRepairTime(const struct RepairProcess* self);
|
||||
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
@@ -219,6 +220,6 @@ extern struct RepairProcessRow* repairProcess_getRowInformation(const struct Rep
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern struct Observable* repairProcess_getObservable(struct RepairProcess* self);
|
||||
extern const struct Observable* repairProcess_getObservable(struct RepairProcess* self);
|
||||
|
||||
#endif /* REPAIRPROCESS_H_ */
|
||||
|
||||
@@ -126,6 +126,7 @@ ErrorStatus Display_clearScreen(struct Display* self)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
returnValue = DisplayDevice_clear(self->displayDevice);
|
||||
vTaskDelay(5);
|
||||
Display_clearShadow(self);
|
||||
return returnValue;
|
||||
}
|
||||
@@ -309,6 +310,7 @@ static void DisplayTask(void* parameters)
|
||||
|
||||
size_t rowStart;
|
||||
size_t columnStart;
|
||||
|
||||
while (self->runTask)
|
||||
{
|
||||
// Wait until a write or refresh function has requested this task to write to the display
|
||||
@@ -406,7 +408,7 @@ static void DisplayTask(void* parameters)
|
||||
}
|
||||
|
||||
// Task has been marked to end - after leaving the endless loop, end/delete this task
|
||||
vTaskDelete(self->taskHandle);
|
||||
vTaskDelete(NULL);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -30,8 +30,10 @@
|
||||
#include "hsb-mrts.h"
|
||||
|
||||
#include "Display.h"
|
||||
#include "Error.h"
|
||||
|
||||
#include "platform.h"
|
||||
#include "Interlock.h"
|
||||
#include "Logger.h"
|
||||
#include "PCBA.h"
|
||||
#include "Version.h"
|
||||
@@ -104,3 +106,81 @@ ErrorStatus hsb_solenoidUnlock (void)
|
||||
{
|
||||
return GPIO_setValue(solenoid, true);
|
||||
}
|
||||
|
||||
ErrorStatus hsb_enableSafety(void)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
// 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);
|
||||
returnValue = ERROR;
|
||||
}
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
||||
ErrorStatus hsb_disableSafety(void)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
// Power the circuit
|
||||
if (GPIO_setValue(power6v5Enable, true) != SUCCESS)
|
||||
{
|
||||
Error_postError(POWERENABLE_FAIL);
|
||||
returnValue = ERROR;
|
||||
}
|
||||
|
||||
Interlock_setEXTI(interlock, DISABLE);
|
||||
// TESLA has a second interlock that must be closed
|
||||
if (PCBA_getInstance()->pcba == Tesla)
|
||||
{
|
||||
Interlock_setEXTI(teslalock, DISABLE);
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
@@ -194,6 +194,8 @@ static void initTask(void* parameters)
|
||||
// IRQs are defined here
|
||||
initPlatform();
|
||||
|
||||
// Disable power
|
||||
GPIO_setValue(power6v5Enable, true);
|
||||
|
||||
// Create a small task that only blinks a LED and flashes the identification letter on the display
|
||||
xTaskCreate(ledBlinkTask, (const char* const)"ledTask", 100, &ledTaskArguments, 0, &ledTaskHandle);
|
||||
@@ -229,10 +231,7 @@ static void initTask(void* parameters)
|
||||
// Construct the repair menu
|
||||
repairMenus_construct();
|
||||
|
||||
// Disable power
|
||||
GPIO_setValue(power6v5Enable, false);
|
||||
|
||||
xTaskCreate(printSystemInfoTask, (const char* const)"SysInfoTask", 512, NULL, 0, &sysTaskHandle);
|
||||
// xTaskCreate(printSystemInfoTask, (const char* const)"SysInfoTask", 512, NULL, 0, &sysTaskHandle);
|
||||
|
||||
// Delete this init task
|
||||
vTaskDelete(NULL);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include "stm32f10x.h"
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
#include "queue.h"
|
||||
#include "semphr.h"
|
||||
@@ -91,6 +93,7 @@ ErrorStatus repairProcess_construct(struct RepairProcess* self, struct RepairPro
|
||||
Observable_construct(&self->observable);
|
||||
|
||||
self->initialized = true;
|
||||
self->taskIsDeleted = false;
|
||||
self->isProcessRunning = false;
|
||||
self->repairPreset = preset;
|
||||
self->currentState = PREPARE;
|
||||
@@ -142,9 +145,22 @@ ErrorStatus repairProcess_construct(struct RepairProcess* self, struct RepairPro
|
||||
|
||||
void repairProcess_destruct(struct RepairProcess* self)
|
||||
{
|
||||
|
||||
MAX5715Channel_setValue(self->row[0].dacChannel, 0);
|
||||
MAX5715Channel_setValue(self->row[1].dacChannel, 0);
|
||||
MAX5715Channel_setValue(self->row[2].dacChannel, 0);
|
||||
|
||||
self->runTask = false;
|
||||
// Observable_destruct(&self->observable);
|
||||
// self->initialized = false;
|
||||
while (!self->taskIsDeleted)
|
||||
{
|
||||
vTaskDelay(10);
|
||||
}
|
||||
Observable_destruct(&self->observable);
|
||||
PID_destruct(&self->row[0].pid);
|
||||
PID_destruct(&self->row[1].pid);
|
||||
PID_destruct(&self->row[2].pid);
|
||||
vSemaphoreDelete(self->secondsSyncronisation);
|
||||
self->initialized = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -169,32 +185,25 @@ void repairProcess_feedSecondsCounterFromISR(struct RepairProcess* self)
|
||||
}
|
||||
|
||||
|
||||
struct Time repairProcess_getRemainingRepairTime(const struct RepairProcess* self)
|
||||
uint32_t repairProcess_getRemainingRepairTime(const struct RepairProcess* self)
|
||||
{
|
||||
struct Time returnValue;
|
||||
uint32_t returnValue;
|
||||
|
||||
if ((self->initialized) && (self->isProcessRunning))
|
||||
{
|
||||
uint32_t timeToRemain = self->voltageHoldTimer - self->secondsCounter;
|
||||
if (timeToRemain > 0)
|
||||
if (self->voltageHoldTimer >= self->secondsCounter)
|
||||
{
|
||||
returnValue.hours = (timeToRemain / (60 * 60));
|
||||
returnValue.minutes = (timeToRemain - (returnValue.hours * 60 * 60)) / 60;
|
||||
returnValue.seconds = (timeToRemain - (returnValue.hours * 60 * 60) - (returnValue.minutes * 60));
|
||||
returnValue = (self->voltageHoldTimer - self->secondsCounter);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Prevent underflows
|
||||
returnValue.hours = 0;
|
||||
returnValue.minutes = 0;
|
||||
returnValue.seconds = 0;
|
||||
// ERROR - negative time
|
||||
returnValue = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
returnValue.hours = 99;
|
||||
returnValue.minutes = 99;
|
||||
returnValue.seconds = 99;
|
||||
returnValue = 0xFFFFFFFF;
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
@@ -206,7 +215,7 @@ struct RepairProcessRow* repairProcess_getRowInformation(const struct RepairProc
|
||||
}
|
||||
|
||||
|
||||
struct Observable* repairProcess_getObservable(struct RepairProcess* self)
|
||||
const struct Observable* repairProcess_getObservable(struct RepairProcess* self)
|
||||
{
|
||||
return &self->observable;
|
||||
}
|
||||
@@ -272,7 +281,8 @@ static void repairProcess_task(void* parameters)
|
||||
}
|
||||
|
||||
LOGGER_INFO(mainLog, "Deleting repairProcess task");
|
||||
vTaskDelete(self->taskHandle);
|
||||
self->taskIsDeleted = true;
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -88,6 +88,7 @@ void repairProcesses_abortMainRepairProcess(void)
|
||||
GPIO_setValue(power6v5Enable, true);
|
||||
|
||||
repairProcess_destruct(&mainRepairProcess);
|
||||
Observable_deleteObserver(RTC_getObservable(rtc), repairProcesses_feedMainRepairProcessSecondsCounter);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user