1
0
forked from me/IronOS
Files
IronOS/source/Core/Threads/UI/logic/ShowStartupWarnings.cpp
Ben V. Brown 48649908a7 WIP: Split Render for multiple screen resolutions (#1888)
* Create README.md

* Move to new folder

* Migrating

* Migrate Remainder

* format fix (all but one) (#1889)

* Update USBPDDebug_FS2711.cpp

* Delete PrintVoltage.cpp

* Copy in 128x32 template

* Mask drawing for 96x16

* Import #1819

* Update Font.h

* Homescreen

* Update draw_homescreen_detailed.cpp

* Fix oled normal draw for variable height

* Update OLED.cpp

* Draw settings icons

* Update draw_homescreen_simplified.cpp

* Update draw_power_source_icon.cpp

* Fixup oled drawing for fill area

* Update the region fill for mixed heights

* Fix newline height

* FIXUP! Draw icons in settings menu at correct size

* Fix scrollbar

* Update settingsGUI.cpp

* S60(P) Disable auto display rotation

* On tall oled, scroll in 2 line increments

* Bugfix transition L<->R

@discip I take it back, there was a bug :)

* Draw every other one on transitions

* .

* cleanup

* Bootup logo: Draw in centre

* Update OLED.hpp

---------

Co-authored-by: discip <53649486+discip@users.noreply.github.com>
2024-07-12 08:27:05 +10:00

114 lines
3.3 KiB
C++

#include "FS2711.hpp"
#include "HUB238.hpp"
#include "OperatingModes.h"
#include "ui_drawing.hpp"
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
}