Is there a more efficient and cleaner way of doing what the following method is already doing?
void sendCode(prog_uint16_t inArray[], int nLimit) {
unsigned int arr[nLimit];
unsigned int c;
int index = 0;
while ((c = pgm_read_word(inArray++))) {
arr[index] = c;
index++;
}
for (int i = 0; i < nLimit; i=i+2) {
delayMicroseconds(arr[i]);
pulseIR(arr[i+1]);
}
}
This is in reference to an existing question I had answered.
There should be no need for the local
arr
array variable. If you do away with that you should both save temporary stack space and speed up execution by removing the need to copy data.This code assumes that the maximum integer stored in an
int
is greater than the maximum size ofinArray
(this seems reasonable as the original code essentially makes the same assumption by using anint
fornLimit
).