Skip to content
Draft
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
4 changes: 2 additions & 2 deletions src/Power.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ class AnalogBatteryLevel : public HasBatteryLevel
// ADC2 wifi bug workaround not required, breaks compile
// On ESP32S3, ADC2 can take turns with Wifi (?)

int32_t adc_buf;
int adc_buf;
esp_err_t read_result;

// Multiple samples
Expand All @@ -394,7 +394,7 @@ class AnalogBatteryLevel : public HasBatteryLevel
}

#else // Other ESP32
int32_t adc_buf = 0;
int adc_buf = 0;
for (int i = 0; i < BATTERY_SENSE_SAMPLES; i++) {
// ADC2 wifi bug workaround, see
// https://github.com/espressif/arduino-esp32/issues/102
Expand Down
2 changes: 1 addition & 1 deletion src/gps/RTC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ time_t gm_mktime(struct tm *tm)
days_before_this_year -= 719162; // (1969 * 365 + 1969 / 4 - 1969 / 100 + 1969 / 400);

// Now, within this tm->year, compute the days *before* this tm->month starts.
int days_before_month[12] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}; // non-leap year
const int days_before_month[12] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}; // non-leap year
int days_this_year_before_this_month = days_before_month[tm->tm_mon]; // tm->tm_mon is 0..11

// If this is a leap year, and we're past February, add a day:
Expand Down
16 changes: 3 additions & 13 deletions src/graphics/Screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,6 @@ static void drawModuleFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int
pi.drawFrame(display, state, x, y);
}

// Ignore messages originating from phone (from the current node 0x0) unless range test or store and forward module are enabled
static bool shouldDrawMessage(const meshtastic_MeshPacket *packet)
{
return packet->from != 0 && !moduleConfig.store_forward.enabled;
}

/**
* Given a recent lat/lon return a guess of the heading the user is walking on.
*
Expand Down Expand Up @@ -341,9 +335,7 @@ Screen::Screen(ScanI2C::DeviceAddress address, meshtastic_Config_DisplayConfig_O
uint8_t TFT_MESH_b = rawRGB & 0xFF;
LOG_INFO("Values of r,g,b: %d, %d, %d", TFT_MESH_r, TFT_MESH_g, TFT_MESH_b);

if (TFT_MESH_r <= 255 && TFT_MESH_g <= 255 && TFT_MESH_b <= 255) {
TFT_MESH = COLOR565(TFT_MESH_r, TFT_MESH_g, TFT_MESH_b);
}
TFT_MESH = COLOR565(TFT_MESH_r, TFT_MESH_g, TFT_MESH_b);
}

#if defined(USE_SH1106) || defined(USE_SH1107) || defined(USE_SH1107_128_64)
Expand Down Expand Up @@ -813,6 +805,7 @@ int32_t Screen::runOnce()
break;
case Cmd::STOP_ALERT_FRAME:
NotificationRenderer::pauseBanner = false;
break;
case Cmd::STOP_BOOT_SCREEN:
EINK_ADD_FRAMEFLAG(dispdev, COSMETIC); // E-Ink: Explicitly use full-refresh for next frame
if (NotificationRenderer::current_notification_type != notificationTypeEnum::text_input) {
Expand All @@ -822,7 +815,7 @@ int32_t Screen::runOnce()
case Cmd::NOOP:
break;
default:
LOG_ERROR("Invalid screen cmd");
LOG_ERROR("Invalid screen cmd %d", static_cast<int>(cmd.cmd));
}
}

Expand Down Expand Up @@ -983,9 +976,6 @@ void Screen::setFrames(FrameFocus focus)
}
#endif

// Declare this early so it’s available in FOCUS_PRESERVE block
bool willInsertTextMessage = shouldDrawMessage(&devicestate.rx_text_message);

if (!hiddenFrames.home) {
fsi.positions.home = numframes;
normalFrames[numframes++] = graphics::UIRenderer::drawDeviceFocused;
Expand Down
3 changes: 1 addition & 2 deletions src/graphics/SharedUIDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,8 @@ void drawCommonHeader(OLEDDisplay *display, int16_t x, int16_t y, const char *ti
// plugged in
}

uint32_t now = millis();

#ifndef USE_EINK
uint32_t now = millis();
if (isCharging && now - lastBlinkShared > 500) {
isBoltVisibleShared = !isBoltVisibleShared;
lastBlinkShared = now;
Expand Down
2 changes: 0 additions & 2 deletions src/graphics/VirtualKeyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,6 @@ void VirtualKeyboard::drawInputArea(OLEDDisplay *display, int16_t offsetX, int16
if (screenHeight <= 64) {
textY = boxY + (boxHeight - inputLineH) / 2;
} else {
const int innerLeft = boxX + 1;
const int innerRight = boxX + boxWidth - 2;
const int innerTop = boxY + 1;
const int innerBottom = boxY + boxHeight - 2;

Expand Down
12 changes: 5 additions & 7 deletions src/graphics/draw/ClockRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ void drawDigitalClockFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int1
const char *titleStr = "";
// === Header ===
graphics::drawCommonHeader(display, x, y, titleStr, true, true);
int line = 0;

#ifdef T_WATCH_S3
if (nimbleBluetooth && nimbleBluetooth->isConnected()) {
Expand Down Expand Up @@ -317,7 +316,6 @@ void drawAnalogClockFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16
const char *titleStr = "";
// === Header ===
graphics::drawCommonHeader(display, x, y, titleStr, true, true);
int line = 0;

#ifdef T_WATCH_S3
if (nimbleBluetooth && nimbleBluetooth->isConnected()) {
Expand Down Expand Up @@ -413,17 +411,12 @@ void drawAnalogClockFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16
double minuteAngleOffset = ((double)second / 60) * degreesPerMinuteOrSecond;
double minuteAngle = radians(minuteBaseAngle + minuteAngleOffset);

double secondAngle = radians(second * degreesPerMinuteOrSecond);

double hourX = sin(-hourAngle) * (hourHandNoonY - centerY) + noonX;
double hourY = cos(-hourAngle) * (hourHandNoonY - centerY) + centerY;

double minuteX = sin(-minuteAngle) * (minuteHandNoonY - centerY) + noonX;
double minuteY = cos(-minuteAngle) * (minuteHandNoonY - centerY) + centerY;

double secondX = sin(-secondAngle) * (secondHandNoonY - centerY) + noonX;
double secondY = cos(-secondAngle) * (secondHandNoonY - centerY) + centerY;

display->setFont(FONT_MEDIUM);

// draw minute and hour tick marks and hour numbers
Expand Down Expand Up @@ -512,6 +505,11 @@ void drawAnalogClockFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16
// draw minute hand
display->drawLine(centerX, centerY, minuteX, minuteY);
#ifndef USE_EINK
double secondAngle = radians(second * degreesPerMinuteOrSecond);

double secondX = sin(-secondAngle) * (secondHandNoonY - centerY) + noonX;
double secondY = cos(-secondAngle) * (secondHandNoonY - centerY) + centerY;

// draw second hand
display->drawLine(centerX, centerY, secondX, secondY);
#endif
Expand Down
3 changes: 2 additions & 1 deletion src/graphics/draw/NodeListRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,11 +362,12 @@ void drawCompassArrow(OLEDDisplay *display, meshtastic_NodeInfoLite *node, int16
float bearing = GeoCoord::bearing(userLat, userLon, nodeLat, nodeLon);
float bearingToNode = RAD_TO_DEG * bearing;
float relativeBearing = fmod((bearingToNode - myHeading + 360), 360);
float angle = relativeBearing * DEG_TO_RAD;

// Shrink size by 2px
int size = FONT_HEIGHT_SMALL - 5;
CompassRenderer::drawArrowToNode(display, centerX, centerY, size, relativeBearing);
/*
float angle = relativeBearing * DEG_TO_RAD;
float halfSize = size / 2.0;

// Point of the arrow
Expand Down
11 changes: 5 additions & 6 deletions src/graphics/draw/UIRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,6 @@ void UIRenderer::drawCompassAndLocationScreen(OLEDDisplay *display, OLEDDisplayU
config.display.heading_bold = false;

const char *displayLine = ""; // Initialize to empty string by default
meshtastic_NodeInfoLite *ourNode = nodeDB->getMeshNode(nodeDB->getNodeNum());

if (config.position.gps_mode != meshtastic_Config_PositionConfig_GpsMode_ENABLED) {
if (config.position.fixed_position) {
Expand Down Expand Up @@ -1050,7 +1049,6 @@ void UIRenderer::drawCompassAndLocationScreen(OLEDDisplay *display, OLEDDisplayU
uint32_t days = delta / 86400;
uint32_t hours = (delta % 86400) / 3600;
uint32_t mins = (delta % 3600) / 60;
uint32_t secs = delta % 60;

char buf[32];
#if defined(USE_EINK)
Expand All @@ -1063,6 +1061,7 @@ void UIRenderer::drawCompassAndLocationScreen(OLEDDisplay *display, OLEDDisplayU
snprintf(buf, sizeof(buf), "Last: %um", mins);
}
#else
uint32_t secs = delta % 60;
// Non E-Ink: include seconds where useful
if (days > 0) {
snprintf(buf, sizeof(buf), "Last: %ud %uh", days, hours);
Expand Down Expand Up @@ -1140,13 +1139,13 @@ void UIRenderer::drawCompassAndLocationScreen(OLEDDisplay *display, OLEDDisplayU
// Portrait or square: put compass at the bottom and centered, scaled to fit available space
// For E-Ink screens, account for navigation bar at the bottom!
int yBelowContent = getTextPositions(display)[5] + FONT_HEIGHT_SMALL + 2;
const int margin = 4;
int availableHeight =

#if defined(USE_EINK)
SCREEN_HEIGHT - yBelowContent - 24; // Leave extra space for nav bar on E-Ink
const int margin = 24; // Leave extra space for nav bar on E-Ink
#else
SCREEN_HEIGHT - yBelowContent - margin;
const int margin = 4;
#endif
int availableHeight = SCREEN_HEIGHT - yBelowContent - margin;

if (availableHeight < FONT_HEIGHT_SMALL * 2)
return;
Expand Down
3 changes: 0 additions & 3 deletions src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,3 @@ meshtastic_DeviceMetadata getDeviceMetadata();
void scannerToSensorsMap(const std::unique_ptr<ScanI2CTwoWire> &i2cScanner, ScanI2C::DeviceType deviceType,
meshtastic_TelemetrySensorType sensorType);
#endif

// We default to 4MHz SPI, SPI mode 0
extern SPISettings spiSettings;
6 changes: 1 addition & 5 deletions src/modules/ExternalNotificationModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,7 @@ int32_t ExternalNotificationModule::runOnce()
return INT32_MAX; // we don't need this thread here...
} else {
uint32_t delay = EXT_NOTIFICATION_MODULE_OUTPUT_MS;
bool isRtttlPlaying = rtttl::isPlaying();
#ifdef HAS_I2S
// audioThread->isPlaying() also handles actually playing the RTTTL, needs to be called in loop
isRtttlPlaying = isRtttlPlaying || audioThread->isPlaying();
#endif

if ((nagCycleCutoff <= millis())) {
// Turn off external notification immediately when timeout is reached, regardless of song state
nagCycleCutoff = UINT32_MAX;
Expand Down
7 changes: 3 additions & 4 deletions src/nimble/NimbleBluetooth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "mesh/mesh-pb-constants.h"
#include "sleep.h"
#include <NimBLEDevice.h>
#include <array>
#include <atomic>
#include <mutex>

Expand Down Expand Up @@ -312,11 +313,9 @@ class BluetoothPhoneAPI : public PhoneAPI, public concurrency::OSThread
{
PhoneAPI::onNowHasData(fromRadioNum);

int currentNotifyCount = notifyCount.fetch_add(1);

uint8_t cc = bleServer->getConnectedCount();

#ifdef DEBUG_NIMBLE_NOTIFY
uint8_t cc = bleServer->getConnectedCount();
int currentNotifyCount = notifyCount.fetch_add(1);
// This logging slows things down when there are lots of packets going to the phone, like initial connection:
LOG_DEBUG("BLE notify(%d) fromNum: %d connections: %d", currentNotifyCount, fromRadioNum, cc);
#endif
Expand Down
8 changes: 4 additions & 4 deletions src/platform/portduino/PortduinoGlue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ void portduinoSetup()
randomSeed(time(NULL));

std::string defaultGpioChipName = gpioChipName + std::to_string(portduino_config.lora_default_gpiochip);
for (auto i : portduino_config.all_pins) {
for (const auto i : portduino_config.all_pins) {
if (i->enabled && i->pin > max_GPIO)
max_GPIO = i->pin;
}
Expand All @@ -392,7 +392,7 @@ void portduinoSetup()

// Need to bind all the configured GPIO pins so they're not simulated
// TODO: If one of these fails, we should log and terminate
for (auto i : portduino_config.all_pins) {
for (const auto i : portduino_config.all_pins) {
if (i->enabled)
if (initGPIOPin(i->pin, gpioChipName + std::to_string(i->gpiochip), i->line) != ERRNO_OK) {
printf("Error setting pin number %d. It may not exist, or may already be in use.\n", i->line);
Expand All @@ -419,7 +419,7 @@ void portduinoSetup()
return;
}

int initGPIOPin(int pinNum, const std::string gpioChipName, int line)
int initGPIOPin(int pinNum, const std::string &gpioChipName, int line)
{
#ifdef PORTDUINO_LINUX_HARDWARE
std::string gpio_name = "GPIO" + std::to_string(pinNum);
Expand Down Expand Up @@ -579,7 +579,7 @@ bool loadConfig(const char *configPath)
}
if (yamlConfig["Display"]) {

for (auto &screen_name : portduino_config.screen_names) {
for (const auto &screen_name : portduino_config.screen_names) {
if (yamlConfig["Display"]["Panel"].as<std::string>("") == screen_name.second)
portduino_config.displayPanel = screen_name.first;
}
Expand Down
10 changes: 5 additions & 5 deletions src/platform/portduino/PortduinoGlue.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ struct pinMapping {

extern std::ofstream traceFile;
extern Ch341Hal *ch341Hal;
int initGPIOPin(int pinNum, std::string gpioChipname, int line);
int initGPIOPin(int pinNum, const std::string & gpioChipname, int line);
bool loadConfig(const char *configPath);
static bool ends_with(std::string_view str, std::string_view suffix);
void getMacAddr(uint8_t *dmac);
Expand Down Expand Up @@ -202,7 +202,7 @@ extern struct portduino_config_struct {
out << YAML::Key << "Lora" << YAML::Value << YAML::BeginMap;
out << YAML::Key << "Module" << YAML::Value << loraModules[lora_module];

for (auto lora_pin : all_pins) {
for (const auto lora_pin : all_pins) {
if (lora_pin->config_section == "Lora" && lora_pin->enabled) {
out << YAML::Key << lora_pin->config_name << YAML::Value << YAML::BeginMap;
out << YAML::Key << "pin" << YAML::Value << lora_pin->pin;
Expand Down Expand Up @@ -307,7 +307,7 @@ extern struct portduino_config_struct {
if (displayPanel == screen_name.first)
out << YAML::Key << "Module" << YAML::Value << screen_name.second;
}
for (auto display_pin : all_pins) {
for (const auto display_pin : all_pins) {
if (display_pin->config_section == "Display" && display_pin->enabled) {
out << YAML::Key << display_pin->config_name << YAML::Value << YAML::BeginMap;
out << YAML::Key << "pin" << YAML::Value << display_pin->pin;
Expand Down Expand Up @@ -355,7 +355,7 @@ extern struct portduino_config_struct {
case ft5x06:
out << YAML::Key << "Module" << YAML::Value << "FT5x06";
}
for (auto touchscreen_pin : all_pins) {
for (const auto touchscreen_pin : all_pins) {
if (touchscreen_pin->config_section == "Touchscreen" && touchscreen_pin->enabled) {
out << YAML::Key << touchscreen_pin->config_name << YAML::Value << YAML::BeginMap;
out << YAML::Key << "pin" << YAML::Value << touchscreen_pin->pin;
Expand All @@ -378,7 +378,7 @@ extern struct portduino_config_struct {
if (pointerDevice != "")
out << YAML::Key << "PointerDevice" << YAML::Value << pointerDevice;

for (auto input_pin : all_pins) {
for (const auto input_pin : all_pins) {
if (input_pin->config_section == "Input" && input_pin->enabled) {
out << YAML::Key << input_pin->config_name << YAML::Value << YAML::BeginMap;
out << YAML::Key << "pin" << YAML::Value << input_pin->pin;
Expand Down
2 changes: 1 addition & 1 deletion src/platform/portduino/USBHal.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Ch341Hal : public RadioLibHal
{
public:
// default constructor - initializes the base HAL and any needed private members
explicit Ch341Hal(uint8_t spiChannel, std::string serial = "", uint32_t vid = 0x1A86, uint32_t pid = 0x5512,
explicit Ch341Hal(uint8_t spiChannel, const std::string& serial = "", uint32_t vid = 0x1A86, uint32_t pid = 0x5512,
uint32_t spiSpeed = 2000000, uint8_t spiDevice = 0, uint8_t gpioDevice = 0)
: RadioLibHal(PI_INPUT, PI_OUTPUT, PI_LOW, PI_HIGH, PI_RISING, PI_FALLING)
{
Expand Down