2021-05-13 13:12:30 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include "pico/stdlib.h"
|
2021-05-14 18:12:37 +01:00
|
|
|
#include "common/pimoroni_common.hpp"
|
2021-05-13 13:12:30 +01:00
|
|
|
|
|
|
|
#include "breakout_msa301.hpp"
|
|
|
|
|
|
|
|
using namespace pimoroni;
|
|
|
|
|
2021-05-14 18:12:37 +01:00
|
|
|
I2C i2c(BOARD::BREAKOUT_GARDEN);
|
|
|
|
BreakoutMSA301 msa301(&i2c);
|
2021-05-13 13:12:30 +01:00
|
|
|
|
|
|
|
int main() {
|
|
|
|
stdio_init_all();
|
|
|
|
|
|
|
|
msa301.init();
|
|
|
|
|
|
|
|
uint8_t part_id = msa301.part_id();
|
|
|
|
printf("Found MSA301. Part ID: 0x%02x\n", part_id);
|
|
|
|
|
|
|
|
msa301.enable_interrupts(MSA301::FREEFALL | MSA301::ORIENTATION);
|
|
|
|
|
|
|
|
while(true){
|
2021-05-13 16:26:08 +01:00
|
|
|
printf("X: %f, Y: %f, Z: %f", msa301.get_x_axis(), msa301.get_y_axis(), msa301.get_z_axis());
|
|
|
|
printf(", Freefall? %d", msa301.read_interrupt(MSA301::FREEFALL));
|
|
|
|
printf(", Orientation: %d\n", msa301.get_orientation());
|
2021-05-13 13:12:30 +01:00
|
|
|
sleep_ms(100);
|
|
|
|
};
|
|
|
|
return 0;
|
|
|
|
}
|