embedded systems developers tools, cross compilers
  Home  |   SwiftX Archive  |   SwiftForth Archive  |

Re: The correct code

From: Noel Henson <noel_at_noels-lab.com>
Date: Mon, 11 Aug 2003 07:06:48 -0700

Much better!

One thing that is hard to understand about Forth it that it is _completely_
understandable. In this case you don't have 100KB of code that manages
tasks to try to understand. You have maybe a few dozen bytes.

I hope you continue to have fun with it!
Noel

On Monday 11 August 2003 06:35 am, you wrote:
> Hi,
>
> Yes, Noel and Elizabeth, you were right.
> The actions with ACTIVATE were not treated well in my code
> and probably it worked only by chance. But it explained
> probably why it didn't work with buttons - which is what I
> will try to do in the next step.
>
> Meanwhile FYI I give you the correct code as suggested by both of you.
> The easiest solution actually was to factor out
> the actions, so that
>
> : SEQBITFLASH .. code ... ;
>
> became
>
> : SEQBITFLASH ACTIVATE BEGIN PAUSE ... code ... AGAIN ;
>
> After this is done, this action can be assigned to a TASK, so:
> TASK SEQBITFLASH
> And this can then be done as often as needed.
>
> The complete code is below. It works fine. When it'll be rewritten
> with buttons I'll post it. Of course, all of your good advice
> will still be welcome.
>
>
> Thanks to both of you.
> Viviane Beullens
>
>
>
>
> TARGET
>
> |U| |S| |R| BACKGROUND TESTER
> |
> |U| |S| |R| BACKGROUND TESTER2
> |
> : SEQBITFLASH ( -- ) ACTIVATE
>
> 1
> BEGIN PAUSE
>
> PORTB C@ 2DUP SWAP - AND
> PORTB C! 100 MS 2*
> PORTB C@ 127 = IF DROP 1 CR
> THEN
> 255 PORTB C! 100 MS
> AGAIN ; \ To assign to TESTER
>
> : READSWITCHES ACTIVATE BEGIN PAUSE
>
> PIND C@ 254 =
> IF TESTER HALT
> ELSE PIND C@ 253 =
> IF TESTER SEQBITFLASH
> THEN
> THEN AGAIN ; \ To assign to TESTER2
>
> : /TESTER ( -- )
>
> $FF DDRB C! \ Set PORTB as OUTPUT
> $FF PORTB C! \ set leds off at start up
> TESTER BUILD TESTER
> SEQBITFLASH ;
>
> : /TESTER2 ( -- )
>
> TESTER2 BUILD TESTER2 READSWITCHES ;
> ----------------------------------------------------------------------
> swiftx_at_forth.com The SwiftX programming discussion email list
> To unsubscribe, send subject "unsubscribe" to swiftx-request_at_forth.com
> For list command help, send subject "help" to swiftx-request_at_forth.com
> Message archives are located at http://www.forth.com/archive/swiftx
> ----------------------------------------------------------------------
> This list is a forum for SwiftX users. For product support and bug
> reports, please send email to support_at_forth.com
> ----------------------------------------------------------------------

----------------------------------------------------------------------
swiftx_at_forth.com The SwiftX programming discussion email list
To unsubscribe, send subject "unsubscribe" to swiftx-request_at_forth.com
For list command help, send subject "help" to swiftx-request_at_forth.com
Message archives are located at http://www.forth.com/archive/swiftx
----------------------------------------------------------------------
This list is a forum for SwiftX users. For product support and bug
reports, please send email to support_at_forth.com
----------------------------------------------------------------------
Received on Mon Aug 11 2003 - 07:07:09 PDT

This archive was generated by hypermail 2.2.0 : Fri Dec 05 2008 - 03:04:22 PST