Skip to content

Commit 588a986

Browse files
committed
t1000e: gps toggle not using board class
1 parent 8765b3d commit 588a986

File tree

8 files changed

+14
-14
lines changed

8 files changed

+14
-14
lines changed

examples/companion_radio/UITask.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ static const uint8_t meshcore_logo [] PROGMEM = {
3434
0xe3, 0xe3, 0x8f, 0xff, 0x1f, 0xfc, 0x3c, 0x0e, 0x1f, 0xf8, 0xff, 0xf8, 0x70, 0x3c, 0x7f, 0xf8,
3535
};
3636

37-
void UITask::begin(DisplayDriver* display, NodePrefs* node_prefs) {
37+
void UITask::begin(DisplayDriver* display, SensorManager* sensors, NodePrefs* node_prefs) {
3838
_display = display;
39+
_sensors = sensors;
3940
_auto_off = millis() + AUTO_OFF_MILLIS;
4041
clearMsgPreview();
4142
_node_prefs = node_prefs;
@@ -386,7 +387,9 @@ void UITask::handleButtonTriplePress() {
386387

387388
void UITask::handleButtonQuadruplePress() {
388389
MESH_DEBUG_PRINTLN("UITask: quad press triggered");
389-
_board->toggleGps();
390+
if (_sensors != NULL) {
391+
_sensors->toggleGps();
392+
}
390393
_need_refresh = true;
391394
}
392395

examples/companion_radio/UITask.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include <MeshCore.h>
44
#include <helpers/ui/DisplayDriver.h>
5+
#include <helpers/SensorManager.h>
56
#include <stddef.h>
67

78
#ifdef PIN_BUZZER
@@ -24,6 +25,7 @@
2425
class UITask {
2526
DisplayDriver* _display;
2627
mesh::MainBoard* _board;
28+
SensorManager* _sensors;
2729
#ifdef PIN_BUZZER
2830
genericBuzzer buzzer;
2931
#endif
@@ -59,12 +61,12 @@ class UITask {
5961

6062
public:
6163

62-
UITask(mesh::MainBoard* board) : _board(board), _display(NULL) {
64+
UITask(mesh::MainBoard* board) : _board(board), _display(NULL), _sensors(NULL) {
6365
_next_refresh = 0;
6466
ui_started_at = 0;
6567
_connected = false;
6668
}
67-
void begin(DisplayDriver* display, NodePrefs* node_prefs);
69+
void begin(DisplayDriver* display, SensorManager* sensors, NodePrefs* node_prefs);
6870

6971
void setHasConnection(bool connected) { _connected = connected; }
7072
bool hasDisplay() const { return _display != NULL; }

examples/companion_radio/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ void setup() {
186186
sensors.begin();
187187

188188
#ifdef DISPLAY_CLASS
189-
ui_task.begin(disp, the_mesh.getNodePrefs()); // still want to pass this in as dependency, as prefs might be moved
189+
ui_task.begin(disp, &sensors, the_mesh.getNodePrefs()); // still want to pass this in as dependency, as prefs might be moved
190190
#endif
191191
}
192192

src/MeshCore.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ class MainBoard {
4141
virtual void onAfterTransmit() { }
4242
virtual void reboot() = 0;
4343
virtual void powerOff() { /* no op */ }
44-
virtual bool toggleGps() { return false; } // could be a board_toggle depending on the board features ...
4544
virtual uint8_t getStartupReason() const = 0;
4645
virtual bool startOTAUpdate(const char* id, char reply[]) { return false; } // not supported
4746
};

src/helpers/SensorManager.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,6 @@ class SensorManager {
2121
virtual const char* getSettingName(int i) const { return NULL; }
2222
virtual const char* getSettingValue(int i) const { return NULL; }
2323
virtual bool setSettingValue(const char* name, const char* value) { return false; }
24+
virtual bool getGpsStatus() { return false; }
25+
virtual bool toggleGps() { return false; }
2426
};

variants/t1000-e/T1000eBoard.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include <Arduino.h>
22
#include "T1000eBoard.h"
33
#include <Wire.h>
4-
#include "target.h"
54

65
#include <bluefruit.h>
76

@@ -27,10 +26,6 @@ void T1000eBoard::begin() {
2726
delay(10); // give sx1262 some time to power up
2827
}
2928

30-
bool T1000eBoard::toggleGps() {
31-
return sensors.toggle_gps();
32-
}
33-
3429
#if 0
3530
static BLEDfu bledfu;
3631

variants/t1000-e/T1000eBoard.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ class T1000eBoard : public mesh::MainBoard {
6666
return 0;
6767
}
6868

69-
virtual bool toggleGps() override;
70-
7169
void powerOff() override {
7270
#ifdef HAS_GPS
7371
digitalWrite(GPS_VRTC_EN, LOW);

variants/t1000-e/target.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ class T1000SensorManager: public SensorManager {
2828
const char* getSettingName(int i) const override;
2929
const char* getSettingValue(int i) const override;
3030
bool setSettingValue(const char* name, const char* value) override;
31-
bool toggle_gps() { gps_active ? stop_gps() : start_gps(); return gps_active;}
31+
bool getGpsStatus() override { return gps_active; }
32+
bool toggleGps() override { gps_active ? sleep_gps() : start_gps(); return gps_active; }
3233
};
3334

3435
#ifdef DISPLAY_CLASS

0 commit comments

Comments
 (0)