Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
vad7 committed May 18, 2023
1 parent 7e56077 commit 8d1c79f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
12 changes: 6 additions & 6 deletions Distr/nrf24batch/Kitchen Vent Dimmer.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,18 @@ W: _PORTA=,0x3B,,WRAM
R: _PORTB=0x36,,RAM
W: _PORTB=,0x38,WRAM

R: _Fanspeed=0x75,,RAM
R: _LED_Warning=0x6B,,RAM
W: _LED_Warning=,0x6B,WRAM
R: _IRHashLast*2=0x7C,,RAM2#
R: _SleepTimer=0x84,,RAM
R: _FanOn=0x76,,RAM
R: _FanOnNext=0x74,,RAM
R: _FanOnNextCnt=0x72,,RAM
R: _FanOnLast=0x73,,RAM
R: _IRHashLast*2=0x7C,,RAM2#
R: _SleepTimer=0x84,,RAM

R: _OutSpeedMax=0x87,,RAM
W: _OutSpeedMax=,0x87,WRAM
R: _LED_Warning=0x6B,,RAM
W: _LED_Warning=,0x6B,WRAM
R: _Fanspeed=0x75,,RAM
R: _ZeroCrossDelay*2=0x8E,,RAM2
W: _ZeroCrossDelay=,0x8E,WRAM2
R: _PulseDelayAfterZero*2=0x9A,,RAM2
Expand Down Expand Up @@ -142,5 +142,5 @@ WBatch: LED Warning: _LED Warning=0x10
WBatch: OSCCAL: _OSCCAL=146
WBatch: CO2 Level: CO2 level={750,850,1000}
WBatch: Zero cross EEPROM: ZeroCrossLag,us=30;SSR_PulseWidth,us=200;Reset
WBatch: Zero cross RAM: _ZeroCrossDelay=1225;_PulseDelayAfterZero=0001;_PulseWidth=1249
WBatch: Zero cross RAM: _ZeroCrossDelay=1246;_PulseDelayAfterZero=0001;_PulseWidth=1249
WBatch: Reset: Reset
22 changes: 19 additions & 3 deletions nrf24batch.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,22 @@ static void add_to_str_hex_bytes(char *out, uint8_t *arr, int bytes)
} while(--bytes);
}

// skip leading zeros
static void add_to_str_hex_variable(char *out, uint8_t *arr, int size)
{
if(size <= 0) return;
out += strlen(out);
arr += size - 1;
while(*arr == 0 && size > 1) {
arr--;
size--;
}
do {
snprintf(out, 3, "%02X", *arr--);
out += 2;
} while(--size);
}

void Edit_insert_digit(char new)
{
if(*Edit_pos == '-') return;
Expand Down Expand Up @@ -482,7 +498,7 @@ bool nrf24_read_newpacket() {
else {
char hex[9];
hex[0] = '\0';
add_to_str_hex_bytes(hex, (uint8_t*)&var, size);
add_to_str_hex_variable(hex, (uint8_t*)&var, size);
if((cmd_array && cmd_array_hex) || furi_string_end_with_str(str, "0x")) furi_string_cat_str(str, hex);
else {
if(var >= 0 && var <= 9) furi_string_cat_printf(str, "%ld", var);
Expand Down Expand Up @@ -1173,12 +1189,12 @@ static void render_callback(Canvas* const canvas, void* ctx) {
int32_t n = get_payload_receive_field(pld, len);
if(hex) {
strcat(screen_buf, "0x");
add_to_str_hex_bytes(screen_buf, pld, len);
add_to_str_hex_variable(screen_buf, pld, len);
} else {
snprintf(screen_buf + strlen(screen_buf), 20, "%ld", n);
if(n > 9) {
strcat(screen_buf, " (");
add_to_str_hex_bytes(screen_buf, pld, len);
add_to_str_hex_variable(screen_buf, pld, len);
strcat(screen_buf, ")");
}
}
Expand Down

0 comments on commit 8d1c79f

Please sign in to comment.