|
Forum Index : Microcontroller and PC projects : Pi-cromite Version 5.04.16
| Author | Message | ||||
| matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 10572 |
Please find attached V5.04.16 for Stretch 2018-01-12_224620_mmbasicstretch.zip and for Jessie 2018-01-12_224632_mmbasicjessie.zip Manual 2018-01-13_192334_Pi-cromite_Manual.pdf This fixes a bug in the PEEK command and also implements the USER display driver capability of Geoff's version 5.4.09. In addition it includes a new font #7 which is a small 6x8 font ideal for smaller displays. NB the Pi-cromite does not support loadable fonts. This is a huge advantage on the Pi-cromite where we can't have CFunctions. MMBasic is very fast on the Pi-cromite and drivers in Basic perform well The picture shows an ST7920 based 128x64 display (QC12864B) being driven by a SPI user driver on a Pi Zero-W. The code is attached below and will also work unchanged on any of the Micromites (other than adjusting the pin numbers) userdisplayinit Line 0,0,MM.HRes-1,MM.VRes-1 Line MM.HRes-1,0,0,MM.VRes-1 Box 0,0,MM.HRes,MM.VRes Text MM.HRes/2,MM.VRes/2,"Hello World",CM End ' Sub userdisplayinit Option explicit Option default none On error skip 'if OPTION is already set then ignore the error Option LCDPANEL USER, 128,64 On error skip 'don't error if Global variables not yet defined Erase S$(), tmaskarray(), bmaskarray(), LCD_RESET, LCD_CD, LCD_CMD, LCD_DATA Dim S$(MM.VRes-1) length MM.HRes\4 Dim integer tmaskarray(3)=(240,112,48,16) Dim integer bmaskarray(3)=(128,192,224,240) Dim INTEGER LCD_RESET=22 ' pin for chip select Dim INTEGER LCD_CD=24 ' pin for Reset Dim INTEGER LCD_CMD=&B11111000 Dim INTEGER LCD_DATA=&B11111010 Local i% On error skip 'don't error if SPI already open SPI open 100000,3,8 Pin(LCD_RESET)=1 Pin(LCD_CD)=1 SetPin LCD_RESET,dout SetPin LCD_CD,dout Pin(LCD_RESET)=0 Pause 200 Pin(LCD_RESET)=1 Pause 200 Pin(LCD_CD)=1 ' continuous enable for the moment LCD.CMD(1) 'DISPLAY CLEAR LCD.CMD(&B00001100) 'display on LCD.CMD(1) 'DISPLAY CLEAR LCD.CMD(&B00100110) 'graphic mode For i% = 0 To MM.VRes-1 s$(i%)=String$(MM.HRes\4,Chr$(&H0)) Next i% update 0, 0, ((MM.HRes-1)\16), MM.VRes-1 End Sub ' Sub MM.USER_RECTANGLE(x1%, y1%, x2%, y2%, fcol%) If x1%=0 And y1%=0 And x2%=MM.HRes-1 And y2%=MM.VRes-1 Then Local b$, i% If fcol% Then b$=String$(MM.HRes\4,Chr$(&HF0)) Else b$=String$(MM.HRes\4,Chr$(0)) EndIf For i% = 0 To MM.VRes-1 s$(i%)=b$ Next i% Else Local integer i, j, k, l, t, left_x,right_x, mask,emask Local b$ 'print "userrectangle ", x1%, y1%, x2%, y2%, fcol% If x2% <= x1% Then t = x1% x1% = x2% x2% = t EndIf If y2% <= y1% Then t = y1% y1% = y2% y2% = t EndIf If x1% < 0 Then x1% = 0 If x1% >= MM.HRes Then x1% = MM.HRes - 1 If x2% < 0 Then x2% = 0 If x2% >= MM.HRes Then x2% = MM.HRes - 1 If y1% < 0 Then y1% = 0 If y1% >= MM.VRes Then y1% = MM.VRes - 1 If y2% < 0 Then y2% = 0 If y2% >= MM.VRes Then y2% = MM.VRes - 1 left_x=x1%\4 right_x=x2%\4 If left_x=right_x Then If (fcol%) Then mask =(tmaskarray(x1% Mod 4) And bmaskarray(x2% Mod 4)) Else mask = notmask%(tmaskarray(x1% Mod 4) And bmaskarray(x2% Mod 4)) EndIf For t=y1% To y2% l= Peek(var S$(t),left_x+1) If (fcol%) Then l=l Or mask Else l=l And mask EndIf Poke var S$(t),left_x+1, l Next t Else If (fcol%) Then mask =tmaskarray(x1% Mod 4) emask=bmaskarray(x2% Mod 4) Else mask = notmask%(tmaskarray(x1% Mod 4)) emask= notmask%(bmaskarray(x2% Mod 4)) EndIf For t=y1% To y2% If fcol% Then l=Peek(var S$(t),left_x+1) l=l Or mask Poke var S$(t),left_x+1, l l=Peek(var S$(t),right_x+1) l=l Or emask Poke var S$(t),right_x+1, l Else l=Peek(var S$(t),left_x+1) l=l And mask Poke var S$(t),left_x+1, l l=Peek(var S$(t),right_x+1) l=l And emask Poke var S$(t),right_x+1, l EndIf Next t If left_x+1<=right_x-1 Then If fcol% Then b$=String$(right_x-left_x-1, Chr$(240)) Else b$=String$(right_x-left_x-1, Chr$(0)) EndIf For t=y1% To y2% s$(t)=Left$(s$(t),left_x+1)+b$+Right$(s$(t),32-right_x) Next t EndIf EndIf EndIf update x1%\16, y1%, x2%\16, y2% End Sub ' ' Sub MM.USER_BITMAP(x1%, y1%, width%, height%, scale%, fcol%, bcol%, bitmap%)'bitmap is in string bitmap$ ' print "userbitmap ", x1%, y1%, width%, height%, scale%, fcol%, bcol% Local INTEGER i, j, k, mask, m, l, ll, t, tt, vCd, hCd, x, y, a%=height% * width%, ln%, c2%, c3%, c4% vCd = y1% If y1% < 0 Then y1% = 0 ' the y coord is above the top of the screen For i = 0 To height%-1 ' step thru the font scan line by line ln%=i * width% For j = 0 To scale%-1 ' repeat lines to scale the font vCd=vCd+1 If vCd >= 0 Then ' we are above the top of the screen y=vCd - 1 If vCd > MM.VRes Then GoTo D_UP ' we have extended beyond the bottom of the screen hCd = x1% For k = 0 To width%-1 ' step through each bit in a scan line c2%=ln% + k c4%=(a% - c2% - 1) Mod 8 t=Peek(BYTE bitmap% + c2%\8) tt = (t >> c4%) And 1 'we now know if the pixel is on or off For m = 0 To scale% -1 ' repeat pixels to scale in the x axis hCd = hCd +1' we have not reached the left margin If hCd >= 0 Then If hCd <= MM.HRes Then ' check are we beyond the right margin x=hCd -1 mask=1<<(7-(x Mod 4)) c3%=notmask%(mask) ll= Peek(var S$(y),x\4+1) If tt Then If fcol% Then ll = ll Or mask Else ll = ll And c3% EndIf Else If bcol%<>-1 Then 'transparent text If bcol% Then ll = ll Or mask Else ll = ll And c3% EndIf EndIf EndIf Poke var S$(y), x\4+1, ll EndIf EndIf Next m Next k EndIf Next j Next i D_UP: update x1%\16, y1%, x\16, y End Sub ' Sub LCD.CMD(databyte As integer) Local integer i,J SPI write 3,LCD_CMD, DATABYTE And &HF0, (DATABYTE And &H0F)<<4 Pause 2 End Sub ' Sub SetXY(x As integer, y As integer) Local integer xx=x<<4,yy=y If yy>31 Then xx=xx+128 yy=yy-32 EndIf SPI write 5, LCD_CMD, (yy And &H10) Or &H80, yy<<4, &H80, xx Pause 1 End Sub ' Sub update(x1%, y1%, x2%, y2%) Local b$, i% Pin(LCD_CD)=1 ' enable For i% = y1% To y2% If i%<MM.VRes Then SetXY(x1%,i%) b$=Chr$(LCD_DATA)+Mid$(s$(i%),x1%*4 +1, (x2%-x1%+1)*4) SPI WRITE Len(b$),b$ EndIf Next i% Pin(LCD_CD)=0 ' disable End Sub ' Function notmask%(x%) notmask% = (-1 Xor x%) And &HFF End Function |
||||
| Micro-80 Newbie Joined: 03/03/2017 Location: Russian FederationPosts: 26 |
The manual says that there are two serial ports COM1 and COM2. COM2 on the 7-Tx and 11-Rx pins. Can I reassign COM2Rx to a different PIN? The project needs COM2, and pin 11 is occupied by HAT. |
||||
| vegipete Guru Joined: 29/01/2013 Location: CanadaPosts: 1146 |
In your sample code, you have the following: Line 0,0,MM.HRes-1,MM.VRes-1 <skip> Box 0,0,MM.HRes,MM.VRes It appears the bottom right corner of the screen is in different places for the Line and Box commands. Why is that? Visit Vegipete's *Mite Library for cool programs. |
||||
| matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 10572 |
Check the MM+ manual line x1,y1,x2,y2 box x,y,w,h At the moment this is hardwired. I'll look at it in a future release |
||||
| Micro-80 Newbie Joined: 03/03/2017 Location: Russian FederationPosts: 26 |
Thank you Peter! |
||||
| lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
Peter I've been reading the manual as well as all the pages I can find about using a Pi on here I only have 1 question (at the moment) IF I wanted to make an interface board for an SDD1963 I know you've put the pin numbers in the manual but it doesn't say if you can use the SD card on there that I can see Can you? and if you can is there specific pin numbers to use? Or am I going stupid and you actually just use the SPI pins? (I know nothing about how SD cards work in reading/writing yet but I plan on learning) By the way, Amazing work, it's prompted me to buy a Raspberry Pi Zero W today/ EDIT: Can you use the SD card on the Pi to store pictures to be used with Pi-cromite? And Can you use touch if you use a HDMI display with touch built in? |
||||
| matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 10572 |
No, you just use the SDcard that is on the Pi Yes No |
||||
| lizby Guru Joined: 17/05/2016 Location: United StatesPosts: 3469 |
As of now, the link in the manual (v5.4.16) for installing pigpio software version 64 is timing out: http://abyz.co.uk/rpi/pigpio/download.html I've just loaded the latest raspbian stretch lite and I think the latest mmbasic (11/17). How do I install the right version of pigpio? Never mind. I found it here: http://abyz.me.uk/rpi/pigpio/download.html PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed |
||||
| disco4now Guru Joined: 18/12/2014 Location: AustraliaPosts: 1044 |
Last time I installed Raspbian it was already included. You can check with the command below to see if its already installed pigpiod -v Not sure if you have seen this one. This thread has latest versions of MMBasic for Pi F4 H7FotSF4xGT |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |