vad7 2 سال پیش
والد
کامیت
8d1c79f9fc
2فایلهای تغییر یافته به همراه25 افزوده شده و 9 حذف شده
  1. 6 6
      Distr/nrf24batch/Kitchen Vent Dimmer.txt
  2. 19 3
      nrf24batch.c

+ 6 - 6
Distr/nrf24batch/Kitchen Vent Dimmer.txt

@@ -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
@@ -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

+ 19 - 3
nrf24batch.c

@@ -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;
@@ -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);
@@ -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, ")");
 							}
 						}