Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bertmelis authored Jan 13, 2025
1 parent f6abc51 commit 8343d8f
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/Datapoint/ConversionHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,15 @@ std::size_t decodeSchedule(const uint8_t* data, std::size_t len, char* output, s

std::size_t pos = 0;
for (std::size_t i = 0; i < 8; ++i) {
unsigned int hour = std::min(23, data[i] >> 3);
unsigned int minutes = std::min(59, (data[i] & 0x07) * 10);
res = snprintf(&output[pos], maxLen - res, "%u.02:%u.02", hour, minutes);
if (res < 0) return 0;
pos += res;
unsigned int hour = data[i] >> 3;
unsigned int minutes = sdata[i] & 0x07) * 10;
if (hour > 23 || minutes > 59) {
hour = 0;
minutes 0;
}
std::size_t result = snprintf(&output[pos], maxLen - res, "%u.02:%u.02", hour, minutes);
if (result < 0) return 0;
pos += result;
if (i < 7) {
&output[pos++] = ' ';
}
Expand Down

0 comments on commit 8343d8f

Please sign in to comment.