Re enable accel, fix accel flags & cleanup qc
This commit is contained in:
@@ -51,8 +51,7 @@ uint8_t showBootLogoIfavailable();
|
|||||||
void delay_ms(uint16_t count) ;
|
void delay_ms(uint16_t count) ;
|
||||||
//Used to allow knowledge of if usb_pd is being used
|
//Used to allow knowledge of if usb_pd is being used
|
||||||
uint8_t usb_pd_detect();
|
uint8_t usb_pd_detect();
|
||||||
//Returns 0 when the irq line is pulled down
|
|
||||||
uint8_t pd_irq_read();
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -12,9 +12,6 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Called once at startup, after RToS
|
|
||||||
// This can handle negotiations for QC/PD etc
|
|
||||||
void power_probe();
|
|
||||||
|
|
||||||
// Called periodically in the movement handling thread
|
// Called periodically in the movement handling thread
|
||||||
// Can be used to check any details for the power system
|
// Can be used to check any details for the power system
|
||||||
|
|||||||
@@ -45,12 +45,15 @@ void QC_SeekContNeg() {
|
|||||||
uint8_t QCMode = 0;
|
uint8_t QCMode = 0;
|
||||||
uint8_t QCTries = 0;
|
uint8_t QCTries = 0;
|
||||||
void seekQC(int16_t Vx10, uint16_t divisor) {
|
void seekQC(int16_t Vx10, uint16_t divisor) {
|
||||||
if (QCMode == 5) startQC(divisor);
|
if (QCMode == 0)
|
||||||
if (QCMode == 0) return; // NOT connected to a QC Charger
|
startQC(divisor);
|
||||||
|
|
||||||
if (Vx10 < 45) return;
|
if (Vx10 < 45)
|
||||||
if (xTaskGetTickCount() < 100) return;
|
return;
|
||||||
if (Vx10 > 130) Vx10 = 130; // Cap max value at 13V
|
if (xTaskGetTickCount() < 100)
|
||||||
|
return;
|
||||||
|
if (Vx10 > 130)
|
||||||
|
Vx10 = 130; // Cap max value at 13V
|
||||||
// Seek the QC to the Voltage given if this adapter supports continuous mode
|
// Seek the QC to the Voltage given if this adapter supports continuous mode
|
||||||
// try and step towards the wanted value
|
// try and step towards the wanted value
|
||||||
|
|
||||||
@@ -62,7 +65,8 @@ void seekQC(int16_t Vx10, uint16_t divisor) {
|
|||||||
|
|
||||||
int steps = difference / 2;
|
int steps = difference / 2;
|
||||||
if (QCMode == 3) {
|
if (QCMode == 3) {
|
||||||
if (steps > -2 && steps < 2) return; // dont bother with small steps
|
if (steps > -2 && steps < 2)
|
||||||
|
return; // dont bother with small steps
|
||||||
while (steps < 0) {
|
while (steps < 0) {
|
||||||
QC_SeekContNeg();
|
QC_SeekContNeg();
|
||||||
osDelay(30);
|
osDelay(30);
|
||||||
@@ -106,6 +110,9 @@ void startQC(uint16_t divisor) {
|
|||||||
QCMode = 1; // Already at 12V, user has probably over-ridden this
|
QCMode = 1; // Already at 12V, user has probably over-ridden this
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (QCTries > 10) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
QC_Init_GPIO();
|
QC_Init_GPIO();
|
||||||
|
|
||||||
// Tries to negotiate QC for 9V
|
// Tries to negotiate QC for 9V
|
||||||
@@ -145,13 +152,12 @@ void startQC(uint16_t divisor) {
|
|||||||
}
|
}
|
||||||
osDelay(100); // 100mS
|
osDelay(100); // 100mS
|
||||||
}
|
}
|
||||||
QCMode = 5;
|
|
||||||
QCTries++;
|
|
||||||
if (QCTries > 10) // 10 goes to get it going
|
|
||||||
QCMode = 0;
|
QCMode = 0;
|
||||||
|
QCTries++;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// no QC
|
// no QC
|
||||||
QCMode = 0;
|
QCMode = 0;
|
||||||
}
|
}
|
||||||
if (QCTries > 10) QCMode = 0;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,17 +43,23 @@ int main(void) {
|
|||||||
OLED::setFont(0); // default to bigger font
|
OLED::setFont(0); // default to bigger font
|
||||||
// Testing for which accelerometer is mounted
|
// Testing for which accelerometer is mounted
|
||||||
resetWatchdog();
|
resetWatchdog();
|
||||||
usb_pd_available = true;//usb_pd_detect();
|
usb_pd_available = usb_pd_detect();
|
||||||
resetWatchdog();
|
resetWatchdog();
|
||||||
settingsWereReset = restoreSettings(); // load the settings from flash
|
settingsWereReset = restoreSettings(); // load the settings from flash
|
||||||
/*if (MMA8652FC::detect()) {
|
#ifdef ACCEL_MMA
|
||||||
|
if (MMA8652FC::detect()) {
|
||||||
PCBVersion = 1;
|
PCBVersion = 1;
|
||||||
MMA8652FC::initalize(); // this sets up the I2C registers
|
MMA8652FC::initalize(); // this sets up the I2C registers
|
||||||
} else if (LIS2DH12::detect()) {
|
} else
|
||||||
|
#endif
|
||||||
|
#ifdef ACCEL_LIS
|
||||||
|
if (LIS2DH12::detect()) {
|
||||||
PCBVersion = 2;
|
PCBVersion = 2;
|
||||||
// Setup the ST Accelerometer
|
// Setup the ST Accelerometer
|
||||||
LIS2DH12::initalize(); // startup the accelerometer
|
LIS2DH12::initalize(); // startup the accelerometer
|
||||||
} else*/{
|
} else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
PCBVersion = 3;
|
PCBVersion = 3;
|
||||||
systemSettings.SleepTime = 0;
|
systemSettings.SleepTime = 0;
|
||||||
systemSettings.ShutdownTime = 0; // No accel -> disable sleep
|
systemSettings.ShutdownTime = 0; // No accel -> disable sleep
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ uint32_t lastMovementTime = 0;
|
|||||||
void startMOVTask(void const *argument __unused) {
|
void startMOVTask(void const *argument __unused) {
|
||||||
OLED::setRotation(systemSettings.OrientationMode & 1);
|
OLED::setRotation(systemSettings.OrientationMode & 1);
|
||||||
postRToSInit();
|
postRToSInit();
|
||||||
power_probe();
|
|
||||||
lastMovementTime = 0;
|
lastMovementTime = 0;
|
||||||
int16_t datax[MOVFilter] = { 0 };
|
int16_t datax[MOVFilter] = { 0 };
|
||||||
int16_t datay[MOVFilter] = { 0 };
|
int16_t datay[MOVFilter] = { 0 };
|
||||||
@@ -39,13 +38,20 @@ void startMOVTask(void const *argument __unused) {
|
|||||||
for (;;) {
|
for (;;) {
|
||||||
int32_t threshold = 1500 + (9 * 200);
|
int32_t threshold = 1500 + (9 * 200);
|
||||||
threshold -= systemSettings.sensitivity * 200; // 200 is the step size
|
threshold -= systemSettings.sensitivity * 200; // 200 is the step size
|
||||||
|
#ifdef ACCEL_LIS
|
||||||
if (PCBVersion == 2) {
|
if (PCBVersion == 2) {
|
||||||
LIS2DH12::getAxisReadings(tx, ty, tz);
|
LIS2DH12::getAxisReadings(tx, ty, tz);
|
||||||
rotation = LIS2DH12::getOrientation();
|
rotation = LIS2DH12::getOrientation();
|
||||||
} else if (PCBVersion == 1) {
|
} else
|
||||||
|
#endif
|
||||||
|
#ifdef ACCEL_MMA
|
||||||
|
if (PCBVersion == 1) {
|
||||||
MMA8652FC::getAxisReadings(tx, ty, tz);
|
MMA8652FC::getAxisReadings(tx, ty, tz);
|
||||||
rotation = MMA8652FC::getOrientation();
|
rotation = MMA8652FC::getOrientation();
|
||||||
|
}else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
//do nothing :(
|
||||||
}
|
}
|
||||||
if (systemSettings.OrientationMode == 2) {
|
if (systemSettings.OrientationMode == 2) {
|
||||||
if (rotation != ORIENTATION_FLAT) {
|
if (rotation != ORIENTATION_FLAT) {
|
||||||
|
|||||||
Reference in New Issue
Block a user