Added calibration setpoints
git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@417 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
@@ -0,0 +1,215 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
/// @file CalibrationParameters.c
|
||||
/// @brief 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) 2018 Micro-Key bv
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/// @file CalibrationParameters.c
|
||||
/// @ingroup {group_name}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "hsb-mrts.h"
|
||||
#include "Error.h"
|
||||
|
||||
#include "CalibrationParameters.h"
|
||||
#include "CalibrationSetpoint.h"
|
||||
#include "CalibrationSetpoints.h"
|
||||
|
||||
#include "CachedStorage.h"
|
||||
#include "crc32.h"
|
||||
|
||||
#include "Logger.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
struct CalibrationParameters
|
||||
{
|
||||
bool initialized;
|
||||
struct CachedStorage cache;
|
||||
struct MemoryDevice* memoryDevice;
|
||||
unsigned int CalibrationSetpointsOffset;
|
||||
};
|
||||
|
||||
struct CalibrationSetpointsStorageClass
|
||||
{
|
||||
uint32_t crc;
|
||||
struct CalibrationSetpoints setpoints;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// File-scope variables
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
static struct CalibrationParameters _self = {.initialized = false, .cache.initialized = false};
|
||||
struct CalibrationParameters* const cpSelf = &_self;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
static void CalibrationParameters_verifyCRCs(void);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
ErrorStatus CalibrationParameters_construct(struct MemoryDevice* memoryDevice)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
if (!cpSelf->initialized)
|
||||
{
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
if (memoryDevice != NULL)
|
||||
{
|
||||
if (memoryDevice->initialized)
|
||||
{
|
||||
cpSelf->memoryDevice = memoryDevice;
|
||||
}
|
||||
else
|
||||
{
|
||||
returnValue = ERROR;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
returnValue = ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
// Create new cachedStorage with preset page number
|
||||
returnValue = CachedStorage_construct(&cpSelf->cache, cpSelf->memoryDevice, APP_FLASH_CALIBRATION_PAGE, sizeof(struct CalibrationSetpointsStorageClass) / 4);
|
||||
}
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
cpSelf->initialized = 0;
|
||||
cpSelf->initialized = true;
|
||||
}
|
||||
|
||||
// Check the CRC on the loaded parameters
|
||||
// If a CRC fails, corrupted data will automatically be replaced with defaults
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
CalibrationParameters_verifyCRCs();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
returnValue = ERROR;
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
||||
void CalibrationParameters_destruct(void)
|
||||
{
|
||||
if (cpSelf->initialized)
|
||||
{
|
||||
cpSelf->cache.initialized = false;
|
||||
cpSelf->initialized = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct CalibrationSetpoints* CalibrationParameters_getCalibrationSetpoints(void)
|
||||
{
|
||||
struct CalibrationSetpoints* returnValue = NULL;
|
||||
if (cpSelf->initialized)
|
||||
{
|
||||
struct CalibrationSetpointsStorageClass* tempValue;
|
||||
tempValue = (struct CalibrationSetpointsStorageClass*)CachedStorage_readBlob(&cpSelf->cache, cpSelf->CalibrationSetpointsOffset);
|
||||
returnValue = &tempValue->setpoints;
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
||||
ErrorStatus CalibrationParameters_setCalibrationSetpoints(struct CalibrationSetpoints* setpoints)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
if (cpSelf->initialized)
|
||||
{
|
||||
struct CalibrationSetpointsStorageClass tempStorage;
|
||||
tempStorage.setpoints = *setpoints;
|
||||
// Calculate CRC over preset
|
||||
tempStorage.crc = crc32_calculate(0, &tempStorage.setpoints, sizeof(struct CalibrationSetpoints));
|
||||
// Put default preset on Cache
|
||||
CachedStorage_writeBlob(&cpSelf->cache, cpSelf->CalibrationSetpointsOffset, &tempStorage, sizeof(struct CalibrationSetpointsStorageClass) / 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
returnValue = ERROR;
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
||||
void CalibrationParameters_saveParameters(void)
|
||||
{
|
||||
if (cpSelf->initialized)
|
||||
{
|
||||
// Commit cache to memory - will not write if no changes have been made
|
||||
CachedStorage_commit(&cpSelf->cache);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void CalibrationParameters_verifyCRCs(void)
|
||||
{
|
||||
uint32_t tempCRC;
|
||||
if (cpSelf->initialized)
|
||||
{
|
||||
// PID PARAMETERS CHECK
|
||||
struct CalibrationSetpointsStorageClass _tempParameters;
|
||||
struct CalibrationSetpointsStorageClass* tempParameters = &_tempParameters;
|
||||
tempParameters = (struct CalibrationSetpointsStorageClass*)CachedStorage_readBlob(&cpSelf->cache, cpSelf->CalibrationSetpointsOffset);
|
||||
|
||||
// Calculate the CRC of the parameters
|
||||
tempCRC = crc32_calculate(0, &tempParameters->setpoints, sizeof(struct CalibrationSetpoints));
|
||||
// Compare CRC
|
||||
if (tempCRC != tempParameters->crc)
|
||||
{
|
||||
Error_postError(ERROR_CRC_CALIBRATION);
|
||||
// CRC do not match
|
||||
LOGGER_ERROR(mainLog, "CRC ERROR at Calibration Parameters (calculated %X but loaded %X)", (unsigned int)tempCRC, (unsigned int)tempParameters->crc);
|
||||
// Replace corrupt Device parameters with defaults
|
||||
CalibrationSetpoints_generateDefaultParameters(&tempParameters->setpoints);
|
||||
// Write parameters to cache including the CRC (calculated inside write function)
|
||||
CalibrationParameters_setCalibrationSetpoints(&tempParameters->setpoints);
|
||||
}
|
||||
|
||||
CalibrationParameters_saveParameters();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
/// @file CalibrationSetpoint.c
|
||||
/// @brief 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) 2018 Micro-Key bv
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/// @file CalibrationSetpoint.c
|
||||
/// @ingroup {group_name}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include "CalibrationSetpoint.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// File-scope variables
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
void CalibrationSetpoint_setLowSetpoint(struct CalibrationSetpoint* self, int lowSetpoint)
|
||||
{
|
||||
self->low = lowSetpoint;
|
||||
}
|
||||
|
||||
|
||||
void CalibrationSetpoint_setHighSetpoint(struct CalibrationSetpoint* self, int highSetpoint)
|
||||
{
|
||||
self->high = highSetpoint;
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
/// @file CalibrationSetpoints.c
|
||||
/// @brief 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) 2018 Micro-Key bv
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/// @file CalibrationSetpoints.c
|
||||
/// @ingroup {group_name}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include "CalibrationSetpoints.h"
|
||||
|
||||
#include "PCBA.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#define CATHODE_LOW (200)
|
||||
#define CATHODE_HIGH (1000)
|
||||
|
||||
#define MCP_LOW (500)
|
||||
#define MCP_HIGH (2000)
|
||||
|
||||
#define TESLA_LOW (3000)
|
||||
#define TESLA_HIGH (6000)
|
||||
|
||||
#define ANODE_LOW (6000)
|
||||
#define ANODE_HIGH (10000)
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// File-scope variables
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void CalibrationSetpoints_generateDefaultParameters(struct CalibrationSetpoints* self)
|
||||
{
|
||||
self->setpoints[CALIBRATION_SETPOINT_CATHODE].low = CATHODE_LOW;
|
||||
self->setpoints[CALIBRATION_SETPOINT_CATHODE].high = CATHODE_HIGH;
|
||||
|
||||
self->setpoints[CALIBRATION_SETPOINT_MCP].low = MCP_LOW;
|
||||
self->setpoints[CALIBRATION_SETPOINT_MCP].high = MCP_HIGH;
|
||||
|
||||
self->setpoints[CALIBRATION_SETPOINT_TESLA].low = TESLA_LOW;
|
||||
self->setpoints[CALIBRATION_SETPOINT_TESLA].high = TESLA_HIGH;
|
||||
|
||||
self->setpoints[CALIBRATION_SETPOINT_ANODE].low = ANODE_LOW;
|
||||
self->setpoints[CALIBRATION_SETPOINT_ANODE].high = ANODE_HIGH;
|
||||
}
|
||||
|
||||
|
||||
struct CalibrationSetpoint* CalibrationSetpoints_getSetpoint(struct CalibrationSetpoints* self, enum CALIBRATION_SETPOINT_ID setpointIdentifier)
|
||||
{
|
||||
return &self->setpoints[setpointIdentifier];
|
||||
}
|
||||
|
||||
|
||||
void CalibrationSetpoints_setActiveSetpointSet(struct CalibrationSetpoints* self, enum CALIBRATION_SETPOINT_ID setpointIdentifier)
|
||||
{
|
||||
self->currentActiveSetpointSet = setpointIdentifier;
|
||||
}
|
||||
|
||||
|
||||
struct CalibrationSetpoint* CalibrationSetpoints_getActiveSetpointSet(struct CalibrationSetpoints* self)
|
||||
{
|
||||
return &self->setpoints[self->currentActiveSetpointSet];
|
||||
}
|
||||
@@ -11,9 +11,9 @@
|
||||
// Email: support@microkey.nl
|
||||
// Web: www.microkey.nl
|
||||
// -----------------------------------------------------------------------------
|
||||
/// $Revision: $
|
||||
/// $Author: $
|
||||
/// $Date: $
|
||||
/// $Revision$
|
||||
/// $Author$
|
||||
/// $Date$
|
||||
// (c) 2017 Micro-Key bv
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
@@ -72,9 +72,10 @@ struct PINStorageClass
|
||||
// -----------------------------------------------------------------------------
|
||||
// File-scope variables
|
||||
// -----------------------------------------------------------------------------
|
||||
static struct CachedStorage deviceParameters = {.initialized = false};
|
||||
|
||||
static struct DeviceParameters _dParam = {.initialized = false};
|
||||
struct DeviceParameters* const dParam = &_dParam;
|
||||
static struct DeviceParameters _dParam = {.initialized = false, .parametersStorage = &deviceParameters};
|
||||
struct DeviceParameters* const dParam = &_dParam;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
@@ -86,23 +87,12 @@ static void DeviceParameters_verifyCRCs(void);
|
||||
// Function definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
ErrorStatus DeviceParameters_construct(struct CachedStorage* parametersStorage, struct MemoryDevice* memoryDevice)
|
||||
ErrorStatus DeviceParameters_construct(struct MemoryDevice* memoryDevice)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
if (!dParam->initialized)
|
||||
{
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
if (parametersStorage != NULL)
|
||||
{
|
||||
dParam->parametersStorage = parametersStorage;
|
||||
}
|
||||
else
|
||||
{
|
||||
returnValue = ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
|
||||
@@ -65,8 +65,9 @@ struct RepairPresetStorageClass
|
||||
// -----------------------------------------------------------------------------
|
||||
// File-scope variables
|
||||
// -----------------------------------------------------------------------------
|
||||
static struct CachedStorage cache = {.initialized = false};
|
||||
|
||||
static struct RepairPresets _self = {.initialized = false, .presetsLoaded = false};
|
||||
static struct RepairPresets _self = {.initialized = false, .presetStorage = &cache, .presetsLoaded = false};
|
||||
struct RepairPresets* const self = &_self;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -81,23 +82,11 @@ static ErrorStatus RepairPresets_verifyPresetCRC(struct RepairPresetStorageClass
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
ErrorStatus RepairPresets_construct(struct CachedStorage* presetStorage, struct MemoryDevice* memoryDevice)
|
||||
ErrorStatus RepairPresets_construct(struct MemoryDevice* memoryDevice)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
if (!self->initialized)
|
||||
{
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
if (presetStorage != NULL)
|
||||
{
|
||||
self->presetStorage = presetStorage;
|
||||
}
|
||||
else
|
||||
{
|
||||
returnValue = ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
if (memoryDevice != NULL)
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
|
||||
#include "ADConverters.h"
|
||||
#include "DAConverters.h"
|
||||
#include "CalibrationParameters.h"
|
||||
#include "DeviceParameters.h"
|
||||
#include "Displays.h"
|
||||
#include "Error.h"
|
||||
@@ -101,8 +102,6 @@ static struct HwValidationMenuItems hwTestItems;
|
||||
struct HwValidationMenu* hwValidation = &_hwValidation;
|
||||
#endif
|
||||
|
||||
static struct CachedStorage cs = {.initialized = false};
|
||||
static struct CachedStorage deviceParameters = {.initialized = false};
|
||||
|
||||
//static char taskList[600];
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -272,13 +271,19 @@ static void initTask(void* parameters)
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
// Construct/Load the device parameters
|
||||
returnValue = DeviceParameters_construct(&deviceParameters, &iFlash->memoryDevice);
|
||||
returnValue = DeviceParameters_construct(&iFlash->memoryDevice);
|
||||
}
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
// Construct/Load the device calibration parameters
|
||||
returnValue = CalibrationParameters_construct(&iFlash->memoryDevice);
|
||||
}
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
// Construct the repair presets
|
||||
returnValue = RepairPresets_construct(&cs, &iFlash->memoryDevice);
|
||||
returnValue = RepairPresets_construct(&iFlash->memoryDevice);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_HW_VALIDATION
|
||||
|
||||
@@ -33,6 +33,10 @@
|
||||
#include "PIDParameters.h"
|
||||
#include "PowerLossDetector.h"
|
||||
#include "repairMenu.h"
|
||||
|
||||
#include "CalibrationParameters.h"
|
||||
#include "CalibrationSetpoint.h"
|
||||
#include "CalibrationSetpoints.h"
|
||||
#include "repairMenus.h"
|
||||
#include "RepairPreset.h"
|
||||
#include "repairProcess.h"
|
||||
@@ -135,6 +139,8 @@ static void repairMenu_configPID(struct MenuCore* self);
|
||||
static void repairMenu_configConfirmPIDKp(struct MenuCore* self);
|
||||
static void repairMenu_configConfirmPIDKi(struct MenuCore* self);
|
||||
static void repairMenu_configConfirmPIDKd(struct MenuCore* self);
|
||||
static void repairMenu_setDACToLowSetpoint(struct MenuCore* self);
|
||||
static void repairMenu_setDACToHighSetpoint(struct MenuCore* self);
|
||||
static void repairMenu_printPINVerification(struct MenuCore* self);
|
||||
static void repairMenu_printVoltageOutput(struct MenuCore* self);
|
||||
static void repairMenu_printPIDConstants(struct MenuCore* self);
|
||||
@@ -142,7 +148,9 @@ static void repairMenu_printInfo(struct MenuCore* self);
|
||||
static void repairMenu_confirmCalibrationPin(struct MenuCore* self);
|
||||
|
||||
static void repairMenu_selectCathodeRepair(struct MenuCore* self);
|
||||
static void repairMenu_selectCathodeCalibration(struct MenuCore* self);
|
||||
static void repairMenu_selectMCPRepair(struct MenuCore* self);
|
||||
static void repairMenu_selectMCPCalibration(struct MenuCore* self);
|
||||
static void repairMenu_selectPreset(struct MenuCore* self);
|
||||
static void repairMenu_solenoidLock(struct MenuCore* self);
|
||||
static void repairMenu_solenoidUnlock(struct MenuCore* self);
|
||||
@@ -286,6 +294,10 @@ void repairMenu_printCRCFailure(struct RepairMenu* self, T_ErrorCode errorCode)
|
||||
{
|
||||
snprintf(self->menuCore->errorMessage, sizeof(self->menuCore->errorMessage) / sizeof(self->menuCore->errorMessage[0]), MenuText_ERROR_CRC_PARAMETERS[languageIndex]);
|
||||
}
|
||||
else if (errorCode == ERROR_CRC_CALIBRATION)
|
||||
{
|
||||
snprintf(self->menuCore->errorMessage, sizeof(self->menuCore->errorMessage) / sizeof(self->menuCore->errorMessage[0]), MenuText_ERROR_CRC_CALIBRATION[languageIndex]);
|
||||
}
|
||||
else if (errorCode == ERROR_CRC_PRESETS)
|
||||
{
|
||||
snprintf(self->menuCore->errorMessage, sizeof(self->menuCore->errorMessage) / sizeof(self->menuCore->errorMessage[0]), MenuText_ERROR_CRC_PRESETS[languageIndex]);
|
||||
@@ -807,6 +819,33 @@ static void repairMenu_configConfirmPIDKd(struct MenuCore* self)
|
||||
}
|
||||
|
||||
|
||||
static void repairMenu_setDACToLowSetpoint(struct MenuCore* self)
|
||||
{
|
||||
struct CalibrationSetpoints* tempSetpoints = CalibrationParameters_getCalibrationSetpoints();
|
||||
struct CalibrationSetpoint* tempSetpoint = CalibrationSetpoints_getActiveSetpointSet(tempSetpoints);
|
||||
|
||||
if (PCBA_getInstance()->pcba != PCBA_Tesla)
|
||||
{
|
||||
DAConverter_setOutputVoltage(dacRow1, tempSetpoint->low);
|
||||
DAConverter_setOutputVoltage(dacRow3, tempSetpoint->low);
|
||||
}
|
||||
DAConverter_setOutputVoltage(dacRow2, tempSetpoint->low);
|
||||
}
|
||||
|
||||
|
||||
static void repairMenu_setDACToHighSetpoint(struct MenuCore* self)
|
||||
{
|
||||
struct CalibrationSetpoints* tempSetpoints = CalibrationParameters_getCalibrationSetpoints();
|
||||
struct CalibrationSetpoint* tempSetpoint = CalibrationSetpoints_getActiveSetpointSet(tempSetpoints);
|
||||
|
||||
if (PCBA_getInstance()->pcba != PCBA_Tesla)
|
||||
{
|
||||
DAConverter_setOutputVoltage(dacRow1, tempSetpoint->high);
|
||||
DAConverter_setOutputVoltage(dacRow3, tempSetpoint->high);
|
||||
}
|
||||
DAConverter_setOutputVoltage(dacRow2, tempSetpoint->high);
|
||||
}
|
||||
|
||||
static void repairMenu_printAdminVoltageInput(struct MenuCore* self)
|
||||
{
|
||||
char buffer[self->display->displayDevice->parameters.numberOfColumns + 1];
|
||||
@@ -934,20 +973,45 @@ static void repairMenu_confirmCalibrationPin(struct MenuCore* self)
|
||||
static void repairMenu_selectCathodeRepair(struct MenuCore* self)
|
||||
{
|
||||
RepairPresets_loadPresets(REPAIR_PRESETS_CATHODE);
|
||||
struct RepairMenu* tempMenu = repairMenus_getMainRepairMenu();
|
||||
tempMenu->repairPreset = RepairPresets_getPreset(1);
|
||||
// struct RepairMenu* tempMenu = repairMenus_getMainRepairMenu();
|
||||
// tempMenu->repairPreset = RepairPresets_getPreset(1);
|
||||
CathodeMCP_switchToCathode();
|
||||
}
|
||||
|
||||
static void repairMenu_selectPCBACalibration(struct MenuCore* self)
|
||||
{
|
||||
struct CalibrationSetpoints* tempSetpoints = CalibrationParameters_getCalibrationSetpoints();
|
||||
if (PCBA_getInstance()->pcba == PCBA_Anode)
|
||||
{
|
||||
CalibrationSetpoints_setActiveSetpointSet(tempSetpoints, CALIBRATION_SETPOINT_ANODE);
|
||||
}
|
||||
else if (PCBA_getInstance()->pcba == PCBA_Tesla)
|
||||
{
|
||||
CalibrationSetpoints_setActiveSetpointSet(tempSetpoints, CALIBRATION_SETPOINT_TESLA);
|
||||
}
|
||||
}
|
||||
|
||||
static void repairMenu_selectCathodeCalibration(struct MenuCore* self)
|
||||
{
|
||||
struct CalibrationSetpoints* tempSetpoints = CalibrationParameters_getCalibrationSetpoints();
|
||||
CalibrationSetpoints_setActiveSetpointSet(tempSetpoints, CALIBRATION_SETPOINT_CATHODE);
|
||||
}
|
||||
|
||||
|
||||
static void repairMenu_selectMCPRepair(struct MenuCore* self)
|
||||
{
|
||||
RepairPresets_loadPresets(REPAIR_PRESETS_MCP);
|
||||
struct RepairMenu* tempMenu = repairMenus_getMainRepairMenu();
|
||||
tempMenu->repairPreset = RepairPresets_getPreset(1);
|
||||
// struct RepairMenu* tempMenu = repairMenus_getMainRepairMenu();
|
||||
// tempMenu->repairPreset = RepairPresets_getPreset(1);
|
||||
CathodeMCP_switchToMCP();
|
||||
}
|
||||
|
||||
static void repairMenu_selectMCPCalibration(struct MenuCore* self)
|
||||
{
|
||||
struct CalibrationSetpoints* tempSetpoints = CalibrationParameters_getCalibrationSetpoints();
|
||||
CalibrationSetpoints_setActiveSetpointSet(tempSetpoints, CALIBRATION_SETPOINT_MCP);
|
||||
}
|
||||
|
||||
|
||||
static void repairMenu_selectPreset(struct MenuCore* self)
|
||||
{
|
||||
@@ -1568,6 +1632,16 @@ void repairMenu_menuStateHandle(struct MenuCore* self)
|
||||
Display_writeCentered(self->display, MenuText_VOLTAGE_OUT_CLEANUP[languageIndex][1], 4);
|
||||
|
||||
}
|
||||
|
||||
else if (self->menuState == RM_CALIBRATION_SETPOINT_LOW)
|
||||
{
|
||||
repairMenu_printVoltageOutput(self);
|
||||
}
|
||||
|
||||
else if (self->menuState == RM_CALIBRATION_SETPOINT_HIGH)
|
||||
{
|
||||
repairMenu_printVoltageOutput(self);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2247,12 +2321,73 @@ void repairMenu_createMenuEntries(struct MenuCore* menuCore)
|
||||
|
||||
|
||||
|
||||
MenuElements_createMenuPage(&menuCore->menuArray[RM_CALIBRATIONMENU], MENU_HAS_NO_CURSOR, 2);
|
||||
MenuElements_createMenuPage(&menuCore->menuArray[RM_CALIBRATIONMENU], MENU_HAS_CURSOR, 2);
|
||||
MenuElements_addMenuPageRow(&menuCore->menuArray[RM_CALIBRATIONMENU], MenuText_CALIBRATIONMENU[languageIndex][0], RM_CALIBRATIONMENU, NULL);
|
||||
MenuElements_addMenuPageRow(&menuCore->menuArray[RM_CALIBRATIONMENU], MenuText_CALIBRATIONMENU[languageIndex][1], RM_CALIBRATIONMENU, NULL);
|
||||
if (PCBA_getInstance()->pcba == PCBA_CathodeMCP)
|
||||
{
|
||||
// For Cathode/MCP PCBA, the type of repair must be selected first
|
||||
MenuElements_addMenuPageRow(&menuCore->menuArray[RM_CALIBRATIONMENU], MenuText_CALIBRATIONMENU[languageIndex][1], RM_CALIBRATION_CATHOEMCP_SELECT, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
MenuElements_addMenuPageRow(&menuCore->menuArray[RM_CALIBRATIONMENU], MenuText_CALIBRATIONMENU[languageIndex][1], RM_CALIBRATION_SETPOINT_MENU, repairMenu_selectPCBACalibration);
|
||||
}
|
||||
|
||||
|
||||
MenuElements_addKeyAction_SCROLLUP(&menuCore->menuArray[RM_CALIBRATIONMENU], 'U', PRESSED);
|
||||
MenuElements_addKeyAction_SCROLLDOWN(&menuCore->menuArray[RM_CALIBRATIONMENU], 'D', PRESSED);
|
||||
MenuElements_addKeyAction_SELECT(&menuCore->menuArray[RM_CALIBRATIONMENU], 'E', PRESSED);
|
||||
MenuElements_addKeyAction_HOTKEYSELECT(&menuCore->menuArray[RM_CALIBRATIONMENU], '1', PRESSED, 1);
|
||||
MenuElements_addKeyAction_GOTOSTATE(&menuCore->menuArray[RM_CALIBRATIONMENU], 'X', PRESSED, RM_MAINMENU);
|
||||
|
||||
|
||||
/* -------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
* Cathode / MCP selection
|
||||
* This screen is only required for CATHODE/MCP PCBAs and allows selection between these two repair methods
|
||||
*
|
||||
* Key '0' allows control of the Solenoids - Hold to open, release to close
|
||||
* -------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
MenuElements_createMenuPage(&menuCore->menuArray[RM_CALIBRATION_CATHOEMCP_SELECT], MENU_HAS_CURSOR, 4);
|
||||
MenuElements_addMenuPageRow(&menuCore->menuArray[RM_CALIBRATION_CATHOEMCP_SELECT], MenuText_CATHODEMCP_SELECT[languageIndex][0], RM_CALIBRATION_CATHOEMCP_SELECT, NULL);
|
||||
MenuElements_addMenuPageRow(&menuCore->menuArray[RM_CALIBRATION_CATHOEMCP_SELECT], MenuText_CATHODEMCP_SELECT[languageIndex][1], RM_CALIBRATION_SETPOINT_MENU, repairMenu_selectCathodeCalibration);
|
||||
MenuElements_addMenuPageRow(&menuCore->menuArray[RM_CALIBRATION_CATHOEMCP_SELECT], MenuText_CATHODEMCP_SELECT[languageIndex][2], RM_CALIBRATION_SETPOINT_MENU, repairMenu_selectMCPCalibration);
|
||||
MenuElements_addKeyAction_SCROLLUP(&menuCore->menuArray[RM_CALIBRATION_CATHOEMCP_SELECT], 'U', PRESSED);
|
||||
MenuElements_addKeyAction_SCROLLDOWN(&menuCore->menuArray[RM_CALIBRATION_CATHOEMCP_SELECT], 'D', PRESSED);
|
||||
MenuElements_addKeyAction_SELECT(&menuCore->menuArray[RM_CALIBRATION_CATHOEMCP_SELECT], 'E', PRESSED);
|
||||
MenuElements_addKeyAction_HOTKEYSELECT(&menuCore->menuArray[RM_CALIBRATION_CATHOEMCP_SELECT], '1', PRESSED, 1);
|
||||
MenuElements_addKeyAction_HOTKEYSELECT(&menuCore->menuArray[RM_CALIBRATION_CATHOEMCP_SELECT], '2', PRESSED, 2);
|
||||
MenuElements_addKeyAction_GOTOSTATE(&menuCore->menuArray[RM_CALIBRATION_CATHOEMCP_SELECT], 'X', PRESSED, RM_CALIBRATIONMENU);
|
||||
|
||||
/* -------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
* Calibration setpoint selection
|
||||
* -------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
MenuElements_createMenuPage(&menuCore->menuArray[RM_CALIBRATION_SETPOINT_MENU], MENU_HAS_CURSOR, 3);
|
||||
MenuElements_addMenuPageRow(&menuCore->menuArray[RM_CALIBRATION_SETPOINT_MENU], MenuText_CALIBRATION_SETPOINTMENU[languageIndex][0], RM_CALIBRATION_SETPOINT_MENU, NULL);
|
||||
MenuElements_addMenuPageRow(&menuCore->menuArray[RM_CALIBRATION_SETPOINT_MENU], MenuText_CALIBRATION_SETPOINTMENU[languageIndex][1], RM_CALIBRATION_SETPOINT_LOW, repairMenu_setDACToLowSetpoint);
|
||||
MenuElements_addMenuPageRow(&menuCore->menuArray[RM_CALIBRATION_SETPOINT_MENU], MenuText_CALIBRATION_SETPOINTMENU[languageIndex][2], RM_CALIBRATION_SETPOINT_HIGH, repairMenu_setDACToHighSetpoint);
|
||||
MenuElements_addKeyAction_SCROLLUP(&menuCore->menuArray[RM_CALIBRATION_SETPOINT_MENU], 'U', PRESSED);
|
||||
MenuElements_addKeyAction_SCROLLDOWN(&menuCore->menuArray[RM_CALIBRATION_SETPOINT_MENU], 'D', PRESSED);
|
||||
MenuElements_addKeyAction_SELECT(&menuCore->menuArray[RM_CALIBRATION_SETPOINT_MENU], 'E', PRESSED);
|
||||
MenuElements_addKeyAction_HOTKEYSELECT(&menuCore->menuArray[RM_CALIBRATION_SETPOINT_MENU], '1', PRESSED, 1);
|
||||
MenuElements_addKeyAction_HOTKEYSELECT(&menuCore->menuArray[RM_CALIBRATION_SETPOINT_MENU], '2', PRESSED, 2);
|
||||
MenuElements_addKeyAction_GOTOSTATE(&menuCore->menuArray[RM_CALIBRATION_SETPOINT_MENU], 'X', PRESSED, RM_CALIBRATIONMENU);
|
||||
|
||||
/* -------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
* Calibration LOW setpoint
|
||||
* -------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
MenuElements_createMenuPage(&menuCore->menuArray[RM_CALIBRATION_SETPOINT_LOW], MENU_HAS_NO_CURSOR, 3);
|
||||
MenuElements_addKeyAction_GOTOSTATE(&menuCore->menuArray[RM_CALIBRATION_SETPOINT_LOW], 'X', PRESSED, RM_CALIBRATION_SETPOINT_MENU);
|
||||
|
||||
/* -------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
* Calibration HIGH setpoint
|
||||
* -------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
MenuElements_createMenuPage(&menuCore->menuArray[RM_CALIBRATION_SETPOINT_HIGH], MENU_HAS_NO_CURSOR, 3);
|
||||
MenuElements_addKeyAction_GOTOSTATE(&menuCore->menuArray[RM_CALIBRATION_SETPOINT_HIGH], 'X', PRESSED, RM_CALIBRATION_SETPOINT_MENU);
|
||||
|
||||
MenuElements_createMenuPage(&menuCore->menuArray[RM_REPAIR_RUNNING], MENU_HAS_NO_CURSOR, 4);
|
||||
MenuElements_addKeyAction_GOTOSTATE(&menuCore->menuArray[RM_REPAIR_RUNNING], 'X', PRESSED, RM_REPAIR_ASK_PAUSE);
|
||||
|
||||
|
||||
@@ -149,6 +149,7 @@ static ErrorStatus repairMenus_errorReceive(const void* const data)
|
||||
}
|
||||
case ERROR_CRC_PIN:
|
||||
case ERROR_CRC_PARAMETERS:
|
||||
case ERROR_CRC_CALIBRATION:
|
||||
case ERROR_CRC_PRESETS:
|
||||
{
|
||||
repairMenu_printCRCFailure(mainMenu, errorCode);
|
||||
|
||||
Reference in New Issue
Block a user