2019-05-10 05:17:29 +00:00
|
|
|
#pragma once
|
2021-03-29 08:10:55 +00:00
|
|
|
#include <Figments.h>
|
|
|
|
|
|
|
|
//#define PLATFORM_PHOTON
|
2021-03-31 18:50:00 +00:00
|
|
|
//#define PLATFORM_ARDUINO
|
|
|
|
#define RENDERBUG_VERSION 2
|
2019-05-10 05:17:29 +00:00
|
|
|
|
|
|
|
struct HardwareConfig {
|
2021-03-29 00:18:03 +00:00
|
|
|
uint8_t version = 2;
|
2019-05-10 05:17:29 +00:00
|
|
|
uint8_t checksum = 0;
|
|
|
|
struct TaskState {
|
|
|
|
char name[16] = {0};
|
2021-03-29 00:18:03 +00:00
|
|
|
bool isDisabled = false;
|
2019-05-10 05:17:29 +00:00
|
|
|
};
|
|
|
|
struct Data {
|
|
|
|
uint16_t pixelCount = 255;
|
|
|
|
uint16_t startPixel = 0;
|
2021-03-29 00:18:03 +00:00
|
|
|
uint8_t lastRed = 255;
|
|
|
|
uint8_t lastGreen = 255;
|
|
|
|
uint8_t lastBlue = 255;
|
|
|
|
char lastScene[16] = {0};
|
2019-05-10 05:17:29 +00:00
|
|
|
TaskState serviceStates[32];
|
|
|
|
};
|
|
|
|
Data data;
|
|
|
|
|
|
|
|
static HardwareConfig load();
|
|
|
|
void save();
|
|
|
|
bool isValid() const;
|
|
|
|
|
2021-03-28 01:19:55 +00:00
|
|
|
LinearCoordinateMapping toCoordMap() const;
|
|
|
|
|
|
|
|
static constexpr uint16_t MAX_LED_NUM = 255;
|
2021-03-31 18:50:00 +00:00
|
|
|
#ifdef PLATFORM_PHOTON
|
|
|
|
static constexpr bool HAS_MPU_6050 = true;
|
|
|
|
#else
|
2021-03-29 08:10:55 +00:00
|
|
|
static constexpr bool HAS_MPU_6050 = false;
|
2021-03-31 18:50:00 +00:00
|
|
|
#endif
|
2021-03-28 01:19:55 +00:00
|
|
|
|
2019-05-10 05:17:29 +00:00
|
|
|
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;
|
|
|
|
};
|