Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions examples/companion_radio/ui-new/UITask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,13 +260,24 @@ class HomeScreen : public UIScreen {
#if ENV_INCLUDE_GPS == 1
} else if (_page == HomePage::GPS) {
LocationProvider* nmea = sensors.getLocationProvider();
char buf[50];
int y = 18;
display.drawTextLeftAlign(0, y, _task->getGPSState() ? "gps on" : "gps off");
bool gps_state = _task->getGPSState();
#ifdef PIN_GPS_SWITCH
bool hw_gps_state = digitalRead(PIN_GPS_SWITCH);
if (gps_state != hw_gps_state) {
strcpy(buf, gps_state ? "gps off(hw)" : "gps off(sw)");
} else {
strcpy(buf, gps_state ? "gps on" : "gps off");
}
#else
strcpy(buf, gps_state ? "gps on" : "gps off");
#endif
display.drawTextLeftAlign(0, y, buf);
if (nmea == NULL) {
y = y + 12;
display.drawTextLeftAlign(0, y, "Can't access GPS");
} else {
char buf[50];
strcpy(buf, nmea->isValid()?"fix":"no fix");
display.drawTextRightAlign(display.width()-1, y, buf);
y = y + 12;
Expand Down Expand Up @@ -716,10 +727,14 @@ void UITask::loop() {
_analogue_pin_read_millis = millis();
}
#endif
#if defined(DISP_BACKLIGHT) && defined(BACKLIGHT_BTN)
#if defined(BACKLIGHT_BTN)
if (millis() > next_backlight_btn_check) {
bool touch_state = digitalRead(PIN_BUTTON2);
#if defined(DISP_BACKLIGHT)
digitalWrite(DISP_BACKLIGHT, !touch_state);
#elif defined(EXP_PIN_BACKLIGHT)
expander.digitalWrite(EXP_PIN_BACKLIGHT, !touch_state);
#endif
next_backlight_btn_check = millis() + 300;
}
#endif
Expand Down
4 changes: 4 additions & 0 deletions src/helpers/sensors/EnvironmentSensorManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,11 @@ void EnvironmentSensorManager::initBasicGPS() {
delay(1000);

// We'll consider GPS detected if we see any data on Serial1
#ifdef ENV_SKIP_GPS_DETECT
gps_detected = true;
#else
gps_detected = (Serial1.available() > 0);
#endif

if (gps_detected) {
MESH_DEBUG_PRINTLN("GPS detected");
Expand Down
17 changes: 17 additions & 0 deletions src/helpers/ui/GxEPDDisplay.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@

#include "GxEPDDisplay.h"

#ifdef EXP_PIN_BACKLIGHT
#include <PCA9557.h>
extern PCA9557 expander;
#endif

#ifndef DISPLAY_ROTATION
#define DISPLAY_ROTATION 3
#endif

#ifdef ESP32
SPIClass SPI1 = SPIClass(FSPI);
#endif

bool GxEPDDisplay::begin() {
display.epd2.selectSPI(SPI1, SPISettings(4000000, MSBFIRST, SPI_MODE0));
#ifdef ESP32
SPI1.begin(PIN_DISPLAY_SCLK, PIN_DISPLAY_MISO, PIN_DISPLAY_MOSI, PIN_DISPLAY_CS);
#else
SPI1.begin();
#endif
display.init(115200, true, 2, false);
display.setRotation(DISPLAY_ROTATION);
setTextSize(1); // Default to size 1
Expand All @@ -27,13 +40,17 @@ void GxEPDDisplay::turnOn() {
if (!_init) begin();
#if defined(DISP_BACKLIGHT) && !defined(BACKLIGHT_BTN)
digitalWrite(DISP_BACKLIGHT, HIGH);
#elif defined(EXP_PIN_BACKLIGHT) && !defined(BACKLIGHT_BTN)
expander.digitalWrite(EXP_PIN_BACKLIGHT, HIGH);
#endif
_isOn = true;
}

void GxEPDDisplay::turnOff() {
#if defined(DISP_BACKLIGHT) && !defined(BACKLIGHT_BTN)
digitalWrite(DISP_BACKLIGHT, LOW);
#elif defined(EXP_PIN_BACKLIGHT) && !defined(BACKLIGHT_BTN)
expander.digitalWrite(EXP_PIN_BACKLIGHT, LOW);
#endif
_isOn = false;
}
Expand Down
47 changes: 47 additions & 0 deletions variants/thinknode_m5/ThinknodeM5Board.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#include "ThinknodeM5Board.h"

PCA9557 expander (0x18, &Wire1);

void ThinknodeM5Board::begin() {
// Start expander and configure pins
Wire1.begin(48, 47);
expander.pinMode(EXP_PIN_POWER, OUTPUT); // eink
expander.pinMode(EXP_PIN_BACKLIGHT, OUTPUT); // peripherals
expander.pinMode(EXP_PIN_LED, OUTPUT); // peripherals
expander.digitalWrite(EXP_PIN_POWER, HIGH);
expander.digitalWrite(EXP_PIN_BACKLIGHT, LOW);
expander.digitalWrite(EXP_PIN_LED, LOW);

#ifdef PIN_GPS_SWITCH
pinMode(PIN_GPS_SWITCH, INPUT);
#endif

ESP32Board::begin();
}

void ThinknodeM5Board::enterDeepSleep(uint32_t secs, int pin_wake_btn) {
esp_deep_sleep_start();
}

void ThinknodeM5Board::powerOff() {
enterDeepSleep(0);
}

uint16_t ThinknodeM5Board::getBattMilliVolts() {
analogReadResolution(12);
analogSetPinAttenuation(PIN_VBAT_READ, ADC_11db);

uint32_t mv = 0;
for (int i = 0; i < 8; ++i) {
mv += analogReadMilliVolts(PIN_VBAT_READ);
delayMicroseconds(200);
}
mv /= 8;

analogReadResolution(10);
return static_cast<uint16_t>(mv * ADC_MULTIPLIER );
}

const char* ThinknodeM5Board::getManufacturerName() const {
return "Elecrow ThinkNode M2";
}
27 changes: 27 additions & 0 deletions variants/thinknode_m5/ThinknodeM5Board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#pragma once

#include <Arduino.h>
#include <helpers/RefCountedDigitalPin.h>
#include <helpers/ESP32Board.h>
#include <driver/rtc_io.h>
#include <PCA9557.h>

extern PCA9557 expander;

class ThinknodeM5Board : public ESP32Board {

public:

void begin();
void enterDeepSleep(uint32_t secs, int pin_wake_btn = -1);
void powerOff() override;
uint16_t getBattMilliVolts() override;
const char* getManufacturerName() const override ;

void onBeforeTransmit() override {
expander.digitalWrite(EXP_PIN_LED, HIGH); // turn TX LED on
}
void onAfterTransmit() override {
expander.digitalWrite(EXP_PIN_LED, LOW); // turn TX LED off
}
};
28 changes: 28 additions & 0 deletions variants/thinknode_m5/pins_arduino.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Need this file for ESP32-S3
// No need to modify this file, changes to pins imported from variant.h
// Most is similar to https://github.com/espressif/arduino-esp32/blob/master/variants/esp32s3/pins_arduino.h

#ifndef Pins_Arduino_h
#define Pins_Arduino_h

#include <stdint.h>
#include <variant.h>

#define USB_VID 0x303a
#define USB_PID 0x1001

// Serial
static const uint8_t TX = PIN_GPS_TX;
static const uint8_t RX = PIN_GPS_RX;

// Default SPI will be mapped to Radio
static const uint8_t SS = P_LORA_NSS;
static const uint8_t SCK = P_LORA_SCLK;
static const uint8_t MOSI = P_LORA_MISO;
static const uint8_t MISO = P_LORA_MOSI;

// The default Wire will be mapped to PMU and RTC
static const uint8_t SCL = PIN_BOARD_SCL;
static const uint8_t SDA = PIN_BOARD_SDA;

#endif /* Pins_Arduino_h */
Loading