Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 8:ed92317b2c9b, committed 2019-11-05
- Comitter:
- brano2
- Date:
- Tue Nov 05 13:54:48 2019 +0000
- Parent:
- 7:db23f12fcd02
- Commit message:
- Print acceleration at slow rate
Changed in this revision
source/main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/source/main.cpp Tue Nov 05 13:36:16 2019 +0000 +++ b/source/main.cpp Tue Nov 05 13:54:48 2019 +0000 @@ -58,6 +58,7 @@ _event_queue.call_every(50, this, &BatteryDemo::send_acceleration); + _event_queue.call_every(2000, this, &BatteryDemo::print_last_acceleration); _event_queue.call_every(500, this, &BatteryDemo::blink); _event_queue.call_every(1000, this, &BatteryDemo::update_sensor_value); @@ -137,16 +138,15 @@ } void send_acceleration() { -// printf("Hello world!\n"); - int16_t acc[3] = {0,0,0}; - _mpu.readAccelData(acc); + _mpu.readAccelData(_acc); + _imu_service->updateImuState(_acc); +// _event_queue.call(Callback<void(int16_t*)>(_imu_service, &ImuService::updateImuState), acc); + } + + void print_last_acceleration() { float scale = _mpu.aRes; -// printf("acc: %f, %f, %f\r\n", -// acc[0]*scale, acc[1]*scale, acc[2]*scale); -// printf("acc: %d, %d, %d\r\n", -// acc[0], acc[1], acc[2]); - _imu_service->updateImuState(acc); -// _event_queue.call(Callback<void(int16_t*)>(_imu_service, &ImuService::updateImuState), acc); + printf("acc: %f, %f, %f\r\n", + _acc[0]*scale, _acc[1]*scale, _acc[2]*scale); } void blink(void) { @@ -174,6 +174,7 @@ MPU9250 _mpu; ImuService* _imu_service; + int16_t _acc[3] = {0,0,0}; }; /** Schedule processing of events from the BLE middleware in the event queue. */