static OutputPacket *motorola_common_packet(uint8_t addr, uint8_t aux, uint8_t value)
{
- uint8_t i;
-
OutputPacket *packet = output_create_packet();
packet->bit_duration = 2;
packet->length = 18*8;
- for(i=0; i<4; ++i)
+ for(uint8_t i=0; i<4; ++i)
{
uint8_t d = addr%3;
addr /= 3;
packet->data[8] = (aux ? 0x7F : 0x01);
packet->data[9] = packet->data[8];
- for(i=0; i<4; ++i)
+ for(uint8_t i=0; i<4; ++i)
{
packet->data[10+i*2] = ((value&1) ? 0x7F : 0x01);
value >>= 1;
static OutputPacket *motorola_old_packet(uint8_t addr, uint8_t aux, uint8_t value)
{
- uint8_t i;
-
OutputPacket *packet = motorola_common_packet(addr, aux, value);
- for(i=0; i<4; ++i)
+ for(uint8_t i=0; i<4; ++i)
packet->data[11+i*2] = packet->data[10+i*2];
return packet;
void motorola_locomotive_speed_function_packet(uint8_t addr, uint8_t aux, uint8_t speed, uint8_t func, uint8_t state)
{
- uint8_t i;
- uint8_t value;
- OutputPacket *packet;
-
- value = motorola_speed_to_value(speed);
- packet = motorola_common_packet(addr, aux, value);
+ uint8_t value = motorola_speed_to_value(speed);
+ OutputPacket *packet = motorola_common_packet(addr, aux, value);
/*
001 -> 011
if(func==value)
func = ((value&8) ? 2 : 5) | (func&8);
- for(i=0; i<4; ++i)
+ for(uint8_t i=0; i<4; ++i)
{
packet->data[11+i*2] = ((func&1) ? 0x7F : 0x01);
func >>= 1;