refactor: zbylé tři nálezy z review — rozpočet, rename, duplicity

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
tthandClaude Opus 5 committed 2026-09-21 22:37:20 +02:00
1 parent 871f75d246
commit e7fdec8404
5 files changed
+104 -31

No files matched your search

+19
View File
@@ -31,6 +31,25 @@ public:
void setFeat1(uint16_t extra) { _extra1 = extra; }
void setFeat2(uint16_t extra) { _extra2 = extra; }
void setName(const char* name) { _name = name; }
/**
* \brief bytes left for the name with the fields set so far.
*
* CUSTOM (TeTeHacko): the name is encoded last and clamped to whatever is
* left, so anyone who wants to append to it (battery icon, see
* helpers/BatteryIcon.h) has to know the remainder. Deriving it a second
* time elsewhere goes stale the moment a field is added -- a copy in
* BatteryIcon.h already missed FEAT1/FEAT2 and would have let the UTF-8
* clamp cut a glyph in half.
*/
size_t nameBudget() const {
size_t used = 1; // flags
if (_has_loc) used += 8; // lat + lon
if (_extra1) used += 2;
if (_extra2) used += 2;
return MAX_ADVERT_DATA_SIZE - used;
}
/**
* \brief encode the given advertisement data.