diff options
author | discip <[email protected]> | 2023-07-05 22:26:35 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2023-07-05 22:26:35 +0200 |
commit | 88f62941ec68b049cfee4944ca6c8ac6eef6d840 (patch) | |
tree | d6d55f2219742b46a3e216dada6c6f1f0efd17c0 | |
parent | 3a8eb3c5110dd94ef7ad0a2bf0f617b8c1364a33 (diff) | |
parent | cbde61edb40473cb133800dc892f1c3d4c42b5fc (diff) | |
download | IronOS-88f62941ec68b049cfee4944ca6c8ac6eef6d840.tar.gz IronOS-88f62941ec68b049cfee4944ca6c8ac6eef6d840.zip |
Merge branch 'dev' into Short-Detection
-rw-r--r-- | .gitignore | 76 | ||||
-rw-r--r-- | source/Core/Drivers/OLED.cpp | 88 | ||||
-rw-r--r-- | source/Core/Drivers/OLED.hpp | 26 | ||||
-rw-r--r-- | source/Core/Inc/Settings.h | 6 | ||||
-rw-r--r-- | source/Core/Src/Settings.cpp | 15 | ||||
-rw-r--r-- | source/Core/Src/settingsGUI.cpp | 122 |
6 files changed, 205 insertions, 128 deletions
@@ -1,3 +1,5 @@ +#### Generic ####
+
# Object files
*.o
*.ko
@@ -5,6 +7,7 @@ *.elf
*.d
*.DS_Store
+
# Precompiled Headers
*.gch
*.pch
@@ -31,33 +34,22 @@ # Debug files
*.dSYM/
*.su
-source/.metadata/*
-TS100/KiCad/TS100.bak
-Logo GUI/TS100 Logo Editor/TS100 Logo Editor/obj/
-Logo GUI/TS100 Logo Editor/TS100 Logo Editor/bin/
-*.cache
-Translation Editor/.vscode/
-Translation Editor/__pycache__/
+# Custom scripts & misc. files
*.pyc
*.lst
*.mk
*.list
-source/Hexfile/
-source/Objects/
-ci/artefacts/
-ci/secrets/unencrypted/
+# Auto generated files
+*.cache
codeship.aes
-.vscode/settings.json
+CoreCompileInputs.cache
-# Auto generated files
-source/Core/Inc/unit.h
-source/Core/Gen/
# IDE configs
.vs/*
.settings/*
-..cproject.swp
+.cproject.swp
# Visual Studios
.vscode/*
@@ -65,6 +57,7 @@ source/Core/Gen/ !.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
+.vscode/settings.json
# Eclipse
.metadata
@@ -120,11 +113,24 @@ local.properties .scala_dependencies
.worksheet
-# Jetbrains
-# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
+# source code tagging systems (GNU Global, ctags, cscope)
+GPATH
+GRTAGS
+GTAGS
+*tags
+*tags/
+.*tags
+.*tags/
+cscope.*
+cscope/
+.cscope/
+
+
+#### Jetbrains: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm ####
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
+.idea/
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
@@ -174,7 +180,35 @@ fabric.properties # Editor-based Rest Client
.idea/httpRequests
-CoreCompileInputs.cache
-.vscode/settings.json
+
+#### IronOS project specific files ####
+
+# Binaries
+source/Hexfile/
+source/Objects/
+
+# Autogenerated
+source/Core/Gen/
+source/Core/Inc/unit.h
+
+# Deploy
+scripts/ci/artefacts/
+scripts/ci/secrets/unencrypted/
+
+# Generated static local docs
+site/
+
+# Translations
+Translations/__pycache__/
+Translation Editor/__pycache__/
+Translation Editor/.vscode/
+
+# misc.
source/compile_commands.json
-.idea/
+source/.metadata/*
+
+# TS100 related
+TS100/KiCad/TS100.bak
+Logo GUI/TS100 Logo Editor/TS100 Logo Editor/obj/
+Logo GUI/TS100 Logo Editor/TS100 Logo Editor/bin/
+
diff --git a/source/Core/Drivers/OLED.cpp b/source/Core/Drivers/OLED.cpp index cb9f6327..d3388177 100644 --- a/source/Core/Drivers/OLED.cpp +++ b/source/Core/Drivers/OLED.cpp @@ -25,41 +25,43 @@ uint8_t OLED::displayOffset; uint8_t OLED::screenBuffer[16 + (OLED_WIDTH * (OLED_HEIGHT / 8)) + 10]; // The data buffer uint8_t OLED::secondFrameBuffer[16 + (OLED_WIDTH * (OLED_HEIGHT / 8)) + 10]; uint32_t OLED::displayChecksum; -/*Setup params for the OLED screen*/ -/*http://www.displayfuture.com/Display/datasheet/controller/SSD1307.pdf*/ -/*All commands are prefixed with 0x80*/ -/*Data packets are prefixed with 0x40*/ +/* + * Setup params for the OLED screen + * http://www.displayfuture.com/Display/datasheet/controller/SSD1307.pdf + * All commands are prefixed with 0x80 + * Data packets are prefixed with 0x40 + */ I2C_CLASS::I2C_REG OLED_Setup_Array[] = { /**/ - {0x80, 0xAE, 0}, /*Display off*/ - {0x80, OLED_DIVIDER, 0}, /*Set display clock divide ratio / osc freq*/ - {0x80, 0x52, 0}, /*Divide ratios*/ - {0x80, 0xA8, 0}, /*Set Multiplex Ratio*/ - {0x80, OLED_HEIGHT - 1, 0}, /*Multiplex ratio adjusts how far down the matrix it scans*/ - {0x80, 0xC0, 0}, /*Set COM Scan direction*/ - {0x80, 0xD3, 0}, /*Set vertical Display offset*/ - {0x80, 0x00, 0}, /*0 Offset*/ - {0x80, 0x40, 0}, /*Set Display start line to 0*/ + {0x80, OLED_OFF, 0}, /* Display off */ + {0x80, OLED_DIVIDER, 0}, /* Set display clock divide ratio / osc freq */ + {0x80, 0x52, 0}, /* Divide ratios */ + {0x80, 0xA8, 0}, /* Set Multiplex Ratio */ + {0x80, OLED_HEIGHT - 1, 0}, /* Multiplex ratio adjusts how far down the matrix it scans */ + {0x80, 0xC0, 0}, /* Set COM Scan direction */ + {0x80, 0xD3, 0}, /* Set vertical Display offset */ + {0x80, 0x00, 0}, /* 0 Offset */ + {0x80, 0x40, 0}, /* Set Display start line to 0 */ #ifdef OLED_SEGMENT_MAP_REVERSED - {0x80, 0xA1, 0}, /*Set Segment remap to normal*/ + {0x80, 0xA1, 0}, /* Set Segment remap to normal */ #else - {0x80, 0xA0, 0}, /*Set Segment remap to normal*/ + {0x80, 0xA0, 0}, /* Set Segment remap to normal */ #endif - {0x80, 0x8D, 0}, /*Charge Pump*/ - {0x80, 0x14, 0}, /*Charge Pump settings*/ - {0x80, 0xDA, 0}, /*Set VCOM Pins hardware config*/ - {0x80, OLED_VCOM_LAYOUT, 0}, /*Combination 0x2 or 0x12 depending on OLED model*/ - {0x80, 0x81, 0}, /*Brightness*/ - {0x80, 0x00, 0}, /*^0*/ - {0x80, 0xD9, 0}, /*Set pre-charge period*/ - {0x80, 0xF1, 0}, /*Pre charge period*/ - {0x80, 0xDB, 0}, /*Adjust VCOMH regulator ouput*/ - {0x80, 0x30, 0}, /*VCOM level*/ - {0x80, 0xA4, 0}, /*Enable the display GDDR*/ - {0x80, 0XA6, 0}, /*Normal display*/ - {0x80, 0x20, 0}, /*Memory Mode*/ - {0x80, 0x00, 0}, /*Wrap memory*/ - {0x80, 0xAF, 0}, /*Display on*/ + {0x80, 0x8D, 0}, /* Charge Pump */ + {0x80, 0x14, 0}, /* Charge Pump settings */ + {0x80, 0xDA, 0}, /* Set VCOM Pins hardware config */ + {0x80, OLED_VCOM_LAYOUT, 0}, /* Combination 0x2 or 0x12 depending on OLED model */ + {0x80, 0x81, 0}, /* Brightness */ + {0x80, 0x00, 0}, /* ^0 */ + {0x80, 0xD9, 0}, /* Set pre-charge period */ + {0x80, 0xF1, 0}, /* Pre charge period */ + {0x80, 0xDB, 0}, /* Adjust VCOMH regulator ouput */ + {0x80, 0x30, 0}, /* VCOM level */ + {0x80, 0xA4, 0}, /* Enable the display GDDR */ + {0x80, 0xA6, 0}, /* Normal display */ + {0x80, 0x20, 0}, /* Memory Mode */ + {0x80, 0x00, 0}, /* Wrap memory */ + {0x80, OLED_ON, 0}, /* Display on */ }; // Setup based on the SSD1307 and modified for the SSD1306 @@ -115,6 +117,7 @@ static uint16_t lerp(uint16_t a, uint16_t b, uint16_t t) { return a + t * (b - a void OLED::initialize() { cursor_x = cursor_y = 0; inLeftHandedMode = false; + #ifdef OLED_128x32 stripPointers[0] = &screenBuffer[FRAMEBUFFER_START]; stripPointers[1] = &screenBuffer[FRAMEBUFFER_START + OLED_WIDTH]; @@ -124,7 +127,8 @@ void OLED::initialize() { #else stripPointers[0] = &screenBuffer[FRAMEBUFFER_START]; stripPointers[1] = &screenBuffer[FRAMEBUFFER_START + OLED_WIDTH]; -#endif + +#endif /* OLED_128x32 */ displayOffset = 0; memcpy(&screenBuffer[0], &REFRESH_COMMANDS[0], sizeof(REFRESH_COMMANDS)); memcpy(&secondFrameBuffer[0], &REFRESH_COMMANDS[0], sizeof(REFRESH_COMMANDS)); @@ -140,6 +144,7 @@ void OLED::initialize() { setDisplayState(DisplayState::ON); initDone = true; } + void OLED::setFramebuffer(uint8_t *buffer) { stripPointers[0] = &buffer[FRAMEBUFFER_START]; stripPointers[1] = &buffer[FRAMEBUFFER_START + OLED_WIDTH]; @@ -147,7 +152,7 @@ void OLED::setFramebuffer(uint8_t *buffer) { #ifdef OLED_128x32 stripPointers[2] = &buffer[FRAMEBUFFER_START + (2 * OLED_WIDTH)]; stripPointers[3] = &buffer[FRAMEBUFFER_START + (3 * OLED_WIDTH)]; -#endif +#endif /* OLED_128x32 */ } /* @@ -156,7 +161,6 @@ void OLED::setFramebuffer(uint8_t *buffer) { * Precursor is the command char that is used to select the table. */ void OLED::drawChar(const uint16_t charCode, const FontStyle fontStyle) { - const uint8_t *currentFont; static uint8_t fontWidth, fontHeight; uint16_t index; @@ -243,7 +247,7 @@ void OLED::maskScrollIndicatorOnOLED() { #ifdef OLED_128x32 0x00, 0x00, -#endif +#endif /* OLED_128x32 */ // Clears two 8px strips 0x00, 0x00, @@ -266,7 +270,7 @@ void OLED::transitionSecondaryFramebuffer(bool forwardNavigation) { #ifdef OLED_128x32 stripBackPointers[2] = &secondFrameBuffer[OLED_WIDTH * 2]; stripBackPointers[3] = &secondFrameBuffer[OLED_WIDTH * 3]; -#endif +#endif /* OLED_128x32 */ TickType_t totalDuration = TICKS_100MS * 5; // 500ms TickType_t duration = 0; @@ -297,17 +301,19 @@ void OLED::transitionSecondaryFramebuffer(bool forwardNavigation) { memmove(&stripPointers[0][oldStart], &stripPointers[0][oldPrevious], OLED_WIDTH - progress); memmove(&stripPointers[1][oldStart], &stripPointers[1][oldPrevious], OLED_WIDTH - progress); + #ifdef OLED_128x32 memmove(&stripPointers[2][oldStart], &stripPointers[2][oldPrevious], OLED_WIDTH - progress); memmove(&stripPointers[3][oldStart], &stripPointers[3][oldPrevious], OLED_WIDTH - progress); -#endif +#endif /* OLED_128x32 */ memmove(&stripPointers[0][newStart], &stripBackPointers[0][newEnd], progress); memmove(&stripPointers[1][newStart], &stripBackPointers[1][newEnd], progress); + #ifdef OLED_128x32 memmove(&stripPointers[2][newStart], &stripBackPointers[2][newEnd], progress); memmove(&stripPointers[3][newStart], &stripBackPointers[3][newEnd], progress); -#endif +#endif /* OLED_128x32 */ refresh(); // Now refresh to write out the contents to the new page vTaskDelayUntil(&startDraw, TICKS_100MS / 7); @@ -367,7 +373,7 @@ void OLED::transitionScrollDown() { secondFrameBuffer[firstStripPos] = (secondFrameBuffer[firstStripPos] >> 1) | ((secondFrameBuffer[secondStripPos] & 0x01) << 7); // Finally on the bottom row; we shuffle it up ready secondFrameBuffer[secondStripPos] >>= 1; -#endif +#endif /* OLED_128x32 */ } if (getButtonState() != BUTTON_NONE) { // Exit early, but have to transition whole buffer @@ -383,7 +389,7 @@ void OLED::transitionScrollDown() { void OLED::setRotation(bool leftHanded) { #ifdef OLED_FLIP leftHanded = !leftHanded; -#endif +#endif /* OLED_FLIP */ if (inLeftHandedMode == leftHanded) { return; } @@ -399,7 +405,7 @@ void OLED::setRotation(bool leftHanded) { } else { OLED_Setup_Array[9].val = 0xA0; } -#endif +#endif /* OLED_SEGMENT_MAP_REVERSED */ // send command struct again with changes if (leftHanded) { OLED_Setup_Array[5].val = 0xC8; // c1? @@ -486,6 +492,7 @@ inline void stripLeaderZeros(char *buffer, uint8_t places) { } } } + void OLED::drawHex(uint32_t x, FontStyle fontStyle, uint8_t digits) { // print number to hex for (uint_fast8_t i = 0; i < digits; i++) { @@ -493,6 +500,7 @@ void OLED::drawHex(uint32_t x, FontStyle fontStyle, uint8_t digits) { drawChar(value + 2, fontStyle); } } + // maximum places is 5 void OLED::printNumber(uint16_t number, uint8_t places, FontStyle fontStyle, bool noLeaderZeros) { char buffer[7] = {0}; diff --git a/source/Core/Drivers/OLED.hpp b/source/Core/Drivers/OLED.hpp index cfe47eb6..93e6f694 100644 --- a/source/Core/Drivers/OLED.hpp +++ b/source/Core/Drivers/OLED.hpp @@ -36,7 +36,9 @@ extern "C" { #endif
#define DEVICEADDR_OLED (0x3c << 1)
+
#ifdef OLED_128x32
+
#define OLED_WIDTH 128
#define OLED_HEIGHT 32
#define OLED_GRAM_START 0x00 // Should be 0x00 when we have full width
@@ -44,22 +46,28 @@ extern "C" { #define OLED_GRAM_START_FLIP 0
#define OLED_GRAM_END_FLIP 0x7F
-#define OLED_VCOM_LAYOUT 0x12
+#define OLED_VCOM_LAYOUT 0x12
#define OLED_SEGMENT_MAP_REVERSED
-#define OLED_DIVIDER 0xD3
+#define OLED_DIVIDER 0xD3
+
#else
-#define OLED_WIDTH 96
-#define OLED_HEIGHT 16
-#define OLED_VCOM_LAYOUT 0x02
+#define OLED_WIDTH 96
+#define OLED_HEIGHT 16
#define OLED_GRAM_START 0x20
#define OLED_GRAM_END 0x7F
#define OLED_GRAM_START_FLIP 0
#define OLED_GRAM_END_FLIP 95
-#define OLED_DIVIDER 0xD5
+
+#define OLED_VCOM_LAYOUT 0x02
#define OLED_SEGMENT_MAP 0xA0
+#define OLED_DIVIDER 0xD5
+
+#endif /* OLED_128x32 */
+
+#define OLED_ON 0xAF
+#define OLED_OFF 0xAE
-#endif
#define FRAMEBUFFER_START 17
enum class FontStyle {
@@ -88,7 +96,7 @@ public: static void setDisplayState(DisplayState state) {
if (state != displayState) {
displayState = state;
- screenBuffer[1] = (state == ON) ? 0xAF : 0xAE;
+ screenBuffer[1] = (state == ON) ? OLED_ON : OLED_OFF;
// Dump the screen state change out _now_
I2C_CLASS::Transmit(DEVICEADDR_OLED, screenBuffer, FRAMEBUFFER_START - 1);
osDelay(TICKS_10MS);
@@ -102,7 +110,7 @@ public: return !inLeftHandedMode;
#else
return inLeftHandedMode;
-#endif
+#endif /* OLED_FLIP */
}
static void setBrightness(uint8_t contrast);
static void setInverseDisplay(bool inverted);
diff --git a/source/Core/Inc/Settings.h b/source/Core/Inc/Settings.h index 9fa7da71..c1eef128 100644 --- a/source/Core/Inc/Settings.h +++ b/source/Core/Inc/Settings.h @@ -86,6 +86,12 @@ typedef enum { ZERO = 3, // Power on only (No heat Mode) } autoStartMode_t; +typedef enum { + RIGHT = 0, // Right-hand screen orientation + LEFT = 1, // Left-hand screen orientation + AUTO = 2, // Automatic screen orientation based on accel.data if presented +} orientationMode_t; + // Settings wide operations void saveSettings(); bool loadSettings(); diff --git a/source/Core/Src/Settings.cpp b/source/Core/Src/Settings.cpp index 4cb2c29e..00f33c54 100644 --- a/source/Core/Src/Settings.cpp +++ b/source/Core/Src/Settings.cpp @@ -19,7 +19,7 @@ bool sanitiseSettings(); #define QC_VOLTAGE_MAX 220 #else #define QC_VOLTAGE_MAX 140 -#endif +#endif /* POW_QC_20V */ /* * This struct must be a multiple of 2 bytes as it is saved / restored from @@ -36,6 +36,7 @@ typedef struct { //~1024 is common programming size, setting threshold to be lower so we have warning static_assert(sizeof(systemSettingsType) < 512); + // char (*__kaboom)[sizeof(systemSettingsType)] = 1; // Uncomment to print size at compile time volatile systemSettingsType systemSettings; @@ -108,9 +109,9 @@ static_assert((sizeof(settingsConstants) / sizeof(SettingConstants)) == ((int)Se void saveSettings() { #ifdef CANT_DIRECT_READ_SETTINGS // For these devices flash is not 1:1 mapped, so need to read into staging buffer - systemSettingsType temp; - flash_read_buffer((uint8_t *)&temp, sizeof(systemSettingsType)); - if (memcmp((void *)&temp, (void *)&systemSettings, sizeof(systemSettingsType))) { + systemSettingsType settings; + flash_read_buffer((uint8_t *)&settings, sizeof(systemSettingsType)); + if (memcmp((void *)&settings, (void *)&systemSettings, sizeof(systemSettingsType))) { flash_save_buffer((uint8_t *)&systemSettings, sizeof(systemSettingsType)); } @@ -119,7 +120,7 @@ void saveSettings() { flash_save_buffer((uint8_t *)&systemSettings, sizeof(systemSettingsType)); } -#endif +#endif /* CANT_DIRECT_READ_SETTINGS */ } bool loadSettings() { @@ -161,6 +162,7 @@ bool sanitiseSettings() { } return dirty; } + void resetSettings() { memset((void *)&systemSettings, 0xFF, sizeof(systemSettingsType)); sanitiseSettings(); @@ -179,6 +181,7 @@ void setSettingValue(const enum SettingsOptions option, const uint16_t newValue) } systemSettings.settingsValues[(int)option] = constrainedValue; } + // Lookup wrapper for ease of use (with typing) uint16_t getSettingValue(const enum SettingsOptions option) { return systemSettings.settingsValues[(int)option]; } @@ -217,6 +220,7 @@ bool prevSettingValue(const enum SettingsOptions option) { // Return if we are at the min return constants.min == systemSettings.settingsValues[(int)option]; } + uint16_t lookupHallEffectThreshold() { // Return the threshold above which the hall effect sensor is "activated" // We want this to be roughly exponentially mapped from 0-1000 @@ -245,6 +249,7 @@ uint16_t lookupHallEffectThreshold() { return 0; // Off } } + // Lookup function for cutoff setting -> X10 voltage /* * 0=DC diff --git a/source/Core/Src/settingsGUI.cpp b/source/Core/Src/settingsGUI.cpp index f90af520..636e5bb4 100644 --- a/source/Core/Src/settingsGUI.cpp +++ b/source/Core/Src/settingsGUI.cpp @@ -20,35 +20,42 @@ void gui_Menu(const menuitem *menu); static void displayInputVRange(void); static bool showInputVOptions(void); static void displayInputMinVRange(void); -#endif +#endif /* POW_DC */ + #ifdef POW_QC static void displayQCInputV(void); -#endif +#endif /* POW_QC */ + #ifdef POW_PD static void displayPDNegTimeout(void); static void displayPDVpdo(void); -#endif +#endif /* POW_PD */ + static void displaySensitivity(void); static void displayShutdownTime(void); static bool showSleepOptions(void); + #ifndef NO_SLEEP_MODE static bool setSleepTemp(void); static void displaySleepTemp(void); static void displaySleepTime(void); -#endif +#endif /* *not* NO_SLEEP_MODE */ + static bool setTempF(void); static void displayTempF(void); static void displayAdvancedSolderingScreens(void); static void displayAdvancedIDLEScreens(void); static void displayScrollSpeed(void); static void displayPowerLimit(void); + #ifdef BLE_ENABLED static void displayBluetoothLE(void); -#endif +#endif /* BLE_ENABLED */ + #ifndef NO_DISPLAY_ROTATE static bool setDisplayRotation(void); static void displayDisplayRotation(void); -#endif +#endif /* *not* NO_DISPLAY_ROTATE */ static bool setBoostTemp(void); static void displayBoostTemp(void); @@ -79,7 +86,7 @@ static bool showProfilePhase2Options(void); static bool showProfilePhase3Options(void); static bool showProfilePhase4Options(void); static bool showProfilePhase5Options(void); -#endif +#endif /* PROFILE_SUPPORT */ static void displayAutomaticStartMode(void); static void displayLockingMode(void); @@ -107,13 +114,15 @@ static void displayLogoTime(void); #ifdef HALL_SENSOR static void displayHallEffect(void); static bool showHallEffect(void); -#endif +#endif /* HALL_SENSOR */ + // Menu functions #if defined(POW_DC) || defined(POW_QC) static void displayPowerMenu(void); static bool enterPowerMenu(void); -#endif +#endif /* POW_DC or POW_QC */ + static void displaySolderingMenu(void); static bool enterSolderingMenu(void); static void displayPowerSavingMenu(void); @@ -122,6 +131,7 @@ static void displayUIMenu(void); static bool enterUIMenu(void); static void displayAdvancedMenu(void); static bool enterAdvancedMenu(void); + /* * Root Settings Menu * @@ -185,6 +195,7 @@ static bool enterAdvancedMenu(void); * Factory Reset * */ + const menuitem rootSettingsMenu[] { /* * Power Menu @@ -197,7 +208,7 @@ const menuitem rootSettingsMenu[] { */ #if defined(POW_DC) || defined(POW_QC) {0, enterPowerMenu, displayPowerMenu, nullptr, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::NUM_ITEMS, 0}, /*Power*/ -#endif +#endif /* POW_DC or POW_QC */ {0, enterSolderingMenu, displaySolderingMenu, nullptr, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::NUM_ITEMS, 0}, /*Soldering*/ {0, enterPowerSavingMenu, displayPowerSavingMenu, nullptr, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::NUM_ITEMS, 0}, /*Sleep Options Menu*/ {0, enterUIMenu, displayUIMenu, nullptr, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::NUM_ITEMS, 0}, /*UI Menu*/ @@ -220,17 +231,18 @@ const menuitem powerMenu[] = { #ifdef POW_DC {SETTINGS_DESC(SettingsItemIndex::DCInCutoff), nullptr, displayInputVRange, nullptr, SettingsOptions::MinDCVoltageCells, SettingsItemIndex::DCInCutoff, 6}, /*Voltage input*/ {SETTINGS_DESC(SettingsItemIndex::MinVolCell), nullptr, displayInputMinVRange, showInputVOptions, SettingsOptions::MinVoltageCells, SettingsItemIndex::MinVolCell, 5}, /*Minimum voltage input*/ -#endif +#endif /* POW_DC */ #ifdef POW_QC {SETTINGS_DESC(SettingsItemIndex::QCMaxVoltage), nullptr, displayQCInputV, nullptr, SettingsOptions::QCIdealVoltage, SettingsItemIndex::QCMaxVoltage, 4}, /*Voltage input*/ -#endif +#endif /* POW_QC */ #ifdef POW_PD {SETTINGS_DESC(SettingsItemIndex::PDNegTimeout), nullptr, displayPDNegTimeout, nullptr, SettingsOptions::PDNegTimeout, SettingsItemIndex::PDNegTimeout, 5}, /*PD timeout setup*/ {SETTINGS_DESC(SettingsItemIndex::PDVpdo), nullptr, displayPDVpdo, nullptr, SettingsOptions::PDVpdo, SettingsItemIndex::PDVpdo, 7 }, /*Toggle PPS & EPR*/ -#endif +#endif /* POW_PD */ {0, nullptr, nullptr, nullptr, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::NUM_ITEMS, 0} // end of menu marker. DO NOT REMOVE }; -#endif +#endif /* POW_DC or POW_QC or POW_PD */ + const menuitem solderingMenu[] = { /* * Boost Mode Temp @@ -275,9 +287,10 @@ const menuitem solderingMenu[] = { {SETTINGS_DESC(SettingsItemIndex::ProfilePhase1Temp), setProfilePhase5Temp, displayProfilePhase5Temp, showProfilePhase5Options, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::ProfilePhase5Temp, 5}, /*Phase 5 Temp*/ {SETTINGS_DESC(SettingsItemIndex::ProfilePhase1Duration), nullptr, displayProfilePhase5Duration, showProfilePhase5Options, SettingsOptions::ProfilePhase5Duration, SettingsItemIndex::ProfilePhase5Duration, 5}, /*Phase 5 Duration*/ {SETTINGS_DESC(SettingsItemIndex::ProfileCooldownSpeed), nullptr, displayProfileCooldownSpeed, showProfileOptions, SettingsOptions::ProfileCooldownSpeed, SettingsItemIndex::ProfileCooldownSpeed, 5}, /*Profile Cooldown Speed*/ -#endif +#endif /* PROFILE_SUPPORT */ {0, nullptr, nullptr, nullptr, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::NUM_ITEMS, 0} // end of menu marker. DO NOT REMOVE }; + const menuitem PowerSavingMenu[] = { /* * Motion Sensitivity @@ -291,14 +304,15 @@ const menuitem PowerSavingMenu[] = { {SETTINGS_DESC(SettingsItemIndex::SleepTemperature), setSleepTemp, displaySleepTemp, showSleepOptions, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::SleepTemperature, 5}, /*Sleep Temp*/ {SETTINGS_DESC(SettingsItemIndex::SleepTimeout), nullptr, displaySleepTime, showSleepOptions, SettingsOptions::SleepTime, SettingsItemIndex::SleepTimeout, 5}, /*Sleep Time*/ -#endif +#endif /* *not* NO_SLEEP_MODE */ {SETTINGS_DESC(SettingsItemIndex::ShutdownTimeout), nullptr, displayShutdownTime, showSleepOptions, SettingsOptions::ShutdownTime, SettingsItemIndex::ShutdownTimeout, 5}, /*Shutdown Time*/ #ifdef HALL_SENSOR {SETTINGS_DESC(SettingsItemIndex::HallEffSensitivity), nullptr, displayHallEffect, showHallEffect, SettingsOptions::HallEffectSensitivity, SettingsItemIndex::HallEffSensitivity, 7}, /* HallEffect Sensitivity*/ -#endif +#endif /* HALL_SENSOR */ {0, nullptr, nullptr, nullptr, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::NUM_ITEMS, 0} // end of menu marker. DO NOT REMOVE }; + const menuitem UIMenu[] = { /* * Temperature Unit @@ -319,7 +333,7 @@ const menuitem UIMenu[] = { #ifndef NO_DISPLAY_ROTATE {SETTINGS_DESC(SettingsItemIndex::DisplayRotation), setDisplayRotation, displayDisplayRotation, nullptr, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::DisplayRotation, 7}, /*Display Rotation*/ -#endif +#endif /* *not* NO_DISPLAY_ROTATE */ {SETTINGS_DESC(SettingsItemIndex::CooldownBlink), nullptr, displayCoolingBlinkEnabled, nullptr, SettingsOptions::CoolingTempBlink, SettingsItemIndex::CooldownBlink, 7}, /*Cooling blink warning*/ {SETTINGS_DESC(SettingsItemIndex::ScrollingSpeed), nullptr, displayScrollSpeed, nullptr, SettingsOptions::DescriptionScrollSpeed, SettingsItemIndex::ScrollingSpeed, 7}, /*Scroll Speed for descriptions*/ @@ -335,6 +349,7 @@ const menuitem UIMenu[] = { 7}, /*Advanced soldering screen*/ {0, nullptr, nullptr, nullptr, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::NUM_ITEMS, 0} // end of menu marker. DO NOT REMOVE }; + const menuitem advancedMenu[] = { /* * BluetoothLE @@ -348,7 +363,7 @@ const menuitem advancedMenu[] = { */ #ifdef BLE_ENABLED {SETTINGS_DESC(SettingsItemIndex::BluetoothLE), nullptr, displayBluetoothLE, nullptr, SettingsOptions::BluetoothLE, SettingsItemIndex::BluetoothLE, 7}, /*Toggle BLE*/ -#endif +#endif /* BLE_ENABLED */ {SETTINGS_DESC(SettingsItemIndex::PowerLimit), nullptr, displayPowerLimit, nullptr, SettingsOptions::PowerLimit, SettingsItemIndex::PowerLimit, 4}, /*Power limit*/ {SETTINGS_DESC(SettingsItemIndex::CalibrateCJC), setCalibrate, displayCalibrate, nullptr, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::CalibrateCJC, 7}, /*Calibrate Cold Junktion Compensation at next boot*/ @@ -409,10 +424,10 @@ static int userConfirmation(const char *message) { } return 0; } + #ifdef POW_DC static void displayInputVRange(void) { - if (getSettingValue(SettingsOptions::MinDCVoltageCells)) { OLED::printNumber(2 + getSettingValue(SettingsOptions::MinDCVoltageCells), 1, FontStyle::LARGE); OLED::print(LargeSymbolCellCount, FontStyle::LARGE); @@ -422,17 +437,18 @@ static void displayInputVRange(void) { } static bool showInputVOptions(void) { return getSettingValue(SettingsOptions::MinDCVoltageCells) > 0; } -static void displayInputMinVRange(void) { +static void displayInputMinVRange(void) { OLED::printNumber(getSettingValue(SettingsOptions::MinVoltageCells) / 10, 1, FontStyle::LARGE); OLED::print(LargeSymbolDot, FontStyle::LARGE); OLED::printNumber(getSettingValue(SettingsOptions::MinVoltageCells) % 10, 1, FontStyle::LARGE); } -#endif + +#endif /* POW_DC */ + #ifdef POW_QC static void displayQCInputV(void) { - // These are only used in QC modes // Allows setting the voltage negotiated for QC auto voltage = getSettingValue(SettingsOptions::QCIdealVoltage); @@ -441,12 +457,11 @@ static void displayQCInputV(void) { OLED::printNumber(voltage % 10, 1, FontStyle::LARGE); } -#endif +#endif /* POW_QC */ -#ifdef POW_PD +#ifdef POW_PD /* POW_PD */ static void displayPDNegTimeout(void) { - auto value = getSettingValue(SettingsOptions::PDNegTimeout); if (value == 0) { OLED::print(translatedString(Tr->OffString), FontStyle::LARGE); @@ -454,8 +469,10 @@ static void displayPDNegTimeout(void) { OLED::printNumber(value, 3, FontStyle::LARGE); } } + static void displayPDVpdo(void) { OLED::drawCheckbox(getSettingValue(SettingsOptions::PDVpdo)); } -#endif + +#endif /* POW_PD */ static bool setBoostTemp(void) { uint16_t value = getSettingValue(SettingsOptions::BoostTemp); @@ -485,7 +502,6 @@ static bool setBoostTemp(void) { } static void displayBoostTemp(void) { - if (getSettingValue(SettingsOptions::BoostTemp)) { OLED::printNumber(getSettingValue(SettingsOptions::BoostTemp), 3, FontStyle::LARGE); } else { @@ -494,7 +510,6 @@ static void displayBoostTemp(void) { } static void displayAutomaticStartMode(void) { - switch (getSettingValue(SettingsOptions::AutoStartMode)) { case autoStartMode_t::NO: OLED::print(translatedString(Tr->SettingStartNoneChar), FontStyle::LARGE); @@ -519,7 +534,6 @@ static void displayTempChangeShortStep(void) { OLED::printNumber(getSettingValue static void displayTempChangeLongStep(void) { OLED::printNumber(getSettingValue(SettingsOptions::TempChangeLongStep), 2, FontStyle::LARGE); } static void displayLockingMode(void) { - switch (getSettingValue(SettingsOptions::LockingMode)) { case 0: OLED::print(translatedString(Tr->SettingLockDisableChar), FontStyle::LARGE); @@ -587,7 +601,7 @@ static bool showProfilePhase3Options(void) { return getSettingValue(SettingsOpti static bool showProfilePhase4Options(void) { return getSettingValue(SettingsOptions::ProfilePhases) >= 4; } static bool showProfilePhase5Options(void) { return getSettingValue(SettingsOptions::ProfilePhases) >= 5; } -#endif +#endif /* PROFILE_SUPPORT */ static void displaySensitivity(void) { OLED::printNumber(getSettingValue(SettingsOptions::Sensitivity), 1, FontStyle::LARGE, false); } static bool showSleepOptions(void) { return getSettingValue(SettingsOptions::Sensitivity) > 0; } @@ -615,7 +629,6 @@ static bool setSleepTemp(void) { static void displaySleepTemp(void) { OLED::printNumber(getSettingValue(SettingsOptions::SleepTemp), 3, FontStyle::LARGE); } static void displaySleepTime(void) { - if (getSettingValue(SettingsOptions::SleepTime) == 0) { OLED::print(translatedString(Tr->OffString), FontStyle::LARGE); } else if (getSettingValue(SettingsOptions::SleepTime) < 6) { @@ -626,10 +639,10 @@ static void displaySleepTime(void) { OLED::print(LargeSymbolMinutes, FontStyle::LARGE); } } -#endif -static void displayShutdownTime(void) { +#endif /* *not* NO_SLEEP_MODE */ +static void displayShutdownTime(void) { if (getSettingValue(SettingsOptions::ShutdownTime) == 0) { OLED::print(translatedString(Tr->OffString), FontStyle::LARGE); } else { @@ -641,7 +654,7 @@ static void displayShutdownTime(void) { #ifdef HALL_SENSOR static void displayHallEffect(void) { OLED::printNumber(getSettingValue(SettingsOptions::HallEffectSensitivity), 1, FontStyle::LARGE, false); } static bool showHallEffect(void) { return getHallSensorFitted(); } -#endif +#endif /* HALL_SENSOR */ static void setTempF(const enum SettingsOptions option) { uint16_t Temp = getSettingValue(option); @@ -666,7 +679,7 @@ static bool setTempF(void) { setTempF(SettingsOptions::SolderingTemp); #ifndef NO_SLEEP_MODE setTempF(SettingsOptions::SleepTemp); -#endif +#endif /* *not* NO_SLEEP_MODE */ #ifdef PROFILE_SUPPORT setTempF(SettingsOptions::ProfilePreheatTemp); setTempF(SettingsOptions::ProfilePhase1Temp); @@ -674,23 +687,24 @@ static bool setTempF(void) { setTempF(SettingsOptions::ProfilePhase3Temp); setTempF(SettingsOptions::ProfilePhase4Temp); setTempF(SettingsOptions::ProfilePhase5Temp); -#endif +#endif /* PROFILE_SUPPORT */ return res; } static void displayTempF(void) { OLED::print((getSettingValue(SettingsOptions::TemperatureInF)) ? LargeSymbolDegF : LargeSymbolDegC, FontStyle::LARGE); } #ifndef NO_DISPLAY_ROTATE + static bool setDisplayRotation(void) { bool res = nextSettingValue(SettingsOptions::OrientationMode); switch (getSettingValue(SettingsOptions::OrientationMode)) { - case 0: + case orientationMode_t::RIGHT: OLED::setRotation(false); break; - case 1: + case orientationMode_t::LEFT: OLED::setRotation(true); break; - case 2: + case orientationMode_t::AUTO: // do nothing on auto break; default: @@ -700,15 +714,14 @@ static bool setDisplayRotation(void) { } static void displayDisplayRotation(void) { - switch (getSettingValue(SettingsOptions::OrientationMode)) { - case 0: + case orientationMode_t::RIGHT: OLED::print(translatedString(Tr->SettingRightChar), FontStyle::LARGE); break; - case 1: + case orientationMode_t::LEFT: OLED::print(translatedString(Tr->SettingLeftChar), FontStyle::LARGE); break; - case 2: + case orientationMode_t::AUTO: OLED::print(translatedString(Tr->SettingAutoChar), FontStyle::LARGE); break; default: @@ -716,7 +729,8 @@ static void displayDisplayRotation(void) { break; } } -#endif + +#endif /* NO_DISPLAY_ROTATE */ static void displayCoolingBlinkEnabled(void) { OLED::drawCheckbox(getSettingValue(SettingsOptions::CoolingTempBlink)); } @@ -725,7 +739,6 @@ static void displayScrollSpeed(void) { OLED::print(translatedString((getSettingV static void displayReverseButtonTempChangeEnabled(void) { OLED::drawCheckbox(getSettingValue(SettingsOptions::ReverseButtonTempChangeEnabled)); } static void displayAnimationSpeed(void) { - switch (getSettingValue(SettingsOptions::AnimationSpeed)) { case settingOffSpeed_t::SLOW: OLED::print(translatedString(Tr->SettingSlowChar), FontStyle::LARGE); @@ -746,21 +759,18 @@ static bool displayAnimationOptions(void) { return getSettingValue(SettingsOptio static void displayAnimationLoop(void) { OLED::drawCheckbox(getSettingValue(SettingsOptions::AnimationLoop)); } static void displayBrightnessLevel(void) { - OLED::printNumber((getSettingValue(SettingsOptions::OLEDBrightness) / BRIGHTNESS_STEP + 1), 1, FontStyle::LARGE); // While not optimal to apply this here, it is _very_ convienient OLED::setBrightness(getSettingValue(SettingsOptions::OLEDBrightness)); } static void displayInvertColor(void) { - OLED::drawCheckbox(getSettingValue(SettingsOptions::OLEDInversion)); // While not optimal to apply this here, it is _very_ convienient OLED::setInverseDisplay(getSettingValue(SettingsOptions::OLEDInversion)); } static void displayLogoTime(void) { - if (getSettingValue(SettingsOptions::LOGOTime) == 0) { OLED::print(translatedString(Tr->OffString), FontStyle::LARGE); } else if (getSettingValue(SettingsOptions::LOGOTime) == 5) { @@ -774,11 +784,12 @@ static void displayLogoTime(void) { static void displayAdvancedIDLEScreens(void) { OLED::drawCheckbox(getSettingValue(SettingsOptions::DetailedIDLE)); } static void displayAdvancedSolderingScreens(void) { OLED::drawCheckbox(getSettingValue(SettingsOptions::DetailedSoldering)); } + #ifdef BLE_ENABLED static void displayBluetoothLE(void) { OLED::drawCheckbox(getSettingValue(SettingsOptions::BluetoothLE)); } -#endif -static void displayPowerLimit(void) { +#endif /* BLE_ENABLED */ +static void displayPowerLimit(void) { if (getSettingValue(SettingsOptions::PowerLimit) == 0) { OLED::print(translatedString(Tr->OffString), FontStyle::LARGE); } else { @@ -845,7 +856,6 @@ static bool setCalibrateVIN(void) { static void displayCalibrateVIN(void) {} static void displayPowerPulse(void) { - if (getSettingValue(SettingsOptions::KeepAwakePulse)) { OLED::printNumber(getSettingValue(SettingsOptions::KeepAwakePulse) / 10, 1, FontStyle::LARGE); OLED::print(LargeSymbolDot, FontStyle::LARGE); @@ -856,6 +866,7 @@ static void displayPowerPulse(void) { } static bool showPowerPulseOptions(void) { return getSettingValue(SettingsOptions::KeepAwakePulse) > 0; } + static void displayPowerPulseWait(void) { OLED::printNumber(getSettingValue(SettingsOptions::KeepAwakePulseWait), 1, FontStyle::LARGE); } static void displayPowerPulseDuration(void) { OLED::printNumber(getSettingValue(SettingsOptions::KeepAwakePulseDuration), 1, FontStyle::LARGE); } @@ -922,22 +933,26 @@ static bool enterPowerMenu(void) { gui_Menu(powerMenu); return false; } -#endif +#endif /* POW_DC or POW_QC */ + static void displaySolderingMenu(void) { displayMenu(1); } static bool enterSolderingMenu(void) { gui_Menu(solderingMenu); return false; } + static void displayPowerSavingMenu(void) { displayMenu(2); } static bool enterPowerSavingMenu(void) { gui_Menu(PowerSavingMenu); return false; } + static void displayUIMenu(void) { displayMenu(3); } static bool enterUIMenu(void) { gui_Menu(HasFahrenheit ? UIMenu : UIMenu + 1); return false; } + static void displayAdvancedMenu(void) { displayMenu(4); } static bool enterAdvancedMenu(void) { gui_Menu(advancedMenu); @@ -955,6 +970,7 @@ uint8_t gui_getMenuLength(const menuitem *menu) { } return scrollContentSize; } + void gui_Menu(const menuitem *menu) { // Draw the settings menu and provide iteration support etc |