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 demo on the Waveshare RP2040-LCD-1.28
Page 1 of 2 | |||||
Author | Message | ||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 9128 |
https://www.youtube.com/watch?v=flaFdoR4pJo The PicoMite supports the SSD1963 displays but these are now expensive and use nearly all the I/O pins. However, there are lots of SPI displays available. These have two downsides. First: they are comparatively slow as they rely on serial data transmission. Second: many of them don't support reading the controllers framebuffer and even those that do are even slower in read mode than in write mode. I therefore decided to add some extra functionality to get round this. The limitation is that the memory in the RP2040 isn't nearly big enough to hold a complete framebuffer for even a 240x240 display like the Waveshare RP2040-LCD-1.28 in its normal resolution (RGB565 = 2 bytes per pixel). So I have used some of the code from the PicoMiteVGA to create a memory framebuffer at RGB121 like the PicoMiteVGA. This allows me to create two memory framebuffers and still have plenty of space for variables. The demo uses this new functionality to create an artefact free moving display. I'll post the new firmware once a bit of tidying has been completed Option explicit Option default none ' Const Y_top = 0 'Y coordinate of top of the image file on the screen Const X_left = 0 'X coordinate of left of the image file on the screen Const s_Y_point = 172 'Y coordinate of the centre of the second hand relative to the image top Const s_X_point = 119 'X coordinate of the centre of the second hand relative to the image left Const h_Y_point = 119 'Y coordinate of the centre of the hour and minute hands relative to the image top Const h_X_point = 120 'X coordinate of the centre of the hour and minute hands relative to the image top Const sl=-30 Const ml=-100 Const hl=-75 ' ' ' ' Now we define the pointers as the X,Y coordinates of a number of triangles with the rotation point at 0,0 ' It is simplest to define this in the 12-oclock position which means the Y-coordinates at the top of the pointer will be negative ' The order of data elements in the array is: ' t1x1,t1y1,t1x2,t1y2,t1x3,t1y3, t2x1,t2y1,t2x2,t2y2,t2x3,t2y3,...tntx1,tnty1,tntx2,tnty2,tntx3,tnty3 ' Dim integer nt=6 'Number of triangles used to define the pointer Dim integer x1(nt-1)=(-1,-1,-2,-2,-3,-3) Dim integer y1(nt-1)=(0,0,0,0,0,0) Dim integer x2(nt-1)=(-1,1,-2,2,-3,3) Dim integer y2(nt-1)=(sl,sl,ml,ml,hl,hl) Dim integer x3(nt-1)=(1,1,2,2,3,3) Dim integer y3(nt-1)=(sl,0,ml,0,hl,0) Dim INTEGER pcolour=RGB(Green) 'define the colour of the pointer Const s_pivot=3, m_pivot=5, h_pivot=3 'diameter in pixels of the fulcrum of the pointer ' Dim integer xx0(nt-1),yy0(nt-1),xx1(nt-1),yy1(nt-1),xx2(nt-1),yy2(nt-1),tcol(nt-1) Dim integer first=1 'marker to control alternate processing on first time through the loop ' FRAMEBUFFER create FRAMEBUFFER layer FRAMEBUFFER write l CLS Load image "face" ' ' demo code moving the pointer Dim float secondangle=0, minuteangle=0, hourangle=0 Do FRAMEBUFFER copy l,f If secondangle Mod 60=0 Then Inc minuteangle,1 If (minuteangle Mod 72=0) And (secondangle Mod 60=0) Then Inc hourangle,6 drawpointer FRAMEBUFFER copy f,n Inc secondangle,6 Loop ' Sub drawpointer Local integer i,x,y Local float angle For i=0 To nt-1 If i<2 Then x=s_X_point y=s_Y_point pcolour=RGB(green) angle=secondangle Else x=h_X_point y=h_Y_point pcolour=RGB(white) If i<4 Then angle=minuteangle Else angle=hourangle EndIf EndIf rotatetriangle(i,pcolour,angle,x+X_left,y+Y_top,x1(i),y1(i),x2(i),y2(i),x3(i),y3(i)) 'rotate the pointer into the drawing array Next i FRAMEBUFFER write f Triangle xx0(), yy0(), xx1(), yy1(), xx2(), yy2(),tcol(),tcol() drawpivot End Sub Sub rotatetriangle(n As integer, col As integer, angle As float, x As integer, y As integer, x0 As integer, y0 As integer, x1 As in teger, y1 As integer, x2 As integer, y2 As integer) Local float sine=Sin(Rad(angle)),cosine=Cos(Rad(angle)) Local integer x0a,y0a,x1a,y1a,x2a,y2a x0a= x0*cosine - y0 * sine + x y0a= y0*cosine + x0 * sine + y x1a= x1*cosine - y1 * sine + x y1a= y1*cosine + x1 * sine + y x2a= x2*cosine - y2 * sine + x y2a= y2*cosine + x2 * sine + y xx0(n)=x0a yy0(n)=y0a xx1(n)=x1a yy1(n)=y1a xx2(n)=x2a yy2(n)=y2a tcol(n)=pcolour End Sub ' Sub drawpivot() 'put anything you like here to draw the fulcrum as you wish Circle s_X_point+X_left,s_Y_point+Y_top,s_pivot,0,,,RGB(green) Circle h_X_point+X_left,h_Y_point+Y_top,m_pivot,0,,,RGB(white) Circle h_X_point+X_left,h_Y_point+Y_top,h_pivot,0,,,RGB(black) End Sub Edited 2023-01-01 22:19 by matherp |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 4043 |
Great ... I think ... in theory useful for my Bintendo ;-) Is this a balancing act between when it is faster to write to and blit the entire buffer vs. when when it is faster to perform the individual drawing instructions "directly" on the display ... or do I misunderstand how these SPI displays work ? Thanks, Tom Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 9128 |
Not really The big issue with all these displays is "undrawing" something. Consider the demo but without the framebuffers Think of the hands of the clock. To move the second hand I need to: 1: restore the background that was under it 2: save the background where I am now going to draw it 3: draw the hand in the new position All this takes time and the result is that the hand flickers from one location to the next. This is improved if the background is a flat colour as I can miss step 2 but I still get flicker It can be improved again if I can time the moves with the displays raster but his is impossible on many displays (anything without a working MISO, and even with difficult) such as the demo display. The framebuffer solves this as I can assemble the image in a framebuffer where all these moves are invisible and then just paint the completed image (COPY) or the part that has changed (BLIT) to the actual display. Copying framebuffer to framebuffer takes less than a millisecond. Copying the complete image to the display in the demo takes 50mSec @ default CPU speed and 46 @ 378MHz |
||||
Tinine Guru Joined: 30/03/2016 Location: United KingdomPosts: 1646 |
Very cool Pete I have one of these and really like it. To be clear; does this mean I can throw a bmp on the display in 50ms? Craig |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 9128 |
Yes if you load it to a framebuffer first and accept the lower colour depth |
||||
Tinine Guru Joined: 30/03/2016 Location: United KingdomPosts: 1646 |
Oh hell yeah |
||||
Frank N. Furter Guru Joined: 28/05/2012 Location: GermanyPosts: 831 |
Hi! Can anyone tell me what firmware I need for this display? I just ordered a display like this. Frank |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6798 |
You need a non-VGA version of the PicoMite firmware. The driver is built into that. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
Frank N. Furter Guru Joined: 28/05/2012 Location: GermanyPosts: 831 |
Hi Mick, THANKS!!! Frank |
||||
Frank N. Furter Guru Joined: 28/05/2012 Location: GermanyPosts: 831 |
Hi! Can someone send me a test image for the display? All the pictures I have tried so far have wrong colors. @Peter: Can you maybe upload me the image from your sample program ("face")? THANKS! Frank |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6798 |
Try doing CLS RGB(RED), CLS RGB(GREEN) and CLS RGB(BLUE) to give you an idea if the video connections are correct. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
Frank N. Furter Guru Joined: 28/05/2012 Location: GermanyPosts: 831 |
What are these commands supposed to do? If I change pcolour=RGB(green) in "Sub drawpointer" to red or blue, the pointer appears in the correct colors. Frank |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6798 |
Sorry, I have no sample pictures as such. If using a graphic display (not the console) CLS clears the screen. CLS RGB(RED) will make it all red etc. I'm trying not to involve the program, just do it from the command line. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
Frank N. Furter Guru Joined: 28/05/2012 Location: GermanyPosts: 831 |
Hmm, the commands were accepted, but the display did not change, i.e. the pointers were still visible unchanged and the background remained black...(I tried the commands in the Console). I think that maybe the color format of my pictures just doesn't fit - but I can't find anything about it in the manual. Frank |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6798 |
Try For i=48 To 55 For j=48 To 55 Â Print Chr$(27);"[3"+Chr$(i)+";"+"4"+Chr$(j)+"mABCDEFGH"; Next Next Print Chr$(27);"[37;40m" ' clear to white on black Vertical bars should be in the order Black, Red, Green, Yellow,Blue,Magenta,Cyan,White Edited 2023-04-19 17:39 by Mixtel90 Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
Frank N. Furter Guru Joined: 28/05/2012 Location: GermanyPosts: 831 |
Hi Mick, with your program the display just stays dark... Frank |
||||
lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
Peter Any chance of a copy of the "face" image? |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 9128 |
face.zip |
||||
Frank N. Furter Guru Joined: 28/05/2012 Location: GermanyPosts: 831 |
Peter, thank you very much!!! |
||||
lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
Really stupid question (possibly) but HOW do you load an image to the Picomite if you don't have an SD card attached? Only the usb cable to the computer I've been through the manual and all I can see is loading it from the SD card or xmodem send but it seems to only send to/from an sdcard I need to send this file to the picomite C:\Users\Lewis\Desktop\face.bmp How can I do it? I use MMEdit5 but I also have putty, terra term and so on |
||||
Page 1 of 2 |
Print this page |