FemtoBasic version for QuickStart board
Mike Green
Posts: 23,101
Just for fun ... I got my QuickStart board running today and thought I'd put together a version of FemtoBasic (actually DongleBasic) for it. The only differences from the DongleBasic in the Object Exchange is that the I/O pins for an optional SD card were changed to 12-15 and a BUTTONS statement was added to allow use of the touch buttons. This just calls the Touch Buttons object from the demo program for the QuickStart board. Look at the description in the included QSBasicDocs file.
Updated QSBasic archive to include I2C statement and its documentation.
Updated QSBasic archive. See comments at beginning of main file.
Updated QSBasic archive to include I2C statement and its documentation.
Updated QSBasic archive. See comments at beginning of main file.
zip
115K
Comments
I've not played with any of the alternate languages yet.
This will be the first.
Looks like Tiny BASIC on the Propeller.
It will be a week or more before I get the chance.
I'm closing on the new house tomorrow and then moving again.
Out of this apartment and into a real house! Yea!
So as soon as I find my toys and get set up again I'll be on it.
If you do requests, I'd love to see a real While-wend.
And labels instead of line numbers.
But if not, I'm ok with primitive BASIC.
What's the performance like?
How do you get it into the Prop?
Is the source code available???
Will you respect me in the morning???
You load it into the Prop like any other program. There's a pre-compiled binary in the .ZIP file that you can use with the Propeller Tool or BST.
Source code? Look in the .ZIP file. It's intended for people to modify. Look in the Object Exchange for other versions for specific hardware with extensions for that hardware.
When I get back up I'll give it a Spin!
Mike's Femtobasic is the bomb! Not only is the project very cool, but his source code is an excellent way to learn Spin if you tend to learn by example. Lots of good stuff there.
OBC
FemtoBasic is also useful for developing complicated software code that will eventually be converted to spin code.
Here is an example of what I mean:
I was developing a new command to add to FemtoBasic that:
1. prints numbers in any number base from 2 to 36.
2 I wanted to specify how many characters this number will occupy
3. I wanted to specify where number separators were placed.
I first made it work by writing it in Femto. OK, a bit slow but it worked nicely.
Just cut and paste it into Femto and see how it works. Femto is much easier to test and edit than Spin.
I then translated the Femto code into spin. Ok use repeat instead of for/next. But it's really easy to do. The code snipit is then added to my Dongle basic as a new command called "PRINTA".
Duane J
Programming examples are always helpful.
Thanks for including the data and resources.
The language is included in the following updated Propeller list.
http://humanoidolabs.blogspot.com/2012/03/ultimate-list-of-big-brain-languages.html
ULTIMATE LIST BIG BRAIN PROGRAMMING LANGUAGES
Please do not add this or the PropBOE version of FemtoBasic to your list. It's very misleading. They are not languages. They are trivially reconfigured versions of the same language and same language interpreter. If the Propeller Tool supported compile-time conditionals like BST does, these would all be produced from the same source file. I wanted to keep them supported by the Propeller Tool, so they're not.
You make me feel old by showing the first programming language that I learned back in the 80's and it's cool to see it again. I will add FemtoBasic to the programs that I currently have and continue to show examples, because it will help others learn something different.
Mike, thanks for your note. I have added a notes section to the list and a note at the top and near the bottom of the blog indicating the list includes languages and their versions. I hope this clears up any confusion the list may have caused in the past.
The old list at the Parallax site was suspended (Do to a problem posting to a post of extended length and/or the inability to find time to update the redundancy of two competing lists). The new updated and reformatted list is here.
It's useful being able to reference a list to find a single language and a specific version of that language which runs on board A or board B or board C... Your updates to the same language, with references to the same source file, are valuable and useful contributions towards making the same language work with different flavored boards.
I just tried the example you provided in post #3 but hit a problem with a syntax error with line 130, this I realise now is because the adapted version that Jeff created isn't the latest version of FemtoBasic which has the BUTTONS command implemented.
I wouldn't have a clue as to how to adapt the latest version to run with PropTerminal and was wondering if you could kindly help with how it could be done as I'd really like to start playing with the quickstart buttons using FemtoBasic with PropTerminal
Thanks
http://insonix.ch/propeller/objects/PropTerminal_0.4.zip
This zip file contains the PropTerminal program and the version of FemtoBasic that Jeff adapted is located here:
http://dl.dropbox.com/u/7557533/shared/FemtoBasic_Propterminal.zip
Many thanks for your help in this
My kids might actually use this one.
Now all I need to do is buy an sd card for the reader I have.
Thanks again for this, it should be fun to play with it. Both of my quickstart boards are both configured as fm radios, and it's going to take some doing to convince either my son or myself to use one of them for other things (or I could just buy another one)
I'd grab one at the rs nearby that sells them, but they want 43 bucks for one, even with shipping, and wait time from parallax, I don't think the mark-up on that one is worth it. <sigh>
It'd be ok for the bs2 hw board though, they sell it for the same price, and that can't get here from parallax w/shipping charges for less than that, so when I need one of those, I do get them there.
Nice to have the ability.
Anyway, this will be a useful toy for a while.
I'll put this on my todo list. I really love Propterminal, (here's an article I wrote on it. as it's all the power of the PMC project without having to have more than a Quickstart. BTW, I've still got a few of the Quickstart/Servo&More combo kits left here.
Jeff
Keep up the good work guys you are an inspiration to beginners like myself that maybe one day may aspire to something like this.
I learned a LOT of my initial spin coding from following Mike's examples in Femtobasic. Mike is right on the money, it's only appears intimidating on the surface. I'd challenge you to dig into the code and as just add simple command that puts something back on the screen once you issue it. You'll get really hooked in a hurry. I did.
Jeff
First thing I believe I need is to add the touch buttons object from the obex and then look at how jeff added those extra basic commands,
I notice there are "tok byte" before each new command the last one jeff added was 65 so I need something like:
tok 66 byte "buttons",0
and add a tok 66 in the toks section like:
@tok66
Can it be as simple as that? or is there more I need to put elsewhere?
or perhaps Mike hasn't got around to adding the buttons command just yet?
All I had to do was including the BB_TouchButtons object in the OBJ section, added the button.start methode in Main, renamed the "KEYCODE" token to "BUTTONS", and then copied the Button-token-code from the QSBasic version to the right token in the "factor" methode.
You need the BB_TouchButtons.spin from the ZIP in the first post in addition to the attached Spin file.
Have fun.
Andy
Once you've added the string and the address to the tables, the keyword will be recognized by the interpreter. There's a big CASE statement for the Basic statements and you'll need to add an entry for the new keyword number if the keyword is used to begin a statement. Use some simple statement as a model. In the case of BUTTONS, this keyword is used as a function and there's another big CASE statement in the 'factor' method for simple functions. The code there just RETURNs the value of the function.
@Ariba: Thanks Andy
I notice Andy mentioned that he replaced KEYCODE with BUTTONS where I was trying to add another line
The bits I added were:
added the touchbuttons obj
tok66 byte "BUTTONS",0
in the tok section added @tok66
and in the pri factor | tok, t, i section
added 178: 'BUTTONS
return buttons.state
this produces a "syntax error in line 10" when running femtobasic program: running Andys version it works perfectly so perhaps by adding a command rather than replacing the KEYCODE command( or another) I had to add some more code elsewhere?
Andy
With your last couple of posts I'm starting to get the hang of it somewhat, It shows how far behind I am with spin but I'll get there eventually.
I understand now how Andy used tok 49 and got 177(128+49) and put the button.start there from Mike's post #27, I'm not understanding from reading the code quite where the 128 bit comes from (something to do with the keyword position in the table?) that's a bit over my head at the moment as is most of the femtobasic code, but i'm sort of understanding bits of it here and there, the next thing is to try what you said and add a simple command to do something although I'm not sure what at the moment.
I think a nice addition would be a BEEP or SOUND command , although I'm not sure if that is too ambitious just yet, any ideas for something simple I could attempt that's not too daunting for a Spin beginner?