1
0
forked from me/IronOS

Pinecil pd tweaking (#1272)

* Raise PD max to 21V

* gui -> settingsGUI

* VBus probe cache

* Rough pass PD capabilities display

* Cleanup build errors

* PD Debug menu working

* Update make_translation.py

* settingsGUI

* Update GUIThread.cpp

* Nicer debug prints

* Show VBus in PD debug

* Update GUIThread.cpp

* Update make_translation.py

* Add docs

* Build tweaks for TS80P 😢

* Show PPS ranges
This commit is contained in:
Ben V. Brown
2022-04-03 12:58:07 +10:00
committed by GitHub
parent 787bc46bdc
commit a73f634cff
11 changed files with 155 additions and 32 deletions

View File

@@ -40,7 +40,7 @@ This is the raw tip reading in μV. This can be used when assessing the calibrat
### CTip
This is the tip temperature in degrees Celsius.
This is the tip temperature in degrees Celsius.
This can be used with RTip for assessing temperature processing performance.
### CHan
@@ -48,11 +48,11 @@ This can be used with RTip for assessing temperature processing performance.
This is the handle temperature in °C. This is used for cold junction compensation of the tip temperature.
This is shown in degrees Celsius x10, so 200 == 20.0 °C
### Vin
### Vin
The input voltage as read by the internal ADC. Can be used to sanity check its being read correctly.
### ACC
### ACC
This indicates the accelerometer that is fitted inside the unit.
@@ -64,7 +64,7 @@ This indicates the accelerometer that is fitted inside the unit.
- None detected -> running in fallback without movement detection
- Scanning -> Still searching I2C for one
### PWR
### PWR
This indicates the current power source for the iron.
This may change during power up as the sources are negotiated in turn.
@@ -76,13 +76,23 @@ This may change during power up as the sources are negotiated in turn.
- If you successfully modified the Pinecil to support 24 V by cutting the trace line to Vbus, then 'PD No VBus' displays on screen.
- Connect to any PD USB power to check Vbus status. It will not show any PD message when Pinecil is powered by DC port, QC, or USB 5 V (non PD).
### Max
### Max
This indicates the max temperature in degrees Celsius that the system estimates it can measure the tip reliably to.
This is dependant on a few factors including the handle temperature so it can move around during use.
### Hall
This appears if your device is capable of having a magnetic hall effect sensor installed (Pinecil).
This shows the current field strength reading from the sensor. It can be used to check if the sensor is operational, and measure how strong the magnetic field is for diagnostics and optimal placement of magnets on a stand.
# PD Debug menu
On the Pinecil; if the iron is booted up while holding the front button (+); it will show an extra menu for inspecting USB-PD power adapters.
The menu navigates like the debug menu, where pressing (+) cycles through elements, and (-) will exit the menu.
First page shows the PD negotiation stage number; which can be used for diagnosing if PD is not working.
After a few seconds or after PD negotiates (state above 5) it will show "No VBus" if the VBus mod is performed or "VBus" if the mod has not been done.
Once negotiation is complete; the other screens will show the advertised readings for voltage and current of the proposals.

View File

@@ -106,9 +106,14 @@ def get_constants(build_version: str) -> List[Tuple[str, str]]:
("SymbolSeconds", "S"),
("SymbolWatts", "W"),
("SymbolVolts", "V"),
("SymbolAmps", "A"),
("SymbolDC", "DC"),
("SymbolCellCount", "S"),
("SymbolVersionNumber", build_version),
("SymbolPDDebug", "PD Debug"),
("SymbolState", "State"),
("SymbolNoVBus", "No VBus"),
("SymbolVBus", "VBus"),
]

View File

@@ -124,7 +124,7 @@
#define POWER_LIMIT_STEPS 5 //
#define OP_AMP_GAIN_STAGE OP_AMP_GAIN_STAGE_PINECIL // Uses TS100 resistors
#define TEMP_uV_LOOKUP_HAKKO // Use Hakko lookup table
#define USB_PD_VMAX 20 // Maximum voltage for PD to negotiate
#define USB_PD_VMAX 21 // Maximum voltage for PD to negotiate
#define PID_TIM_HZ (8) // Tick rate of the PID loop
#define MAX_TEMP_C 450 // Max soldering temp selectable °C
#define MAX_TEMP_F 850 // Max soldering temp selectable °F
@@ -153,3 +153,5 @@
#endif
#define FLASH_LOGOADDR (0x08000000 + (126 * 1024))
#define HAS_POWER_DEBUG_MENU

View File

@@ -5,7 +5,7 @@
* Author: Ralim
*/
#include "FreeRTOS.h"
#include "gui.hpp"
#include "settingsGUI.hpp"
#include "task.h"
#include <Buttons.hpp>
uint32_t lastButtonTime = 0;

View File

@@ -67,10 +67,24 @@ bool USBPowerDelivery::fusbPresent() {
return detectionState == 1;
}
bool USBPowerDelivery::isVBUSConnected() { return fusb.isVBUSConnected(); }
bool USBPowerDelivery::isVBUSConnected() {
static uint8_t state = 0;
if (state) {
return state == 1;
}
if (fusb.isVBUSConnected()) {
state = 1;
return true;
} else {
state = 2;
return false;
}
}
pd_msg lastCapabilities;
pd_msg *USBPowerDelivery::getLastSeenCapabilities() { return &lastCapabilities; }
bool pdbs_dpm_evaluate_capability(const pd_msg *capabilities, pd_msg *request) {
memcpy(&lastCapabilities, capabilities, sizeof(pd_msg));
/* Get the number of PDOs */
uint8_t numobj = PD_NUMOBJ_GET(capabilities);

View File

@@ -2,6 +2,7 @@
#ifndef DRIVERS_USBPD_H_
#define DRIVERS_USBPD_H_
#include "configuration.h"
#include "pdb_msg.h"
#include <stdbool.h>
#include <stdint.h>
@@ -9,16 +10,17 @@
#if POW_PD
class USBPowerDelivery {
public:
static bool start(); // Start the PD stack
static bool negotiationComplete(); // Has negotiation completed to a voltage > 5v
static bool negotiationInProgress(); // Is negotiation ongoing
static bool fusbPresent(); // Is the FUSB302 present on the bus
static void PPSTimerCallback(); // PPS Timer
static void IRQOccured(); // Thread callback that an irq occured
static void step(); // Iterate the step machine
static bool negotiationHasWorked(); // Has PD negotiation worked (are we in a PD contract)
static uint8_t getStateNumber(); // Debugging - Get the internal state number
static bool isVBUSConnected(); // Is the VBus pin connected on the FUSB302
static bool start(); // Start the PD stack
static bool negotiationComplete(); // Has negotiation completed to a voltage > 5v
static bool negotiationInProgress(); // Is negotiation ongoing
static bool fusbPresent(); // Is the FUSB302 present on the bus
static void PPSTimerCallback(); // PPS Timer
static void IRQOccured(); // Thread callback that an irq occured
static void step(); // Iterate the step machine
static bool negotiationHasWorked(); // Has PD negotiation worked (are we in a PD contract)
static uint8_t getStateNumber(); // Debugging - Get the internal state number
static bool isVBUSConnected(); // Is the VBus pin connected on the FUSB302
static pd_msg *getLastSeenCapabilities(); // returns pointer to the last seen capabilities from the powersource
private:
//
static int detectionState;

View File

@@ -14,6 +14,7 @@ extern const bool HasFahrenheit;
extern const char *SymbolPlus;
extern const char *SymbolMinus;
extern const char *SymbolSpace;
extern const char *SymbolAmps;
extern const char *SymbolDot;
extern const char *SymbolDegC;
extern const char *SymbolDegF;
@@ -24,6 +25,10 @@ extern const char *SymbolVolts;
extern const char *SymbolDC;
extern const char *SymbolCellCount;
extern const char *SymbolVersionNumber;
extern const char *SymbolPDDebug;
extern const char *SymbolState;
extern const char *SymbolNoVBus;
extern const char *SymbolVBus;
extern const char *DebugMenu[];
extern const char *AccelTypeNames[];

View File

@@ -1,5 +1,5 @@
/*
* gui.h
* settingsGUI.h
*
* Created on: 3Sep.,2017
* Author: Ben V. Brown

View File

@@ -3,10 +3,10 @@
#include "Translation_multi.h"
#include "brieflz.h"
#include "configuration.h"
#include "gui.hpp"
#include "settingsGUI.hpp"
const TranslationIndexTable *Tr = nullptr;
const char * TranslationStrings = nullptr;
const char *TranslationStrings = nullptr;
static uint8_t selectedLangIndex = 255;
@@ -38,7 +38,7 @@ void prepareTranslations() {
const TranslationData *translationData;
uint16_t buffer_remaining_size = translation_data_out_buffer_size;
uint8_t * buffer_next_ptr = translation_data_out_buffer;
uint8_t *buffer_next_ptr = translation_data_out_buffer;
if (langMeta.translation_is_compressed) {
unsigned int outsize;
outsize = blz_depack_srcsize(langMeta.translation_data, buffer_next_ptr, langMeta.translation_size);
@@ -55,7 +55,7 @@ void prepareTranslations() {
memset(DynamicFontSections, 0, FontSectionsCount * sizeof(DynamicFontSections[0]));
for (int i = 0; i < FontSectionDataCount; i++) {
const auto &fontSectionDataInfo = FontSectionDataInfos[i];
auto & fontSection = DynamicFontSections[i];
auto &fontSection = DynamicFontSections[i];
fontSection.symbol_start = fontSectionDataInfo.symbol_start;
fontSection.symbol_end = fontSection.symbol_start + fontSectionDataInfo.symbol_count;
const uint16_t font12_size = fontSectionDataInfo.symbol_count * (12 * 16 / 8);

View File

@@ -1,11 +1,11 @@
/*
* gui.cpp
* settingsGUI.cpp
*
* Created on: 3Sep.,2017
* Author: Ben V. Brown
*/
#include "gui.hpp"
#include "settingsGUI.hpp"
#include "Buttons.hpp"
#include "ScrollMessage.hpp"
#include "TipThermoModel.h"

View File

@@ -11,20 +11,22 @@ extern "C" {
#include "Buttons.hpp"
#include "I2CBB.hpp"
#include "LIS2DH12.hpp"
#include "MMA8652FC.hpp"
#include "OLED.hpp"
#include "Settings.h"
#include "TipThermoModel.h"
#include "Translation.h"
#include "cmsis_os.h"
#include "configuration.h"
#include "history.hpp"
#include "main.hpp"
#include "power.hpp"
#include "settingsGUI.hpp"
#include "stdlib.h"
#include "string.h"
#include <MMA8652FC.hpp>
#include <gui.hpp>
#include <history.hpp>
#include <power.hpp>
#if POW_PD
#include "USBPD.h"
#include "pd.h"
#endif
// File local variables
extern uint32_t currentTempTargetDegC;
@@ -797,6 +799,82 @@ void showDebugMenu(void) {
}
}
#if POW_PD
#ifdef HAS_POWER_DEBUG_MENU
static 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(SymbolPDDebug, FontStyle::SMALL); // Print Title
OLED::setCursor(0, 8); // second line
if (screen == 0) {
// Print the PD state machine
OLED::print(SymbolState, FontStyle::SMALL);
OLED::print(SymbolSpace, FontStyle::SMALL);
OLED::printNumber(USBPowerDelivery::getStateNumber(), 2, FontStyle::SMALL, true);
OLED::print(SymbolSpace, FontStyle::SMALL);
// Also print vbus mod status
if (USBPowerDelivery::fusbPresent()) {
if (USBPowerDelivery::negotiationComplete() || (xTaskGetTickCount() > (TICKS_SECOND * 10))) {
if (!USBPowerDelivery::isVBUSConnected()) {
OLED::print(SymbolNoVBus, FontStyle::SMALL);
} else {
OLED::print(SymbolVBus, FontStyle::SMALL);
}
}
}
} else {
// Print out the Proposed power options one by one
auto lastCaps = USBPowerDelivery::getLastSeenCapabilities();
uint8_t numobj = PD_NUMOBJ_GET(lastCaps);
if ((screen - 1) < numobj) {
int voltage_mv = 0;
int min_voltage = 0;
int current_a_x100 = 0;
if ((lastCaps->obj[screen - 1] & PD_PDO_TYPE) == PD_PDO_TYPE_FIXED) {
voltage_mv = PD_PDV2MV(PD_PDO_SRC_FIXED_VOLTAGE_GET(lastCaps->obj[screen - 1])); // voltage in mV units
current_a_x100 = PD_PDO_SRC_FIXED_CURRENT_GET(lastCaps->obj[screen - 1]); // current in 10mA units
} else {
voltage_mv = PD_PAV2MV(PD_APDO_PPS_MAX_VOLTAGE_GET(lastCaps->obj[screen - 1]));
min_voltage = PD_PAV2MV(PD_APDO_PPS_MIN_VOLTAGE_GET(lastCaps->obj[screen - 1]));
current_a_x100 = PD_PAI2CA(PD_APDO_PPS_CURRENT_GET(lastCaps->obj[screen - 1])); // max current in 10mA units
}
// print out this entry of the proposal
OLED::printNumber(screen, 1, FontStyle::SMALL, true); // print the entry number
OLED::print(SymbolSpace, FontStyle::SMALL);
if (min_voltage > 0) {
OLED::printNumber(min_voltage / 1000, 2, FontStyle::SMALL, true); // print the voltage
OLED::print(SymbolMinus, FontStyle::SMALL);
}
OLED::printNumber(voltage_mv / 1000, 2, FontStyle::SMALL, true); // print the voltage
OLED::print(SymbolVolts, FontStyle::SMALL);
OLED::print(SymbolSpace, FontStyle::SMALL);
OLED::printNumber(current_a_x100 / 100, 2, FontStyle::SMALL, true); // print the current in 0.1A res
OLED::print(SymbolDot, FontStyle::SMALL);
OLED::printNumber(current_a_x100 % 10, 1, FontStyle::SMALL, true); // print the current in 0.1A res
OLED::print(SymbolAmps, 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
void showWarnings() {
// Display alert if settings were reset
if (settingsWereReset) {
@@ -860,7 +938,14 @@ void startGUITask(void const *argument) {
}
getTipRawTemp(1); // reset filter
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
if (getButtonA()) {
showPDDebug();
}
#endif
#endif
BootLogo::handleShowingLogo((uint8_t *)FLASH_LOGOADDR);
showWarnings();