2021-05-06 09:48:17 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include "pico/stdlib.h"
|
|
|
|
|
|
|
|
#include "breakout_ltr559.hpp"
|
|
|
|
|
|
|
|
using namespace pimoroni;
|
|
|
|
|
2021-05-17 11:08:23 +01:00
|
|
|
I2C i2c(BOARD::BREAKOUT_GARDEN);
|
2021-05-14 18:12:37 +01:00
|
|
|
BreakoutLTR559 ltr559(&i2c);
|
2021-05-06 09:48:17 +01:00
|
|
|
|
|
|
|
int main() {
|
|
|
|
stdio_init_all();
|
|
|
|
|
|
|
|
ltr559.init();
|
|
|
|
|
|
|
|
uint8_t part_id = ltr559.part_id();
|
2021-05-17 11:08:23 +01:00
|
|
|
if(part_id == LTR559_VALID_PART_ID) {
|
|
|
|
printf("Found LTR559. Part ID: 0x%02x\n", part_id);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf("Could not find LTR559. Got Part ID: 0x%02x, expected 0x%02x\n", part_id, LTR559_VALID_PART_ID);
|
|
|
|
}
|
2021-05-06 09:48:17 +01:00
|
|
|
|
|
|
|
while(true){
|
|
|
|
bool new_data = ltr559.get_reading();
|
|
|
|
if(new_data) {
|
2022-08-03 09:32:59 +01:00
|
|
|
printf("Lux: %.2f Prox: %d\n", ltr559.data.lux, ltr559.data.proximity);
|
2021-05-06 09:48:17 +01:00
|
|
|
}
|
|
|
|
sleep_ms(100);
|
|
|
|
};
|
|
|
|
return 0;
|
|
|
|
}
|