-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmain.cpp
More file actions
61 lines (58 loc) · 1.91 KB
/
Copy pathmain.cpp
File metadata and controls
61 lines (58 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <sns/sns.h>
#if defined (STM32)
#include <foc/vfd.h>
#include <foc/foc.h>
#endif
static constexpr
std::pair<int, void(*)()>
dispatch_table[] = {
{ 1, test_led },
{ 2, test_m200 },
{ 3, test_blhS },
{ 4, test_ms5837 },
{ 5, test_bno055 },
{ 6, test_bno085 },
{ 7, test_serial },
{ 8, test_hmc58883l },
{ 9, test_sg90_servo },
{10, test_motor_drv8833 },
{11, toggle_default_led },
{12, test_network_nanopb },
{13, test_vl53l0x },
{14, test_28BYJ_48_stepper },
{15, test_bldc_trapezoidal_ll },
{16, test_bldc_trapezoidal_pwm },
{17, test_bldc_trapezoidal_pwm_comp },
{18, test_bldc_sinusoidal_wave },
{19, test_mpu6050},
{20, test_mahony},
{21, adc_tim_dma_test},
#if defined (STM32)
{22, test_vf_drive},
{23, test_foc},
#endif
#if defined(PICO)
{99, []() {
watchdog_enable(3000, true);
while (true) {}
}},
#endif
};
int main(void) {
mcl::initialize();
auto *c = getInstance<config>();
//while(!c->getKeyValue(config::key::action)) { mcl::send_discovery(); };
while (true) {
auto test = static_cast<int>(c->getKeyValue(config::key::action));
LOG << "waiting for new action.. " << test;
auto it = std::ranges::find_if(dispatch_table,
[test](const auto& e){ return e.first == test; });
if (it != std::end(dispatch_table)) {
it->second();
} else {
LOG << "unknown action: " << test;
}
c->setKeyValue({config::key::action, -1});
mcl::sleep_ms(500);
}
}