mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
Fix build for MSA
This commit is contained in:
@@ -34,8 +34,9 @@ Orientation MSA301::getOrientation() {
|
||||
return Orientation::ORIENTATION_LEFT_HAND;
|
||||
case 96:
|
||||
return Orientation::ORIENTATION_RIGHT_HAND;
|
||||
}
|
||||
default:
|
||||
return Orientation::ORIENTATION_FLAT;
|
||||
}
|
||||
}
|
||||
|
||||
void MSA301::getAxisReadings(int16_t &x, int16_t &y, int16_t &z) {
|
||||
|
||||
@@ -394,8 +394,8 @@ static void display_countdown(int sleepThres) {
|
||||
* mode is triggered.
|
||||
*/
|
||||
int lastEventTime = lastButtonTime < lastMovementTime ? lastMovementTime : lastButtonTime;
|
||||
int downCount = sleepThres - xTaskGetTickCount() + lastEventTime;
|
||||
if (downCount > 99000) {
|
||||
TickType_t downCount = sleepThres - xTaskGetTickCount() + lastEventTime;
|
||||
if (downCount > (99 * TICKS_SECOND)) {
|
||||
OLED::printNumber(downCount / 60000 + 1, 2);
|
||||
OLED::print(SymbolMinutes);
|
||||
} else {
|
||||
@@ -645,10 +645,10 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
|
||||
void showDebugMenu(void) {
|
||||
uint8_t screen = 0;
|
||||
ButtonState b;
|
||||
OLED::setFont(1); // small font
|
||||
for (;;) {
|
||||
OLED::clearScreen(); // Ensure the buffer starts clean
|
||||
OLED::setCursor(0, 0); // Position the cursor at the 0,0 (top left)
|
||||
OLED::setFont(1); // small font
|
||||
OLED::print(SymbolVersionNumber); // Print version number
|
||||
OLED::setCursor(0, 8); // second line
|
||||
OLED::print(DebugMenu[screen]);
|
||||
@@ -717,7 +717,6 @@ void showDebugMenu(void) {
|
||||
}
|
||||
#endif
|
||||
if (poweredbyPD) {
|
||||
|
||||
OLED::printNumber(2, 1);
|
||||
} else {
|
||||
|
||||
|
||||
@@ -25,12 +25,11 @@
|
||||
uint8_t accelInit = 0;
|
||||
TickType_t lastMovementTime = 0;
|
||||
void detectAccelerometerVersion() {
|
||||
PCBVersion = 99;
|
||||
DetectedAccelerometerVersion = 99;
|
||||
#ifdef ACCEL_MMA
|
||||
if (MMA8652FC::detect()) {
|
||||
|
||||
if (MMA8652FC::initalize()) {
|
||||
PCBVersion = 1;
|
||||
DetectedAccelerometerVersion = 1;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
@@ -38,7 +37,7 @@ void detectAccelerometerVersion() {
|
||||
if (LIS2DH12::detect()) {
|
||||
// Setup the ST Accelerometer
|
||||
if (LIS2DH12::initalize()) {
|
||||
PCBVersion = 2;
|
||||
DetectedAccelerometerVersion = 2;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
@@ -46,7 +45,7 @@ void detectAccelerometerVersion() {
|
||||
if (BMA223::detect()) {
|
||||
// Setup the ST Accelerometer
|
||||
if (BMA223::initalize()) {
|
||||
PCBVersion = 3;
|
||||
DetectedAccelerometerVersion = 3;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
@@ -54,7 +53,7 @@ void detectAccelerometerVersion() {
|
||||
if (MSA301::detect()) {
|
||||
// Setup the MSA301 Accelerometer
|
||||
if (MSA301::initalize()) {
|
||||
PCBVersion = 4;
|
||||
DetectedAccelerometerVersion = 4;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
@@ -63,8 +62,7 @@ void detectAccelerometerVersion() {
|
||||
systemSettings.sensitivity = 0;
|
||||
}
|
||||
}
|
||||
inline void readAccelerometer(int16_t &tx, int16_t &ty, int16_t &tz,
|
||||
Orientation &rotation) {
|
||||
inline void readAccelerometer(int16_t &tx, int16_t &ty, int16_t &tz, Orientation &rotation) {
|
||||
#ifdef ACCEL_LIS
|
||||
if (DetectedAccelerometerVersion == 2) {
|
||||
LIS2DH12::getAxisReadings(tx, ty, tz);
|
||||
@@ -84,7 +82,7 @@ inline void readAccelerometer(int16_t &tx, int16_t &ty, int16_t &tz,
|
||||
} else
|
||||
#endif
|
||||
#ifdef ACCEL_MSA
|
||||
if (PCBVersion == 3) {
|
||||
if (DetectedAccelerometerVersion == 4) {
|
||||
MSA301::getAxisReadings(tx, ty, tz);
|
||||
rotation = MSA301::getOrientation();
|
||||
} else
|
||||
@@ -96,16 +94,16 @@ inline void readAccelerometer(int16_t &tx, int16_t &ty, int16_t &tz,
|
||||
void startMOVTask(void const *argument __unused) {
|
||||
postRToSInit();
|
||||
detectAccelerometerVersion();
|
||||
osDelay(50); // wait ~50ms for setup of accel to finalise
|
||||
osDelay(TICKS_100MS / 2); // wait ~50ms for setup of accel to finalise
|
||||
lastMovementTime = 0;
|
||||
// Mask 2 seconds if we are in autostart so that if user is plugging in and
|
||||
// then putting in stand it doesnt wake instantly
|
||||
if (systemSettings.autoStartMode)
|
||||
osDelay(2 * TICKS_SECOND);
|
||||
|
||||
int16_t datax[MOVFilter] = {0};
|
||||
int16_t datay[MOVFilter] = {0};
|
||||
int16_t dataz[MOVFilter] = {0};
|
||||
int16_t datax[MOVFilter] = { 0 };
|
||||
int16_t datay[MOVFilter] = { 0 };
|
||||
int16_t dataz[MOVFilter] = { 0 };
|
||||
uint8_t currentPointer = 0;
|
||||
int16_t tx = 0, ty = 0, tz = 0;
|
||||
int32_t avgx, avgy, avgz;
|
||||
@@ -118,18 +116,17 @@ void startMOVTask(void const *argument __unused) {
|
||||
readAccelerometer(tx, ty, tz, rotation);
|
||||
if (systemSettings.OrientationMode == 2) {
|
||||
if (rotation != ORIENTATION_FLAT) {
|
||||
OLED::setRotation(rotation ==
|
||||
ORIENTATION_LEFT_HAND); // link the data through
|
||||
OLED::setRotation(rotation == ORIENTATION_LEFT_HAND); // link the data through
|
||||
}
|
||||
}
|
||||
datax[currentPointer] = (int32_t)tx;
|
||||
datay[currentPointer] = (int32_t)ty;
|
||||
dataz[currentPointer] = (int32_t)tz;
|
||||
datax[currentPointer] = (int32_t) tx;
|
||||
datay[currentPointer] = (int32_t) ty;
|
||||
dataz[currentPointer] = (int32_t) tz;
|
||||
if (!accelInit) {
|
||||
for (uint8_t i = currentPointer + 1; i < MOVFilter; i++) {
|
||||
datax[i] = (int32_t)tx;
|
||||
datay[i] = (int32_t)ty;
|
||||
dataz[i] = (int32_t)tz;
|
||||
datax[i] = (int32_t) tx;
|
||||
datay[i] = (int32_t) ty;
|
||||
dataz[i] = (int32_t) tz;
|
||||
}
|
||||
accelInit = 1;
|
||||
}
|
||||
@@ -155,7 +152,7 @@ void startMOVTask(void const *argument __unused) {
|
||||
lastMovementTime = xTaskGetTickCount();
|
||||
}
|
||||
|
||||
osDelay(100); // Slow down update rate
|
||||
osDelay(TICKS_100MS); // Slow down update rate
|
||||
power_check();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user