* Basic Init * Rought implementation of fs2711 usb pd interface * Rought implementation of fs2711 usb pd interface * Still needs work overcurrent protection keeps getting tripped * New pdo selection logic * Update push.yml * Update push.yml * Update push.yml * Update Makefile * Adds PPS * Removed unused define * Adds PPS * Apply suggestions from code review Co-authored-by: Ben V. Brown <5425387+Ralim@users.noreply.github.com> * Code review changes * Added osDelay include * New line alignment for S60 softwarei2c * Code review * Fixes code review stuff * code review changes * Change voltage limit to 20 as that's what the device is rated for * Shortened wait time for usb pd * Fixed issues that cuase S60P to restart constantly * fixing minimal OLED brightness With the current settings, the OLED turns off if the first level is selected. * Adds protocol to s60p debug menu * loosened fs2711 protocol selection timing * Adds PDO register reading to negotiation logic * Fixes FS2711 timeout issue and cleans up driver * Adds FS2711 protocol negotiation to power loop * Removed uneeded define * Reverts changes to Font.h and adds clang-format comments --------- Co-authored-by: Ben V. Brown <Ralim@Ralimtek.com> Co-authored-by: discip <53649486+discip@users.noreply.github.com> Co-authored-by: Ben V. Brown <5425387+Ralim@users.noreply.github.com>
113 lines
3.3 KiB
C++
113 lines
3.3 KiB
C++
#include "FS2711.hpp"
|
|
#include "HUB238.hpp"
|
|
#include "OperatingModes.h"
|
|
OperatingMode showWarnings(const ButtonState buttons, guiContext *cxt) {
|
|
// Display alert if settings were reset
|
|
|
|
switch (cxt->scratch_state.state1) {
|
|
case 0: // Settings reset warning
|
|
if (settingsWereReset) {
|
|
if (warnUser(translatedString(Tr->SettingsResetMessage), buttons)) {
|
|
settingsWereReset = false;
|
|
cxt->scratch_state.state1 = 1;
|
|
}
|
|
} else {
|
|
cxt->scratch_state.state1 = 1;
|
|
}
|
|
break;
|
|
case 1: // Device validations
|
|
#ifdef DEVICE_HAS_VALIDATION_SUPPORT
|
|
if (getDeviceValidationStatus()) {
|
|
// Warn user this device might be counterfeit
|
|
if (warnUser(translatedString(Tr->DeviceFailedValidationWarning), buttons)) {
|
|
cxt->scratch_state.state1 = 2;
|
|
}
|
|
} else {
|
|
cxt->scratch_state.state1 = 2;
|
|
}
|
|
#else
|
|
cxt->scratch_state.state1 = 2;
|
|
#endif
|
|
break;
|
|
case 2: // Accelerometer detection
|
|
if (DetectedAccelerometerVersion == AccelType::Scanning) {
|
|
break;
|
|
}
|
|
// Display alert if accelerometer is not detected
|
|
if (DetectedAccelerometerVersion == AccelType::None) {
|
|
if (getSettingValue(SettingsOptions::AccelMissingWarningCounter) < 2) {
|
|
|
|
if (warnUser(translatedString(Tr->NoAccelerometerMessage), buttons)) {
|
|
cxt->scratch_state.state1 = 3;
|
|
nextSettingValue(SettingsOptions::AccelMissingWarningCounter);
|
|
saveSettings();
|
|
}
|
|
} else {
|
|
cxt->scratch_state.state1 = 3;
|
|
}
|
|
} else {
|
|
cxt->scratch_state.state1 = 3;
|
|
}
|
|
break;
|
|
case 3:
|
|
|
|
#ifdef POW_PD
|
|
// We expect pd to be present
|
|
if (!USBPowerDelivery::fusbPresent()) {
|
|
if (getSettingValue(SettingsOptions::PDMissingWarningCounter) < 2) {
|
|
if (warnUser(translatedString(Tr->NoPowerDeliveryMessage), buttons)) {
|
|
nextSettingValue(SettingsOptions::PDMissingWarningCounter);
|
|
saveSettings();
|
|
cxt->scratch_state.state1 = 4;
|
|
}
|
|
} else {
|
|
cxt->scratch_state.state1 = 4;
|
|
}
|
|
} else {
|
|
cxt->scratch_state.state1 = 4;
|
|
}
|
|
#else
|
|
#if POW_PD_EXT == 1
|
|
if (!hub238_probe()) {
|
|
if (getSettingValue(SettingsOptions::PDMissingWarningCounter) < 2) {
|
|
if (warnUser(translatedString(Tr->NoPowerDeliveryMessage), buttons)) {
|
|
cxt->scratch_state.state1 = 4;
|
|
nextSettingValue(SettingsOptions::PDMissingWarningCounter);
|
|
saveSettings();
|
|
}
|
|
} else {
|
|
cxt->scratch_state.state1 = 4;
|
|
}
|
|
} else {
|
|
cxt->scratch_state.state1 = 4;
|
|
}
|
|
#else
|
|
#if POW_PD_EXT == 2
|
|
if (!FS2711::probe()) {
|
|
if (getSettingValue(SettingsOptions::PDMissingWarningCounter) < 2) {
|
|
if (warnUser(translatedString(Tr->NoPowerDeliveryMessage), buttons)) {
|
|
cxt->scratch_state.state1 = 4;
|
|
nextSettingValue(SettingsOptions::PDMissingWarningCounter);
|
|
saveSettings();
|
|
}
|
|
} else {
|
|
cxt->scratch_state.state1 = 4;
|
|
}
|
|
} else {
|
|
cxt->scratch_state.state1 = 4;
|
|
}
|
|
#else
|
|
cxt->scratch_state.state1 = 4;
|
|
#endif /*POW_PD_EXT==1*/
|
|
#endif /*POW_PD_EXT==2*/
|
|
#endif /*POW_PD*/
|
|
|
|
break;
|
|
default:
|
|
// We are off the end, warnings done
|
|
return OperatingMode::StartupLogo;
|
|
}
|
|
|
|
return OperatingMode::StartupWarnings; // Stay in warnings
|
|
}
|