* 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
94 lines
4.2 KiB
C++
94 lines
4.2 KiB
C++
#include "OperatingModes.h"
|
|
|
|
#ifdef POW_PD
|
|
#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 == 0) {
|
|
// Print the PD state machine
|
|
OLED::print(SmallSymbolState, FontStyle::SMALL);
|
|
OLED::print(SmallSymbolSpace, FontStyle::SMALL);
|
|
OLED::printNumber(USBPowerDelivery::getStateNumber(), 2, FontStyle::SMALL, true);
|
|
OLED::print(SmallSymbolSpace, FontStyle::SMALL);
|
|
// Also print vbus mod status
|
|
if (USBPowerDelivery::fusbPresent()) {
|
|
if (USBPowerDelivery::negotiationComplete() || (xTaskGetTickCount() > (TICKS_SECOND * 10))) {
|
|
if (!USBPowerDelivery::isVBUSConnected()) {
|
|
OLED::print(SmallSymbolNoVBus, FontStyle::SMALL);
|
|
} else {
|
|
OLED::print(SmallSymbolVBus, FontStyle::SMALL);
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
// Print out the Proposed power options one by one
|
|
auto lastCaps = USBPowerDelivery::getLastSeenCapabilities();
|
|
if ((screen - 1) < 11) {
|
|
int voltage_mv = 0;
|
|
int min_voltage = 0;
|
|
int current_a_x100 = 0;
|
|
int wattage = 0;
|
|
|
|
if ((lastCaps[screen - 1] & PD_PDO_TYPE) == PD_PDO_TYPE_FIXED) {
|
|
voltage_mv = PD_PDV2MV(PD_PDO_SRC_FIXED_VOLTAGE_GET(lastCaps[screen - 1])); // voltage in mV units
|
|
current_a_x100 = PD_PDO_SRC_FIXED_CURRENT_GET(lastCaps[screen - 1]); // current in 10mA units
|
|
} else if (((lastCaps[screen - 1] & PD_PDO_TYPE) == PD_PDO_TYPE_AUGMENTED) && ((lastCaps[screen - 1] & PD_APDO_TYPE) == PD_APDO_TYPE_AVS)) {
|
|
voltage_mv = PD_PAV2MV(PD_APDO_AVS_MAX_VOLTAGE_GET(lastCaps[screen - 1]));
|
|
min_voltage = PD_PAV2MV(PD_APDO_PPS_MIN_VOLTAGE_GET(lastCaps[screen - 1]));
|
|
// Last value is wattage
|
|
wattage = PD_APDO_AVS_MAX_POWER_GET(lastCaps[screen - 1]);
|
|
} else if (((lastCaps[screen - 1] & PD_PDO_TYPE) == PD_PDO_TYPE_AUGMENTED) && ((lastCaps[screen - 1] & PD_APDO_TYPE) == PD_APDO_TYPE_PPS)) {
|
|
voltage_mv = PD_PAV2MV(PD_APDO_PPS_MAX_VOLTAGE_GET(lastCaps[screen - 1]));
|
|
min_voltage = PD_PAV2MV(PD_APDO_PPS_MIN_VOLTAGE_GET(lastCaps[screen - 1]));
|
|
current_a_x100 = PD_PAI2CA(PD_APDO_PPS_CURRENT_GET(lastCaps[screen - 1])); // max current in 10mA units
|
|
}
|
|
// Skip not used entries
|
|
if (voltage_mv == 0) {
|
|
screen++;
|
|
} else {
|
|
// print out this entry of the proposal
|
|
OLED::printNumber(screen, 2, FontStyle::SMALL, true); // print the entry number
|
|
OLED::print(SmallSymbolSpace, FontStyle::SMALL);
|
|
if (min_voltage > 0) {
|
|
OLED::printNumber(min_voltage / 1000, 2, FontStyle::SMALL, true); // print the voltage
|
|
OLED::print(SmallSymbolMinus, FontStyle::SMALL);
|
|
}
|
|
OLED::printNumber(voltage_mv / 1000, 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);
|
|
}
|
|
}
|
|
} else {
|
|
screen = 0;
|
|
}
|
|
}
|
|
|
|
OLED::refresh();
|
|
b = getButtonState();
|
|
if (b == BUTTON_B_SHORT)
|
|
return;
|
|
else if (b == BUTTON_F_SHORT) {
|
|
screen++;
|
|
}
|
|
GUIDelay();
|
|
}
|
|
}
|
|
#endif
|
|
#endif
|