diff options
Diffstat (limited to 'apps/accelerometer-test')
-rw-r--r-- | apps/accelerometer-test/app.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/apps/accelerometer-test/app.c b/apps/accelerometer-test/app.c index 1f7803c6..1a3acafa 100644 --- a/apps/accelerometer-test/app.c +++ b/apps/accelerometer-test/app.c @@ -24,17 +24,13 @@ static void cb_tick(void) { if (!lis2dw_have_new_data()) return; watch_set_indicator(WATCH_INDICATOR_SIGNAL); - lis2dw_reading raw_reading; - lis2dw_acceleration_measurement measurement = lis2dw_get_acceleration_measurement(&raw_reading); - printf("%f, %f, %f\n", measurement.x, measurement.y, measurement.z); - char buf[128]; - sprintf(buf, "%f, %f, %f\n", measurement.x, measurement.y, measurement.z); - watch_debug_puts(buf); + lis2dw_fifo_t fifo; + bool overrun = lis2dw_read_fifo(&fifo); + printf("FIFO captured %d readings.\n", fifo.count); + if (overrun) printf("\tThere was an overrun!\n\n"); } void app_init(void) { - watch_enable_debug_uart(460800); // this is glitchy now, but this enables a baud rate of 115200 when USB is disabled. - watch_enable_display(); watch_display_string("AC Strean", 0); @@ -45,12 +41,14 @@ void app_init(void) { watch_enable_i2c(); lis2dw_begin(); - lis2dw_set_data_rate(LIS2DW_DATA_RATE_25_HZ); // is this enough for training? - lis2dw_set_low_noise_mode(true); // consumes a little more power lis2dw_set_low_power_mode(LIS2DW_LP_MODE_2); // lowest power 14-bit mode, 25 Hz is 3.5 µA @ 1.8V w/ low noise, 3µA without + lis2dw_set_low_noise_mode(true); // consumes a little more power lis2dw_set_range(LIS2DW_CTRL6_VAL_RANGE_4G); + lis2dw_set_data_rate(LIS2DW_DATA_RATE_25_HZ); // is this enough for training? + + lis2dw_enable_fifo(); - watch_rtc_register_periodic_callback(cb_tick, 64); + watch_rtc_register_periodic_callback(cb_tick, 1); } void app_wake_from_backup(void) { |