Skip to content

Commit

Permalink
gps-edition: add sensors and fix debug app
Browse files Browse the repository at this point in the history
  • Loading branch information
uvwxy committed Jul 17, 2021
1 parent 51c467a commit 7846e00
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 29 deletions.
3 changes: 0 additions & 3 deletions include/osw_hal.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ class OswHal {
void stopEnvironmentSensor(void);
void setupCompass(void);
void stopCompass(void);
uint8_t setupSD(void);
void setupGps(void);
#endif

Expand Down Expand Up @@ -189,8 +188,6 @@ class OswHal {
long _lastDoubleTap = 0;
uint8_t _brightness = 0;
bool _hasBMA400 = false;
bool _hasSD = false;
bool _isSDMounted = false;
bool _hasGPS = false;
bool _debugGPS = false;
bool _requestFlush = false;
Expand Down
4 changes: 4 additions & 0 deletions src/apps/main/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ void OswAppMap::setup(OswHal* hal) {
_satellites[i].snr = 0;
_satellites[i].tracked = 0;
}

hal->gpsFullOnGpsGlonassBeidu();
}

uint16_t z = 10;
Expand Down Expand Up @@ -197,6 +199,8 @@ void OswAppMap::stop(OswHal* hal) {
delete tileBuffer[i];
}
delete[] tileBuffer;

hal->gpsBackupMode();
}

#endif
8 changes: 7 additions & 1 deletion src/apps/tools/print_debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ void printStatus(OswHal* hal, const char* setting, const char* value) {
void OswAppPrintDebug::setup(OswHal* hal) {
#if defined(GPS_EDITION)
hal->gpsFullOnGpsGlonassBeidu();
hal->setupCompass();
#endif
}
void OswAppPrintDebug::loop(OswHal* hal) {
Expand All @@ -44,6 +45,11 @@ void OswAppPrintDebug::loop(OswHal* hal) {

printStatus(hal, "DS3231", hal->hasDS3231() ? "OK" : "missing");
printStatus(hal, "BMA400", hal->hasBMA400() ? "OK" : "missing");
#ifdef GPS_EDITION
printStatus(hal, "BME280", hal->getPressure() != 0 ? "OK" : "missing");
hal->updateCompass();
printStatus(hal, "QMC5883L", hal->getCompassAzimuth() != 0 ? "OK" : "missing");
#endif
printStatus(hal, "PSRAM", String(ESP.getPsramSize(), 10).c_str());

#if defined(GPS_EDITION)
Expand Down Expand Up @@ -101,6 +107,6 @@ void OswAppPrintDebug::loop(OswHal* hal) {
void OswAppPrintDebug::stop(OswHal* hal) {
#if defined(GPS_EDITION)
hal->gpsBackupMode();

hal->stopCompass();
#endif
}
8 changes: 8 additions & 0 deletions src/hal/esp32/sd_filesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,32 @@

#include "osw_pins.h"

bool _hasSD = false;
bool _isSDMounted = false;

bool SDFileSystemHal::initialize() {
// Mount the filesystem and register vfs
SD.begin(SD_CS);

uint8_t cardType = SD.cardType();
if (cardType == CARD_NONE) {
_hasSD = false;
#ifdef DEBUG
Serial.println("ERR_SD_MISSING");
#endif
return false;
} else {
_hasSD = true;
// there is a card
if (!SD.begin(SD_CS)) {
#ifdef DEBUG
Serial.println("ERR_SD_MOUNT_FAILED");
#endif
_isSDMounted = false;

return false;
}
_isSDMounted = true;
return true;
}
}
26 changes: 3 additions & 23 deletions src/hal/sd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,9 @@

#if defined(GPS_EDITION)

uint8_t OswHal::setupSD() {
SD.begin(SD_CS);

uint8_t cardType = SD.cardType();
if (cardType == CARD_NONE) {
_hasSD = false;
#ifdef DEBUG
Serial.println("ERR_SD_MISSING");
#endif
return ERR_SD_MISSING;
} else {
_hasSD = true;
if (!SD.begin(SD_CS)) {
#ifdef DEBUG
Serial.println("ERR_SD_MOUNT_FAILED");
#endif
return ERR_SD_MOUNT_FAILED;
}
_isSDMounted = true;
}

return 0;
}
// this is a nasty hack and depends on hal/esp32/sd_filesystem.cpp
extern bool _hasSD;
extern bool _isSDMounted;

bool OswHal::hasSD(void) { return _hasSD; }
bool OswHal::isSDMounted(void) { return _isSDMounted; }
Expand Down
1 change: 0 additions & 1 deletion src/hal/sensors_compass_qmc5883l.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ QMC5883LCompass qmc5883l;
void OswHal::setupCompass(void) {
qmc5883l.init();
qmc5883l.setSmoothing(10, true);
qmc5883l.setCalibration(-1708, 1190, -1841, 1135, -2370, 1636);
}

void OswHal::updateCompass(void) { qmc5883l.read(); }
Expand Down
4 changes: 3 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "./overlays/overlays.h"
#if defined(GPS_EDITION)
#include "./apps/main/map.h"
#include "./apps/_experiments/compass_calibrate.h"
#endif
#include "./services/OswServiceManager.h"
#include "./services/OswServiceTaskBLECompanion.h"
Expand Down Expand Up @@ -134,7 +135,8 @@ void loop() {
delayedAppInit = false;
#ifdef GPS_EDITION
mainAppSwitcher->registerApp(new OswAppMap());
// mainAppSwitcher->registerApp(new OswAppPrintDebug());
mainAppSwitcher->registerApp(new OswAppPrintDebug());
mainAppSwitcher->registerApp(new OswAppCompassCalibrate());
#endif
// enable / sort your apps here:
// tests
Expand Down

0 comments on commit 7846e00

Please sign in to comment.