PS2Keyboard.cpp using millis() function

chips.cnc

New member
I am trying to understand the code in 'PS2Keyboard.cpp' and have a (hopefully not too stupid) question.

According to the Arduino.cc web site (https://www.arduino.cc/en/Reference/AttachInterrupt), it states:
Note
Inside the attached function, delay() won't work and the value returned by millis() will not increment.

Am I correct in assuming that in the following snippet of code:
val = digitalRead(DataPin);
now_ms = millis();
if (now_ms - prev_ms > 250) {
bitcount = 0;
incoming = 0;
}
prev_ms = now_ms;
n = bitcount - 1;
if (n <= 7) {
incoming |= (val << n);
}
that the 'now_ms = millis();' will retrieve the current/correct value each time the interrupt 'fires off'?

Thank you for helping me to expand my knowledge,
Chips
 
Back
Top