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 : is there a list of error messages in mmbasic?
Author | Message | ||||
v.lenzer Regular Member Joined: 04/05/2024 Location: GermanyPosts: 49 |
I only recently discovered the rp2040 zero and I enjoy programming with mmbasic. At the moment I'm trying to work on the gui controls (GUI BUTTON). I get the error message "gui reference number #1 in use". Sometimes it's a different number. What could be wrong? I haven't found anything (google, manual, this forum). "gui disable all" didn't help either. Can anyone give me a hint? (I'm using version 5.08) Edited 2024-06-04 18:36 by v.lenzer Best wishes! Joachim |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6783 |
When programming using the GUI controls each control has a reference number. That's used to work with that particular control. If you define, say, a button you might use GUI BUTTON #6, "Button" etc. That is now control #6 and nothing else can use that number. If you now define a LED using GUI LED #6, "LED" etc. you'll get the error "GUI reference #6 in use" because that reference number has already been used. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
v.lenzer Regular Member Joined: 04/05/2024 Location: GermanyPosts: 49 |
Hello Mick! Thank you for your answer. My program has a main menu with buttons. I use them to branch into different parts of the program. From the program parts, I want to use the "MENU" button to go back to the main menu. There, the command "GUI BUTTON #1 ....." is processed again and an error occurs. Obviously, I am not allowed to call the command a second time. But how can I display the buttons again? Here is my source code. But be careful: It is in development and I am a beginner when it comes to RP2040 Zero and MMBasic. I am also trying out different techniques with it. Comments are german. 'PIO-Monitor V.1.0. JM 5/2024 'PicoMite MMBasic Version 5.08.00 'OPTION SYSTEM SPI GP6,GP3,GP4 'OPTION LCDPANEL ILI9341, LANDSCAPE,GP7,GP2,GP5 'OPTION GUI CONTROLS 76 'OPTION TOUCH GP14,GP15 'GUI CALIBRATE 0, 133, 158, 898, 644 'COM 6 'to do: ' 'Datenlogger auf SD-Card 'Trigger? setpin gp09,din setpin gp10,din setpin gp11,din setpin gp12,din setpin gp26,din setpin gp27,din setpin gp28,din setpin gp29,din DefineFont #8 'hi-lo-40x20.bas ' Font type : Numeric (2 characters) ' Font start : CHR$(48) ' Font size : 40x20 pixels ' Memory usage : 204 bytes 02301428 00000000 00000000 00000100 00010000 00000000 00000000 00000000 00000100 00010000 00000000 00000000 00000000 00000100 00010000 00000000 00000000 00000000 FFFF0100 FFFFFFFF FFFFFFFF 00000000 00000000 00000100 00010000 00000000 FFFFFFFF FFFFFFFC 00C0FDFF C00D0000 0C000000 000000C0 0000C00C 00C00D00 C00D0000 0C000000 000000C0 0000C00C 00C00D00 C00D0000 0C000000 000000C0 0000C00C 00C00D00 C00F0000 0F000000 00000000 00000000 00000100 00010000 00000000 End DefineFont const messen=1 const monitor=2 const d0=3 const d1=4 const d2=5 const d3=6 const d4=7 const d5=8 const d6=9 const d7=10 const menu=11 '------------------------------------------------------------------------ Menue: bh=50 'button-Höhe bw=240 'button-Weite cls rgb(black) font 5 gui button messen, "Messen",40,80,bw,bh, rgb(white),rgb(red) gui button monitor, "Monitor",40,160,bw,bh, rgb(white),rgb(red) do if ctrlval(messen)=1 then goto zeitmessung if ctrlval(monitor)=1 then goto monitor loop '------------------------------------------------------------------------ 'Ausgabe horizontal binär, dezimal monitor: cls rgb(black) x=0:y=60 menubutton do p=port (gp09,4,gp26,4) d$=str$(port (gp09,4,gp26,4)) if p < 10 then d$="00"+d$ if p > 9 and p < 100 then d$="0"+d$ font 8:text x,y,bin$(p,8) font 6:text x+100,y+60,d$+" " loop until ctrlval(menu)=1 goto menue ------------------------------------------------------------------------ 'Zeitmessung zwischen Flankenwechsel 0-1-0 oder 1-0-1 zeitmessung: bh=60 'button-Höhe bw=60 'button-Weite r1=16 'äußerer Rand und mittlerer Abstand in x-Richtung r2=20 'mittlerer Abstand in y-Richtung font 5 cls rgb(black) 'Portauswahl D0 bis D7 x=r1:y=r1 gui button d0, "D0", x,y,bw,bh, rgb(white),rgb(red) x=x+r1+bw gui button d1, "D1", x,y,bw,bh, rgb(white),rgb(red) x=x+r1+bw gui button d2, "D2", x,y,bw,bh, rgb(white),rgb(red) x=x+r1+bw gui button d3, "D3", x,y,bw,bh, rgb(white),rgb(red) x=r1:y=r1+r2+bh gui button d4, "D4", x,y,bw,bh, rgb(white),rgb(red) x=x+r1+bw gui button d5, "D5", x,y,bw,bh, rgb(white),rgb(red) x=x+r1+bw gui button d6, "D6", x,y,bw,bh, rgb(white),rgb(red) x=x+r1+bw gui button d7, "D7", x,y,bw,bh, rgb(white),rgb(red) menubutton 'Pin-Nr.-Zuweisung für Messung und GP-Zuweisung für Anzeige do if ctrlval(d0)=1 then p=12:g$="D0-GP9":goto messung if ctrlval(d1)=1 then p=14:g$="D1-GP10":goto messung if ctrlval(d2)=1 then p=15:g$="D2-GP11":goto messung if ctrlval(d3)=1 then p=16:g$="D3-GP12":goto messung if ctrlval(d4)=1 then p=31:g$="D4-GP26":goto messung if ctrlval(d5)=1 then p=32:g$="D5-GP27":goto messung if ctrlval(d6)=1 then p=34:g$="D6-GP28":goto messung if ctrlval(d7)=1 then p=35:g$="D7-GP29":goto messung if ctrlval(menu)=1 then goto menue loop Messung: gui disable all cls a=pin(p) t=0 do loop until pin(p) <> a do t=t+1 loop until pin(p) = a if a=1 then b=0 if a=0 then b=1 t=t*38316 'Dauer in nsec für einen Durchlauf t font 5 text 10,20,"Port "+g$ text 10,80,"Dauer " font 8:text 170,80,str$(a)+str$(b)+str$(a) font 5 if t>=1000000 then text 10,140,str$((int(t/10000))/100)+" msec" if t<1000000 then text 10,140,str$(t/1000)+" usec" menubutton do loop until ctrlval(menu)=1 goto auswahl '----------------------------------------------------------------------- sub menubutton: gui button menu,"Menu",210,170,100,60, rgb(white),rgb(red) end sub Best wishes! Joachim |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6783 |
I'm afraid you'll have to ask someone who uses the GUI controls more than I do. :) I've played with them but that's all. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
v.lenzer Regular Member Joined: 04/05/2024 Location: GermanyPosts: 49 |
I found a workaround: the menu button gets a different number in each part of the program. That works. It also works if I work with RUN instead of GOTO MENU, since the menu is at the beginning of the program. That's OK for me. That allows me to realize my planned projects. In the options I entered "option controls 75" :) Best wishes! Joachim |
||||
William Leue Guru Joined: 03/07/2020 Location: United StatesPosts: 393 |
Although you were asking about error codes that relate to GUI, here is my own strictly non-official list of MMBasic error codes. Also, note that you can always print out mm.errmsg$ to get a text explanation of an error. ' MMBASIC Error Codes -- non-official and likely partial list const FR_OK = 0 ' Succeeded const FR_DISK_ERR = 1 ' A hard error occurred in the low level disk I/O layer const FR_INT_ERR = 2 ' Assertion failed const FR_NOT_READY = 3 ' The physical drive cannot work const FR_NO_FILE = 4 ' Could not find the file const FR_NO_PATH = 5 ' Could not find the path const FR_INVALID_NAME = 6 ' The path name format is invalid const FR_DENIED = 7 ' Access denied due to prohibited access or directory full const FR_EXIST = 8 ' Access denied due to prohibited access const FR_INVALID_OBJECT = 9 ' The file/directory object is invalid const FR_WRITE_PROTECTED = 10 ' The physical drive is write protected const FR_INVALID_DRIVE = 11 ' The logical drive number is invalid const FR_NOT_ENABLED = 12 ' The volume has no work area const FR_NO_FILESYSTEM = 13 ' There is no valid FAT volume const FR_MKFS_ABORTED = 14 ' The f_mkfs() aborted due to any problem const FR_TIMEOUT = 15 ' Could not get a grant to access the volume within defined period const FR_LOCKED = 16 ' The operation is rejected according to the file sharing policy const FR_NOT_ENOUGH_CORE = 17 ' LFN working buffer could not be allocated const FR_TOO_MANY_OPEN_FILES = 18 ' Number of open files > FF_FS_LOCK const FR_INVALID_PARAMETER = 19 ' Given parameter is invalid -Bill |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 4036 |
I'm pretty familiar with the firmware C source now and my understanding is that: To the first (and second, third, fourth ...) approximation MMBasic does not have meaningful error codes/numbers other than Mm.ErrNo <> 0 is an error; the contents of Mm.ErrMsg$ are generally useful though. The codes that Bill quotes above are specific to errors in the third-party "Generic FAT Filesystem Module" which I believe is used by the CMM2 and the PicoMite "B:" drive (but not the PicoMite "A:" drive). In general if there is an error then Mm.ErrNo = 16, this value is hard-coded into MMBasic's central C error() function. Why *16*, I've no idea, probably some historical legacy. I'm trying to do better for MMB4L, but that's a work in progress and the list of error codes is very far from stabilising. Best wishes, Tom Edited 2024-06-04 23:30 by thwill Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
PhenixRising Guru Joined: 07/11/2023 Location: United KingdomPosts: 857 |
Disclaimer: I'm clueless about MM GUI stuff. However, I do graphics programming on Android and this strikes me that the GUI BUTTON is being repeatedly defined but with the same handle. A quick check of the manual shows that the button is defined one time and from then-on, only the handle is referenced. GUI CAPTION #1, "Speed (rpm)", 200, 50 ' label the number box GUI NUMBERBOX #2, 200, 100, 150, 40 ' define and draw the number box CtrlVal(#2) = 100 ' default value for the speed GUI BUTTON #3, "RUN", 200, 350, 0, RGB(red) ' define and draw the RUN button DO ' this runs in a loop forever IF CtrlVal(#3)<10 OR CtrlVal(#3)>200 THEN ' check the speed setting GUI DISABLE #3 ' disable RUN if it is invalid ELSE ' otherwise GUI ENABLE #3 ' enable the RUN button ENDIF IF CtrlVal(#3) = 1 THEN ' if the button is pressed SetMotorSpeed CtrlVal(#2) ' make the motor run ELSE ' otherwise the button is up SetMotorSpeed 0 ' therefore set motor speed to zero ENDIF LOOP |
||||
v.lenzer Regular Member Joined: 04/05/2024 Location: GermanyPosts: 49 |
Thank you very much for your answers and tips. I tried to test the example program. It is full of errors. The author has certainly never run it. The definition of GUI BUTTON #3, for example, is wrong and incomplete. The query ctrlval(#3) should be ctrlval(#2). I then stopped trying. I will try to solve my problem with GUI ENABLE and GUI DISABLE. But I expect much more from the GUI SETUP Nbr. command that I came across in the manual. I have to get used to programming in an object-oriented way. Up until now, my input buttons were buttons on a circuit board. I am now testing the options mentioned and will report back. Hopefully with a successful report. Until then, best wishes! Joachim Edited 2024-06-05 03:53 by v.lenzer Best wishes! Joachim |
||||
v.lenzer Regular Member Joined: 04/05/2024 Location: GermanyPosts: 49 |
I think I have found the solution: I first defined the screens with the buttons. To do this, I used the GUI SETUP nbr command. In the rest of the program, the various screens with the buttons are then called up with the GUI PAGE nbr command. You can also combine screens with one command. For example, I defined a screen (#3) that has the MENU button at the bottom right. Another screen has the port pins for selection (#1). With the GUI PAGE #1, #3 command, I can now display the buttons with the port pins together with the menu button. An error message no longer occurs. Best wishes! Joachim Edited 2024-06-05 16:58 by v.lenzer Best wishes! Joachim |
||||
Print this page |