princeton working

This commit is contained in:
HTotoo
2023-12-09 15:48:50 +01:00
parent dd5b6d001a
commit d2cb93d957
10 changed files with 61 additions and 58 deletions
+11 -14
View File
@@ -34,8 +34,9 @@ namespace ui {
void SubGhzDRecentEntryDetailView::update_data() {
// set text elements
text_type.set(SubGhzDView::getSensorTypeName((FPROTO_SUBGHZD_SENSOR)entry_.sensorType));
text_id.set("0x" + to_string_hex(entry_.id));
// text_temp.set(to_string_decimal(entry_.temp, 2));
text_id.set("0x" + to_string_hex(entry_.serial));
if (entry_.bits > 0) console.writeln("Bits: " + to_string_dec_uint(entry_.bits));
if (entry_.btn != SD_NO_BTN) console.writeln("Btn: " + to_string_dec_uint(entry_.btn));
}
SubGhzDRecentEntryDetailView::SubGhzDRecentEntryDetailView(NavigationView& nav, const SubGhzDRecentEntry& entry)
@@ -44,7 +45,7 @@ SubGhzDRecentEntryDetailView::SubGhzDRecentEntryDetailView(NavigationView& nav,
add_children({&button_done,
&text_type,
&text_id,
&text_temp,
&console,
&labels});
button_done.on_select = [&nav](const ui::Button&) {
@@ -100,7 +101,7 @@ void SubGhzDView::on_tick_second() {
}
void SubGhzDView::on_data(const SubGhzDDataMessage* data) {
SubGhzDRecentEntry key{data->sensorType, data->id};
SubGhzDRecentEntry key{data->sensorType, data->serial, data->bits, data->btn};
auto matching_recent = find(recent, key.key());
if (matching_recent != std::end(recent)) {
// Found within. Move to front of list, increment counter.
@@ -147,19 +148,15 @@ void RecentEntriesTable<ui::SubGhzDRecentEntries>::draw(
line.reserve(30);
line = SubGhzDView::getSensorTypeName((FPROTO_SUBGHZD_SENSOR)entry.sensorType);
if (line.length() < 14) {
line += SubGhzDView::pad_string_with_spaces(14 - line.length());
line = line + " " + to_string_hex(entry.serial);
if (line.length() < 19) {
line += SubGhzDView::pad_string_with_spaces(19 - line.length());
} else {
line = truncate(line, 14);
line = truncate(line, 19);
}
// TODO
// std::string idStr = to_string_hex(entry.id);
std::string ageStr = to_string_dec_uint(entry.age);
// line += SubGhzDView::pad_string_with_spaces(6 - id.length()) + temp;
// line += SubGhzDView::pad_string_with_spaces(5 - humStr.length()) + humStr;
// line += SubGhzDView::pad_string_with_spaces(4 - chStr.length()) + chStr;
std::string bitsStr = to_string_dec_uint(entry.bits);
line += SubGhzDView::pad_string_with_spaces(5 - bitsStr.length()) + bitsStr;
line += SubGhzDView::pad_string_with_spaces(4 - ageStr.length()) + ageStr;
line.resize(target_rect.width() / 8, ' ');
+15 -8
View File
@@ -42,19 +42,24 @@ struct SubGhzDRecentEntry {
using Key = uint64_t;
static constexpr Key invalid_key = 0x0fffffff; // todo calc the invalid all
uint8_t sensorType = FPS_Invalid;
uint32_t id = 0xFFFFFFFF;
uint32_t serial = SD_NO_SERIAL;
uint16_t bits = 0;
uint8_t btn = SD_NO_BTN;
uint16_t age = 0; // updated on each seconds, show how long the signal was last seen
SubGhzDRecentEntry() {}
SubGhzDRecentEntry(
uint8_t sensorType,
uint32_t id)
uint32_t serial,
uint16_t bits = 0,
uint8_t btn = SD_NO_BTN)
: sensorType{sensorType},
id{id} {
serial{serial},
bits{bits},
btn{btn} {
}
Key key() const {
return (static_cast<uint64_t>(id) << 32) |
return (static_cast<uint64_t>(serial) << 32) |
(static_cast<uint64_t>(sensorType) & 0xFF) << 0;
}
void inc_age(int delta) {
@@ -142,11 +147,13 @@ class SubGhzDRecentEntryDetailView : public View {
SubGhzDRecentEntry entry_{};
Text text_type{{0 * 8, 1 * 16, 15 * 8, 16}, "?"};
Text text_id{{6 * 8, 2 * 16, 10 * 8, 16}, "?"};
Text text_temp{{6 * 8, 3 * 16, 8 * 8, 7 * 16}, "?"};
Console console{
{0, 4 * 16, 240, screen_height - (4 * 16) - 36}};
Labels labels{
{{0 * 8, 0 * 16}, "Tpe:", Color::light_grey()},
{{0 * 8, 2 * 16}, "Id: ", Color::light_grey()},
{{0 * 8, 0 * 16}, "Type:", Color::light_grey()},
{{0 * 8, 2 * 16}, "Serial: ", Color::light_grey()},
{{0 * 8, 3 * 16}, "Data:", Color::light_grey()},
};