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 : PicoMiteHDMI: Color Cycle Animation
Page 1 of 2 | |||||
Author | Message | ||||
Martin H. Guru Joined: 04/06/2022 Location: GermanyPosts: 1113 |
Animation using MAP Command 'HDMI only MODE 2:CLS Dim integer col(15):Restore colors:For f=1 To 15:Read col(f):Next Dim integer mp(15,3) Map reset:Map set For CL=0 To 15 x=20*CL Box x,0,20,128,,col(cl),col(cl) For n=0 To 127 Step 2 If cl Then For c=0 To 9 Step 2 Pixel x+c+10,n,col(cl+(CL<15)) Pixel x+c+11,n+1,col(cl+(CL<15)) Next End If If cl<15 Then Circle 40,180,40-(cl*2),,,col(15-cl),Col(15-cl) Circle 280,180,40-(cl*2),,,col(15-cl),Col(15-cl) End If Circle 160,180,40-(cl*2),,,col(cl),Col(cl) Next Next Print @(96,130); "Mode 2 color cycling" Do For r=0 To 255 Step 8 For g=0 To 255 Step 8 For b=0 To 255 Step 8 For n=1 To 14 mp(n,0)=mp(n+1,0) mp(n,1)=mp(n+1,1) mp(n,2)=mp(n+1,2) Map(n)=RGB(mp(n,0),mp(n,1),mp(n,2)) Next Map(15)=RGB(r,g,b) mp(15,0)=r:mp(15,1)=g:mp(15,2)=b Map set 'Pause 10 FRAMEBUFFER wait Next Next Next Loop colors: '--Colorscheme accordung to Screencolors Data RGB(BLUE),RGB(MYRTLE),RGB(COBALT) ,RGB(MIDGREEN),RGB(CERULEAN) Data RGB(GREEN),RGB(CYAN),RGB(RED) Data RGB(MAGENTA),RGB(RUST),RGB(FUCHSIA),RGB(BROWN),RGB(LILAC) Data RGB(YELLOW),RGB(WHITE) Edited 2024-10-17 01:12 by Martin H. 'no comment |
||||
stanleyella Guru Joined: 25/06/2022 Location: United KingdomPosts: 2118 |
impressive. is it 256 shades of grey? |
||||
Martin H. Guru Joined: 04/06/2022 Location: GermanyPosts: 1113 |
no just Mode 2 ,so just 16 Colors at once .. It just counts through all possible RGB values and change the “MAP” entry accordingly Edited 2024-10-17 02:55 by Martin H. 'no comment |
||||
stanleyella Guru Joined: 25/06/2022 Location: United KingdomPosts: 2118 |
er , it was a joke , 50 shades of grey, never seen it. mode 2 hdmi vs mode 2 vga. vga can run mode 2 faster, pico 2350 usb |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 9104 |
VGA only has 16 fixed colours HDMI mode 2 (or 3) has any 16 out of 32768 as in the animation HDMI mode 4 can show all 32768 colours at the same time HDMI mode 5 can show any 256 out of 32768 at the same time Edited 2024-10-17 03:33 by matherp |
||||
stanleyella Guru Joined: 25/06/2022 Location: United KingdomPosts: 2118 |
I think it's brill. using optimex 2350 hdmi. testing existing code 2040 vga. this vga example to test mode 2 hdmi and not the same, slower and sprite colours wrong. try this code on vga and hdmi to see. 'vga 320x240 mode 2 sprites mode 2 OPTION BASE 0 ' 0 based arrays option DEFAULT INTEGER OPTION EXPLICIT dim dx(15),dy(15),spx(15),spy(15) dim cannon(119),missile(15),oldspx(15),oldspy(15) dim ptr,hiscore,spw,spht,temp,frame,frame_count,spdata,sp1 hiscore=0 'colour shortcuts const WH =RGB(255, 255, 255) 'WHITE const YE =RGB(255, 255, 0) 'YELLOW const LI =RGB(255, 128, 255) 'LILAC const BR =RGB(255, 128, 0) 'BROWN const FU =RGB(255, 64, 255) 'FUCHSIA const RU =RGB(255, 64, 0) 'RUST const MA =RGB(255, 0, 255) 'MAGENTA const RE =RGB(255, 0, 0) 'RED const CY =RGB(0, 255, 255) 'CYAN const GR =RGB(0, 255, 0) 'GREEN const CE =RGB(0, 128, 255) 'CERULEAN const MI =RGB(0, 128, 0) 'MIDGREEN const CO =RGB(0, 64, 255) 'COBALT const MY =RGB(0, 64, 0) 'MYRTLE const BL =RGB(0, 0, 255) 'BLUE const Bk =RGB(0, 0, 0) 'BLACK const Gy =RGB(128, 128, 128) 'GREY const Lg =RGB(210, 210, 210) 'LITEGREY const Og =RGB(255, 165, 0) 'ORANGE const PK =RGB(255, 160, 171) 'PINK const Gd =RGB(255, 215, 0) 'GOLD const SA =RGB(250, 128, 114) 'SALMON const BE =RGB(245, 245, 220) 'BEIGE ' cls restore sprite1 udg1 'draws sprite1 on screen at 10,10 sprite READ 1,10,10,16,16 'reads sprite1 from screen to blit buffer1 restore sprite2 udg1 'draws sprite2 on screen at 10,10 sprite read 2,10,10,16,16 'reads sprite2 from screen to blit buffer2 ' for temp=0 to 15 'set up start sprite positions and directions spx(temp)=(mm.hres /2)-32+int(rnd*64) spy(temp)=(mm.vres /2)-20+int(rnd*40) do :dx(temp)=int(rnd*5)-int(rnd*9):loop until dx(temp)<>0 do :dy(temp)=int(rnd*5)-int(rnd*9):loop until dy(temp)<>0 next temp ' FRAMEBUFFER CREATE F FRAMEBUFFER WRITE f do 'demo moving sprite cls RGB(black) for temp=0 to 15 ' if sprite_status(temp)=1 then 'is sprite active if spx(temp)> mm.hres-32 then 'check right edge dx(temp)= 0-dx(temp) elseif spx(temp)<16 then 'check left edge dx(temp)= 0-dx(temp) end if if spy(temp)>mm.vres-32 then 'check bottom edge dy(temp)= 0-dy(temp) elseif spy(temp)<16 then 'check top edge dy(temp)= 0-dy(temp) end if ' spx(temp)=spx(temp)+dx(temp):spy(temp)=spy(temp)+dy(temp) 'get new position for draw ' if frame=0 then'which sprite to draw sprite WRITE 1,spx(temp),spy(temp) 'draw sprite1 at new position else sprite WRITE 2,spx(temp),spy(temp) 'draw sprite2 at new position end if next temp FRAMEBUFFER COPY f,N ' frame_count=frame_count+1 'when to change sprite if frame_count=10 then frame=not frame frame_count=0 end if pause 50 loop ' sub udg1 'draws 16x16 data for blit to copy for spht=0 to 15 for spw=0 to 15 read sp1 pixel spw+10,spht+10,sp1 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,fu,fu,fu,fu,ye,bk,bk,bk 'missile data wh,wh,re,re,ye,ye,wh,wh,wh,wh,ye,ye,re,re,wh,wh |
||||
Martin H. Guru Joined: 04/06/2022 Location: GermanyPosts: 1113 |
Stan, Since the values of the colors are hardwired on PicomiteVGA, it is of course not possible to create other colors via software. In my setups I don't have much difference with the RGB 121 colors between Micomite VGA and DVI/HDMI. The VGA colors can vary a little depending on the setup, as the resistors also have a tolerance and the AD-Converter in monitors also can “interpret” this differently. DVI/HDMI send the color values digitally to the monitor, which then displays the colors. Here, of course, we have the option of adding more simultaneous colors, but this would mean that much more Screenmemory would be required for the image. The generation via the MAP command is a compromise, similar to the Atari ST LOW-RES mode. No extra memory is required for the screen, but the data in there are only pointers to a color palette. Here you have the choice of many more colors (RGB555) but only 16 at a time. My animation takes advantage of this by generating the image only once, but then changing the color palette again and again. That wouldn't work on the PicomiteVGA. Edited 2024-10-17 06:12 by Martin H. 'no comment |
||||
stanleyella Guru Joined: 25/06/2022 Location: United KingdomPosts: 2118 |
yes, I got vga is 16 colours, plenty. In the case of VGA, the hardware is limited to the 16 colours defined by the resistor network. In the case of HDMI each of the 16 colours can be mapped to any RGB555 colour. Use MAP GREYSCALE to have 16 shades of grey from black to white available. I don't understand rgb555 colour... or the other rgb modes. vga seemed easier if the 16 colours can be defined with RGB(255, 64, 255) https://www.thebackshed.com/forum/ViewTopic.php?TID=17173&P=8#225819 |
||||
stanleyella Guru Joined: 25/06/2022 Location: United KingdomPosts: 2118 |
and map works vga 'map swithing demo Dim integer cmap(13) 'Clear the screen MODE 2 Map reset CLS rgb(black) 'Set up colours in the array cmap(1)=RGB(white) cmap(2)=RGB(black) cmap(3)=RGB(black) cmap(4)=RGB(black) cmap(5)=RGB(black) cmap(6)=RGB(black) cmap(7)=RGB(white) cmap(8)=RGB(black) cmap(9)=RGB(black) cmap(10)=RGB(black) cmap(11)=RGB(black) cmap(12)=RGB(black) ' Do an initial update of the Colour map to set up our colours domap hline=76:hy=1:mch=1 line 0,75,319,75,,RGB(white) do'draw horizontal lines line 0,hline,319,hline,,map(mch) inc mch:if mch=7 then mch=1 hline=hline+hy:hy=hy+0.6 loop until hline>240 xb=-149:xt=10:mch=7 do'draw vertical lines line xb,239,xt,75,,map(mch) inc mch:if mch=13 then mch=7 xb=xb+8:xt=xt+4 loop until xb>=479 ' lr=0 do cmap(0)=cmap(6) For i=5 To 0 Step -1' move horizontal lines cmap(i+1)=cmap(i) Next if lr<40 then cmap(6)=cmap(12) For i=11 To 6 Step -1' move vertical lines cmap(i+1)=cmap(i) Next else cmap(12)=cmap(7) For i=7 To 12' move vertical lines cmap(i)=cmap(i+1) Next end if inc lr:if lr>80 then lr=0 domap pause 100 loop end Sub domap Local integer i Map (0)=RGB(black) For i=1 To 12 Map (i)=cmap(i) Next Map set End Sub |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6776 |
RGBxyz refers to the number of bits available for each colour. So, for example, RGB222 would have 2 bits each for red, green and blue. That would give you off+3 brightness levels for each colour because 2 bits counts up 0-1-2-3. RGB555 gives you 5 bits for each colour. That's off+31 brightness levels for each. If you multiply the possibilities that gives you the total number of colours you can get: RGB222 = 4 x 4 x 4 = 64 colours RGB121 (our standard "VGA" Mode 2) = 2 x 4 x 2 = 16 colours RGB555 = 32 x 32 x 32 = 32768 colours Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
stanleyella Guru Joined: 25/06/2022 Location: United KingdomPosts: 2118 |
box don't fill.thought I had box fill sorted mode 2 OPTION EXPLICIT OPTION DEFAULT NONE dim r%,g%,b%,count1% mode 2:cls rgb(black) for count1%=0 to 255 r%=count1% box 100,100,60,60,1,rgb(r%,g%,b%),rgb(r%,g%,b%) pause 100 next |
||||
stanleyella Guru Joined: 25/06/2022 Location: United KingdomPosts: 2118 |
hdmi on olimex. for beginner, nice. thanks to matherp for making possible and know there's other designs but £17 total ,postage and tax is good if you ever wired pico and sd card reader and audio filter and 3.5 jack and vga socket. olimex is so easy to use 2350 and hdmi. ready made alternatives? ebay? |
||||
phil99 Guru Joined: 11/02/2018 Location: AustraliaPosts: 2135 |
Box fill works on PicoMiteVGA MMBasic RP2350A Edition V6.00.00RC8 Dim r%,g%,b%,count1% MODE 2:CLS RGB(black) For r%=0 To 255 Step 255 For g%=0 To 255 Step 64 For b%=0 To 255 Step 255 Box 100,100,60,60,1,RGB(r%,g%,b%),RGB(r%,g%,b%) Pause 1000 Next Next Next Edited 2024-10-17 08:30 by phil99 |
||||
stanleyella Guru Joined: 25/06/2022 Location: United KingdomPosts: 2118 |
Dim r%,g%,b%,count1% MODE 2:CLS RGB(black) For r%=0 To 255 Step 255 For g%=0 To 255 Step 64 For b%=0 To 255 Step 255 Box 100,100,60,60,1,RGB(r%,g%,b%),RGB(r%,g%,b%) Pause 1000 Next Next Next er? not hdmi Edited 2024-10-17 08:55 by stanleyella |
||||
phil99 Guru Joined: 11/02/2018 Location: AustraliaPosts: 2135 |
The point is the Box command is exactly the same as in your program and it works. The box is filled with the same colour as its border. |
||||
JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 3800 |
Dim r%,g%,b%,count1% MODE 2:CLS RGB(black) For r%=0 To 255 Step 255 For g%=0 To 255 Step 64 For b%=0 To 255 Step 255 Box 100,100,60,60,1,RGB(r%,g%,b%),RGB(r%,g%,b%) Pause 1000 Next Next Next er? not hdmi Are you saying that with the right firmware correctly installed that Box does not fill with HDMI? I am (very) doubtful that you'd be right if so but be sure to report the version and Options with a short test program. John |
||||
stanleyella Guru Joined: 25/06/2022 Location: United KingdomPosts: 2118 |
dim r%,g%,b%,count1% mode 2:cls rgb(black) for count1%=0 to 255 b%=count1% text 0,0,str$(count1%) box 100,100,60,60,1,rgb(white),rgb(r%,g%,b%) pause 1000 next red box at 128 green box at 64 and lite green box at 128 blue box at 128 same as vga mode2 but hdmi mode 2 |
||||
phil99 Guru Joined: 11/02/2018 Location: AustraliaPosts: 2135 |
That is how it is meant to be, except when g%=count% it is:- dark green box at 64, mid green at 128 and light green box at 192, though the visible difference between mid and bright green is small. The reason for that is the colour scale is in linear steps but our vision is logarithmic. It's 4 bit colour RGB121, Blue and Red are 1 bit each so any value up to 127 = &B0 = off and 128 to 255 = &B1 = on. Green has 2 bits so:- 0 to 63 = &B00 = off 64 to 127 = &B01 = dark green 128 to 191 = &B10 = mid green 192 to 255 = &B11 = bright green |
||||
stanleyella Guru Joined: 25/06/2022 Location: United KingdomPosts: 2118 |
hdmi mode 5 is more like 3 blue,7 green,7 red same code. getting the drift now.. I think. thanks, stan |
||||
phil99 Guru Joined: 11/02/2018 Location: AustraliaPosts: 2135 |
If you want to know exactly how many colour steps there are in each mode this colour counter will do the job. 'A Display colour counter MODE 2 '<-----------------Select the mode to test CLS RGB(white) : Option Base 0 Dim String S$(2) = (" Blues", " Greens", " Reds") Dim Integer a, b, c, d For a = 0 To 2 'cycle through blue , green and red b = 0 'initialize colour count For c = 0 To 255 'set the brightness d = c << (a * 8) 'make a 24bit colour Line c, 1+a*9, c, 9+a*9, 1, d 'send it to a line ' Pixel c, 9+a*9, d 'send it to a pixel If d = Pixel(c, 9+a*9) Then 'read that pixel back from the screen Inc b 'if the colour is the same as the one sent count it EndIf Next Print b; S$(a) 'show counted colours Next End Edited 2024-10-18 10:59 by phil99 |
||||
Page 1 of 2 |
Print this page |