#pragma once template struct Checker { static constexpr bool value = v; }; namespace entry { enum Type : uint8_t { stop, config, set, set_ts, clear, clear_ts, }; struct Set { uint8_t index; uint16_t frequency; }; struct Clear { uint8_t index; }; struct SetTS { uint8_t index; uint32_t ticks; uint16_t frequency; }; struct ClearTS { uint8_t index; uint32_t ticks; }; struct Stop { }; struct Config { uint32_t us_per_tick; uint8_t amplitude; uint32_t jump_addr; }; struct Generic { Type type; union { Set set; SetTS set_ts; Clear clear; ClearTS clear_ts; Stop stop; Config config; }; }; inline size_t get_size(Type type) { switch(type) { case Type::set: return 3; case Type::clear: return 1; case Type::set_ts: return 5; case Type::clear_ts: return 4; case Type::config: return 8; case Type::stop: default: return 1; } } };