Suggestions mostly corrected
This commit is contained in:
@@ -16,7 +16,7 @@ void power_check() {
|
|||||||
if (FUSB302_present) {
|
if (FUSB302_present) {
|
||||||
PolicyEngine::PPSTimerCallback();
|
PolicyEngine::PPSTimerCallback();
|
||||||
// Cant start QC until either PD works or fails
|
// Cant start QC until either PD works or fails
|
||||||
if (PolicyEngine::setupCompleteOrTimedOut() == false) {
|
if (PolicyEngine::setupCompleteOrTimedOut(systemSettings.PDNegTimeout) == false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (PolicyEngine::pdHasNegotiated()) {
|
if (PolicyEngine::pdHasNegotiated()) {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ void power_check() {
|
|||||||
if (FUSB302_present) {
|
if (FUSB302_present) {
|
||||||
PolicyEngine::PPSTimerCallback();
|
PolicyEngine::PPSTimerCallback();
|
||||||
// Cant start QC until either PD works or fails
|
// Cant start QC until either PD works or fails
|
||||||
if (PolicyEngine::setupCompleteOrTimedOut() == false) {
|
if (PolicyEngine::setupCompleteOrTimedOut(systemSettings.PDNegTimeout) == false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (PolicyEngine::pdHasNegotiated()) {
|
if (PolicyEngine::pdHasNegotiated()) {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ void power_check() {
|
|||||||
if (FUSB302_present) {
|
if (FUSB302_present) {
|
||||||
PolicyEngine::PPSTimerCallback();
|
PolicyEngine::PPSTimerCallback();
|
||||||
// Cant start QC until either PD works or fails
|
// Cant start QC until either PD works or fails
|
||||||
if (PolicyEngine::setupCompleteOrTimedOut() == false) {
|
if (PolicyEngine::setupCompleteOrTimedOut(systemSettings.PDNegTimeout) == false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (PolicyEngine::pdHasNegotiated()) {
|
if (PolicyEngine::pdHasNegotiated()) {
|
||||||
@@ -43,7 +43,7 @@ uint8_t usb_pd_detect() {
|
|||||||
|
|
||||||
bool getIsPoweredByDCIN() {
|
bool getIsPoweredByDCIN() {
|
||||||
// We return false until we are sure we are not using PD
|
// We return false until we are sure we are not using PD
|
||||||
if (PolicyEngine::setupCompleteOrTimedOut() == false) {
|
if (PolicyEngine::setupCompleteOrTimedOut(systemSettings.PDNegTimeout) == false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (PolicyEngine::pdHasNegotiated()) {
|
if (PolicyEngine::pdHasNegotiated()) {
|
||||||
|
|||||||
@@ -21,7 +21,6 @@
|
|||||||
#include "int_n.h"
|
#include "int_n.h"
|
||||||
#include <pd.h>
|
#include <pd.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include "Settings.h"
|
|
||||||
|
|
||||||
bool PolicyEngine::pdNegotiationComplete;
|
bool PolicyEngine::pdNegotiationComplete;
|
||||||
int PolicyEngine::current_voltage_mv;
|
int PolicyEngine::current_voltage_mv;
|
||||||
@@ -619,12 +618,13 @@ void PolicyEngine::PPSTimerCallback() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PolicyEngine::NegotiationTimeoutReached() {
|
bool PolicyEngine::NegotiationTimeoutReached(uint8_t timeout) {
|
||||||
if (systemSettings.PDNegTimeout == 0){
|
if (timeout == 0){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xTaskGetTickCount() > (TICKS_SECOND/10 * systemSettings.PDNegTimeout)) {
|
if (xTaskGetTickCount() > (TICKS_100MS * timeout)) {
|
||||||
|
state = PESinkSourceUnresponsive;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,10 +33,10 @@ public:
|
|||||||
static void handleMessage(union pd_msg *msg);
|
static void handleMessage(union pd_msg *msg);
|
||||||
// Returns true if headers indicate PD3.0 compliant
|
// Returns true if headers indicate PD3.0 compliant
|
||||||
static bool isPD3_0();
|
static bool isPD3_0();
|
||||||
static bool setupCompleteOrTimedOut() {
|
static bool setupCompleteOrTimedOut(uint8_t timeout) {
|
||||||
if (pdNegotiationComplete)
|
if (pdNegotiationComplete)
|
||||||
return true;
|
return true;
|
||||||
if (PolicyEngine::NegotiationTimeoutReached())
|
if (PolicyEngine::NegotiationTimeoutReached(timeout))
|
||||||
return true;
|
return true;
|
||||||
if (state == policy_engine_state::PESinkSourceUnresponsive)
|
if (state == policy_engine_state::PESinkSourceUnresponsive)
|
||||||
return true;
|
return true;
|
||||||
@@ -48,16 +48,12 @@ public:
|
|||||||
static bool pdHasNegotiated() {
|
static bool pdHasNegotiated() {
|
||||||
if (state == policy_engine_state::PESinkSourceUnresponsive)
|
if (state == policy_engine_state::PESinkSourceUnresponsive)
|
||||||
return false;
|
return false;
|
||||||
if (pdNegotiationComplete)
|
|
||||||
return true;
|
|
||||||
if (PolicyEngine::NegotiationTimeoutReached())
|
|
||||||
return false;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Call this periodically, at least once every second
|
// Call this periodically, at least once every second
|
||||||
static void PPSTimerCallback();
|
static void PPSTimerCallback();
|
||||||
|
|
||||||
static bool NegotiationTimeoutReached();
|
static bool NegotiationTimeoutReached(uint8_t timeout);
|
||||||
|
|
||||||
enum class Notifications {
|
enum class Notifications {
|
||||||
PDB_EVT_PE_RESET = EVENT_MASK(0),
|
PDB_EVT_PE_RESET = EVENT_MASK(0),
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ typedef struct {
|
|||||||
uint8_t minDCVoltageCells; // The voltage we cut out at for under voltage when powered by DC jack
|
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 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 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 OrientationMode : 2; // Selects between Auto,Right and left handed layouts
|
||||||
uint8_t sensitivity : 4; // Sensitivity of accelerometer (5 bits)
|
uint8_t sensitivity : 4; // Sensitivity of accelerometer (5 bits)
|
||||||
uint8_t animationLoop : 1; // Animation loop switch
|
uint8_t animationLoop : 1; // Animation loop switch
|
||||||
@@ -62,6 +61,8 @@ typedef struct {
|
|||||||
uint8_t pdMissingWarningCounter; // Counter of how many times we have warned we cannot detect the pd interface
|
uint8_t pdMissingWarningCounter; // Counter of how many times we have warned we cannot detect the pd interface
|
||||||
char uiLanguage[8]; // Selected UI Language code, null-terminated *only if* the length is less than 8 chars
|
char uiLanguage[8]; // Selected UI Language code, null-terminated *only if* the length is less than 8 chars
|
||||||
|
|
||||||
|
uint8_t PDNegTimeout; // PD timeout in 100ms steps
|
||||||
|
|
||||||
uint32_t padding; // This is here for in case we are not an even divisor so
|
uint32_t padding; // This is here for in case we are not an even divisor so
|
||||||
// that nothing gets cut off
|
// that nothing gets cut off
|
||||||
// MUST BE LAST
|
// MUST BE LAST
|
||||||
|
|||||||
@@ -26,10 +26,10 @@ static bool settings_displayInputMinVRange(void);
|
|||||||
static bool settings_setQCInputV(void);
|
static bool settings_setQCInputV(void);
|
||||||
static bool settings_displayQCInputV(void);
|
static bool settings_displayQCInputV(void);
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef POW_PD
|
||||||
static bool settings_setPDNegTimeout(void);
|
static bool settings_setPDNegTimeout(void);
|
||||||
static bool settings_displayPDNegTimeout(void);
|
static bool settings_displayPDNegTimeout(void);
|
||||||
|
#endif
|
||||||
#ifndef NO_SLEEP_MODE
|
#ifndef NO_SLEEP_MODE
|
||||||
static bool settings_setSleepTemp(void);
|
static bool settings_setSleepTemp(void);
|
||||||
static bool settings_displaySleepTemp(void);
|
static bool settings_displaySleepTemp(void);
|
||||||
@@ -165,7 +165,7 @@ const menuitem rootSettingsMenu[] {
|
|||||||
} // end of menu marker. DO NOT REMOVE
|
} // end of menu marker. DO NOT REMOVE
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined(POW_DC) || defined(POW_QC)
|
#if defined(POW_DC) || defined(POW_QC) || defined(POW_PD)
|
||||||
const menuitem powerMenu[] = {
|
const menuitem powerMenu[] = {
|
||||||
/*
|
/*
|
||||||
* Power Source
|
* Power Source
|
||||||
@@ -177,7 +177,9 @@ const menuitem powerMenu[] = {
|
|||||||
#ifdef POW_QC
|
#ifdef POW_QC
|
||||||
{SETTINGS_DESC(SettingsItemIndex::QCMaxVoltage), settings_setQCInputV, settings_displayQCInputV}, /*Voltage input*/
|
{SETTINGS_DESC(SettingsItemIndex::QCMaxVoltage), settings_setQCInputV, settings_displayQCInputV}, /*Voltage input*/
|
||||||
#endif
|
#endif
|
||||||
{SETTINGS_DESC(SettingsItemIndex::PDNegTimeout), settings_setPDNegTimeout, settings_displayPDNegTimeout}, /*PD timeout setup*/
|
#ifdef POW_PD
|
||||||
|
{SETTINGS_DESC(SettingsItemIndex::PDNegTimeout), settings_setPDNegTimeout, settings_displayPDNegTimeout}, /*PD timeout setup*/
|
||||||
|
#endif
|
||||||
{0, nullptr, nullptr} // end of menu marker. DO NOT REMOVE
|
{0, nullptr, nullptr} // end of menu marker. DO NOT REMOVE
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
@@ -387,6 +389,7 @@ static bool settings_displayQCInputV(void) {
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef POW_PD
|
||||||
static bool settings_setPDNegTimeout(void) {
|
static bool settings_setPDNegTimeout(void) {
|
||||||
systemSettings.PDNegTimeout = (systemSettings.PDNegTimeout + 1) % 50;
|
systemSettings.PDNegTimeout = (systemSettings.PDNegTimeout + 1) % 50;
|
||||||
|
|
||||||
@@ -399,6 +402,7 @@ static bool settings_displayPDNegTimeout(void){
|
|||||||
|
|
||||||
return systemSettings.QCIdealVoltage == 49;
|
return systemSettings.QCIdealVoltage == 49;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef NO_SLEEP_MODE
|
#ifndef NO_SLEEP_MODE
|
||||||
static bool settings_setSleepTemp(void) {
|
static bool settings_setSleepTemp(void) {
|
||||||
|
|||||||
Reference in New Issue
Block a user