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)
{
bool val; // 1=pulse, 0=break
uint duration; // in μs
- switch (rc_tick++) {
+ switch (rc_tick) {
case 0:
// Better be safe
return;
// 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
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
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);