Lab_interaccio/2011/dmx_readout/ActionLoop.pde

62 lines
1.4 KiB
Plaintext
Raw Permalink Normal View History

2025-02-25 21:29:42 +01:00
void action() {
volatile byte v;
volatile int w;
volatile int i;
// **************************************************
// Display the address of the first displayed channel
// **************************************************
w = dmxaddress - 3; // Adjust back to the true address
lcd.setCursor(0,0);
if (w < 10) {
lcd.print(" ");
}
else if (w < 100) {
lcd.print(" ");
}
lcd.print(w);
lcd.print(":");
// **************************************************
// Compute the frames/sec
// **************************************************
lcd.setCursor(0,1);
if (deltaT > 1000) {
// Less than one frame per second -> we assume no incoming data
lcd.print("--- ");
for (i=0; i<7; i++) {
fpsArray[i] = 0;
}
} else {
v = 1000 / deltaT; // current frames/sec -> 1 second / deltaT
w = 0;
for (i=7; i>0; i--) {
fpsArray[i] = fpsArray[i-1]; // shift averaging array
w += fpsArray[i]; // sum components for average
}
fpsArray[0] = v;
w += v;
v = w >> 3; // average = sum / 8 (probably ought to round this)
if (v < 10) {
lcd.print(" ");
}
lcd.print(v, DEC);
lcd.print("/s ");
}
// **************************************************
// Display the 8 channels, 4 per line
// **************************************************
for (i=0; i<8; i++) {
lcd.setCursor(lcdCol[i],lcdRow[i]);
v = dmxvalue[i];
if (v < 16) {
lcd.print(" ");
}
lcd.print(v, HEX);
}
return; //go back to loop()
} //end action() loop