I am working with the BBC Micro Bit and am creating an extension for Make Code in TypeScript.
I have the following event that gets triggered by a wheel encoder on my robot. Inside the event, I increment a couple of variables. In the Arduino language, I would declare such variables as "volatile" indicating that the variable could be changed by an interrupt, thus ensuring that I was working with the most recent value in the variable.
control.onEvent(EventBusSource.MICROBIT_ID_IO_P0, EventBusValue.MICROBIT_PIN_EVT_RISE, function () {
_lTicks += 1;
_lerrTicks += 1;
if (_lTicks % _partialTurn == 0) {
_lTicks = 0;
_lTurns += .0625;
}
})
Does TypeScript have an equivalent "volatile" keyword when declaring a variable? If so, how is it implemented?