Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 22:59 28 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: Lcdpanel USER / Virtual_M with WaveShare Clock - Help

Author Message
mozzie
Regular Member

Joined: 15/06/2020
Location: Australia
Posts: 68
Posted: 10:01am 12 May 2023
Copy link to clipboard 
Print this post

G'day All,

Purchased this (see below) from Waveshare to tinker with, turns out you need to multiplex the led displays from the Picomite so its been a fun exercise to get it to work smoothly with both the multiplexing and dimming together.

As part of this, I looked at using both the framebuffer (option LCDPANEL virtual_m) and user (option LCDPANEL user) options, the framebuffer method is currently working by finding it in memory and reading it into an array every second to update the display. This is a work in motion but the code below is a start.

Does anyone know if the pointer to the framebuffer is visible to MMbasic?

The LCDPANEL USER option has been a non-starter, I think I am trying to use it incorrectly and there is very little mention of it on the forum, are mmbasic lcd drivers implemented on the PicoMite?

So far have tried every combination of OPTION LCDPANEL USER, X, Y / OPTION LCDPANEL USER X, Y I can think of with no joy, this is on a fresh install of 5.07.07 with no other option set. It exists in the source code but my understanding of C is limited, hence the love of MMBasic.  

I have a couple of other displays with odd driver chips to tinker with so any help with this would be appreciated.




' program for WaveShare Clock v2.10
' LR 10/05/23
' Still much to do...

Option default integer
Option explicit

SetPin gp8,gp11,gp10,spi2
SPI2 open 5000000,0,16

Pin(gp16)=0:SetPin gp16,dout
Pin(gp18)=0:SetPin gp18,dout
Pin(gp22)=0:SetPin gp22,dout
Pin(gp12)=0:SetPin gp12,dout
SetPin gp13,pwm6b:PWM 6,500,,-1
SetPin gp15,din,pullup
SetPin gp17,din,pullup
SetPin gp2,din,pullup

Dim rwc,lcnt,ccnt,tcnt,indx,vdow,bklt = 1
Dim outval1(7),outval2(7)
Dim outtmp1,outtmp2
Dim oldtime$ length 10
Dim cntr=0,indm=0,rslt=0,addr=0

findbuff                            ' dodgy find framebuffer
'Print Hex$(addr)
cntr = 0
chkbuff(0)                          ' is framebuffer found 0
chkbuff(&hffffffff)                 ' is framebuffer found 1
'Print cntr                         ' 0 if framebuffer found

SetTick 2,screenupdate,1            ' 2ms multiplex update
CLS

Do
 If Time$ <> oldtime$ Then         ' do we need to update time?
   If Pin(gp15)=0 Or Pin(gp2)=0 Then BkltUpdate
   If Pin(gp17)=1 Then
     TimeUpdate : Buffupdate
     Else : Swearing : Buffupdate  ' future alarm messages....
   EndIf
 EndIf
Loop While Inkey$ = ""

SPI2 write 2,&h00,&h00
Pin(gp12)=1:Pin(gp12)=0
End

Sub TimeUpdate                      ' update time to F-buffer
 Text 0,0,"      ",,7,1,0
 Text 4,0,Mid$(Time$,1,1),,10,1,1
 Text 8,0,Mid$(Time$,2,1),,10,1,1
 If Val(Mid$(Time$,8,1)) Mod 2 Then Text 11,0,":",,10,1,1
 Text 14,0,Mid$(Time$,4,1),,10,1,1
 Text 18,0,Mid$(Time$,5,1),,10,1,1
End Sub

Sub ShowDate
 Text 0,0,"      ",,7,1,0          ' update date to F-buffer
 Text 3,1,Mid$(Date$,1,2),,10,1,1
 Text 10,0,Mid$(Date$,4,2),,10,1,1
 Text 17,-1,Mid$(Date$,9,2),,10,1,1
End Sub

Sub Swearing                        ' future alarm messages
 Select Case Val(Mid$(Time$,8,1))
 Case 1,2: Text 3,0,"OH sh*t",,10,1,1
 Case 3,4: Text 3,0,"UR LAZY",,10,1,1
 Case 5,6: Text 3,0,"UR LATE",,10,1,1
 Case Else : Showdate
 End Select
End Sub

Sub BuffUpdate                      ' move F-buffer to S-buffer
 RTC getreg &h03,vdow
 If vdow = 7 Then vdow = 0
 Line 0,0,32,0,1,0
 Line 3+(vdow*3),0,4+(vdow*3),0,1,1
 For lcnt = 0 To 7
   indx = addr + (lcnt * &h50)
   outtmp1 = Peek(short indx)
   outtmp2 = Peek(short indx+2)
   BitOrderReverse(outtmp1,16,outval1(lcnt)
   BitOrderReverse(outtmp2,16,outval2(lcnt)
 Next
 oldtime$ = Time$
End Sub

Sub screenupdate                    ' S-buffer to display row 0-7
 SPI2 write 2,outval1(rwc),outval2(rwc)
 Poke word &h4001406c,&h304        ' override PWM disable display
 Port(gp16,1,gp18,1,gp22,1)=rwc    ' Set display row
 Pin(gp12)=1:Pin(gp12)=0           ' Latch display data
 Poke word &h4001406c,&h04         ' re-enable PWM
 Inc rwc                           ' inc row counter
 rwc = rwc And &h07                ' limit 0-7 (overflow?)
End Sub

Sub BkltUpdate                      ' PWM brightness control
 If Pin(gp2) = 0 Then bklt = bklt << 1
 If Pin(gp15) = 0 Then bklt = bklt >> 1
 If bklt = 0 Then bklt = 1
 If bklt > 100 Then bklt = 96
 PWM 6,500,,0 - bklt
End Sub

Sub Findbuff                        ' look for Framebuffer
 CLS 1
 indm = 0:cntr = 0:addr = &h20020000
 Do
   rslt = Peek(word addr+indm)
   indm = indm + &h100
   If rslt = &hffffffff Then : Inc cntr
   Else : cntr = 0
   EndIf
   If cntr = &h10 Then addr = &h20020000 + (indm - &h1000)
 Loop Until indm > &hffff Or addr > &h20020000
End Sub

Sub Chkbuff(chkv)                   ' confirm Framebuffer
 CLS Choice(chkv = 0,0,1)
 For indm = 0 To &h95B0 Step &h50
   rslt = Peek(word addr+indm)
   If rslt <> chkv Then Inc cntr
 Next
End Sub

CSub BitOrderReverse                ' pinched from BSF
 00000000
 2300B5F0 46DE4657 4645464E 00104684 B5E02200 60436002 684A680B B085469A
 DD672A00 681B4663 46992400 685B4663 46982500 91022301 21209003 00274249
 D43D1866 40B10019 001E468B 40A64649 400E4640 40014659 D037430E 37014652
 22201BD7 18BA4252 0019D43E 91014091 40BA001A 92009803 68476806 9A019900
 41571876 60476006 26019902 2700680A 20024692 2100684A 416F1936 414D1824
 DC2B4295 4661D031 00346809 46614689 003D6849 21204688 00274249 D5C11866
 1B0E2120 40F10019 E7BE468B 27002601 21002002 416F1936 414D1824 DC0D4295
 0034D016 E7A8003D 00192220 40D11BD2 E7BD9101 D1012A00 D1932B00 BCF0B005
 46B246BB 46A046A9 4554BDF0 E7F5D9CB D9E64554 46C0E7F2
End CSUB

DefineFont #10
 2B300803 0178DB03 9F03B864 78960338 03C8BB00 4F0378CE 90920378 0378DF03
 200058DE 00000080 00000000 00000000 10CC0300 01000000 5D03E85B 50590170
 03705B03 CD0338CD 58590120 0168DF02 93039024 A8E90250 02384902 DF0268FF
 505B01E8 0120DF03 5D03D85B 70C40168 0290A403 DB0278DB F8DF0250 0268D502
 C40390DE 00000078
End DefineFont


Regards,
Lyle.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9131
Posted: 11:22am 12 May 2023
Copy link to clipboard 
Print this post

mm.info(writebuf) will return the address of the buffer currently being used for graphics output

so

FRAMEBUFFER CREATE
FRAMEBUFFER WRITE F
add% = MM.INFO(WRITEBUFF)

should do what you want
 
mozzie
Regular Member

Joined: 15/06/2020
Location: Australia
Posts: 68
Posted: 06:45am 13 May 2023
Copy link to clipboard 
Print this post

Thanks Peter, that will be far more reliable  

I just looked into the PicomiteVGA manual and there it is   does MM_Misc.c contain them all?

Can you add any further to the support of MMbasic user LCD routines on the Picomite?

My thanks again to the work you have put in to the Picomite, a look through the source code has been a real eye opener to what goes on behind MMbasic, even if most of it is way over my head  

Regards,
Lyle.
Edited 2023-05-13 20:02 by mozzie
 
Print this page


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

© JAQ Software 2024