3 static uint8_t motorola_speed_to_value(uint8_t speed)
13 static void motorola_common_packet(uint8_t addr, uint8_t aux, uint8_t value)
19 packet.bit_duration = 2;
27 packet.data[i*2] = (d==0 ? 0x01 : 0x7F);
28 packet.data[i*2+1] = (d==1 ? 0x7F : 0x01);
31 packet.data[8] = (aux ? 0x7F : 0x01);
32 packet.data[9] = packet.data[8];
36 packet.data[10+i*2] = ((value&1) ? 0x7F : 0x01);
40 packet.repeat_count = 2;
41 // Duration of three trits
42 packet.repeat_delay = 96;
43 packet.final_delay = 224;
46 static void motorola_old_packet(uint8_t addr, uint8_t aux, uint8_t value)
50 motorola_common_packet(addr, aux, value);
53 packet.data[11+i*2] = packet.data[10+i*2];
56 void motorola_locomotive_speed_packet(uint8_t addr, uint8_t aux, uint8_t speed)
58 motorola_old_packet(addr, aux, motorola_speed_to_value(speed));
63 void motorola_locomotive_reverse_packet(uint8_t addr, uint8_t aux)
65 motorola_old_packet(addr, aux, 1);
70 void motorola_locomotive_speed_direction_packet(uint8_t addr, uint8_t aux, uint8_t speed, uint8_t dir)
72 motorola_common_packet(addr, aux, motorola_speed_to_value(speed));
74 packet.data[11] = (dir ? 0x01 : 0x7F);
75 packet.data[13] = (dir ? 0x7F : 0x01);
76 packet.data[15] = (dir ? 0x01 : 0x7F);
77 packet.data[17] = 0x80-packet.data[16];
82 void motorola_locomotive_speed_function_packet(uint8_t addr, uint8_t aux, uint8_t speed, uint8_t func, uint8_t state)
87 value = motorola_speed_to_value(speed);
88 motorola_common_packet(addr, aux, value);
102 func = ((value&8) ? 2 : 5) | (func&8);
106 packet.data[11+i*2] = ((func&1) ? 0x7F : 0x01);
113 void motorola_solenoid_packet(uint8_t addr, uint8_t output, uint8_t state)
115 uint8_t value = output;
119 motorola_old_packet(addr, 0, value);
120 packet.repeat_delay >>= 1;
121 packet.bit_duration = 1;