exercises: add Exercise 08 SystemStartup scaffold with early SPI deselect and SD/OLED startup orchestration
This commit is contained in:
parent
2aec641fc2
commit
322a77bfe4
9 changed files with 720 additions and 0 deletions
|
|
@ -0,0 +1,46 @@
|
|||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
#include "StartupSdManager.h"
|
||||
|
||||
// Convenience alias so sketches can use System.println(...) style logging.
|
||||
// Arduino exposes Serial, not System, so map System -> Serial.
|
||||
#ifndef System
|
||||
#define System Serial
|
||||
#endif
|
||||
|
||||
enum class SystemEvent : uint8_t {
|
||||
BOOTING = 0,
|
||||
SD_MISSING,
|
||||
SD_READY,
|
||||
SD_REMOVED
|
||||
};
|
||||
|
||||
using SystemEventCallback = void (*)(SystemEvent event, const char* message);
|
||||
|
||||
struct SystemStartupConfig {
|
||||
uint32_t serialDelayMs = 5000;
|
||||
SdWatcherConfig sd{};
|
||||
};
|
||||
|
||||
class SystemStartup {
|
||||
public:
|
||||
explicit SystemStartup(Print& serial = Serial);
|
||||
|
||||
bool begin(const SystemStartupConfig& cfg = SystemStartupConfig{}, SystemEventCallback callback = nullptr);
|
||||
void update();
|
||||
|
||||
bool isSdMounted() const { return sd_.isMounted(); }
|
||||
StartupSdManager& sdManager() { return sd_; }
|
||||
|
||||
private:
|
||||
static void onSdEventThunk(SdEvent event, const char* message);
|
||||
void onSdEvent(SdEvent event, const char* message);
|
||||
void emit(SystemEvent event, const char* message);
|
||||
void oledShow3(const char* l1, const char* l2 = nullptr, const char* l3 = nullptr);
|
||||
|
||||
Print& serial_;
|
||||
SystemStartupConfig cfg_{};
|
||||
SystemEventCallback callback_ = nullptr;
|
||||
StartupSdManager sd_;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue