Skip to content

Commit

Permalink
Show power source type on detailed screen in soldering mode (Ralim#1708)
Browse files Browse the repository at this point in the history
  • Loading branch information
ia committed Jun 16, 2023
1 parent 5b1c273 commit 9470de2
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 40 deletions.
4 changes: 2 additions & 2 deletions Translations/make_translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ def get_power_source_list() -> List[str]:
return [
"DC",
"QC",
"PD W. VBus",
"PD No VBus",
"PV:PDwVBus",
"PD:No VBus",
]


Expand Down
6 changes: 5 additions & 1 deletion source/Core/Drivers/OLED.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,9 @@ void OLED::setInverseDisplay(bool inverse) {
}

// print a string to the current cursor location
void OLED::print(const char *const str, FontStyle fontStyle) {
void OLED::print(const char *const str, FontStyle fontStyle, uint8_t n) {
const uint8_t *next = reinterpret_cast<const uint8_t *>(str);
bool cut = n ? true : false;
if (next[0] == 0x01) {
fontStyle = FontStyle::LARGE;
next++;
Expand All @@ -424,6 +425,9 @@ void OLED::print(const char *const str, FontStyle fontStyle) {
next += 2;
}
drawChar(index, fontStyle);
if (cut && !--n) {
return;
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion source/Core/Drivers/OLED.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class OLED {
static void setBrightness(uint8_t contrast);
static void setInverseDisplay(bool inverted);
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 print(const char *string, FontStyle fontStyle, uint8_t num = 0); // Draw a string (or only a number of chars from string if specified) 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) {
Expand Down
68 changes: 35 additions & 33 deletions source/Core/Threads/OperatingModes/DebugMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,39 @@ extern osThreadId MOVTaskHandle;
extern osThreadId PIDTaskHandle;
extern OperatingMode currentMode;

int8_t getPowerSourceNumber(void) {
int8_t sourceNumber = 0;
if (getIsPoweredByDCIN()) {
sourceNumber = 0;
} else {
// We are not powered via DC, so want to display the appropriate state for PD or QC
bool poweredbyPD = false;
bool pdHasVBUSConnected = false;
#ifdef POW_PD
if (USBPowerDelivery::fusbPresent()) {
// We are PD capable
if (USBPowerDelivery::negotiationComplete()) {
// We are powered via PD
poweredbyPD = true;
#ifdef VBUS_MOD_TEST
pdHasVBUSConnected = USBPowerDelivery::isVBUSConnected();
#endif
}
}
#endif
if (poweredbyPD) {
if (pdHasVBUSConnected) {
sourceNumber = 2;
} else {
sourceNumber = 3;
}
} else {
sourceNumber = 1;
}
}
return sourceNumber;
}

void showDebugMenu(void) {
currentMode = OperatingMode::debug;
uint8_t screen = 0;
Expand Down Expand Up @@ -35,39 +68,8 @@ void showDebugMenu(void) {
OLED::print(AccelTypeNames[(int)DetectedAccelerometerVersion], FontStyle::SMALL);
break;
case 3: // Power Negotiation Status
{
int sourceNumber = 0;
if (getIsPoweredByDCIN()) {
sourceNumber = 0;
} else {
// We are not powered via DC, so want to display the appropriate state for PD or QC
bool poweredbyPD = false;
bool pdHasVBUSConnected = false;
#ifdef POW_PD
if (USBPowerDelivery::fusbPresent()) {
// We are PD capable
if (USBPowerDelivery::negotiationComplete()) {
// We are powered via PD
poweredbyPD = true;
#ifdef VBUS_MOD_TEST
pdHasVBUSConnected = USBPowerDelivery::isVBUSConnected();
#endif
}
}
#endif
if (poweredbyPD) {

if (pdHasVBUSConnected) {
sourceNumber = 2;
} else {
sourceNumber = 3;
}
} else {
sourceNumber = 1;
}
}
OLED::print(PowerSourceNames[sourceNumber], FontStyle::SMALL);
} break;
OLED::print(PowerSourceNames[getPowerSourceNumber()], FontStyle::SMALL);
break;
case 4: // Input Voltage
printVoltage();
break;
Expand Down
9 changes: 6 additions & 3 deletions source/Core/Threads/OperatingModes/OperatingModes.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,18 @@ enum OperatingMode {
debug = 5
};

// Main functions
void performCJCC(void); // Used to calibrate the Cold Junction offset
void gui_solderingTempAdjust(void); // For adjusting the setpoint temperature of the iron
int gui_SolderingSleepingMode(bool stayOff, bool autoStarted); // Sleep mode
void gui_solderingMode(uint8_t jumpToSleep); // Main mode for hot pointy tool
void gui_solderingProfileMode(); // Profile mode for hot likely-not-so-pointy tool
void showDebugMenu(void); // Debugging values
void showPDDebug(void); // Debugging menu that hows PD adaptor info
void showPDDebug(void); // Debugging menu that shows PD adaptor info
void showWarnings(void); // Shows user warnings if required
void drawHomeScreen(bool buttonLockout) __attribute__((noreturn)); // IDLE / Home screen
void renderHomeScreenAssets(void); // Called to act as start delay and used to render out flipped images for home screen graphics
//
#endif

// Common helpers
int8_t getPowerSourceNumber(void); // Returns number ID of power source
#endif
7 changes: 7 additions & 0 deletions source/Core/Threads/OperatingModes/Soldering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,13 @@ void gui_solderingMode(uint8_t jumpToSleep) {
OLED::setCursor(55, 8);
}
OLED::print(SmallSymbolPlus, FontStyle::SMALL);
} else {
if (OLED::getRotation()) {
OLED::setCursor(32, 8);
} else {
OLED::setCursor(47, 8);
}
OLED::print(PowerSourceNames[getPowerSourceNumber()], FontStyle::SMALL, 2);
}

detailedPowerStatus();
Expand Down

0 comments on commit 9470de2

Please sign in to comment.