mirror of
https://github.com/meshtastic/firmware.git
synced 2025-08-03 20:30:43 +00:00
WIP: GPS works
This commit is contained in:
parent
7289b2a972
commit
79db7a5208
@ -1078,6 +1078,7 @@ void GPS::publishUpdate()
|
||||
|
||||
int32_t GPS::runOnce()
|
||||
{
|
||||
#if !defined(SENSECAP_INDICATOR)
|
||||
if (!GPSInitFinished) {
|
||||
if (!_serial_gps || config.position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_NOT_PRESENT) {
|
||||
LOG_INFO("GPS set to not-present. Skip probe");
|
||||
@ -1093,6 +1094,7 @@ int32_t GPS::runOnce()
|
||||
GPSInitFinished = true;
|
||||
publishUpdate();
|
||||
}
|
||||
#endif
|
||||
|
||||
// Repeaters have no need for GPS
|
||||
if (config.device.role == meshtastic_Config_DeviceConfig_Role_REPEATER) {
|
||||
@ -1411,8 +1413,10 @@ GPS *GPS::createGps()
|
||||
if (!settingsMap[has_gps])
|
||||
return nullptr;
|
||||
#endif
|
||||
#if !defined(SENSECAP_INDICATOR)
|
||||
if (!_rx_gpio || !_serial_gps) // Configured to have no GPS at all
|
||||
return nullptr;
|
||||
#endif
|
||||
|
||||
GPS *new_gps = new GPS;
|
||||
new_gps->rx_gpio = _rx_gpio;
|
||||
|
@ -1,22 +1,23 @@
|
||||
#ifdef SENSECAP_INDICATOR
|
||||
|
||||
#include "IndicatorSerial.h"
|
||||
#include "mesh/comms/FakeUART.h"
|
||||
#include "mesh/comms/FakeI2C.h"
|
||||
#include "mesh/comms/FakeUART.h"
|
||||
#include <HardwareSerial.h>
|
||||
#include <pb_decode.h>
|
||||
#include <pb_encode.h>
|
||||
|
||||
SensecapIndicator *sensecapIndicator;
|
||||
|
||||
SensecapIndicator::SensecapIndicator(HardwareSerial &serial) : OSThread("SensecapIndicator") {
|
||||
SensecapIndicator::SensecapIndicator(HardwareSerial &serial) : OSThread("SensecapIndicator")
|
||||
{
|
||||
if (!running) {
|
||||
_serial = &serial;
|
||||
_serial->setRxBufferSize(PB_BUFSIZE);
|
||||
_serial->setPins(SENSOR_RP2040_RXD, SENSOR_RP2040_TXD);
|
||||
_serial->begin(SENSOR_BAUD_RATE);
|
||||
running = true;
|
||||
LOG_DEBUG("Start communication thread");
|
||||
LOG_DEBUG("Start indicator communication thread");
|
||||
}
|
||||
}
|
||||
|
||||
@ -120,7 +121,8 @@ bool SensecapIndicator::handle_packet(size_t payload_len)
|
||||
return false;
|
||||
}
|
||||
switch (message.which_data) {
|
||||
case meshtastic_InterdeviceMessage_i2c_response_tag:
|
||||
case meshtastic_InterdeviceMessage_i2c_response_tag:
|
||||
LOG_DEBUG("Got I2C response");
|
||||
if (message.data.i2c_response.status != meshtastic_I2CResponse_Status_OK) {
|
||||
LOG_DEBUG("I2C response error: %d", message.data.i2c_response.status);
|
||||
return false;
|
||||
|
@ -25,7 +25,7 @@
|
||||
class SensecapIndicator : public concurrency::OSThread
|
||||
{
|
||||
public:
|
||||
SensecapIndicator(HardwareSerial& serial);
|
||||
SensecapIndicator(HardwareSerial &serial);
|
||||
int32_t runOnce() override;
|
||||
bool send_uplink(meshtastic_InterdeviceMessage message);
|
||||
|
||||
@ -33,7 +33,7 @@ class SensecapIndicator : public concurrency::OSThread
|
||||
pb_byte_t pb_tx_buf[PB_BUFSIZE];
|
||||
pb_byte_t pb_rx_buf[PB_BUFSIZE];
|
||||
size_t pb_rx_size = 0; // Number of bytes currently in the buffer
|
||||
HardwareSerial* _serial = &Serial2;
|
||||
HardwareSerial *_serial = &Serial2;
|
||||
bool running = false;
|
||||
size_t serial_check(char *buf, size_t space_left);
|
||||
void check_packet();
|
||||
|
@ -77,6 +77,8 @@ size_t FakeUART::write(char *buffer, size_t size)
|
||||
size = sizeof(message.data.nmea); // Truncate if buffer is too large
|
||||
}
|
||||
memcpy(message.data.nmea, buffer, size);
|
||||
message.which_data = meshtastic_InterdeviceMessage_nmea_tag;
|
||||
LOG_DEBUG("FakeUART::write(%s)", message.data.nmea);
|
||||
sensecapIndicator->send_uplink(message);
|
||||
return size;
|
||||
}
|
||||
|
@ -44,13 +44,7 @@
|
||||
#define TOUCH_I2C_PORT 0
|
||||
#define TOUCH_SLAVE_ADDRESS 0x48
|
||||
|
||||
// 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
|
||||
// // Buzzer
|
||||
// #define PIN_BUZZER 19
|
||||
|
||||
#define GPS_DEFAULT_NOT_PRESENT 1
|
||||
#define GPS_RX_PIN 20
|
||||
#define GPS_TX_PIN 19
|
||||
#define HAS_GPS 1
|
||||
|
||||
#define USE_SX1262
|
||||
@ -78,3 +72,7 @@
|
||||
|
||||
#define USE_VIRTUAL_KEYBOARD 1
|
||||
#define DISPLAY_CLOCK_FRAME 1
|
||||
|
||||
// this powers the RP 2040 on boot.
|
||||
#define SENSOR_POWER_CTRL_EXPANDER (8 | IO_EXPANDER)
|
||||
#define SENSOR_POWER_ON_EXPANDER 1
|
||||
|
Loading…
Reference in New Issue
Block a user