mirror of
https://github.com/cesanta/mongoose.git
synced 2026-12-04 21:58:22 +00:00
Full dashboard - make LEDs and graph overridable
This commit is contained in:
1 parent
364c979a1d
commit
37db92bfc2
7 files changed
+294
-69
No files matched your search
@@ -7,15 +7,34 @@
|
||||
static void blink_task(void) {
|
||||
static uint64_t blink_timer = 0;
|
||||
if (mg_timer_expired(&blink_timer, 500, mg_millis())) {
|
||||
hal_gpio_toggle(LED);
|
||||
hal_gpio_toggle(LED_RED);
|
||||
}
|
||||
}
|
||||
|
||||
// Mongoose time source, see MG_ENABLE_CUSTOM_MILLIS
|
||||
uint64_t mg_millis(void) {
|
||||
return hal_get_tick();
|
||||
}
|
||||
|
||||
// Mongoose random source, see MG_ENABLE_CUSTOM_RANDOM
|
||||
bool mg_random(void *buf, size_t len) {
|
||||
for (size_t n = 0; n < len; n += sizeof(uint32_t)) {
|
||||
uint32_t r = hal_rng_read();
|
||||
memcpy((char *) buf + n, &r, n + sizeof(r) > len ? len - n : sizeof(r));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
hal_system_init();
|
||||
hal_rng_init();
|
||||
hal_gpio_write(LED, true); // Off
|
||||
hal_gpio_output(LED);
|
||||
hal_gpio_write(LED_RED, true); // RGB LED off, it is active low
|
||||
hal_gpio_write(LED_GREEN, true);
|
||||
hal_gpio_write(LED_BLUE, true);
|
||||
hal_gpio_output(LED_RED); // Dashboard LED1, LED2, LED3
|
||||
hal_gpio_output(LED_GREEN);
|
||||
hal_gpio_output(LED_BLUE);
|
||||
int imu = hal_imu_init(); // For the dashboard's real-time graph
|
||||
|
||||
struct mg_mgr mgr;
|
||||
mg_mgr_init(&mgr); // Also starts the USB driver, see mongoose_config.h
|
||||
@@ -24,6 +43,8 @@ int main(void) {
|
||||
MG_INFO(("Initialised. CPU clock: %lu MHz", SystemCoreClock / 1000000));
|
||||
MG_INFO(("RAM used: %zu, free: %zu", hal_ram_used(), hal_ram_free()));
|
||||
MG_INFO(("USB Ethernet + serial"));
|
||||
if (imu) MG_INFO(("IMU at I2C address 0x%x", imu));
|
||||
if (!imu) MG_ERROR(("IMU not found, is this a XIAO nRF52840 Sense?"));
|
||||
|
||||
for (;;) {
|
||||
mg_mgr_poll(&mgr, 0);
|
||||
|
||||
Reference in new issue
Block a user