2024-08-19 22:43:24 +10:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2024-08-25 13:55:43 +10:00
|
|
|
template <int P, bool v>
|
|
|
|
struct Checker {
|
|
|
|
static constexpr bool value = v;
|
|
|
|
};
|
|
|
|
|
2024-08-19 22:43:24 +10:00
|
|
|
namespace entry {
|
|
|
|
|
2024-08-25 13:55:43 +10:00
|
|
|
enum Type : uint8_t {
|
|
|
|
stop,
|
|
|
|
config,
|
|
|
|
set,
|
|
|
|
set_ts,
|
|
|
|
clear,
|
|
|
|
clear_ts,
|
|
|
|
};
|
|
|
|
|
2024-08-19 22:43:24 +10:00
|
|
|
struct Set {
|
|
|
|
uint8_t index;
|
|
|
|
uint16_t frequency;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Clear {
|
|
|
|
uint8_t index;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SetTS {
|
|
|
|
uint8_t index;
|
2024-08-25 13:55:43 +10:00
|
|
|
uint32_t ticks;
|
2024-08-19 22:43:24 +10:00
|
|
|
uint16_t frequency;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ClearTS {
|
|
|
|
uint8_t index;
|
2024-08-25 13:55:43 +10:00
|
|
|
uint32_t ticks;
|
2024-08-19 22:43:24 +10:00
|
|
|
};
|
|
|
|
|
2024-08-25 13:55:43 +10:00
|
|
|
struct Stop {
|
2024-08-19 22:43:24 +10:00
|
|
|
};
|
2024-08-25 13:55:43 +10:00
|
|
|
|
|
|
|
struct Config {
|
|
|
|
uint32_t us_per_tick;
|
2024-08-26 13:02:17 +10:00
|
|
|
uint8_t amplitude;
|
2024-08-25 13:55:43 +10:00
|
|
|
};
|
|
|
|
|
|
|
|
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:
|
2024-08-26 13:02:17 +10:00
|
|
|
return 5;
|
2024-08-25 13:55:43 +10:00
|
|
|
case Type::stop:
|
|
|
|
default:
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
2024-08-19 22:43:24 +10:00
|
|
|
};
|
|
|
|
|