Files
mongoose/tutorials/nordic/xiao-nrf52840/usb/dashboard_config.h
T

23 lines
875 B
C

// Dashboard hooks, see tutorials/device-dashboard/full/dashboard.c
// Used because the Makefile builds with -DDASHBOARD_CONFIG
#pragma once
#include "hal.h"
// LED1, LED2, LED3 are the red, green and blue parts of the RGB LED, which
// are active low
#define LED1_READ() (!hal_gpio_read(LED_RED))
#define LED1_WRITE(on) hal_gpio_write(LED_RED, !(on))
#define LED2_READ() (!hal_gpio_read(LED_GREEN))
#define LED2_WRITE(on) hal_gpio_write(LED_GREEN, !(on))
#define LED3_READ() (!hal_gpio_read(LED_BLUE))
#define LED3_WRITE(on) hal_gpio_write(LED_BLUE, !(on))
// Real-time graph: X, Y, Z acceleration, the IMU's full +-2 g mapped to the
// graph's 0..100, 40 mg per step
static inline void graph_read(int *v) {
int i;
hal_imu_accel(v); // Raw counts, -32768..32767
for (i = 0; i < 3; i++) v[i] = GRAPH_SCALE(v[i], -32768, 32767);
}
#define GRAPH_READ(v) graph_read(v)