port to platformio
This commit is contained in:
53
src/Config.h
Normal file
53
src/Config.h
Normal file
@@ -0,0 +1,53 @@
|
||||
#pragma once
|
||||
#include <Figments.h>
|
||||
|
||||
//#define PLATFORM_PHOTON
|
||||
#define PLATFORM_ARDUINO
|
||||
|
||||
struct HardwareConfig {
|
||||
uint8_t version = 2;
|
||||
uint8_t checksum = 0;
|
||||
struct TaskState {
|
||||
char name[16] = {0};
|
||||
bool isDisabled = false;
|
||||
};
|
||||
struct Data {
|
||||
uint16_t pixelCount = 255;
|
||||
uint16_t startPixel = 0;
|
||||
uint8_t lastRed = 255;
|
||||
uint8_t lastGreen = 255;
|
||||
uint8_t lastBlue = 255;
|
||||
char lastScene[16] = {0};
|
||||
TaskState serviceStates[32];
|
||||
};
|
||||
Data data;
|
||||
|
||||
static HardwareConfig load();
|
||||
void save();
|
||||
bool isValid() const;
|
||||
|
||||
LinearCoordinateMapping toCoordMap() const;
|
||||
|
||||
static constexpr uint16_t MAX_LED_NUM = 255;
|
||||
static constexpr bool HAS_MPU_6050 = false;
|
||||
|
||||
private:
|
||||
uint8_t getCRC() const;
|
||||
|
||||
static constexpr uint8_t CRC7_POLY = 0x91;
|
||||
};
|
||||
|
||||
// A task that manages the EEPROM settings and coord mapping when modified via
|
||||
// Particle. This allows for multiple devices with wildly different displays to
|
||||
// run the same code
|
||||
struct ConfigService: public Task {
|
||||
ConfigService() : Task("Configuration") {}
|
||||
void onStart();
|
||||
void loop() override;
|
||||
void handleEvent(const InputEvent &evt) override;
|
||||
const LinearCoordinateMapping* coordMap() const { return &m_coordMap; }
|
||||
|
||||
private:
|
||||
HardwareConfig m_config;
|
||||
LinearCoordinateMapping m_coordMap;
|
||||
};
|
Reference in New Issue
Block a user