mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
Implement optional looping for animated boot logo [#1839]
This commit is contained in:
@@ -3,10 +3,11 @@
|
|||||||
#include "Buttons.hpp"
|
#include "Buttons.hpp"
|
||||||
#include "OLED.hpp"
|
#include "OLED.hpp"
|
||||||
#include "cmsis_os.h"
|
#include "cmsis_os.h"
|
||||||
|
|
||||||
#define LOGO_PAGE_LENGTH 1024
|
#define LOGO_PAGE_LENGTH 1024
|
||||||
|
|
||||||
void delay() {
|
void delay() {
|
||||||
if (getSettingValue(SettingsOptions::LOGOTime) == 5) {
|
if (getSettingValue(SettingsOptions::LOGOTime) >= logoMode_t::ONETIME) {
|
||||||
waitForButtonPress();
|
waitForButtonPress();
|
||||||
} else {
|
} else {
|
||||||
waitForButtonPressOrTimeout(TICKS_SECOND * getSettingValue(SettingsOptions::LOGOTime));
|
waitForButtonPressOrTimeout(TICKS_SECOND * getSettingValue(SettingsOptions::LOGOTime));
|
||||||
@@ -20,60 +21,75 @@ void BootLogo::handleShowingLogo(const uint8_t *ptrLogoArea) {
|
|||||||
} else if (ptrLogoArea[0] == 0xAA) {
|
} else if (ptrLogoArea[0] == 0xAA) {
|
||||||
showNewFormat(ptrLogoArea + 1);
|
showNewFormat(ptrLogoArea + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
OLED::clearScreen();
|
OLED::clearScreen();
|
||||||
OLED::refresh();
|
OLED::refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BootLogo::showOldFormat(const uint8_t *ptrLogoArea) {
|
void BootLogo::showOldFormat(const uint8_t *ptrLogoArea) {
|
||||||
|
|
||||||
OLED::drawAreaSwapped(0, 0, 96, 16, (uint8_t *)(ptrLogoArea + 4));
|
OLED::drawAreaSwapped(0, 0, 96, 16, (uint8_t *)(ptrLogoArea + 4));
|
||||||
OLED::refresh();
|
OLED::refresh();
|
||||||
|
// Delay here with static logo until a button is pressed or its been the amount of seconds set by the user
|
||||||
// Delay here until button is pressed or its been the amount of seconds set by the user
|
|
||||||
delay();
|
delay();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BootLogo::showNewFormat(const uint8_t *ptrLogoArea) {
|
void BootLogo::showNewFormat(const uint8_t *ptrLogoArea) {
|
||||||
if (getSettingValue(SettingsOptions::LOGOTime) == 0) {
|
if (getSettingValue(SettingsOptions::LOGOTime) == logoMode_t::SKIP) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// New logo format (a) fixes long standing byte swap quirk and (b) supports animation
|
// New logo format (a) fixes long standing byte swap quirk and (b) supports animation
|
||||||
uint8_t interFrameDelay = ptrLogoArea[0];
|
uint8_t interFrameDelay = ptrLogoArea[0];
|
||||||
OLED::clearScreen();
|
OLED::clearScreen();
|
||||||
ButtonState buttons = getButtonState();
|
|
||||||
|
|
||||||
// Now draw in the frames
|
// Now draw in the frames
|
||||||
int position = 1;
|
int position = 1;
|
||||||
do {
|
while (getButtonState() == BUTTON_NONE) {
|
||||||
|
|
||||||
int len = (showNewFrame(ptrLogoArea + position));
|
int len = (showNewFrame(ptrLogoArea + position));
|
||||||
OLED::refresh();
|
OLED::refresh();
|
||||||
position += len;
|
position += len;
|
||||||
buttons = getButtonState();
|
|
||||||
|
|
||||||
if (interFrameDelay) {
|
if (interFrameDelay) {
|
||||||
osDelay(interFrameDelay * 4);
|
osDelay(interFrameDelay * 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1024 less the header type byte and the inter-frame-delay
|
// 1024 less the header type byte and the inter-frame-delay
|
||||||
if (getSettingValue(SettingsOptions::LOGOTime) > 0 && (position >= 1022 || len == 0)) {
|
if (getSettingValue(SettingsOptions::LOGOTime) && (position >= 1022 || len == 0)) {
|
||||||
// Delay here until button is pressed or its been the amount of seconds set by the user
|
// Animated logo stops here ...
|
||||||
|
if (getSettingValue(SettingsOptions::LOGOTime) == logoMode_t::INFINITY) {
|
||||||
|
// ... but if it's infinite logo setting then keep it rolling over again until a button is pressed
|
||||||
|
osDelay(4 * TICKS_100MS);
|
||||||
|
OLED::clearScreen();
|
||||||
|
position = 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Animation in progress so jumping to the next frame
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Static logo case ends up right here, so delay until a button is pressed or its been the amount of seconds set by the user
|
||||||
delay();
|
delay();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} while (buttons == BUTTON_NONE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int BootLogo::showNewFrame(const uint8_t *ptrLogoArea) {
|
int BootLogo::showNewFrame(const uint8_t *ptrLogoArea) {
|
||||||
uint8_t length = ptrLogoArea[0];
|
uint8_t length = ptrLogoArea[0];
|
||||||
|
switch (length) {
|
||||||
if (length == 0xFF) {
|
case 0:
|
||||||
|
// End
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
|
case 0xFE:
|
||||||
|
return 1;
|
||||||
|
break;
|
||||||
|
case 0xFF:
|
||||||
// Full frame update
|
// Full frame update
|
||||||
OLED::drawArea(0, 0, 96, 16, ptrLogoArea + 1);
|
OLED::drawArea(0, 0, 96, 16, ptrLogoArea + 1);
|
||||||
length = 96;
|
length = 96;
|
||||||
} else if (length == 0xFE) {
|
break;
|
||||||
return 1;
|
default:
|
||||||
} else if (length == 0) {
|
|
||||||
return 0; // end
|
|
||||||
} else {
|
|
||||||
length /= 2;
|
length /= 2;
|
||||||
// Draw length patches
|
// Draw length patches
|
||||||
for (int p = 0; p < length; p++) {
|
for (int p = 0; p < length; p++) {
|
||||||
|
|||||||
@@ -92,6 +92,12 @@ typedef enum {
|
|||||||
AUTO = 2, // Automatic screen orientation based on accel.data if presented
|
AUTO = 2, // Automatic screen orientation based on accel.data if presented
|
||||||
} orientationMode_t;
|
} orientationMode_t;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
SKIP = 0, // Skip boot logo
|
||||||
|
ONETIME = 5, // Show boot logo once (if animated) and stall until a button toggled
|
||||||
|
INFINITY = 6, // Show boot logo on repeat (if animated) until a button toggled
|
||||||
|
} logoMode_t;
|
||||||
|
|
||||||
// Settings wide operations
|
// Settings wide operations
|
||||||
void saveSettings();
|
void saveSettings();
|
||||||
bool loadSettings();
|
bool loadSettings();
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ static const SettingConstants settingsConstants[(int)SettingsOptions::SettingsOp
|
|||||||
{0, 50, 1, 20}, // PDNegTimeout
|
{0, 50, 1, 20}, // PDNegTimeout
|
||||||
{0, 1, 1, 0}, // OLEDInversion
|
{0, 1, 1, 0}, // OLEDInversion
|
||||||
{MIN_BRIGHTNESS, MAX_BRIGHTNESS, BRIGHTNESS_STEP, DEFAULT_BRIGHTNESS}, // OLEDBrightness
|
{MIN_BRIGHTNESS, MAX_BRIGHTNESS, BRIGHTNESS_STEP, DEFAULT_BRIGHTNESS}, // OLEDBrightness
|
||||||
{0, 5, 1, 1}, // LOGOTime
|
{0, 6, 1, 1}, // LOGOTime
|
||||||
{0, 1, 1, 0}, // CalibrateCJC
|
{0, 1, 1, 0}, // CalibrateCJC
|
||||||
{0, 1, 1, 1}, // BluetoothLE
|
{0, 1, 1, 1}, // BluetoothLE
|
||||||
{0, 1, 1, 1}, // PDVpdo
|
{0, 1, 1, 1}, // PDVpdo
|
||||||
|
|||||||
@@ -837,13 +837,20 @@ static void displayInvertColor(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void displayLogoTime(void) {
|
static void displayLogoTime(void) {
|
||||||
if (getSettingValue(SettingsOptions::LOGOTime) == 0) {
|
switch (getSettingValue(SettingsOptions::LOGOTime)) {
|
||||||
|
case logoMode_t::SKIP:
|
||||||
OLED::print(translatedString(Tr->OffString), FontStyle::LARGE);
|
OLED::print(translatedString(Tr->OffString), FontStyle::LARGE);
|
||||||
} else if (getSettingValue(SettingsOptions::LOGOTime) == 5) {
|
break;
|
||||||
|
case logoMode_t::ONETIME:
|
||||||
|
OLED::printNumber(1, 3, FontStyle::LARGE);
|
||||||
|
break;
|
||||||
|
case logoMode_t::INFINITY:
|
||||||
OLED::drawArea(OLED_WIDTH - 24 - 2, 0, 24, 16, infinityIcon);
|
OLED::drawArea(OLED_WIDTH - 24 - 2, 0, 24, 16, infinityIcon);
|
||||||
} else {
|
break;
|
||||||
|
default:
|
||||||
OLED::printNumber(getSettingValue(SettingsOptions::LOGOTime), 2, FontStyle::LARGE);
|
OLED::printNumber(getSettingValue(SettingsOptions::LOGOTime), 2, FontStyle::LARGE);
|
||||||
OLED::print(LargeSymbolSeconds, FontStyle::LARGE);
|
OLED::print(LargeSymbolSeconds, FontStyle::LARGE);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ extern "C" {
|
|||||||
#include "USBPD.h"
|
#include "USBPD.h"
|
||||||
#include "pd.h"
|
#include "pd.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// File local variables
|
// File local variables
|
||||||
|
|
||||||
extern bool heaterThermalRunaway;
|
extern bool heaterThermalRunaway;
|
||||||
@@ -63,14 +64,13 @@ void startGUITask(void const *argument) {
|
|||||||
performCJCC();
|
performCJCC();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint16_t logoMode = getSettingValue(SettingsOptions::LOGOTime);
|
||||||
|
uint16_t startMode = getSettingValue(SettingsOptions::AutoStartMode);
|
||||||
// If the boot logo is enabled (but it times out) and the autostart mode is enabled (but not set to sleep w/o heat), start heating during boot logo
|
// If the boot logo is enabled (but it times out) and the autostart mode is enabled (but not set to sleep w/o heat), start heating during boot logo
|
||||||
if (getSettingValue(SettingsOptions::LOGOTime) > 0 && getSettingValue(SettingsOptions::LOGOTime) < 5 && getSettingValue(SettingsOptions::AutoStartMode) > 0
|
if (logoMode && logoMode < logoMode_t::ONETIME && startMode && startMode < autoStartMode_t::ZERO) {
|
||||||
&& getSettingValue(SettingsOptions::AutoStartMode) < 3) {
|
uint16_t sleepTempDegC = getSettingValue(SettingsOptions::SleepTemp);
|
||||||
uint16_t sleepTempDegC;
|
|
||||||
if (getSettingValue(SettingsOptions::TemperatureInF)) {
|
if (getSettingValue(SettingsOptions::TemperatureInF)) {
|
||||||
sleepTempDegC = TipThermoModel::convertFtoC(getSettingValue(SettingsOptions::SleepTemp));
|
sleepTempDegC = TipThermoModel::convertFtoC(sleepTempDegC);
|
||||||
} else {
|
|
||||||
sleepTempDegC = getSettingValue(SettingsOptions::SleepTemp);
|
|
||||||
}
|
}
|
||||||
// Only heat to sleep temperature (but no higher than 75°C for safety)
|
// Only heat to sleep temperature (but no higher than 75°C for safety)
|
||||||
currentTempTargetDegC = min(sleepTempDegC, 75);
|
currentTempTargetDegC = min(sleepTempDegC, 75);
|
||||||
|
|||||||
Reference in New Issue
Block a user