Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 02:41 05 Jul 2025 Privacy Policy
Jump to

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 : dim var as byte

     Page 7 of 16    
Author Message
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2527
Posted: 03:54pm 06 Aug 2022
Copy link to clipboard 
Print this post

Thanks for the advice. I am having one error after another. Latest is the display isn't configured but it does the touch, filled circles and read sd card for ili9341 ok and is supposed to remember the gp setup.
I tried
OPTION SYSTEM SPI GP18, GP19, GP16
OPTION LCDPANEL ILI9341, P, GP15, GP14, GP13
but get
> RUN
[6] Option SYSTEM SPI GP18, GP19, GP16
Error : Invalid option
I rechecked my wiring and it matches and the display works but not in my program.
I don't know what to do next.
If I could see the basic in the circles demo that works I could copy that to work on.
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5035
Posted: 03:59pm 06 Aug 2022
Copy link to clipboard 
Print this post

Not sure if this is the right thread name, it seems a bit derailed. Anyway, there are 2 versions of picomite. The normal version supports LCD. The VGA version supports a vga monitor.

The VGA software does not support option system spi. Check your version.
PicomiteVGA PETSCII ROBOTS
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10198
Posted: 04:06pm 06 Aug 2022
Copy link to clipboard 
Print this post

You can't set the OPTION LCDPANEL in a program. You just set it once at the command line -PLEASE READ THE MANUAL

  Quote  The PicoMite includes support for many LCD display panels using an SPI, I2C or parallel interface.
These commands must be entered at the command prompt (not in a program)
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2527
Posted: 05:02pm 06 Aug 2022
Copy link to clipboard 
Print this post

Yes matherp, did set up in terminal and said it's supposed to be stored and I can type
gui test lcdpanel in teraterm and get filled circle demo.
If I don't use  OPTION SYSTEM SPI GP18, GP19, GP16
OPTION LCDPANEL ILI9341, P, GP15, GP14, GP13
in my code it gives error lcd not configured when it sees the PIXEL command ???.
using mmedit v4 and PicoMite firmware V5.07.04
I don't find the error messages helpful and I don't see answers in the manual as helpful as otherwise I would have read data working. No use saying it's like glbasic if I've never used glbasic and I looked up glbasic read data and that's vague.
I expected a learning curve but that it was basic but the errors.
This thread was about me learning mmbasic variables and I'm enlightened, thanks.
if I use OPTION DEFAULT INTEGER I still got to dim all variables or get not declared error.
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2527
Posted: 05:29pm 06 Aug 2022
Copy link to clipboard 
Print this post

If I have the OPTION SYSTEM SPI GP18, GP19, GP16
OPTION LCDPANEL ILI9341, P, GP15, GP14, GP13  set up in teraterm and the lcd and touch and sd card work then do I need to tell my code the display values? it's not clear for me. Why do I get lcd not configured error when it sees pixel x,y,colour if it is configured and works? I can't see any explanations of error messages.
I got the display drawing circles in front of me... why can't I code that?
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3348
Posted: 05:56pm 06 Aug 2022
Copy link to clipboard 
Print this post

  stanleyella said  if I use OPTION DEFAULT INTEGER I still got to dim all variables or get not declared error.


Works for me.

> new
> option default integer
> i=1234
> ?i
1234
>

Perhaps you also have OPTION EXPLICIT.
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3348
Posted: 06:03pm 06 Aug 2022
Copy link to clipboard 
Print this post

  stanleyella said  I don't see answers in the manual as helpful as otherwise I would have read data working.


This is what the manual says:



I'm not sure how you can blame it for your repeated efforts to use "READ DATA ..." as the form of the command despite having had the problem pointed out several times.
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10198
Posted: 06:06pm 06 Aug 2022
Copy link to clipboard 
Print this post

  Quote  if I use OPTION DEFAULT INTEGER I still got to dim all variables or get not declared error.


Have you also set OPTION EXPLICIT? This forces all variables to be "explicitly" declared

Have you anywhere got the line OPTION RESET?


 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2527
Posted: 07:12pm 06 Aug 2022
Copy link to clipboard 
Print this post

> RUN
[121] Pixel oldspx(temp)+spw,oldspy(temp)+spht,BK
Error : Display not configured
>
Pixel 100,100,RGB(white) works in teraterm
> option list
OPTION SYSTEM SPI GP18,GP19,GP16
OPTION LCDPANEL ILI9341, LANDSCAPE,GP15,GP14,GP13
OPTION TOUCH GP12,GP11
GUI CALIBRATE 0, 3878, 3882, -881, -647
OPTION SDCARD GP22

mycode which gives error
> RUN
[120] Pixel oldspx(temp)+spw,oldspy(temp)+spht,BK
Error : Display not configured
>

OPTION BASE 0        ' 0 based arrays
OPTION DEFAULT NONE  ' Don't assume a type for variables
OPTION EXPLICIT
OPTION DEFAULT INTEGER
'OPTION LCDPANEL ILI9341, OR, DC, RESET, CS
'OPTION SYSTEM SPI GP18, GP19, GP16
'OPTION SDCARD GP22
'OPTION LCDPANEL ILI9341, P, GP15, GP14, GP13
'OPTION TOUCH GP12, GP11

dim sp1(255),sp2(255),cannon(119),missile(15),dx(7),dy(7),spx(7),spy(7)
dim oldspx(7),oldspy(7)
dim ptr,bk,wh,bl,gr,cy,re,ma,ye,br,hiscore integer
dim spw,spht,temp,frame,frame_count integer
for ptr=0 to 255
 read sp1(ptr)
next ptr

for ptr=0 to 255
 read sp2(ptr)
next ptr

for ptr=0 to 119
 read cannon(ptr)
next ptr

for ptr=0 to 15
 read missile(ptr)
next ptr

hiscore=0
'white, black,blue, green, cyan, red, magenta, yellow, brown, white, orange, pink, gold, salmon, beige, lightgrey and grey (orUSA spelling gray/lightgray).
'CONST bk = RGB(BLack)
'const wh = rgb(white)
'const bl = rgb(blue)
'const gr = rgb(green)
'const cy = rgb(cyan)
'const re = rgb(red)
'const ma = rgb(magenta)
'const ye = rgb(yellow)
'const br = rgb(brown)

for temp=0 to 7 'set up start sprite positions and directions
do
 dx(temp)=(int(rnd*8)+1)-4 'set up start sprite positions and directions
loop until dx(temp)<>0
do
 dy(temp)=(int(rnd*8)+1)-4
loop until dy(temp)<>0
 spx(temp)=104+((rnd*16)+1)
 spy(temp)=144+((rnd*16)+1)    
'  sprite_status(temp)=1 'activate sprite
next

do 'demo moving sprite
   for temp=0 to 7
'        if sprite_status(temp)=1 then 'is sprite active
           if spx(temp)>213 then 'check right edge
             dx(temp)= 0-dx(temp)
           end if
           if spx(temp)<8 then 'check left edge
             dx(temp)= 0-dx(temp)
           end if
           if spy(temp)>289 then 'check bottom edge
             dy(temp)= 0-dy(temp)
           end if
           if spy(temp)<32 then 'check top edge
             dy(temp)= 0-dy(temp)
           end if
     '
           oldspx(temp)=spx(temp)
           oldspy(temp)=spy(temp) 'get last position for erase
           spx(temp)=spx(temp)+dx(temp)
           spy(temp)=spy(temp)+dy(temp) 'get new position for draw
     '
'            if sprite_status(temp)=1 then 'is sprite active
               if frame=0 then'which sprite to draw
                 erase_sprite 'erase sprite at last position
                 sprite1 'draw sprite1 at new position
               else
                 erase_sprite 'erase sprite at last position
                 sprite2 'draw sprite2 at new position
               end if
'            end if
'       end if
   next temp
 '
   frame_count=frame_count+1 'when to change sprite
   if frame_count=5 then
     frame=not frame
     frame_count=0
   end if

loop

'
sub sprite1
 ptr=0
 for spht=0 to 15
   for spw=0 to 15
     pixel spx(temp)+spw,spy(temp)+spht,sp1(ptr)
     ptr=ptr+1
   next spw
 next spht
end sub
'
sub sprite2
 ptr=0
 for spht=0 to 15
   for spw=0 to 15
     pixel spx(temp)+spw,spy(temp)+spht,sp2(ptr)
     ptr=ptr+1
   next spw
 next spht
end sub
'
sub erase_sprite 'fills window background colour
 for spht=0 to 15
   for spw=0 to 15
     pixel oldspx(temp)+spw,oldspy(temp)+spht,BK
   next spw
 next spht
end sub
'sprite1
data wh,bl,bl,bl,bl,bk,bk,bk,bk,bk,bk,bl,bl,bl,bl,wh
data bk,bl,re,re,re,bl,bl,bk,bk,bl,bl,re,re,re,bl,bk
data bk,bk,bk,bl,re,wh,bl,bk,bk,bl,wh,re,bl,bk,bk,bk
data bk,bk,bk,bl,re,wh,bl,bk,bk,bl,wh,re,bl,bk,bk,bk
data bk,bk,bk,bk,bl,wh,bl,bk,bk,bl,wh,bl,bk,bk,bk,bk
data bk,bk,bk,bk,bk,bl,bl,bk,bk,bl,bl,bk,bk,bk,bk,bk
data bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk
data bk,bk,bk,bk,ye,ye,ye,bk,bk,ye,ye,ye,bk,bk,bk,bk
data bk,bk,bk,ye,bk,bk,bk,bk,bk,bk,bk,bk,ye,bk,bk,bk
data bk,ye,ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,ye,ye,bk
data bk,ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,ye,bk
data ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bl,ye
data ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,ye
data ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,ye
data bk,ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,ye,bk
data bk,bk,ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,ye,bk,bk
'sprite2
data bl,bl,bl,bl,bl,bk,bk,bk,bk,bk,bk,bl,bl,bl,bl,bl
data bk,bl,re,re,re,bl,bl,bk,bk,bl,bl,re,re,re,bl,bk
data bk,bk,bl,wh,wh,re,bl,bk,bk,bl,re,wh,wh,bl,bk,bk
data bk,bk,bk,bl,re,wh,bl,bk,bk,bl,wh,re,bl,bk,bk,bk
data bk,bk,bk,bk,bl,wh,bl,bk,bk,bl,wh,bl,bk,bk,bk,bk
data bk,bk,bk,bk,bk,bl,bl,bk,bk,bl,bl,bk,bk,bk,bk,bk
data bk,bk,bk,bk,bk,bk,bk,ye,ye,bk,bk,bk,bk,bk,bk,bk
data bk,bk,bk,bk,bk,ye,ye,bk,bk,ye,ye,bk,bk,bk,bk,bk
data bk,bk,bk,bk,ye,ye,bk,bk,bk,bk,ye,ye,bk,bk,bk,bk
data bk,bk,bk,bk,ye,bk,bk,bk,bk,bk,bk,ye,bk,bk,bk,bk
data bk,bk,bk,ye,bk,bk,bk,bk,bk,bk,bk,bk,ye,bk,bk,bk
data bk,bk,ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,ye,bk,bk
data bk,bk,bk,ye,ye,bk,bk,bk,bk,bk,bk,ye,ye,bk,bk,bk
data bk,bk,bk,bk,ye,ye,bk,bk,bk,bk,ye,ye,bk,bk,bk,bk
data bk,bk,bk,bk,bk,ye,bk,bk,bk,bk,ye,bk,bk,bk,bk,bk
data bk,bk,bk,bk,bk,bk,ye,bk,bk,ye,bk,bk,bk,bk,bk,bk
'cannon
data bk,bk,bk,bk,bk,wh,wh,bk,bk,bk,bk,bk
data bk,bk,bk,bk,ye,cy,cy,ye,bk,bk,bk,bk
data bk,bk,bk,ye,cy,wh,wh,cy,ye,bk,bk,bk
data bk,bk,bk,ye,cy,cy,cy,cy,ye,bk,bk,bk
data bk,bk,ye,ye,cy,wh,wh,cy,ye,ye,bk,bk
data bk,bk,ye,cy,cy,cy,cy,cy,cy,ye,bk,bk
data bk,ye,bl,bl,bl,re,re,bl,bl,bl,ye,bk
data ye,ye,bl,bl,bl,re,re,bl,bl,bl,ye,ye
data bk,bk,ye,re,re,re,re,re,re,ye,bk,bk
data bk,bk,bk,ye,ma,ma,ma,ma,ye,bk,bk,bk
'missile
data wh,wh,re,re,ye,ye,wh,wh,wh,wh,ye,ye,re,re,wh,wh
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10198
Posted: 07:41pm 06 Aug 2022
Copy link to clipboard 
Print this post

Just run your code with your options and no errors. There is something else you are doing and/or not aware of.

Try re-loading MMbasic then OPTION RESET and also try the latest beta
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7829
Posted: 07:53pm 06 Aug 2022
Copy link to clipboard 
Print this post

Forget the rest of the program. Isolate what's happening with your display first. Write a very simple program to put some text on the screen:

TEXT 10,10,"TEST"
If you don't understand that then READ THE MANUAL. Don't assume anything.
Play with the values. Add the extra options. See how they work.

Once that works you can start to consider parts of your program, but if it doesn't work you *have* to fix it before you do anything else. There's no point in continuing if you can't access the screen.

The only options you need to set up to start with are for system SPI and the display (entered *once* at the command line). If you need to change the display you have to use OPTION LCDPANEL DISABLE before you can enter new values.

Once you can write to the screen you can set up Touch, if you are going to want it. Once again, get it working properly before adding any more code whatsoever.

Always work like this. Test small bits of your program so that you know they work before integrating them into the whole. Trying to run the whole thing from ground zero is pointless - and you'll get a very sore head from banging it against the wall in frustration! It's useful to write the bits as SUBs and FUNCTIONs. You can test the complete blocks then.

EDIT:
It seems Peter has tested it and got in while I was typing. I'm too slow. lol
Edited 2022-08-07 05:56 by Mixtel90
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2527
Posted: 08:40pm 06 Aug 2022
Copy link to clipboard 
Print this post

TEXT 10,10,"TEST" works in teraterm ie prints TEST on lcd
Pixel 10,10,rgb(white) works
cls works
box 10,10,30,30,2,rgb(blue),rgb(red) works

if I try
cls
box 10,10,30,30,2,rgb(blue),rgb(red)
using mmedit I get
> RUN
[1] CLS
Error : Display not configured
>
so mmedit is not working? set to picomite. stick to teraterm?
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3348
Posted: 08:49pm 06 Aug 2022
Copy link to clipboard 
Print this post

If you are connected to the serial port in Teraterm, you may not be able to access it from MMEdit. Try closing Teraterm before trying MMEdit.

From what TassyJim had said earlier, you had been accessing his online MMBasic device. Could you still be connected to that?

~
Edited 2022-08-07 06:52 by lizby
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6268
Posted: 09:01pm 06 Aug 2022
Copy link to clipboard 
Print this post

Yes.
He trying to use my test "micromite without any display"
Different device, different configuration.

"Just because you have a black cat it doesn't mean all cats are black!"

Jim
Don't worry, you are not he first person who has tried to run non-existent LCd's on the test server
Edited 2022-08-07 07:04 by TassyJim
VK7JH
MMedit
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10198
Posted: 09:21pm 06 Aug 2022
Copy link to clipboard 
Print this post

  Quote  There is something else you are doing and/or not aware of.


 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1128
Posted: 09:30pm 06 Aug 2022
Copy link to clipboard 
Print this post

Here's a different way about it, if the SD card is configured and working:
' Requires "glyphs.bmp" to be saved on SD card in active directory
OPTION BASE 0        ' 0 based arrays
OPTION DEFAULT INTEGER

cls
blit load 1,"glyphs.bmp", 0,0,16,16   ' alien 1
blit load 2,"glyphs.bmp",16,0,16,16   ' alien 2
blit load 3,"glyphs.bmp",32,0,12,10   ' cannon
blit load 4,"glyphs.bmp",44,0, 2, 8   ' missile

cx = 100 : cy = 150 : blit write 3,cx,cy
cdx = 1   ' cannon motion
ax =  20 : ay =  15 : aa = 1 : blit write aa,ax,ay
adx! = 1.1 : ady! = 1.9   ' alien motion

settick 500,animate,1

do
 box cx,cy,16,16,0,0,0   ' erase cannon at old position
 cx = cx + cdx   ' move cannon
 blit write 3,cx,cy  ' draw cannon at new location
 if cx > 200 or cx < 50 then cdx = -cdx  ' change direction
 
 box ax,ay,16,16,0,0,0   ' erase alien at old position
 ax = ax + adx! : ay = ay + ady!   ' move alien
 blit write aa,ax,ay     ' draw alien at new location
 if ax > 220 or ax < 10 then adx! = -adx!
 if ay > 132 or ay < 10 then ady! = -ady!
 
 pause 10   ' wait a bit
loop

' change alien animation frame
sub animate
 aa = 1 + (aa=1)   ' toggle alien animation frame
end sub

end

Here is the required image file. Unzip the "glyphs.bmp" file to an SD card where you can see it with the FILES command.

I created the BMP file using a CMM2 by drawing the 4 sprites packed together and saving the resulting image. The four "blit load" commands extract exactly the correct region of this graphic file, also known as a "sprite sheet." A better method of generating the sprite sheet would be to use something like "paint.net" on a PC to make the BMP file.
Visit Vegipete's *Mite Library for cool programs.
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2527
Posted: 12:03am 07 Aug 2022
Copy link to clipboard 
Print this post

I noticed chat- vegipete in mmedit but not a clue. I spent a while typing code into teraterm and F1 to save but where it went ? can't get it back, teraterm is imho terrible to use. I can't use it for writing a program. Could I use notepad++ or geany as an editor cos mmedit is not working?
I have a feeling it doesn't work with rpi 2040 as a system. Attempts at pasting code to teraterm result in duplicates and missing code, it's terrible to use.
It's annoying that I can't see why my code doesn't work and nobody can point out why.
Is it that rpi pico and mmbasic is buggy? It's not a "mite" yet.
If I could use an editor in win and save/run the files to the rpi pico via teraterm if that's the way. no way I could live with teraterm for coding.
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2527
Posted: 12:13am 07 Aug 2022
Copy link to clipboard 
Print this post

@vegipete - interesting code
how to copy and paste it?
would box be a fast way of erasing?
nice the blit can be a bmp on sd card, could it be loaded/read from data?
where's a bmp editor when you need one.
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3348
Posted: 12:51am 07 Aug 2022
Copy link to clipboard 
Print this post

  stanleyella said  teraterm is imho terrible to use. I can't use it for writing a program. Could I use notepad++ or geany as an editor cos mmedit is not working?


It's not that MMEdit is not working, it's that it's not connected to your PicoMite but to TassyJim's online MMBasic device which doesn't have an LCD.

TeraTerm is a terminal, not an editor. You could use it to type into the MMBasic editor, but has has been said previously, it's best used with an editor such as Notepad++ or Geany. Then you copy your code, press F10 (Autosave) in Teraterm and paste in your code and terminate it with Ctrl+z. Then you can RUN or EDIT. Or if you have and SD card working, SAVE it.

  Quote  I have a feeling it doesn't work with rpi 2040 as a system.


You're as wrong as can be. You haven't learned how to use it yet. (Though I myself prefer Notepad++ and TeraTerm).

  Quote  Attempts at pasting code to teraterm result in duplicates and missing code, it's terrible to use.


You're not doing it in the way that has been suggested.

  Quote  It's annoying that I can't see why my code doesn't work and nobody can point out why.


Everyone posting here has been telling you why what you are doing isn't working for you. You don't appear to either read the manual or what people have posted.

  Quote  Is it that rpi pico and mmbasic is buggy? It's not a "mite" yet.


It's not that MMBasic on the Pico is buggy. One of the most important things for a programmer to learn is that if something goes wrong and you can't figure out why, it's probably an error on your part. For beginners, it's probably ten thousand to one that it's the programmer's fault. Maybe if you're quite experienced it's down to one thousand to one (speaking of a programming language which is pretty well developed).

  Quote  If I could use an editor in win and save/run the files to the rpi pico via teraterm if that's the way. no way I could live with teraterm for coding.


You can do that as explained above and as previously explained. I don't even know what you mean when you speak of "teraterm for coding".
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6268
Posted: 04:10am 07 Aug 2022
Copy link to clipboard 
Print this post

One last try.

The best feature of the maximie family is the built-in editor. It is rare to be ably to program on the device.
But if you prefer to edit on the PC:
Make sure Teraterm is not running.
In MMEdit menu
Select 'Connect - New'
In the pop up window, select 'serial port'
'find port'
a list of currently available com ports will appear.
select your picomite (which was com13 at one stage)
select a baud rate in the right hand pull-down box.
115200 is a good choice but it doesn't matter for the picomite.

Click on OK
Click on save
Your window title bar should now show the com port and baud rate.

On the advanced menu, make sure a tick is beside "auto run on load"
Now if you press the right hand button (run and go) and you have done every thing right,
You program will be uploaded to the picomite and run after loading.

Now the bad news.

MMEdit will open a terminal for you to use
It's a crap terminal but you don't seem interested on using MMEdit V5 which has a much better terminal. Still not as good as Teraterm.
You can't get away from terminals.
VK7JH
MMedit
 
     Page 7 of 16    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025