SENDING
};
-OutputPacket packet;
+OutputPacket packets[4];
+uint8_t chain_length;
+uint8_t current_packet;
volatile uint8_t packet_state = IDLE;
static uint8_t out_bit;
static uint8_t out_time;
OutputPacket *output_create_packet(void)
{
while(packet_state!=IDLE) ;
- return &packet;
+ chain_length = 1;
+ return &packets[0];
+}
+
+OutputPacket *output_create_chained_packet(void)
+{
+ ++chain_length;
+ return &packets[chain_length-1];
}
void output_send_packet(void)
if(packet_state!=IDLE)
return;
+ current_packet = 0;
packet_state = READY;
}
if(out_time && !--out_time)
{
+ OutputPacket *packet = &packets[current_packet];
++out_bit;
- if(out_bit>=packet.length)
+ if(out_bit>=packet->length)
{
PORTD &= ~BIT(POLARITY);
- if(packet.repeat_count>1)
+ if(--packet->repeat_count)
{
- if(packet.repeat_count<0xFF)
- --packet.repeat_count;
- delay_time = packet.repeat_delay;
+ delay_time = packet->repeat_delay;
packet_state = READY;
}
else
{
- delay_time = packet.final_delay;
- packet_state = IDLE;
+ delay_time = packet->final_delay;
+ if(++current_packet<chain_length)
+ packet_state = READY;
+ else
+ packet_state = IDLE;
}
}
else
{
if((out_bit&7)==0)
- out_data = packet.data[out_bit>>3];
+ out_data = packet->data[out_bit>>3];
else
out_data >>= 1;
else
PORTD &= ~BIT(POLARITY);
- out_time = packet.bit_duration;
+ out_time = packet->bit_duration;
}
return;
if(packet_state==READY)
{
+ OutputPacket *packet = &packets[current_packet];
packet_state = SENDING;
out_bit = 0;
- out_time = packet.bit_duration;
- out_data = packet.data[0];
+ out_time = packet->bit_duration;
+ out_data = packet->data[0];
if(out_data&1)
PORTD |= BIT(POLARITY);
else
void output_init(void);
OutputPacket *output_create_packet(void);
+OutputPacket *output_create_chained_packet(void);
void output_send_packet(void);
void output_set_power(uint8_t);
uint8_t output_is_power_on();