Show loading bootsplash with firmware name and version (#18)
Bootsplash is displayed before EEPROM erase, which is a slow operation. Reviewed-on: https://git.pinkduck.xyz/awonak/libGravity/pulls/18
This commit is contained in:
@ -64,6 +64,10 @@ void setup() {
|
|||||||
// Start Gravity.
|
// Start Gravity.
|
||||||
gravity.Init();
|
gravity.Init();
|
||||||
|
|
||||||
|
// Show bootsplash when initializing firmware.
|
||||||
|
Bootsplash();
|
||||||
|
delay(2000);
|
||||||
|
|
||||||
// Initialize the state manager. This will load settings from EEPROM
|
// Initialize the state manager. This will load settings from EEPROM
|
||||||
stateManager.initialize(app);
|
stateManager.initialize(app);
|
||||||
InitGravity(app);
|
InitGravity(app);
|
||||||
@ -219,7 +223,9 @@ void HandleEncoderPressed() {
|
|||||||
}
|
}
|
||||||
if (app.selected_param == PARAM_MAIN_FACTORY_RESET) {
|
if (app.selected_param == PARAM_MAIN_FACTORY_RESET) {
|
||||||
if (app.selected_sub_param == 0) { // Reset
|
if (app.selected_sub_param == 0) { // Reset
|
||||||
|
Bootsplash();
|
||||||
stateManager.factoryReset();
|
stateManager.factoryReset();
|
||||||
|
stateManager.reset(app);
|
||||||
InitGravity(app);
|
InitGravity(app);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -469,4 +469,21 @@ void UpdateDisplay() {
|
|||||||
} while (gravity.display.nextPage());
|
} while (gravity.display.nextPage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Bootsplash() {
|
||||||
|
gravity.display.firstPage();
|
||||||
|
do {
|
||||||
|
int textWidth;
|
||||||
|
gravity.display.setFont(TEXT_FONT);
|
||||||
|
|
||||||
|
textWidth = gravity.display.getStrWidth(SKETCH_NAME);
|
||||||
|
gravity.display.drawStr(24 + (textWidth / 2), 24, SKETCH_NAME);
|
||||||
|
|
||||||
|
textWidth = gravity.display.getStrWidth(SEMANTIC_VERSION);
|
||||||
|
gravity.display.drawStr(24 + (textWidth / 2), 36, SEMANTIC_VERSION);
|
||||||
|
|
||||||
|
textWidth = gravity.display.getStrWidth("LOADING....");
|
||||||
|
gravity.display.drawStr(34 + (textWidth / 2), 48, "LOADING....");
|
||||||
|
} while (gravity.display.nextPage());
|
||||||
|
}
|
||||||
|
|
||||||
#endif // DISPLAY_H
|
#endif // DISPLAY_H
|
||||||
|
|||||||
@ -105,7 +105,7 @@ bool StateManager::_isDataValid() {
|
|||||||
Metadata load_meta;
|
Metadata load_meta;
|
||||||
EEPROM.get(METADATA_START_ADDR, load_meta);
|
EEPROM.get(METADATA_START_ADDR, load_meta);
|
||||||
bool name_match = (strcmp(load_meta.sketch_name, SKETCH_NAME) == 0);
|
bool name_match = (strcmp(load_meta.sketch_name, SKETCH_NAME) == 0);
|
||||||
bool version_match = (load_meta.version == SKETCH_VERSION);
|
bool version_match = (strcmp(load_meta.version, SEMANTIC_VERSION) == 0);
|
||||||
return name_match && version_match;
|
return name_match && version_match;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,7 +184,7 @@ void StateManager::_saveMetadata(const AppState& app) {
|
|||||||
noInterrupts();
|
noInterrupts();
|
||||||
Metadata current_meta;
|
Metadata current_meta;
|
||||||
strcpy(current_meta.sketch_name, SKETCH_NAME);
|
strcpy(current_meta.sketch_name, SKETCH_NAME);
|
||||||
current_meta.version = SKETCH_VERSION;
|
strcpy(current_meta.version, SEMANTIC_VERSION);
|
||||||
|
|
||||||
// Global user settings
|
// Global user settings
|
||||||
current_meta.selected_save_slot = app.selected_save_slot;
|
current_meta.selected_save_slot = app.selected_save_slot;
|
||||||
|
|||||||
@ -19,8 +19,8 @@
|
|||||||
struct AppState;
|
struct AppState;
|
||||||
|
|
||||||
// Define the constants for the current firmware.
|
// Define the constants for the current firmware.
|
||||||
const char SKETCH_NAME[] = "AltGravity";
|
const char SKETCH_NAME[] = "ALT GRAVITY";
|
||||||
const byte SKETCH_VERSION = 1;
|
const char SEMANTIC_VERSION[] = "V2.0.0BETA1";
|
||||||
|
|
||||||
// Number of available save slots.
|
// Number of available save slots.
|
||||||
const byte MAX_SAVE_SLOTS = 10; // Count of save slots 0 - 9 to save/load presets.
|
const byte MAX_SAVE_SLOTS = 10; // Count of save slots 0 - 9 to save/load presets.
|
||||||
@ -58,8 +58,8 @@ class StateManager {
|
|||||||
|
|
||||||
// This struct holds the data that identifies the firmware version.
|
// This struct holds the data that identifies the firmware version.
|
||||||
struct Metadata {
|
struct Metadata {
|
||||||
byte version;
|
|
||||||
char sketch_name[16];
|
char sketch_name[16];
|
||||||
|
char version[16];
|
||||||
// Additional global/hardware settings
|
// Additional global/hardware settings
|
||||||
byte selected_save_slot;
|
byte selected_save_slot;
|
||||||
bool encoder_reversed;
|
bool encoder_reversed;
|
||||||
|
|||||||
Reference in New Issue
Block a user