I have optimised it as much as I feel I can and want to know what suggestions you have that could make it more efficient etc.
Note: I know the array goes on forever :)
volatile uint16_t IRCode[]={340,171,21,21,21,21,21,21,21,64,21,21,21,21,21,21,21,21,21,64,21,21,21,64,21,21,21,64,21,64,21,64,21,64,21,64,21,21,21,21,21,21,21,64,21,21,21,21,21,21,21,21,21,64,21,64,21,64,21,21,21,64,21,64,21,64,21,1556,340,86,21,3654}; // ProntoHex to uint16_t delete first 4 array numbers.
volatile uint16_t MicrosPassed;
volatile uint8_t Array_Seq;
uint8_t State;
void setup() {
Config(); // Config sketch will set working settings for different microcontrollers.
SendIRCode();
}
void loop() {
}
void SendIRCode() {
switch(State) {
case 1:
TCCR1A&=63; // Opposite of case 0 -193 = 63
State=0;
break;
case 0:
TCCR1A|=192;
State=1;
break;
}
}
void Config() {
DDRB|=10;
ICR1=416;
OCR1A=9983;
TCCR1A=2;
TCCR1B=24;
TCCR1B|=1;
TIMSK1=1;
}
ISR(TIMER1_OVF_vect) {
MicrosPassed++;
if(MicrosPassed==IRCode[Array_Seq]) {
SendIRCode();
MicrosPassed=0;
Array_Seq++;
}
}