#include <M5Unified.h>
#include "M5_ANGLE8.h"
M5_ANGLE8 dev;
uint32_t color_list[] = {0xff0000, 0x00ff00, 0x0000ff};
uint8_t color_index = 0;
time_t last_update_time = 0;
void setup()
{
M5.begin();
Serial.begin(115200);
M5.Display.setFont(&fonts::lgfxJapanMinchoP_20);
Wire.begin(2, 1, 100000L);
while (!dev.begin(ANGLE8_I2C_ADDR)) {
M5.Display.drawString("Unit 8Angle init Fail!", M5.Display.width() / 2, M5.Display.height() / 2);
delay(1000);
}
}
void loop()
{
bool switch_status = dev.getDigitalInput();
M5.Display.clear();
M5.Display.setCursor(0, 0);
M5.Display.printf("Switch: %s\r\n", switch_status ? "ON" : "OFF");
for (uint8_t i = 0; i < ANGLE8_TOTAL_ADC; i++) {
uint16_t adc_v = dev.getAnalogInput(i, _12bit);
M5.Display.printf("CH[%d]: %d\r\n", i, adc_v);
}
if (millis() - last_update_time > 1000) {
color_index = (color_index + 1) % 3;
for (uint8_t i = 0; i < ANGLE8_TOTAL_LED; i++) {
dev.setLEDColor(i, color_list[color_index], 80);
}
last_update_time = millis();
}
delay(100);
}
For the CoreS3, press and hold the reset button (approximately 2 seconds) until the internal green LED lights up, then release the button. At this point, the device will enter download mode and wait for flashing.
Read and display the statuses of the potentiometers and the switch, while also controlling the RGB LED color to change every 1 second.