Widget:Interrupt: Difference between revisions

From COMP15212 Wiki
gravatar Yuron [userbureaucratinterface-adminsysopPHRhYmxlIGNsYXNzPSJ0d3BvcHVwIj48dHI+PHRkIGNsYXNzPSJ0d3BvcHVwLWVudHJ5dGl0bGUiPkdyb3Vwczo8L3RkPjx0ZD51c2VyPGJyIC8+YnVyZWF1Y3JhdDxiciAvPmludGVyZmFjZS1hZG1pbjxiciAvPnN5c29wPGJyIC8+PC90ZD48L3RyPjwvdGFibGU+] (talk | contribs)
m (1 revision imported)
pc>Yuron
No edit summary
Line 67: Line 67:
}
}


var isRunning = true;
function interrupt() {
function interrupt() {
     if ((mouse.x >= STOP_X) && (mouse.x < (STOP_X + STOP_DX)) &&
     if ((mouse.x >= STOP_X) && (mouse.x < (STOP_X + STOP_DX)) &&
         (mouse.y >= STOP_Y) && (mouse.y < (STOP_Y + STOP_DY))) {
         (mouse.y >= STOP_Y) && (mouse.y < (STOP_Y + STOP_DY))) {
         clearInterval(clockId);
         if (isRunning) {
            clearInterval(clockId);
            isRunning = false;
        } else {
            clockId = setInterval(animate, STEP_TIME);
            isRunning = true;
        }
     } else {
     } else {
         pending = true;
         pending = true;

Revision as of 10:48, 13 August 2019

This widget demonstrates the operation of an interrupt handler, and what happens when interrupts are disabled.