Skip to content

Commit 79db7a5

Browse files
committed
WIP: GPS works
1 parent 7289b2a commit 79db7a5

5 files changed

Lines changed: 18 additions & 12 deletions

File tree

src/gps/GPS.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,6 +1078,7 @@ void GPS::publishUpdate()
10781078

10791079
int32_t GPS::runOnce()
10801080
{
1081+
#if !defined(SENSECAP_INDICATOR)
10811082
if (!GPSInitFinished) {
10821083
if (!_serial_gps || config.position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_NOT_PRESENT) {
10831084
LOG_INFO("GPS set to not-present. Skip probe");
@@ -1093,6 +1094,7 @@ int32_t GPS::runOnce()
10931094
GPSInitFinished = true;
10941095
publishUpdate();
10951096
}
1097+
#endif
10961098

10971099
// Repeaters have no need for GPS
10981100
if (config.device.role == meshtastic_Config_DeviceConfig_Role_REPEATER) {
@@ -1411,8 +1413,10 @@ GPS *GPS::createGps()
14111413
if (!settingsMap[has_gps])
14121414
return nullptr;
14131415
#endif
1416+
#if !defined(SENSECAP_INDICATOR)
14141417
if (!_rx_gpio || !_serial_gps) // Configured to have no GPS at all
14151418
return nullptr;
1419+
#endif
14161420

14171421
GPS *new_gps = new GPS;
14181422
new_gps->rx_gpio = _rx_gpio;

src/mesh/IndicatorSerial.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
#ifdef SENSECAP_INDICATOR
22

33
#include "IndicatorSerial.h"
4-
#include "mesh/comms/FakeUART.h"
54
#include "mesh/comms/FakeI2C.h"
5+
#include "mesh/comms/FakeUART.h"
66
#include <HardwareSerial.h>
77
#include <pb_decode.h>
88
#include <pb_encode.h>
99

1010
SensecapIndicator *sensecapIndicator;
1111

12-
SensecapIndicator::SensecapIndicator(HardwareSerial &serial) : OSThread("SensecapIndicator") {
12+
SensecapIndicator::SensecapIndicator(HardwareSerial &serial) : OSThread("SensecapIndicator")
13+
{
1314
if (!running) {
1415
_serial = &serial;
1516
_serial->setRxBufferSize(PB_BUFSIZE);
1617
_serial->setPins(SENSOR_RP2040_RXD, SENSOR_RP2040_TXD);
1718
_serial->begin(SENSOR_BAUD_RATE);
1819
running = true;
19-
LOG_DEBUG("Start communication thread");
20+
LOG_DEBUG("Start indicator communication thread");
2021
}
2122
}
2223

@@ -120,7 +121,8 @@ bool SensecapIndicator::handle_packet(size_t payload_len)
120121
return false;
121122
}
122123
switch (message.which_data) {
123-
case meshtastic_InterdeviceMessage_i2c_response_tag:
124+
case meshtastic_InterdeviceMessage_i2c_response_tag:
125+
LOG_DEBUG("Got I2C response");
124126
if (message.data.i2c_response.status != meshtastic_I2CResponse_Status_OK) {
125127
LOG_DEBUG("I2C response error: %d", message.data.i2c_response.status);
126128
return false;

src/mesh/IndicatorSerial.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@
2525
class SensecapIndicator : public concurrency::OSThread
2626
{
2727
public:
28-
SensecapIndicator(HardwareSerial& serial);
28+
SensecapIndicator(HardwareSerial &serial);
2929
int32_t runOnce() override;
3030
bool send_uplink(meshtastic_InterdeviceMessage message);
3131

3232
private:
3333
pb_byte_t pb_tx_buf[PB_BUFSIZE];
3434
pb_byte_t pb_rx_buf[PB_BUFSIZE];
3535
size_t pb_rx_size = 0; // Number of bytes currently in the buffer
36-
HardwareSerial* _serial = &Serial2;
36+
HardwareSerial *_serial = &Serial2;
3737
bool running = false;
3838
size_t serial_check(char *buf, size_t space_left);
3939
void check_packet();

src/mesh/comms/FakeUART.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ size_t FakeUART::write(char *buffer, size_t size)
7777
size = sizeof(message.data.nmea); // Truncate if buffer is too large
7878
}
7979
memcpy(message.data.nmea, buffer, size);
80+
message.which_data = meshtastic_InterdeviceMessage_nmea_tag;
81+
LOG_DEBUG("FakeUART::write(%s)", message.data.nmea);
8082
sensecapIndicator->send_uplink(message);
8183
return size;
8284
}

variants/seeed-sensecap-indicator/variant.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,7 @@
4444
#define TOUCH_I2C_PORT 0
4545
#define TOUCH_SLAVE_ADDRESS 0x48
4646

47-
// in future, we may want to add a buzzer and add all sensors to the indicator via a data protocol for now only GPS is supported
48-
// // Buzzer
49-
// #define PIN_BUZZER 19
50-
5147
#define GPS_DEFAULT_NOT_PRESENT 1
52-
#define GPS_RX_PIN 20
53-
#define GPS_TX_PIN 19
5448
#define HAS_GPS 1
5549

5650
#define USE_SX1262
@@ -78,3 +72,7 @@
7872

7973
#define USE_VIRTUAL_KEYBOARD 1
8074
#define DISPLAY_CLOCK_FRAME 1
75+
76+
// this powers the RP 2040 on boot.
77+
#define SENSOR_POWER_CTRL_EXPANDER (8 | IO_EXPANDER)
78+
#define SENSOR_POWER_ON_EXPANDER 1

0 commit comments

Comments
 (0)