RPi BASIC programming examples wanted - in 24 hours!
Steve Revill (20) 1361 posts |
Hello. Yet again, we’re doing some work on the RISC OS Pi distro and related things. We’ve spotted an opportunity for the community to help out, once again! Does anyone out there have a simple demo BASIC program (that’ll work outside the desktop) which shows what you can do with the GPIO module ? Ideally, something that doesn’t require any extra kit aside from your RPi. Maybe flashing some LEDs or similar? It’d need to be BSD licenced (or something equally permissive) because we’re hoping to include it in the distro. That’s the challenge – you’ve got 24 hours to get something to us at code@riscosopen.org. Any other simple, stand-alone, non-destop BASIC programs that talk to popular RPi peripherals and could be included under similar terms would be more than welcome (e.g. something that demos IIC, UART or that sort of thing). The key points, at the risk of repeating myself ;) are:
|
Tank (53) 375 posts |
Steve, In the initial import of the GPIO module, you have also included !PiLED (not registered by the way!!!), that when run simply switches the file activity LED on and off at key presses. The !RunImage from that will work outside the desktop. The “App” just runs a taskwindow for it. |
Rick Murray (539) 13840 posts |
If you’re also looking for some prebuilt stuff to talk to other hardware – you’re welcome to my OLED module. Written in C/assembler (kind of necessary, but the code is all well commented and I’m prepared to open it). Benefits? You only need to buy a dirt-cheap OLED off eBay (under a tenner), make a small modification (or find a nerd / tv repairman who can do this), and you’re set to go. Hooks directly to the RISC OS IIC port. No extra hardware. It is feasible to do this stand-alone in BASIC – my original code to convert bitmap to OLED data was written in BASIC. But… um… The process of converting to OLED data – given it needs a long preamble to set it up, plus it draws eight pixels down at a time in columns across – it’s best left in the capable hands of something else so you can do the fun stuff and not worry too much about how this becomes that. ;-) |
Clive Semmens (2335) 3276 posts |
I’m probably old enough (at 64) for that, too, but “ought to be” may be as far as it goes…trouble is, I’ve developed a probably undesirable aptitude for following labyrinthine code…structured and commented, okay, but well? I’m not sure… |
Simon Pyatt (2276) 7 posts |
I have something that had been gathering dust on my Pi that may qualify. Anyhow, email sent. (Apologies, I should really post a bit more on here!) |
Leo (448) 82 posts |
I’ve sent in a simple ‘Simon Says’ type game that uses the GPIO module. I’ve also included code for driving the PiGlow via IIC ( http://www.mybigideas.co.uk/RPi/PiGlow/ ) which may be useful (I know I could have done with a working example of using IIC from BASIC when writing it!) |
Steve Revill (20) 1361 posts |
Thanks everyone for all the suggestions. I can’t guarantee everything will get in initially, primarily because we’ve got ourselves into such a rush(!) but it has all been very useful. |
Wouter Rademaker (458) 197 posts |
I’ve send in two simple programs that uses the LedBorg, but can also be used with just 3 leds. |
Steve Drain (222) 1620 posts |
I have a couple of simple BASIC programs that run on the MCP82170 via IIC, but unfortunately they do not meet your criteria because they use Basalt and my own small MCPIO module. Maybe next time. ;-) |
Steve Revill (20) 1361 posts |
Well, we’ve got everything together now. Thanks for all your help. Keep sending stuff if you think it’s interesting/useful, you never know what we might add into the next RISC OS Pi release… Also note, we’ll loosen a lot of those restrictions from now on. Basically, anything interesting will be considered (doesn’t have to be BASIC or operate outside the desktop). |
Chris Hall (132) 3554 posts |
Thanks for all your help. Keep sending stuff if you think it’s interesting/useful, you never know what we might add into the next RISC OS Pi release… Also note, we’ll loosen a lot of those restrictions from now on. Basically, anything interesting will be considered (doesn’t have to be BASIC or operate outside the desktop). Does it still have to relate to the GPIO module? |
Jeffrey Lee (213) 6048 posts |
I’d assume that “anything” means “anything”. I might be wrong of course! I have a few ideas for things which would fall into the “anything” category, but as usual I have no real time to implement them. |
Steve Drain (222) 1620 posts |
Could you include some of the demos from Jan Vibe in StarInfo? They were pretty impressive. And there were quite few one-liners there, too. Copyright might be a problem. |
Chris Hall (132) 3554 posts |
You are welcome to include any of my items from !Store – !Cat, !MultiTask, !MakeDraw, !CountDn, !SudoTutor or even (rather arcane) !TraceMe. All of these are multi-tasking applications written in BASIC. None of them is more than about 15000 lines of BASIC. Some even have some REM comments. |
Steve Revill (20) 1361 posts |
This is something that’s just bubbling at the back of my mind, along with the 2,000 other ROOL things bubbling at the back of my mind. I’m leaning more towards small and simple demos (rather than whole applications) that could be considered ‘cool’, ‘useful’ or ‘educational’. I recall the StarInfo stuff certainly being cool, so that’d be interesting if someone could chase it up to find out about rights. If that sort of stuff could be republished under (say) a BSD licence, it’d be perfect. My gut says I’d look a favourably upon something that’s well structured and well commented and probably not too complicated. |
Chris Hall (132) 3554 posts |
Does anyone out there have a simple demo BASIC program (that’ll work outside the desktop) You can include this – it is written in BASIC, is commented. It is a fruit machine simulation that works outside the desktop. I wrote the first version of this programme in 1972 in a Sixth Form computing course at school on a Hatfield Polytechnic time sharing terminal at Borehamwood College of Further Education. It was subsequently developed on a Compukit UK101 (adding 6502 machine code), a Nascom 2 (Z80 machine code), a BBC model B (6502 again), a BBC Master, and finally an Acorn Archimedes A310 in 1988 (ARM machine code). As it still worked on an Iyonix under Aemulor (for the 16 colour screen mode) twenty five years later, I tried to get it working on a Raspberry Pi Pico… At the moment the SCREENLOAD command it uses (to avoid having to use the Font manager to write the initial screen) causes an Abort on Data Transfer error on the Pico build (it works fine on the Pi so long as you give some memory to the system sprite area using *configure spritesize 32k) but that will probably be fixed sometime? Sorry it wasn’t within 24 hours… Colours look a bit grim as they were from a 16 colour mode… |
Chris Hall (132) 3554 posts |
Although not yet bug free (that will have to wait until late next week) it does at least now run on the Pico – needs a configured spritesize of 320k and runs in MODE 21 and avoids a second ‘SLOAD’ command (which gives an abort) and SCREENLOAD (ditto). |
Chris Hall (132) 3554 posts |
Well nothing is bug free, but it is now tidy and functions correctly on the Pico, provided you do a *configure spritesize 320k and a CTRL-BREAK before trying to run it (don’t know where the old utility ‘Malloc’ is). A fruit machine simulation, written in BASIC, illustrating VDU commands. Try it here |
Stephen Unwin (1516) 154 posts |
I don’t know if these are of any use. |
Rick Murray (539) 13840 posts |
Depends on how flexible you want the terms to be.
1 Hint: absolutely zero for if a single GPL function found its way into the RISC OS code base, it would have nasty repercussions. This is why we aren’t pilfering Linux for code for drivers for things – RISC OS is a GPL free zone, by necessity. |
Chris Hall (132) 3554 posts |
Well nothing is bug free, but it is now tidy and functions correctly on the Pico, provided you do a *configure spritesize 320k and a CTRL-BREAK before trying to run it It now works with no special tricks. It uses mode 21 – as the Pandaboard had no 16 colour mode, I converted it to run in mode 21 (256 colours). Now I find that the Titanium has 16 colour modes but no 256 colour mode!? I’m not going to convert it back again! ARMX6 cannot handle both mode 21 AND hdmi audio yet. So my ARMX6 is back to analogue sound for the moment. Latest version of fruit machine is available from my web site or from !Store. |
Chris Hall (132) 3554 posts |
I’m not going to convert it back again! Well I did update it after all, so that it now works on Titanium [no C256] and ARMX6 [no C16] with HDMI audio [no Mode 21] (as well as Risc PC, Pi, Pico Pi, Pandaboard, Beagleboard, IGEPv5 etc.). It therefore chooses Mode 21, 27 or 28 (preferring 28) as available (and will accept 800×480 as well). I have also improved the graphics – converting to 16 colours was a bit of a pain – I can use !DPlgScan to convert the sprites it uses from C256 to C16 with optimal pallette but I need specific logical colours so that inverting against 7 (using PLOT EOR with 7) and inverting against 15 (using PLOT invert) produce the correct colour transformations (to flash the reels and light the table without rubbing out the snakes and ladders). That meant shuffling the logical colour around until it looked right… Anyway as I use legal OS calls, the BGR/RGB nature of the machine does not affect the programme. |