Skip to content

Commit

Permalink
Refactor application.cpp for MPU6050 sample
Browse files Browse the repository at this point in the history
  • Loading branch information
xeonqq committed Jul 28, 2023
1 parent dbbb278 commit 6b20199
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions samples/Accel_Gyro_MPU6050/app/application.cpp
Original file line number Diff line number Diff line change
@@ -1,24 +1,13 @@
#include <Libraries/MPU6050/MPU6050.h>
#include <SmingCore.h>

constexpr float mainLoopInterval = 0.02; // sec
constexpr uint16_t mainLoopInterval = 20; // ms
SimpleTimer mainLoopTimer;
MPU6050 mpu;

void printAccelGyro(int16_t ax, int16_t ay, int16_t az, int16_t gx, int16_t gy, int16_t gz)
{
Serial.print("a/g:\t");
Serial.print(ax);
Serial.print("\t");
Serial.print(ay);
Serial.print("\t");
Serial.print(az);
Serial.print("\t");
Serial.print(gx);
Serial.print("\t");
Serial.print(gy);
Serial.print("\t");
Serial.println(gz);
Serial << "a/g:\t" << ax << "\t" << ay << "\t" << az << "\t" << gx << "\t" << gy << "\t" << gz << endl;
}

void mainLoop()
Expand All @@ -38,5 +27,5 @@ void init()
mpu.initialize();
Serial.println(mpu.testConnection() ? "MPU6050 connection successful" : "MPU6050 connection failed");

mainLoopTimer.initializeMs(static_cast<int>(mainLoopInterval * 1000), mainLoop).start();
mainLoopTimer.initializeMs<mainLoopInterval>(mainLoop).start();
}

0 comments on commit 6b20199

Please sign in to comment.