#pragma once #include //#define PLATFORM_PHOTON //#define PLATFORM_ARDUINO #define RENDERBUG_VERSION 2 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; #ifdef PLATFORM_PHOTON static constexpr bool HAS_MPU_6050 = true; #else static constexpr bool HAS_MPU_6050 = false; #endif 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; };