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
5 changes: 1 addition & 4 deletions src/buzz/BuzzerFeedbackThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,7 @@ int32_t BuzzerFeedbackThread::runOnce()
// This thread is primarily event-driven, but we can use runOnce
// for any periodic tasks if needed in the future

if (needsUpdate) {
needsUpdate = false;
// Could add any periodic processing here
}
needsUpdate = false;

// Run every 100ms when active, less frequently when idle
return needsUpdate ? 100 : 1000;
Expand Down
2 changes: 1 addition & 1 deletion src/graphics/Screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,7 @@ void Screen::setFrames(FrameFocus focus)
// Insert favorite frames *after* collecting them all
if (!favoriteFrames.empty()) {
fsi.positions.firstFavorite = numframes;
for (auto &f : favoriteFrames) {
for (const auto &f : favoriteFrames) {
normalFrames[numframes++] = f;
indicatorIcons.push_back(icon_node);
}
Expand Down
6 changes: 1 addition & 5 deletions src/graphics/draw/ClockRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ void drawDigitalClockFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int1
hour %= 12;
if (hour == 0)
hour = 12;
bool isPM = hour >= 12;
snprintf(timeString, sizeof(timeString), "%d:%02d", hour, minute);
} else {
snprintf(timeString, sizeof(timeString), "%02d:%02d", hour, minute);
Expand Down Expand Up @@ -366,9 +365,6 @@ void drawAnalogClockFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16

// hour hand radius and y coordinate
int16_t hourHandRadius = radius * 0.35;
if (isHighResolution) {
int16_t hourHandRadius = radius * 0.55;
}
int16_t hourHandNoonY = centerY - hourHandRadius;

display->setColor(OLEDDISPLAY_COLOR::WHITE);
Expand All @@ -386,7 +382,7 @@ void drawAnalogClockFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16

bool isPM = hour >= 12;
if (config.display.use_12h_clock) {
bool isPM = hour >= 12;
isPM = hour >= 12;
display->setFont(FONT_SMALL);
int yOffset = isHighResolution ? 1 : 0;
#ifdef USE_EINK
Expand Down
4 changes: 2 additions & 2 deletions src/input/ButtonThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct ButtonConfig {
bool touchQuirk = false;

// Constructor to set required parameter
ButtonConfig(uint8_t pin = 0) : pinNumber(pin) {}
explicit ButtonConfig(uint8_t pin = 0) : pinNumber(pin) {}
};

#ifndef BUTTON_CLICK_MS
Expand Down Expand Up @@ -62,7 +62,7 @@ class ButtonThread : public Observable<const InputEvent *>, public concurrency::
BUTTON_EVENT_COMBO_SHORT_LONG,
};

ButtonThread(const char *name);
explicit ButtonThread(const char *name);
int32_t runOnce() override;
OneButton userButton;
void attachButtonInterrupts();
Expand Down
2 changes: 1 addition & 1 deletion src/mesh/MeshPacketQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ meshtastic_MeshPacket *MeshPacketQueue::remove(NodeNum from, PacketId id, bool t
bool MeshPacketQueue::find(const NodeNum from, const PacketId id)
{
for (auto it = queue.begin(); it != queue.end(); it++) {
const auto p = (*it);
const auto *p = *it;
if (getFrom(p) == from && p->id == id) {
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/mesh/NodeDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1868,7 +1868,7 @@ UserLicenseStatus NodeDB::getLicenseStatus(uint32_t nodeNum)
return info->user.is_licensed ? UserLicenseStatus::Licensed : UserLicenseStatus::NotLicensed;
}

bool NodeDB::checkLowEntropyPublicKey(const meshtastic_Config_SecurityConfig_public_key_t keyToTest)
bool NodeDB::checkLowEntropyPublicKey(const meshtastic_Config_SecurityConfig_public_key_t &keyToTest)
{
if (keyToTest.size == 32) {
uint8_t keyHash[32] = {0};
Expand Down
2 changes: 1 addition & 1 deletion src/mesh/NodeDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ class NodeDB

bool hasValidPosition(const meshtastic_NodeInfoLite *n);

bool checkLowEntropyPublicKey(const meshtastic_Config_SecurityConfig_public_key_t keyToTest);
bool checkLowEntropyPublicKey(const meshtastic_Config_SecurityConfig_public_key_t &keyToTest);

bool backupPreferences(meshtastic_AdminMessage_BackupLocation location);
bool restorePreferences(meshtastic_AdminMessage_BackupLocation location,
Expand Down
6 changes: 3 additions & 3 deletions src/mesh/PacketHistory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ PacketHistory::PacketRecord *PacketHistory::find(NodeNum sender, PacketId id)
}

/** Insert/Replace oldest PacketRecord in recentPackets. */
void PacketHistory::insert(PacketRecord &r)
void PacketHistory::insert(const PacketRecord &r)
{
uint32_t now_millis = millis(); // Should not jump with time changes
uint32_t OldtrxTimeMsec = 0;
Expand Down Expand Up @@ -308,7 +308,7 @@ bool PacketHistory::wasRelayer(const uint8_t relayer, const uint32_t id, const N
return false;
}

PacketRecord *found = find(sender, id);
const PacketRecord *found = find(sender, id);

if (found == NULL) {
#if VERBOSE_PACKET_HISTORY
Expand All @@ -327,7 +327,7 @@ bool PacketHistory::wasRelayer(const uint8_t relayer, const uint32_t id, const N

/* Check if a certain node was a relayer of a packet in the history given iterator
* @return true if node was indeed a relayer, false if not */
bool PacketHistory::wasRelayer(const uint8_t relayer, PacketRecord &r)
bool PacketHistory::wasRelayer(const uint8_t relayer, const PacketRecord &r)
{
for (uint8_t i = 0; i < NUM_RELAYERS; i++) {
if (r.relayed_by[i] == relayer) {
Expand Down
4 changes: 2 additions & 2 deletions src/mesh/PacketHistory.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ class PacketHistory

/** Insert/Replace oldest PacketRecord in mx_recentPackets.
* @param r PacketRecord to insert or replace */
void insert(PacketRecord &r); // Insert or replace a packet record in the history
void insert(const PacketRecord &r); // Insert or replace a packet record in the history

/* Check if a certain node was a relayer of a packet in the history given iterator
* @return true if node was indeed a relayer, false if not */
bool wasRelayer(const uint8_t relayer, PacketRecord &r);
bool wasRelayer(const uint8_t relayer, const PacketRecord &r);

PacketHistory(const PacketHistory &); // non construction-copyable
PacketHistory &operator=(const PacketHistory &); // non copyable
Expand Down
41 changes: 21 additions & 20 deletions src/modules/CannedMessageModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1447,7 +1447,7 @@ void CannedMessageModule::drawEmotePickerScreen(OLEDDisplay *display, OLEDDispla
int headerY = y;
int listTop = headerY + headerFontHeight + headerMargin;

int visibleRows = (display->getHeight() - listTop - 2) / rowHeight;
int _visibleRows = (display->getHeight() - listTop - 2) / rowHeight;
int numEmotes = graphics::numEmotes;

// Clamp highlight index
Expand All @@ -1457,11 +1457,11 @@ void CannedMessageModule::drawEmotePickerScreen(OLEDDisplay *display, OLEDDispla
emotePickerIndex = numEmotes - 1;

// Determine which emote is at the top
int topIndex = emotePickerIndex - visibleRows / 2;
int topIndex = emotePickerIndex - _visibleRows / 2;
if (topIndex < 0)
topIndex = 0;
if (topIndex > numEmotes - visibleRows)
topIndex = std::max(0, numEmotes - visibleRows);
if (topIndex > numEmotes - _visibleRows)
topIndex = std::max(0, numEmotes - _visibleRows);

// Draw header/title
display->setFont(FONT_SMALL);
Expand Down Expand Up @@ -1709,7 +1709,7 @@ void CannedMessageModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *st
} else {
// Text: split by words and wrap inside word if needed
String text = token.second;
uint16_t pos = 0;
pos = 0;
while (pos < text.length()) {
// Find next space (or end)
int spacePos = text.indexOf(' ', pos);
Expand Down Expand Up @@ -1753,7 +1753,7 @@ void CannedMessageModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *st
int yLine = inputY;
for (auto &line : lines) {
int nextX = x;
for (auto &token : line) {
for (const auto &token : line) {
if (token.first) {
const graphics::Emote *emote = nullptr;
for (int j = 0; j < graphics::numEmotes; j++) {
Expand Down Expand Up @@ -1789,19 +1789,20 @@ void CannedMessageModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *st

int topMsg;
std::vector<int> rowHeights;
int visibleRows;
int _visibleRows;

// Draw header (To: ...)
drawHeader(display, x, y, buffer);

// Shift message list upward by 3 pixels to reduce spacing between header and first message
const int listYOffset = y + FONT_HEIGHT_SMALL - 3;
visibleRows = (display->getHeight() - listYOffset) / baseRowSpacing;
_visibleRows = (display->getHeight() - listYOffset) / baseRowSpacing;

// Figure out which messages are visible and their needed heights
topMsg =
(messagesCount > visibleRows && currentMessageIndex >= visibleRows - 1) ? currentMessageIndex - visibleRows + 2 : 0;
int countRows = std::min(messagesCount, visibleRows);
topMsg = (messagesCount > _visibleRows && currentMessageIndex >= _visibleRows - 1)
? currentMessageIndex - _visibleRows + 2
: 0;
int countRows = std::min(messagesCount, _visibleRows);

// --- Build per-row max height based on all emotes in line ---
for (int i = 0; i < countRows; i++) {
Expand All @@ -1828,7 +1829,7 @@ void CannedMessageModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *st
int lineY = yCursor;
const char *msg = getMessageByIndex(msgIdx);
int rowHeight = rowHeights[vis];
bool highlight = (msgIdx == currentMessageIndex);
bool _highlight = (msgIdx == currentMessageIndex);

// --- Multi-emote tokenization ---
std::vector<std::pair<bool, String>> tokens; // (isEmote, token)
Expand Down Expand Up @@ -1881,20 +1882,20 @@ void CannedMessageModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *st
int textYOffset = (rowHeight - FONT_HEIGHT_SMALL) / 2;

#ifdef USE_EINK
int nextX = x + (highlight ? 12 : 0);
if (highlight)
int nextX = x + (_highlight ? 12 : 0);
if (_highlight)
display->drawString(x + 0, lineY + textYOffset, ">");
#else
int scrollPadding = 8;
if (highlight) {
if (_highlight) {
display->fillRect(x + 0, lineY, display->getWidth() - scrollPadding, rowHeight);
display->setColor(BLACK);
}
int nextX = x + (highlight ? 2 : 0);
int nextX = x + (_highlight ? 2 : 0);
#endif

// Draw all tokens left to right
for (auto &token : tokens) {
for (const auto &token : tokens) {
if (token.first) {
// Emote
const graphics::Emote *emote = nullptr;
Expand All @@ -1916,19 +1917,19 @@ void CannedMessageModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *st
}
}
#ifndef USE_EINK
if (highlight)
if (_highlight)
display->setColor(WHITE);
#endif

yCursor += rowHeight;
}

// Scrollbar
if (messagesCount > visibleRows) {
if (messagesCount > _visibleRows) {
int scrollHeight = display->getHeight() - listYOffset;
int scrollTrackX = display->getWidth() - 6;
display->drawRect(scrollTrackX, listYOffset, 4, scrollHeight);
int barHeight = (scrollHeight * visibleRows) / messagesCount;
int barHeight = (scrollHeight * _visibleRows) / messagesCount;
int scrollPos = listYOffset + (scrollHeight * topMsg) / messagesCount;
display->fillRect(scrollTrackX, scrollPos, 4, barHeight);
}
Expand Down