diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/inc/CachedStorage.h b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/inc/CachedStorage.h index 3bb0d9f..a2ad04f 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/inc/CachedStorage.h +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/inc/CachedStorage.h @@ -53,11 +53,11 @@ struct CachedStorage { bool initialized; unsigned int pageNumber; - unsigned int cacheSize; + size_t cacheSize; bool dirty; struct MemoryDevice* memoryDevice; - uint8_t storage[CACHED_STORAGE_PAGESIZE * 4]; // Times 4 to get 32bit width - uint8_t tempBuffer[CACHED_STORAGE_PAGESIZE * 4]; // Times 4 to get 32bit width + uint32_t* storage; + uint32_t* tempBuffer; }; // ----------------------------------------------------------------------------- @@ -68,23 +68,13 @@ struct CachedStorage /** * Initializes the EEPROM hardware and reads the flash page */ -ErrorStatus CachedStorage_construct(struct CachedStorage* self, struct MemoryDevice* memoryDevice, unsigned int pageNumber); +ErrorStatus CachedStorage_construct(struct CachedStorage* self, struct MemoryDevice* memoryDevice, unsigned int pageNumber, size_t cacheSize); /** * Terminates the EEPROM hardware. SPI port is available again */ void CachedStorage_destruct(struct CachedStorage* self); -/** -* Writes one byte to the storage buffer -*/ -void CachedStorage_writeByte(struct CachedStorage* self, int offset, uint8_t value); - -/** -* Writes two bytes to the storage buffer -*/ -void CachedStorage_writeHalfWord(struct CachedStorage* self, int offset, uint16_t value); - /** * Writes four bytes to the storage buffer */ @@ -95,15 +85,6 @@ void CachedStorage_writeWord(struct CachedStorage* self, int offset, uint32_t va */ void CachedStorage_writeBlob(struct CachedStorage* self, int offset, const void* blob, size_t blobSize); -/** -* Reads one byte from the storage buffer -*/ -uint8_t CachedStorage_readByte(struct CachedStorage* self, int offset); - -/** -* Reads two bytes from the storage buffer -*/ -uint16_t CachedStorage_readHalfWord(struct CachedStorage* self, int offset); /** * Reads four bytes from the storage buffer diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/inc/DisplayDevice.h b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/inc/DisplayDevice.h index 7556d3d..7f57fbe 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/inc/DisplayDevice.h +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/inc/DisplayDevice.h @@ -56,12 +56,15 @@ struct DisplayDevice; typedef ErrorStatus (*DisplayResetFunction)(const struct DisplayDevice* self); typedef ErrorStatus (*DisplaySetStateFunction)(const struct DisplayDevice* self, DisplayDevice_functionalState state); +typedef ErrorStatus (*DisplayBackspaceFunction)(const struct DisplayDevice* self); +typedef ErrorStatus (*DisplayCursorPositionFunction)(const struct DisplayDevice* self, unsigned int row, unsigned int column); typedef ErrorStatus (*DisplayWriteFunction)(const struct DisplayDevice* self, const char* buffer, size_t length, size_t row, size_t column); typedef ErrorStatus (*DisplayClearFunction)(const struct DisplayDevice* self); typedef ErrorStatus (*DisplayClearLineFunction)(const struct DisplayDevice* self, size_t row); typedef ErrorStatus (*DisplaySetBrightnessFunction)(const struct DisplayDevice* self, size_t brightness); typedef ErrorStatus (*DisplaySetContrastFunction)(const struct DisplayDevice* self, size_t contrast); typedef ErrorStatus (*DisplayInvertFunction)(const struct DisplayDevice* self); +typedef ErrorStatus (*DisplaySetBlinkingCursor)(const struct DisplayDevice* self, DisplayDevice_functionalState state); struct DisplayDeviceParameters { @@ -77,12 +80,15 @@ struct DisplayDevice { DisplayResetFunction _reset; DisplaySetStateFunction _setState; + DisplayBackspaceFunction _backspace; + DisplayCursorPositionFunction _setCursorToPosition; DisplayWriteFunction _write; DisplayClearFunction _clear; DisplayClearLineFunction _clearLine; DisplaySetBrightnessFunction _setBrightness; DisplaySetContrastFunction _setContrast; DisplayInvertFunction _invert; + DisplaySetBlinkingCursor _setBlinkingCursor; struct DisplayDeviceParameters parameters; bool initialized; }; @@ -94,20 +100,26 @@ struct DisplayDevice extern ErrorStatus DisplayDevice_construct (struct DisplayDevice* self, struct DisplayDeviceParameters* parameters, DisplayResetFunction reset, DisplaySetStateFunction setState, + DisplayBackspaceFunction backspace, + DisplayCursorPositionFunction setCursorToPosition, DisplayWriteFunction write, DisplayClearFunction clear, DisplayClearLineFunction clearLine, DisplaySetBrightnessFunction setBrightness, DisplaySetContrastFunction setContrast, - DisplayInvertFunction invert); + DisplayInvertFunction invert, + DisplaySetBlinkingCursor setBlinkingCursor); extern ErrorStatus DisplayDevice_reset(const struct DisplayDevice* self); extern ErrorStatus DisplayDevice_setState(const struct DisplayDevice* self, DisplayDevice_functionalState state); +extern ErrorStatus DisplayDevice_backspace(const struct DisplayDevice* self); +extern ErrorStatus DisplayDevice_setCursorToPosition(const struct DisplayDevice* self, unsigned int row, unsigned int column); extern ErrorStatus DisplayDevice_write(const struct DisplayDevice* self, const char* buffer, size_t length, size_t row, size_t column); extern ErrorStatus DisplayDevice_clear(const struct DisplayDevice* self); extern ErrorStatus DisplayDevice_clearLine(const struct DisplayDevice* self, size_t row); extern ErrorStatus DisplayDevice_setBrightness(const struct DisplayDevice* self, size_t brightness); extern ErrorStatus DisplayDevice_setContrast(const struct DisplayDevice* self, size_t contrast); extern ErrorStatus DisplayDevice_invert(const struct DisplayDevice* self); +extern ErrorStatus DisplayDevice_setBlinkingCursorState(const struct DisplayDevice* self, DisplayDevice_functionalState state); #endif /* INC_DISPLAYDEVICE_H_ */ diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/CachedStorage.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/CachedStorage.c index e5faf4f..d9a2655 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/CachedStorage.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/CachedStorage.c @@ -60,7 +60,7 @@ // ----------------------------------------------------------------------------- -ErrorStatus CachedStorage_construct(struct CachedStorage* self, struct MemoryDevice* memoryDevice, unsigned int pageNumber) +ErrorStatus CachedStorage_construct(struct CachedStorage* self, struct MemoryDevice* memoryDevice, unsigned int pageNumber, size_t cacheSize) { ErrorStatus returnValue = SUCCESS; if (!self->initialized) @@ -82,10 +82,39 @@ ErrorStatus CachedStorage_construct(struct CachedStorage* self, struct MemoryDev self->memoryDevice = memoryDevice; } + if (returnValue == SUCCESS) { - self->cacheSize = CACHED_STORAGE_PAGESIZE / 4; - MemoryDevice_read(self->memoryDevice, (uint32_t*)self->storage, self->memoryDevice->startAddress + self->memoryDevice->pageSize * self->pageNumber, self->cacheSize); + self->cacheSize = cacheSize; + self->tempBuffer = pvPortMalloc(cacheSize * 4); + if (self->tempBuffer == NULL) + { + returnValue = ERROR; + LOGGER_ERROR(mainLog, "Failed to malloc to tempbuffer"); + } + else + { + LOGGER_INFO(mainLog, "Created tempBuffer memory with size %x at address %p", self->cacheSize, self->tempBuffer); + } + } + + if (returnValue == SUCCESS) + { + self->storage = pvPortMalloc(cacheSize * 4); + if (self->storage == NULL) + { + returnValue = ERROR; + LOGGER_ERROR(mainLog, "Failed to malloc to storage"); + } + else + { + LOGGER_INFO(mainLog, "Created storage memory with size %x at address %p", self->cacheSize, self->storage); + } + } + + if (returnValue == SUCCESS) + { + MemoryDevice_read(self->memoryDevice, self->storage, self->memoryDevice->startAddress + self->memoryDevice->pageSize * self->pageNumber, self->cacheSize); self->initialized = true; self->dirty = false; @@ -99,87 +128,22 @@ void CachedStorage_destruct(struct CachedStorage* self) { if (self->initialized) { + vPortFree(self->storage); + vPortFree(self->tempBuffer); + LOGGER_INFO(mainLog, "Free'd buffers"); self->initialized = false; } } -void CachedStorage_writeByte(struct CachedStorage* self, int offset, uint8_t value) -{ - if (self->initialized) - { - if(offset < CACHED_STORAGE_PAGESIZE) - { - if(value != self->storage[offset]) - { - self->storage[offset] = value; - self->dirty = true; - } - } - } -} - -void CachedStorage_writeHalfWord(struct CachedStorage* self, int offset, uint16_t _value) -{ - if (self->initialized) - { - if(offset < CACHED_STORAGE_PAGESIZE - 1) - { - uint16_t value = _value; - - if((value & 0xFF) != self->storage[offset + 1]) - { - self->storage[offset + 1] = value & 0xFF; - self->dirty = true; - } - - value >>= 8; - - if((value & 0xFF) != self->storage[offset]) - { - self->storage[offset] = value & 0xFF; - self->dirty = true; - } - } - } -} - void CachedStorage_writeWord(struct CachedStorage* self, int offset, uint32_t _value) { if (self->initialized) { - if(offset < CACHED_STORAGE_PAGESIZE - 3) + if(offset < self->cacheSize) { - uint32_t value = _value; - if((value & 0xFF) != self->storage[offset + 3]) - { - self->storage[offset + 3] = value & 0xFF; - self->dirty = true; - } - - value >>= 8; - - if((value & 0xFF) != self->storage[offset + 2]) - { - self->storage[offset + 2] = value & 0xFF; - self->dirty = true; - } - - value >>= 8; - - if((value & 0xFF) != self->storage[offset + 1]) - { - self->storage[offset + 1] = value & 0xFF; - self->dirty = true; - } - - value >>= 8; - - if((value & 0xFF) != self->storage[offset]) - { - self->storage[offset] = value & 0xFF; - self->dirty = true; - } + self->storage[offset] = _value; + self->dirty = true; } } } @@ -188,19 +152,23 @@ void CachedStorage_writeBlob(struct CachedStorage* self, int offset, const void* { if (self->initialized) { - if(offset + blobSize <= CACHED_STORAGE_PAGESIZE) + if(offset + blobSize <= self->cacheSize) { - memcpy(&self->storage[offset], blob, blobSize); + memcpy(&self->storage[offset], blob, blobSize * 4); self->dirty = true; } + else + { + LOGGER_ERROR(mainLog, "WriteBlob failed at offset %d, blobsize %d --- %p", offset, blobSize, self->storage[offset]); + } } } -uint8_t CachedStorage_readByte(struct CachedStorage* self, int offset) +uint32_t CachedStorage_readWord(struct CachedStorage* self, int offset) { if (self->initialized) { - if(offset < CACHED_STORAGE_PAGESIZE) + if(offset < self->cacheSize) { return self->storage[offset]; } @@ -215,54 +183,19 @@ uint8_t CachedStorage_readByte(struct CachedStorage* self, int offset) } } -uint16_t CachedStorage_readHalfWord(struct CachedStorage* self, int offset) -{ - if (self->initialized) - { - if(offset < CACHED_STORAGE_PAGESIZE - 1) - { - return self->storage[offset + 1] | (self->storage[offset] << 8); - } - else - { - return 0; - } - } - else - { - return 0; - } -} -uint32_t CachedStorage_readWord(struct CachedStorage* self, int offset) -{ - if (self->initialized) - { - if(offset < CACHED_STORAGE_PAGESIZE - 3) - { - return self->storage[offset + 3] | (self->storage[offset + 2] << 8) | (self->storage[offset + 1] << 16) | (self->storage[offset] << 24); - } - else - { - return 0; - } - } - else - { - return 0; - } -} const void* CachedStorage_readBlob(struct CachedStorage* self, int offset) { if (self->initialized) { - if(offset < CACHED_STORAGE_PAGESIZE) + if(offset < self->cacheSize) { return &self->storage[offset]; } else { + LOGGER_ERROR(mainLog, "ReadBlob failed at offset %d --- %p", offset, self->storage[offset]); return NULL; } } @@ -278,16 +211,16 @@ void CachedStorage_commit(struct CachedStorage* self) { if(self->dirty) { - MemoryDevice_read(self->memoryDevice, (uint32_t*)self->tempBuffer, self->memoryDevice->startAddress + self->memoryDevice->pageSize * self->pageNumber, self->cacheSize); + MemoryDevice_read(self->memoryDevice, self->tempBuffer, self->memoryDevice->startAddress + self->memoryDevice->pageSize * self->pageNumber, self->cacheSize); - if(memcmp(self->tempBuffer, self->storage, (sizeof(self->storage) / sizeof(self->storage[0]))) != 0) + if(memcmp(self->tempBuffer, self->storage, (self->cacheSize * 4)) != 0) { if (self->memoryDevice->needsEraseBeforeWrite) { MemoryDevice_erasePage(self->memoryDevice, self->pageNumber); } - MemoryDevice_write(self->memoryDevice, (uint32_t*)self->storage, self->memoryDevice->startAddress + self->memoryDevice->pageSize * self->pageNumber, self->cacheSize); + MemoryDevice_write(self->memoryDevice, self->storage, self->memoryDevice->startAddress + self->memoryDevice->pageSize * self->pageNumber, self->cacheSize); } else { diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/DisplayDevice.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/DisplayDevice.c index da4006e..9ba78f1 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/DisplayDevice.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/DisplayDevice.c @@ -60,25 +60,31 @@ ErrorStatus DisplayDevice_construct (struct DisplayDevice* self, struct DisplayDeviceParameters* parameters, DisplayResetFunction reset, DisplaySetStateFunction setState, + DisplayBackspaceFunction backspace, + DisplayCursorPositionFunction setCursorToPosition, DisplayWriteFunction write, DisplayClearFunction clear, DisplayClearLineFunction clearLine, DisplaySetBrightnessFunction setBrightness, DisplaySetContrastFunction setContrast, - DisplayInvertFunction invert) + DisplayInvertFunction invert, + DisplaySetBlinkingCursor setBlinkingCursor) { ErrorStatus returnValue = SUCCESS; if (!self->initialized) { - self->_reset = reset; - self->_setState = setState; - self->_write = write; - self->_clear = clear; - self->_clearLine = clearLine, - self->_setBrightness = setBrightness; - self->_setContrast = setContrast; - self->_invert = invert; + self->_reset = reset; + self->_setState = setState; + self->_backspace = backspace; + self->_setCursorToPosition = setCursorToPosition; + self->_write = write; + self->_clear = clear; + self->_clearLine = clearLine, + self->_setBrightness = setBrightness; + self->_setContrast = setContrast; + self->_invert = invert; + self->_setBlinkingCursor = setBlinkingCursor; self->initialized = true; @@ -128,6 +134,42 @@ ErrorStatus DisplayDevice_setState(const struct DisplayDevice* self, DisplayDevi } +ErrorStatus DisplayDevice_backspace(const struct DisplayDevice* self) +{ + ErrorStatus returnValue = SUCCESS; + if (self->initialized) + { + if (self->_backspace != NULL) + { + returnValue = self->_backspace(self); + } + } + else + { + returnValue = ERROR; + } + return returnValue; +} + + +ErrorStatus DisplayDevice_setCursorToPosition(const struct DisplayDevice* self, unsigned int row, unsigned int column) +{ + ErrorStatus returnValue = SUCCESS; + if (self->initialized) + { + if (self->_setCursorToPosition != NULL) + { + returnValue = self->_setCursorToPosition(self, row, column); + } + } + else + { + returnValue = ERROR; + } + return returnValue; +} + + ErrorStatus DisplayDevice_write(const struct DisplayDevice* self, const char* buffer, size_t length, size_t row, size_t column) { ErrorStatus returnValue = SUCCESS; @@ -234,3 +276,21 @@ ErrorStatus DisplayDevice_invert(const struct DisplayDevice* self) } return returnValue; } + + +ErrorStatus DisplayDevice_setBlinkingCursorState(const struct DisplayDevice* self, DisplayDevice_functionalState state) +{ + ErrorStatus returnValue = SUCCESS; + if (self->initialized) + { + if (self->_setBlinkingCursor != NULL) + { + returnValue = self->_setBlinkingCursor(self, state); + } + } + else + { + returnValue = ERROR; + } + return returnValue; +} diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/Logger.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/Logger.c index b860750..a346cd0 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/Logger.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/Logger.c @@ -45,7 +45,7 @@ // Constant and macro definitions // ----------------------------------------------------------------------------- -#define LOGQUEUE_SIZE (24) +#define LOGQUEUE_SIZE (20) // Makefile compile options: // ENABLE_SERIAL_LOGGING: Use the serial port for logging. diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/nhd0420.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/nhd0420.c index 9fbbc1c..3623698 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/nhd0420.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/src/nhd0420.c @@ -67,10 +67,13 @@ static int nhd0420_cursorRowOffset[NHD0420_NUMBER_OF_ROWS] = // ----------------------------------------------------------------------------- static ErrorStatus setState(const struct DisplayDevice* self, DisplayDevice_functionalState state); +static ErrorStatus backspace(const struct DisplayDevice* self); +static ErrorStatus setCursorToPosition(const struct DisplayDevice* self, unsigned int row, unsigned int column); static ErrorStatus write(const struct DisplayDevice* self, const char* buffer, size_t length, size_t row, size_t column); static ErrorStatus clear(const struct DisplayDevice* self); static ErrorStatus setBrightness(const struct DisplayDevice* self, size_t brightness); static ErrorStatus setContrast(const struct DisplayDevice* self, size_t contrast); +static ErrorStatus setBlinkingCursorState(const struct DisplayDevice* self, DisplayDevice_functionalState state); // ----------------------------------------------------------------------------- // Function definitions @@ -95,7 +98,7 @@ ErrorStatus NHD0420_construct(struct NHD0420* self, const struct IODevice* devic ddParameters.contrastMin = NHD0420_CONTRAST_MIN; ddParameters.contrastMax = NHD0420_CONTRAST_MAX; - returnValue = DisplayDevice_construct(&self->displayDevice, &ddParameters, NULL, setState, write, clear, NULL, setBrightness, setContrast, NULL); + returnValue = DisplayDevice_construct(&self->displayDevice, &ddParameters, NULL, setState, backspace, setCursorToPosition, write, clear, NULL, setBrightness, setContrast, NULL, setBlinkingCursorState); if (returnValue == SUCCESS) { @@ -390,6 +393,17 @@ static ErrorStatus setState(const struct DisplayDevice* self, DisplayDevice_func return returnValue; } +static ErrorStatus backspace(const struct DisplayDevice* self) +{ + return NHD0420_useBackspace((const struct NHD0420*)self); +} + + +ErrorStatus setCursorToPosition(const struct DisplayDevice* self, unsigned int row, unsigned int column) +{ + return NHD0420_setCursorToPosition((const struct NHD0420*)self, row, column); +} + static ErrorStatus write(const struct DisplayDevice* self, const char* buffer, size_t length, size_t row, size_t column) { @@ -462,3 +476,24 @@ static ErrorStatus setContrast(const struct DisplayDevice* self, size_t contrast } +static ErrorStatus setBlinkingCursorState(const struct DisplayDevice* self, DisplayDevice_functionalState state) +{ + ErrorStatus returnValue = SUCCESS; + if (self->initialized) + { + if (state == ON) + { + returnValue = NHD0420_turnOnBlinkingCursor((const struct NHD0420*)self); + } + else + { + returnValue = NHD0420_turnOffBlinkingCursor((const struct NHD0420*)self); + } + } + else + { + returnValue = ERROR; + } + return returnValue; +} + diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/src/InternalFlash.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/src/InternalFlash.c index 36cf3d0..2520985 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/src/InternalFlash.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/Platform/src/InternalFlash.c @@ -105,7 +105,7 @@ ErrorStatus InternalFlash_write(const struct InternalFlash* self, uint32_t* buff ErrorStatus returnValue = SUCCESS; FLASH_Status FLASHStatus = FLASH_COMPLETE; uint32_t _address = address; - uint32_t _endAddress = address + (length * 4) - 1; + uint32_t _endAddress = address + length * 4 - 1; if (self->initialized) { if (returnValue == SUCCESS) @@ -151,7 +151,6 @@ ErrorStatus InternalFlash_write(const struct InternalFlash* self, uint32_t* buff else { returnValue = ERROR; - LOGGER_ERROR(mainLog, "BOEH"); } return returnValue; } @@ -162,7 +161,7 @@ ErrorStatus InternalFlash_read(const struct InternalFlash* self, uint32_t* buffe ErrorStatus returnValue = SUCCESS; uint32_t _address = address; - uint32_t _endAddress = address + (length * 4); + uint32_t _endAddress = address + length * 4 - 1; if (self->initialized) { @@ -174,6 +173,7 @@ ErrorStatus InternalFlash_read(const struct InternalFlash* self, uint32_t* buffe // Start address is NOT OK returnValue = ERROR; } + } if (returnValue == SUCCESS) { @@ -183,6 +183,7 @@ ErrorStatus InternalFlash_read(const struct InternalFlash* self, uint32_t* buffe // End address is NOT OK returnValue = ERROR; } + } // Boundaries OK - Read from FLASH diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/Makefile b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/Makefile index 37163cf..b5af792 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/Makefile +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/Makefile @@ -33,7 +33,7 @@ repairProcesses.o \ repairProcessRow.o \ SignalProfileGenerator.o \ \ -heap_2.o\ +heap_4.o\ list.o \ port.o \ queue.o \ diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/DeviceParameters.h b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/DeviceParameters.h new file mode 100644 index 0000000..6e3f581 --- /dev/null +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/DeviceParameters.h @@ -0,0 +1,111 @@ +// ----------------------------------------------------------------------------- +/// @file DeviceParameters.h +/// @brief File 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) 2015 Micro-Key bv +// ----------------------------------------------------------------------------- + +/// @defgroup {group_name} {group_description} +/// Description + +/// @file DeviceParameters.h +/// @ingroup {group_name} + +#ifndef DEVICEPARAMETERS_H_ +#define DEVICEPARAMETERS_H_ + + +// ----------------------------------------------------------------------------- +// Include files +// ----------------------------------------------------------------------------- + +#include "stm32f10x.h" + +#include "PIDParameters.h" +#include "PIN.h" + +#include "CachedStorage.h" + +// ----------------------------------------------------------------------------- +// Constant and macro definitions +// ----------------------------------------------------------------------------- + + + +// ----------------------------------------------------------------------------- +// Type definitions. +// ----------------------------------------------------------------------------- + + + +// ----------------------------------------------------------------------------- +// Function declarations +// ----------------------------------------------------------------------------- + + +/** ---------------------------------------------------------------------------- + * RepairPresets_construct + * Constructor for repair presets + * + * @return ErrorStatus + * + * @todo + * ----------------------------------------------------------------------------- + */ +extern ErrorStatus DeviceParameters_construct(struct CachedStorage* parametersStorage, struct MemoryDevice* memoryDevice); + + +/** ---------------------------------------------------------------------------- + * DeviceParameters_destruct + * Description of function + * + * @param para1_name + * @param para2_name + * @return void + * + * @todo + * ----------------------------------------------------------------------------- + */ +extern void DeviceParameters_destruct(void); + + +/** ---------------------------------------------------------------------------- + * DeviceParameters_getPIDParameters + * Description of function + * + * @param para1_name + * @param para2_name + * @return struct PIDParameters* + * + * @todo + * ----------------------------------------------------------------------------- + */ +extern struct PIDParameters* DeviceParameters_getPIDParameters(void); + + +/** ---------------------------------------------------------------------------- + * DeviceParameters_getPIN + * Description of function + * + * @param para1_name + * @param para2_name + * @return struct PIN* + * + * @todo + * ----------------------------------------------------------------------------- + */ +extern struct PIN* DeviceParameters_getPIN(void); + +#endif /* DEVICEPARAMETERS_H_ */ diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/Display.h b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/Display.h index feb9542..a72aea4 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/Display.h +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/Display.h @@ -191,6 +191,52 @@ extern ErrorStatus Display_setBrightness(struct Display* self, size_t brightness extern ErrorStatus Display_setContrast(struct Display* self, size_t contrast); +/** ---------------------------------------------------------------------------- + * Display_setBlinkingCursorState + * Sets the status of the blinking cursor + * + * @param self The display information to use + * @param state The state of the blinking cursor to set + * + * @return ErrorStatus SUCCESS if clearing display was OK + * ERROR otherwise + * + * @todo + * ----------------------------------------------------------------------------- + */ +extern ErrorStatus Display_setBlinkingCursorState(struct Display* self, DisplayDevice_functionalState state); + + +/** ---------------------------------------------------------------------------- + * Display_setCurosrToPosition + * Sets didplay cursor to given position + * + * @param self + * @param row + * @param column + * + * @return ErrorStatus + * + * @todo + * ----------------------------------------------------------------------------- + */ +extern ErrorStatus Display_setCursorToPosition(struct Display* self, unsigned int row, unsigned int column); + + +/** ---------------------------------------------------------------------------- + * Display_backspace + * puts the cursor back one column and removes the character + * + * @param self + * + * @return ErrorStatus + * + * @todo + * ----------------------------------------------------------------------------- + */ +extern ErrorStatus Display_backspace(struct Display* self); + + /** ---------------------------------------------------------------------------- * Display_write * Write a text on the display diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/Error.h b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/Error.h index cdd4da1..f76e9d1 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/Error.h +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/Error.h @@ -35,12 +35,13 @@ #include "Observable.h" +#include "FreeRTOS.h" +#include "task.h" // ----------------------------------------------------------------------------- // Constant and macro definitions // ----------------------------------------------------------------------------- - // ----------------------------------------------------------------------------- // Type definitions. // ----------------------------------------------------------------------------- diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/FreeRTOSConfig.h b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/FreeRTOSConfig.h index 6248795..85caf03 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/FreeRTOSConfig.h +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/FreeRTOSConfig.h @@ -44,7 +44,7 @@ #define configTICK_RATE_HZ ( ( TickType_t ) 1000 ) #define configMAX_PRIORITIES ( 5 ) #define configMINIMAL_STACK_SIZE ( ( unsigned short ) 256 ) -#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 0x8000 ) ) +#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 0x7000 ) ) #define configMAX_TASK_NAME_LEN ( 16 ) #define configUSE_TRACE_FACILITY 1 #define configUSE_16_BIT_TICKS 0 diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/MenuCore.h b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/MenuCore.h index 1130671..ec99718 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/MenuCore.h +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/MenuCore.h @@ -37,6 +37,7 @@ #include "Display.h" #include "KeyboardDevice.h" +#include "MenuStates.h" // ----------------------------------------------------------------------------- // Constant and macro definitions // ----------------------------------------------------------------------------- @@ -49,27 +50,6 @@ // Type definitions. // ----------------------------------------------------------------------------- -typedef enum -{ - RM_MAINMENU = 0, - RM_CATHODEMCP_SELECT, - RM_REPAIRMENU, - RM_ADMINMENU, - RM_CALIBRATIONMENU, - RM_PRESETMENU, - RM_PRESET_PRINT, - RM_START_REPAIR, - RM_REPAIR_RUNNING, - RM_REPAIR_ASK_PAUSE, - RM_REPAIR_PAUSE, - RM_FINISH_CONTROL, - RM_FINISH, - RM_ERROR_STATE, - RM_WARNING_STATE, - RM_NO_MENU, - RM_NUMBER_OF_MENUS -} T_MenuState; - typedef enum { @@ -80,7 +60,9 @@ typedef enum EXECUTE_FUNCTION, SCROLL_UP, SCROLL_DOWN, - DIGIT_INSERT + DIGIT_INSERT, + DIGIT_REMOVE, + DIGIT_INSERT_CONFIRM } T_KeyAction; struct MenuCore; @@ -88,49 +70,51 @@ typedef void (*MenuCoreFunctionCall)(struct MenuCore* self); struct MenuRow { - char text[MENUCORE_DISPLAY_ROW_LENGTH]; + const char* text; int newState; MenuCoreFunctionCall actionPointer; }; struct KeyActionBinding { - char key; + MenuCoreFunctionCall actionPointer; + int argument; Keypad_KeyState keyState; T_KeyAction action; - int argument; - MenuCoreFunctionCall actionPointer; -}; + char key; +} __attribute__((packed)); struct MenuPage { + struct MenuRow row[MENUCORE_MAX_NUMBER_OF_ROWS]; + struct KeyActionBinding keyActionBinding[NUMBER_OF_KEY_EVENTS * MENUCORE_MAX_NUMBER_OF_KEYS]; bool hasCursor; int numberOfRows; int maxNumberOfRows; int numberOfKeys; int maxNumberOfKeys; - struct MenuRow row[MENUCORE_MAX_NUMBER_OF_ROWS]; - struct KeyActionBinding keyActionBinding[NUMBER_OF_KEY_EVENTS * MENUCORE_MAX_NUMBER_OF_KEYS]; }; struct MenuCore { - TaskHandle_t taskHandle; - int TaskPriority; - uint16_t stackSize; - bool runTask; - bool initialized; + struct MenuPage menuArray[RM_NUMBER_OF_MENUS]; struct Display* display; struct KeyboardDevice* keyboardDevice; - int cursorIndex; - int scrollOffset; - T_MenuState menuState; - uint32_t popUpCounter; - T_MenuState lastMenuState; - struct MenuPage menuArray[RM_NUMBER_OF_MENUS]; - MenuCoreFunctionCall _handleStateFunction; char errorMessage[MENUCORE_DISPLAY_ROW_LENGTH]; char warningMessage[MENUCORE_DISPLAY_ROW_LENGTH]; + TaskHandle_t taskHandle; + int TaskPriority; + bool runTask; + bool initialized; + int cursorIndex; + int selectionIndex; + int scrollOffset; + int insertValue; + uint32_t popUpCounter; + MenuCoreFunctionCall _handleStateFunction; + uint16_t stackSize; + T_MenuState lastMenuState; + T_MenuState menuState; }; // ----------------------------------------------------------------------------- diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/MenuElements.h b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/MenuElements.h index 693ee1f..5719a45 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/MenuElements.h +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/MenuElements.h @@ -73,4 +73,12 @@ extern ErrorStatus MenuElements_addKeyAction_SCROLLUP (struct MenuPage* self, ch extern ErrorStatus MenuElements_addKeyAction_SCROLLDOWN (struct MenuPage* self, char key, Keypad_KeyState keyState); + +extern ErrorStatus MenuElements_addKeyAction_DIGITINSERT (struct MenuPage* self, char key, Keypad_KeyState keyState, unsigned int maxNumberOfDigits); + + +extern ErrorStatus MenuElements_addKeyAction_DIGITREMOVE (struct MenuPage* self, char key, Keypad_KeyState keyState); + +extern ErrorStatus MenuElements_addKeyAction_DIGITINSERTCONFIRM (struct MenuPage* self, char key, Keypad_KeyState keyState, MenuCoreFunctionCall actionPointer); + #endif /* MENUELEMENTS_H_ */ diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/MenuStates.h b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/MenuStates.h new file mode 100644 index 0000000..6238e42 --- /dev/null +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/MenuStates.h @@ -0,0 +1,109 @@ +// ----------------------------------------------------------------------------- +/// @file MenuStates.h +/// @brief File 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) 2015 Micro-Key bv +// ----------------------------------------------------------------------------- + +/// @defgroup {group_name} {group_description} +/// Description + +/// @file MenuStates.h +/// @ingroup {group_name} + +#ifndef MENUSTATES_H_ +#define MENUSTATES_H_ + + +// ----------------------------------------------------------------------------- +// Include files +// ----------------------------------------------------------------------------- + + +// ----------------------------------------------------------------------------- +// Constant and macro definitions +// ----------------------------------------------------------------------------- + + + +// ----------------------------------------------------------------------------- +// Type definitions. +// ----------------------------------------------------------------------------- + +typedef enum +{ + // -------------------------------------------------------------------------- + // MAIN MENU + // -------------------------------------------------------------------------- + RM_MAINMENU = 0, + // For Cathode/MCP, a menu screen is required prior to the repair menu + RM_REPAIR_CATHODEMCP_SELECT, + // -------------------------------------------------------------------------- + // REPAIR TUBE MENUs + // -------------------------------------------------------------------------- + // The repair menu screen + RM_REPAIRMENU, + // Select and show presets + RM_PRESETMENU, + RM_PRESET_PRINT, + // Repair screens + RM_START_REPAIR, + RM_REPAIR_RUNNING, + RM_FINISH_CONTROL, + RM_FINISH, + // Pause screens + RM_REPAIR_ASK_PAUSE, + RM_REPAIR_PAUSE, + + // -------------------------------------------------------------------------- + // ADMINISTRATION MENUs + // -------------------------------------------------------------------------- + RM_ADMIN_CATHODEMCP_SELECT, + RM_ADMINMENU, + RM_ADMIN_CHANGEPIN, + RM_ADMIN_IOCONTROL, + RM_ADMIN_PRESET_CONFIG_SELECT, + RM_ADMIN_PRESET_CONFIG_FIRST_SOFTSTART, + RM_ADMIN_PRESET_CONFIG_FIRST_DURATION, + RM_ADMIN_PRESET_CONFIG_FIRST_VOLTAGE, + RM_ADMIN_PRESET_CONFIG_SECOND_SOFTSTART, + RM_ADMIN_PRESET_CONFIG_SECOND_DURATION, + RM_ADMIN_PRESET_CONFIG_SECOND_VOLTAGE, + RM_ADMIN_INFO, + + RM_ADMIN_IO_INTERLOCK, + RM_ADMIN_IO_SOLENOID, + RM_ADMIN_IO_VOLTAGE_IN, + RM_ADMIN_IO_VOLTAGE_OUT, + RM_ADMIN_IO_TESLAGUN, + + + // -------------------------------------------------------------------------- + // CALIBRATION MENUs + // -------------------------------------------------------------------------- + RM_CALIBRATIONMENU, + + RM_ERROR_STATE, + RM_WARNING_STATE, + RM_NO_MENU, + RM_NUMBER_OF_MENUS +} T_MenuState; + +// ----------------------------------------------------------------------------- +// Function declarations +// ----------------------------------------------------------------------------- + + +#endif /* MENUSTATES_H_ */ diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/MenuText.h b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/MenuText.h index 63c7cf2..a59c74d 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/MenuText.h +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/MenuText.h @@ -68,6 +68,18 @@ static const char MenuText_CATHODEMCP_SELECT[MENUTEXT_NUMBER_OF_LANGUAGES][MENUC } }; +static const char MenuText_ADMIN_CATHODEMCP_SELECT[MENUTEXT_NUMBER_OF_LANGUAGES][MENUCORE_MAX_NUMBER_OF_ROWS][MENUCORE_DISPLAY_ROW_LENGTH] = +{ + { + "Administration", + " 1.Cathode", + " 2.MCP", + }, + { + //FRENCH TBW + } +}; + static const char MenuText_REPAIRMENU[MENUTEXT_NUMBER_OF_LANGUAGES][MENUCORE_MAX_NUMBER_OF_ROWS][MENUCORE_DISPLAY_ROW_LENGTH] = { @@ -106,13 +118,149 @@ static const char MenuText_PRESETMENU[MENUTEXT_NUMBER_OF_LANGUAGES][MENUCORE_MAX // ----------------------- // ADMINISTRATION MENU // ----------------------- +// Administration main screen static const char MenuText_ADMINMENU[MENUTEXT_NUMBER_OF_LANGUAGES][MENUCORE_MAX_NUMBER_OF_ROWS][MENUCORE_DISPLAY_ROW_LENGTH] = { { "Administration", " 1.Change Pin", " 2.I/O control", - " 3.Info & Version" + " 3.Preset config", + " 4.Info & Version", + }, + { + //FRENCH TBW + } +}; + +// Administration main screen +static const char MenuText_ADMINCHANGEPINMENU[MENUTEXT_NUMBER_OF_LANGUAGES][MENUCORE_MAX_NUMBER_OF_ROWS][MENUCORE_DISPLAY_ROW_LENGTH] = +{ + { + "Change PIN", + }, + { + //FRENCH TBW + } +}; + +// Administration I/O Control screen +static const char MenuText_ADMINIOMAINMENU[MENUTEXT_NUMBER_OF_LANGUAGES][MENUCORE_MAX_NUMBER_OF_ROWS][MENUCORE_DISPLAY_ROW_LENGTH] = +{ + { + "I/O control", + " 1.Read interlock", + " 2.Solenoids", + " 3.Get voltage in", + " 4.Set voltage out", + " 5.Teslagun relais", + }, + { + //FRENCH TBW + } +}; + + +// Administration I/O Control screen +static const char MenuText_ADMINIOINTERLOCKMENU[MENUTEXT_NUMBER_OF_LANGUAGES][MENUCORE_MAX_NUMBER_OF_ROWS][MENUCORE_DISPLAY_ROW_LENGTH] = +{ + { + "Read interlock", + }, + { + //FRENCH TBW + } +}; + + +// Administration solenoids toggle screen +static const char MenuText_ADMINSOLENOIDMENU[MENUTEXT_NUMBER_OF_LANGUAGES][MENUCORE_MAX_NUMBER_OF_ROWS][MENUCORE_DISPLAY_ROW_LENGTH] = +{ + { + "Solenoids", + " Hold 0 to toggle", + "", + + }, + { + //FRENCH TBW + } +}; + + +// Administration Get Voltage input screen +static const char MenuText_ADMINVOLTAGINMAINMENU[MENUTEXT_NUMBER_OF_LANGUAGES][MENUCORE_MAX_NUMBER_OF_ROWS][MENUCORE_DISPLAY_ROW_LENGTH] = +{ + { + "Get voltage in", + " 1.Channel 1", + " 2.Channel 2", + " 3.Channel 3", + + }, + { + //FRENCH TBW + } +}; + + +// Administration Get Voltage output screen +static const char MenuText_ADMINVOLTAGOUTMAINMENU[MENUTEXT_NUMBER_OF_LANGUAGES][MENUCORE_MAX_NUMBER_OF_ROWS][MENUCORE_DISPLAY_ROW_LENGTH] = +{ + { + "Set voltage out", + " 1.Channel 1", + " 2.Channel 2", + " 3.Channel 3", + + }, + { + //FRENCH TBW + } +}; + + +// Administration solenoids toggle screen +static const char MenuText_ADMINTESLAGUNMENU[MENUTEXT_NUMBER_OF_LANGUAGES][MENUCORE_MAX_NUMBER_OF_ROWS][MENUCORE_DISPLAY_ROW_LENGTH] = +{ + { + "Teslagun relais", + " Hold 0 to toggle", + "", + + }, + { + //FRENCH TBW + } +}; + + +// Administration Preset configuration +static const char MenuText_ADMINPRESETCONFIGSELECTMENU[MENUTEXT_NUMBER_OF_LANGUAGES][MENUCORE_MAX_NUMBER_OF_ROWS][MENUCORE_DISPLAY_ROW_LENGTH] = +{ + { + "Preset config", + " 1.Preset 1 config", + " 2.Preset 2 config", + " 3.Preset 3 config", + " 4.Preset 4 config", + " 5.Preset 5 config", + " 6.Preset 6 config", + " 7.Preset 7 config", + " 8.Preset 8 config", + " 9.Preset 9 config", + }, + { + //FRENCH TBW + } +}; + + +// Administration INFO&VERSION +static const char MenuText_ADMININFOMENU[MENUTEXT_NUMBER_OF_LANGUAGES][MENUCORE_MAX_NUMBER_OF_ROWS][MENUCORE_DISPLAY_ROW_LENGTH] = +{ + { + "Info & Version", }, { //FRENCH TBW diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/PIDParameters.h b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/PIDParameters.h new file mode 100644 index 0000000..7084a5a --- /dev/null +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/PIDParameters.h @@ -0,0 +1,55 @@ +// ----------------------------------------------------------------------------- +/// @file PIDParameters.h +/// @brief File 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) 2015 Micro-Key bv +// ----------------------------------------------------------------------------- + +/// @defgroup {group_name} {group_description} +/// Description + +/// @file PIDParameters.h +/// @ingroup {group_name} + +#ifndef PIDPARAMETERS_H_ +#define PIDPARAMETERS_H_ + + +// ----------------------------------------------------------------------------- +// Include files +// ----------------------------------------------------------------------------- + + +// ----------------------------------------------------------------------------- +// Constant and macro definitions +// ----------------------------------------------------------------------------- + +struct PIDParameters +{ + +}; + +// ----------------------------------------------------------------------------- +// Type definitions. +// ----------------------------------------------------------------------------- + + + +// ----------------------------------------------------------------------------- +// Function declarations +// ----------------------------------------------------------------------------- + + +#endif /* PIDPARAMETERS_H_ */ diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/PIN.h b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/PIN.h new file mode 100644 index 0000000..9556a91 --- /dev/null +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/PIN.h @@ -0,0 +1,55 @@ +// ----------------------------------------------------------------------------- +/// @file PIN.h +/// @brief File 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) 2015 Micro-Key bv +// ----------------------------------------------------------------------------- + +/// @defgroup {group_name} {group_description} +/// Description + +/// @file PIN.h +/// @ingroup {group_name} + +#ifndef PIN_H_ +#define PIN_H_ + + +// ----------------------------------------------------------------------------- +// Include files +// ----------------------------------------------------------------------------- + + +// ----------------------------------------------------------------------------- +// Constant and macro definitions +// ----------------------------------------------------------------------------- + +struct PIN +{ + +}; + +// ----------------------------------------------------------------------------- +// Type definitions. +// ----------------------------------------------------------------------------- + + + +// ----------------------------------------------------------------------------- +// Function declarations +// ----------------------------------------------------------------------------- + + +#endif /* PIN_H_ */ diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/RepairPreset.h b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/RepairPreset.h index 8e661f7..e037bca 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/RepairPreset.h +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/RepairPreset.h @@ -37,7 +37,9 @@ // Constant and macro definitions // ----------------------------------------------------------------------------- -#define REPAIR_PRESET_MAX_STAGES (2) +#define REPAIR_PRESET_MAX_STAGES (2) +#define REPAIR_PRESET_MAX_ONE_STAGE_PRESETS (6) +#define REPAIR_PRESET_MAX_TWO_STAGE_PRESETS (3) // ----------------------------------------------------------------------------- // Type definitions. @@ -82,4 +84,46 @@ struct RepairPreset */ extern ErrorStatus RepairPreset_generateDefaultPreset(struct RepairPreset* self, unsigned int presetNumber); + +/** ---------------------------------------------------------------------------- + * RepairPreset_setSoftstartValue + * Description of function + * + * @param self + * @param value + * @return void + * + * @todo + * ----------------------------------------------------------------------------- + */ +extern void RepairPreset_setSoftstartValue(struct RepairPresetParameters* self, unsigned int value); + + +/** ---------------------------------------------------------------------------- + * RepairPreset_setSoftstartValue + * Description of function + * + * @param self + * @param value + * @return void + * + * @todo + * ----------------------------------------------------------------------------- + */ +extern void RepairPreset_setDurationValue(struct RepairPresetParameters* self, unsigned int value); + + +/** ---------------------------------------------------------------------------- + * RepairPreset_setSoftstartValue + * Description of function + * + * @param self + * @param value + * @return void + * + * @todo + * ----------------------------------------------------------------------------- + */ +extern void RepairPreset_setVoltageValue(struct RepairPresetParameters* self, int value); + #endif /* REPAIRPRESET_H_ */ diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/RepairPresets.h b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/RepairPresets.h index a5ed892..529cedf 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/RepairPresets.h +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/RepairPresets.h @@ -108,12 +108,27 @@ extern ErrorStatus RepairPresets_loadPresets(REPAIR_PRESETS_ID presetID); * must be between 1 and * REPAIR_PRESETS_NUMBER_OF_PRESETS * - * @return const struct RepairPreset* + * @return struct RepairPreset* * * @todo * ----------------------------------------------------------------------------- */ -extern const struct RepairPreset* RepairPresets_getPreset(unsigned int index); +extern struct RepairPreset* RepairPresets_getPreset(unsigned int index); + + +extern ErrorStatus RepairPresets_writePreset(struct RepairPreset* preset); + + +/** ---------------------------------------------------------------------------- + * RepairPresets_savePreset + * Description of function + * + * @return void + * + * @todo + * ----------------------------------------------------------------------------- + */ +extern void RepairPresets_savePresets(void); diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/hsb-mrts.h b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/hsb-mrts.h index 899bf67..81c02e1 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/hsb-mrts.h +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/hsb-mrts.h @@ -44,13 +44,13 @@ // ----------------------------------------------------------------------------- #define HSB_MAINMENU_TASK_PRIORITY (2) -#define HSB_MAINMENU_TASK_STACKSIZE (1024) +#define HSB_MAINMENU_TASK_STACKSIZE (512) #define HSB_MAINDISP_TASK_PRIORITY (2) -#define HSB_MAINDISP_TASK_STACKSIZE (512) +#define HSB_MAINDISP_TASK_STACKSIZE (256) #define HSB_MAINREPR_TASK_PRIORITY (2) -#define HSB_MAINREPR_TASK_STACKSIZE (1024) +#define HSB_MAINREPR_TASK_STACKSIZE (512) #define HSB_MAINREPR_OOL_DURATION (20) #define HSB_MAINREPR_OOL_VALUE (300) diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/linker/LinkerScript.ld b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/linker/LinkerScript.ld index a98f718..1a99228 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/linker/LinkerScript.ld +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/linker/LinkerScript.ld @@ -59,7 +59,7 @@ _Min_Heap_Size = 0; /* required amount of heap */ _Min_Stack_Size = 0x400; /* required amount of stack */ /* Memories definition */ -/*Remove 6 pages (12k) for data storage from FLASH */ +/*Removed 6 pages (12k) for data storage from FLASH */ MEMORY { diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/DeviceParameters.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/DeviceParameters.c new file mode 100644 index 0000000..3a98662 --- /dev/null +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/DeviceParameters.c @@ -0,0 +1,136 @@ +// ----------------------------------------------------------------------------- +/// @file DeviceParameters.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) 2017 Micro-Key bv +// ----------------------------------------------------------------------------- + +/// @file DeviceParameters.c +/// @ingroup {group_name} + + +// ----------------------------------------------------------------------------- +// Include files +// ----------------------------------------------------------------------------- + +#include "DeviceParameters.h" + +// ----------------------------------------------------------------------------- +// Constant and macro definitions +// ----------------------------------------------------------------------------- + + + +// ----------------------------------------------------------------------------- +// Type definitions +// ----------------------------------------------------------------------------- + +struct DeviceParameters +{ + bool initialized; + struct CachedStorage* parametersStorage; + struct MemoryDevice* memoryDevice; +}; + +struct PIDParametersStorageClass +{ + uint32_t crc; + struct PIDParameters pidParameters; +}; + +struct PINStorageClass +{ + uint32_t crc; + struct PIN pin; +}; + +// ----------------------------------------------------------------------------- +// File-scope variables +// ----------------------------------------------------------------------------- + +static struct DeviceParameters _self = {.initialized = false}; +struct DeviceParameters* const self = &_self; + +// ----------------------------------------------------------------------------- +// Function declarations +// ----------------------------------------------------------------------------- + + + +// ----------------------------------------------------------------------------- +// Function definitions +// ----------------------------------------------------------------------------- + +ErrorStatus DeviceParameters_construct(struct CachedStorage* parametersStorage, struct MemoryDevice* memoryDevice) +{ + ErrorStatus returnValue = SUCCESS; + if (!self->initialized) + { + if (returnValue == SUCCESS) + { + if (parametersStorage != NULL) + { + self->parametersStorage = parametersStorage; + } + else + { + returnValue = ERROR; + } + } + + if (returnValue == SUCCESS) + { + if (memoryDevice != NULL) + { + if (memoryDevice->initialized) + { + self->memoryDevice = memoryDevice; + } + else + { + returnValue = ERROR; + } + } + else + { + returnValue = ERROR; + } + } + self->initialized = true; + } + else + { + returnValue = ERROR; + } + return returnValue; +} + + +void DeviceParameters_destruct(void) +{ + +} + + +struct PIDParameters* DeviceParameters_getPIDParameters(void) +{ + +} + + +struct PIN* DeviceParameters_getPIN(void) +{ + +} diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/Display.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/Display.c index c02f4d9..a6839e4 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/Display.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/Display.c @@ -158,6 +158,23 @@ ErrorStatus Display_setContrast(struct Display* self, size_t contrast) } +ErrorStatus Display_setBlinkingCursorState(struct Display* self, DisplayDevice_functionalState state) +{ + return DisplayDevice_setBlinkingCursorState(self->displayDevice, state); +} + +ErrorStatus Display_setCursorToPosition(struct Display* self, unsigned int row, unsigned int column) +{ + return DisplayDevice_setCursorToPosition(self->displayDevice, row, column); +} + + +ErrorStatus Display_backspace(struct Display* self) +{ + return DisplayDevice_backspace(self->displayDevice); +} + + ErrorStatus Display_write(struct Display* self, const char* buffer, size_t row, size_t column) { ErrorStatus returnValue = SUCCESS; diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/Displays.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/Displays.c index ab88cf2..fc9760f 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/Displays.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/Displays.c @@ -81,6 +81,11 @@ ErrorStatus Displays_construct(void) returnValue = Observable_addObserver(RTC_getObservable(rtc), Displays_mainDisplayObserverFromISR); } + if (returnValue == SUCCESS) + { + returnValue = Display_setBlinkingCursorState(mainDisplay, OFF); + } + if (returnValue == SUCCESS) { returnValue = Display_clearScreen(mainDisplay); @@ -95,6 +100,7 @@ ErrorStatus Displays_construct(void) { returnValue = Display_setContrast(mainDisplay, MAINDISP_DEFAULT_CONTRAST); } + return returnValue; } diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/Error.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/Error.c index ddcb630..deb983d 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/Error.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/Error.c @@ -70,7 +70,7 @@ ErrorStatus Error_construct(void) Observable_construct(&observable); errorQueue = xQueueCreate(ERROR_QUEUE_SIZE, sizeof(struct ErrorQueueItem)); - xTaskCreate(ErrorTask, "ErrorTask", 512, NULL, 1, &errorTaskHandle); + xTaskCreate(ErrorTask, "ErrorTask", 300, NULL, 1, &errorTaskHandle); return SUCCESS; } diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/MenuCore.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/MenuCore.c index d5e161d..fdc857a 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/MenuCore.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/MenuCore.c @@ -180,8 +180,8 @@ static void MenuCore_task(void* parameters) void MenuCore_changeState(struct MenuCore* self, T_MenuState newState) { Display_clearScreen(self->display); + Display_setBlinkingCursorState(self->display, OFF); self->menuState = newState; - LOGGER_WARNING(mainLog, "New menu index is %d", self->menuState); } static void MenuCore_printMenu(struct MenuCore* self) @@ -191,6 +191,13 @@ static void MenuCore_printMenu(struct MenuCore* self) // Always print Row1 (index0), ignoring the scrolling index Display_write(self->display, self->menuArray[self->menuState].row[0].text, 1, 1); + // Verify the cursor position. + // It may be off from a previous menu, so if it is off, reset it + if (self->cursorIndex > (self->menuArray[self->menuState].numberOfRows - 1)) + { + MenuCore_scrollIndexHandlerReset(self); + } + for (loopCounter = 1 ; loopCounter < self->display->displayDevice->parameters.numberOfRows; loopCounter++) { Display_write(self->display, self->menuArray[self->menuState].row[loopCounter + self->scrollOffset].text, loopCounter + 1, 1); @@ -212,21 +219,18 @@ static ErrorStatus MenuCore_performAction(struct MenuCore* self, char key, Keypa ErrorStatus returnValue = SUCCESS; struct KeyActionBinding keyAction = MenuCore_findKeyAction(self, key, keyState); - LOGGER_DEBUG(mainLog, "Action: received key %c, action to perform %d,", key, keyAction.action); switch (keyAction.action) { case NO_ACTION: { - LOGGER_INFO(mainLog, "This button has no action"); returnValue = ERROR; break; } case HOTKEY_SELECT: { - LOGGER_INFO(mainLog, "HOTKEY SELECT ITEM: char %c, argument %d - Going to state %d", keyAction.key, keyAction.argument, self->menuArray[self->menuState].row[keyAction.argument].newState); - self->cursorIndex = keyAction.argument; + self->selectionIndex = keyAction.argument; T_MenuState tempState = self->menuState; MenuCore_changeState(self, self->menuArray[self->menuState].row[keyAction.argument].newState); if (self->menuArray[tempState].row[keyAction.argument].actionPointer != NULL) @@ -239,8 +243,8 @@ static ErrorStatus MenuCore_performAction(struct MenuCore* self, char key, Keypa case SELECT: { - LOGGER_INFO(mainLog, "SELECT ITEM %d - going to state %d", self->cursorIndex, self->menuArray[self->menuState].row[self->cursorIndex].newState); T_MenuState tempState = self->menuState; + self->selectionIndex = self->cursorIndex; MenuCore_changeState(self, self->menuArray[self->menuState].row[self->cursorIndex].newState); if (self->menuArray[tempState].row[self->cursorIndex].actionPointer != NULL) { @@ -252,15 +256,15 @@ static ErrorStatus MenuCore_performAction(struct MenuCore* self, char key, Keypa case GOTO_STATE: { - LOGGER_INFO(mainLog, "Going to new state %d directly", keyAction.argument); + self->selectionIndex = self->cursorIndex; MenuCore_changeState(self, keyAction.argument); -// MenuCore_scrollIndexHandlerReset(self); + MenuCore_scrollIndexHandlerReset(self); break; } case EXECUTE_FUNCTION: { - LOGGER_INFO(mainLog, "Executing function directly"); + self->selectionIndex = self->cursorIndex; if (keyAction.actionPointer != NULL) { keyAction.actionPointer(self); @@ -270,19 +274,60 @@ static ErrorStatus MenuCore_performAction(struct MenuCore* self, char key, Keypa case SCROLL_UP: { - LOGGER_INFO(mainLog, "Scrolling up"); MenuCore_scrollUpIndexHandler(self); break; } case SCROLL_DOWN: { - LOGGER_INFO(mainLog, "Scrolling down"); MenuCore_scrollDownIndexHandler(self); break; } case DIGIT_INSERT: { LOGGER_INFO(mainLog, "Key is allowed as insert"); + + // Determine the number of digits currently used + int divider = self->insertValue; + int numberOfDigits = 0; + while (divider != 0) + { + divider /= 10; + numberOfDigits++; + } + + // The Argument carries the max number of digits for the current insertion value + if (numberOfDigits < keyAction.argument) + { + // Verify that only digits 0-9 are taken into account + // Copare with decimal ASCII + if ((keyAction.key > 47) && (keyAction.key < 58)) + { + // Shift the already inserted value to the left + self->insertValue = self->insertValue * 10; + // Add the latest value + self->insertValue = self->insertValue + (keyAction.key - 48); + } + } + LOGGER_INFO(mainLog, "Inserted Value is: %d", self->insertValue); + break; + } + + case DIGIT_REMOVE: + { + LOGGER_INFO(mainLog, "Key is allowed as remove"); + // Shift the already inserted value to the right + self->insertValue = self->insertValue / 10; + LOGGER_INFO(mainLog, "Inserted Value is: %d", self->insertValue); + break; + } + + case DIGIT_INSERT_CONFIRM: + { + LOGGER_INFO(mainLog, "Digit insert confirmed"); + if (keyAction.actionPointer != NULL) + { + keyAction.actionPointer(self); + } break; } } diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/MenuElements.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/MenuElements.c index 6342de9..4bb9c4e 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/MenuElements.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/MenuElements.c @@ -82,7 +82,8 @@ ErrorStatus MenuElements_addMenuPageRow (struct MenuPage* self, const char* text ErrorStatus returnValue = SUCCESS; if (self->numberOfRows < self->maxNumberOfRows) { - memcpy(self->row[self->numberOfRows].text, text, 20); +// memcpy(self->row[self->numberOfRows].text, text, 20); + self->row[self->numberOfRows].text = text; self->row[self->numberOfRows].newState = newState; self->row[self->numberOfRows].actionPointer = actionCall; self->numberOfRows++; @@ -219,3 +220,66 @@ ErrorStatus MenuElements_addKeyAction_SCROLLDOWN (struct MenuPage* self, char ke } return returnValue; } + + +ErrorStatus MenuElements_addKeyAction_DIGITINSERT (struct MenuPage* self, char key, Keypad_KeyState keyState, unsigned int maxNumberOfDigits) +{ + ErrorStatus returnValue = SUCCESS; + + if (self->numberOfKeys < self->maxNumberOfKeys) + { + self->keyActionBinding[self->numberOfKeys].key = key; + self->keyActionBinding[self->numberOfKeys].keyState = keyState; + self->keyActionBinding[self->numberOfKeys].action = DIGIT_INSERT; + self->keyActionBinding[self->numberOfKeys].argument = maxNumberOfDigits; + self->keyActionBinding[self->numberOfKeys].actionPointer = NULL; + self->numberOfKeys++; + } + else + { + returnValue = ERROR; + } + return returnValue; +} + + +ErrorStatus MenuElements_addKeyAction_DIGITREMOVE (struct MenuPage* self, char key, Keypad_KeyState keyState) +{ + ErrorStatus returnValue = SUCCESS; + + if (self->numberOfKeys < self->maxNumberOfKeys) + { + self->keyActionBinding[self->numberOfKeys].key = key; + self->keyActionBinding[self->numberOfKeys].keyState = keyState; + self->keyActionBinding[self->numberOfKeys].action = DIGIT_REMOVE; + self->keyActionBinding[self->numberOfKeys].argument = 0; + self->keyActionBinding[self->numberOfKeys].actionPointer = NULL; + self->numberOfKeys++; + } + else + { + returnValue = ERROR; + } + return returnValue; +} + + +ErrorStatus MenuElements_addKeyAction_DIGITINSERTCONFIRM (struct MenuPage* self, char key, Keypad_KeyState keyState, MenuCoreFunctionCall actionPointer) +{ + ErrorStatus returnValue = SUCCESS; + + if (self->numberOfKeys < self->maxNumberOfKeys) + { + self->keyActionBinding[self->numberOfKeys].key = key; + self->keyActionBinding[self->numberOfKeys].keyState = keyState; + self->keyActionBinding[self->numberOfKeys].action = DIGIT_INSERT_CONFIRM; + self->keyActionBinding[self->numberOfKeys].argument = 0; + self->keyActionBinding[self->numberOfKeys].actionPointer = actionPointer; + self->numberOfKeys++; + } + else + { + returnValue = ERROR; + } + return returnValue; +} diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/RepairPreset.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/RepairPreset.c index f44529e..340f772 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/RepairPreset.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/RepairPreset.c @@ -33,6 +33,8 @@ #include "RepairPreset.h" +#include "PCBA.h" + // ----------------------------------------------------------------------------- // Constant and macro definitions // ----------------------------------------------------------------------------- @@ -53,17 +55,50 @@ ErrorStatus RepairPreset_generateDefaultPreset(struct RepairPreset* self, unsign { ErrorStatus returnValue = SUCCESS; + if (presetNumber <= REPAIR_PRESET_MAX_ONE_STAGE_PRESETS) + { + self->numberOfStages = 1; + } + else + { + self->numberOfStages = 2; + } self->presetNumber = presetNumber; - self->numberOfStages = 1; - self->preset[0].softstartDuration = 100; - self->preset[0].duration = 200; - self->preset[0].voltage = 0; + self->preset[0].softstartDuration = 1800; + self->preset[0].duration = 28800; + if (PCBA_getInstance()->pcba == PCBA_CathodeMCP) + { + self->preset[0].voltage = -1000; + self->preset[1].voltage = -1000; + } + else + { + self->preset[0].voltage = 1000; + self->preset[1].voltage = 1000; + } // Generate dummy presets to fill the memory - self->preset[1].softstartDuration = 0; - self->preset[1].duration = 0; - self->preset[1].voltage = 0; + self->preset[1].softstartDuration = 1800; + self->preset[1].duration = 28800; return returnValue; } + +void RepairPreset_setSoftstartValue(struct RepairPresetParameters* self, unsigned int value) +{ + self->softstartDuration = value; +} + + +void RepairPreset_setDurationValue(struct RepairPresetParameters* self, unsigned int value) +{ + self->duration = value; +} + + +void RepairPreset_setVoltageValue(struct RepairPresetParameters* self, int value) +{ + self->voltage = value; +} + #endif /* REPAIRPRESET_C_ */ diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/RepairPresets.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/RepairPresets.c index 7887a24..81e061a 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/RepairPresets.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/RepairPresets.c @@ -74,7 +74,6 @@ struct RepairPresets* const self = &_self; static ErrorStatus RepairPresets_verifyCRCs(void); static ErrorStatus RepairPresets_verifyPresetCRC(struct RepairPresetStorageClass* repairPreset); -static ErrorStatus RepairPresets_writePreset(struct RepairPreset* preset); // ----------------------------------------------------------------------------- // Function definitions @@ -184,7 +183,7 @@ ErrorStatus RepairPresets_loadPresets(REPAIR_PRESETS_ID presetID) if (returnValue == SUCCESS) { // Create new cachedStorage with preset page number - returnValue = CachedStorage_construct(self->presetStorage, self->memoryDevice, pageNumber); + returnValue = CachedStorage_construct(self->presetStorage, self->memoryDevice, pageNumber, ((sizeof(struct RepairPresetStorageClass) * REPAIR_PRESETS_NUMBER_OF_PRESETS) / 4)); } else { @@ -215,9 +214,9 @@ ErrorStatus RepairPresets_loadPresets(REPAIR_PRESETS_ID presetID) } -const struct RepairPreset* RepairPresets_getPreset(unsigned int index) +struct RepairPreset* RepairPresets_getPreset(unsigned int index) { - const struct RepairPreset* returnValue = NULL; + struct RepairPreset* returnValue = NULL; if (self->initialized) { if (self->presetsLoaded) @@ -226,8 +225,8 @@ const struct RepairPreset* RepairPresets_getPreset(unsigned int index) if ((index > 0) || (index <= REPAIR_PRESETS_NUMBER_OF_PRESETS)) { struct RepairPresetStorageClass* tempPreset; - tempPreset = CachedStorage_readBlob(self->presetStorage, (index - 1) * sizeof(struct RepairPresetStorageClass)); - returnValue = (const struct RepairPreset*)&tempPreset->preset; + tempPreset = CachedStorage_readBlob(self->presetStorage, (index - 1) * sizeof(struct RepairPresetStorageClass) / 4); + returnValue = (struct RepairPreset*)&tempPreset->preset; } } } @@ -235,6 +234,13 @@ const struct RepairPreset* RepairPresets_getPreset(unsigned int index) } +void RepairPresets_savePresets(void) +{ + // Commit cache to memory - will not write if no changes have been made + CachedStorage_commit(self->presetStorage); +} + + static ErrorStatus RepairPresets_verifyCRCs(void) { ErrorStatus returnValue = SUCCESS; @@ -246,7 +252,7 @@ static ErrorStatus RepairPresets_verifyCRCs(void) for (loopCounter = 0; loopCounter < REPAIR_PRESETS_NUMBER_OF_PRESETS; loopCounter++) { // Load next preset from cache - tempPresetStorage = CachedStorage_readBlob(self->presetStorage, loopCounter * sizeof(struct RepairPresetStorageClass)); + tempPresetStorage = CachedStorage_readBlob(self->presetStorage, loopCounter * sizeof(struct RepairPresetStorageClass) / 4); // Verify CRC returnValue = RepairPresets_verifyPresetCRC(tempPresetStorage); // Check CRC verification @@ -285,10 +291,6 @@ static ErrorStatus RepairPresets_verifyPresetCRC(struct RepairPresetStorageClass returnValue = ERROR; LOGGER_ERROR(mainLog, "CRC ERROR at repair preset %d (calculated %X but loaded %X)", repairPreset->preset.presetNumber, (unsigned int)tempCRC, (unsigned int)repairPreset->crc); } - else - { - LOGGER_INFO(mainLog, "CRC OK at repair preset %d (calculated %X and loaded %X)", repairPreset->preset.presetNumber, (unsigned int)tempCRC, (unsigned int)repairPreset->crc); - } } else { @@ -299,7 +301,7 @@ static ErrorStatus RepairPresets_verifyPresetCRC(struct RepairPresetStorageClass -static ErrorStatus RepairPresets_writePreset(struct RepairPreset* preset) +ErrorStatus RepairPresets_writePreset(struct RepairPreset* preset) { ErrorStatus returnValue = SUCCESS; if (self->initialized) @@ -309,7 +311,8 @@ static ErrorStatus RepairPresets_writePreset(struct RepairPreset* preset) // Calculate CRC over preset tempPresetStorage.crc = crc32_calculate(0, &tempPresetStorage.preset, sizeof(struct RepairPreset)); // Put default preset on Cache - CachedStorage_writeBlob(self->presetStorage, (tempPresetStorage.preset.presetNumber - 1) * sizeof(struct RepairPresetStorageClass), &tempPresetStorage, sizeof(struct RepairPresetStorageClass)); + CachedStorage_writeBlob(self->presetStorage, (tempPresetStorage.preset.presetNumber - 1) * sizeof(struct RepairPresetStorageClass) / 4, + &tempPresetStorage, sizeof(struct RepairPresetStorageClass) / 4); } else diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/main.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/main.c index 23a1498..daae206 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/main.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/main.c @@ -129,7 +129,7 @@ int main (void) ledTaskArguments.led = ledOrange; ledTaskArguments.frequency = 1; - xTaskCreate(initTask, (const char* const)"initTask", 2048, NULL, 5, &initTaskHandle); + xTaskCreate(initTask, (const char* const)"initTask", 1024, NULL, 5, &initTaskHandle); /* Start the scheduler. */ vTaskStartScheduler(); @@ -169,6 +169,8 @@ static ErrorStatus systeminfoCommandHandler(void) snprintf(text, sizeof(text), "Free heap memory: %d bytes", freeMemory); LOGGER_INFO(mainLog, text); + vTaskDelay(10); + OS_logTaskInfo(initTaskHandle); vTaskDelay(10); OS_logTaskInfo(ledTaskHandle); vTaskDelay(10); @@ -180,6 +182,8 @@ static ErrorStatus systeminfoCommandHandler(void) vTaskDelay(10); OS_logTaskInfo(mainDisplay->taskHandle); vTaskDelay(10); + OS_logTaskInfo(repairMenus_getMainRepairMenu()->menuCore->taskHandle); + vTaskDelay(10); OS_logTaskInfo(repairProcesses_getMainRepairProcess()->taskHandle); @@ -275,7 +279,7 @@ static void ledBlinkTask (void* parameters) vTaskDelay(configTICK_RATE_HZ / (frequency * 2)); IODevice_write(&gpio->device, &low, 1); indicator[0] = ' '; - Display_write(mainDisplay, indicator, 1, 20); +// Display_write(mainDisplay, indicator, 1, 20); vTaskDelay(configTICK_RATE_HZ / (frequency * 2)); } } diff --git a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/repairMenu.c b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/repairMenu.c index 79a5367..26efe21 100644 --- a/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/repairMenu.c +++ b/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/src/repairMenu.c @@ -54,6 +54,7 @@ #include "PCBA.h" #include "rtc.h" #include "storm700.h" +#include "Version.h" // ----------------------------------------------------------------------------- // Constant and macro definitions @@ -87,12 +88,28 @@ static void repairMenu_printAskPause(struct MenuCore* self); static void repairMenu_printPause(struct MenuCore* self); static void repairMenu_printFinish(struct MenuCore* self); static void repairMenu_printPreset(struct MenuCore* self); +static void repairMenu_printChangePinScreen(struct MenuCore* self); +static void repairMenu_printIOInterlockStatus(struct MenuCore* self); + +static void repairMenu_configPresetFirstSoftstart(struct MenuCore* self); +static void repairMenu_configConfirmPresetFirstSoftstart(struct MenuCore* self); +static void repairMenu_configConfirmPresetFirstDuration(struct MenuCore* self); +static void repairMenu_configConfirmPresetFirstVoltage(struct MenuCore* self); +static void repairMenu_configConfirmPresetSecondSoftstart(struct MenuCore* self); +static void repairMenu_configConfirmPresetSecondDuration(struct MenuCore* self); +static void repairMenu_configConfirmPresetSecondVoltage(struct MenuCore* self); +static void repairMenu_configConfirmPreset(struct MenuCore* self); +static void repairMenu_printConfigPreset(struct MenuCore* self); + +static void repairMenu_printInfo(struct MenuCore* self); static void repairMenu_selectCathodeRepair(struct MenuCore* self); static void repairMenu_selectMCPRepair(struct MenuCore* self); static void repairMenu_selectPreset(struct MenuCore* self); static void repairMenu_solenoidLock(struct MenuCore* self); static void repairMenu_solenoidUnlock(struct MenuCore* self); +static void repairMenu_teslagunRelease(struct MenuCore* self); +static void repairMenu_teslagunBlock(struct MenuCore* self); static void repairMenu_startRepairProcess(struct MenuCore* self); static void repairMenu_stopRepairProcess(struct MenuCore* self); static void repairMenu_abortRepairProcessAndGotoMainMenu(struct MenuCore* self); @@ -303,7 +320,7 @@ static void repairMenu_printPreset(struct MenuCore* 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); + snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "Preset %d info", self->selectionIndex); // Always print Row1 (index0), ignoring the scrolling index Display_write(self->display, buffer, 1, 1); @@ -314,21 +331,210 @@ static void repairMenu_printPreset(struct MenuCore* self) snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "Volt:"); Display_write(self->display, buffer, 4, 1); - for (loopCounter = 0; loopCounter < RepairPresets_getPreset(self->cursorIndex)->numberOfStages; loopCounter++) + for (loopCounter = 0; loopCounter < RepairPresets_getPreset(self->selectionIndex)->numberOfStages; loopCounter++) { - snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "%5dm", (RepairPresets_getPreset(self->cursorIndex)->preset[loopCounter].softstartDuration / 60)); + snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "%5dm", (RepairPresets_getPreset(self->selectionIndex)->preset[loopCounter].softstartDuration / 60)); Display_write(self->display, buffer, 2, 8 + loopCounter * 7); - snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "%5dm", (RepairPresets_getPreset(self->cursorIndex)->preset[loopCounter].duration / 60)); + snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "%5dm", (RepairPresets_getPreset(self->selectionIndex)->preset[loopCounter].duration / 60)); Display_write(self->display, buffer, 3, 8 + loopCounter * 7); - snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "%5dV", RepairPresets_getPreset(self->cursorIndex)->preset[loopCounter].voltage); + snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "%5dV", RepairPresets_getPreset(self->selectionIndex)->preset[loopCounter].voltage); Display_write(self->display, buffer, 4, 8 + loopCounter * 7); } } +static void repairMenu_printChangePinScreen(struct MenuCore* self) +{ + char buffer[self->display->displayDevice->parameters.numberOfColumns]; + + snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), " New PIN: ----"); + Display_write(self->display, buffer, 3, 1); + snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), " Repeat PIN: ----"); + Display_write(self->display, buffer, 4, 1); + + Display_setCursorToPosition(self->display, 3, 14); + + DisplayDevice_setBlinkingCursorState(self->display->displayDevice, ON); + +} + + +static void repairMenu_printIOInterlockStatus(struct MenuCore* self) +{ + char buffer[self->display->displayDevice->parameters.numberOfColumns]; + + snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "Cover Interlock is"); + Display_write(self->display, buffer, 2, 1); + + if (Interlock_isClosed(interlock)) + { + snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "closed"); + Display_write(self->display, buffer, 3, 8); + } + else + { + snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "open"); + Display_write(self->display, buffer, 3, 9); + } +} + + +static void repairMenu_configPresetFirstSoftstart(struct MenuCore* self) +{ + self->insertValue = RepairPresets_getPreset(self->selectionIndex)->preset[0].softstartDuration / 60; +} + + +static void repairMenu_configConfirmPresetFirstSoftstart(struct MenuCore* self) +{ + // Takeover the inserted value + RepairPreset_setSoftstartValue(&RepairPresets_getPreset(self->selectionIndex)->preset[0], self->insertValue * 60); + // Goto next insertion state + MenuCore_changeState(self, RM_ADMIN_PRESET_CONFIG_FIRST_DURATION); + // Receive next value for insertion + self->insertValue = RepairPresets_getPreset(self->selectionIndex)->preset[0].duration / 60; +} + + +static void repairMenu_configConfirmPresetFirstDuration(struct MenuCore* self) +{ + // Takeover the inserted value + RepairPreset_setDurationValue(&RepairPresets_getPreset(self->selectionIndex)->preset[0], self->insertValue * 60); + // Goto next insertion state + MenuCore_changeState(self, RM_ADMIN_PRESET_CONFIG_FIRST_VOLTAGE); + // Receive next value for insertion + self->insertValue = RepairPresets_getPreset(self->selectionIndex)->preset[0].voltage; +} + + +static void repairMenu_configConfirmPresetFirstVoltage(struct MenuCore* self) +{ + // Takeover the inserted value + RepairPreset_setVoltageValue(&RepairPresets_getPreset(self->selectionIndex)->preset[0], self->insertValue); + + // Check if another Stage is available inside this preset + if (RepairPresets_getPreset(self->selectionIndex)->numberOfStages > 1) + { + // There is another stage + // Receive next value for insertion + self->insertValue = RepairPresets_getPreset(self->selectionIndex)->preset[1].softstartDuration / 60; + MenuCore_changeState(self, RM_ADMIN_PRESET_CONFIG_SECOND_SOFTSTART); + } + else + { + // Just a single stage preset + repairMenu_configConfirmPreset(self); + Display_setBlinkingCursorState(self->display, OFF); + } +} + + +static void repairMenu_configConfirmPresetSecondSoftstart(struct MenuCore* self) +{ + // Takeover the inserted value + RepairPreset_setSoftstartValue(&RepairPresets_getPreset(self->selectionIndex)->preset[1], self->insertValue * 60); + // Goto next insertion state + MenuCore_changeState(self, RM_ADMIN_PRESET_CONFIG_SECOND_DURATION); + // Receive next value for insertion + self->insertValue = RepairPresets_getPreset(self->selectionIndex)->preset[1].duration / 60; +} + + +static void repairMenu_configConfirmPresetSecondDuration(struct MenuCore* self) +{ + // Takeover the inserted value + RepairPreset_setDurationValue(&RepairPresets_getPreset(self->selectionIndex)->preset[1], self->insertValue * 60); + // Goto next insertion state + MenuCore_changeState(self, RM_ADMIN_PRESET_CONFIG_SECOND_VOLTAGE); + // Receive next value for insertion + self->insertValue = RepairPresets_getPreset(self->selectionIndex)->preset[1].voltage; +} + + +static void repairMenu_configConfirmPresetSecondVoltage(struct MenuCore* self) +{ + // Takeover the inserted value + RepairPreset_setVoltageValue(&RepairPresets_getPreset(self->selectionIndex)->preset[1], self->insertValue); + // Goto next insertion state + + // Check if another Stage is available inside this preset + if (RepairPresets_getPreset(self->selectionIndex)->numberOfStages > 2) + { + // There is another stage + + // TODO - Currently only two-stage presets are implemented + } + else + { + // No more stages available + repairMenu_configConfirmPreset(self); + Display_setBlinkingCursorState(self->display, OFF); + } +} + + +static void repairMenu_configConfirmPreset(struct MenuCore* self) +{ + RepairPresets_writePreset(RepairPresets_getPreset(self->selectionIndex)); + RepairPresets_savePresets(); + MenuCore_changeState(self, RM_ADMIN_PRESET_CONFIG_SELECT); + + Display_clearScreen(self->display); + char buffer[20]; + snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "Preset %d saved", self->selectionIndex); + Display_write(self->display, buffer, 3, 2); + vTaskDelay(2000); + +} + + +static void repairMenu_printConfigPreset(struct MenuCore* 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->selectionIndex); + // Always print Row1 (index0), ignoring the scrolling index + Display_write(self->display, buffer, 1, 1); + + snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "Start:"); + Display_write(self->display, buffer, 2, 1); + snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "Time:"); + Display_write(self->display, buffer, 3, 1); + snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "Volt:"); + Display_write(self->display, buffer, 4, 1); + + for (loopCounter = 0; loopCounter < RepairPresets_getPreset(self->selectionIndex)->numberOfStages; loopCounter++) + { + snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "%5dm", (RepairPresets_getPreset(self->selectionIndex)->preset[loopCounter].softstartDuration / 60)); + Display_write(self->display, buffer, 2, 8 + loopCounter * 7); + + snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "%5dm", (RepairPresets_getPreset(self->selectionIndex)->preset[loopCounter].duration / 60)); + Display_write(self->display, buffer, 3, 8 + loopCounter * 7); + + snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "%5dV", RepairPresets_getPreset(self->selectionIndex)->preset[loopCounter].voltage); + Display_write(self->display, buffer, 4, 8 + loopCounter * 7); + } + +} + + +static void repairMenu_printInfo(struct MenuCore* self) +{ + Display_write(mainDisplay, PCBA_getInstance()->name, 3, 2); + char buffer[20]; + + snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "SW V. %d.%d.%d.%d", Version_getInstance()->major, + Version_getInstance()->minor, + Version_getInstance()->branch, + Version_getInstance()->patch); + Display_write(mainDisplay, buffer, 4, 4); +} + + static void repairMenu_selectCathodeRepair(struct MenuCore* self) { @@ -351,11 +557,11 @@ static void repairMenu_selectMCPRepair(struct MenuCore* self) static void repairMenu_selectPreset(struct MenuCore* self) { struct RepairMenu* tempMenu = repairMenus_getMainRepairMenu(); - tempMenu->repairPreset = RepairPresets_getPreset(self->cursorIndex); + tempMenu->repairPreset = RepairPresets_getPreset(self->selectionIndex); Display_clearScreen(self->display); char buffer[20]; - snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "Preset %d selected", self->cursorIndex); + snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "Preset %d selected", self->selectionIndex); Display_write(self->display, buffer, 3, 2); vTaskDelay(2000); } @@ -372,6 +578,17 @@ static void repairMenu_solenoidUnlock(struct MenuCore* self) CoverSolenoid_unlock(); } +static void repairMenu_teslagunRelease(struct MenuCore* self) +{ + TeslaGunSafety_release(); +} + + +static void repairMenu_teslagunBlock(struct MenuCore* self) +{ + TeslaGunSafety_block(); +} + static void repairMenu_startRepairProcess(struct MenuCore* self) { @@ -527,6 +744,81 @@ void repairMenu_menuStateHandle(struct MenuCore* self) { repairMenu_printFinish(self); } + + else if (self->menuState == RM_ADMIN_IO_INTERLOCK) + { + // Show the current INTERLOCK status + repairMenu_printIOInterlockStatus(self); + } + + else if (self->menuState == RM_ADMIN_INFO) + { + repairMenu_printInfo(self); + } + + else if (self->menuState == RM_ADMIN_CHANGEPIN) + { + repairMenu_printChangePinScreen(self); + } + + else if (self->menuState == RM_ADMIN_PRESET_CONFIG_FIRST_SOFTSTART) + { + repairMenu_printConfigPreset(self); + char buffer[7]; + snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "%4d", self->insertValue); + Display_write(self->display, buffer, 2, 9); + Display_setCursorToPosition(self->display, 2, 12); + Display_setBlinkingCursorState(self->display, ON); + } + + else if (self->menuState == RM_ADMIN_PRESET_CONFIG_FIRST_DURATION) + { + repairMenu_printConfigPreset(self); + char buffer[7]; + snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "%4d", self->insertValue); + Display_write(self->display, buffer, 3, 9); + Display_setCursorToPosition(self->display, 3, 12); + Display_setBlinkingCursorState(self->display, ON); + } + + else if (self->menuState == RM_ADMIN_PRESET_CONFIG_FIRST_VOLTAGE) + { + repairMenu_printConfigPreset(self); + char buffer[7]; + snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "%5d", self->insertValue); + Display_write(self->display, buffer, 4, 8); + Display_setCursorToPosition(self->display, 4, 12); + Display_setBlinkingCursorState(self->display, ON); + } + else if (self->menuState == RM_ADMIN_PRESET_CONFIG_SECOND_SOFTSTART) + { + repairMenu_printConfigPreset(self); + char buffer[7]; + snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "%5d", self->insertValue); + Display_write(self->display, buffer, 2, 15); + Display_setCursorToPosition(self->display, 2, 19); + Display_setBlinkingCursorState(self->display, ON); + } + + else if (self->menuState == RM_ADMIN_PRESET_CONFIG_SECOND_DURATION) + { + repairMenu_printConfigPreset(self); + char buffer[7]; + snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "%5d", self->insertValue); + Display_write(self->display, buffer, 3, 15); + Display_setCursorToPosition(self->display, 3, 19); + Display_setBlinkingCursorState(self->display, ON); + } + + else if (self->menuState == RM_ADMIN_PRESET_CONFIG_SECOND_VOLTAGE) + { + repairMenu_printConfigPreset(self); + char buffer[7]; + snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "%5d", self->insertValue); + Display_write(self->display, buffer, 4, 15); + Display_setCursorToPosition(self->display, 4, 19); + Display_setBlinkingCursorState(self->display, ON); + } } @@ -534,18 +826,30 @@ void repairMenu_menuStateHandle(struct MenuCore* self) void repairMenu_createMenuEntries(struct MenuCore* menuCore) { + /* ------------------------------------------------------------------------------------------------------------------------------------------------------------------- + * MAIN MENU SCREEN with 3 options + * TUBE REPAIR + * for Tesla and Anode, go to repair menu directly + * for CathodeMCP, ask for type of repair first + * ADMINISTRATION + * CALIBRATION + * + * Key '0' allows control of the Solenoids - Hold to open, release to close + * ------------------------------------------------------------------------------------------------------------------------------------------------------------------- + */ MenuElements_createMenuPage(&menuCore->menuArray[RM_MAINMENU], MENU_HAS_CURSOR, 4); MenuElements_addMenuPageRow(&menuCore->menuArray[RM_MAINMENU], PCBA_getInstance()->name, RM_MAINMENU, NULL); if (PCBA_getInstance()->pcba == PCBA_CathodeMCP) { // For Cathode/MCP PCBA, the type of repair must be selected first - MenuElements_addMenuPageRow(&menuCore->menuArray[RM_MAINMENU], MenuText_MAINMENU[MENUTEXT_ENGLISH][1], RM_CATHODEMCP_SELECT, NULL); + MenuElements_addMenuPageRow(&menuCore->menuArray[RM_MAINMENU], MenuText_MAINMENU[MENUTEXT_ENGLISH][1], RM_REPAIR_CATHODEMCP_SELECT, NULL); + MenuElements_addMenuPageRow(&menuCore->menuArray[RM_MAINMENU], MenuText_MAINMENU[MENUTEXT_ENGLISH][2], RM_ADMIN_CATHODEMCP_SELECT, NULL); } else { MenuElements_addMenuPageRow(&menuCore->menuArray[RM_MAINMENU], MenuText_MAINMENU[MENUTEXT_ENGLISH][1], RM_REPAIRMENU, NULL); + MenuElements_addMenuPageRow(&menuCore->menuArray[RM_MAINMENU], MenuText_MAINMENU[MENUTEXT_ENGLISH][2], RM_ADMINMENU, NULL); } - MenuElements_addMenuPageRow(&menuCore->menuArray[RM_MAINMENU], MenuText_MAINMENU[MENUTEXT_ENGLISH][2], RM_ADMINMENU, NULL); MenuElements_addMenuPageRow(&menuCore->menuArray[RM_MAINMENU], MenuText_MAINMENU[MENUTEXT_ENGLISH][3], RM_CALIBRATIONMENU, NULL); MenuElements_addKeyAction_SCROLLUP(&menuCore->menuArray[RM_MAINMENU], 'U', PRESSED); MenuElements_addKeyAction_SCROLLDOWN(&menuCore->menuArray[RM_MAINMENU], 'D', PRESSED); @@ -556,19 +860,35 @@ void repairMenu_createMenuEntries(struct MenuCore* menuCore) MenuElements_addKeyAction_EXECUTEFUNCTION(&menuCore->menuArray[RM_MAINMENU], '0', PRESSED, repairMenu_solenoidUnlock); MenuElements_addKeyAction_EXECUTEFUNCTION(&menuCore->menuArray[RM_MAINMENU], '0', RELEASED, repairMenu_solenoidLock); - MenuElements_createMenuPage(&menuCore->menuArray[RM_CATHODEMCP_SELECT], MENU_HAS_CURSOR, 3); - MenuElements_addMenuPageRow(&menuCore->menuArray[RM_CATHODEMCP_SELECT], MenuText_CATHODEMCP_SELECT[MENUTEXT_ENGLISH][0], RM_CATHODEMCP_SELECT, NULL); - MenuElements_addMenuPageRow(&menuCore->menuArray[RM_CATHODEMCP_SELECT], MenuText_CATHODEMCP_SELECT[MENUTEXT_ENGLISH][1], RM_REPAIRMENU, repairMenu_selectCathodeRepair); - MenuElements_addMenuPageRow(&menuCore->menuArray[RM_CATHODEMCP_SELECT], MenuText_CATHODEMCP_SELECT[MENUTEXT_ENGLISH][2], RM_REPAIRMENU, repairMenu_selectMCPRepair); - MenuElements_addKeyAction_SCROLLUP(&menuCore->menuArray[RM_CATHODEMCP_SELECT], 'U', PRESSED); - MenuElements_addKeyAction_SCROLLDOWN(&menuCore->menuArray[RM_CATHODEMCP_SELECT], 'D', PRESSED); - MenuElements_addKeyAction_SELECT(&menuCore->menuArray[RM_CATHODEMCP_SELECT], 'E', PRESSED); - MenuElements_addKeyAction_HOTKEYSELECT(&menuCore->menuArray[RM_CATHODEMCP_SELECT], '1', PRESSED, 1); - MenuElements_addKeyAction_HOTKEYSELECT(&menuCore->menuArray[RM_CATHODEMCP_SELECT], '2', PRESSED, 2); - MenuElements_addKeyAction_GOTOSTATE(&menuCore->menuArray[RM_CATHODEMCP_SELECT], 'X', PRESSED, RM_MAINMENU); - MenuElements_addKeyAction_EXECUTEFUNCTION(&menuCore->menuArray[RM_CATHODEMCP_SELECT], '0', PRESSED, repairMenu_solenoidUnlock); - MenuElements_addKeyAction_EXECUTEFUNCTION(&menuCore->menuArray[RM_CATHODEMCP_SELECT], '0', RELEASED, repairMenu_solenoidLock); + /* ------------------------------------------------------------------------------------------------------------------------------------------------------------------- + * 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_REPAIR_CATHODEMCP_SELECT], MENU_HAS_CURSOR, 3); + MenuElements_addMenuPageRow(&menuCore->menuArray[RM_REPAIR_CATHODEMCP_SELECT], MenuText_CATHODEMCP_SELECT[MENUTEXT_ENGLISH][0], RM_REPAIR_CATHODEMCP_SELECT, NULL); + MenuElements_addMenuPageRow(&menuCore->menuArray[RM_REPAIR_CATHODEMCP_SELECT], MenuText_CATHODEMCP_SELECT[MENUTEXT_ENGLISH][1], RM_REPAIRMENU, repairMenu_selectCathodeRepair); + MenuElements_addMenuPageRow(&menuCore->menuArray[RM_REPAIR_CATHODEMCP_SELECT], MenuText_CATHODEMCP_SELECT[MENUTEXT_ENGLISH][2], RM_REPAIRMENU, repairMenu_selectMCPRepair); + MenuElements_addKeyAction_SCROLLUP(&menuCore->menuArray[RM_REPAIR_CATHODEMCP_SELECT], 'U', PRESSED); + MenuElements_addKeyAction_SCROLLDOWN(&menuCore->menuArray[RM_REPAIR_CATHODEMCP_SELECT], 'D', PRESSED); + MenuElements_addKeyAction_SELECT(&menuCore->menuArray[RM_REPAIR_CATHODEMCP_SELECT], 'E', PRESSED); + MenuElements_addKeyAction_HOTKEYSELECT(&menuCore->menuArray[RM_REPAIR_CATHODEMCP_SELECT], '1', PRESSED, 1); + MenuElements_addKeyAction_HOTKEYSELECT(&menuCore->menuArray[RM_REPAIR_CATHODEMCP_SELECT], '2', PRESSED, 2); + MenuElements_addKeyAction_GOTOSTATE(&menuCore->menuArray[RM_REPAIR_CATHODEMCP_SELECT], 'X', PRESSED, RM_MAINMENU); + MenuElements_addKeyAction_EXECUTEFUNCTION(&menuCore->menuArray[RM_REPAIR_CATHODEMCP_SELECT], '0', PRESSED, repairMenu_solenoidUnlock); + MenuElements_addKeyAction_EXECUTEFUNCTION(&menuCore->menuArray[RM_REPAIR_CATHODEMCP_SELECT], '0', RELEASED, repairMenu_solenoidLock); + /* ------------------------------------------------------------------------------------------------------------------------------------------------------------------- + * REPAIR MENU + * This screen is the main repair screen + * SELECT PRESET + * START REPAIR + * + * Key '0' allows control of the Solenoids - Hold to open, release to close + * ------------------------------------------------------------------------------------------------------------------------------------------------------------------- + */ MenuElements_createMenuPage(&menuCore->menuArray[RM_REPAIRMENU], MENU_HAS_CURSOR, 4); MenuElements_addMenuPageRow(&menuCore->menuArray[RM_REPAIRMENU], MenuText_REPAIRMENU[MENUTEXT_ENGLISH][0], RM_REPAIRMENU, NULL); MenuElements_addMenuPageRow(&menuCore->menuArray[RM_REPAIRMENU], MenuText_REPAIRMENU[MENUTEXT_ENGLISH][1], RM_PRESETMENU, NULL); @@ -581,7 +901,7 @@ void repairMenu_createMenuEntries(struct MenuCore* menuCore) if (PCBA_getInstance()->pcba == PCBA_CathodeMCP) { // For Cathode/MCP PCBA, the type of repair must can be selected - MenuElements_addKeyAction_GOTOSTATE(&menuCore->menuArray[RM_REPAIRMENU], 'X', PRESSED, RM_CATHODEMCP_SELECT); + MenuElements_addKeyAction_GOTOSTATE(&menuCore->menuArray[RM_REPAIRMENU], 'X', PRESSED, RM_REPAIR_CATHODEMCP_SELECT); } else { @@ -591,20 +911,14 @@ void repairMenu_createMenuEntries(struct MenuCore* menuCore) MenuElements_addKeyAction_EXECUTEFUNCTION(&menuCore->menuArray[RM_REPAIRMENU], '0', PRESSED, repairMenu_solenoidUnlock); MenuElements_addKeyAction_EXECUTEFUNCTION(&menuCore->menuArray[RM_REPAIRMENU], '0', RELEASED, repairMenu_solenoidLock); - - MenuElements_createMenuPage(&menuCore->menuArray[RM_ADMINMENU], MENU_HAS_NO_CURSOR, 2); - MenuElements_addMenuPageRow(&menuCore->menuArray[RM_ADMINMENU], MenuText_ADMINMENU[MENUTEXT_ENGLISH][0], RM_ADMINMENU, NULL); - MenuElements_addMenuPageRow(&menuCore->menuArray[RM_ADMINMENU], MenuText_ADMINMENU[MENUTEXT_ENGLISH][1], RM_ADMINMENU, NULL); - MenuElements_addMenuPageRow(&menuCore->menuArray[RM_ADMINMENU], MenuText_ADMINMENU[MENUTEXT_ENGLISH][2], RM_ADMINMENU, NULL); - MenuElements_addMenuPageRow(&menuCore->menuArray[RM_ADMINMENU], MenuText_ADMINMENU[MENUTEXT_ENGLISH][3], RM_ADMINMENU, NULL); - MenuElements_addKeyAction_GOTOSTATE(&menuCore->menuArray[RM_ADMINMENU], 'X', PRESSED, RM_MAINMENU); - - MenuElements_createMenuPage(&menuCore->menuArray[RM_CALIBRATIONMENU], MENU_HAS_NO_CURSOR, 2); - MenuElements_addMenuPageRow(&menuCore->menuArray[RM_CALIBRATIONMENU], MenuText_CALIBRATIONMENU[MENUTEXT_ENGLISH][0], RM_CALIBRATIONMENU, NULL); - MenuElements_addMenuPageRow(&menuCore->menuArray[RM_CALIBRATIONMENU], MenuText_CALIBRATIONMENU[MENUTEXT_ENGLISH][1], RM_CALIBRATIONMENU, NULL); - MenuElements_addKeyAction_GOTOSTATE(&menuCore->menuArray[RM_CALIBRATIONMENU], 'X', PRESSED, RM_MAINMENU); - - + /* ------------------------------------------------------------------------------------------------------------------------------------------------------------------- + * PRESET SELECTION + * Select the repair preset + * Key 'R' shows preset information + * + * Key '0' allows control of the Solenoids - Hold to open, release to close + * ------------------------------------------------------------------------------------------------------------------------------------------------------------------- + */ MenuElements_createMenuPage(&menuCore->menuArray[RM_PRESETMENU], MENU_HAS_CURSOR, 10); MenuElements_addMenuPageRow(&menuCore->menuArray[RM_PRESETMENU], MenuText_PRESETMENU[MENUTEXT_ENGLISH][0], RM_PRESETMENU, NULL); MenuElements_addMenuPageRow(&menuCore->menuArray[RM_PRESETMENU], MenuText_PRESETMENU[MENUTEXT_ENGLISH][1], RM_REPAIRMENU, repairMenu_selectPreset); @@ -633,10 +947,341 @@ void repairMenu_createMenuEntries(struct MenuCore* menuCore) MenuElements_addKeyAction_EXECUTEFUNCTION(&menuCore->menuArray[RM_PRESETMENU], '0', RELEASED, repairMenu_solenoidLock); MenuElements_addKeyAction_GOTOSTATE(&menuCore->menuArray[RM_PRESETMENU], 'R', PRESSED, RM_PRESET_PRINT); - MenuElements_createMenuPage(&menuCore->menuArray[RM_PRESET_PRINT], MENU_HAS_NO_CURSOR, 10); + /* ------------------------------------------------------------------------------------------------------------------------------------------------------------------- + * PRESET INFORMATION + * Shows the preset information. Screen is generated via function, not as a menu + * Key 'L' and 'X' both leads back to preset selection. + * Showing information does not select the preset + * + * Key '0' allows control of the Solenoids - Hold to open, release to close + * ------------------------------------------------------------------------------------------------------------------------------------------------------------------- + */ + MenuElements_createMenuPage(&menuCore->menuArray[RM_PRESET_PRINT], MENU_HAS_NO_CURSOR, 4); MenuElements_addKeyAction_GOTOSTATE(&menuCore->menuArray[RM_PRESET_PRINT], 'X', PRESSED, RM_PRESETMENU); MenuElements_addKeyAction_GOTOSTATE(&menuCore->menuArray[RM_PRESET_PRINT], 'L', PRESSED, RM_PRESETMENU); + + + + /* ------------------------------------------------------------------------------------------------------------------------------------------------------------------- + * ADMIN 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_ADMIN_CATHODEMCP_SELECT], MENU_HAS_CURSOR, 3); + MenuElements_addMenuPageRow(&menuCore->menuArray[RM_ADMIN_CATHODEMCP_SELECT], MenuText_ADMIN_CATHODEMCP_SELECT[MENUTEXT_ENGLISH][0], RM_ADMIN_CATHODEMCP_SELECT, NULL); + MenuElements_addMenuPageRow(&menuCore->menuArray[RM_ADMIN_CATHODEMCP_SELECT], MenuText_ADMIN_CATHODEMCP_SELECT[MENUTEXT_ENGLISH][1], RM_ADMINMENU, repairMenu_selectCathodeRepair); + MenuElements_addMenuPageRow(&menuCore->menuArray[RM_ADMIN_CATHODEMCP_SELECT], MenuText_ADMIN_CATHODEMCP_SELECT[MENUTEXT_ENGLISH][2], RM_ADMINMENU, repairMenu_selectMCPRepair); + MenuElements_addKeyAction_SCROLLUP(&menuCore->menuArray[RM_ADMIN_CATHODEMCP_SELECT], 'U', PRESSED); + MenuElements_addKeyAction_SCROLLDOWN(&menuCore->menuArray[RM_ADMIN_CATHODEMCP_SELECT], 'D', PRESSED); + MenuElements_addKeyAction_SELECT(&menuCore->menuArray[RM_ADMIN_CATHODEMCP_SELECT], 'E', PRESSED); + MenuElements_addKeyAction_HOTKEYSELECT(&menuCore->menuArray[RM_ADMIN_CATHODEMCP_SELECT], '1', PRESSED, 1); + MenuElements_addKeyAction_HOTKEYSELECT(&menuCore->menuArray[RM_ADMIN_CATHODEMCP_SELECT], '2', PRESSED, 2); + MenuElements_addKeyAction_GOTOSTATE(&menuCore->menuArray[RM_ADMIN_CATHODEMCP_SELECT], 'X', PRESSED, RM_MAINMENU); + + /* ------------------------------------------------------------------------------------------------------------------------------------------------------------------- + * ADMINISTRATION MAIN MENU + * All administrational functionality is concentrated in this menu. Allows access to: + * Change pin + * I/O control + * PRESET configuration + * Info & Version + * ------------------------------------------------------------------------------------------------------------------------------------------------------------------- + */ + MenuElements_createMenuPage(&menuCore->menuArray[RM_ADMINMENU], MENU_HAS_CURSOR, 5); + MenuElements_addMenuPageRow(&menuCore->menuArray[RM_ADMINMENU], MenuText_ADMINMENU[MENUTEXT_ENGLISH][0], RM_ADMINMENU, NULL); + MenuElements_addMenuPageRow(&menuCore->menuArray[RM_ADMINMENU], MenuText_ADMINMENU[MENUTEXT_ENGLISH][1], RM_ADMIN_CHANGEPIN, NULL); + MenuElements_addMenuPageRow(&menuCore->menuArray[RM_ADMINMENU], MenuText_ADMINMENU[MENUTEXT_ENGLISH][2], RM_ADMIN_IOCONTROL, NULL); + MenuElements_addMenuPageRow(&menuCore->menuArray[RM_ADMINMENU], MenuText_ADMINMENU[MENUTEXT_ENGLISH][3], RM_ADMIN_PRESET_CONFIG_SELECT, NULL); + MenuElements_addMenuPageRow(&menuCore->menuArray[RM_ADMINMENU], MenuText_ADMINMENU[MENUTEXT_ENGLISH][4], RM_ADMIN_INFO, NULL); + if (PCBA_getInstance()->pcba == PCBA_CathodeMCP) + { + MenuElements_addKeyAction_GOTOSTATE(&menuCore->menuArray[RM_ADMINMENU], 'X', PRESSED, RM_ADMIN_CATHODEMCP_SELECT); + } + else + { + MenuElements_addKeyAction_GOTOSTATE(&menuCore->menuArray[RM_ADMINMENU], 'X', PRESSED, RM_MAINMENU); + } + MenuElements_addKeyAction_SCROLLUP(&menuCore->menuArray[RM_ADMINMENU], 'U', PRESSED); + MenuElements_addKeyAction_SCROLLDOWN(&menuCore->menuArray[RM_ADMINMENU], 'D', PRESSED); + MenuElements_addKeyAction_SELECT(&menuCore->menuArray[RM_ADMINMENU], 'E', PRESSED); + MenuElements_addKeyAction_HOTKEYSELECT(&menuCore->menuArray[RM_ADMINMENU], '1', PRESSED, 1); + MenuElements_addKeyAction_HOTKEYSELECT(&menuCore->menuArray[RM_ADMINMENU], '2', PRESSED, 2); + MenuElements_addKeyAction_HOTKEYSELECT(&menuCore->menuArray[RM_ADMINMENU], '3', PRESSED, 3); + MenuElements_addKeyAction_HOTKEYSELECT(&menuCore->menuArray[RM_ADMINMENU], '4', PRESSED, 4); + + /* ------------------------------------------------------------------------------------------------------------------------------------------------------------------- + * ADMIN change pin + * ------------------------------------------------------------------------------------------------------------------------------------------------------------------- + */ + + MenuElements_createMenuPage(&menuCore->menuArray[RM_ADMIN_CHANGEPIN], MENU_HAS_NO_CURSOR, 5); + MenuElements_addMenuPageRow(&menuCore->menuArray[RM_ADMIN_CHANGEPIN], MenuText_ADMINCHANGEPINMENU[MENUTEXT_ENGLISH][0], RM_ADMIN_CHANGEPIN, NULL); + MenuElements_addKeyAction_GOTOSTATE(&menuCore->menuArray[RM_ADMIN_CHANGEPIN], 'X', PRESSED, RM_ADMINMENU); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_CHANGEPIN], '0', PRESSED, 4); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_CHANGEPIN], '1', PRESSED, 4); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_CHANGEPIN], '2', PRESSED, 4); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_CHANGEPIN], '3', PRESSED, 4); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_CHANGEPIN], '4', PRESSED, 4); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_CHANGEPIN], '5', PRESSED, 4); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_CHANGEPIN], '6', PRESSED, 4); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_CHANGEPIN], '7', PRESSED, 4); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_CHANGEPIN], '8', PRESSED, 4); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_CHANGEPIN], '9', PRESSED, 4); + MenuElements_addKeyAction_DIGITREMOVE(&menuCore->menuArray[RM_ADMIN_CHANGEPIN], 'L', PRESSED); + + + /* ------------------------------------------------------------------------------------------------------------------------------------------------------------------- + * ADMIN I/O control + * Read interlock + * Solenoid + * Get Voltage In + * Set Voltage Out + * Teslagun Relais + * ------------------------------------------------------------------------------------------------------------------------------------------------------------------- + */ + // TESLA PCBA has one additional menu item + if (PCBA_getInstance()->pcba == PCBA_Tesla) + { + MenuElements_createMenuPage(&menuCore->menuArray[RM_ADMIN_IOCONTROL], MENU_HAS_CURSOR, 6); + } + else + { + MenuElements_createMenuPage(&menuCore->menuArray[RM_ADMIN_IOCONTROL], MENU_HAS_CURSOR, 5); + } + MenuElements_addMenuPageRow(&menuCore->menuArray[RM_ADMIN_IOCONTROL], MenuText_ADMINIOMAINMENU[MENUTEXT_ENGLISH][0], RM_ADMIN_IOCONTROL, NULL); + MenuElements_addMenuPageRow(&menuCore->menuArray[RM_ADMIN_IOCONTROL], MenuText_ADMINIOMAINMENU[MENUTEXT_ENGLISH][1], RM_ADMIN_IO_INTERLOCK, NULL); + MenuElements_addMenuPageRow(&menuCore->menuArray[RM_ADMIN_IOCONTROL], MenuText_ADMINIOMAINMENU[MENUTEXT_ENGLISH][2], RM_ADMIN_IO_SOLENOID, NULL); + MenuElements_addMenuPageRow(&menuCore->menuArray[RM_ADMIN_IOCONTROL], MenuText_ADMINIOMAINMENU[MENUTEXT_ENGLISH][3], RM_ADMIN_IO_VOLTAGE_IN, NULL); + MenuElements_addMenuPageRow(&menuCore->menuArray[RM_ADMIN_IOCONTROL], MenuText_ADMINIOMAINMENU[MENUTEXT_ENGLISH][4], RM_ADMIN_IO_VOLTAGE_OUT, NULL); + if (PCBA_getInstance()->pcba == PCBA_Tesla) + { + MenuElements_addMenuPageRow(&menuCore->menuArray[RM_ADMIN_IOCONTROL], MenuText_ADMINIOMAINMENU[MENUTEXT_ENGLISH][5], RM_ADMIN_IO_TESLAGUN, NULL); + } + MenuElements_addKeyAction_GOTOSTATE(&menuCore->menuArray[RM_ADMIN_IOCONTROL], 'X', PRESSED, RM_ADMINMENU); + MenuElements_addKeyAction_SCROLLUP(&menuCore->menuArray[RM_ADMIN_IOCONTROL], 'U', PRESSED); + MenuElements_addKeyAction_SCROLLDOWN(&menuCore->menuArray[RM_ADMIN_IOCONTROL], 'D', PRESSED); + MenuElements_addKeyAction_SELECT(&menuCore->menuArray[RM_ADMIN_IOCONTROL], 'E', PRESSED); + MenuElements_addKeyAction_HOTKEYSELECT(&menuCore->menuArray[RM_ADMIN_IOCONTROL], '1', PRESSED, 1); + MenuElements_addKeyAction_HOTKEYSELECT(&menuCore->menuArray[RM_ADMIN_IOCONTROL], '2', PRESSED, 2); + MenuElements_addKeyAction_HOTKEYSELECT(&menuCore->menuArray[RM_ADMIN_IOCONTROL], '3', PRESSED, 3); + MenuElements_addKeyAction_HOTKEYSELECT(&menuCore->menuArray[RM_ADMIN_IOCONTROL], '4', PRESSED, 4); + if (PCBA_getInstance()->pcba == PCBA_Tesla) + { + MenuElements_addKeyAction_HOTKEYSELECT(&menuCore->menuArray[RM_ADMIN_IOCONTROL], '5', PRESSED, 5); + } + + /* ------------------------------------------------------------------------------------------------------------------------------------------------------------------- + * ADMIN interlock control + * Shows the interlock state. Screen is generated via function, not as a menu + * Key 'X' returns to I/O menu + * + * ------------------------------------------------------------------------------------------------------------------------------------------------------------------- + */ + MenuElements_createMenuPage(&menuCore->menuArray[RM_ADMIN_IO_INTERLOCK], MENU_HAS_NO_CURSOR, 4); + MenuElements_addMenuPageRow(&menuCore->menuArray[RM_ADMIN_IOCONTROL], MenuText_ADMINIOINTERLOCKMENU[MENUTEXT_ENGLISH][0], RM_ADMIN_IO_INTERLOCK, NULL); + MenuElements_addKeyAction_GOTOSTATE(&menuCore->menuArray[RM_ADMIN_IO_INTERLOCK], 'X', PRESSED, RM_ADMIN_IOCONTROL); + + /* ------------------------------------------------------------------------------------------------------------------------------------------------------------------- + * ADMIN Solenoid control + * Allows control over the Solenoids + * Key '0' controls the solenoid. Holding opens, releasing closes + * Key 'X' returns to I/O menu + * + * ------------------------------------------------------------------------------------------------------------------------------------------------------------------- + */ + MenuElements_createMenuPage(&menuCore->menuArray[RM_ADMIN_IO_SOLENOID], MENU_HAS_NO_CURSOR, 4); + MenuElements_addMenuPageRow(&menuCore->menuArray[RM_ADMIN_IO_SOLENOID], MenuText_ADMINSOLENOIDMENU[MENUTEXT_ENGLISH][0], RM_ADMIN_IO_SOLENOID, NULL); + MenuElements_addMenuPageRow(&menuCore->menuArray[RM_ADMIN_IO_SOLENOID], MenuText_ADMINSOLENOIDMENU[MENUTEXT_ENGLISH][1], RM_ADMIN_IO_SOLENOID, NULL); + MenuElements_addKeyAction_EXECUTEFUNCTION(&menuCore->menuArray[RM_ADMIN_IO_SOLENOID], '0', PRESSED, repairMenu_solenoidUnlock); + MenuElements_addKeyAction_EXECUTEFUNCTION(&menuCore->menuArray[RM_ADMIN_IO_SOLENOID], '0', RELEASED, repairMenu_solenoidLock); + MenuElements_addKeyAction_GOTOSTATE(&menuCore->menuArray[RM_ADMIN_IO_SOLENOID], 'X', PRESSED, RM_ADMIN_IOCONTROL); + + /* ------------------------------------------------------------------------------------------------------------------------------------------------------------------- + * ADMIN Teslagun relais control + * + * THIS MENU IS AVAILABLE ONLY ON TESLA REPAIR PCBAs + * + * Allows control over the TeslaGun relais + * Key '0' controls the relais. Holding opens, releasing closes + * Key 'X' returns to I/O menu + * + * ------------------------------------------------------------------------------------------------------------------------------------------------------------------- + */ + if (PCBA_getInstance()->pcba == PCBA_Tesla) + { + MenuElements_createMenuPage(&menuCore->menuArray[RM_ADMIN_IO_TESLAGUN], MENU_HAS_NO_CURSOR, 4); + MenuElements_addMenuPageRow(&menuCore->menuArray[RM_ADMIN_IO_TESLAGUN], MenuText_ADMINTESLAGUNMENU[MENUTEXT_ENGLISH][0], RM_ADMIN_IO_TESLAGUN, NULL); + MenuElements_addMenuPageRow(&menuCore->menuArray[RM_ADMIN_IO_TESLAGUN], MenuText_ADMINTESLAGUNMENU[MENUTEXT_ENGLISH][1], RM_ADMIN_IO_TESLAGUN, NULL); + MenuElements_addKeyAction_EXECUTEFUNCTION(&menuCore->menuArray[RM_ADMIN_IO_TESLAGUN], '0', PRESSED, repairMenu_teslagunRelease); + MenuElements_addKeyAction_EXECUTEFUNCTION(&menuCore->menuArray[RM_ADMIN_IO_TESLAGUN], '0', RELEASED, repairMenu_teslagunBlock); + MenuElements_addKeyAction_GOTOSTATE(&menuCore->menuArray[RM_ADMIN_IO_TESLAGUN], 'X', PRESSED, RM_ADMIN_IOCONTROL); + } + + /* ------------------------------------------------------------------------------------------------------------------------------------------------------------------- + * ADMIN preset config + * Select the repair preset to configure/modify + * + * ------------------------------------------------------------------------------------------------------------------------------------------------------------------- + */ + MenuElements_createMenuPage(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SELECT], MENU_HAS_CURSOR, 10); + MenuElements_addMenuPageRow(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SELECT], MenuText_ADMINPRESETCONFIGSELECTMENU[MENUTEXT_ENGLISH][0], RM_ADMIN_PRESET_CONFIG_SELECT, NULL); + MenuElements_addMenuPageRow(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SELECT], MenuText_ADMINPRESETCONFIGSELECTMENU[MENUTEXT_ENGLISH][1], RM_ADMIN_PRESET_CONFIG_FIRST_SOFTSTART, repairMenu_configPresetFirstSoftstart); + MenuElements_addMenuPageRow(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SELECT], MenuText_ADMINPRESETCONFIGSELECTMENU[MENUTEXT_ENGLISH][2], RM_ADMIN_PRESET_CONFIG_FIRST_SOFTSTART, repairMenu_configPresetFirstSoftstart); + MenuElements_addMenuPageRow(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SELECT], MenuText_ADMINPRESETCONFIGSELECTMENU[MENUTEXT_ENGLISH][3], RM_ADMIN_PRESET_CONFIG_FIRST_SOFTSTART, repairMenu_configPresetFirstSoftstart); + MenuElements_addMenuPageRow(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SELECT], MenuText_ADMINPRESETCONFIGSELECTMENU[MENUTEXT_ENGLISH][4], RM_ADMIN_PRESET_CONFIG_FIRST_SOFTSTART, repairMenu_configPresetFirstSoftstart); + MenuElements_addMenuPageRow(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SELECT], MenuText_ADMINPRESETCONFIGSELECTMENU[MENUTEXT_ENGLISH][5], RM_ADMIN_PRESET_CONFIG_FIRST_SOFTSTART, repairMenu_configPresetFirstSoftstart); + MenuElements_addMenuPageRow(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SELECT], MenuText_ADMINPRESETCONFIGSELECTMENU[MENUTEXT_ENGLISH][6], RM_ADMIN_PRESET_CONFIG_FIRST_SOFTSTART, repairMenu_configPresetFirstSoftstart); + MenuElements_addMenuPageRow(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SELECT], MenuText_ADMINPRESETCONFIGSELECTMENU[MENUTEXT_ENGLISH][7], RM_ADMIN_PRESET_CONFIG_FIRST_SOFTSTART, repairMenu_configPresetFirstSoftstart); + MenuElements_addMenuPageRow(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SELECT], MenuText_ADMINPRESETCONFIGSELECTMENU[MENUTEXT_ENGLISH][8], RM_ADMIN_PRESET_CONFIG_FIRST_SOFTSTART, repairMenu_configPresetFirstSoftstart); + MenuElements_addMenuPageRow(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SELECT], MenuText_ADMINPRESETCONFIGSELECTMENU[MENUTEXT_ENGLISH][9], RM_ADMIN_PRESET_CONFIG_FIRST_SOFTSTART, repairMenu_configPresetFirstSoftstart); + MenuElements_addKeyAction_SCROLLUP(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SELECT], 'U', PRESSED); + MenuElements_addKeyAction_SCROLLDOWN(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SELECT], 'D', PRESSED); + MenuElements_addKeyAction_SELECT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SELECT], 'E', PRESSED); + MenuElements_addKeyAction_HOTKEYSELECT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SELECT], '1', PRESSED, 1); + MenuElements_addKeyAction_HOTKEYSELECT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SELECT], '2', PRESSED, 2); + MenuElements_addKeyAction_HOTKEYSELECT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SELECT], '3', PRESSED, 3); + MenuElements_addKeyAction_HOTKEYSELECT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SELECT], '4', PRESSED, 4); + MenuElements_addKeyAction_HOTKEYSELECT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SELECT], '5', PRESSED, 5); + MenuElements_addKeyAction_HOTKEYSELECT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SELECT], '6', PRESSED, 6); + MenuElements_addKeyAction_HOTKEYSELECT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SELECT], '7', PRESSED, 7); + MenuElements_addKeyAction_HOTKEYSELECT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SELECT], '8', PRESSED, 8); + MenuElements_addKeyAction_HOTKEYSELECT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SELECT], '9', PRESSED, 9); + MenuElements_addKeyAction_GOTOSTATE(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SELECT], 'X', PRESSED, RM_ADMINMENU); + + /* ------------------------------------------------------------------------------------------------------------------------------------------------------------------- + * ADMIN preset config + * Select the repair preset to configure/modify + * + * ------------------------------------------------------------------------------------------------------------------------------------------------------------------- + */ + unsigned int numberOfDigits = 0; + if (PCBA_getInstance()->pcba == PCBA_Anode) + { + numberOfDigits = 5; + } + else if (PCBA_getInstance()->pcba == PCBA_CathodeMCP) + { + numberOfDigits = 4; + } + else if (PCBA_getInstance()->pcba == PCBA_Tesla) + { + numberOfDigits = 4; + } + MenuElements_createMenuPage(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_FIRST_SOFTSTART], MENU_HAS_NO_CURSOR, 10); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_FIRST_SOFTSTART], '0', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_FIRST_SOFTSTART], '1', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_FIRST_SOFTSTART], '2', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_FIRST_SOFTSTART], '3', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_FIRST_SOFTSTART], '4', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_FIRST_SOFTSTART], '5', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_FIRST_SOFTSTART], '6', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_FIRST_SOFTSTART], '7', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_FIRST_SOFTSTART], '8', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_FIRST_SOFTSTART], '9', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITREMOVE(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_FIRST_SOFTSTART], 'L', PRESSED); + MenuElements_addKeyAction_DIGITINSERTCONFIRM(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_FIRST_SOFTSTART], 'E', PRESSED, repairMenu_configConfirmPresetFirstSoftstart); + MenuElements_addKeyAction_GOTOSTATE(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_FIRST_SOFTSTART], 'X', PRESSED, RM_ADMIN_PRESET_CONFIG_SELECT); + + MenuElements_createMenuPage(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_FIRST_DURATION], MENU_HAS_NO_CURSOR, 10); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_FIRST_DURATION], '0', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_FIRST_DURATION], '1', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_FIRST_DURATION], '2', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_FIRST_DURATION], '3', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_FIRST_DURATION], '4', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_FIRST_DURATION], '5', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_FIRST_DURATION], '6', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_FIRST_DURATION], '7', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_FIRST_DURATION], '8', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_FIRST_DURATION], '9', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITREMOVE(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_FIRST_DURATION], 'L', PRESSED); + MenuElements_addKeyAction_DIGITINSERTCONFIRM(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_FIRST_DURATION], 'E', PRESSED, repairMenu_configConfirmPresetFirstDuration); + MenuElements_addKeyAction_GOTOSTATE(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_FIRST_DURATION], 'X', PRESSED, RM_ADMIN_PRESET_CONFIG_SELECT); + + MenuElements_createMenuPage(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_FIRST_VOLTAGE], MENU_HAS_NO_CURSOR, 10); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_FIRST_VOLTAGE], '0', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_FIRST_VOLTAGE], '1', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_FIRST_VOLTAGE], '2', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_FIRST_VOLTAGE], '3', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_FIRST_VOLTAGE], '4', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_FIRST_VOLTAGE], '5', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_FIRST_VOLTAGE], '6', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_FIRST_VOLTAGE], '7', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_FIRST_VOLTAGE], '8', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_FIRST_VOLTAGE], '9', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITREMOVE(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_FIRST_VOLTAGE], 'L', PRESSED); + MenuElements_addKeyAction_DIGITINSERTCONFIRM(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_FIRST_VOLTAGE], 'E', PRESSED, repairMenu_configConfirmPresetFirstVoltage); + MenuElements_addKeyAction_GOTOSTATE(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_FIRST_VOLTAGE], 'X', PRESSED, RM_ADMIN_PRESET_CONFIG_SELECT); + + MenuElements_createMenuPage(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SECOND_SOFTSTART], MENU_HAS_NO_CURSOR, 10); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SECOND_SOFTSTART], '0', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SECOND_SOFTSTART], '1', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SECOND_SOFTSTART], '2', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SECOND_SOFTSTART], '3', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SECOND_SOFTSTART], '4', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SECOND_SOFTSTART], '5', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SECOND_SOFTSTART], '6', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SECOND_SOFTSTART], '7', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SECOND_SOFTSTART], '8', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SECOND_SOFTSTART], '9', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITREMOVE(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SECOND_SOFTSTART], 'L', PRESSED); + MenuElements_addKeyAction_DIGITINSERTCONFIRM(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SECOND_SOFTSTART], 'E', PRESSED, repairMenu_configConfirmPresetSecondSoftstart); + MenuElements_addKeyAction_GOTOSTATE(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SECOND_SOFTSTART], 'X', PRESSED, RM_ADMIN_PRESET_CONFIG_SELECT); + + MenuElements_createMenuPage(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SECOND_DURATION], MENU_HAS_NO_CURSOR, 10); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SECOND_DURATION], '0', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SECOND_DURATION], '1', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SECOND_DURATION], '2', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SECOND_DURATION], '3', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SECOND_DURATION], '4', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SECOND_DURATION], '5', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SECOND_DURATION], '6', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SECOND_DURATION], '7', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SECOND_DURATION], '8', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SECOND_DURATION], '9', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITREMOVE(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SECOND_DURATION], 'L', PRESSED); + MenuElements_addKeyAction_DIGITINSERTCONFIRM(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SECOND_DURATION], 'E', PRESSED, repairMenu_configConfirmPresetSecondDuration); + MenuElements_addKeyAction_GOTOSTATE(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SECOND_DURATION], 'X', PRESSED, RM_ADMIN_PRESET_CONFIG_SELECT); + + MenuElements_createMenuPage(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SECOND_VOLTAGE], MENU_HAS_NO_CURSOR, 10); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SECOND_VOLTAGE], '0', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SECOND_VOLTAGE], '1', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SECOND_VOLTAGE], '2', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SECOND_VOLTAGE], '3', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SECOND_VOLTAGE], '4', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SECOND_VOLTAGE], '5', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SECOND_VOLTAGE], '6', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SECOND_VOLTAGE], '7', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SECOND_VOLTAGE], '8', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITINSERT(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SECOND_VOLTAGE], '9', PRESSED, numberOfDigits); + MenuElements_addKeyAction_DIGITREMOVE(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SECOND_VOLTAGE], 'L', PRESSED); + MenuElements_addKeyAction_DIGITINSERTCONFIRM(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SECOND_VOLTAGE], 'E', PRESSED, repairMenu_configConfirmPresetSecondVoltage); + MenuElements_addKeyAction_GOTOSTATE(&menuCore->menuArray[RM_ADMIN_PRESET_CONFIG_SECOND_VOLTAGE], 'X', PRESSED, RM_ADMIN_PRESET_CONFIG_SELECT); + + /* ------------------------------------------------------------------------------------------------------------------------------------------------------------------- + * ADMIN INFORMATION & VERSION SCREEN + * ------------------------------------------------------------------------------------------------------------------------------------------------------------------- + */ + MenuElements_createMenuPage(&menuCore->menuArray[RM_ADMIN_INFO], MENU_HAS_NO_CURSOR, 5); + MenuElements_addMenuPageRow(&menuCore->menuArray[RM_ADMIN_INFO], MenuText_ADMININFOMENU[MENUTEXT_ENGLISH][0], RM_ADMIN_INFO, NULL); + MenuElements_addKeyAction_GOTOSTATE(&menuCore->menuArray[RM_ADMIN_INFO], 'X', PRESSED, RM_ADMINMENU); + + + + + + + + + + MenuElements_createMenuPage(&menuCore->menuArray[RM_CALIBRATIONMENU], MENU_HAS_NO_CURSOR, 2); + MenuElements_addMenuPageRow(&menuCore->menuArray[RM_CALIBRATIONMENU], MenuText_CALIBRATIONMENU[MENUTEXT_ENGLISH][0], RM_CALIBRATIONMENU, NULL); + MenuElements_addMenuPageRow(&menuCore->menuArray[RM_CALIBRATIONMENU], MenuText_CALIBRATIONMENU[MENUTEXT_ENGLISH][1], RM_CALIBRATIONMENU, NULL); + MenuElements_addKeyAction_GOTOSTATE(&menuCore->menuArray[RM_CALIBRATIONMENU], 'X', PRESSED, RM_MAINMENU); + + 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);