Shop OBEX P1 Docs P2 Docs Learn Events
Propeller 'FILE' usage — Parallax Forums

Propeller 'FILE' usage

RsadeikaRsadeika Posts: 3,837
edited 2007-03-01 16:25 in Propeller 1
I was looking for an example for the correct usage of the 'FILE' command. I have presented some example code below, just a general feel as to which way I am going at the moment. The thing that I was really looking for was an "#include LEDon_off.txt" kind of·directive, I did not see that in the manual. The prelimanary solution that I am looking for is, in the ''Actual robot behaviour code" segment I would place an "#include" directive, instead of the actual code, instead of the way it's presented now. The thought behind this is, have a general skeleton program, and write the different behaviour·code in a seperate text file. That way I could pick a particular robot behaviour file, name it in the #include directive, compile it, and run the robot.

So, I guess my question is, is their a way to work around the lack of an "#include" directive. All suggestions are welcome.

Thanks

Ray

''MyBotOS.spin
''MyBotOS Ver 00.00.01
''March 1, 2007

OBJ
· ser: "Extended_FDSerial"

CON
·_clkmode = xtal1 + pll16x··· ''Setup the propeller chip
·_xinfreq = 5_000_000

·''Assign constant values
·serRx = 16······ ''Serial receive
·serTx = 17······ ''Serial transmit
·serMode = 0····· ''Serial mode
·serBaud = 57600· ''Baud rate

·''My Robot Command Instructions
· StartProg = 128······· ''Create opcode 128, start OI session
· ModeSafe· = 131······· ''Create opcode 131, safe mode session
· WaitEvent = 158······· ''Create opcode 158, wait procedure
· WPlayBtn· = 17········ ''Create opcode· 17, the play button as an event
· WaitTime· = 155······· ''Create opcode 155, time procedure
·
· LEDctrl·· = 139······· ''Create opcode 139, LED control
· LEDplay_advance = 10·· ''Create LED data byte, turn on play and advance
························ ''····················· buttons
· LEDplay_advance_off = %0101 ''Create LED data byte, turn off play and
····························· ''····················· advance buttons

PUB main
''Procedural stuff
· ser.start(serRx, serTx, serMode, serBaud)·· ''Starts up the serial comm
· ser.str(string(StartProg))· ''This is done once to put into OI mode
· ser.str(string(ModeSafe))·· ''This places Create into safe mode

''Actual robot behaviour code
· waitcnt(5_000_000 + cnt)··· ''Needed time delay between·code segments
· ser.str(string(WaitEvent, WplayBtn))
· waitcnt(5_000_000 + cnt)
· ser.str(string(LEDctrl, LEDplay_advance, %0001, %11111111 ))
· waitcnt(5_000_000 + cnt)
· ser.str(string(WaitTime, 40))
· waitcnt(5_000_000 + cnt)
· ser.str(string(LEDctrl, LEDplay_advance_off, %0001, %00000001))

Comments

  • inserviinservi Posts: 113
    edited 2007-03-01 16:25
    Hello,

    The first idea comming for replace an #include in spin is the use of object declared in OBJ section as ser: "Extended_FDSerial" in your example.

    The 'FILE' declaration is only for include binary data from file instead of typing they in DAT section.

    As you, i hope that some enhancemant as #include, pre-processor, macros, better bite and byte support, ... will come with future spin and Propeller version.

    dro.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    in medio virtus
Sign In or Register to comment.