From 00ca1d6f035cbb3dfec4b7d8d45ab02525b12bf6 Mon Sep 17 00:00:00 2001 From: uvos Date: Tue, 12 Apr 2022 00:35:42 +0200 Subject: [PATCH] fix item name printing --- W433DataReciver.h | 2 +- item.cpp | 2 +- main.cpp | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/W433DataReciver.h b/W433DataReciver.h index fb8f5b1..5b86931 100644 --- a/W433DataReciver.h +++ b/W433DataReciver.h @@ -31,7 +31,7 @@ private: static constexpr uint16_t LARGE_TIME_TOLERANCE = LARGE_TIME*0.30; static constexpr uint8_t SMALL_TIME_TOLERANCE = SMALL_TIME*0.30; static constexpr uint16_t DISCARD_TIME = SMALL_TIME*0.6; - static constexpr uint16_t TICKS_PER_US = (F_CPU) / (1000000*CLOCK_DEVIDER) ; + static constexpr uint16_t TICKS_PER_US = (F_CPU) / (1000000*CLOCK_DEVIDER); static constexpr uint8_t signature = 0xA5; static constexpr int8_t polarity = 1; diff --git a/item.cpp b/item.cpp index 837b685..ad7bb30 100644 --- a/item.cpp +++ b/item.cpp @@ -3,7 +3,7 @@ void Item::setName(const char * const nameN) { - size_t len = strlen(name); + size_t len = strlen(nameN); if(len < MAX_NAME_LENGTH)memcpy(name, nameN, len+1); } diff --git a/main.cpp b/main.cpp index 068f8c4..f28a1a9 100644 --- a/main.cpp +++ b/main.cpp @@ -121,8 +121,7 @@ void itemDispatch(SVector* items, Pwm16b* auxPwm, char* token, uint8_t type = strtol(token, nullptr, 10 ); if(id != 0 && (type == 0 || type == 1) && items->remainingCapacity() > 0) { - id = id << 4; - token = strtok(NULL, "\0"); + token = strtok(NULL, "\n\0"); Item item; item.id = id; item.type = type; @@ -153,6 +152,7 @@ void itemDispatch(SVector* items, Pwm16b* auxPwm, char* token, uint8_t selected = strtol(token, nullptr, 10); if (selected < items->count()) { + items->at(selected).lastValue = true; if(items->at(selected).type == 0)WirelessRelay(items->at(selected)).setValue(true); else UvosItem(items->at(selected)).setValue(true); @@ -170,6 +170,7 @@ void itemDispatch(SVector* items, Pwm16b* auxPwm, char* token, uint8_t selected = strtol(token, nullptr, 10); if (selected < items->count()) { + items->at(selected).lastValue = false; if(items->at(selected).type == 0)WirelessRelay(items->at(selected)).setValue(false); else UvosItem(items->at(selected)).setValue(false);