Currently, I am working on a project utilizing the remarkable BBC Micro Bit, and I am in the process of developing an extension for Make Code using TypeScript.
The core of my task involves handling an event triggered by a wheel encoder integrated into my robot. During this event, I perform incremental operations on certain variables. In typical Arduino language, I would designate such variables as "volatile" to signify that they could be altered by an interrupt, ensuring that I always have access to the most recent value within 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;
}
})
I am curious whether TypeScript has an equivalent keyword like "volatile" when declaring variables. And if it does exist, how can it be effectively implemented?