// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Simple example of using the schedule libraries, there are two kinds // of shceduler, the round robbin (rr-shed) and the burst (b-shed), see // the library header for each to notice the difference. // This example can be used with either by changing the library include. // // This example simly flashed an LED on and off in the background // // Note the SID value, b-shed is an EXTENTION of interrupt, they must // have the same value as they share common words that are not made // public <0> // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // REQUIRES: // #URL-lib "http://pin1.org/forthlib/flb/General/soft1.flb" sid=99 // #URL-lib "http://pin1.org/forthlib/flb/General/pinsel.flb" sid=100 // #URL-lib "http://pin1.org/forthlib/flb/Interupts/interrupt.flb" sid=101 // #URL-lib "http://pin1.org/forthlib/flb/Interupts/b-shed.flb" sid=101 // CONSTANTS: // This is a counter to control the flash rate of the LED integer tx1 // Initialise the port p1.16 in this case, set up the schedule interval // to 10ms and call s-start to initiate scheduling : t-init -16 io-out // set port to o/p 10 s-interval ! // set interval 10 10ms s-start // start scheduler 1 -16 p! // 1 is off, turn off led ; // This word is placed into the schedule by (go), it simply turns // on or off the led according to the value in tx1. It also increments // tx1 each time it gets called and resets it when the max has been reached : f-led tx1 100 < if 1 -16 p! then // off for 1 second tx1 100 > if 0 -16 p! then // on if > 100 tx1 120 > if 0 => tx1 then // reset at 120 1 +> tx1 // continual increment ; // this can be done at the command line with ' f-led s-add but this // shows how to use ['] to implemnt it in a word. ['] will place the cfa // of the following word on the stack at runtime : go t-init ['] f-led s-add -1 <> abort" problem adding to schedule" ; // just some words to show that the schedule can suspend : look ps. ; : halt ['] f-led s-pause ; : res ['] f-led s-resume ;