2021-01-21 20:24:18 +00:00
|
|
|
#include "pico/stdlib.h"
|
2021-05-14 17:12:37 +00:00
|
|
|
#include "common/pimoroni_common.hpp"
|
2021-01-21 20:24:18 +00:00
|
|
|
|
|
|
|
#include "breakout_as7262.hpp"
|
|
|
|
|
|
|
|
using namespace pimoroni;
|
|
|
|
|
2021-05-14 17:12:37 +00:00
|
|
|
I2C i2c(BOARD::BREAKOUT_GARDEN);
|
|
|
|
BreakoutAS7262 as7262(&i2c);
|
2021-01-21 20:24:18 +00:00
|
|
|
|
|
|
|
int main() {
|
2021-05-10 16:22:36 +00:00
|
|
|
stdio_init_all();
|
2021-01-21 20:24:18 +00:00
|
|
|
|
|
|
|
as7262.init();
|
|
|
|
|
2021-05-10 16:22:36 +00:00
|
|
|
uint8_t dev_type = as7262.device_type();
|
|
|
|
uint8_t hw_version = as7262.hardware_version();
|
|
|
|
|
|
|
|
uint8_t major, minor, sub;
|
|
|
|
as7262.firmware_version(major, minor, sub);
|
|
|
|
printf("Device: %d, HW: %d, FW: %d.%d.%d\n", dev_type, hw_version, major, minor, sub);
|
2021-01-21 20:24:18 +00:00
|
|
|
|
2021-05-12 14:01:19 +00:00
|
|
|
as7262.set_gain(AS7262::gain::X64);
|
|
|
|
as7262.set_integration_time(17.857);
|
2021-01-21 20:24:18 +00:00
|
|
|
as7262.set_measurement_mode(AS7262::measurement_mode::cont_roygbr);
|
|
|
|
as7262.set_illumination_current(AS7262::illumination_current::ma12);
|
|
|
|
as7262.set_indicator_current(AS7262::indicator_current::ma4);
|
2021-05-12 14:01:19 +00:00
|
|
|
as7262.set_leds(true, true);
|
2021-01-21 20:24:18 +00:00
|
|
|
|
|
|
|
while(true) {
|
|
|
|
|
|
|
|
AS7262::reading reading = as7262.read();
|
|
|
|
printf("R: %f O: %f Y: %f G: %f B: %f V: %f \n",
|
|
|
|
reading.red,
|
|
|
|
reading.orange,
|
|
|
|
reading.yellow,
|
|
|
|
reading.green,
|
|
|
|
reading.blue,
|
|
|
|
reading.violet
|
|
|
|
);
|
|
|
|
|
|
|
|
sleep_ms(1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|