S60 Support (#1692)
* Mock S60 * cleanup * Start refactor of OLED init * Setup timers roughly * Set Vector table offset correctly Update system_stm32f1xx.c * Update OLED.cpp * Update stm32f1xx_hal_msp.c * Update configuration.h * I2C init before GPIO From Errata Update stm32f1xx_hal_msp.c Update Software_I2C.h Allow no hardware I2C * I2C BB run bus unlock at init * cleanups * Software I2C for now * Mildly more graceful Interpolate * Handle is powered by DC Update Power.cpp Update drawPowerSourceIcon.cpp Update configuration.h Update Setup.cpp * Cleanup HomeScreen * Segment remap oled at init * Cleanup * Update MOVThread.cpp * Fix PWM Init * Fix adc2 trigger * Update configs * Fixup warning * Saner default config * Update ThermoModel.cpp * Util for current@voltage * Hub238 warning * Add hub238 handling in power mode * Update USBPDDebug_FUSB.cpp * HUSB238 debug * Hook PSU Limit * Use wrapping section of GRAM for scroll Update OLED.hpp * Update NTC table * Fix HUB voltage picker * Cleanup * Larger tip filter * Calibrate in a bunch closer Update ThermoModel.cpp * Update configuration.h * Update HUB238.cpp * Update configuration.h * Movement Pin * Update BSP.cpp * tim2 irq * Rough timer conversion (adc broken) but movement working * Fix tim2 start * Faster base PWM * Ensure utils grabs config * Add wattage limiter tolerance for device * Speed up PWM and enable PWM current limiting * tune for 12v * Prevent start until PD done * Update configuration.h * Add HUB238 check for have re-negotiated * Adjust timer to avoid noise when its possible
This commit is contained in:
@@ -26,7 +26,7 @@ extern "C" {
|
||||
#include "settingsGUI.hpp"
|
||||
#include "stdlib.h"
|
||||
#include "string.h"
|
||||
#if POW_PD
|
||||
#ifdef POW_PD
|
||||
#include "USBPD.h"
|
||||
#include "pd.h"
|
||||
#endif
|
||||
@@ -49,12 +49,15 @@ void startGUITask(void const *argument) {
|
||||
|
||||
OLED::setRotation(getSettingValue(SettingsOptions::OrientationMode) & 1);
|
||||
// If the front button is held down, on supported devices, show PD debugging metrics
|
||||
#if POW_PD
|
||||
#ifdef HAS_POWER_DEBUG_MENU
|
||||
#ifdef POW_PD
|
||||
if (getButtonA()) {
|
||||
showPDDebug();
|
||||
}
|
||||
#endif
|
||||
#if POW_PD_EXT == 1
|
||||
if (getButtonB()) {
|
||||
#endif
|
||||
showPDDebug();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (getSettingValue(SettingsOptions::CalibrateCJC) > 0) {
|
||||
|
||||
@@ -74,6 +74,12 @@ void detectAccelerometerVersion() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef GPIO_VIBRATION
|
||||
if (true) {
|
||||
DetectedAccelerometerVersion = AccelType::GPIO;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
{
|
||||
// disable imu sensitivity
|
||||
@@ -111,20 +117,35 @@ inline void readAccelerometer(int16_t &tx, int16_t &ty, int16_t &tz, Orientation
|
||||
SC7A20::getAxisReadings(tx, ty, tz);
|
||||
rotation = SC7A20::getOrientation();
|
||||
} else
|
||||
#endif
|
||||
#ifdef GPIO_VIBRATION
|
||||
if (DetectedAccelerometerVersion == AccelType::GPIO) {
|
||||
// TODO
|
||||
if (HAL_GPIO_ReadPin(MOVEMENT_GPIO_Port, MOVEMENT_Pin) == GPIO_PIN_SET) {
|
||||
// Movement
|
||||
tx = ty = tz = 5000;
|
||||
} else {
|
||||
// No Movement
|
||||
tx = ty = tz = 0;
|
||||
}
|
||||
rotation = Orientation::ORIENTATION_FLAT;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
// do nothing :(
|
||||
}
|
||||
}
|
||||
void startMOVTask(void const *argument __unused) {
|
||||
|
||||
osDelay(TICKS_100MS / 5); // This is here as the BMA doesnt start up instantly and can wedge the I2C bus if probed too fast after boot
|
||||
detectAccelerometerVersion();
|
||||
osDelay(TICKS_100MS / 2); // wait ~50ms for setup of accel to finalise
|
||||
lastMovementTime = 0;
|
||||
// Mask 2 seconds if we are in autostart so that if user is plugging in and
|
||||
// then putting in stand it doesnt wake instantly
|
||||
if (getSettingValue(SettingsOptions::AutoStartMode))
|
||||
if (getSettingValue(SettingsOptions::AutoStartMode)) {
|
||||
osDelay(2 * TICKS_SECOND);
|
||||
}
|
||||
|
||||
int16_t datax[MOVFilter] = {0};
|
||||
int16_t datay[MOVFilter] = {0};
|
||||
|
||||
@@ -43,7 +43,7 @@ void showDebugMenu(void) {
|
||||
// We are not powered via DC, so want to display the appropriate state for PD or QC
|
||||
bool poweredbyPD = false;
|
||||
bool pdHasVBUSConnected = false;
|
||||
#if POW_PD
|
||||
#ifdef POW_PD
|
||||
if (USBPowerDelivery::fusbPresent()) {
|
||||
// We are PD capable
|
||||
if (USBPowerDelivery::negotiationComplete()) {
|
||||
|
||||
@@ -9,6 +9,7 @@ uint8_t buttonAF[sizeof(buttonA)];
|
||||
uint8_t buttonBF[sizeof(buttonB)];
|
||||
uint8_t disconnectedTipF[sizeof(disconnectedTip)];
|
||||
extern OperatingMode currentMode;
|
||||
bool showExitMenuTransition = false;
|
||||
|
||||
void renderHomeScreenAssets(void) {
|
||||
|
||||
@@ -23,66 +24,158 @@ void renderHomeScreenAssets(void) {
|
||||
}
|
||||
}
|
||||
|
||||
void drawHomeScreen(bool buttonLockout) {
|
||||
bool tipDisconnectedDisplay = false;
|
||||
void handleButtons(bool *buttonLockout) {
|
||||
ButtonState buttons = getButtonState();
|
||||
if (buttons != BUTTON_NONE) {
|
||||
OLED::setDisplayState(OLED::DisplayState::ON);
|
||||
}
|
||||
if (buttons != BUTTON_NONE && *buttonLockout) {
|
||||
buttons = BUTTON_NONE;
|
||||
} else {
|
||||
*buttonLockout = false;
|
||||
}
|
||||
switch (buttons) {
|
||||
case BUTTON_NONE:
|
||||
// Do nothing
|
||||
break;
|
||||
case BUTTON_BOTH:
|
||||
// Not used yet
|
||||
// In multi-language this might be used to reset language on a long hold
|
||||
// or some such
|
||||
break;
|
||||
|
||||
case BUTTON_B_LONG:
|
||||
// Show the version information
|
||||
showDebugMenu();
|
||||
break;
|
||||
case BUTTON_F_LONG:
|
||||
gui_solderingTempAdjust();
|
||||
saveSettings();
|
||||
break;
|
||||
case BUTTON_F_SHORT:
|
||||
if (!isTipDisconnected()) {
|
||||
gui_solderingMode(0); // enter soldering mode
|
||||
*buttonLockout = true;
|
||||
}
|
||||
break;
|
||||
case BUTTON_B_SHORT:
|
||||
currentMode = OperatingMode::settings;
|
||||
enterSettingsMenu(); // enter the settings menu
|
||||
{
|
||||
OLED::useSecondaryFramebuffer(true);
|
||||
showExitMenuTransition = true;
|
||||
}
|
||||
*buttonLockout = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void drawDetailedHomeScreen(uint32_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
|
||||
gui_drawTipTemp(true, FontStyle::LARGE); // draw in the temp
|
||||
if (OLED::getRotation()) {
|
||||
OLED::setCursor(6, 0);
|
||||
} else {
|
||||
OLED::setCursor(73, 0); // top right
|
||||
}
|
||||
OLED::printNumber(getSettingValue(SettingsOptions::SolderingTemp), 3, FontStyle::SMALL); // draw set temp
|
||||
if (getSettingValue(SettingsOptions::TemperatureInF))
|
||||
OLED::print(SmallSymbolDegF, FontStyle::SMALL);
|
||||
else
|
||||
OLED::print(SmallSymbolDegC, 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);
|
||||
}
|
||||
}
|
||||
void drawSimplifiedHomeScreen(uint32_t tipTemp) {
|
||||
bool tempOnDisplay = false;
|
||||
bool showExitMenuTransition = false;
|
||||
renderHomeScreenAssets();
|
||||
bool tipDisconnectedDisplay = false;
|
||||
if (OLED::getRotation()) {
|
||||
OLED::drawArea(54, 0, 42, 16, buttonAF);
|
||||
OLED::drawArea(12, 0, 42, 16, buttonBF);
|
||||
OLED::setCursor(0, 0);
|
||||
gui_drawBatteryIcon();
|
||||
} 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);
|
||||
gui_drawBatteryIcon();
|
||||
}
|
||||
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)))
|
||||
gui_drawTipTemp(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
void drawHomeScreen(bool buttonLockout) {
|
||||
|
||||
for (;;) {
|
||||
currentMode = OperatingMode::idle;
|
||||
ButtonState buttons = getButtonState();
|
||||
if (buttons != BUTTON_NONE) {
|
||||
OLED::setDisplayState(OLED::DisplayState::ON);
|
||||
}
|
||||
if (buttons != BUTTON_NONE && buttonLockout)
|
||||
buttons = BUTTON_NONE;
|
||||
else
|
||||
buttonLockout = false;
|
||||
|
||||
switch (buttons) {
|
||||
case BUTTON_NONE:
|
||||
// Do nothing
|
||||
break;
|
||||
case BUTTON_BOTH:
|
||||
// Not used yet
|
||||
// In multi-language this might be used to reset language on a long hold
|
||||
// or some such
|
||||
break;
|
||||
|
||||
case BUTTON_B_LONG:
|
||||
// Show the version information
|
||||
showDebugMenu();
|
||||
break;
|
||||
case BUTTON_F_LONG:
|
||||
#ifdef PROFILE_SUPPORT
|
||||
if (!isTipDisconnected()) {
|
||||
gui_solderingProfileMode(); // enter profile mode
|
||||
buttonLockout = true;
|
||||
}
|
||||
#else
|
||||
gui_solderingTempAdjust();
|
||||
saveSettings();
|
||||
#endif
|
||||
break;
|
||||
case BUTTON_F_SHORT:
|
||||
if (!isTipDisconnected()) {
|
||||
gui_solderingMode(0); // enter soldering mode
|
||||
buttonLockout = true;
|
||||
}
|
||||
break;
|
||||
case BUTTON_B_SHORT:
|
||||
currentMode = OperatingMode::settings;
|
||||
enterSettingsMenu(); // enter the settings menu
|
||||
{
|
||||
OLED::useSecondaryFramebuffer(true);
|
||||
showExitMenuTransition = true;
|
||||
}
|
||||
buttonLockout = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
currentMode = OperatingMode::idle;
|
||||
handleButtons(&buttonLockout);
|
||||
|
||||
currentTempTargetDegC = 0; // ensure tip is off
|
||||
getInputVoltageX10(getSettingValue(SettingsOptions::VoltageDiv), 0);
|
||||
@@ -106,6 +199,7 @@ void drawHomeScreen(bool buttonLockout) {
|
||||
setStatusLED(LED_STANDBY);
|
||||
}
|
||||
}
|
||||
|
||||
// Clear the lcd buffer
|
||||
OLED::clearScreen();
|
||||
if (OLED::getRotation()) {
|
||||
@@ -114,101 +208,9 @@ void drawHomeScreen(bool buttonLockout) {
|
||||
OLED::setCursor(-1, 0);
|
||||
}
|
||||
if (getSettingValue(SettingsOptions::DetailedIDLE)) {
|
||||
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
|
||||
gui_drawTipTemp(true, FontStyle::LARGE); // draw in the temp
|
||||
if (OLED::getRotation()) {
|
||||
OLED::setCursor(6, 0);
|
||||
} else {
|
||||
OLED::setCursor(73, 0); // top right
|
||||
}
|
||||
OLED::printNumber(getSettingValue(SettingsOptions::SolderingTemp), 3, FontStyle::SMALL); // draw set temp
|
||||
if (getSettingValue(SettingsOptions::TemperatureInF))
|
||||
OLED::print(SmallSymbolDegF, FontStyle::SMALL);
|
||||
else
|
||||
OLED::print(SmallSymbolDegC, 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);
|
||||
}
|
||||
|
||||
drawDetailedHomeScreen(tipTemp);
|
||||
} else {
|
||||
if (OLED::getRotation()) {
|
||||
OLED::drawArea(54, 0, 42, 16, buttonAF);
|
||||
OLED::drawArea(12, 0, 42, 16, buttonBF);
|
||||
OLED::setCursor(0, 0);
|
||||
gui_drawBatteryIcon();
|
||||
} 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);
|
||||
gui_drawBatteryIcon();
|
||||
}
|
||||
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)))
|
||||
gui_drawTipTemp(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
drawSimplifiedHomeScreen(tipTemp);
|
||||
}
|
||||
|
||||
if (showExitMenuTransition) {
|
||||
|
||||
@@ -18,7 +18,7 @@ extern "C" {
|
||||
#include "settingsGUI.hpp"
|
||||
#include "stdlib.h"
|
||||
#include "string.h"
|
||||
#if POW_PD
|
||||
#ifdef POW_PD
|
||||
#include "USBPD.h"
|
||||
#include "pd.h"
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "HUB238.hpp"
|
||||
#include "OperatingModes.h"
|
||||
|
||||
void showWarnings(void) {
|
||||
// Display alert if settings were reset
|
||||
if (settingsWereReset) {
|
||||
@@ -11,6 +11,7 @@ void showWarnings(void) {
|
||||
warnUser(translatedString(Tr->DeviceFailedValidationWarning), 10 * TICKS_SECOND);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef NO_WARN_MISSING
|
||||
// We also want to alert if accel or pd is not detected / not responding
|
||||
// In this case though, we dont want to nag the user _too_ much
|
||||
@@ -26,7 +27,7 @@ void showWarnings(void) {
|
||||
warnUser(translatedString(Tr->NoAccelerometerMessage), 10 * TICKS_SECOND);
|
||||
}
|
||||
}
|
||||
#if POW_PD
|
||||
#ifdef POW_PD
|
||||
// We expect pd to be present
|
||||
if (!USBPowerDelivery::fusbPresent()) {
|
||||
if (getSettingValue(SettingsOptions::PDMissingWarningCounter) < 2) {
|
||||
@@ -36,5 +37,14 @@ void showWarnings(void) {
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if POW_PD_EXT == 1
|
||||
if (!hub238_probe()) {
|
||||
if (getSettingValue(SettingsOptions::PDMissingWarningCounter) < 2) {
|
||||
nextSettingValue(SettingsOptions::PDMissingWarningCounter);
|
||||
saveSettings();
|
||||
warnUser(translatedString(Tr->NoPowerDeliveryMessage), 10 * TICKS_SECOND);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "OperatingModes.h"
|
||||
|
||||
#if POW_PD
|
||||
#ifdef POW_PD
|
||||
#ifdef HAS_POWER_DEBUG_MENU
|
||||
void showPDDebug(void) {
|
||||
// Print out the USB-PD state
|
||||
55
source/Core/Threads/OperatingModes/USBPDDebug_HUSB238.cpp
Normal file
55
source/Core/Threads/OperatingModes/USBPDDebug_HUSB238.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
#include "HUB238.hpp"
|
||||
#include "OperatingModes.h"
|
||||
#if POW_PD_EXT == 1
|
||||
#ifdef HAS_POWER_DEBUG_MENU
|
||||
void showPDDebug(void) {
|
||||
// Print out the USB-PD state
|
||||
// Basically this is like the Debug menu, but instead we want to print out the PD status
|
||||
uint8_t screen = 0;
|
||||
ButtonState b;
|
||||
for (;;) {
|
||||
OLED::clearScreen(); // Ensure the buffer starts clean
|
||||
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
|
||||
if (screen > 6) {
|
||||
screen = 0;
|
||||
}
|
||||
if (screen == 0) {
|
||||
// Print the PD Debug state
|
||||
OLED::print(SmallSymbolState, FontStyle::SMALL);
|
||||
OLED::print(SmallSymbolSpace, FontStyle::SMALL);
|
||||
uint16_t temp = hub238_debug_state();
|
||||
OLED::drawHex(temp, FontStyle::SMALL, 4);
|
||||
OLED::print(SmallSymbolSpace, FontStyle::SMALL);
|
||||
// Print current selected specs
|
||||
temp = hub238_source_voltage();
|
||||
OLED::printNumber(temp, 2, FontStyle::SMALL, true);
|
||||
OLED::print(SmallSymbolSpace, FontStyle::SMALL);
|
||||
|
||||
} else {
|
||||
|
||||
// Print out the Proposed power options one by one
|
||||
const uint8_t voltages[] = {5, 9, 12, 15, 18, 20};
|
||||
uint16_t voltage = voltages[screen - 1];
|
||||
uint16_t currentx100 = hub238_getVoltagePDOCurrent(voltage);
|
||||
OLED::printNumber(voltage, 2, FontStyle::SMALL, true);
|
||||
OLED::print(SmallSymbolSpace, FontStyle::SMALL);
|
||||
|
||||
OLED::printNumber(currentx100 / 100, 1, FontStyle::SMALL, true);
|
||||
OLED::print(SmallSymbolDot, FontStyle::SMALL);
|
||||
OLED::printNumber(currentx100 % 100, 2, FontStyle::SMALL, true);
|
||||
}
|
||||
|
||||
OLED::refresh();
|
||||
b = getButtonState();
|
||||
if (b == BUTTON_B_SHORT)
|
||||
return;
|
||||
else if (b == BUTTON_F_SHORT) {
|
||||
screen++;
|
||||
}
|
||||
GUIDelay();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "OperatingModeUtilities.h"
|
||||
|
||||
void gui_drawBatteryIcon(void) {
|
||||
#if defined(POW_PD) || defined(POW_QC)
|
||||
#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
|
||||
|
||||
@@ -116,7 +116,7 @@ int32_t getPIDResultX10Watts(int32_t setpointDelta) {
|
||||
static TickType_t lastCall = 0;
|
||||
static Integrator<int32_t> powerStore = {0};
|
||||
|
||||
const TickType_t rate = 1000 / (xTaskGetTickCount() - lastCall);
|
||||
const TickType_t rate = TICKS_SECOND / (xTaskGetTickCount() - lastCall);
|
||||
lastCall = xTaskGetTickCount();
|
||||
// Sandman note:
|
||||
// PID Challenge - we have a small thermal mass that we to want heat up as fast as possible but we don't
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "BSP.h"
|
||||
#include "FreeRTOS.h"
|
||||
#include "HUB238.hpp"
|
||||
#include "QC3.h"
|
||||
#include "Settings.h"
|
||||
#include "USBPD.h"
|
||||
@@ -16,9 +17,11 @@
|
||||
#include "stdlib.h"
|
||||
#include "task.h"
|
||||
|
||||
|
||||
// Small worker thread to handle power (PD + QC) related steps
|
||||
|
||||
void startPOWTask(void const *argument __unused) {
|
||||
|
||||
// Init any other misc sensors
|
||||
postRToSInit();
|
||||
while (preStartChecksDone() == 0) {
|
||||
@@ -26,7 +29,7 @@ void startPOWTask(void const *argument __unused) {
|
||||
}
|
||||
// You have to run this once we are willing to answer PD messages
|
||||
// Setting up too early can mean that we miss the ~20ms window to respond on some chargers
|
||||
#if POW_PD
|
||||
#ifdef POW_PD
|
||||
USBPowerDelivery::start();
|
||||
// Crank the handle at boot until we are stable and waiting for IRQ
|
||||
USBPowerDelivery::step();
|
||||
@@ -46,7 +49,7 @@ void startPOWTask(void const *argument __unused) {
|
||||
res = xTaskNotifyWait(0x0, 0xFFFFFF, NULL, TICKS_100MS / 2);
|
||||
}
|
||||
|
||||
#if POW_PD
|
||||
#ifdef POW_PD
|
||||
if (res != pdFALSE || getFUS302IRQLow()) {
|
||||
USBPowerDelivery::IRQOccured();
|
||||
}
|
||||
@@ -55,6 +58,9 @@ void startPOWTask(void const *argument __unused) {
|
||||
|
||||
#else
|
||||
(void)res;
|
||||
#endif
|
||||
#if POW_PD_EXT == 1
|
||||
hub238_check_negotiation();
|
||||
#endif
|
||||
power_check();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user