From deca21ba702845cfa539414565792474dadfaf3d Mon Sep 17 00:00:00 2001 From: ActuallyTaylor Date: Mon, 13 Nov 2023 19:33:37 -0500 Subject: [PATCH 1/7] Updated HUDL to new CAN Signed-off-by: ActuallyTaylor --- include/HUDL/HUDL.hpp | 329 ++++++++---------------------------------- libs/EVT-core | 2 +- src/HUDL/HUDL.cpp | 9 +- targets/HUDL/main.cpp | 125 +++++----------- 4 files changed, 107 insertions(+), 358 deletions(-) diff --git a/include/HUDL/HUDL.hpp b/include/HUDL/HUDL.hpp index c9fc7f7..29c0010 100644 --- a/include/HUDL/HUDL.hpp +++ b/include/HUDL/HUDL.hpp @@ -1,13 +1,13 @@ #ifndef _HUDL_ #define _HUDL_ -#include #include #include #include #include #include #include +#include namespace IO = EVT::core::IO; namespace DEV = EVT::core::DEV; @@ -19,13 +19,8 @@ namespace HUDL { * for communicating with other devices on the CAN network and functionality * for displaying what a user wants to an LCD screen */ -class HUDL { +class HUDL: public CANDevice { public: - /** - * The node ID used to identify the device on the CAN network. - */ - static constexpr uint8_t NODE_ID = 0x11; - /** * Default Constructor for the HUDL class * @@ -45,14 +40,21 @@ class HUDL { * * @return an object dictionary */ - CO_OBJ_T* getObjectDictionary(); + CO_OBJ_T* getObjectDictionary() override; /** * Gets the size of the Object Dictionary * * @return size of the Object Dictionary */ - uint16_t getObjectDictionarySize() const; + uint8_t getNumElements() override; + + /** + * Get the device's node ID + * + * @return The node ID of the can device. + */ + uint8_t getNodeID() override; /** * Updates the LCD display with values received from the CAN network @@ -65,10 +67,6 @@ class HUDL { * cs PB_12 */ DEV::LCD lcd; - - static constexpr uintptr_t TMS_NODE_ID = 0x08; - static constexpr uintptr_t MC_NODE_ID = 0x01; - private: enum Corner { TOP_LEFT, @@ -77,6 +75,14 @@ class HUDL { BOTTOM_RIGHT }; + /** + * The node ID used to identify the device on the CAN network. + */ + static constexpr uint8_t NODE_ID = 0x11; + + static constexpr uintptr_t TMS_NODE_ID = 0x08; + static constexpr uintptr_t MC_NODE_ID = 0x01; + bool setHeaders = false; uint16_t dummyValue = 0; @@ -99,264 +105,49 @@ class HUDL { void headerForCorner(Corner corner, const char* text); void dataForCorner(Corner corner, const char* text); - static constexpr uint16_t OBJECT_DICTIONARY_SIZE = 37; + static constexpr uint16_t OBJECT_DICTIONARY_SIZE = 46; CO_OBJ_T objectDictionary[OBJECT_DICTIONARY_SIZE + 1] = { - // Sync ID, defaults to 0x80 - { - CO_KEY(0x1005, 0, CO_UNSIGNED32 | CO_OBJ_D__R_), - nullptr, - (uintptr_t) 0x80, - }, - - /** - * Information about the hardware , hard coded sample values for now - * 1: Vendor ID - * 2: Product Code - * 3: Revision Number - * 4: Serial Number - */ - { - .Key = CO_KEY(0x1018, 1, CO_UNSIGNED32 | CO_OBJ_D__R_), - .Type = nullptr, - .Data = (uintptr_t) 0x10, - }, - { - .Key = CO_KEY(0x1018, 2, CO_UNSIGNED32 | CO_OBJ_D__R_), - .Type = nullptr, - .Data = (uintptr_t) 0x11, - }, - { - .Key = CO_KEY(0x1018, 3, CO_UNSIGNED32 | CO_OBJ_D__R_), - .Type = nullptr, - .Data = (uintptr_t) 0x12, - }, - { - .Key = CO_KEY(0x1018, 4, CO_UNSIGNED32 | CO_OBJ_D__R_), - .Type = nullptr, - .Data = (uintptr_t) 0x13, - }, - - /** - * SDO CAN message IDS. - * 1: Client -> Server ID, default is 0x600 + NODE_ID - * 2: Server -> Client ID, default is 0x580 + NODE_ID - */ - { - .Key = CO_KEY(0x1200, 1, CO_UNSIGNED32 | CO_OBJ_D__R_), - .Type = nullptr, - .Data = (uintptr_t) 0x600 + NODE_ID, - }, - { - .Key = CO_KEY(0x1200, 2, CO_UNSIGNED32 | CO_OBJ_D__R_), - .Type = nullptr, - .Data = (uintptr_t) 0x580 + NODE_ID, - }, - - /** - * *** START RPDO SETTINGS *** - */ - /** - * TMS RPDO 0 - * 0: RPDO number in index and total number of sub indexes. - * 1: The COB-ID to receive PDOs from. - * 2: transmission trigger - */ - { - .Key = CO_KEY(0x1400, 0, CO_UNSIGNED8 | CO_OBJ_D__R_), - .Type = nullptr, - .Data = (uintptr_t) 3, - }, - { - .Key = CO_KEY(0x1400, 1, CO_UNSIGNED32 | CO_OBJ_D__R_), - .Type = nullptr, - .Data = (uintptr_t) CO_COBID_TPDO_DEFAULT(0) + TMS_NODE_ID, - }, - { - .Key = CO_KEY(0x1400, 2, CO_UNSIGNED8 | CO_OBJ_D__R_), - .Type = nullptr, - .Data = (uintptr_t) 0xFE, - }, - /** - * Motor Controller RPDO 0 - * 0: RPDO number in index and total number of sub indexes. - * 1: The COB-ID to receive PDOs from. - * 2: transmission trigger - */ - { - .Key = CO_KEY(0x1401, 0, CO_UNSIGNED8 | CO_OBJ_D__R_), - .Type = nullptr, - .Data = (uintptr_t) 3, - }, - { - .Key = CO_KEY(0x1401, 1, CO_UNSIGNED32 | CO_OBJ_D__R_), - .Type = nullptr, - .Data = (uintptr_t) CO_COBID_TPDO_DEFAULT(0) + MC_NODE_ID, - }, - { - .Key = CO_KEY(0x1401, 2, CO_UNSIGNED8 | CO_OBJ_D__R_), - .Type = nullptr, - .Data = (uintptr_t) 0xFE, - }, - /** - * Motor Controller RPDO 1 - * 0: RPDO number in index and total number of sub indexes. - * 1: The COB-ID to receive PDOs from. - * 2: transmission trigger - */ - { - .Key = CO_KEY(0x1402, 0, CO_UNSIGNED8 | CO_OBJ_D__R_), - .Type = nullptr, - .Data = (uintptr_t) 3, - }, - { - .Key = CO_KEY(0x1402, 1, CO_UNSIGNED32 | CO_OBJ_D__R_), - .Type = nullptr, - .Data = (uintptr_t) CO_COBID_TPDO_DEFAULT(1) + MC_NODE_ID, - }, - { - .Key = CO_KEY(0x1402, 2, CO_UNSIGNED8 | CO_OBJ_D__R_), - .Type = nullptr, - .Data = (uintptr_t) 0xFE, - }, - /** - * TMS RPDO 0 - * Determines the PDO messages to receive when RPDO0 is triggered - * 0: The number of PDO message associated with the RPDO - * 1: tempOne - * 2: tempTwo - * 3: tempThree - * 4: tempFour - */ - { - .Key = CO_KEY(0x1600, 0, CO_UNSIGNED8 | CO_OBJ_D__R_), - .Type = nullptr, - .Data = (uintptr_t) 4, - }, - { - .Key = CO_KEY(0x1600, 1, CO_UNSIGNED32 | CO_OBJ_D__R_), - .Type = nullptr, - .Data = CO_LINK(0x2100, 0, 16),// Temperature One - }, - { - .Key = CO_KEY(0x1600, 2, CO_UNSIGNED32 | CO_OBJ_D__R_), - .Type = nullptr, - .Data = CO_LINK(0x2100, 1, 16),// Temperature Two - }, - { - .Key = CO_KEY(0x1600, 3, CO_UNSIGNED32 | CO_OBJ_D__R_), - .Type = nullptr, - .Data = CO_LINK(0x2100, 2, 16),// Temperature Three - }, - { - .Key = CO_KEY(0x1600, 4, CO_UNSIGNED32 | CO_OBJ_D__R_), - .Type = nullptr, - .Data = CO_LINK(0x2100, 3, 16),// Temperature Four - }, - /** - * Motor Controller RPDO 1 - * Determines the PDO messages to receive when RPDO3 is triggered - * 0: The number of PDO message associated with the RPDO - * 1: statusWord - * 2: positionActual - * 3: torqueActual - */ - { - .Key = CO_KEY(0x1601, 0, CO_UNSIGNED8 | CO_OBJ_D__R_), - .Type = nullptr, - .Data = (uintptr_t) 3, - }, - { - .Key = CO_KEY(0x1601, 1, CO_UNSIGNED32 | CO_OBJ_D__R_), - .Type = nullptr, - .Data = CO_LINK(0x2101, 0, 16), - }, - { - .Key = CO_KEY(0x1601, 2, CO_UNSIGNED32 | CO_OBJ_D__R_), - .Type = nullptr, - .Data = CO_LINK(0x2101, 1, 16), - }, - { - .Key = CO_KEY(0x1601, 3, CO_UNSIGNED32 | CO_OBJ_D__R_), - .Type = nullptr, - .Data = CO_LINK(0x2101, 2, 16), - }, - /** - * Motor Controller RPDO 2 - * Determines the PDO messages to receive when RPDO4 is triggered - * 0: The number of PDO message associated with the RPDO - * 1: Dummy Value - * 2: Battery Voltage - */ - { - .Key = CO_KEY(0x1602, 0, CO_UNSIGNED8 | CO_OBJ_D__R_), - .Type = nullptr, - .Data = (uintptr_t) 2, - }, - { - .Key = CO_KEY(0x1602, 1, CO_UNSIGNED32 | CO_OBJ_D__R_), - .Type = nullptr, - .Data = CO_LINK(0x2102, 0, 16), - }, - { - .Key = CO_KEY(0x1602, 2, CO_UNSIGNED32 | CO_OBJ_D__R_), - .Type = nullptr, - .Data = CO_LINK(0x2102, 1, 16), - }, - /** - * User defined data. Put elements that can be accessed via SDO - * and depending on the configuration PDO - */ - /* These data values assign TMU RPDO 0 to the 4 thermal temperatures. */ - { - .Key = CO_KEY(0x2100, 0, CO_UNSIGNED16 | CO_OBJ___PRW), - .Type = nullptr, - .Data = (uintptr_t) &thermTemps[0], - }, - { - .Key = CO_KEY(0x2100, 1, CO_UNSIGNED16 | CO_OBJ___PRW), - .Type = nullptr, - .Data = (uintptr_t) &thermTemps[1], - }, - { - .Key = CO_KEY(0x2100, 2, CO_UNSIGNED16 | CO_OBJ___PRW), - .Type = nullptr, - .Data = (uintptr_t) &thermTemps[2], - }, - { - .Key = CO_KEY(0x2100, 3, CO_UNSIGNED16 | CO_OBJ___PRW), - .Type = nullptr, - .Data = (uintptr_t) &thermTemps[3], - }, - /* These data values assign Motor Controller RPDO 0 to Status Word, Actual Position, and Torque Actual. */ - { - .Key = CO_KEY(0x2101, 0, CO_UNSIGNED16 | CO_OBJ___PRW), - .Type = nullptr, - .Data = (uintptr_t) &statusWord, - }, - { - .Key = CO_KEY(0x2101, 1, CO_UNSIGNED16 | CO_OBJ___PRW), - .Type = nullptr, - .Data = (uintptr_t) &actualPosition, - }, - { - .Key = CO_KEY(0x2101, 2, CO_UNSIGNED16 | CO_OBJ___PRW), - .Type = nullptr, - .Data = (uintptr_t) &torqueActual, - }, - /* These data values assign Motor Controller RPDO 1 to the Total Voltage, and then a dummy value. */ - { - .Key = CO_KEY(0x2102, 0, CO_UNSIGNED16 | CO_OBJ___PRW), - .Type = nullptr, - .Data = (uintptr_t) &dummyValue, - }, - { - .Key = CO_KEY(0x2102, 1, CO_UNSIGNED16 | CO_OBJ___PRW), - .Type = nullptr, - .Data = (uintptr_t) &totalVoltage, - }, - - CO_OBJ_DIR_ENDMARK, + MANDATORY_IDENTIFICATION_ENTRIES_1000_1014, + HEARTBEAT_PRODUCER_1017(2000), + IDENTITY_OBJECT_1018, + SDO_CONFIGURATION_1200, + + RECEIVE_PDO_SETTINGS_OBJECT_140X(0, 0, TMS_NODE_ID, RECEIVE_PDO_TRIGGER_ASYNC), + RECEIVE_PDO_SETTINGS_OBJECT_140X(1, 0, MC_NODE_ID, RECEIVE_PDO_TRIGGER_ASYNC), + RECEIVE_PDO_SETTINGS_OBJECT_140X(2, 1, MC_NODE_ID, RECEIVE_PDO_TRIGGER_ASYNC), + + RECEIVE_PDO_N_MAPPING_START_KEY_160X(0, 4), + RECEIVE_PDO_N_MAPPING_ENTRY_N_160X(0, 1, PDO_MAPPING_UNSIGNED16), // Temperature One + RECEIVE_PDO_N_MAPPING_ENTRY_N_160X(0, 2, PDO_MAPPING_UNSIGNED16), // Temperature Two + RECEIVE_PDO_N_MAPPING_ENTRY_N_160X(0, 3, PDO_MAPPING_UNSIGNED16), // Temperature Three + RECEIVE_PDO_N_MAPPING_ENTRY_N_160X(0, 4, PDO_MAPPING_UNSIGNED16), // Temperature Three + + RECEIVE_PDO_N_MAPPING_START_KEY_160X(1, 3), + RECEIVE_PDO_N_MAPPING_ENTRY_N_160X(1, 1, PDO_MAPPING_UNSIGNED16), // Status Word + RECEIVE_PDO_N_MAPPING_ENTRY_N_160X(1, 2, PDO_MAPPING_UNSIGNED16), // Position Actual + RECEIVE_PDO_N_MAPPING_ENTRY_N_160X(1, 3, PDO_MAPPING_UNSIGNED16), // Torque Actual + + RECEIVE_PDO_N_MAPPING_START_KEY_160X(2, 2), + RECEIVE_PDO_N_MAPPING_ENTRY_N_160X(2, 1, PDO_MAPPING_UNSIGNED16), // Dummy Value + RECEIVE_PDO_N_MAPPING_ENTRY_N_160X(2, 2, PDO_MAPPING_UNSIGNED16), // Battery Voltage + + DATA_LINK_START_KEY_210X(0, 6), + DATA_LINK_210X(0, 1, CO_TUNSIGNED16, &thermTemps[0]), // Temperature One + DATA_LINK_210X(0, 2, CO_TUNSIGNED16, &thermTemps[1]), // Temperature Two + DATA_LINK_210X(0, 3, CO_TUNSIGNED16, &thermTemps[2]), // Temperature Three + DATA_LINK_210X(0, 4, CO_TUNSIGNED16, &thermTemps[3]), // Temperature Four + + DATA_LINK_START_KEY_210X(1, 3), + DATA_LINK_210X(1, 1, CO_TUNSIGNED16, &statusWord), // Status Word + DATA_LINK_210X(1, 2, CO_TUNSIGNED16, &actualPosition), // Actual Position + DATA_LINK_210X(1, 3, CO_TUNSIGNED16, &torqueActual), // Torque Actual + + DATA_LINK_START_KEY_210X(2, 2), + DATA_LINK_210X(2, 1, CO_TUNSIGNED16, &dummyValue), // Dummy Value + DATA_LINK_210X(2, 2, CO_TUNSIGNED16, &totalVoltage), // Total Voltage + + CO_OBJ_DICT_ENDMARK, }; }; diff --git a/libs/EVT-core b/libs/EVT-core index 5e66296..4026920 160000 --- a/libs/EVT-core +++ b/libs/EVT-core @@ -1 +1 @@ -Subproject commit 5e66296bbb72215f755e3de8e085553163a1c716 +Subproject commit 40269206150da4d1c217aaba0f598d0aebe8a2c4 diff --git a/src/HUDL/HUDL.cpp b/src/HUDL/HUDL.cpp index 3e62ad6..7bede89 100644 --- a/src/HUDL/HUDL.cpp +++ b/src/HUDL/HUDL.cpp @@ -12,7 +12,7 @@ #include #include #include -#include "EVT/dev/BitmapFonts.hpp" + // clang-format on namespace IO = EVT::core::IO; @@ -31,10 +31,14 @@ CO_OBJ_T* HUDL::getObjectDictionary() { return &objectDictionary[0]; } -uint16_t HUDL::getObjectDictionarySize() const { +uint8_t HUDL::getNumElements() { return OBJECT_DICTIONARY_SIZE; } +uint8_t HUDL::getNodeID() { + return NODE_ID; +} + void HUDL::updateLCD() { if (!setHeaders) { lcd.clearLCD(); @@ -140,5 +144,4 @@ uint8_t HUDL::pageForCorner(HUDL::Corner corner) { return -1; } } - }// namespace HUDL diff --git a/targets/HUDL/main.cpp b/targets/HUDL/main.cpp index 4b9aa5d..8de70a7 100644 --- a/targets/HUDL/main.cpp +++ b/targets/HUDL/main.cpp @@ -2,8 +2,6 @@ * This is the main code running on the HUDL responsible for displaying * information that other boards that broadcast through the CAN network */ -#include -#include #include #include #include @@ -13,7 +11,6 @@ #include #include -#include namespace IO = EVT::core::IO; namespace DEV = EVT::core::DEV; @@ -23,6 +20,7 @@ using namespace std; #define SPI_SPEED SPI_SPEED_500KHZ #define DEVICE_COUNT 1 +#define REFRESH_RATE 16128 /////////////////////////////////////////////////////////////////////////////// // CANopen specific Callbacks. Need to be defined in some location @@ -47,32 +45,6 @@ void canInterrupt(IO::CANMessage& message, void* priv) { } } -extern "C" void CONodeFatalError(void) {} - -extern "C" void COIfCanReceive(CO_IF_FRM* frm) {} - -extern "C" int16_t COLssStore(uint32_t baudrate, uint8_t nodeId) { return 0; } - -extern "C" int16_t COLssLoad(uint32_t* baudrate, uint8_t* nodeId) { return 0; } - -extern "C" void CONmtModeChange(CO_NMT* nmt, CO_MODE mode) {} - -extern "C" void CONmtHbConsEvent(CO_NMT* nmt, uint8_t nodeId) {} - -extern "C" void CONmtHbConsChange(CO_NMT* nmt, uint8_t nodeId, CO_MODE mode) {} - -extern "C" int16_t COParaDefault(CO_PARA* pg) { return 0; } - -extern "C" void COPdoTransmit(CO_IF_FRM* frm) {} - -extern "C" int16_t COPdoReceive(CO_IF_FRM* frm) { return 0; } - -extern "C" void COPdoSyncUpdate(CO_RPDO* pdo) {} - -extern "C" void COTmrLock(void) {} - -extern "C" void COTmrUnlock(void) {} - int main() { // Initialize system EVT::core::platform::init(); @@ -81,14 +53,6 @@ int main() { log::LOGGER.setUART(&uart); log::LOGGER.setLogLevel(log::Logger::LogLevel::INFO); - // Will store CANOpen messages that will be populated by the EVT-core CAN - // interrupt - auto canOpenQueue = EVT::core::types::FixedQueue(true); - - // Initialize CAN, add an IRQ which will add messages to the queue above - IO::CAN& can = IO::getCAN(); - can.addIRQHandler(canInterrupt, reinterpret_cast(&canOpenQueue)); - // Initialize the timer DEV::Timerf3xx timer(TIM2, 160); @@ -111,19 +75,43 @@ int main() { HUDL::HUDL hudl(regSelect, reset, hudl_spi); + /////////////////////////////////////////////////////////////////////////// + // Setup CAN configuration, this handles making drivers, applying settings. + // And generally creating the CANopen stack node which is the interface + // between the application (the code we write) and the physical CAN network + /////////////////////////////////////////////////////////////////////////// + + // Will store CANopen messages that will be populated by the EVT-core CAN + // interrupt + EVT::core::types::FixedQueue canOpenQueue; + + // Initialize CAN, add an IRQ which will add messages to the queue above + IO::CAN& can = IO::getCAN(); + can.addIRQHandler(canInterrupt, reinterpret_cast(&canOpenQueue)); + // Reserved memory for CANopen stack usage - uint8_t sdoBuffer[1][CO_SDO_BUF_BYTE]; - CO_TMR_MEM appTmrMem[4]; + uint8_t sdoBuffer[CO_SSDO_N * CO_SDO_BUF_BYTE]; + CO_TMR_MEM appTmrMem[16]; - // Attempt to join the CAN network - IO::CAN::CANStatus result = can.connect(); + // Reserve CAN drivers + CO_IF_DRV canStackDriver; + + CO_IF_CAN_DRV canDriver; + CO_IF_TIMER_DRV timerDriver; + CO_IF_NVM_DRV nvmDriver; + + // Reserve canNode + CO_NODE canNode; // Adds CAN filtering to only allow messages from IDs 1, 5, and 8. can.addCANFilter(0x1, 0b00001111111, 0); can.addCANFilter(0x8, 0b00001111111, 1); can.addCANFilter(0x5, 0b00001111111, 2); - //test that the board is connected to the can network + // Attempt to join the CAN network + IO::CAN::CANStatus result = can.connect(); + + // test that the board is connected to the can network if (result != IO::CAN::CANStatus::OK) { log::LOGGER.log(log::Logger::LogLevel::ERROR, "Failed to connect to CAN network\r\n"); return 1; @@ -131,56 +119,27 @@ int main() { log::LOGGER.log(log::Logger::LogLevel::INFO, "Connected to CAN network\r\n"); } - /////////////////////////////////////////////////////////////////////////// - // Setup CAN configuration, this handles making drivers, applying settings. - // And generally creating the CANopen stack node which is the interface - // between the application (the code we write) and the physical CAN network - /////////////////////////////////////////////////////////////////////////// - // Make drivers - CO_IF_DRV canStackDriver; - - CO_IF_CAN_DRV canDriver; - CO_IF_TIMER_DRV timerDriver; - CO_IF_NVM_DRV nvmDriver; + // Initialize all the CANOpen drivers. + IO::initializeCANopenDriver(&canOpenQueue, &can, &timer, &canStackDriver, &nvmDriver, &timerDriver, &canDriver); - IO::getCANopenCANDriver(&can, &canOpenQueue, &canDriver); - IO::getCANopenTimerDriver(&timer, &timerDriver); - IO::getCANopenNVMDriver(&nvmDriver); - - canStackDriver.Can = &canDriver; - canStackDriver.Timer = &timerDriver; - canStackDriver.Nvm = &nvmDriver; - - //setup CANopen Node - CO_NODE_SPEC canSpec = { - .NodeId = HUDL::HUDL::NODE_ID, - .Baudrate = IO::CAN::DEFAULT_BAUD, - .Dict = hudl.getObjectDictionary(), - .DictLen = hudl.getObjectDictionarySize(), - .EmcyCode = nullptr, - .TmrMem = appTmrMem, - .TmrNum = 16, - .TmrFreq = 1, - .Drv = &canStackDriver, - .SdoBuf = reinterpret_cast(&sdoBuffer[0]), - }; - - CO_NODE canNode; + // Initialize the CANOpen node we are using. + IO::initializeCANopenNode(&canNode, &hudl, &canStackDriver, sdoBuffer, appTmrMem); - CONodeInit(&canNode, &canSpec); - CONodeStart(&canNode); CONmtSetMode(&canNode.Nmt, CO_OPERATIONAL); time::wait(500); - //print any CANOpen errors log::LOGGER.log(log::Logger::LogLevel::DEBUG, "Error: %d\r\n", CONodeGetErr(&canNode)); + /////////////////////////////////////////////////////////////////////////// + // Main loop + /////////////////////////////////////////////////////////////////////////// + hudl.initLCD(); uint16_t displayCounter = 0; while (true) { - if (displayCounter >= 1000) { + if (displayCounter >= REFRESH_RATE) { displayCounter = 0; hudl.updateLCD(); @@ -188,10 +147,6 @@ int main() { displayCounter++; } - CONodeProcess(&canNode); - // Update the state of timer based events - COTmrService(&canNode.Tmr); - // Handle executing timer events that have elapsed - COTmrProcess(&canNode.Tmr); + IO::processCANopenNode(&canNode); } } From dad7763ba0f33583db33af0621a9d7995d52fc3f Mon Sep 17 00:00:00 2001 From: ActuallyTaylor Date: Sat, 18 Nov 2023 12:28:45 -0500 Subject: [PATCH 2/7] Shortens Enums across repo Signed-off-by: ActuallyTaylor --- include/HUDL/HUDL.hpp | 2 +- src/HUDL/HUDL.cpp | 14 ++++++++------ targets/HUDL/main.cpp | 11 ++++++----- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/include/HUDL/HUDL.hpp b/include/HUDL/HUDL.hpp index 29c0010..9d6ac3e 100644 --- a/include/HUDL/HUDL.hpp +++ b/include/HUDL/HUDL.hpp @@ -132,7 +132,7 @@ class HUDL: public CANDevice { RECEIVE_PDO_N_MAPPING_ENTRY_N_160X(2, 1, PDO_MAPPING_UNSIGNED16), // Dummy Value RECEIVE_PDO_N_MAPPING_ENTRY_N_160X(2, 2, PDO_MAPPING_UNSIGNED16), // Battery Voltage - DATA_LINK_START_KEY_210X(0, 6), + DATA_LINK_START_KEY_210X(0, 4), DATA_LINK_210X(0, 1, CO_TUNSIGNED16, &thermTemps[0]), // Temperature One DATA_LINK_210X(0, 2, CO_TUNSIGNED16, &thermTemps[1]), // Temperature Two DATA_LINK_210X(0, 3, CO_TUNSIGNED16, &thermTemps[2]), // Temperature Three diff --git a/src/HUDL/HUDL.cpp b/src/HUDL/HUDL.cpp index 7bede89..631b901 100644 --- a/src/HUDL/HUDL.cpp +++ b/src/HUDL/HUDL.cpp @@ -20,6 +20,8 @@ namespace DEV = EVT::core::DEV; namespace log = EVT::core::log; namespace HUDL { +typedef DEV::LCD::FontSize FontSize; + HUDL::HUDL(IO::GPIO& reg_select, IO::GPIO& reset, IO::SPI& spi) : lcd(DEV::LCD(reg_select, reset, spi)) {} void HUDL::initLCD() { @@ -85,7 +87,7 @@ void HUDL::updateLCD() { dataForCorner(BOTTOM_RIGHT, status); } -void HUDL::headerForCorner(HUDL::Corner corner, const char* text) { +void HUDL::headerForCorner(Corner corner, const char* text) { // Clear the sections area so text is not written over old text. uint8_t sectionColumn = columnForCorner(corner); uint8_t sectionPage = pageForCorner(corner); @@ -99,10 +101,10 @@ void HUDL::headerForCorner(HUDL::Corner corner, const char* text) { sectionColumn += padding; // Write the text to the screen under the section header. - lcd.writeText(text, sectionPage, sectionColumn, EVT::core::DEV::LCD::FontSize::LARGE, false); + lcd.writeText(text, sectionPage, sectionColumn, FontSize::LARGE, false); } -void HUDL::dataForCorner(HUDL::Corner corner, const char* text) { +void HUDL::dataForCorner(Corner corner, const char* text) { // Clear the sections area so text is not written over old text. uint8_t sectionColumn = columnForCorner(corner); uint8_t sectionPage = pageForCorner(corner) + 2; @@ -116,10 +118,10 @@ void HUDL::dataForCorner(HUDL::Corner corner, const char* text) { sectionColumn += padding; // Write the text to the screen under the section header. - lcd.writeText(text, sectionPage, sectionColumn, EVT::core::DEV::LCD::FontSize::LARGE, false); + lcd.writeText(text, sectionPage, sectionColumn, FontSize::LARGE, false); } -uint8_t HUDL::columnForCorner(HUDL::Corner corner) { +uint8_t HUDL::columnForCorner(Corner corner) { switch (corner) { case TOP_LEFT: case BOTTOM_LEFT: @@ -132,7 +134,7 @@ uint8_t HUDL::columnForCorner(HUDL::Corner corner) { } } -uint8_t HUDL::pageForCorner(HUDL::Corner corner) { +uint8_t HUDL::pageForCorner(Corner corner) { switch (corner) { case TOP_LEFT: case TOP_RIGHT: diff --git a/targets/HUDL/main.cpp b/targets/HUDL/main.cpp index 8de70a7..c7b9e4e 100644 --- a/targets/HUDL/main.cpp +++ b/targets/HUDL/main.cpp @@ -16,6 +16,7 @@ namespace IO = EVT::core::IO; namespace DEV = EVT::core::DEV; namespace time = EVT::core::time; namespace log = EVT::core::log; +namespace types = EVT::core::types; using namespace std; #define SPI_SPEED SPI_SPEED_500KHZ @@ -38,7 +39,7 @@ using namespace std; */ // create a can interrupt handler void canInterrupt(IO::CANMessage& message, void* priv) { - auto* queue = (EVT::core::types::FixedQueue*) priv; + auto* queue = (types::FixedQueue*) priv; if (queue != nullptr) { queue->append(message); @@ -59,10 +60,10 @@ int main() { //create the RPDO node IO::GPIO* devices[DEVICE_COUNT]; - IO::GPIO& regSelect = IO::getGPIO(EVT::core::IO::GPIO::Direction::OUTPUT); + IO::GPIO& regSelect = IO::getGPIO(IO::GPIO::Direction::OUTPUT); - IO::GPIO& reset = IO::getGPIO(EVT::core::IO::GPIO::Direction::OUTPUT); - devices[0] = &IO::getGPIO(EVT::core::IO::GPIO::Direction::OUTPUT); + IO::GPIO& reset = IO::getGPIO(IO::GPIO::Direction::OUTPUT); + devices[0] = &IO::getGPIO(IO::GPIO::Direction::OUTPUT); devices[0]->writePin(IO::GPIO::State::HIGH); auto& hudl_spi = IO::getSPI(devices, DEVICE_COUNT); @@ -83,7 +84,7 @@ int main() { // Will store CANopen messages that will be populated by the EVT-core CAN // interrupt - EVT::core::types::FixedQueue canOpenQueue; + types::FixedQueue canOpenQueue; // Initialize CAN, add an IRQ which will add messages to the queue above IO::CAN& can = IO::getCAN(); From 703fa0e9448bd29b770058a23dc913c61bef522c Mon Sep 17 00:00:00 2001 From: ActuallyTaylor Date: Sat, 2 Dec 2023 11:21:57 -0500 Subject: [PATCH 3/7] Fixed build & upgrade evet-core Signed-off-by: ActuallyTaylor --- CMakeLists.txt | 2 ++ libs/EVT-core | 2 +- targets/HUDL/main.cpp | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b992913..b64a58b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,8 @@ cmake_minimum_required(VERSION 3.15) # is changed to TPDO (CO_TPDO_N=50) add_compile_definitions(CO_RPDO_N=50) +add_compile_definitions(USE_HAL_DRIVER) + set(EVT_CORE_DIR ${CMAKE_SOURCE_DIR}/libs/EVT-core) set(TARGET_DEV "STM32F302x8") diff --git a/libs/EVT-core b/libs/EVT-core index 4026920..0676b16 160000 --- a/libs/EVT-core +++ b/libs/EVT-core @@ -1 +1 @@ -Subproject commit 40269206150da4d1c217aaba0f598d0aebe8a2c4 +Subproject commit 0676b1677e95fe36adadd8c951b846c04cb5e4d2 diff --git a/targets/HUDL/main.cpp b/targets/HUDL/main.cpp index c7b9e4e..fa3fe02 100644 --- a/targets/HUDL/main.cpp +++ b/targets/HUDL/main.cpp @@ -2,6 +2,8 @@ * This is the main code running on the HUDL responsible for displaying * information that other boards that broadcast through the CAN network */ +#include + #include #include #include From 3d4cb946f2a1687385cb3753e8f493d03ba8f70f Mon Sep 17 00:00:00 2001 From: GitHub Build Date: Sat, 2 Dec 2023 16:23:38 +0000 Subject: [PATCH 4/7] Applied Formatting Changes During GitHub Build --- include/HUDL/HUDL.hpp | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/include/HUDL/HUDL.hpp b/include/HUDL/HUDL.hpp index 9d6ac3e..249dac5 100644 --- a/include/HUDL/HUDL.hpp +++ b/include/HUDL/HUDL.hpp @@ -2,12 +2,12 @@ #define _HUDL_ #include +#include #include #include #include #include #include -#include namespace IO = EVT::core::IO; namespace DEV = EVT::core::DEV; @@ -19,7 +19,7 @@ namespace HUDL { * for communicating with other devices on the CAN network and functionality * for displaying what a user wants to an LCD screen */ -class HUDL: public CANDevice { +class HUDL : public CANDevice { public: /** * Default Constructor for the HUDL class @@ -67,6 +67,7 @@ class HUDL: public CANDevice { * cs PB_12 */ DEV::LCD lcd; + private: enum Corner { TOP_LEFT, @@ -118,34 +119,34 @@ class HUDL: public CANDevice { RECEIVE_PDO_SETTINGS_OBJECT_140X(2, 1, MC_NODE_ID, RECEIVE_PDO_TRIGGER_ASYNC), RECEIVE_PDO_N_MAPPING_START_KEY_160X(0, 4), - RECEIVE_PDO_N_MAPPING_ENTRY_N_160X(0, 1, PDO_MAPPING_UNSIGNED16), // Temperature One - RECEIVE_PDO_N_MAPPING_ENTRY_N_160X(0, 2, PDO_MAPPING_UNSIGNED16), // Temperature Two - RECEIVE_PDO_N_MAPPING_ENTRY_N_160X(0, 3, PDO_MAPPING_UNSIGNED16), // Temperature Three - RECEIVE_PDO_N_MAPPING_ENTRY_N_160X(0, 4, PDO_MAPPING_UNSIGNED16), // Temperature Three + RECEIVE_PDO_N_MAPPING_ENTRY_N_160X(0, 1, PDO_MAPPING_UNSIGNED16),// Temperature One + RECEIVE_PDO_N_MAPPING_ENTRY_N_160X(0, 2, PDO_MAPPING_UNSIGNED16),// Temperature Two + RECEIVE_PDO_N_MAPPING_ENTRY_N_160X(0, 3, PDO_MAPPING_UNSIGNED16),// Temperature Three + RECEIVE_PDO_N_MAPPING_ENTRY_N_160X(0, 4, PDO_MAPPING_UNSIGNED16),// Temperature Three RECEIVE_PDO_N_MAPPING_START_KEY_160X(1, 3), - RECEIVE_PDO_N_MAPPING_ENTRY_N_160X(1, 1, PDO_MAPPING_UNSIGNED16), // Status Word - RECEIVE_PDO_N_MAPPING_ENTRY_N_160X(1, 2, PDO_MAPPING_UNSIGNED16), // Position Actual - RECEIVE_PDO_N_MAPPING_ENTRY_N_160X(1, 3, PDO_MAPPING_UNSIGNED16), // Torque Actual + RECEIVE_PDO_N_MAPPING_ENTRY_N_160X(1, 1, PDO_MAPPING_UNSIGNED16),// Status Word + RECEIVE_PDO_N_MAPPING_ENTRY_N_160X(1, 2, PDO_MAPPING_UNSIGNED16),// Position Actual + RECEIVE_PDO_N_MAPPING_ENTRY_N_160X(1, 3, PDO_MAPPING_UNSIGNED16),// Torque Actual RECEIVE_PDO_N_MAPPING_START_KEY_160X(2, 2), - RECEIVE_PDO_N_MAPPING_ENTRY_N_160X(2, 1, PDO_MAPPING_UNSIGNED16), // Dummy Value - RECEIVE_PDO_N_MAPPING_ENTRY_N_160X(2, 2, PDO_MAPPING_UNSIGNED16), // Battery Voltage + RECEIVE_PDO_N_MAPPING_ENTRY_N_160X(2, 1, PDO_MAPPING_UNSIGNED16),// Dummy Value + RECEIVE_PDO_N_MAPPING_ENTRY_N_160X(2, 2, PDO_MAPPING_UNSIGNED16),// Battery Voltage DATA_LINK_START_KEY_210X(0, 4), - DATA_LINK_210X(0, 1, CO_TUNSIGNED16, &thermTemps[0]), // Temperature One - DATA_LINK_210X(0, 2, CO_TUNSIGNED16, &thermTemps[1]), // Temperature Two - DATA_LINK_210X(0, 3, CO_TUNSIGNED16, &thermTemps[2]), // Temperature Three - DATA_LINK_210X(0, 4, CO_TUNSIGNED16, &thermTemps[3]), // Temperature Four + DATA_LINK_210X(0, 1, CO_TUNSIGNED16, &thermTemps[0]),// Temperature One + DATA_LINK_210X(0, 2, CO_TUNSIGNED16, &thermTemps[1]),// Temperature Two + DATA_LINK_210X(0, 3, CO_TUNSIGNED16, &thermTemps[2]),// Temperature Three + DATA_LINK_210X(0, 4, CO_TUNSIGNED16, &thermTemps[3]),// Temperature Four DATA_LINK_START_KEY_210X(1, 3), - DATA_LINK_210X(1, 1, CO_TUNSIGNED16, &statusWord), // Status Word - DATA_LINK_210X(1, 2, CO_TUNSIGNED16, &actualPosition), // Actual Position - DATA_LINK_210X(1, 3, CO_TUNSIGNED16, &torqueActual), // Torque Actual + DATA_LINK_210X(1, 1, CO_TUNSIGNED16, &statusWord), // Status Word + DATA_LINK_210X(1, 2, CO_TUNSIGNED16, &actualPosition),// Actual Position + DATA_LINK_210X(1, 3, CO_TUNSIGNED16, &torqueActual), // Torque Actual DATA_LINK_START_KEY_210X(2, 2), - DATA_LINK_210X(2, 1, CO_TUNSIGNED16, &dummyValue), // Dummy Value - DATA_LINK_210X(2, 2, CO_TUNSIGNED16, &totalVoltage), // Total Voltage + DATA_LINK_210X(2, 1, CO_TUNSIGNED16, &dummyValue), // Dummy Value + DATA_LINK_210X(2, 2, CO_TUNSIGNED16, &totalVoltage),// Total Voltage CO_OBJ_DICT_ENDMARK, }; From 1c5cb2fc0e99d4cf7a0da179ea3a8bb77ef89fd3 Mon Sep 17 00:00:00 2001 From: Taylor Lineman Date: Sun, 10 Dec 2023 12:58:49 -0500 Subject: [PATCH 5/7] Apply suggestions from code review Co-authored-by: Matthew Magee --- include/HUDL/HUDL.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/HUDL/HUDL.hpp b/include/HUDL/HUDL.hpp index 249dac5..003e0cd 100644 --- a/include/HUDL/HUDL.hpp +++ b/include/HUDL/HUDL.hpp @@ -122,7 +122,7 @@ class HUDL : public CANDevice { RECEIVE_PDO_N_MAPPING_ENTRY_N_160X(0, 1, PDO_MAPPING_UNSIGNED16),// Temperature One RECEIVE_PDO_N_MAPPING_ENTRY_N_160X(0, 2, PDO_MAPPING_UNSIGNED16),// Temperature Two RECEIVE_PDO_N_MAPPING_ENTRY_N_160X(0, 3, PDO_MAPPING_UNSIGNED16),// Temperature Three - RECEIVE_PDO_N_MAPPING_ENTRY_N_160X(0, 4, PDO_MAPPING_UNSIGNED16),// Temperature Three + RECEIVE_PDO_N_MAPPING_ENTRY_N_160X(0, 4, PDO_MAPPING_UNSIGNED16),// Temperature Four RECEIVE_PDO_N_MAPPING_START_KEY_160X(1, 3), RECEIVE_PDO_N_MAPPING_ENTRY_N_160X(1, 1, PDO_MAPPING_UNSIGNED16),// Status Word @@ -130,7 +130,7 @@ class HUDL : public CANDevice { RECEIVE_PDO_N_MAPPING_ENTRY_N_160X(1, 3, PDO_MAPPING_UNSIGNED16),// Torque Actual RECEIVE_PDO_N_MAPPING_START_KEY_160X(2, 2), - RECEIVE_PDO_N_MAPPING_ENTRY_N_160X(2, 1, PDO_MAPPING_UNSIGNED16),// Dummy Value + RECEIVE_PDO_N_MAPPING_ENTRY_N_160X(2, 1, PDO_MAPPING_UNSIGNED16),// Unused Value RECEIVE_PDO_N_MAPPING_ENTRY_N_160X(2, 2, PDO_MAPPING_UNSIGNED16),// Battery Voltage DATA_LINK_START_KEY_210X(0, 4), @@ -145,7 +145,7 @@ class HUDL : public CANDevice { DATA_LINK_210X(1, 3, CO_TUNSIGNED16, &torqueActual), // Torque Actual DATA_LINK_START_KEY_210X(2, 2), - DATA_LINK_210X(2, 1, CO_TUNSIGNED16, &dummyValue), // Dummy Value + DATA_LINK_210X(2, 1, CO_TUNSIGNED16, &dummyValue), // Unused Value DATA_LINK_210X(2, 2, CO_TUNSIGNED16, &totalVoltage),// Total Voltage CO_OBJ_DICT_ENDMARK, From 567525624a4afbacf0da86e1c0ca9b292a34d01b Mon Sep 17 00:00:00 2001 From: ActuallyTaylor Date: Sun, 10 Dec 2023 13:02:41 -0500 Subject: [PATCH 6/7] Updated names Signed-off-by: ActuallyTaylor --- include/HUDL/HUDL.hpp | 58 +++++++++++++++++++++---------------------- libs/EVT-core | 2 +- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/include/HUDL/HUDL.hpp b/include/HUDL/HUDL.hpp index 003e0cd..04e9292 100644 --- a/include/HUDL/HUDL.hpp +++ b/include/HUDL/HUDL.hpp @@ -118,35 +118,35 @@ class HUDL : public CANDevice { RECEIVE_PDO_SETTINGS_OBJECT_140X(1, 0, MC_NODE_ID, RECEIVE_PDO_TRIGGER_ASYNC), RECEIVE_PDO_SETTINGS_OBJECT_140X(2, 1, MC_NODE_ID, RECEIVE_PDO_TRIGGER_ASYNC), - RECEIVE_PDO_N_MAPPING_START_KEY_160X(0, 4), - RECEIVE_PDO_N_MAPPING_ENTRY_N_160X(0, 1, PDO_MAPPING_UNSIGNED16),// Temperature One - RECEIVE_PDO_N_MAPPING_ENTRY_N_160X(0, 2, PDO_MAPPING_UNSIGNED16),// Temperature Two - RECEIVE_PDO_N_MAPPING_ENTRY_N_160X(0, 3, PDO_MAPPING_UNSIGNED16),// Temperature Three - RECEIVE_PDO_N_MAPPING_ENTRY_N_160X(0, 4, PDO_MAPPING_UNSIGNED16),// Temperature Four - - RECEIVE_PDO_N_MAPPING_START_KEY_160X(1, 3), - RECEIVE_PDO_N_MAPPING_ENTRY_N_160X(1, 1, PDO_MAPPING_UNSIGNED16),// Status Word - RECEIVE_PDO_N_MAPPING_ENTRY_N_160X(1, 2, PDO_MAPPING_UNSIGNED16),// Position Actual - RECEIVE_PDO_N_MAPPING_ENTRY_N_160X(1, 3, PDO_MAPPING_UNSIGNED16),// Torque Actual - - RECEIVE_PDO_N_MAPPING_START_KEY_160X(2, 2), - RECEIVE_PDO_N_MAPPING_ENTRY_N_160X(2, 1, PDO_MAPPING_UNSIGNED16),// Unused Value - RECEIVE_PDO_N_MAPPING_ENTRY_N_160X(2, 2, PDO_MAPPING_UNSIGNED16),// Battery Voltage - - DATA_LINK_START_KEY_210X(0, 4), - DATA_LINK_210X(0, 1, CO_TUNSIGNED16, &thermTemps[0]),// Temperature One - DATA_LINK_210X(0, 2, CO_TUNSIGNED16, &thermTemps[1]),// Temperature Two - DATA_LINK_210X(0, 3, CO_TUNSIGNED16, &thermTemps[2]),// Temperature Three - DATA_LINK_210X(0, 4, CO_TUNSIGNED16, &thermTemps[3]),// Temperature Four - - DATA_LINK_START_KEY_210X(1, 3), - DATA_LINK_210X(1, 1, CO_TUNSIGNED16, &statusWord), // Status Word - DATA_LINK_210X(1, 2, CO_TUNSIGNED16, &actualPosition),// Actual Position - DATA_LINK_210X(1, 3, CO_TUNSIGNED16, &torqueActual), // Torque Actual - - DATA_LINK_START_KEY_210X(2, 2), - DATA_LINK_210X(2, 1, CO_TUNSIGNED16, &dummyValue), // Unused Value - DATA_LINK_210X(2, 2, CO_TUNSIGNED16, &totalVoltage),// Total Voltage + RECEIVE_PDO_MAPPING_START_KEY_16XX(0, 4), + RECEIVE_PDO_MAPPING_ENTRY_16XX(0, 1, PDO_MAPPING_UNSIGNED16),// Temperature One + RECEIVE_PDO_MAPPING_ENTRY_16XX(0, 2, PDO_MAPPING_UNSIGNED16),// Temperature Two + RECEIVE_PDO_MAPPING_ENTRY_16XX(0, 3, PDO_MAPPING_UNSIGNED16),// Temperature Three + RECEIVE_PDO_MAPPING_ENTRY_16XX(0, 4, PDO_MAPPING_UNSIGNED16),// Temperature Four + + RECEIVE_PDO_MAPPING_START_KEY_16XX(1, 3), + RECEIVE_PDO_MAPPING_ENTRY_16XX(1, 1, PDO_MAPPING_UNSIGNED16),// Status Word + RECEIVE_PDO_MAPPING_ENTRY_16XX(1, 2, PDO_MAPPING_UNSIGNED16),// Position Actual + RECEIVE_PDO_MAPPING_ENTRY_16XX(1, 3, PDO_MAPPING_UNSIGNED16),// Torque Actual + + RECEIVE_PDO_MAPPING_START_KEY_16XX(2, 2), + RECEIVE_PDO_MAPPING_ENTRY_16XX(2, 1, PDO_MAPPING_UNSIGNED16),// Unused Value + RECEIVE_PDO_MAPPING_ENTRY_16XX(2, 2, PDO_MAPPING_UNSIGNED16),// Battery Voltage + + DATA_LINK_START_KEY_21XX(0, 4), + DATA_LINK_21XX(0, 1, CO_TUNSIGNED16, &thermTemps[0]),// Temperature One + DATA_LINK_21XX(0, 2, CO_TUNSIGNED16, &thermTemps[1]),// Temperature Two + DATA_LINK_21XX(0, 3, CO_TUNSIGNED16, &thermTemps[2]),// Temperature Three + DATA_LINK_21XX(0, 4, CO_TUNSIGNED16, &thermTemps[3]),// Temperature Four + + DATA_LINK_START_KEY_21XX(1, 3), + DATA_LINK_21XX(1, 1, CO_TUNSIGNED16, &statusWord), // Status Word + DATA_LINK_21XX(1, 2, CO_TUNSIGNED16, &actualPosition),// Actual Position + DATA_LINK_21XX(1, 3, CO_TUNSIGNED16, &torqueActual), // Torque Actual + + DATA_LINK_START_KEY_21XX(2, 2), + DATA_LINK_21XX(2, 1, CO_TUNSIGNED16, &dummyValue), // Unused Value + DATA_LINK_21XX(2, 2, CO_TUNSIGNED16, &totalVoltage),// Total Voltage CO_OBJ_DICT_ENDMARK, }; diff --git a/libs/EVT-core b/libs/EVT-core index 0676b16..b74cfd2 160000 --- a/libs/EVT-core +++ b/libs/EVT-core @@ -1 +1 @@ -Subproject commit 0676b1677e95fe36adadd8c951b846c04cb5e4d2 +Subproject commit b74cfd2d500072f0919a78515804e3a7881da1e7 From 36c1d89f33fecd0c42d78cd0d8f6c84f24036f2e Mon Sep 17 00:00:00 2001 From: ActuallyTaylor Date: Sat, 20 Jan 2024 10:49:34 -0500 Subject: [PATCH 7/7] Added documentation to Hpp file Signed-off-by: ActuallyTaylor --- include/HUDL/HUDL.hpp | 61 ++++++++++++++++++++++++++++++++++++------- libs/EVT-core | 2 +- 2 files changed, 52 insertions(+), 11 deletions(-) diff --git a/include/HUDL/HUDL.hpp b/include/HUDL/HUDL.hpp index 04e9292..79586ad 100644 --- a/include/HUDL/HUDL.hpp +++ b/include/HUDL/HUDL.hpp @@ -7,7 +7,6 @@ #include #include #include -#include namespace IO = EVT::core::IO; namespace DEV = EVT::core::DEV; @@ -62,13 +61,14 @@ class HUDL : public CANDevice { void updateLCD(); /** - * reg_select PA_3 - * reset PB_3 - * cs PB_12 + * +The internal LCD used for for the HUDL to display. */ DEV::LCD lcd; private: + /** + * The corner of the display that will content will be displayed in. + */ enum Corner { TOP_LEFT, TOP_RIGHT, @@ -77,19 +77,25 @@ class HUDL : public CANDevice { }; /** - * The node ID used to identify the device on the CAN network. + * The node IDs used to identify the device on the CAN network. */ - static constexpr uint8_t NODE_ID = 0x11; - - static constexpr uintptr_t TMS_NODE_ID = 0x08; - static constexpr uintptr_t MC_NODE_ID = 0x01; - + /** NODE ID for the HUDL */ + static constexpr uint8_t NODE_ID = 11; + /** NODE ID for the TMS */ + static constexpr uintptr_t TMS_NODE_ID = 8; + /** NANO ID for the Motor Controller */ + static constexpr uintptr_t MC_NODE_ID = 1; + + /** A boolean that tracks whether or not the headers have been set. */ bool setHeaders = false; + /** An unused value for holding a place in the CAN Object Dictionary */ uint16_t dummyValue = 0; + /** The total voltage from the Motor Controller */ uint16_t totalVoltage = 0; + /** An array of four temperatures from the TMS */ uint16_t thermTemps[4] = {}; /** The status word provided by the MC node over CAN. Found in the first 16 bits of the 1st PDO coming from the MC. */ @@ -98,16 +104,51 @@ class HUDL : public CANDevice { /** The torque actual value provided by the MC node over CAN. Found in the first 16 bits of the 4th PDO coming from the MC. */ uint16_t torqueActual = 0; + /** The current position of the Motor Controller. Used to calculate speed, RPM and more. */ int16_t actualPosition = 0; + /** + * A static function that retrieves the column number for a specified corner. This is used + * to start drawing at a specific x column when we want to display in one of the corners. + * + * @param corner the corner to retrieve a column number for. + * @return the column index that indicates the start of the given corner. + */ static uint8_t columnForCorner(Corner corner); + + /** + * A static function that retrieves the page number for a specified corner. This is used + * to retrieve the y page where drawing should begin for a specific corner. + * + * @param corner the corner to retrieve the page for. + * @return the page index that indicates the start of the given corner. + */ static uint8_t pageForCorner(Corner corner); + /** + * Sets the header for a given corner to the specific text + * + * @param corner the corner to change text for. + * @param text the header text to display. + */ void headerForCorner(Corner corner, const char* text); + + /** + * Sets the data to display for a given corner + * + * @param corner the corner to set data for. + * @param text the data to display in the corner. + */ void dataForCorner(Corner corner, const char* text); + /** + * The size of the CAN object dictionary. + */ static constexpr uint16_t OBJECT_DICTIONARY_SIZE = 46; + /** + * The CAN object dictionary. + */ CO_OBJ_T objectDictionary[OBJECT_DICTIONARY_SIZE + 1] = { MANDATORY_IDENTIFICATION_ENTRIES_1000_1014, HEARTBEAT_PRODUCER_1017(2000), diff --git a/libs/EVT-core b/libs/EVT-core index b74cfd2..e9bcd1a 160000 --- a/libs/EVT-core +++ b/libs/EVT-core @@ -1 +1 @@ -Subproject commit b74cfd2d500072f0919a78515804e3a7881da1e7 +Subproject commit e9bcd1ab0eac0d9bfb2e2c44f0d515de46e438cb