Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 10:45 24 Nov 2024 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 : Picomite colourbars test card

Author Message
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6096
Posted: 05:21am 24 Sep 2024
Copy link to clipboard 
Print this post

This is a modification of a test card program I wrote for the cMM@ a few years ago,
It should run on a picoVGA as well as picoHDMI bit I have only tested on the HDMI.
Widescreen mode is OK.

 ' test card for Picomite VGA and HDMI
 ' TassyJim September 2024
 
 OPTION EXPLICIT
 OPTION DEFAULT NONE
 DIM INTEGER wd, ht, wbox, sh, x, w, n, nn, m, mp, cd, maxMode, keepMode, widesc, mk
 DIM FLOAT a, defaultMode
 DIM k$, imgtitle$, fname$, imgRes$, pages$
 DIM INTEGER c(8)
 c(0) = RGB(BLACK)
 c(1) = RGB(YELLOW)
 c(2) = RGB(CYAN)
 c(3) = RGB(GREEN)
 c(4) = RGB(MAGENTA)
 c(5) = RGB(RED)
 c(6) = RGB(BLUE)
 c(7) = RGB(WHITE)
 c(8) = RGB(64,64,64)
 IF INSTR(MM.DEVICE$,"HDMI") THEN
 maxMode = 5
 ELSE
 maxmode = 3
 ENDIF
 IF MM.VRES/MM.HRES = 0.75 THEN
     widesc = 0
     ELSE
     widesc = 1
     ENDIF
 a = 1
 defaultMode = 3
 CLS
 
 DO
   IF m = 0 THEN
     MODE 1
     CLS
     TEXT 320,100, "Video mode test",cm,5,1
     TEXT 320,180, "Ratio = aspect ratio used in the circle command",cm,1,1
     TEXT 320,220, "Q to quit, P to save page as a BMP",cm,3,1
     TEXT 320,260, "Up Down arrow to change resolution",cm,2,1
     TEXT 320,300, "+ - to change circle aspect ratio",cm,2,1
     
   ELSE
     
     IF keepmode THEN  ' only change resolution if needed
       keepmode = 0
     ELSE
       CLS             ' erase video memory before mode change
       ON ERROR SKIP
       MODE m
       CLS
     ENDIF
     
     wd = MM.HRES : ht = MM.VRES
     nn = INT(wd/80)
     imgtitle$ =" MODE "+STR$(M)+" Ratio "+STR$(a,1,3)+" "
     imgRes$ = " "+STR$(MM.HRES)+" x "+STR$(MM.VRES)+" "
     pages$ = " "'Maximum page number = "+STR$(mp)+" "
     wbox = wd / 8
     
     ' primary colours
     FOR x = 0 TO 7
       BOX x*wbox,ht/4,wbox,ht/2,0,c(x), c(x)
     NEXT x
     ' full gradient for each primary colour and greyscale
     FOR x = 0 TO wd-1
       sh = 255*x/wd
       
       LINE x,0,x,ht/12,1,RGB(sh,0,0)
       LINE x,ht/12,x,ht/6,1,RGB(0,sh,0)
       LINE x,ht/6,x,ht/4,1,RGB(0,0,sh)
       
       LINE x,ht*9/12,x,ht*10/12,1,RGB(0,sh,sh)
       LINE x,ht*10/12,x,ht*11/12,1,RGB(sh,0,sh)
       LINE x,ht*11/12,x,ht,1,RGB(sh,sh,0)
       
       LINE x,ht/2,x,ht*3/4,1,RGB(sh,sh,sh) ' greyscale
     NEXT x
     ' circle to check aspect ratio
     CIRCLE wd/2,ht/2, ht*15/32,3,a,c(7)
     sh = 0
     x = wd/2 - 55*nn/2
     ' black white bars to check monitor bandwidth
     FOR w = 10 TO 1 STEP -1
       FOR n = 1 TO nn
         sh = 255 - sh
         LINE x,ht*3/8,x,ht*5/8,w,RGB(sh,sh,sh)
         x = x + w
       NEXT n
     NEXT w
     ' white and red border to check that image fits on monitor
     BOX 0,0,wd,ht,3,c(7)
     BOX 1,1,wd-2,ht-2,1,c(5)
     ' title
     IF wd > 600 THEN
       TEXT wd/2,ht/2-15, imgtitle$,cm,4,1
       TEXT wd/2,ht/2, pages$,cm,4,1
       TEXT wd/2,ht/2+15, imgRes$,cm,4,1
     ELSE
       TEXT wd/2,ht/2-11, imgtitle$,cm,1,1
       TEXT wd/2,ht/2, pages$,cm,1,1
       TEXT wd/2,ht/2+11, imgRes$,cm,1,1
     ENDIF
     
   ENDIF
   PAUSE 100
   ' wait for keypress
   DO
     k$ = INKEY$
   LOOP UNTIL k$<>""
   '
   SELECT CASE k$
     CASE "Q","q"
       EXIT DO
     CASE "P","p"
       fname$ = MID$(imgtitle$,2)+".bmp"
       TIMER = 0
       SAVE IMAGE fname$
      ' PAGE WRITE 0
       TEXT wd/2,ht/2,"Saved as "+fname$+" in "+STR$(TIMER/1000,3,2)+" Sec" ,cm,1,1
       DO
         k$ = INKEY$
       LOOP UNTIL k$<>""
     CASE CHR$(128) ' up arrow
       m = m - 1
       IF m < 1 THEN m = maxMode
       IF m = 4 AND widesc THEN m = 3
     CASE CHR$(129) ' down arrow
       m = m + 1
       IF m > maxMode THEN m = 1
       IF m = 4 AND widesc THEN m = 5
     CASE "+" ' ratio plus
       IF a < 1.4 THEN a = a + 0.01
       keepmode = 1
     CASE "-" ' ratio minus
       IF a > 0.75 THEN a = a - 0.01
       keepmode = 1
     CASE ELSE ' same as down arrow
       m = m + 1
       IF m > maxMode THEN m = 1
   END SELECT
 LOOP
 MODE defaultMode ' restore original mode before ending program
 CLS
 
END







Jim
Edited 2024-09-24 16:02 by TassyJim
VK7JH
MMedit   MMBasic Help
 
Plasmamac

Guru

Joined: 31/01/2019
Location: Germany
Posts: 554
Posted: 06:10am 24 Sep 2024
Copy link to clipboard 
Print this post

thx Jim
Plasma
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4222
Posted: 06:20am 24 Sep 2024
Copy link to clipboard 
Print this post

HI Jim,

On VGA (with hardware color palette) it will look completely different.
The greyscale is not a scale. RP2350 and RP2040 are the same on VGA.

Volhout
Edited 2024-09-24 16:20 by Volhout
PicomiteVGA PETSCII ROBOTS
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6096
Posted: 04:10am 01 Oct 2024
Copy link to clipboard 
Print this post

Updated to handle the new modes and added a staircase to better understand some instability I can see in some modes.

 ' test card for Picomite VGA and HDMI
 ' TassyJim September 2024
 
 OPTION EXPLICIT
 OPTION DEFAULT NONE
 DIM INTEGER wd, ht, wbox, sh, x, w, n, nn, m, mp, cd, maxMode, keepMode, widesc, mk
 DIM FLOAT a, defaultMode
 DIM k$, imgtitle$, fname$, imgRes$, pages$
 DIM INTEGER c(8)
 c(0) = RGB(BLACK)
 c(1) = RGB(YELLOW)
 c(2) = RGB(CYAN)
 c(3) = RGB(GREEN)
 c(4) = RGB(MAGENTA)
 c(5) = RGB(RED)
 c(6) = RGB(BLUE)
 c(7) = RGB(WHITE)
 c(8) = RGB(64,64,64)
 IF INSTR(MM.DEVICE$,"HDMI") THEN
 maxMode = 5
 ELSE
 maxmode = 3
 ENDIF
 IF MM.VRES MOD 240 = 0 AND MM.VRES <> 720 THEN
     widesc = 0
     ELSE
     widesc = 1
     ENDIF
 a = 1
 defaultMode = 3
 CLS
 
 DO
   IF m = 0 THEN
     MODE 1
     CLS
     TEXT 320,100, "Video mode test",cm,5,1
     TEXT 320,180, "Ratio = aspect ratio used in the circle command",cm,1,1
     TEXT 320,220, "Q to quit, P to save page as a BMP",cm,3,1
     TEXT 320,260, "Up Down arrow to change resolution",cm,2,1
     TEXT 320,300, "+ - to change circle aspect ratio",cm,2,1
     
   ELSE
     
     IF keepmode THEN  ' only change resolution if needed
       keepmode = 0
     ELSE
       CLS             ' erase video memory before mode change
       ON ERROR SKIP
       MODE m
       CLS
     ENDIF
     
     wd = MM.HRES : ht = MM.VRES
     nn = INT(wd/80)
     imgtitle$ =" MODE "+STR$(M)+" Ratio "+STR$(a,1,3)+" "
     imgRes$ = " "+STR$(MM.HRES)+" x "+STR$(MM.VRES)+" "
     pages$ = " "'Maximum page number = "+STR$(mp)+" "
     wbox = wd / 8
     
     ' primary colours
     FOR x = 0 TO 7
       BOX x*wbox,ht/4,wbox,ht/2,0,c(x), c(x)
     NEXT x
     ' full gradient for each primary colour and greyscale
     FOR x = 0 TO wd-1
       sh = 255*x/wd
       
       LINE x,0,x,ht/12,1,RGB(sh,0,0)
       LINE x,ht/12,x,ht/6,1,RGB(0,sh,0)
       LINE x,ht/6,x,ht/4,1,RGB(0,0,sh)
       
       LINE x,ht*9/12,x,ht*10/12,1,RGB(0,sh,sh)
       LINE x,ht*10/12,x,ht*11/12,1,RGB(sh,0,sh)
       LINE x,ht*11/12,x,ht,1,RGB(sh,sh,0)
       
       LINE x,ht/2,x,ht*3/4,1,RGB(sh,sh,sh) ' greyscale
     NEXT x
     ' circle to check aspect ratio
     CIRCLE wd/2,ht/2, ht*15/32,3,a,c(7)
     sh = 0
     x = wd/2 - 55*nn/2
     ' black white bars to check monitor bandwidth
     FOR w = 10 TO 1 STEP -1
       FOR n = 1 TO nn
         sh = 255 - sh
         LINE x,ht*3/8,x,ht*5/8,w,RGB(sh,sh,sh)
         x = x + w
       NEXT n
     NEXT w
     ' horisontal lines to check for raster stability
     x = wd/2 - 50*nn/2
     sh = ht*5/8-5
     BOX x,sh,50*nn,5*nn+4,1,RGB(BLACK),RGB(BLACK)
     sh = sh + 2
     FOR n = x TO wd/2 + 50*nn/2 - 10 STEP 10
     LINE n,sh,n+9,sh,1,RGB(WHITE)
     sh = sh + 1
     NEXT n
     
     ' white and red border to check that image fits on monitor
     BOX 0,0,wd,ht,3,c(7)
     BOX 1,1,wd-2,ht-2,1,c(5)
     ' title
     IF wd > 600 THEN
       TEXT wd/2,ht/2-15, imgtitle$,cm,4,1
       TEXT wd/2,ht/2, pages$,cm,4,1
       TEXT wd/2,ht/2+15, imgRes$,cm,4,1
     ELSE
       TEXT wd/2,ht/2-11, imgtitle$,cm,1,1
       TEXT wd/2,ht/2, pages$,cm,1,1
       TEXT wd/2,ht/2+11, imgRes$,cm,1,1
     ENDIF
     
   ENDIF
   PAUSE 100
   ' wait for keypress
   DO
     k$ = INKEY$
   LOOP UNTIL k$<>""
   '
   SELECT CASE k$
     CASE "Q","q"
       EXIT DO
     CASE "P","p"
       fname$ = MID$(imgtitle$,2)+".bmp"
       TIMER = 0
       SAVE IMAGE fname$
      ' PAGE WRITE 0
       TEXT wd/2,ht/2,"Saved as "+fname$+" in "+STR$(TIMER/1000,3,2)+" Sec" ,cm,1,1
       DO
         k$ = INKEY$
       LOOP UNTIL k$<>""
     CASE CHR$(128) ' up arrow
       m = m - 1
       IF m < 1 THEN m = maxMode
       IF m = 4 AND widesc THEN m = 3
     CASE CHR$(129) ' down arrow
       m = m + 1
       IF m > maxMode THEN m = 1
       IF m = 4 AND widesc THEN m = 5
     CASE "+" ' ratio plus
       IF a < 1.4 THEN a = a + 0.01
       keepmode = 1
     CASE "-" ' ratio minus
       IF a > 0.75 THEN a = a - 0.01
       keepmode = 1
     CASE ELSE ' same as down arrow
       m = m + 1
       IF m > maxMode THEN m = 1
       IF m = 4 AND widesc THEN m = 5
   END SELECT
 LOOP
 MODE defaultMode ' restore original mode before ending program
 CLS
 
END


VK7JH
MMedit   MMBasic Help
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6096
Posted: 01:17am 02 Oct 2024
Copy link to clipboard 
Print this post

  Quote  TassyJim,

I have flashed Version 6.00.00RC3 PicoMiteRP2350HDMI in the RPI2 and I am working with the Olimex board. Operation via Tera Term which is also displayed on an HDMI screen. Further OPTION RESET OLIMEX selected.
Played around with your test image program. I have 1 HDMI monitor and a TV with HDMI.
I have to manually set my HDMI monitor to 4:3 mode to get a round circle. The TV automatically switches to 4:3 mode because others do not provide support, but automatically a nice circle.
Arrow Up = Space. All screens work correctly in 4:3 mode and mode 1 to 5 work correctly and no distorted image.
+ and - option doesn't work yet or I don't understand?
Saving a .bmp file also works well, but is a bit large.

153718 MODE 1 Ratio 1,000 .bmp
038518 MODE 2 Ratio 1.010 .bmp
153718 MODE 3 Ratio 1,000 .bmp
230454 MODE 4 Ratio 1,000 .bmp
230454 MODE 5 Ratio 1,000 .bmp

Jan.

Replied here to keep the firmware thread clear.

If your circles are not round, use + and - to stretch/shrink the circle until it looks right. Then, in your programs the circle command has a parameter for aspect ratio:
  Quote  The optional 'a' is a floating point number which will define the
aspect ratio. If the aspect is not specified the default is 1.0 which gives a
standard circle.


The size of the BMP files is due to the number of pixels for each resolution.
BMP is the only format available.

Jim
VK7JH
MMedit   MMBasic Help
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024