WIP: Split Render for multiple screen resolutions (#1888)

* Create README.md

* Move to new folder

* Migrating

* Migrate Remainder

* format fix (all but one) (#1889)

* Update USBPDDebug_FS2711.cpp

* Delete PrintVoltage.cpp

* Copy in 128x32 template

* Mask drawing for 96x16

* Import #1819

* Update Font.h

* Homescreen

* Update draw_homescreen_detailed.cpp

* Fix oled normal draw for variable height

* Update OLED.cpp

* Draw settings icons

* Update draw_homescreen_simplified.cpp

* Update draw_power_source_icon.cpp

* Fixup oled drawing for fill area

* Update the region fill for mixed heights

* Fix newline height

* FIXUP! Draw icons in settings menu at correct size

* Fix scrollbar

* Update settingsGUI.cpp

* S60(P) Disable auto display rotation

* On tall oled, scroll in 2 line increments

* Bugfix transition L<->R

@discip I take it back, there was a bug :)

* Draw every other one on transitions

* .

* cleanup

* Bootup logo: Draw in centre

* Update OLED.hpp

---------

Co-authored-by: discip <53649486+discip@users.noreply.github.com>
This commit is contained in:
Ben V. Brown
2024-07-12 08:27:05 +10:00
committed by GitHub
parent 18e936ae6d
commit 48649908a7
76 changed files with 2052 additions and 1588 deletions

View File

@@ -0,0 +1,12 @@
#include "ui_drawing.hpp"
#ifdef OLED_128x32
void ui_draw_cjc_sampling(const uint8_t num_dots) {
OLED::setCursor(0, 0);
OLED::print(translatedString(Tr->CJCCalibrating), FontStyle::SMALL);
OLED::setCursor(0, 8);
OLED::print(SmallSymbolDot, FontStyle::SMALL);
for (uint8_t x = 0; x < num_dots; x++) {
OLED::print(SmallSymbolDot, FontStyle::SMALL);
}
}
#endif

View File

@@ -0,0 +1,95 @@
#include "OperatingModes.h"
#include "TipThermoModel.h"
#include "main.hpp"
#include "ui_drawing.hpp"
#ifdef OLED_128x32
extern osThreadId GUITaskHandle;
extern osThreadId MOVTaskHandle;
extern osThreadId PIDTaskHandle;
void ui_draw_debug_menu(const uint8_t item_number) {
OLED::setCursor(0, 0); // Position the cursor at the 0,0 (top left)
OLED::print(SmallSymbolVersionNumber, FontStyle::SMALL); // Print version number
OLED::setCursor(0, 8); // second line
OLED::print(DebugMenu[item_number], FontStyle::SMALL);
switch (item_number) {
case 0: // Build Date
break;
case 1: // Device ID
{
uint64_t id = getDeviceID();
#ifdef DEVICE_HAS_VALIDATION_CODE
// If device has validation code; then we want to take over both lines of the screen
OLED::clearScreen(); // Ensure the buffer starts clean
OLED::setCursor(0, 0); // Position the cursor at the 0,0 (top left)
OLED::print(DebugMenu[item_number], FontStyle::SMALL);
OLED::drawHex(getDeviceValidation(), FontStyle::SMALL, 8);
OLED::setCursor(0, 8); // second line
#endif
OLED::drawHex((uint32_t)(id >> 32), FontStyle::SMALL, 8);
OLED::drawHex((uint32_t)(id & 0xFFFFFFFF), FontStyle::SMALL, 8);
} break;
case 2: // ACC Type
OLED::print(AccelTypeNames[(int)DetectedAccelerometerVersion], FontStyle::SMALL);
break;
case 3: // Power Negotiation Status
OLED::print(PowerSourceNames[getPowerSourceNumber()], FontStyle::SMALL);
break;
case 4: // Input Voltage
printVoltage();
break;
case 5: // Temp in °C
OLED::printNumber(TipThermoModel::getTipInC(), 6, FontStyle::SMALL);
break;
case 6: // Handle Temp in °C
OLED::printNumber(getHandleTemperature(0) / 10, 6, FontStyle::SMALL);
OLED::print(SmallSymbolDot, FontStyle::SMALL);
OLED::printNumber(getHandleTemperature(0) % 10, 1, FontStyle::SMALL);
break;
case 7: // Max Temp Limit in °C
OLED::printNumber(TipThermoModel::getTipMaxInC(), 6, FontStyle::SMALL);
break;
case 8: // System Uptime
OLED::printNumber(xTaskGetTickCount() / TICKS_100MS, 8, FontStyle::SMALL);
break;
case 9: // Movement Timestamp
OLED::printNumber(lastMovementTime / TICKS_100MS, 8, FontStyle::SMALL);
break;
case 10: // Tip Resistance in Ω
OLED::printNumber(getTipResistanceX10() / 10, 6, FontStyle::SMALL); // large to pad over so that we cover ID left overs
OLED::print(SmallSymbolDot, FontStyle::SMALL);
OLED::printNumber(getTipResistanceX10() % 10, 1, FontStyle::SMALL);
break;
case 11: // Raw Tip in µV
OLED::printNumber(TipThermoModel::convertTipRawADCTouV(getTipRawTemp(0), true), 8, FontStyle::SMALL);
break;
case 12: // Tip Cold Junction Compensation Offset in µV
OLED::printNumber(getSettingValue(SettingsOptions::CalibrationOffset), 8, FontStyle::SMALL);
break;
case 13: // High Water Mark for GUI
OLED::printNumber(uxTaskGetStackHighWaterMark(GUITaskHandle), 8, FontStyle::SMALL);
break;
case 14: // High Water Mark for Movement Task
OLED::printNumber(uxTaskGetStackHighWaterMark(MOVTaskHandle), 8, FontStyle::SMALL);
break;
case 15: // High Water Mark for PID Task
OLED::printNumber(uxTaskGetStackHighWaterMark(PIDTaskHandle), 8, FontStyle::SMALL);
break;
break;
#ifdef HALL_SENSOR
case 16: // Raw Hall Effect Value
{
int16_t hallEffectStrength = getRawHallEffect();
if (hallEffectStrength < 0) {
hallEffectStrength = -hallEffectStrength;
}
OLED::printNumber(hallEffectStrength, 6, FontStyle::SMALL);
} break;
#endif
default:
break;
}
}
#endif

View File

@@ -0,0 +1,57 @@
#include "ui_drawing.hpp"
#ifdef OLED_128x32
extern uint8_t buttonAF[sizeof(buttonA)];
extern uint8_t buttonBF[sizeof(buttonB)];
extern uint8_t disconnectedTipF[sizeof(disconnectedTip)];
void ui_draw_homescreen_detailed(TemperatureType_t tipTemp) {
if (isTipDisconnected()) {
if (OLED::getRotation()) {
// in right handed mode we want to draw over the first part
OLED::drawArea(54, 0, 56, 32, disconnectedTipF);
} else {
OLED::drawArea(0, 0, 56, 32, disconnectedTip);
}
if (OLED::getRotation()) {
OLED::setCursor(-1, 0);
} else {
OLED::setCursor(56, 0);
}
uint32_t Vlt = getInputVoltageX10(getSettingValue(SettingsOptions::VoltageDiv), 0);
OLED::printNumber(Vlt / 10, 2, FontStyle::LARGE);
OLED::print(LargeSymbolDot, FontStyle::LARGE);
OLED::printNumber(Vlt % 10, 1, FontStyle::LARGE);
if (OLED::getRotation()) {
OLED::setCursor(48, 8);
} else {
OLED::setCursor(91, 8);
}
OLED::print(SmallSymbolVolts, FontStyle::SMALL);
} else {
if (!(getSettingValue(SettingsOptions::CoolingTempBlink) && (tipTemp > 55) && (xTaskGetTickCount() % 1000 < 300))) {
// Blink temp if setting enable and temp < 55°
// 1000 tick/sec
// OFF 300ms ON 700ms
ui_draw_tip_temperature(true, FontStyle::LARGE); // draw in the temp
}
if (OLED::getRotation()) {
OLED::setCursor(6, 0);
} else {
OLED::setCursor(73, 0); // top right
}
// draw set temp
OLED::printNumber(getSettingValue(SettingsOptions::SolderingTemp), 3, FontStyle::SMALL);
OLED::printSymbolDeg(FontStyle::SMALL);
if (OLED::getRotation()) {
OLED::setCursor(0, 8);
} else {
OLED::setCursor(67, 8); // bottom right
}
printVoltage(); // draw voltage then symbol (v)
OLED::print(SmallSymbolVolts, FontStyle::SMALL);
}
}
#endif

View File

@@ -0,0 +1,62 @@
#include "ui_drawing.hpp"
#ifdef OLED_128x32
extern uint8_t buttonAF[sizeof(buttonA)];
extern uint8_t buttonBF[sizeof(buttonB)];
extern uint8_t disconnectedTipF[sizeof(disconnectedTip)];
void ui_draw_homescreen_simplified(TemperatureType_t tipTemp) {
bool tempOnDisplay = false;
bool tipDisconnectedDisplay = false;
if (OLED::getRotation()) {
OLED::drawArea(68, 0, 56, 32, buttonAF);
OLED::drawArea(12, 0, 56, 32, buttonBF);
OLED::setCursor(0, 0);
ui_draw_power_source_icon();
} else {
OLED::drawArea(0, 0, 56, 32, buttonA); // Needs to be flipped so button ends up
OLED::drawArea(58, 0, 56, 32, buttonB); // on right side of screen
OLED::setCursor(116, 0);
ui_draw_power_source_icon();
}
tipDisconnectedDisplay = false;
if (tipTemp > 55) {
tempOnDisplay = true;
} else if (tipTemp < 45) {
tempOnDisplay = false;
}
if (isTipDisconnected()) {
tempOnDisplay = false;
tipDisconnectedDisplay = true;
}
if (tempOnDisplay || tipDisconnectedDisplay) {
// draw temp over the start soldering button
// Location changes on screen rotation
if (OLED::getRotation()) {
// in right handed mode we want to draw over the first part
OLED::fillArea(68, 0, 56, 32, 0); // clear the area for the temp
OLED::setCursor(56, 0);
} else {
OLED::fillArea(0, 0, 56, 32, 0); // clear the area
OLED::setCursor(0, 0);
}
// If we have a tip connected draw the temp, if not we leave it blank
if (!tipDisconnectedDisplay) {
// draw in the temp
if (!(getSettingValue(SettingsOptions::CoolingTempBlink) && (xTaskGetTickCount() % 1000 < 300))) {
ui_draw_tip_temperature(false, FontStyle::LARGE); // draw in the temp
}
} else {
// Draw in missing tip symbol
if (OLED::getRotation()) {
// in right handed mode we want to draw over the first part
OLED::drawArea(54, 0, 56, 32, disconnectedTipF);
} else {
OLED::drawArea(0, 0, 56, 32, disconnectedTip);
}
}
}
}
#endif

View File

@@ -0,0 +1,43 @@
#include "ui_drawing.hpp"
#ifdef OLED_128x32
void ui_draw_power_source_icon(void) {
#if defined(POW_PD) || defined(POW_QC) || defined(POW_PD_EXT)
if (!getIsPoweredByDCIN()) {
// On non-DC inputs we replace this symbol with the voltage we are operating on
// If <9V then show single digit, if not show dual small ones vertically stacked
uint16_t V = getInputVoltageX10(getSettingValue(SettingsOptions::VoltageDiv), 0);
if (V % 10 >= 5) {
V = (V / 10) + 1; // round up
} else {
V = V / 10;
}
int16_t xPos = OLED::getCursorX();
OLED::printNumber(V / 10, 1, FontStyle::LARGE);
OLED::setCursor(xPos, 16);
OLED::printNumber(V % 10, 1, FontStyle::LARGE);
return;
}
#endif
#ifdef POW_DC
if (getSettingValue(SettingsOptions::MinDCVoltageCells)) {
// User is on a lithium battery
// we need to calculate which of the 10 levels they are on
uint8_t cellCount = getSettingValue(SettingsOptions::MinDCVoltageCells) + 2;
uint32_t cellV = getInputVoltageX10(getSettingValue(SettingsOptions::VoltageDiv), 0) / cellCount;
// Should give us approx cell voltage X10
// Range is 42 -> Minimum voltage setting (systemSettings.minVoltageCells) = 9 steps therefore we will use battery 0-9
if (cellV < getSettingValue(SettingsOptions::MinVoltageCells)) {
cellV = getSettingValue(SettingsOptions::MinVoltageCells);
}
cellV -= getSettingValue(SettingsOptions::MinVoltageCells); // Should leave us a number of 0-9
if (cellV > 9) {
cellV = 9;
}
OLED::drawBattery(cellV + 1);
} else {
OLED::drawSymbol(15); // Draw the DC Logo
}
#endif
}
#endif

View File

@@ -0,0 +1,59 @@
#include "ui_drawing.hpp"
#ifdef OLED_128x32
void ui_draw_soldering_profile_advanced(TemperatureType_t tipTemp, TemperatureType_t profileCurrentTargetTemp, uint32_t phaseElapsedSeconds, uint32_t phase, const uint32_t phaseTimeGoal) {
// print temperature
if (OLED::getRotation()) {
OLED::setCursor(48, 0);
} else {
OLED::setCursor(0, 0);
}
OLED::printNumber(tipTemp, 3, FontStyle::SMALL);
OLED::print(SmallSymbolSlash, FontStyle::SMALL);
OLED::printNumber(profileCurrentTargetTemp, 3, FontStyle::SMALL);
if (getSettingValue(SettingsOptions::TemperatureInF)) {
OLED::print(SmallSymbolDegF, FontStyle::SMALL);
} else {
OLED::print(SmallSymbolDegC, FontStyle::SMALL);
}
// print phase
if (phase > 0 && phase <= getSettingValue(SettingsOptions::ProfilePhases)) {
if (OLED::getRotation()) {
OLED::setCursor(36, 0);
} else {
OLED::setCursor(55, 0);
}
OLED::printNumber(phase, 1, FontStyle::SMALL);
}
// print time progress / preheat / cooldown
if (OLED::getRotation()) {
OLED::setCursor(42, 8);
} else {
OLED::setCursor(0, 8);
}
if (phase == 0) {
OLED::print(translatedString(Tr->ProfilePreheatString), FontStyle::SMALL);
} else if (phase > getSettingValue(SettingsOptions::ProfilePhases)) {
OLED::print(translatedString(Tr->ProfileCooldownString), FontStyle::SMALL);
} else {
OLED::printNumber(phaseElapsedSeconds / 60, 1, FontStyle::SMALL);
OLED::print(SmallSymbolColon, FontStyle::SMALL);
OLED::printNumber(phaseElapsedSeconds % 60, 2, FontStyle::SMALL, false);
OLED::print(SmallSymbolSlash, FontStyle::SMALL);
// blink if we can't keep up with the time goal
if (phaseElapsedSeconds < phaseTimeGoal + 2 || (xTaskGetTickCount() / TICKS_SECOND) % 2 == 0) {
OLED::printNumber(phaseTimeGoal / 60, 1, FontStyle::SMALL);
OLED::print(SmallSymbolColon, FontStyle::SMALL);
OLED::printNumber(phaseTimeGoal % 60, 2, FontStyle::SMALL, false);
}
}
}
#endif

View File

@@ -0,0 +1,45 @@
#include "power.hpp"
#include "ui_drawing.hpp"
#ifdef OLED_128x32
void ui_draw_soldering_basic_status(bool boostModeOn) {
OLED::setCursor(0, 0);
// We switch the layout direction depending on the orientation of the oled
if (OLED::getRotation()) {
// battery
ui_draw_power_source_icon();
// Space out gap between battery <-> temp
OLED::print(LargeSymbolSpace, FontStyle::LARGE);
// Draw current tip temp
ui_draw_tip_temperature(true, FontStyle::LARGE);
// We draw boost arrow if boosting,
// or else gap temp <-> heat indicator
if (boostModeOn) {
OLED::drawSymbol(2);
} else {
OLED::print(LargeSymbolSpace, FontStyle::LARGE);
}
// Draw heating/cooling symbols
OLED::drawHeatSymbol(X10WattsToPWM(x10WattHistory.average()));
} else {
// Draw heating/cooling symbols
OLED::drawHeatSymbol(X10WattsToPWM(x10WattHistory.average()));
// We draw boost arrow if boosting,
// or else gap temp <-> heat indicator
if (boostModeOn) {
OLED::drawSymbol(2);
} else {
OLED::print(LargeSymbolSpace, FontStyle::LARGE);
}
// Draw current tip temp
ui_draw_tip_temperature(true, FontStyle::LARGE);
// Space out gap between battery <-> temp
OLED::print(LargeSymbolSpace, FontStyle::LARGE);
ui_draw_power_source_icon();
}
}
#endif

View File

@@ -0,0 +1,69 @@
#include "power.hpp"
#include "ui_drawing.hpp"
#include <OperatingModes.h>
#ifdef OLED_128x32
void ui_draw_soldering_power_status(bool boost_mode_on) {
if (OLED::getRotation()) {
OLED::setCursor(50, 0);
} else {
OLED::setCursor(-1, 0);
}
ui_draw_tip_temperature(true, FontStyle::LARGE);
if (boost_mode_on) { // Boost mode is on
if (OLED::getRotation()) {
OLED::setCursor(34, 0);
} else {
OLED::setCursor(50, 0);
}
OLED::print(LargeSymbolPlus, FontStyle::LARGE);
} else {
#ifndef NO_SLEEP_MODE
if (getSettingValue(SettingsOptions::Sensitivity) && getSettingValue(SettingsOptions::SleepTime)) {
if (OLED::getRotation()) {
OLED::setCursor(32, 0);
} else {
OLED::setCursor(47, 0);
}
printCountdownUntilSleep(getSleepTimeout());
}
#endif
if (OLED::getRotation()) {
OLED::setCursor(32, 8);
} else {
OLED::setCursor(47, 8);
}
OLED::print(PowerSourceNames[getPowerSourceNumber()], FontStyle::SMALL, 2);
}
if (OLED::getRotation()) {
OLED::setCursor(0, 0);
} else {
OLED::setCursor(67, 0);
}
// Print wattage
{
uint32_t x10Watt = x10WattHistory.average();
if (x10Watt > 999) {
// If we exceed 99.9W we drop the decimal place to keep it all fitting
OLED::print(SmallSymbolSpace, FontStyle::SMALL);
OLED::printNumber(x10WattHistory.average() / 10, 3, FontStyle::SMALL);
} else {
OLED::printNumber(x10WattHistory.average() / 10, 2, FontStyle::SMALL);
OLED::print(SmallSymbolDot, FontStyle::SMALL);
OLED::printNumber(x10WattHistory.average() % 10, 1, FontStyle::SMALL);
}
OLED::print(SmallSymbolWatts, FontStyle::SMALL);
}
if (OLED::getRotation()) {
OLED::setCursor(0, 8);
} else {
OLED::setCursor(67, 8);
}
printVoltage();
OLED::print(SmallSymbolVolts, FontStyle::SMALL);
}
#endif

View File

@@ -0,0 +1,36 @@
#include "ui_drawing.hpp"
#ifdef OLED_128x32
void ui_draw_soldering_detailed_sleep(TemperatureType_t tipTemp) {
OLED::clearScreen();
OLED::setCursor(0, 0);
OLED::print(translatedString(Tr->SleepingAdvancedString), FontStyle::SMALL);
OLED::setCursor(0, 8);
OLED::print(translatedString(Tr->SleepingTipAdvancedString), FontStyle::SMALL);
OLED::printNumber(tipTemp, 3, FontStyle::SMALL);
if (getSettingValue(SettingsOptions::TemperatureInF)) {
OLED::print(SmallSymbolDegF, FontStyle::SMALL);
} else {
OLED::print(SmallSymbolDegC, FontStyle::SMALL);
}
OLED::print(SmallSymbolSpace, FontStyle::SMALL);
printVoltage();
OLED::print(SmallSymbolVolts, FontStyle::SMALL);
OLED::refresh();
}
void ui_draw_soldering_basic_sleep(TemperatureType_t tipTemp) {
OLED::clearScreen();
OLED::setCursor(0, 0);
OLED::print(LargeSymbolSleep, FontStyle::LARGE);
OLED::printNumber(tipTemp, 3, FontStyle::LARGE);
OLED::printSymbolDeg(FontStyle::EXTRAS);
OLED::refresh();
}
#endif

View File

@@ -0,0 +1,23 @@
#include "ui_drawing.hpp"
#ifdef OLED_128x32
void ui_draw_temperature_change(void) {
OLED::setCursor(0, 0);
if (OLED::getRotation()) {
OLED::print(getSettingValue(SettingsOptions::ReverseButtonTempChangeEnabled) ? LargeSymbolPlus : LargeSymbolMinus, FontStyle::LARGE);
} else {
OLED::print(getSettingValue(SettingsOptions::ReverseButtonTempChangeEnabled) ? LargeSymbolMinus : LargeSymbolPlus, FontStyle::LARGE);
}
OLED::print(LargeSymbolSpace, FontStyle::LARGE);
OLED::printNumber(getSettingValue(SettingsOptions::SolderingTemp), 3, FontStyle::LARGE);
OLED::printSymbolDeg(FontStyle::EXTRAS);
OLED::print(LargeSymbolSpace, FontStyle::LARGE);
if (OLED::getRotation()) {
OLED::print(getSettingValue(SettingsOptions::ReverseButtonTempChangeEnabled) ? LargeSymbolMinus : LargeSymbolPlus, FontStyle::LARGE);
} else {
OLED::print(getSettingValue(SettingsOptions::ReverseButtonTempChangeEnabled) ? LargeSymbolPlus : LargeSymbolMinus, FontStyle::LARGE);
}
}
#endif

View File

@@ -0,0 +1,17 @@
#include "OperatingModeUtilities.h"
#include "OperatingModes.h"
#include "SolderingCommon.h"
#include "TipThermoModel.h"
#ifdef OLED_128x32
void ui_draw_tip_temperature(bool symbol, const FontStyle font) {
// Draw tip temp handling unit conversion & tolerance near setpoint
TemperatureType_t Temp = getTipTemp();
OLED::printNumber(Temp, 3, font); // Draw the tip temp out
if (symbol) {
// For big font, can draw nice symbols, otherwise fall back to chars
OLED::printSymbolDeg(font == FontStyle::LARGE ? FontStyle::EXTRAS : font);
}
}
#endif

View File

@@ -0,0 +1,45 @@
#include "ui_drawing.hpp"
#ifdef OLED_128x32
void ui_draw_usb_pd_debug_state(const uint16_t vbus_sense_state, const uint8_t stateNumber) {
OLED::setCursor(0, 0); // Position the cursor at the 0,0 (top left)
OLED::print(SmallSymbolPDDebug, FontStyle::SMALL); // Print Title
OLED::setCursor(0, 8); // second line
// Print the PD state machine
OLED::print(SmallSymbolState, FontStyle::SMALL);
OLED::print(SmallSymbolSpace, FontStyle::SMALL);
OLED::printNumber(stateNumber, 2, FontStyle::SMALL, true);
OLED::print(SmallSymbolSpace, FontStyle::SMALL);
if (vbus_sense_state == 2) {
OLED::print(SmallSymbolNoVBus, FontStyle::SMALL);
} else if (vbus_sense_state == 1) {
OLED::print(SmallSymbolVBus, FontStyle::SMALL);
}
}
void ui_draw_usb_pd_debug_pdo(const uint8_t entry_num, const uint16_t min_voltage, const uint16_t max_voltage, const uint16_t current_a_x100, const uint16_t wattage) {
OLED::setCursor(0, 0); // Position the cursor at the 0,0 (top left)
OLED::print(SmallSymbolPDDebug, FontStyle::SMALL); // Print Title
OLED::setCursor(0, 8); // second line
OLED::printNumber(entry_num, 2, FontStyle::SMALL, true); // print the entry number
OLED::print(SmallSymbolSpace, FontStyle::SMALL);
if (min_voltage > 0) {
OLED::printNumber(min_voltage, 2, FontStyle::SMALL, true); // print the voltage
OLED::print(SmallSymbolMinus, FontStyle::SMALL);
}
OLED::printNumber(max_voltage, 2, FontStyle::SMALL, true); // print the voltage
OLED::print(SmallSymbolVolts, FontStyle::SMALL);
OLED::print(SmallSymbolSpace, FontStyle::SMALL);
if (wattage) {
OLED::printNumber(wattage, 3, FontStyle::SMALL, true); // print the current in 0.1A res
OLED::print(SmallSymbolWatts, FontStyle::SMALL);
} else {
OLED::printNumber(current_a_x100 / 100, 2, FontStyle::SMALL, true); // print the current in 0.1A res
OLED::print(SmallSymbolDot, FontStyle::SMALL);
OLED::printNumber(current_a_x100 % 100, 2, FontStyle::SMALL, false); // print the current in 0.1A res
OLED::print(SmallSymbolAmps, FontStyle::SMALL);
}
}
#endif

View File

@@ -0,0 +1,21 @@
#include "ui_drawing.hpp"
#ifdef OLED_128x32
void ui_draw_warning_undervoltage(void) {
OLED::clearScreen();
OLED::setCursor(0, 0);
if (getSettingValue(SettingsOptions::DetailedSoldering)) {
OLED::print(translatedString(Tr->UndervoltageString), FontStyle::SMALL);
OLED::setCursor(0, 8);
OLED::print(translatedString(Tr->InputVoltageString), FontStyle::SMALL);
printVoltage();
OLED::print(SmallSymbolVolts, FontStyle::SMALL);
} else {
OLED::print(translatedString(Tr->UVLOWarningString), FontStyle::LARGE);
}
OLED::refresh();
GUIDelay();
waitForButtonPress();
}
#endif

View File

@@ -0,0 +1,19 @@
#include "ui_drawing.hpp"
#ifdef OLED_128x32
uint8_t buttonAF[sizeof(buttonA)];
uint8_t buttonBF[sizeof(buttonB)];
uint8_t disconnectedTipF[sizeof(disconnectedTip)];
void ui_pre_render_assets(void) {
// Generate the flipped screen into ram for later use
// flipped is generated by flipping each row
for (int row = 0; row < 4; row++) {
for (int x = 0; x < 56; x++) {
buttonAF[(row * 56) + x] = buttonA[(row * 56) + (41 - x)];
buttonBF[(row * 56) + x] = buttonB[(row * 56) + (41 - x)];
disconnectedTipF[(row * 56) + x] = disconnectedTip[(row * 56) + (41 - x)];
}
}
}
#endif

View File

@@ -0,0 +1,22 @@
#include "Buttons.hpp"
#include "OperatingModeUtilities.h"
#ifdef OLED_128x32
extern TickType_t lastMovementTime;
#ifndef NO_SLEEP_MODE
void printCountdownUntilSleep(int sleepThres) {
/*
* Print seconds or minutes (if > 99 seconds) until sleep
* mode is triggered.
*/
TickType_t lastEventTime = lastButtonTime < lastMovementTime ? lastMovementTime : lastButtonTime;
TickType_t downCount = sleepThres - xTaskGetTickCount() + lastEventTime;
if (downCount > (99 * TICKS_SECOND)) {
OLED::printNumber(downCount / 60000 + 1, 2, FontStyle::SMALL);
OLED::print(SmallSymbolMinutes, FontStyle::SMALL);
} else {
OLED::printNumber(downCount / 1000 + 1, 2, FontStyle::SMALL);
OLED::print(SmallSymbolSeconds, FontStyle::SMALL);
}
}
#endif
#endif

View File

@@ -0,0 +1,10 @@
#include "ui_drawing.hpp"
#ifdef OLED_128x32
void printVoltage(void) {
uint32_t volt = getInputVoltageX10(getSettingValue(SettingsOptions::VoltageDiv), 0);
OLED::printNumber(volt / 10, 2, FontStyle::SMALL);
OLED::print(SmallSymbolDot, FontStyle::SMALL);
OLED::printNumber(volt % 10, 1, FontStyle::SMALL);
}
#endif

View File

@@ -0,0 +1,14 @@
#include "Buttons.hpp"
#include "OperatingModeUtilities.h"
#include "OperatingModes.h"
#ifdef OLED_128x32
bool warnUser(const char *warning, const ButtonState buttons) {
OLED::clearScreen();
OLED::printWholeScreen(warning);
// Also timeout after 5 seconds
if ((xTaskGetTickCount() - lastButtonTime) > TICKS_SECOND * 5) {
return true;
}
return buttons != BUTTON_NONE;
}
#endif

View File

@@ -0,0 +1,13 @@
#include "ui_drawing.hpp"
#ifdef OLED_96x16
void ui_draw_cjc_sampling(const uint8_t num_dots) {
OLED::setCursor(0, 0);
OLED::print(translatedString(Tr->CJCCalibrating), FontStyle::SMALL);
OLED::setCursor(0, 8);
OLED::print(SmallSymbolDot, FontStyle::SMALL);
for (uint8_t x = 0; x < num_dots; x++) {
OLED::print(SmallSymbolDot, FontStyle::SMALL);
}
}
#endif

View File

@@ -0,0 +1,94 @@
#include "OperatingModes.h"
#include "TipThermoModel.h"
#include "main.hpp"
#include "ui_drawing.hpp"
#ifdef OLED_96x16
extern osThreadId GUITaskHandle;
extern osThreadId MOVTaskHandle;
extern osThreadId PIDTaskHandle;
void ui_draw_debug_menu(const uint8_t item_number) {
OLED::setCursor(0, 0); // Position the cursor at the 0,0 (top left)
OLED::print(SmallSymbolVersionNumber, FontStyle::SMALL); // Print version number
OLED::setCursor(0, 8); // second line
OLED::print(DebugMenu[item_number], FontStyle::SMALL);
switch (item_number) {
case 0: // Build Date
break;
case 1: // Device ID
{
uint64_t id = getDeviceID();
#ifdef DEVICE_HAS_VALIDATION_CODE
// If device has validation code; then we want to take over both lines of the screen
OLED::clearScreen(); // Ensure the buffer starts clean
OLED::setCursor(0, 0); // Position the cursor at the 0,0 (top left)
OLED::print(DebugMenu[item_number], FontStyle::SMALL);
OLED::drawHex(getDeviceValidation(), FontStyle::SMALL, 8);
OLED::setCursor(0, 8); // second line
#endif
OLED::drawHex((uint32_t)(id >> 32), FontStyle::SMALL, 8);
OLED::drawHex((uint32_t)(id & 0xFFFFFFFF), FontStyle::SMALL, 8);
} break;
case 2: // ACC Type
OLED::print(AccelTypeNames[(int)DetectedAccelerometerVersion], FontStyle::SMALL);
break;
case 3: // Power Negotiation Status
OLED::print(PowerSourceNames[getPowerSourceNumber()], FontStyle::SMALL);
break;
case 4: // Input Voltage
printVoltage();
break;
case 5: // Temp in °C
OLED::printNumber(TipThermoModel::getTipInC(), 6, FontStyle::SMALL);
break;
case 6: // Handle Temp in °C
OLED::printNumber(getHandleTemperature(0) / 10, 6, FontStyle::SMALL);
OLED::print(SmallSymbolDot, FontStyle::SMALL);
OLED::printNumber(getHandleTemperature(0) % 10, 1, FontStyle::SMALL);
break;
case 7: // Max Temp Limit in °C
OLED::printNumber(TipThermoModel::getTipMaxInC(), 6, FontStyle::SMALL);
break;
case 8: // System Uptime
OLED::printNumber(xTaskGetTickCount() / TICKS_100MS, 8, FontStyle::SMALL);
break;
case 9: // Movement Timestamp
OLED::printNumber(lastMovementTime / TICKS_100MS, 8, FontStyle::SMALL);
break;
case 10: // Tip Resistance in Ω
OLED::printNumber(getTipResistanceX10() / 10, 6, FontStyle::SMALL); // large to pad over so that we cover ID left overs
OLED::print(SmallSymbolDot, FontStyle::SMALL);
OLED::printNumber(getTipResistanceX10() % 10, 1, FontStyle::SMALL);
break;
case 11: // Raw Tip in µV
OLED::printNumber(TipThermoModel::convertTipRawADCTouV(getTipRawTemp(0), true), 8, FontStyle::SMALL);
break;
case 12: // Tip Cold Junction Compensation Offset in µV
OLED::printNumber(getSettingValue(SettingsOptions::CalibrationOffset), 8, FontStyle::SMALL);
break;
case 13: // High Water Mark for GUI
OLED::printNumber(uxTaskGetStackHighWaterMark(GUITaskHandle), 8, FontStyle::SMALL);
break;
case 14: // High Water Mark for Movement Task
OLED::printNumber(uxTaskGetStackHighWaterMark(MOVTaskHandle), 8, FontStyle::SMALL);
break;
case 15: // High Water Mark for PID Task
OLED::printNumber(uxTaskGetStackHighWaterMark(PIDTaskHandle), 8, FontStyle::SMALL);
break;
break;
#ifdef HALL_SENSOR
case 16: // Raw Hall Effect Value
{
int16_t hallEffectStrength = getRawHallEffect();
if (hallEffectStrength < 0) {
hallEffectStrength = -hallEffectStrength;
}
OLED::printNumber(hallEffectStrength, 6, FontStyle::SMALL);
} break;
#endif
default:
break;
}
}
#endif

View File

@@ -0,0 +1,57 @@
#include "ui_drawing.hpp"
#ifdef OLED_96x16
extern uint8_t buttonAF[sizeof(buttonA)];
extern uint8_t buttonBF[sizeof(buttonB)];
extern uint8_t disconnectedTipF[sizeof(disconnectedTip)];
void ui_draw_homescreen_detailed(TemperatureType_t tipTemp) {
if (isTipDisconnected()) {
if (OLED::getRotation()) {
// in right handed mode we want to draw over the first part
OLED::drawArea(54, 0, 42, 16, disconnectedTipF);
} else {
OLED::drawArea(0, 0, 42, 16, disconnectedTip);
}
if (OLED::getRotation()) {
OLED::setCursor(-1, 0);
} else {
OLED::setCursor(42, 0);
}
uint32_t Vlt = getInputVoltageX10(getSettingValue(SettingsOptions::VoltageDiv), 0);
OLED::printNumber(Vlt / 10, 2, FontStyle::LARGE);
OLED::print(LargeSymbolDot, FontStyle::LARGE);
OLED::printNumber(Vlt % 10, 1, FontStyle::LARGE);
if (OLED::getRotation()) {
OLED::setCursor(48, 8);
} else {
OLED::setCursor(91, 8);
}
OLED::print(SmallSymbolVolts, FontStyle::SMALL);
} else {
if (!(getSettingValue(SettingsOptions::CoolingTempBlink) && (tipTemp > 55) && (xTaskGetTickCount() % 1000 < 300))) {
// Blink temp if setting enable and temp < 55°
// 1000 tick/sec
// OFF 300ms ON 700ms
ui_draw_tip_temperature(true, FontStyle::LARGE); // draw in the temp
}
if (OLED::getRotation()) {
OLED::setCursor(6, 0);
} else {
OLED::setCursor(73, 0); // top right
}
// draw set temp
OLED::printNumber(getSettingValue(SettingsOptions::SolderingTemp), 3, FontStyle::SMALL);
OLED::printSymbolDeg(FontStyle::SMALL);
if (OLED::getRotation()) {
OLED::setCursor(0, 8);
} else {
OLED::setCursor(67, 8); // bottom right
}
printVoltage(); // draw voltage then symbol (v)
OLED::print(SmallSymbolVolts, FontStyle::SMALL);
}
}
#endif

View File

@@ -0,0 +1,62 @@
#include "ui_drawing.hpp"
#ifdef OLED_96x16
extern uint8_t buttonAF[sizeof(buttonA)];
extern uint8_t buttonBF[sizeof(buttonB)];
extern uint8_t disconnectedTipF[sizeof(disconnectedTip)];
void ui_draw_homescreen_simplified(TemperatureType_t tipTemp) {
bool tempOnDisplay = false;
bool tipDisconnectedDisplay = false;
if (OLED::getRotation()) {
OLED::drawArea(54, 0, 42, 16, buttonAF);
OLED::drawArea(12, 0, 42, 16, buttonBF);
OLED::setCursor(0, 0);
ui_draw_power_source_icon();
} else {
OLED::drawArea(0, 0, 42, 16, buttonA); // Needs to be flipped so button ends up
OLED::drawArea(42, 0, 42, 16, buttonB); // on right side of screen
OLED::setCursor(84, 0);
ui_draw_power_source_icon();
}
tipDisconnectedDisplay = false;
if (tipTemp > 55) {
tempOnDisplay = true;
} else if (tipTemp < 45) {
tempOnDisplay = false;
}
if (isTipDisconnected()) {
tempOnDisplay = false;
tipDisconnectedDisplay = true;
}
if (tempOnDisplay || tipDisconnectedDisplay) {
// draw temp over the start soldering button
// Location changes on screen rotation
if (OLED::getRotation()) {
// in right handed mode we want to draw over the first part
OLED::fillArea(55, 0, 41, 16, 0); // clear the area for the temp
OLED::setCursor(56, 0);
} else {
OLED::fillArea(0, 0, 41, 16, 0); // clear the area
OLED::setCursor(0, 0);
}
// If we have a tip connected draw the temp, if not we leave it blank
if (!tipDisconnectedDisplay) {
// draw in the temp
if (!(getSettingValue(SettingsOptions::CoolingTempBlink) && (xTaskGetTickCount() % 1000 < 300))) {
ui_draw_tip_temperature(false, FontStyle::LARGE); // draw in the temp
}
} else {
// Draw in missing tip symbol
if (OLED::getRotation()) {
// in right handed mode we want to draw over the first part
OLED::drawArea(54, 0, 42, 16, disconnectedTipF);
} else {
OLED::drawArea(0, 0, 42, 16, disconnectedTip);
}
}
}
}
#endif

View File

@@ -0,0 +1,49 @@
#include "ui_drawing.hpp"
#ifdef OLED_96x16
void ui_draw_power_source_icon(void) {
#if defined(POW_PD) || defined(POW_QC) || defined(POW_PD_EXT)
if (!getIsPoweredByDCIN()) {
// On non-DC inputs we replace this symbol with the voltage we are operating on
// If <9V then show single digit, if not show dual small ones vertically stacked
uint16_t V = getInputVoltageX10(getSettingValue(SettingsOptions::VoltageDiv), 0);
if (V % 10 >= 5) {
V = (V / 10) + 1; // round up
} else {
V = V / 10;
}
if (V > 9) {
int16_t xPos = OLED::getCursorX();
OLED::printNumber(V / 10, 1, FontStyle::SMALL);
OLED::setCursor(xPos, 8);
OLED::printNumber(V % 10, 1, FontStyle::SMALL);
OLED::setCursor(xPos + 12, 0); // need to reset this as if we drew a wide char
} else {
OLED::printNumber(V, 1, FontStyle::LARGE);
}
return;
}
#endif
#ifdef POW_DC
if (getSettingValue(SettingsOptions::MinDCVoltageCells)) {
// User is on a lithium battery
// we need to calculate which of the 10 levels they are on
uint8_t cellCount = getSettingValue(SettingsOptions::MinDCVoltageCells) + 2;
uint32_t cellV = getInputVoltageX10(getSettingValue(SettingsOptions::VoltageDiv), 0) / cellCount;
// Should give us approx cell voltage X10
// Range is 42 -> Minimum voltage setting (systemSettings.minVoltageCells) = 9 steps therefore we will use battery 0-9
if (cellV < getSettingValue(SettingsOptions::MinVoltageCells)) {
cellV = getSettingValue(SettingsOptions::MinVoltageCells);
}
cellV -= getSettingValue(SettingsOptions::MinVoltageCells); // Should leave us a number of 0-9
if (cellV > 9) {
cellV = 9;
}
OLED::drawBattery(cellV + 1);
} else {
OLED::drawSymbol(15); // Draw the DC Logo
}
#endif
}
#endif

View File

@@ -0,0 +1,59 @@
#include "ui_drawing.hpp"
#ifdef OLED_96x16
void ui_draw_soldering_profile_advanced(TemperatureType_t tipTemp, TemperatureType_t profileCurrentTargetTemp, uint32_t phaseElapsedSeconds, uint32_t phase, const uint32_t phaseTimeGoal) {
// print temperature
if (OLED::getRotation()) {
OLED::setCursor(48, 0);
} else {
OLED::setCursor(0, 0);
}
OLED::printNumber(tipTemp, 3, FontStyle::SMALL);
OLED::print(SmallSymbolSlash, FontStyle::SMALL);
OLED::printNumber(profileCurrentTargetTemp, 3, FontStyle::SMALL);
if (getSettingValue(SettingsOptions::TemperatureInF)) {
OLED::print(SmallSymbolDegF, FontStyle::SMALL);
} else {
OLED::print(SmallSymbolDegC, FontStyle::SMALL);
}
// print phase
if (phase > 0 && phase <= getSettingValue(SettingsOptions::ProfilePhases)) {
if (OLED::getRotation()) {
OLED::setCursor(36, 0);
} else {
OLED::setCursor(55, 0);
}
OLED::printNumber(phase, 1, FontStyle::SMALL);
}
// print time progress / preheat / cooldown
if (OLED::getRotation()) {
OLED::setCursor(42, 8);
} else {
OLED::setCursor(0, 8);
}
if (phase == 0) {
OLED::print(translatedString(Tr->ProfilePreheatString), FontStyle::SMALL);
} else if (phase > getSettingValue(SettingsOptions::ProfilePhases)) {
OLED::print(translatedString(Tr->ProfileCooldownString), FontStyle::SMALL);
} else {
OLED::printNumber(phaseElapsedSeconds / 60, 1, FontStyle::SMALL);
OLED::print(SmallSymbolColon, FontStyle::SMALL);
OLED::printNumber(phaseElapsedSeconds % 60, 2, FontStyle::SMALL, false);
OLED::print(SmallSymbolSlash, FontStyle::SMALL);
// blink if we can't keep up with the time goal
if (phaseElapsedSeconds < phaseTimeGoal + 2 || (xTaskGetTickCount() / TICKS_SECOND) % 2 == 0) {
OLED::printNumber(phaseTimeGoal / 60, 1, FontStyle::SMALL);
OLED::print(SmallSymbolColon, FontStyle::SMALL);
OLED::printNumber(phaseTimeGoal % 60, 2, FontStyle::SMALL, false);
}
}
}
#endif

View File

@@ -0,0 +1,44 @@
#include "power.hpp"
#include "ui_drawing.hpp"
#ifdef OLED_96x16
void ui_draw_soldering_basic_status(bool boostModeOn) {
OLED::setCursor(0, 0);
// We switch the layout direction depending on the orientation of the oled
if (OLED::getRotation()) {
// battery
ui_draw_power_source_icon();
// Space out gap between battery <-> temp
OLED::print(LargeSymbolSpace, FontStyle::LARGE);
// Draw current tip temp
ui_draw_tip_temperature(true, FontStyle::LARGE);
// We draw boost arrow if boosting,
// or else gap temp <-> heat indicator
if (boostModeOn) {
OLED::drawSymbol(2);
} else {
OLED::print(LargeSymbolSpace, FontStyle::LARGE);
}
// Draw heating/cooling symbols
OLED::drawHeatSymbol(X10WattsToPWM(x10WattHistory.average()));
} else {
// Draw heating/cooling symbols
OLED::drawHeatSymbol(X10WattsToPWM(x10WattHistory.average()));
// We draw boost arrow if boosting,
// or else gap temp <-> heat indicator
if (boostModeOn) {
OLED::drawSymbol(2);
} else {
OLED::print(LargeSymbolSpace, FontStyle::LARGE);
}
// Draw current tip temp
ui_draw_tip_temperature(true, FontStyle::LARGE);
// Space out gap between battery <-> temp
OLED::print(LargeSymbolSpace, FontStyle::LARGE);
ui_draw_power_source_icon();
}
}
#endif

View File

@@ -0,0 +1,69 @@
#include "power.hpp"
#include "ui_drawing.hpp"
#include <OperatingModes.h>
#ifdef OLED_96x16
void ui_draw_soldering_power_status(bool boost_mode_on) {
if (OLED::getRotation()) {
OLED::setCursor(50, 0);
} else {
OLED::setCursor(-1, 0);
}
ui_draw_tip_temperature(true, FontStyle::LARGE);
if (boost_mode_on) { // Boost mode is on
if (OLED::getRotation()) {
OLED::setCursor(34, 0);
} else {
OLED::setCursor(50, 0);
}
OLED::print(LargeSymbolPlus, FontStyle::LARGE);
} else {
#ifndef NO_SLEEP_MODE
if (getSettingValue(SettingsOptions::Sensitivity) && getSettingValue(SettingsOptions::SleepTime)) {
if (OLED::getRotation()) {
OLED::setCursor(32, 0);
} else {
OLED::setCursor(47, 0);
}
printCountdownUntilSleep(getSleepTimeout());
}
#endif
if (OLED::getRotation()) {
OLED::setCursor(32, 8);
} else {
OLED::setCursor(47, 8);
}
OLED::print(PowerSourceNames[getPowerSourceNumber()], FontStyle::SMALL, 2);
}
if (OLED::getRotation()) {
OLED::setCursor(0, 0);
} else {
OLED::setCursor(67, 0);
}
// Print wattage
{
uint32_t x10Watt = x10WattHistory.average();
if (x10Watt > 999) {
// If we exceed 99.9W we drop the decimal place to keep it all fitting
OLED::print(SmallSymbolSpace, FontStyle::SMALL);
OLED::printNumber(x10WattHistory.average() / 10, 3, FontStyle::SMALL);
} else {
OLED::printNumber(x10WattHistory.average() / 10, 2, FontStyle::SMALL);
OLED::print(SmallSymbolDot, FontStyle::SMALL);
OLED::printNumber(x10WattHistory.average() % 10, 1, FontStyle::SMALL);
}
OLED::print(SmallSymbolWatts, FontStyle::SMALL);
}
if (OLED::getRotation()) {
OLED::setCursor(0, 8);
} else {
OLED::setCursor(67, 8);
}
printVoltage();
OLED::print(SmallSymbolVolts, FontStyle::SMALL);
}
#endif

View File

@@ -0,0 +1,36 @@
#include "ui_drawing.hpp"
#ifdef OLED_96x16
void ui_draw_soldering_detailed_sleep(TemperatureType_t tipTemp) {
OLED::clearScreen();
OLED::setCursor(0, 0);
OLED::print(translatedString(Tr->SleepingAdvancedString), FontStyle::SMALL);
OLED::setCursor(0, 8);
OLED::print(translatedString(Tr->SleepingTipAdvancedString), FontStyle::SMALL);
OLED::printNumber(tipTemp, 3, FontStyle::SMALL);
if (getSettingValue(SettingsOptions::TemperatureInF)) {
OLED::print(SmallSymbolDegF, FontStyle::SMALL);
} else {
OLED::print(SmallSymbolDegC, FontStyle::SMALL);
}
OLED::print(SmallSymbolSpace, FontStyle::SMALL);
printVoltage();
OLED::print(SmallSymbolVolts, FontStyle::SMALL);
OLED::refresh();
}
void ui_draw_soldering_basic_sleep(TemperatureType_t tipTemp) {
OLED::clearScreen();
OLED::setCursor(0, 0);
OLED::print(LargeSymbolSleep, FontStyle::LARGE);
OLED::printNumber(tipTemp, 3, FontStyle::LARGE);
OLED::printSymbolDeg(FontStyle::EXTRAS);
OLED::refresh();
}
#endif

View File

@@ -0,0 +1,23 @@
#include "ui_drawing.hpp"
#ifdef OLED_96x16
void ui_draw_temperature_change(void) {
OLED::setCursor(0, 0);
if (OLED::getRotation()) {
OLED::print(getSettingValue(SettingsOptions::ReverseButtonTempChangeEnabled) ? LargeSymbolPlus : LargeSymbolMinus, FontStyle::LARGE);
} else {
OLED::print(getSettingValue(SettingsOptions::ReverseButtonTempChangeEnabled) ? LargeSymbolMinus : LargeSymbolPlus, FontStyle::LARGE);
}
OLED::print(LargeSymbolSpace, FontStyle::LARGE);
OLED::printNumber(getSettingValue(SettingsOptions::SolderingTemp), 3, FontStyle::LARGE);
OLED::printSymbolDeg(FontStyle::EXTRAS);
OLED::print(LargeSymbolSpace, FontStyle::LARGE);
if (OLED::getRotation()) {
OLED::print(getSettingValue(SettingsOptions::ReverseButtonTempChangeEnabled) ? LargeSymbolMinus : LargeSymbolPlus, FontStyle::LARGE);
} else {
OLED::print(getSettingValue(SettingsOptions::ReverseButtonTempChangeEnabled) ? LargeSymbolPlus : LargeSymbolMinus, FontStyle::LARGE);
}
}
#endif

View File

@@ -0,0 +1,17 @@
#include "OperatingModeUtilities.h"
#include "OperatingModes.h"
#include "SolderingCommon.h"
#include "TipThermoModel.h"
#ifdef OLED_96x16
void ui_draw_tip_temperature(bool symbol, const FontStyle font) {
// Draw tip temp handling unit conversion & tolerance near setpoint
TemperatureType_t Temp = getTipTemp();
OLED::printNumber(Temp, 3, font); // Draw the tip temp out
if (symbol) {
// For big font, can draw nice symbols, otherwise fall back to chars
OLED::printSymbolDeg(font == FontStyle::LARGE ? FontStyle::EXTRAS : font);
}
}
#endif

View File

@@ -0,0 +1,45 @@
#include "ui_drawing.hpp"
#ifdef OLED_96x16
void ui_draw_usb_pd_debug_state(const uint16_t vbus_sense_state, const uint8_t stateNumber) {
OLED::setCursor(0, 0); // Position the cursor at the 0,0 (top left)
OLED::print(SmallSymbolPDDebug, FontStyle::SMALL); // Print Title
OLED::setCursor(0, 8); // second line
// Print the PD state machine
OLED::print(SmallSymbolState, FontStyle::SMALL);
OLED::print(SmallSymbolSpace, FontStyle::SMALL);
OLED::printNumber(stateNumber, 2, FontStyle::SMALL, true);
OLED::print(SmallSymbolSpace, FontStyle::SMALL);
if (vbus_sense_state == 2) {
OLED::print(SmallSymbolNoVBus, FontStyle::SMALL);
} else if (vbus_sense_state == 1) {
OLED::print(SmallSymbolVBus, FontStyle::SMALL);
}
}
void ui_draw_usb_pd_debug_pdo(const uint8_t entry_num, const uint16_t min_voltage, const uint16_t max_voltage, const uint16_t current_a_x100, const uint16_t wattage) {
OLED::setCursor(0, 0); // Position the cursor at the 0,0 (top left)
OLED::print(SmallSymbolPDDebug, FontStyle::SMALL); // Print Title
OLED::setCursor(0, 8); // second line
OLED::printNumber(entry_num, 2, FontStyle::SMALL, true); // print the entry number
OLED::print(SmallSymbolSpace, FontStyle::SMALL);
if (min_voltage > 0) {
OLED::printNumber(min_voltage, 2, FontStyle::SMALL, true); // print the voltage
OLED::print(SmallSymbolMinus, FontStyle::SMALL);
}
OLED::printNumber(max_voltage, 2, FontStyle::SMALL, true); // print the voltage
OLED::print(SmallSymbolVolts, FontStyle::SMALL);
OLED::print(SmallSymbolSpace, FontStyle::SMALL);
if (wattage) {
OLED::printNumber(wattage, 3, FontStyle::SMALL, true); // print the current in 0.1A res
OLED::print(SmallSymbolWatts, FontStyle::SMALL);
} else {
OLED::printNumber(current_a_x100 / 100, 2, FontStyle::SMALL, true); // print the current in 0.1A res
OLED::print(SmallSymbolDot, FontStyle::SMALL);
OLED::printNumber(current_a_x100 % 100, 2, FontStyle::SMALL, false); // print the current in 0.1A res
OLED::print(SmallSymbolAmps, FontStyle::SMALL);
}
}
#endif

View File

@@ -0,0 +1,21 @@
#include "ui_drawing.hpp"
#ifdef OLED_96x16
void ui_draw_warning_undervoltage(void) {
OLED::clearScreen();
OLED::setCursor(0, 0);
if (getSettingValue(SettingsOptions::DetailedSoldering)) {
OLED::print(translatedString(Tr->UndervoltageString), FontStyle::SMALL);
OLED::setCursor(0, 8);
OLED::print(translatedString(Tr->InputVoltageString), FontStyle::SMALL);
printVoltage();
OLED::print(SmallSymbolVolts, FontStyle::SMALL);
} else {
OLED::print(translatedString(Tr->UVLOWarningString), FontStyle::LARGE);
}
OLED::refresh();
GUIDelay();
waitForButtonPress();
}
#endif

View File

@@ -0,0 +1,19 @@
#include "ui_drawing.hpp"
#ifdef OLED_96x16
uint8_t buttonAF[sizeof(buttonA)];
uint8_t buttonBF[sizeof(buttonB)];
uint8_t disconnectedTipF[sizeof(disconnectedTip)];
void ui_pre_render_assets(void) {
// Generate the flipped screen into ram for later use
// flipped is generated by flipping each row
for (int row = 0; row < 2; row++) {
for (int x = 0; x < 42; x++) {
buttonAF[(row * 42) + x] = buttonA[(row * 42) + (41 - x)];
buttonBF[(row * 42) + x] = buttonB[(row * 42) + (41 - x)];
disconnectedTipF[(row * 42) + x] = disconnectedTip[(row * 42) + (41 - x)];
}
}
}
#endif

View File

@@ -0,0 +1,22 @@
#include "Buttons.hpp"
#include "OperatingModeUtilities.h"
#ifdef OLED_96x16
extern TickType_t lastMovementTime;
#ifndef NO_SLEEP_MODE
void printCountdownUntilSleep(int sleepThres) {
/*
* Print seconds or minutes (if > 99 seconds) until sleep
* mode is triggered.
*/
TickType_t lastEventTime = lastButtonTime < lastMovementTime ? lastMovementTime : lastButtonTime;
TickType_t downCount = sleepThres - xTaskGetTickCount() + lastEventTime;
if (downCount > (99 * TICKS_SECOND)) {
OLED::printNumber(downCount / 60000 + 1, 2, FontStyle::SMALL);
OLED::print(SmallSymbolMinutes, FontStyle::SMALL);
} else {
OLED::printNumber(downCount / 1000 + 1, 2, FontStyle::SMALL);
OLED::print(SmallSymbolSeconds, FontStyle::SMALL);
}
}
#endif
#endif

View File

@@ -0,0 +1,10 @@
#include "ui_drawing.hpp"
#ifdef OLED_96x16
void printVoltage(void) {
uint32_t volt = getInputVoltageX10(getSettingValue(SettingsOptions::VoltageDiv), 0);
OLED::printNumber(volt / 10, 2, FontStyle::SMALL);
OLED::print(SmallSymbolDot, FontStyle::SMALL);
OLED::printNumber(volt % 10, 1, FontStyle::SMALL);
}
#endif

View File

@@ -0,0 +1,14 @@
#include "Buttons.hpp"
#include "OperatingModeUtilities.h"
#include "OperatingModes.h"
#ifdef OLED_96x16
bool warnUser(const char *warning, const ButtonState buttons) {
OLED::clearScreen();
OLED::printWholeScreen(warning);
// Also timeout after 5 seconds
if ((xTaskGetTickCount() - lastButtonTime) > TICKS_SECOND * 5) {
return true;
}
return buttons != BUTTON_NONE;
}
#endif

View File

@@ -0,0 +1,33 @@
#ifndef UI_DRAWING_UI_DRAWING_HPP_
#define UI_DRAWING_UI_DRAWING_HPP_
#include "Buttons.hpp"
#include "OLED.hpp"
#include "OperatingModeUtilities.h"
#include "configuration.h"
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
void ui_draw_warning_undervoltage(void);
void ui_draw_power_source_icon(void); // Draw a single character wide power source icon
void ui_draw_tip_temperature(bool symbol, const FontStyle font); // Draw tip temp, aware of conversions
bool warnUser(const char *warning, const ButtonState buttons); // Print a full screen warning to the user
void ui_draw_cjc_sampling(const uint8_t num_dots); // Draws the CJC info text and progress dots
void ui_draw_debug_menu(const uint8_t item_number); // Draws the debug menu state
void ui_draw_homescreen_detailed(TemperatureType_t tipTemp); // Drawing the home screen -- Detailed mode
void ui_draw_homescreen_simplified(TemperatureType_t tipTemp); // Drawing the home screen -- Simple mode
void ui_pre_render_assets(void); // If any assets need to be pre-rendered into ram
// Soldering mode
void ui_draw_soldering_power_status(bool boost_mode_on);
void ui_draw_soldering_basic_status(bool boostModeOn);
void ui_draw_soldering_detailed_sleep(TemperatureType_t tipTemp);
void ui_draw_soldering_basic_sleep(TemperatureType_t tipTemp);
void ui_draw_soldering_profile_advanced(TemperatureType_t tipTemp, TemperatureType_t profileCurrentTargetTemp, uint32_t phaseElapsedSeconds, uint32_t phase,const uint32_t phaseTimeGoal);
//Temp change
void ui_draw_temperature_change(void);
//USB-PD debug
void ui_draw_usb_pd_debug_state(const uint16_t vbus_sense_state, const uint8_t stateNumber) ;
void ui_draw_usb_pd_debug_pdo(const uint8_t entry_num, const uint16_t min_voltage, const uint16_t max_voltage, const uint16_t current_a_x100, const uint16_t wattage) ;
// Utils
void printVoltage(void);
#endif // UI_DRAWING_UI_DRAWING_HPP_