Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : Fun with the Library (Pico 2 Gamma system)
Author | Message | ||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6764 |
lib src.zip This is my current library source file. I'm no programmer so it's pretty ropey, but it illustrates some of the things that the Library can be used for. If you aren't using a Library then using this will create it, but you will have to modify the file first as it won't suit your hardware! It will use flash slot 3 so make sure that there's nothing on there. Simply unzip it and save "lib src.BAS" to your SD card or XMODEM it over. In particular check out the way that SUB LED will attempt to control your non-existent front panel LED. :) Once you have saved the modified file (you'll lose it forever if you don't) use LIBRARY SAVE to create your library. The source file will magically disappear from the editor. Enter Help at the command line to play with the (rather skimpy at this stage) help system. I programmed the F1 key to do it. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
PhenixRising Guru Joined: 07/11/2023 Location: United KingdomPosts: 855 |
Thanks Mick, quite a bit of stuff here that I was unaware of (shouldn't be the case with spending so much time here) Question: Is this block comment for real? MMEdit doesn't recognize it. /* Look after this file And keep backups! It is awkward to maintain the Library without it. How to use this file: 1 . Make your changes in the editor 2 . Save it - A VERY IMPORTANT STEP!!! 3 . At the command line LIBRARY DELETE 4 . At the command line LIBRARY SAVE The revised library is now active - and has disappeared from the editor. You did remember step 2, didn't you?? You can add SUBs etc directly to the library without using this file but I don't recommend it as making deletions or other changes in the library is a bit of a pain as you have lost all the lovely comments. */ |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6764 |
No idea about MMEdit, I don't use it. Yes, it's been valid in MMBasic for a while now. It's even shown at the beginning of LIST COMMANDS. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 6092 |
In MMEdit program menu there is a "convert C type comments" So it doesn't display then correctly but does know about them. Peter keeps giving me challenges. That is one that needs major changes to implement. Jim VK7JH MMedit MMBasic Help |
||||
phil99 Guru Joined: 11/02/2018 Location: AustraliaPosts: 2133 |
Once you have saved the modified file (you'll lose it forever if you don't) use LIBRARY SAVE Well almost, but not quite.> AUTOSAVE You can preserve important comments as strings.Sub mm.startup Local i%, C$="'This runs automatically once only on power up/reset" For %i=1 To 40 If MM.Info(pin i%)="OFF" Then SetPin i%, DIN, PULLUP Next End Sub > Saved 164 bytes > library save Library Saved 152 bytes > Library list Sub mm.startup Local i%, C$="'This runs automatically once only on power up/reset" For %i=1 To 40 If MM.Info(pin i%)="OFF" Then SetPin i%, DIN, PULLUP Next End Sub > To edit within the Pico save your current program then copy the output of Library List to the clipboard, press F10, paste clipboard then Ctrl-Z then F4. When done:- > library delete > library save > It is very clumsy but if you are desperate it can be done. |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6764 |
Handy to know about stringy comments and that all is not lost. Thanks Phil. :) Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6764 |
Some tweaks to my Library code to make the introductory page nicer: Changes in SUB mm.startup to put the function keys along the bottom like the editor: Sub mm.startup 'This runs automatically once only on power up/reset Local i 'The following puts unused pins into a stable state for the RP2350 For i=1 To 40 If MM.Info(pin i)="OFF" Then SetPin i, DIN, PULLUP Next SetPin gp20, dout led 2,1,4 'make it a pretty colour. :) Print "== PicoGAME 2350 GAMMA ==" i = MM.Info(FONTHEIGHT) Line 0,(MM.VRes-i*2-4),MM.HRes,(MM.VRes-i*2-4) Print @(0,MM.VRes-i*2); Print "F1:Help F2:Run F3:List F4:Editor F5:CLS"; Print @(0,MM.VRes-i); Print "F9:FE F10:Autosave F11:XMODEM Rec. F12:XMODEM Send"; Print @(0,50); End Sub A GPIO pins list added to Help/Utilities: Case "p" 'Note: these Case statements are specific to this system Print " Pin GPIO Description" For i=0 To 28 If (i<12 Or i>19) Then a$=Str$(i) Print "("Str$(MM.Info(pinno "GP"+a$),2)")"; Print " GP"+Str$(i,2);" "; Select Case i Case 10,11 Print "Audio" Case 4,5,6,7 Print "SD Card" Case 8,9 Print "Console - COM2" Case 2,3 Print "System I2C & front socket - I2C2" Case 20 Print "Front panel LED" Case 0,1 Print "ESP8266 & front socket - COM1 & I2C" Case 21,22,26,27,28 Print "User GPIO port" Case Else Print "-See MMBasic manual-" End Select EndIf Next My menu selection system now uses a little Function to tidy things up. For example: Print "Help categories available are:" Print "[A]bout ibrary [S]ound [D]evice [M]ath" Print "dsplay [K]eyboard tility [Esc]" Select Case _hmen0$("ALSDMIKU") Case "a" .... Case "l" .... Which uses this Function: Function _hmen0$(a$) 'used internally for menu choice Local k$ Do k$=UCase$(Inkey$) Loop Until Instr(a$,k$) Or Asc(k$)=27 _hmen0$ = LCase$(k$) End Function LOL! I see that the CODE commands don't protect against everything. :) I just reset them at the end. . Edited 2024-10-15 23:32 by Mixtel90 Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
Print this page |