Here is some simple test code that tends to show that %128 executes much faster than %127
Its a bit messy and long winded as I hadnt read that the res of the micro() is only 4
so it got chopped up and duplicated and moved around quit a bit till it produced sensible results.
swap and move the mod values around to see the results change.
unsigned long t11;
unsigned long t21;
unsigned long t12;
unsigned long t22;
uint8_t val0 = 0xA5;
uint8_t res0 = 0;
uint8_t val1 = 0xA5;
uint8_t res1 = 0;
t11 = micros();
for (int i = 0; i < 500; i++)
{
res0 = (val0+i) % 127;
}
t21 = micros();
t12 = micros();
for (int i = 0; i < 500; i++)
{
res1 = (val1+i) % 128;
}
t22 = micros();
Serial.print("Res 0 "); Serial.println(res0);
Serial.print("Dur 0 "); Serial.println(t21 - t11);
Serial.print("Res 1 "); Serial.println(res1);
Serial.print("Dur 1 "); Serial.println(t22 - t12);
result :-
Res 0 29
Dur 0 7648
Res 1 24
Dur 1 440
... Simon