From: Martin Mares Date: Fri, 14 Jul 2023 15:42:27 +0000 (+0200) Subject: test-sinclair: Debugging RC X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=5b48fbfc8c5d7e6cb7de640286c839b5e60300e9;p=home-hw.git test-sinclair: Debugging RC --- diff --git a/test-sinclair/main.c b/test-sinclair/main.c index 7cfe1b4..5e90ecf 100644 --- a/test-sinclair/main.c +++ b/test-sinclair/main.c @@ -370,9 +370,9 @@ enum rc_mode { MODE_DEHUMIDIFY, }; -static byte rc_mode; // MODE_xxx -static byte rc_fan; // 0-3 -static byte rc_temp; // 17-30 +static byte rc_mode = MODE_COOL; // MODE_xxx +static byte rc_fan; // 0-3 +static byte rc_temp = 17; // 17-30 static void rc_init(void) { @@ -424,7 +424,7 @@ void tim4_isr(void) bool val; // 1=pulse, 0=break uint duration; // in μs - switch (rc_tick++) { + switch (rc_tick) { case 0: // Better be safe return; @@ -433,11 +433,13 @@ void tim4_isr(void) // Initial / final marker val = 0; duration = 3600; + // debug_putc('#'); break; case 110: // Inter-packet gap val = 0; duration = 10000; + // debug_putc('$'); break; case 111: // End of message @@ -447,17 +449,23 @@ void tim4_isr(void) if (rc_tick % 2) { val = 1; duration = 565; + // debug_putc('*'); } else { // Even ticks 4 to 106 transmit 52 bits of data uint i = 12 + (rc_tick - 4) / 2; val = 0; - if (rc_pattern[i>>5] & (1 << (i & 31))) + if (rc_pattern[i>>5] & (0x80000000 >> (i & 31))) { duration = 1471; - else + // debug_putc('B'); + } else { duration = 480; + // debug_putc('A'); + } } } + rc_tick++; + if (val) gpio_set(GPIOA, GPIO8); else @@ -475,7 +483,9 @@ static void rc_send(void) return; rc_encode(); - debug_printf("RC sending: %05x %08x\n", (uint) rc_pattern[0], (uint) rc_pattern[1]); + debug_printf("RC sending: %05x %08x (mode=%d, fan=%d, temp=%d)\n", + (uint) rc_pattern[0], (uint) rc_pattern[1], + rc_mode, rc_fan, rc_temp); rc_tick = 1; timer_set_period(TIM4, 1);