Exercise 10 works now, #9 needs to be revised accordingly
This commit is contained in:
parent
3b15b0aeef
commit
0077381546
12 changed files with 1775 additions and 0 deletions
46
exercises/09_GPS_Time/lib/system_startup/SystemStartup.h
Normal file
46
exercises/09_GPS_Time/lib/system_startup/SystemStartup.h
Normal file
|
|
@ -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