1
0
forked from me/IronOS

Merge branch 'master' into messing_with_pd

This commit is contained in:
Ben V. Brown
2021-04-05 20:01:40 +10:00
committed by GitHub
43 changed files with 824 additions and 551 deletions

View File

@@ -267,6 +267,26 @@ void OLED::print(const char *const str, FontStyle fontStyle) {
}
}
/**
* Prints a static string message designed to use the whole screen, starting
* from the top-left corner.
*
* If the message starts with a newline (`\\x01`), the string starting from
* after the newline is printed in the large font. Otherwise, the message
* is printed in the small font.
*
* @param string The string message to be printed
*/
void OLED::printWholeScreen(const char *string) {
setCursor(0, 0);
if (string[0] == '\x01') {
// Empty first line means that this uses large font (for CJK).
OLED::print(string + 1, FontStyle::LARGE);
} else {
OLED::print(string, FontStyle::SMALL);
}
}
inline void stripLeaderZeros(char *buffer, uint8_t places) {
// Removing the leading zero's by swapping them to SymbolSpace
// Stop 1 short so that we dont blank entire number if its zero

View File

@@ -55,6 +55,7 @@ public:
static bool getRotation() { return inLeftHandedMode; }
static int16_t getCursorX() { return cursor_x; }
static void print(const char *string, FontStyle fontStyle); // Draw a string to the current location, with selected font
static void printWholeScreen(const char *string);
// Set the cursor location by pixels
static void setCursor(int16_t x, int16_t y) {
cursor_x = x;

View File

@@ -12,9 +12,9 @@ extern const uint8_t USER_FONT_12[];
extern const uint8_t USER_FONT_6x8[];
extern const bool HasFahrenheit;
extern const char *SettingsShortNames[33][2];
extern const char *SettingsDescriptions[33];
extern const char *SettingsMenuEntries[5];
extern const char *SettingsShortNames[];
extern const char *SettingsDescriptions[];
extern const char *SettingsMenuEntries[];
extern const char *SettingsCalibrationDone;
extern const char *SettingsCalibrationWarning;
@@ -35,8 +35,9 @@ extern const char *IdleSetString;
extern const char *TipDisconnectedString;
extern const char *SolderingAdvancedPowerPrompt;
extern const char *OffString;
extern const char *ResetOKMessage;
extern const char *YourGainMessage;
extern const char *ResetOKMessage;
extern const char *SettingsResetMessage;
extern const char *NoAccelerometerMessage;
extern const char *NoPowerDeliveryMessage;

View File

@@ -29,6 +29,7 @@ typedef struct {
void enterSettingsMenu();
void GUIDelay();
void warnUser(const char *warning, const int timeout);
extern const menuitem rootSettingsMenu[];
#endif /* GUI_HPP_ */

View File

@@ -237,20 +237,6 @@ const menuitem advancedMenu[] = {
{nullptr, nullptr, nullptr} // end of menu marker. DO NOT REMOVE
};
static void printShortDescriptionDoubleLine(SettingsItemIndex settingsItemIndex) {
uint8_t shortDescIndex = static_cast<uint8_t>(settingsItemIndex);
if (SettingsShortNames[shortDescIndex][0][0] == '\x00') {
// Empty first line means that this uses large font (for CJK).
OLED::setCursor(0, 0);
OLED::print(SettingsShortNames[shortDescIndex][1], FontStyle::LARGE);
} else {
OLED::setCursor(0, 0);
OLED::print(SettingsShortNames[shortDescIndex][0], FontStyle::SMALL);
OLED::setCursor(0, 8);
OLED::print(SettingsShortNames[shortDescIndex][1], FontStyle::SMALL);
}
}
/**
* Prints two small lines (or one line for CJK) of short description for
* setting items and prepares cursor after it.
@@ -260,7 +246,8 @@ static void printShortDescriptionDoubleLine(SettingsItemIndex settingsItemIndex)
*/
static void printShortDescription(SettingsItemIndex settingsItemIndex, uint16_t cursorCharPosition) {
// print short description (default single line, explicit double line)
printShortDescriptionDoubleLine(settingsItemIndex);
uint8_t shortDescIndex = static_cast<uint8_t>(settingsItemIndex);
OLED::printWholeScreen(SettingsShortNames[shortDescIndex]);
// prepare cursor for value
// make room for scroll indicator
@@ -724,13 +711,7 @@ static bool settings_displayCoolingBlinkEnabled(void) {
static bool settings_setResetSettings(void) {
if (userConfirmation(SettingsResetWarning)) {
resetSettings();
OLED::clearScreen();
OLED::setCursor(0, 0);
OLED::print(ResetOKMessage, FontStyle::LARGE);
OLED::refresh();
waitForButtonPressOrTimeout(2000); // 2 second timeout
warnUser(ResetOKMessage, 2 * TICKS_SECOND);
}
return false;
}
@@ -814,7 +795,7 @@ static bool settings_setCalibrateVIN(void) {
OLED::setCursor(0, 0);
OLED::printNumber(systemSettings.voltageDiv, 3, FontStyle::LARGE);
OLED::refresh();
waitForButtonPressOrTimeout(1000);
waitForButtonPressOrTimeout(1 * TICKS_SECOND);
return false;
case BUTTON_NONE:
default:
@@ -1014,18 +995,8 @@ static bool animOpenState = false;
static void displayMenu(size_t index) {
// Call into the menu
const char *textPtr = SettingsMenuEntries[index];
FontStyle font;
if (textPtr[0] == '\x01') { // `\x01` is used as newline.
// Empty first line means that this uses large font (for CJK).
font = FontStyle::LARGE;
textPtr++;
} else {
font = FontStyle::SMALL;
}
OLED::setCursor(0, 0);
// Draw title
OLED::print(textPtr, font);
OLED::printWholeScreen(SettingsMenuEntries[index]);
// Draw symbol
// 16 pixel wide image
// 2 pixel wide scrolling indicator

View File

@@ -43,10 +43,10 @@ static uint16_t min(uint16_t a, uint16_t b) {
else
return a;
}
void warnUser(const char *warning, const FontStyle font, const int timeout) {
void warnUser(const char *warning, const int timeout) {
OLED::clearScreen();
OLED::setCursor(0, 0);
OLED::print(warning, font);
OLED::printWholeScreen(warning);
OLED::refresh();
waitForButtonPressOrTimeout(timeout);
}
@@ -462,7 +462,7 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
case BUTTON_BOTH_LONG:
// Unlock buttons
buttonsLocked = false;
warnUser(UnlockingKeysString, FontStyle::LARGE, TICKS_SECOND);
warnUser(UnlockingKeysString, TICKS_SECOND);
break;
case BUTTON_F_LONG:
// if boost mode is enabled turn it on
@@ -476,7 +476,7 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
case BUTTON_F_SHORT:
case BUTTON_B_SHORT:
// Do nothing and display a lock warming
warnUser(WarningKeysLockedString, FontStyle::LARGE, TICKS_SECOND / 2);
warnUser(WarningKeysLockedString, TICKS_SECOND / 2);
break;
default:
break;
@@ -511,7 +511,7 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
if (systemSettings.lockingMode != 0) {
// Lock buttons
buttonsLocked = true;
warnUser(LockingKeysString, FontStyle::LARGE, TICKS_SECOND);
warnUser(LockingKeysString, TICKS_SECOND);
}
break;
default:
@@ -713,12 +713,7 @@ void showDebugMenu(void) {
void showWarnings() {
// Display alert if settings were reset
if (settingsWereReset) {
if (SettingsResetMessage[0] == '\x01') { // `\x01` is used as newline.
// Empty first line means that this uses large font (for CJK).
warnUser(SettingsResetMessage + 1, FontStyle::LARGE, 10 * TICKS_SECOND);
} else {
warnUser(SettingsResetMessage, FontStyle::SMALL, 10 * TICKS_SECOND);
}
warnUser(SettingsResetMessage, 10 * TICKS_SECOND);
}
#ifndef NO_WARN_MISSING
// We also want to alert if accel or pd is not detected / not responding
@@ -732,7 +727,7 @@ void showWarnings() {
if (systemSettings.accelMissingWarningCounter < 2) {
systemSettings.accelMissingWarningCounter++;
saveSettings();
warnUser(NoAccelerometerMessage, FontStyle::SMALL, 10 * TICKS_SECOND);
warnUser(NoAccelerometerMessage, 10 * TICKS_SECOND);
}
}
#ifdef POW_PD
@@ -741,7 +736,7 @@ void showWarnings() {
if (systemSettings.pdMissingWarningCounter < 2) {
systemSettings.pdMissingWarningCounter++;
saveSettings();
warnUser(NoPowerDeliveryMessage, FontStyle::SMALL, 10 * TICKS_SECOND);
warnUser(NoPowerDeliveryMessage, 10 * TICKS_SECOND);
}
}
#endif

View File

@@ -316,7 +316,7 @@ $(OUT_OBJS_S): $(OUTPUT_DIR)/%.o: %.S Makefile
@echo 'Building file: $<'
@$(AS) -c $(AFLAGS) $< -o $@
Core/Gen/Translation.%.cpp: ../Translations/translation_%.json Makefile ../Translations/make_translation.py ../Translations/translations_commons.js ../Translations/font_tables.py ../Translations/wqy-bitmapsong/wenquanyi_9pt.bdf
Core/Gen/Translation.%.cpp: ../Translations/translation_%.json Makefile ../Translations/make_translation.py ../Translations/translations_def.js ../Translations/font_tables.py ../Translations/wqy-bitmapsong/wenquanyi_9pt.bdf
@test -d $(@D) || mkdir -p $(@D)
@echo 'Generating translations for language $*'
@python3 ../Translations/make_translation.py -o $(PWD)/$@ $*