mirror of
https://github.com/meshtastic/firmware.git
synced 2025-08-01 19:35:42 +00:00
Misc cppcheck fixes
This commit is contained in:
parent
71b6508ad3
commit
37fd05c9a4
@ -69,10 +69,7 @@ int32_t BuzzerFeedbackThread::runOnce()
|
|||||||
// This thread is primarily event-driven, but we can use runOnce
|
// This thread is primarily event-driven, but we can use runOnce
|
||||||
// for any periodic tasks if needed in the future
|
// for any periodic tasks if needed in the future
|
||||||
|
|
||||||
if (needsUpdate) {
|
needsUpdate = false;
|
||||||
needsUpdate = false;
|
|
||||||
// Could add any periodic processing here
|
|
||||||
}
|
|
||||||
|
|
||||||
// Run every 100ms when active, less frequently when idle
|
// Run every 100ms when active, less frequently when idle
|
||||||
return needsUpdate ? 100 : 1000;
|
return needsUpdate ? 100 : 1000;
|
||||||
|
@ -1001,7 +1001,7 @@ void Screen::setFrames(FrameFocus focus)
|
|||||||
// Insert favorite frames *after* collecting them all
|
// Insert favorite frames *after* collecting them all
|
||||||
if (!favoriteFrames.empty()) {
|
if (!favoriteFrames.empty()) {
|
||||||
fsi.positions.firstFavorite = numframes;
|
fsi.positions.firstFavorite = numframes;
|
||||||
for (auto &f : favoriteFrames) {
|
for (const auto &f : favoriteFrames) {
|
||||||
normalFrames[numframes++] = f;
|
normalFrames[numframes++] = f;
|
||||||
indicatorIcons.push_back(icon_node);
|
indicatorIcons.push_back(icon_node);
|
||||||
}
|
}
|
||||||
|
@ -218,7 +218,6 @@ void drawDigitalClockFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int1
|
|||||||
hour %= 12;
|
hour %= 12;
|
||||||
if (hour == 0)
|
if (hour == 0)
|
||||||
hour = 12;
|
hour = 12;
|
||||||
bool isPM = hour >= 12;
|
|
||||||
snprintf(timeString, sizeof(timeString), "%d:%02d", hour, minute);
|
snprintf(timeString, sizeof(timeString), "%d:%02d", hour, minute);
|
||||||
} else {
|
} else {
|
||||||
snprintf(timeString, sizeof(timeString), "%02d:%02d", hour, minute);
|
snprintf(timeString, sizeof(timeString), "%02d:%02d", hour, minute);
|
||||||
@ -366,9 +365,6 @@ void drawAnalogClockFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16
|
|||||||
|
|
||||||
// hour hand radius and y coordinate
|
// hour hand radius and y coordinate
|
||||||
int16_t hourHandRadius = radius * 0.35;
|
int16_t hourHandRadius = radius * 0.35;
|
||||||
if (isHighResolution) {
|
|
||||||
int16_t hourHandRadius = radius * 0.55;
|
|
||||||
}
|
|
||||||
int16_t hourHandNoonY = centerY - hourHandRadius;
|
int16_t hourHandNoonY = centerY - hourHandRadius;
|
||||||
|
|
||||||
display->setColor(OLEDDISPLAY_COLOR::WHITE);
|
display->setColor(OLEDDISPLAY_COLOR::WHITE);
|
||||||
@ -386,7 +382,7 @@ void drawAnalogClockFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16
|
|||||||
|
|
||||||
bool isPM = hour >= 12;
|
bool isPM = hour >= 12;
|
||||||
if (config.display.use_12h_clock) {
|
if (config.display.use_12h_clock) {
|
||||||
bool isPM = hour >= 12;
|
isPM = hour >= 12;
|
||||||
display->setFont(FONT_SMALL);
|
display->setFont(FONT_SMALL);
|
||||||
int yOffset = isHighResolution ? 1 : 0;
|
int yOffset = isHighResolution ? 1 : 0;
|
||||||
#ifdef USE_EINK
|
#ifdef USE_EINK
|
||||||
|
@ -24,7 +24,7 @@ struct ButtonConfig {
|
|||||||
bool touchQuirk = false;
|
bool touchQuirk = false;
|
||||||
|
|
||||||
// Constructor to set required parameter
|
// Constructor to set required parameter
|
||||||
ButtonConfig(uint8_t pin = 0) : pinNumber(pin) {}
|
explicit ButtonConfig(uint8_t pin = 0) : pinNumber(pin) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef BUTTON_CLICK_MS
|
#ifndef BUTTON_CLICK_MS
|
||||||
@ -62,7 +62,7 @@ class ButtonThread : public Observable<const InputEvent *>, public concurrency::
|
|||||||
BUTTON_EVENT_COMBO_SHORT_LONG,
|
BUTTON_EVENT_COMBO_SHORT_LONG,
|
||||||
};
|
};
|
||||||
|
|
||||||
ButtonThread(const char *name);
|
explicit ButtonThread(const char *name);
|
||||||
int32_t runOnce() override;
|
int32_t runOnce() override;
|
||||||
OneButton userButton;
|
OneButton userButton;
|
||||||
void attachButtonInterrupts();
|
void attachButtonInterrupts();
|
||||||
|
@ -121,7 +121,7 @@ meshtastic_MeshPacket *MeshPacketQueue::remove(NodeNum from, PacketId id, bool t
|
|||||||
bool MeshPacketQueue::find(const NodeNum from, const PacketId id)
|
bool MeshPacketQueue::find(const NodeNum from, const PacketId id)
|
||||||
{
|
{
|
||||||
for (auto it = queue.begin(); it != queue.end(); it++) {
|
for (auto it = queue.begin(); it != queue.end(); it++) {
|
||||||
const auto p = (*it);
|
const auto *p = *it;
|
||||||
if (getFrom(p) == from && p->id == id) {
|
if (getFrom(p) == from && p->id == id) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1868,7 +1868,7 @@ UserLicenseStatus NodeDB::getLicenseStatus(uint32_t nodeNum)
|
|||||||
return info->user.is_licensed ? UserLicenseStatus::Licensed : UserLicenseStatus::NotLicensed;
|
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) {
|
if (keyToTest.size == 32) {
|
||||||
uint8_t keyHash[32] = {0};
|
uint8_t keyHash[32] = {0};
|
||||||
|
@ -279,7 +279,7 @@ class NodeDB
|
|||||||
|
|
||||||
bool hasValidPosition(const meshtastic_NodeInfoLite *n);
|
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 backupPreferences(meshtastic_AdminMessage_BackupLocation location);
|
||||||
bool restorePreferences(meshtastic_AdminMessage_BackupLocation location,
|
bool restorePreferences(meshtastic_AdminMessage_BackupLocation location,
|
||||||
|
@ -181,7 +181,7 @@ PacketHistory::PacketRecord *PacketHistory::find(NodeNum sender, PacketId id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Insert/Replace oldest PacketRecord in recentPackets. */
|
/** 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 now_millis = millis(); // Should not jump with time changes
|
||||||
uint32_t OldtrxTimeMsec = 0;
|
uint32_t OldtrxTimeMsec = 0;
|
||||||
@ -308,7 +308,7 @@ bool PacketHistory::wasRelayer(const uint8_t relayer, const uint32_t id, const N
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
PacketRecord *found = find(sender, id);
|
const PacketRecord *found = find(sender, id);
|
||||||
|
|
||||||
if (found == NULL) {
|
if (found == NULL) {
|
||||||
#if VERBOSE_PACKET_HISTORY
|
#if VERBOSE_PACKET_HISTORY
|
||||||
@ -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
|
/* 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 */
|
* @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++) {
|
for (uint8_t i = 0; i < NUM_RELAYERS; i++) {
|
||||||
if (r.relayed_by[i] == relayer) {
|
if (r.relayed_by[i] == relayer) {
|
||||||
|
@ -31,11 +31,11 @@ class PacketHistory
|
|||||||
|
|
||||||
/** Insert/Replace oldest PacketRecord in mx_recentPackets.
|
/** Insert/Replace oldest PacketRecord in mx_recentPackets.
|
||||||
* @param r PacketRecord to insert or replace */
|
* @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
|
/* 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 */
|
* @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(const PacketHistory &); // non construction-copyable
|
||||||
PacketHistory &operator=(const PacketHistory &); // non copyable
|
PacketHistory &operator=(const PacketHistory &); // non copyable
|
||||||
|
@ -1447,7 +1447,7 @@ void CannedMessageModule::drawEmotePickerScreen(OLEDDisplay *display, OLEDDispla
|
|||||||
int headerY = y;
|
int headerY = y;
|
||||||
int listTop = headerY + headerFontHeight + headerMargin;
|
int listTop = headerY + headerFontHeight + headerMargin;
|
||||||
|
|
||||||
int visibleRows = (display->getHeight() - listTop - 2) / rowHeight;
|
int _visibleRows = (display->getHeight() - listTop - 2) / rowHeight;
|
||||||
int numEmotes = graphics::numEmotes;
|
int numEmotes = graphics::numEmotes;
|
||||||
|
|
||||||
// Clamp highlight index
|
// Clamp highlight index
|
||||||
@ -1457,11 +1457,11 @@ void CannedMessageModule::drawEmotePickerScreen(OLEDDisplay *display, OLEDDispla
|
|||||||
emotePickerIndex = numEmotes - 1;
|
emotePickerIndex = numEmotes - 1;
|
||||||
|
|
||||||
// Determine which emote is at the top
|
// Determine which emote is at the top
|
||||||
int topIndex = emotePickerIndex - visibleRows / 2;
|
int topIndex = emotePickerIndex - _visibleRows / 2;
|
||||||
if (topIndex < 0)
|
if (topIndex < 0)
|
||||||
topIndex = 0;
|
topIndex = 0;
|
||||||
if (topIndex > numEmotes - visibleRows)
|
if (topIndex > numEmotes - _visibleRows)
|
||||||
topIndex = std::max(0, numEmotes - visibleRows);
|
topIndex = std::max(0, numEmotes - _visibleRows);
|
||||||
|
|
||||||
// Draw header/title
|
// Draw header/title
|
||||||
display->setFont(FONT_SMALL);
|
display->setFont(FONT_SMALL);
|
||||||
@ -1709,7 +1709,7 @@ void CannedMessageModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *st
|
|||||||
} else {
|
} else {
|
||||||
// Text: split by words and wrap inside word if needed
|
// Text: split by words and wrap inside word if needed
|
||||||
String text = token.second;
|
String text = token.second;
|
||||||
uint16_t pos = 0;
|
pos = 0;
|
||||||
while (pos < text.length()) {
|
while (pos < text.length()) {
|
||||||
// Find next space (or end)
|
// Find next space (or end)
|
||||||
int spacePos = text.indexOf(' ', pos);
|
int spacePos = text.indexOf(' ', pos);
|
||||||
@ -1753,7 +1753,7 @@ void CannedMessageModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *st
|
|||||||
int yLine = inputY;
|
int yLine = inputY;
|
||||||
for (auto &line : lines) {
|
for (auto &line : lines) {
|
||||||
int nextX = x;
|
int nextX = x;
|
||||||
for (auto &token : line) {
|
for (const auto &token : line) {
|
||||||
if (token.first) {
|
if (token.first) {
|
||||||
const graphics::Emote *emote = nullptr;
|
const graphics::Emote *emote = nullptr;
|
||||||
for (int j = 0; j < graphics::numEmotes; j++) {
|
for (int j = 0; j < graphics::numEmotes; j++) {
|
||||||
@ -1789,19 +1789,20 @@ void CannedMessageModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *st
|
|||||||
|
|
||||||
int topMsg;
|
int topMsg;
|
||||||
std::vector<int> rowHeights;
|
std::vector<int> rowHeights;
|
||||||
int visibleRows;
|
int _visibleRows;
|
||||||
|
|
||||||
// Draw header (To: ...)
|
// Draw header (To: ...)
|
||||||
drawHeader(display, x, y, buffer);
|
drawHeader(display, x, y, buffer);
|
||||||
|
|
||||||
// Shift message list upward by 3 pixels to reduce spacing between header and first message
|
// Shift message list upward by 3 pixels to reduce spacing between header and first message
|
||||||
const int listYOffset = y + FONT_HEIGHT_SMALL - 3;
|
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
|
// Figure out which messages are visible and their needed heights
|
||||||
topMsg =
|
topMsg = (messagesCount > _visibleRows && currentMessageIndex >= _visibleRows - 1)
|
||||||
(messagesCount > visibleRows && currentMessageIndex >= visibleRows - 1) ? currentMessageIndex - visibleRows + 2 : 0;
|
? currentMessageIndex - _visibleRows + 2
|
||||||
int countRows = std::min(messagesCount, visibleRows);
|
: 0;
|
||||||
|
int countRows = std::min(messagesCount, _visibleRows);
|
||||||
|
|
||||||
// --- Build per-row max height based on all emotes in line ---
|
// --- Build per-row max height based on all emotes in line ---
|
||||||
for (int i = 0; i < countRows; i++) {
|
for (int i = 0; i < countRows; i++) {
|
||||||
@ -1828,7 +1829,7 @@ void CannedMessageModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *st
|
|||||||
int lineY = yCursor;
|
int lineY = yCursor;
|
||||||
const char *msg = getMessageByIndex(msgIdx);
|
const char *msg = getMessageByIndex(msgIdx);
|
||||||
int rowHeight = rowHeights[vis];
|
int rowHeight = rowHeights[vis];
|
||||||
bool highlight = (msgIdx == currentMessageIndex);
|
bool _highlight = (msgIdx == currentMessageIndex);
|
||||||
|
|
||||||
// --- Multi-emote tokenization ---
|
// --- Multi-emote tokenization ---
|
||||||
std::vector<std::pair<bool, String>> tokens; // (isEmote, token)
|
std::vector<std::pair<bool, String>> tokens; // (isEmote, token)
|
||||||
@ -1881,20 +1882,20 @@ void CannedMessageModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *st
|
|||||||
int textYOffset = (rowHeight - FONT_HEIGHT_SMALL) / 2;
|
int textYOffset = (rowHeight - FONT_HEIGHT_SMALL) / 2;
|
||||||
|
|
||||||
#ifdef USE_EINK
|
#ifdef USE_EINK
|
||||||
int nextX = x + (highlight ? 12 : 0);
|
int nextX = x + (_highlight ? 12 : 0);
|
||||||
if (highlight)
|
if (_highlight)
|
||||||
display->drawString(x + 0, lineY + textYOffset, ">");
|
display->drawString(x + 0, lineY + textYOffset, ">");
|
||||||
#else
|
#else
|
||||||
int scrollPadding = 8;
|
int scrollPadding = 8;
|
||||||
if (highlight) {
|
if (_highlight) {
|
||||||
display->fillRect(x + 0, lineY, display->getWidth() - scrollPadding, rowHeight);
|
display->fillRect(x + 0, lineY, display->getWidth() - scrollPadding, rowHeight);
|
||||||
display->setColor(BLACK);
|
display->setColor(BLACK);
|
||||||
}
|
}
|
||||||
int nextX = x + (highlight ? 2 : 0);
|
int nextX = x + (_highlight ? 2 : 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Draw all tokens left to right
|
// Draw all tokens left to right
|
||||||
for (auto &token : tokens) {
|
for (const auto &token : tokens) {
|
||||||
if (token.first) {
|
if (token.first) {
|
||||||
// Emote
|
// Emote
|
||||||
const graphics::Emote *emote = nullptr;
|
const graphics::Emote *emote = nullptr;
|
||||||
@ -1916,7 +1917,7 @@ void CannedMessageModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *st
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifndef USE_EINK
|
#ifndef USE_EINK
|
||||||
if (highlight)
|
if (_highlight)
|
||||||
display->setColor(WHITE);
|
display->setColor(WHITE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1924,11 +1925,11 @@ void CannedMessageModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *st
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Scrollbar
|
// Scrollbar
|
||||||
if (messagesCount > visibleRows) {
|
if (messagesCount > _visibleRows) {
|
||||||
int scrollHeight = display->getHeight() - listYOffset;
|
int scrollHeight = display->getHeight() - listYOffset;
|
||||||
int scrollTrackX = display->getWidth() - 6;
|
int scrollTrackX = display->getWidth() - 6;
|
||||||
display->drawRect(scrollTrackX, listYOffset, 4, scrollHeight);
|
display->drawRect(scrollTrackX, listYOffset, 4, scrollHeight);
|
||||||
int barHeight = (scrollHeight * visibleRows) / messagesCount;
|
int barHeight = (scrollHeight * _visibleRows) / messagesCount;
|
||||||
int scrollPos = listYOffset + (scrollHeight * topMsg) / messagesCount;
|
int scrollPos = listYOffset + (scrollHeight * topMsg) / messagesCount;
|
||||||
display->fillRect(scrollTrackX, scrollPos, 4, barHeight);
|
display->fillRect(scrollTrackX, scrollPos, 4, barHeight);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user