USB PD timeout added
This commit is contained in:
@@ -21,6 +21,8 @@
|
||||
#include "int_n.h"
|
||||
#include <pd.h>
|
||||
#include <stdbool.h>
|
||||
#include "Settings.h"
|
||||
|
||||
bool PolicyEngine::pdNegotiationComplete;
|
||||
int PolicyEngine::current_voltage_mv;
|
||||
int PolicyEngine::_requested_voltage;
|
||||
@@ -617,6 +619,18 @@ void PolicyEngine::PPSTimerCallback() {
|
||||
}
|
||||
}
|
||||
|
||||
bool PolicyEngine::NegotiationTimeoutReached() {
|
||||
if (systemSettings.PDNegTimeout == 0){
|
||||
return false;
|
||||
}
|
||||
|
||||
if (xTaskGetTickCount() > (TICKS_SECOND/10 * systemSettings.PDNegTimeout)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
EventBits_t PolicyEngine::pushMessage(union pd_msg *msg) {
|
||||
if (PD_MSGTYPE_GET(msg) == PD_MSGTYPE_SOFT_RESET && PD_NUMOBJ_GET(msg) == 0) {
|
||||
/* Clear MessageIDCounter */
|
||||
|
||||
@@ -36,6 +36,8 @@ public:
|
||||
static bool setupCompleteOrTimedOut() {
|
||||
if (pdNegotiationComplete)
|
||||
return true;
|
||||
if (PolicyEngine::NegotiationTimeoutReached())
|
||||
return true;
|
||||
if (state == policy_engine_state::PESinkSourceUnresponsive)
|
||||
return true;
|
||||
if (state == policy_engine_state::PESinkReady)
|
||||
@@ -46,11 +48,17 @@ public:
|
||||
static bool pdHasNegotiated() {
|
||||
if (state == policy_engine_state::PESinkSourceUnresponsive)
|
||||
return false;
|
||||
if (pdNegotiationComplete)
|
||||
return true;
|
||||
if (PolicyEngine::NegotiationTimeoutReached())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
// Call this periodically, at least once every second
|
||||
static void PPSTimerCallback();
|
||||
|
||||
static bool NegotiationTimeoutReached();
|
||||
|
||||
enum class Notifications {
|
||||
PDB_EVT_PE_RESET = EVENT_MASK(0),
|
||||
PDB_EVT_PE_MSG_RX = EVENT_MASK(1),
|
||||
|
||||
@@ -27,6 +27,7 @@ typedef struct {
|
||||
uint8_t minDCVoltageCells; // The voltage we cut out at for under voltage when powered by DC jack
|
||||
uint8_t minVoltageCells; // Minimum allowed voltage per cell <3S - 3.0V (30)> <4S - 2.4V (24)> <...> (Minimum recommended 2.7V)
|
||||
uint8_t QCIdealVoltage; // Desired QC3.0 voltage (9,12,20V)
|
||||
uint8_t PDNegTimeout; // PD timeout in 100ms steps
|
||||
uint8_t OrientationMode : 2; // Selects between Auto,Right and left handed layouts
|
||||
uint8_t sensitivity : 4; // Sensitivity of accelerometer (5 bits)
|
||||
uint8_t animationLoop : 1; // Animation loop switch
|
||||
|
||||
@@ -45,6 +45,7 @@ enum class SettingsItemIndex : uint8_t {
|
||||
AdvancedSoldering,
|
||||
ScrollingSpeed,
|
||||
QCMaxVoltage,
|
||||
PDNegTimeout,
|
||||
PowerLimit,
|
||||
ReverseButtonTempChange,
|
||||
TempChangeShortStep,
|
||||
|
||||
@@ -57,6 +57,7 @@ void resetSettings() {
|
||||
systemSettings.minDCVoltageCells = CUT_OUT_SETTING; // default to no cut-off voltage
|
||||
systemSettings.minVoltageCells = RECOM_VOL_CELL; // Minimum voltage per cell (Recommended 3.3V (33))
|
||||
systemSettings.QCIdealVoltage = 0; // Default to 9V for QC3.0 Voltage
|
||||
systemSettings.PDNegTimeout = 0; // Default for PD timout to 0
|
||||
systemSettings.version = SETTINGSVERSION; // Store the version number to allow for easier upgrades
|
||||
systemSettings.detailedSoldering = DETAILED_SOLDERING; // Detailed soldering screen
|
||||
systemSettings.detailedIDLE = DETAILED_IDLE; // Detailed idle screen (off for first time users)
|
||||
|
||||
@@ -27,6 +27,9 @@ static bool settings_setQCInputV(void);
|
||||
static bool settings_displayQCInputV(void);
|
||||
#endif
|
||||
|
||||
static bool settings_setPDNegTimeout(void);
|
||||
static bool settings_displayPDNegTimeout(void);
|
||||
|
||||
#ifndef NO_SLEEP_MODE
|
||||
static bool settings_setSleepTemp(void);
|
||||
static bool settings_displaySleepTemp(void);
|
||||
@@ -174,6 +177,7 @@ const menuitem powerMenu[] = {
|
||||
#ifdef POW_QC
|
||||
{SETTINGS_DESC(SettingsItemIndex::QCMaxVoltage), settings_setQCInputV, settings_displayQCInputV}, /*Voltage input*/
|
||||
#endif
|
||||
{SETTINGS_DESC(SettingsItemIndex::PDNegTimeout), settings_setPDNegTimeout, settings_displayPDNegTimeout}, /*PD timeout setup*/
|
||||
{0, nullptr, nullptr} // end of menu marker. DO NOT REMOVE
|
||||
};
|
||||
#endif
|
||||
@@ -350,6 +354,7 @@ static bool settings_displayInputMinVRange(void) {
|
||||
static bool settings_setQCInputV(void) {
|
||||
#ifdef POW_QC_20V
|
||||
systemSettings.QCIdealVoltage = (systemSettings.QCIdealVoltage + 1) % 3;
|
||||
|
||||
return systemSettings.QCIdealVoltage == 2;
|
||||
#else
|
||||
systemSettings.QCIdealVoltage = (systemSettings.QCIdealVoltage + 1) % 2;
|
||||
@@ -382,6 +387,19 @@ static bool settings_displayQCInputV(void) {
|
||||
|
||||
#endif
|
||||
|
||||
static bool settings_setPDNegTimeout(void) {
|
||||
systemSettings.PDNegTimeout = (systemSettings.PDNegTimeout + 1) % 50;
|
||||
|
||||
return systemSettings.QCIdealVoltage == 49;
|
||||
}
|
||||
|
||||
static bool settings_displayPDNegTimeout(void){
|
||||
printShortDescription(SettingsItemIndex::PDNegTimeout, 5);
|
||||
OLED::printNumber(systemSettings.PDNegTimeout, 2, FontStyle::LARGE);
|
||||
|
||||
return systemSettings.QCIdealVoltage == 49;
|
||||
}
|
||||
|
||||
#ifndef NO_SLEEP_MODE
|
||||
static bool settings_setSleepTemp(void) {
|
||||
// If in C, 10 deg, if in F 20 deg
|
||||
|
||||
Reference in New Issue
Block a user