Logo rework (#1232)
!Allows for new logo format that supports animation! Also moves logos out of repo into their own repo for ease of management. Changes: * Remove deprecated logos * Draft new Bootloader decoder * Use new logo handler * Simplify logo code further * Fix time bug on static images * Fix exit at end of animation * Docs * Interframe delay in 5ms increments * Quick pass handling empty updates * Exit at the end _after_ the frame delay * One final delay * Fix for overrun of logo data * Fixes https://github.com/Ralim/IronOS-Meta/issues/7
This commit is contained in:
@@ -56,7 +56,7 @@ void reboot();
|
||||
|
||||
// If the user has programmed in a bootup logo, draw it to the screen from flash
|
||||
// Returns 1 if the logo was printed so that the unit waits for the timeout or button
|
||||
uint8_t showBootLogoIfavailable();
|
||||
void showBootLogoIfavailable();
|
||||
// delay wrapper for delay using the hardware timer (used before RTOS)
|
||||
void delay_ms(uint16_t count);
|
||||
// Probe if the Hall sensor is fitted to the unit
|
||||
|
||||
@@ -156,3 +156,5 @@
|
||||
#define NO_SLEEP_MODE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define FLASH_LOGOADDR (0x08000000 + (62 * 1024))
|
||||
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
* logo.c
|
||||
*
|
||||
* Created on: 29 May 2020
|
||||
* Author: Ralim
|
||||
*/
|
||||
|
||||
#include "BSP.h"
|
||||
#include "OLED.hpp"
|
||||
|
||||
static uint8_t logo_page[1024] __attribute__((section(".logo_page")));
|
||||
|
||||
// Logo header signature.
|
||||
#define LOGO_HEADER_VALUE 0xF00DAA55
|
||||
|
||||
uint8_t showBootLogoIfavailable() {
|
||||
// Do not show logo data if signature is not found.
|
||||
if (LOGO_HEADER_VALUE != *(reinterpret_cast<const uint32_t *>(logo_page))) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
OLED::drawAreaSwapped(0, 0, 96, 16, (uint8_t *)(logo_page + 4));
|
||||
OLED::refresh();
|
||||
return 1;
|
||||
}
|
||||
@@ -232,3 +232,5 @@
|
||||
#define TIP_RESISTANCE 45 // x10 ohms, 4.5 typical for ts80 tips
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define FLASH_LOGOADDR (0x08000000 + (62 * 1024))
|
||||
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
* logo.c
|
||||
*
|
||||
* Created on: 29 May 2020
|
||||
* Author: Ralim
|
||||
*/
|
||||
|
||||
#include "BSP.h"
|
||||
#include "OLED.hpp"
|
||||
|
||||
static uint8_t logo_page[1024] __attribute__((section(".logo_page")));
|
||||
|
||||
// Logo header signature.
|
||||
#define LOGO_HEADER_VALUE 0xF00DAA55
|
||||
|
||||
uint8_t showBootLogoIfavailable() {
|
||||
// Do not show logo data if signature is not found.
|
||||
if (LOGO_HEADER_VALUE != *(reinterpret_cast<const uint32_t *>(logo_page))) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
OLED::drawAreaSwapped(0, 0, 96, 16, (uint8_t *)(logo_page + 4));
|
||||
OLED::refresh();
|
||||
return 1;
|
||||
}
|
||||
@@ -151,3 +151,5 @@
|
||||
#define TIP_RESISTANCE 75 // x10 ohms, 7.5 typical for Pinecil tips
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define FLASH_LOGOADDR (0x08000000 + (126 * 1024))
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
/*
|
||||
* logo.c
|
||||
*
|
||||
* Created on: 29 May 2020
|
||||
* Author: Ralim
|
||||
*/
|
||||
|
||||
#include "BSP.h"
|
||||
#include "OLED.hpp"
|
||||
// Second last page of flash set aside for logo image.
|
||||
#define FLASH_LOGOADDR (0x08000000 + (126 * 1024))
|
||||
// Logo header signature.
|
||||
#define LOGO_HEADER_VALUE 0xF00DAA55
|
||||
|
||||
uint8_t showBootLogoIfavailable() {
|
||||
// Do not show logo data if signature is not found.
|
||||
if (LOGO_HEADER_VALUE != *(reinterpret_cast<const uint32_t *>(FLASH_LOGOADDR))) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
OLED::drawAreaSwapped(0, 0, 96, 16, (uint8_t *)(FLASH_LOGOADDR + 4));
|
||||
OLED::refresh();
|
||||
return 1;
|
||||
}
|
||||
84
source/Core/Drivers/BootLogo.cpp
Normal file
84
source/Core/Drivers/BootLogo.cpp
Normal file
@@ -0,0 +1,84 @@
|
||||
#include "BootLogo.h"
|
||||
#include "BSP.h"
|
||||
#include "Buttons.hpp"
|
||||
#include "OLED.hpp"
|
||||
#include "cmsis_os.h"
|
||||
#define LOGO_PAGE_LENGTH 1024
|
||||
void BootLogo::handleShowingLogo(const uint8_t *ptrLogoArea) {
|
||||
// Read the first few bytes and figure out what format we are looking at
|
||||
if (OLD_LOGO_HEADER_VALUE == *(reinterpret_cast<const uint32_t *>(ptrLogoArea))) {
|
||||
showOldFormat(ptrLogoArea);
|
||||
} else if (ptrLogoArea[0] == 0xAA) {
|
||||
showNewFormat(ptrLogoArea + 1);
|
||||
}
|
||||
OLED::clearScreen();
|
||||
OLED::refresh();
|
||||
}
|
||||
|
||||
void BootLogo::showOldFormat(const uint8_t *ptrLogoArea) {
|
||||
|
||||
OLED::drawAreaSwapped(0, 0, 96, 16, (uint8_t *)(ptrLogoArea + 4));
|
||||
OLED::refresh();
|
||||
|
||||
// Delay here until button is pressed or its been 4 seconds
|
||||
waitForButtonPressOrTimeout(TICKS_SECOND * 4);
|
||||
}
|
||||
|
||||
void BootLogo::showNewFormat(const uint8_t *ptrLogoArea) {
|
||||
// New logo format (a) fixes long standing byte swap quirk and (b) supports animation
|
||||
uint8_t interFrameDelay = ptrLogoArea[0];
|
||||
OLED::clearScreen();
|
||||
ButtonState buttons = getButtonState();
|
||||
|
||||
// Now draw in the frames
|
||||
int position = 1;
|
||||
do {
|
||||
|
||||
int len = (showNewFrame(ptrLogoArea + position));
|
||||
OLED::refresh();
|
||||
position += len;
|
||||
buttons = getButtonState();
|
||||
|
||||
// Button pressed
|
||||
if (buttons != BUTTON_NONE) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (interFrameDelay) {
|
||||
osDelay(interFrameDelay * 5);
|
||||
} else {
|
||||
// Delay here until button is pressed or its been 4 seconds
|
||||
waitForButtonPressOrTimeout(TICKS_SECOND * 4);
|
||||
return;
|
||||
}
|
||||
// If this was an early exit; bail now
|
||||
if (len == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
} while (position < 1022); // 1024 less the header type byte and the inter-frame-delay
|
||||
}
|
||||
int BootLogo::showNewFrame(const uint8_t *ptrLogoArea) {
|
||||
uint8_t length = ptrLogoArea[0];
|
||||
|
||||
if (length == 0xFF) {
|
||||
// Full frame update
|
||||
OLED::drawArea(0, 0, 96, 16, ptrLogoArea + 1);
|
||||
length = 96;
|
||||
} else if (length == 0xFE) {
|
||||
return 1;
|
||||
} else if (length == 0) {
|
||||
return 0; // end
|
||||
} else {
|
||||
length /= 2;
|
||||
// Draw length patches
|
||||
for (int p = 0; p < length; p++) {
|
||||
uint8_t index = ptrLogoArea[1 + (p * 2)];
|
||||
uint8_t value = ptrLogoArea[2 + (p * 2)];
|
||||
OLED::drawArea(index % 96, index >= 96 ? 8 : 0, 1, 8, &value);
|
||||
}
|
||||
}
|
||||
|
||||
OLED::refresh();
|
||||
return (length * 2) + 1;
|
||||
}
|
||||
17
source/Core/Drivers/BootLogo.h
Normal file
17
source/Core/Drivers/BootLogo.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef DRIVERS_BOOTLOGO_H_
|
||||
#define DRIVERS_BOOTLOGO_H_
|
||||
|
||||
// Wrapper for handling showing a bootlogo
|
||||
#include <stdint.h>
|
||||
#define OLD_LOGO_HEADER_VALUE 0xF00DAA55
|
||||
class BootLogo {
|
||||
public:
|
||||
static void handleShowingLogo(const uint8_t *ptrLogoArea);
|
||||
|
||||
private:
|
||||
static void showOldFormat(const uint8_t *ptrLogoArea);
|
||||
static void showNewFormat(const uint8_t *ptrLogoArea);
|
||||
static int showNewFrame(const uint8_t *ptrLogoArea);
|
||||
};
|
||||
|
||||
#endif // DRIVERS_BOOTLOGO_H_
|
||||
@@ -7,6 +7,7 @@
|
||||
extern "C" {
|
||||
#include "FreeRTOSConfig.h"
|
||||
}
|
||||
#include "BootLogo.h"
|
||||
#include "Buttons.hpp"
|
||||
#include "I2CBB.hpp"
|
||||
#include "LIS2DH12.hpp"
|
||||
@@ -859,16 +860,8 @@ void startGUITask(void const *argument) {
|
||||
}
|
||||
getTipRawTemp(1); // reset filter
|
||||
OLED::setRotation(getSettingValue(SettingsOptions::OrientationMode) & 1);
|
||||
uint32_t ticks = xTaskGetTickCount();
|
||||
ticks += (TICKS_SECOND * 4); // 4 seconds from now
|
||||
while (xTaskGetTickCount() < ticks) {
|
||||
if (showBootLogoIfavailable() == false)
|
||||
ticks = xTaskGetTickCount();
|
||||
ButtonState buttons = getButtonState();
|
||||
if (buttons)
|
||||
ticks = xTaskGetTickCount(); // make timeout now so we will exit
|
||||
GUIDelay();
|
||||
}
|
||||
|
||||
BootLogo::handleShowingLogo((uint8_t *)FLASH_LOGOADDR);
|
||||
|
||||
showWarnings();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user