Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 21:43 01 May 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 : MM2: Text overlayed on graphics

Author Message
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8591
Posted: 03:53am 05 Oct 2015
Copy link to clipboard 
Print this post

In a thread ages ago someone asked if it was possible to display text without the character background overwriting the existing display - it is now



This builds on the sprite code and uses the same technique of reading the SSD1963 display memory and then writing it back with only the text pixels updated and the background pixels left as-is.

In this case the read of the display is built into the loadable driver code and is triggered by setting the background colour to the value 1. This is chosen as a non-useful colour i.e. a blue so dark it is completely indistinguishable from black.

To use this facility it is necessary to connect the RD pin on the display to the Micromite. The loadable driver will then automatically set this as an output. If the RD pin allocation is omitted in the call to display.open then the driver will work as before and a backgound colour of 1 will be a very dark blue.

At the moment the code will only run on a 44-pin Micromite uM2 using the special loadable SSD1963 driver included in the example code and it needs the pinout set as below:
you must use pins 25,26,27,36,37,38,2,3 for the data pins DB0-DB7
you must use pin 4 for RS and pin 5 for WR
Tie CS Low
connect RD to an unused Micromite output and set the pin number in MM.STARTUP
connect RST to an unused Micromite output and set the pin number in MM.STARTUP

Note that I am using a PWM output to control the display backlight - this is specific to my test system and you probably won't need it.

I will write a version for the MM+ once I have a suitable test system available.

There is one "feature" related to the way Geoff has implemented the space character as a rectangle in the backgound colour rather than as an actual character - unfortunately a space will always overwrite the display in the background colour. The workround is to output multiple strings rather than a single string with spaces.

Also note that the CFunction allocates temporary memory to store the existing display pixels. If you are using a very large scaled font or your program is using most of the Micromite RAM you may see an "out of memory error" when using the overlayed font mode.

My test program is:


option explicit
option default none
'
' Demonstration of using overlayed text
' To specify that text should be overlayed set the background colour to 1
'
dim integer t,x,y,r,c
colour rgb(white),1 'background colour set to 1 to use overlay mode
PWM 1,1000,50 ' turn on the backlight control
cls
if (MM.HRes > MM.VRes) then : t=MM.HRes \7 : else : t=MM.VRES\7: endif
do while(1) 'fill the screen with random circles
x=cint(rnd() * mm.HRes)
y=cint(rnd() * mm.VRes)
r=cint(rnd() * t + t\5)
c=rgb(cint(rnd() *255), cint(rnd() * 255), cint(rnd() * 255))
Circle x,y,r,,,&HFFFFFF,c
text mm.hres\2,mm.vres\2,"Hello-World",CM,,4
loop

end

'
sub mm.startup
CPU 48
DIM integer RDpin=24,RESETPin=42
Display.Open(RESETpin,3,4.3,RDpin) 'reset on pin 42, landscape, 4.3" display, RD pin on 24
PWM 1,1000,50
end sub

'**********Append this code and below onto the end of your MMBasic program***********
'
' Author: Peter Mather 2015
'
' Initialise the Display Driver for SSD1963 controlled TFT LCD Panel in 8-bit databus, 24-bit mode
' i.e. RGB888. This is optimised for the 44-pin uM2 and uses defined pinout except for the reset pin
' It achieves performance approaching that of the uM+ by heavily optimising bus I/O
'
' Display.Open initialises the loadable CFunction driver so that you can use all of the
' MMBasic graphic commands in your program.
'
' RST% is pin number of Reset signal
' Orient% PORTRAIT=0,RPORTRAIT=1,LANDSCAPE=2,RLANDSCAPE=3
' Size% is display size in Inches eg 4 inch, 5 etc
'
' After Calling Display.Open, any of the usual MM Graphic commands may be used
' in your MMBasic program, eg BOX, TEXT, LINE, CIRCLE etc
'
' Note: you must use pins 25,26,27,36,37,38,2,3 for the data pins DB0-DB7
' you must use pin 4 for RS and pin 5 for WR
' Tie CS Low
' Select convenient pins for RESET and RD
'
' You can omit the RD pin in the call to Display.Open, in this case you cannot use the overlayed text capability
'
' Ver 2.00 2015-10-05 Initial Release
'
'**********************************************************************************

sub Display.Open(RST%,Orient%,Size!,RD%) as integer

LOCAL CFuncAddr%
LOCAL Retrn%


CFuncAddr%=PEEK(CFUNADDR SSD1963_V44)

Retrn% = SSD1963_V44(CFuncAddr%,RST%,RD%,Orient%,cint(size!) )

END SUB
'
' File SSD1963_V44.bas written 15-Sep-2015 11:56:02
'
CFunction SSD1963_V44
0000001C
'write_command_data
27BDFFF8 AFA60010 AFA70014 27A20010 AFA20000 308400FF 34840200 3C02BF88
AC446230 24030200 AC436234 AC436238 18A0000D 8FA40000 00001821 24060200
24870004 AFA70000 80840000 34840300 AC446230 AC466234 AC466238 24630001
1465FFF7 8FA40000 03E00008 27BD0008
'main
27BDFF98 AFBF0064 AFB50060 AFB4005C AFB30058 AFB20054 AFB10050 AFB0004C
0080A021 3C029D00 8C430090 8CA40000 A064002E 8C430090 8CC40000 A064002D
8C430090 8CE40000 A0640015 8C420090 8FA30078 8C630000 A0430014 24020019
AFA20028 2402001A AFA2002C 2402001B AFA20030 24020024 AFA20034 24020025
AFA20038 24020026 AFA2003C 24020002 AFA20040 24020003 AFA20044 27B20028
27B30048 3C109D00 8E510000 8E020010 02202021 24050008 0040F809 00003021
8E020010 02202021 24050065 0040F809 00003021 8E02001C 02202021 0040F809
24050005 26520004 5653FFF0 8E510000 3C109D00 8E020010 24040004 24050008
0040F809 00003021 8E020010 24040004 24050065 0040F809 00003021 3C11BF88
24020100 AE226238 8E020010 24040005 24050008 0040F809 00003021 8E020010
24040005 24050065 0040F809 00003021 24020200 AE226238 8E030090 8E020010
8064002E 24050008 0040F809 00003021 8E030090 8E020010 8064002E 24050065
0040F809 00003021 8E020090 8044002D 5080000C 3C109D00 8E020010 24050008
0040F809 00003021 8E030090 8E020010 8064002D 24050065 0040F809 00003021
3C109D00 8E030090 8E02001C 8064002E 0040F809 24050006 8E020090 8044002D
10800006 3C029D00 3C029D00 8C42001C 0040F809 24050006 3C029D00 24420070
3C159D00 26B50A34 02A2182B 10600004 02A2A823 8E830000 10000003 02A3A821
8E830000 02A3A821 3C119D00 26310C00 0222182B 10600004 02228823 8E830000
10000003 02238821 8E830000 02238821 3C029D00 8C430090 80620014 28420005
24040110 241301E0 0082980B 240401E0 24120320 0082900B 3C109D00 8E02001C
8064002E 0040F809 24050006 8E020004 0040F809 24042710 8E030090 8E02001C
8064002E 0040F809 24050005 8E020004 0040F809 24042710 8E030090 8E02001C
8064002E 0040F809 24050006 8E020004 0040F809 24042710 8E020090 80420014
28430005 1060000B 28420006 24020054 AFA20010 240400E2 24050003 24060023
24070002 0411FF22 00000000 10000015 240400E0 1040000B 24020004 24020054
AFA20010 240400E2 24050003 2406001E 24070002 0411FF16 00000000 10000009
240400E0 AFA20010 240400E2 24050003 24060023 24070002 0411FF0D 00000000
240400E0 24050001 24060001 0411FF08 00000000 3C109D00 8E020004 0040F809
24042710 240400E0 24050001 24060003 0411FEFF 00000000 8E020004 0040F809
24042710 24040001 00002821 0411FEF8 00000000 8E020004 3C040001 0040F809
348486A0 8E020090 80420014 28430005 10600035 28420006 240200FF AFA20010
240400E6 24050003 24060001 2407001F 0411FEE7 00000000 24020001 AFA20010
240300DF AFA30014 AFA20018 2402000F AFA2001C AFA00020 240400B0 24050007
24060020 00003821 0411FED9 00000000 AFA00010 24020008 AFA20014 2402002B
AFA20018 AFA0001C 24100002 AFB00020 AFA00024 240400B4 24050008 24060002
24070013 0411FECA 00000000 AFA00010 24020004 AFA20014 2402000C AFA20018
AFA0001C AFB00020 240400B6 24050007 24060001 24070020 0411FEBD 00000000
1000004F 240400BA 1040001A 240200E0 240200FF AFA20010 240400E6 24050003
24060003 240700FF 0411FEB1 00000000 24020003 AFA20010 2402001F AFA20014
24020001 AFA20018 240200DF AFA2001C AFA00020 240400B0 24050007 24060024
00003821 0411FEA2 00000000 10000018 AFA00010 AFA20010 240400E6 24050003
24060004 24070093 0411FE99 00000000 24020003 AFA20010 2402001F AFA20014
24020001 AFA20018 240200DF AFA2001C AFA00020 240400B0 24050007 00003021
00003821 0411FE8A 00000000 AFA00010 2402002E AFA20014 24020030 AFA20018
AFA0001C 2402000F AFA20020 AFA00024 240400B4 24050008 24060003 240700A0
0411FE7B 00000000 AFA00010 24020010 AFA20014 AFA20018 AFA0001C 24020008
AFA20020 240400B6 24050007 24060002 2407000D 0411FE6E 00000000 240400BA
24050001 2406000F 0411FE69 00000000 240400B8 24050002 24060007 24070001
0411FE63 00000000 24040036 24050001 00003021 0411FE5E 00000000 240400F0
24050001 00003021 0411FE59 00000000 2404003A 24050001 24060070 0411FE54
00000000 24040026 24050001 24060001 0411FE4F 00000000 3C109D00 8E020004
0040F809 24042710 24040029 00002821 0411FE47 00000000 24020001 AFA20010
240200F0 AFA20014 AFA00018 AFA0001C 240400BE 24050006 24060006 240700F0
0411FE3B 00000000 240400D0 24050001 2406000D 0411FE36 00000000 8E030090
80620015 24040002 14440008 24040004 80660014 28C60006 240400E0 240500A0
00A6200B 1000000A 00803021 14440008 240600A0 80660014 28C60006 24040020
24050060 00A6200B 1000000A 00803021 24040001 14440008 24040003 80660014
28C60006 24020040 0006100B 1000000A 00403021 24040003 14440008 24040036
80660014 28C60006 240200C0 24030080 0066100A 00403021 24040036 24050001
0411FE0B 00000000 3C029D00 8C420090 90420015 30420001 10400006 3C029D00
8C430094 AC720000 8C420098 10000005 AC530000 8C430098 AC720000 8C420094
AC530000 3C029D00 8C430048 AC750000 8C43004C AC710000 8C430048 8C440094
8C860000 8C420098 8C470000 AFA00010 8C620000 00002021 00002821 24C6FFFF
0040F809 24E7FFFF 00001021 00001821 8FBF0064 8FB50060 8FB4005C 8FB30058
8FB20054 8FB10050 8FB0004C 03E00008 27BD0068
'defineregion
2482FFFF 00463021 24A2FFFF 00471021 3C089D00 8D090094 8D230000 8D080098
8D080000 0103482B 11200003 01006021 00606021 01001821 3C089D00 8D0D0090
81A80015 24090001 1509000C 24070002 00805021 00C04821 81A30014 28630007
14600023 00A05821 00063027 00042027 008C4821 1000001E 00CC5021 15070008
24070003 00A05021 00404821 00063027 00C35821 00041027 10000015 00431021
1507000E 00021027 00C04821 00435821 00051027 00431021 81A30014 28630007
1060000B 00805021 00063027 00042027 008C4821 10000006 00CC5021 004C5021
00052827 00AC4821 00805821 00C01021 3C03BF88 2404022A AC646230 24080200
AC686234 AC686238 000A2202 34840300 AC646230 AC686234 AC686238 354A0300
AC6A6230 AC686234 AC686238 00092202 34840300 AC646230 AC686234 AC686238
35290300 AC696230 AC686234 AC686238 2404022B AC646230 AC686234 AC686238
000B2202 34840300 AC646230 AC686234 AC686238 356B0300 AC6B6230 AC686234
AC686238 00022202 34840300 AC646230 AC686234 AC686238 34420300 AC626230
AC686234 AC686238 03E00008 00000000
'DrawRectangle_SSD1963
27BDFFE0 AFBF001C AFB10018 AFB00014 0086102A 14400004 8FB00030 00801021
00C02021 00403021 00A7102A 14400005 28820000 00A01021 00E02821 00403821
28820000 0002200B 3C029D00 8C420094 8C430000 0083402B 2462FFFF 0048200A
28C20000 0002300B 00C3102B 2463FFFF 0062300A 28A20000 0002280B 3C029D00
8C420098 8C430000 00A3402B 2462FFFF 0048280A 28E20000 0002380B 00E01021
00E3382B 2463FFFF 0067100A 24070001 00E41823 00663021 00E53823 00E23821
70E68802 0411FF62 00000000 3C02BF88 2403022C AC436230 24030200 AC436234
AC436238 7E053C00 34A50300 7E063A00 321000FF 36100300 10B00005 34C60300
1620001E 2624FFFF 1000002C 8FBF001C 14A6FFFB 3C02BF88 AC456230 24030200
AC436234 AC436238 AC436234 AC436238 AC436234 AC436238 2631FFFF 1220001E
2631FFFF 3C03BF88 24020200 2404FFFF AC626234 AC626238 AC626234 AC626238
AC626234 AC626238 2631FFFF 1624FFF8 8FBF001C 10000012 8FB10018 3C02BF88
24030200 2407FFFF AC456230 AC436234 AC436238 AC466230 AC436234 AC436238
AC506230 AC436234 AC436238 2484FFFF 1487FFF5 00000000 8FBF001C 8FB10018
8FB00014 03E00008 27BD0020
'DrawBitmap_SSD1963
27BDFF98 AFBF0064 AFBE0060 AFB7005C AFB60058 AFB50054 AFB40050 AFB3004C
AFB20048 AFB10044 AFB00040 AFA40068 AFA5006C AFA70074 8FB00078 8FB40080
8FB30084 3C029D00 8C430094 8C710000 8C420098 8C420000 AFA20024 24020001
16820050 00C09021 3C029D00 8C420090 8044002D 1080004C 8FA2007C 3C159D00
8EA20028 0040F809 24160001 0056B004 8EA30090 8EA20024 8064002D 0040F809
24050006 0040B821 8EA30090 8EA20024 8064002D 0040F809 24050005 0040F021
24020003 72421002 8FA30074 70431002 70501002 00500018 00001812 AFA30014
8EA2003C 0040F809 00002012 AFA20018 8FA40068 8FA5006C 72123002 8FA20074
72023802 0411FEDF 00000000 3C02BF88 2403022E AC436230 24030200 AC436234
AC436238 240300FF AC43621C 8FA30018 00002821 3C02BF81 3C04BF88 AFD60000
8C46F220 8C46F220 AEF60000 8C866220 A0660000 AFD60000 8C46F220 8C46F220
AEF60000 8C866220 A0660001 AFD60000 8C46F220 8C46F220 AEF60000 8C866220
A0660002 24A50003 8FA70014 00A7302A 14C0FFEA 24630003 240300FF 3C02BF88
AC43621C 8FA2007C 0002BC03 36F70300 0002B203 36D60300 34550300 00141403
34420300 AFA20010 00141203 34420300 AFA20014 369E0300 8FA40068 8FA5006C
72123002 8FA20074 72023802 0411FEA5 00000000 3C02BF88 2403022C AC436230
24030200 AC436234 AC436238 8FA30074 1860008B 0200C821 8FA4006C AFA40028
00123823 AFA70030 70721002 2442FFFF AFA20020 AFB20034 0000C021 AFA0002C
00007021 240F0001 3C05BF88 10000078 24060200 04400043 0051202B 50800042
24630001 04E20040 24630001 5160003E 24630001 91A40000 008C2024 1080000C
00000000 ACB76230 ACA66234 ACA66238 ACB66230 ACA66234 ACA66238 ACB56230
ACA66234 ACA66238 1000002E 25CE0003 168F0022 8FA40010 3C049D00 8C840090
8084002D 1080001D 8FA40010 8FA40018 008E2021 AFA40038 80840000 34840300
ACA46230 ACA66234 ACA66238 8FA40018 008E2021 AFA40038 80840001 34840300
ACA46230 ACA66234 ACA66238 8FA40018 008E2021 AFA40038 80840002 34840300
AFA40038 ACA46230 25CE0003 ACA66234 ACA66238 1000000C 24630001 ACA46230
ACA66234 ACA66238 8FA40014 ACA46230 ACA66234 ACA66238 ACBE6230 ACA66234
ACA66238 24630001 1470FFBA 24420001 25290001 2508FFFF 11320010 01595021
01381021 24430007 284D0000 006D100B 000268C3 026D6821 000817C3 00021742
01026021 318C0007 01826023 018F6004 01401021 1000FFA7 00001821 8FA2001C
24420001 AFA2001C 14500004 24E70001 10000009 8FA4002C AFA0001C 1A40FFF7
8FAA0068 8FA80020 00004821 8FA30024 1000FFE3 00E3582B 24840001 AFA4002C
8FA70028 00F93821 AFA70028 8FA20020 8FA30030 00431021 AFA20020 8FA40034
8FA7002C 8FA20074 10E20005 0304C021 1E00FFE9 8FA70028 1000FFEF 8FA4002C
24020001 1682000B 8FBF0064 3C029D00 8C420090 8042002D 10400007 8FBE0060
3C029D00 8C420044 0040F809 8FA40018 8FBF0064 8FBE0060 8FB7005C 8FB60058
8FB50054 8FB40050 8FB3004C 8FB20048 8FB10044 8FB00040 03E00008 27BD0068
End CFunction



Edited by matherp 2015-10-06
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2794
Posted: 04:50am 05 Oct 2015
Copy link to clipboard 
Print this post

  matherp said  . . .
I will write a version for the MM+ once I have a suitable test system available. . . .


Would an Explore64 module help??

WW
For everything Micromite visit micromite.org

Direct Email: whitewizzard@micromite.o
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8591
Posted: 04:58am 05 Oct 2015
Copy link to clipboard 
Print this post

  Quote  Would an Explore64 module help??


No, but thanks for the offer. I'm waiting on my 40-pin backpack PCBs. Patch wiring the 40-pin headers is too much of a pain with too much scope for error. Also the patch leads can cause electrical crosstalk issues which just confuse things when doing this sort of development.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8591
Posted: 06:45am 28 Jan 2016
Copy link to clipboard 
Print this post

Please find attached an alternative driver for the SSD1963 to run on the 64-pin MM+ that supports overlay text as per the picture above.

Make sure there is no LCD panel already enabled with the option command. Use OPTION LCDPANEL DISABLE if required. Then load the program (save it in the library if you want). Reboot the MM+ and the new driver will be enabled.

It uses the normal MM+ SSD1963 pins + the ability to specify a connection to the RD pin on the display.

Using the RD pin allows the program to read the display's video memory and therefore write bitmaps (including text) without overwriting the existing background.

To do this, as detailed above, just specify the background colour as "1" e.g.

text 0,0,"hello",,,5,rgb(blue),1


The colour "1" is used as a code to cause the Cfunction to read in the display memory and only overwrite pixels that require the foreground colour of the text.

sub mm.startup
SSD1963(PEEK(CFUNADDR SSD1963),30,1,5 ) ' Address, RD pin, orientation, size
end sub

'**********Append this code and below onto the end of your MMBasic program***********
'
' Copyright (c) Peter Mather 2015
'
' Initialise the Display Driver for SSD1963 controlled TFT LCD Panel in 8-bit databus, 24-bit mode
' i.e. RGB888. This is optimised for the 64-pin MM+ and uses standard SSD1963 pinout except for the read pin
'
' SSD1963 initialises the loadable CFunction driver so that you can use all of the normal
' MMBasic graphic commands in your program.
'
' Parameters are:
' Address of the Cfunction
' Pin number of Read pin, set to zero if tied high
' Display orientation: LANDSCAPE=1,PORTRAIT=2,RLANDSCAPE=3, RPORTRAIT=4
' Size of display in inches i.e. 4 , 5 or 7
'
' After Calling SSD1963 any of the usual MM Graphic commands may be used
' in your MMBasic program, eg BOX, TEXT, LINE, CIRCLE etc
'
' Note: you must use the standard MM+ pins for d0=d7, WR, RS and Reset
' Tie CS Low
'
' This driver gives the ability to write text as an overlay on an existing backgound
' by specifying the backgound colour as "1"
' e.g. text 0,0,"hello",,,5,rgb(blue),1
'
' Ver 1.00 2016-01-28 Initial Release
'
'**********************************************************************************
'
CSUB ssd1963
00000022
'write_command_data
27BDFFF8 308400FF 3C02BF88 24081000 24090800 27A30010 34840800 AFA60010
AFA70014 AC486134 AFA30000 AC446430 AC496134 AC496138 AC486138 18A00010
00001021 00603021 3C04BF88 24070800 80C80000 24420001 35081800 AC886430
24C60004 AC876134 AC876138 5445FFF9 80C80000 00021080 00621821 AFA30000
03E00008 27BD0008
'main
3C029D00 8C430090 8CA50000 27BDFF98 AFB60060 AFB40058 AFB30054 AFB20050
AFB1004C AFBF0064 AFB5005C AFB00048 A065002D 8C430090 8CC50000 0080B021
A0650015 8C430090 8CE50000 27B2002C A065002C 8C420090 2403001C A043002E
2402003C AFA20028 2402003D AFA2002C 2402003E AFA20030 2402003F AFA20034
24020040 AFA20038 24020001 AFA2003C 24020002 AFA20040 24020003 AFA20044
27B40048 2411003C 10000002 3C139D00 26520004 8E620010 02202021 24050008
0040F809 00003021 8E620010 02202021 24050065 0040F809 00003021 8E62001C
02202021 24050005 0040F809 3C119D00 5654FFEF 8E510000 8E220010 2404001B
24050008 0040F809 00003021 8E220010 2404001B 24050065 0040F809 00003021
3C12BF88 24031000 8E220010 24040018 AE436138 24050008 0040F809 00003021
8E220010 24040018 24050065 0040F809 00003021 8E220090 24030800 AE436138
8044002D 5480012F 8E220010 3C119D00 8044002E 8E220010 24050008 0040F809
00003021 8E230090 8E220010 8064002E 24050065 0040F809 00003021 8E230090
8E22001C 8064002E 0040F809 24050006 8E230090 8064002D 54800116 8E22001C
3C029D00 3C159D00 3C149D00 8EC40000 24420088 8076002C 26B50A08 26940BD0
3C129D00 02A2A823 0282A023 24060320 2AD60005 8E42001C 02A4A821 0284A021
24110110 8064002E 240301E0 24050006 0076880A 00D6180A 0040F809 0060B021
8E420004 0040F809 24042710 8E430090 8E42001C 8064002E 0040F809 24050005
8E420004 0040F809 24042710 8E430090 8E42001C 8064002E 0040F809 24050006
8E420004 0040F809 24042710 8E420090 8042002C 28430005 146000FA 24030005
104300CC 24020054 24020004 240400E2 24050003 24060023 24070002 AFA20010
0411FF35 00000000 3C129D00 24050001 24060001 240400E0 0411FF2F 00000000
8E420004 0040F809 24042710 24060003 24050001 240400E0 0411FF27 00000000
8E420004 0040F809 24042710 24040001 00002821 0411FF20 00000000 8E420004
3C040001 0040F809 348486A0 8E420090 8042002C 28430005 146000DC 24030005
144300B1 240400E6 24050003 24060003 240200FF 240700FF AFA20010 0411FF0E
00000000 240400B0 24050007 24060024 24020003 AFA20010 2402001F AFA20014
24020001 00003821 AFA20018 240200DF AFA2001C AFA00020 0411FEFF 00000000
2402002E AFA20014 24020030 240400B4 24050008 24060003 240700A0 AFA20018
2402000F AFA20020 AFA00010 AFA0001C AFA00024 0411FEF0 00000000 24020010
AFA20014 AFA20018 240400B6 24020008 24050007 24060002 2407000D AFA00010
AFA0001C AFA20020 0411FEE3 00000000 240400BA 24050001 2406000F 0411FEDE
00000000 24070001 240400B8 24050002 24060007 0411FED8 00000000 24040036
24050001 00003021 0411FED3 00000000 240400F0 24050001 00003021 0411FECE
00000000 2404003A 24050001 24060070 0411FEC9 00000000 3C129D00 24060001
24050001 24040026 0411FEC3 00000000 8E420004 0040F809 24042710 24040029
00002821 0411FEBC 00000000 24130001 240200F0 240400BE 24050006 24060006
240700F0 AFA20014 AFB30010 AFA00018 AFA0001C 0411FEB0 00000000 240400D0
24050001 2406000D 0411FEAB 00000000 8E430090 24040002 80620015 104400A4
24040004 5044009D 8063002C 145300A6 24040003 8062002C 24100040 28420006
0002800B 24040036 24050001 02003021 0411FE99 00000000 3C029D00 8C430090
90630015 30630001 5460002B 8C430094 8C430098 AC760000 8C420094 AC510000
3C029D00 8C430048 00002021 AC750000 8C43004C 00002821 AC740000 8C430098
8C460094 8C420048 8C670000 8CC60000 AFA00010 8C420000 24C6FFFF 0040F809
24E7FFFF 8FBF0064 00001021 00001821 8FB60060 8FB5005C 8FB40058 8FB30054
8FB20050 8FB1004C 8FB00048 03E00008 27BD0068 240400E2 24050003 2406001E
24070002 AFA20010 0411FE6B 00000000 1000FF36 3C129D00 AC760000 8C420098
1000FFD7 AC510000 24050003 24060004 240200E0 24070093 AFA20010 0411FE5E
00000000 240400B0 24050007 1000FF50 00003021 0040F809 24050006 1000FEE8
8E230090 24050008 0040F809 00003021 8E230090 8E220010 8064002D 24050065
0040F809 00003021 8E230090 8E22001C 8064002D 0040F809 24050006 1000FEC3
8E220090 24020054 240400E2 24050003 24060023 24070002 AFA20010 0411FE3E
00000000 1000FF09 3C129D00 240200FF 240400E6 24050003 24060001 2407001F
AFA20010 0411FE34 00000000 24020001 240300DF AFA20010 AFA20018 240400B0
2402000F 24050007 24060020 00003821 AFA30014 AFA2001C AFA00020 0411FE26
00000000 24020008 24120002 AFA20014 240400B4 2402002B 24050008 24060002
24070013 AFA20018 AFA00010 AFA0001C AFB20020 AFA00024 0411FE17 00000000
24020004 AFA20014 240400B6 2402000C 24050007 24060001 24070020 AFA00010
AFA20018 AFA0001C AFB20020 0411FE0A 00000000 1000FF27 240400BA 24100020
28630006 24020060 1000FF66 0043800B 8063002C 241000E0 28630006 240200A0
1000FF60 0043800B 1444FF5E 24020080 8063002C 241000C0 28630006 1000FF59
0043800A
'defineregion
3C029D00 8C430094 24091000 8C420098 3C08BF88 AD096134 8C630000 8C420000
248AFFFF 24A9FFFF 0043402B 01465021 15000046 01274821 00404021 00601021
3C039D00 8C660090 240D0001 80C30015 506D0046 80C2002C 24070002 10670058
24070003 5067004C 80C3002C 00094827 00052827 01286021 00A85821 000C1202
3C03BF88 24060800 24081000 000B7202 00046A02 000A3A02 34421800 2405022A
AC656430 358C1800 AC666134 35CE1800 AC666138 356B1800 AC686138 35AD1800
AC626430 34841800 34E71800 354A1800 2402022B AC666134 AC666138 AC6C6430
AC666134 AC666138 AC6E6430 AC666134 AC666138 AC6B6430 AC666134 AC666138
AC686134 AC626430 AC666134 AC666138 AC686138 AC6D6430 AC666134 AC666138
AC646430 AC666134 AC666138 AC676430 AC666134 AC666138 AC6A6430 AC666134
AC666138 03E00008 00000000 00604021 3C039D00 8C660090 240D0001 80C30015
146DFFBE 24070002 80C2002C 00806021 28420007 01405821 00A02021 1440FFBF
01205021 000B1027 000C5827 01685821 1000FFBA 00486021 00094827 00052827
28630007 01405821 00806021 00A25021 1060FFB2 01222021 1000FFF3 000B1027
000A5027 00041827 00A06021 01422021 01205821 1000FFA9 00625021
'DrawRectangle_SSD1963
27BDFFE0 0086102A AFB00014 AFBF001C AFB10018 14400004 8FB00030 00801021
00C02021 00403021 00A7102A 14400005 3C029D00 00A01021 00E02821 00403821
3C029D00 8C430094 8C420098 8C680000 28890000 8C430000 28A20000 0009200B
0002280B 28F10000 28C20000 2509FFFF 0002300B 0011380B 2462FFFF 0088582B
00A3502B 004A280A 012B200A 00E3182B 00C8402B 24110001 0043380A 0128300A
02241023 02258823 00461021 02278821 00403021 02203821 72228802 0411FF59
00000000 7E043C00 320500FF 3C02BF88 24061000 24030800 7E103A00 2407022C
34841800 34A51800 AC466134 36101800 AC476430 AC436134 AC436138 AC466138
10850017 00000000 12200010 2631FFFF 3C02BF88 24030800 2406FFFF 2631FFFF
AC446430 AC436134 AC436138 AC506430 AC436134 AC436138 AC456430 AC436134
AC436138 1626FFF6 2631FFFF 8FBF001C 8FB10018 8FB00014 03E00008 27BD0020
1490FFE9 00000000 2625FFFF AC446430 AC436134 AC436138 AC436134 AC436138
AC436134 AC436138 10A0FFF0 2631FFFE 3C03BF88 24020800 2404FFFF 2631FFFF
AC626134 AC626138 AC626134 AC626138 AC626134 AC626138 1624FFF9 2631FFFF
1000FFE3 8FBF001C
'DrawBitmap_SSD1963
27BDFF88 AFB50064 3C159D00 8EA20098 8EA80094 8C420000 AFB00050 8FB00088
AFB10054 8D110000 AFA2002C 72061002 AFB40060 AFA20010 72071002 8FB40090
AFA20014 24020001 AFB3005C AFB20058 AFBF0074 AFBE0070 AFB7006C AFB60068
00C09021 AFA70034 AFA40028 AFA50030 8FA3008C 128200B7 8FB30094 8FA40028
8FA50030 8FA60010 8FA70014 00144403 00141203 34421800 35081800 0003AC03
0003B203 AFA20014 AFA30040 AFA80010 0411FEEA 00000000 8FA30040 3C02BF88
24041000 24050800 34771800 2403022C AC446134 AC436430 AC456134 AC456138
AC446138 8FA20034 36B51800 36D61800 18400053 369E1800 70521002 00121823
2442FFFF 3C198000 AFA3003C AFA20024 0000C021 AFA00038 00007021 27390007
240F0001 3C05BF88 24060800 1A000037 8FA20038 8FA70030 AFA00020 1A40002D
8FA4002C 8FAA0028 8FA90024 00004021 00E4582B 01186821 25A20007 29A30000
0043680B 000D68C3 01396024 05800052 026D6821 018F6004 01401021 00001821
04400015 0051202B 50800014 24630001 04E20012 24630001 51600010 24630001
91A40000 008C2024 10800034 00000000 ACB56430 25CE0003 ACA66134 ACA66138
ACB66430 ACA66134 ACA66138 ACB76430 ACA66134 ACA66138 24630001 1470FFE8
24420001 25080001 2529FFFF 1512FFD9 01505021 8FA30020 24E70001 24630001
1470FFCE AFA30020 8FA20038 8FA30030 24420001 AFA20038 8FA40024 8FA2003C
00701821 00822021 AFA30030 AFA40024 8FA30038 8FA40034 1464FFBC 0312C021
24020001 12820092 3C029D00 8FBF0074 8FBE0070 8FB7006C 8FB60068 8FB50064
8FB40060 8FB3005C 8FB20058 8FB10054 8FB00050 03E00008 27BD0078 128F0013
3C049D00 8FA40010 ACA46430 8FA40014 ACA66134 ACA66138 ACA46430 ACA66134
ACA66138 ACBE6430 ACA66134 ACA66138 1000FFCA 24630001 258CFFFF 2402FFF8
01826025 1000FFAB 258C0001 8C840090 8084002D 1080FFEC 8FA40010 8FA4001C
008E2021 AFA40018 80840000 25CE0003 AFA40048 8FA40048 34841800 AFA40048
ACA46430 8FA40018 ACA66134 ACA66138 80840001 AFA40048 8FA40048 34841800
AFA40048 ACA46430 8FA40018 ACA66134 ACA66138 80840002 34841800 AFA40018
ACA46430 ACA66134 ACA66138 1000FFA3 24630001 8EA20090 8044002D 5080FF48
8FA40028 8EA20028 0040F809 AFA30040 8EA40090 8EA60024 8084002D 24050006
00C0F809 0054B004 8EA40090 0040B821 8084002D 8EA20024 0040F809 24050005
24040003 72442002 8FA50034 0040F021 8EA2003C 7085A802 72B0A802 72B0A802
0040F809 02A02021 8FA40028 8FA50030 8FA60010 8FA70014 AFA2001C 0411FE1F
00000000 3C02BF88 24081000 24060800 2404022E AC486134 8FA5001C 8FA30040
AC446430 AC466134 AC466138 AC486138 240800FF 00003821 3C04BF81 3C06BF88
AC48641C AFD60000 8C82F220 8C82F220 AEF60000 8CC26420 24E70003 A0A20000
AFD60000 8C82F220 8C82F220 AEF60000 8CC86420 00F5102A A0A80001 AFD60000
8C88F220 8C88F220 AEF60000 8CC86420 A0A80002 1440FFEB 24A50003 240400FF
3C02BF88 AC44641C 1000FEFD 8FA40028 8C430090 8063002D 1060FF6D 8FBF0074
8FA4001C 8C590044 8FBE0070 8FB7006C 8FB60068 8FB50064 8FB40060 8FB3005C
8FB20058 8FB10054 8FB00050 03200008 27BD0078
End CSUB


C source


/*******************************************************************************
*
* Driver for SSD1963 Display written as CFunctions
*
* (c) Peter Mather 2015 with acknowledgements to Peter Carnegie & Geoff Graham
*
*
* This CFunction MUST be compiled with Optimization Level 1, -O1
* -O2,-O3,-Os will compile successfully, but generate exceptions at runtime.
*
* When Generating the CFunction, use MERGE CFunction mode, and name the CFunction
* SSD1963_V44
*
* Entry point is function long long main(long long *MyAddress,
* long long *RST,
* long long *orientation
* long long *size)
*
* V1.0 2015-07-21 Peter Mather
* 1.01 Change orientation codes to 1:landscape, 2:portrait, 3:rlandscape, 4:rportrait
* 1.02 Use fixed PortC pinout for maximum performance
* 1.03 Stripped routines for use as loadable LIBRARY
* 1.04 Conditional compilation for 44 and 64-pin parts
*
******************************************************************************/
#include <stdarg.h>

#define Version 103 //Version 1.03
#define MX470 //Comment out for compilation for 44-pin part

#include "../cfunctions.h"
#define bclrport *(volatile unsigned int *)(0xbf886134) //latch registers
#define bsetport *(volatile unsigned int *)(0xbf886138) //latch registers
#define cport *(volatile unsigned int *)(0xbf886230) //latch registers
#define cread *(volatile unsigned int *)(0xbf886220) //latch registers
#define ctrisinv *(volatile unsigned int *)(0xbf88621C) //latch registers
#define cclrport *(volatile unsigned int *)(0xbf886234) //latch registers
#define csetport *(volatile unsigned int *)(0xbf886238) //latch registers
#define eport *(volatile unsigned int *)(0xbf886430) //latch registers
#define eread *(volatile unsigned int *)(0xbf886420) //latch registers
#define etrisinv *(volatile unsigned int *)(0xbf88641C) //latch registers
#define eclrport *(volatile unsigned int *)(0xbf886434) //latch registers
#define esetport *(volatile unsigned int *)(0xbf886438) //latch registers
#define DEVID (*(volatile unsigned int *)0xBF80F220)

//Offsets into the persistent RAM of variables
#ifdef MX470
#define RS_Pin_No 27
#define WR_Pin_No 24
#define RS_Pin 0x1000
#define WR_Pin 0x0800
#define clrport bclrport
#define setport bsetport
#define port eport
#define read eread
#define trisinv etrisinv
#define RSLo {clrport=RS_Pin;}
#define RSHi {setport=RS_Pin;}
#define WRLo {clrport=WR_Pin;}
#define WRHi {setport=WR_Pin;}
#else
#define RS_Pin_No 4
#define WR_Pin_No 5
#define RS_Pin 0x100
#define WR_Pin 0x200
#define clrport cclrport
#define setport csetport
#define port cport
#define read cread
#define trisinv ctrisinv
#define RSLo clrport=RS_Pin
#define RSHi setport=RS_Pin
#define WRLo clrport=WR_Pin
#define WRHi setport=WR_Pin
#endif
#define Both WR_Pin | RS_Pin
#define RDLo (*(volatile unsigned int *)RDclrport)=RDpin
#define RDHi (*(volatile unsigned int *)RDsetport)=RDpin
#define LANDSCAPE 1
#define PORTRAIT 2
#define RLANDSCAPE 3
#define RPORTRAIT 4

/*******************************************************************************
*
* Write Data to a register on the Chip
*
******************************************************************************/
void write_command_data(unsigned int command, int data, ...){
int i;
#ifdef MX470
RSLo;
#endif
va_list ap;
va_start(ap, data);
port=(command & 0x00FF) | WR_Pin; WRLo; WRHi; // RS low
#ifdef MX470
RSHi;
#endif
for(i = 0; i < data; i++) {
port= (char)va_arg(ap, int) | Both; WRLo; WRHi; //RS high
}
va_end(ap);
}
/*******************************************************************************
*
* defines start/end coordinates for memory access from host to SSD1963
* also maps the start and end points to suit the orientation
*
* This function is a modified version of the function inside the MMBasic Interpreter
* for MM+ on 'MX470 chips
*
*******************************************************************************/
void defineregion(long x, long y, long width,long height){ //SSD1963
long x1=x,x2=x+width-1,y1=y,y2=y+height-1;
unsigned long xstart,xend,ystart,yend,Vertical,Horizontal;
#ifdef MX470
RSLo;
#endif
if(HRes>VRes){
Vertical=VRes;
Horizontal=HRes;
}
else {
Vertical=HRes;
Horizontal=VRes;
}
if(Option->DISPLAY_ORIENTATION!=LANDSCAPE)goto isP;
xstart = x1;
xend = x2;
ystart = y1;
yend = y2;
if(Option->LCD_CD>6){ //reverse for 7" displays
xstart = (Horizontal - 1) - x2;
xend = (Horizontal - 1) - x1;
}
goto setreg;
isP:
if(Option->DISPLAY_ORIENTATION!=PORTRAIT)goto isRL;
xstart = y1;
xend = y2;
ystart = (Vertical - 1) - x2;
yend = (Vertical - 1) - x1;
goto setreg;
isRL:
if(Option->DISPLAY_ORIENTATION!=RLANDSCAPE)goto isRP;
xstart = (Horizontal - 1) - x2;
xend = (Horizontal - 1) - x1;
ystart = (Vertical - 1) - y2;
yend = (Vertical - 1) - y1;
if(Option->LCD_CD>6){//reverse for 7" displays
xstart = x1;
xend = x2;
}
goto setreg;
isRP:
xstart = (Horizontal - 1) - y2;
xend = (Horizontal - 1) - y1;
ystart = x1;
yend = x2;
setreg:
port=0x22A ;WRLo; WRHi; // RS low
#ifdef MX470
RSHi;
#endif
port=(xstart>>8 ) | Both; WRLo; WRHi; // RS HIGH
port=(xstart) | Both; WRLo; WRHi; // RS HIGH
port=(xend>>8 ) | Both; WRLo; WRHi; // RS HIGH
port=(xend) | Both; WRLo; WRHi; // RS HIGH
#ifdef MX470
RSLo;
#endif
port=0x22B ; WRLo; WRHi; // RS low
#ifdef MX470
RSHi;
#endif
port=(ystart>>8 ) | Both; WRLo; WRHi; // RS HIGH
port=(ystart) | Both; WRLo; WRHi; // RS HIGH
port=(yend>>8 ) | Both; WRLo; WRHi; // RS HIGH
port=(yend) | Both; WRLo; WRHi; // RS HIGH RSHi;
}



/***********************************************************************************************
* Display the bitmap of a char on the TFT panel
*
* This function is NEVER called by MMBasic programs
*
* This is optimised for the
* x, y - the top left of the char
* width, height - size of the char's bitmap
* scale - how much to scale the bitmap
* fg, bg - foreground and background colour
* bitmap - pointer to the butmap
*
* This function is a modified version of the function inside the MMBasic Interpreter
* for MM+ on 'MX470 chips
***********************************************************************************************/
void DrawBitmap_SSD1963(int x1, int y1, int width, int height, int scale, int fc, int bc, unsigned char *bitmap ){
long i, j, k, m, n, RDpin, RDsetport, RDclrport;
unsigned int fhb,fmb, flb, bhb, bmb, blb, xtest, ytest;
char *p;
xtest=HRes;
ytest=VRes;
if(bc==1 && Option->LCD_CS!=0){ //special case of overlay text
RDpin=1<<GetPinBit(Option->LCD_CS);
RDsetport=(unsigned int)GetPortAddr(Option->LCD_CS,LATSET);
RDclrport=(unsigned int)GetPortAddr(Option->LCD_CS,LATCLR);
i=0;
j=width*height*scale*scale*3;
p=GetMemory(j); //allocate some temporary memory
defineregion(x1,y1,width*scale,height*scale);
#ifdef MX470
RSLo;
#endif
port=0x22E ; WRLo; WRHi; // RS low
#ifdef MX470
RSHi;
#endif
trisinv=0xFF; //set pins to read
do { //read in the screen area to be overlayed
RDLo;
n=DEVID;n=DEVID;
RDHi;
p[i++]=(read & 0xFF);
RDLo;
n=DEVID;n=DEVID;
RDHi;
p[i++]=(read & 0xFF);
RDLo;
n=DEVID;n=DEVID;
RDHi;
p[i++]=(read & 0xFF);
} while(i<j);
trisinv=0xFF; //set pins to write
}

// convert the colours to 888 format
fhb = (fc >> 16) | Both;
fmb = (fc >> 8) | Both;
flb = fc | Both;
bhb = (bc >> 16) | Both;
bmb = (bc >> 8) | Both;
blb = bc | Both;

n=0;
defineregion(x1,y1,width*scale,height*scale);
#ifdef MX470
RSLo;
#endif
port=0x22C ; WRLo; WRHi; // RS low
#ifdef MX470
RSHi;
#endif
for(i = 0; i < height; i++) { // step thru the font scan line by line
for(j = 0; j < scale; j++) { // repeat lines to scale the font
for(k = 0; k < width; k++) { // step through each bit in a scan line
for(m = 0; m < scale; m++) { // repeat pixels to scale in the x axis
if(x1 + k * scale + m >= 0 && x1 + k * scale + m < xtest && y1 + i * scale + j >= 0 && y1 + i * scale + j < ytest) { // if the coordinates are valid
if((bitmap[((i * width) + k)/8] >> (((height * width) - ((i * width) + k) - 1) %8)) & 1) {
port=fhb; WRLo; WRHi;
port=fmb; WRLo; WRHi;
port=flb; WRLo; WRHi;
n+=3;
} else {
if(bc==1 && Option->LCD_CS!=0){
port=p[n++] | Both; WRLo; WRHi;
port=p[n++] | Both; WRLo; WRHi;
port=p[n++] | Both; WRLo; WRHi;
} else {
port=bhb; WRLo; WRHi;
port=bmb; WRLo; WRHi;
port=blb; WRLo; WRHi;
}
}
}
}
}
}
}
if(bc==1 && Option->LCD_CS!=0) FreeMemory(p);
}

/*******************************************************************************
*
* Called by MMBasic Interpreter to draw a rectangle
* on the SSD1963 panel
*
* This function is NEVER called by MMBasic programs
*
*
******************************************************************************/

void DrawRectangle_SSD1963(int x1, int y1, int x2, int y2, int fc){
int t;
long width, height;
unsigned long i,ch,cm,cl;
// make sure the coordinates are kept within the display area
if(x2 <= x1) { t = x1; x1 = x2; x2 = t; }
if(y2 <= y1) { t = y1; y1 = y2; y2 = t; }
if(x1 < 0) x1 = 0; if(x1 >= HRes) x1 = HRes - 1;
if(x2 < 0) x2 = 0; if(x2 >= HRes) x2 = HRes - 1;
if(y1 < 0) y1 = 0; if(y1 >= VRes) y1 = VRes - 1;
if(y2 < 0) y2 = 0; if(y2 >= VRes) y2 = VRes - 1;
width=x2-x1+1;height=y2-y1+1;
i=width*height;
defineregion(x1,y1,width,height);
#ifdef MX470
RSLo;
#endif
port=0x22C ; WRLo; WRHi; // RS low
#ifdef MX470
RSHi;
#endif
// convert the colours to 888 format
ch = ((fc >> 16)) & 0xFF | Both; // make 8 bits to allow the optimisation to work
cm = ((fc >> 8)) & 0xFF | Both;
cl = fc & 0xFF | Both;
if((ch==cl) && (ch==cm)){
port=ch; WRLo; WRHi;
WRLo; WRHi;
WRLo; WRHi;
i--;
while (i--){
WRLo;
WRHi;
WRLo;
WRHi;
WRLo;
WRHi;
}
}else {
while (i--) {
port=ch; WRLo; WRHi;
port=cm; WRLo; WRHi;
port=cl; WRLo; WRHi;
}
}
}


/*******************************************************************************
*
* SSD1963_V44 : Initialise the CFunction Driver Sub-System
*
* Function called to initialise the driver SubSystem
*
* SSD1963_V44 is ALWAYS called from an MMBasic program
* On exit, vectors DrawRectangleVector, and DrawBitmapVector will
* be set to point to the CFunctions DrawRectangle_SSD1963 and
* DrawBitmap_SSD1963 respectively
*
* Input Arguments
* MyAddress: The Address of the CFunction, use PEEK(CFUNADDR SSD1963_V44)
* RST: The pin connected to the Reset input on the display
* orientation:
* is 0 for Portrait orientation, 1 for reverse portrait, 2 for landscape, 3 for reverse landscape
* size: The display size 4, 5, or 7"
*
* Exit Value Version
*
* Note, For added performance, it may be desirable to create a
* separate WriteData function which doen't asser/de-asser CS for each byte and
* instead use block CSLo/CSHi around data transfers. These "block" CSLo/CSHi
* statements have been left in the code as comments.
*
******************************************************************************/
//CFunction Driver_SSD1963
#ifdef MX470
long long main(long long *MyAddress, long long *RD,long long *orientation, long long *size){
#else
long long main(long long *MyAddress, long long *RST,long long *RD,long long *orientation, long long *size){
#endif
int t,DrawRectangleVectorOffset,DrawBitmapVectorOffset,HorizontalRes,VerticalRes;
unsigned int p[8];
int j;
#ifndef MX470
Option->LCD_Reset=*RST;
#endif

Option->LCD_CS=*RD;
Option->DISPLAY_ORIENTATION=*orientation;
Option->LCD_CD=*size; //save the display size as the display type for use in the driver routines

#ifdef MX470
Option->LCD_Reset=28;
p[0]=60;
p[1]=61;
p[2]=62;
p[3]=63;
p[4]=64;
p[5]=1;
p[6]=2;
p[7]=3;

#else
Option->LCD_Reset=*RST;
p[0]=25;
p[1]=26;
p[2]=27;
p[3]=36;
p[4]=37;
p[5]=38;
p[6]=2;
p[7]=3;
#endif
for(j=0;j<8;j++){
ExtCfg(p[j],EXT_DIG_OUT,0);ExtCfg(p[j],EXT_BOOT_RESERVED,0);
PinSetBit(p[j],LATCLR);
}

//Control Signals
ExtCfg(RS_Pin_No,EXT_DIG_OUT,0);ExtCfg(RS_Pin_No,EXT_BOOT_RESERVED,0);
RSHi;

ExtCfg(WR_Pin_No,EXT_DIG_OUT,0);ExtCfg(WR_Pin_No,EXT_BOOT_RESERVED,0);
WRHi;

if(Option->LCD_CS){
ExtCfg(Option->LCD_CS, EXT_DIG_OUT,0);
ExtCfg(Option->LCD_CS, EXT_BOOT_RESERVED,0);
PinSetBit(Option->LCD_CS, LATSET);
}
ExtCfg(Option->LCD_Reset,EXT_DIG_OUT,0);ExtCfg(Option->LCD_Reset,EXT_BOOT_RESERVED,0);
PinSetBit(Option->LCD_Reset, LATSET);
if(Option->LCD_CS) PinSetBit(Option->LCD_CS, LATSET);
//Calculate the address vectors
if ((unsigned int)&DrawRectangle_SSD1963 < (unsigned int)&main){
DrawRectangleVectorOffset=*MyAddress - ((unsigned int)&main - (unsigned int)&DrawRectangle_SSD1963);
}else{
DrawRectangleVectorOffset=*MyAddress + ((unsigned int)&DrawRectangle_SSD1963 - (unsigned int)&main);
}

if ((unsigned int)&DrawBitmap_SSD1963 < (unsigned int)&main){
DrawBitmapVectorOffset=*MyAddress - ((unsigned int)&main - (unsigned int)&DrawBitmap_SSD1963);
}else{
DrawBitmapVectorOffset=*MyAddress + ((unsigned int)&DrawBitmap_SSD1963 - (unsigned int)&main);
}

//Save DisplayMetrics
if(Option->LCD_CD<5){
HorizontalRes=480;
VerticalRes=272;
} else {
HorizontalRes=800;
VerticalRes=480;
}

//Reset the SSD1963
PinSetBit(Option->LCD_Reset,LATSET);
uSec(10000);
PinSetBit(Option->LCD_Reset,LATCLR);
uSec(10000);
PinSetBit(Option->LCD_Reset,LATSET);
uSec(10000);

if(Option->LCD_CD<5) {
write_command_data(0xE2,3,0x23,0x02,0x54);
} else {
if(Option->LCD_CD<6){
write_command_data(0xE2,3,0x1E,0x02,0x54);
} else {
write_command_data(0xE2,3,0x23,0x02,0x04);
}
}

write_command_data(0xE0,1,0x01); uSec( 10000); // PLL enable
write_command_data(0xE0,1,0x03); uSec( 10000);
write_command_data(0x01,0); uSec( 100000); // software reset

if(Option->LCD_CD<5) {
write_command_data(0xE6,3,0x01,0x1F,0xFF);
write_command_data(0xB0,7,0x20,0x00,0x01,0xDF,0x01,0x0F,0x00); //LCD SPECIFICATION
write_command_data(0xB4,8,0x02,0x13,0x00,0x08,0x2B,0x00,0x02,0x00);
write_command_data(0xB6,7,0x01,0x20,0x00,0x04,0x0C,0x00,0x02);
} else {
if (Option->LCD_CD<6){
write_command_data(0xE6,3,0x03,0xFF,0xFF);
write_command_data(0xB0,7,0x24,0x00,0x03,0x1F,0x01,0xDF,0x00); //LCD SPECIFICATION
} else {
write_command_data(0xE6,3,0x04,0x93,0xE0);
write_command_data(0xB0,7,0x00,0x00,0x03,0x1F,0x01,0xDF,0x00); //LCD SPECIFICATION
}
write_command_data(0xB4,8,0x03,0xA0,0x00,0x2E,0x30,0x00,0x0F,0x00);
write_command_data(0xB6,7,0x02,0x0D,0x00,0x10,0x10,0x00,0x08);
}

write_command_data(0xBA,1,0x0F);
write_command_data(0xB8,2,0x07,0x01);
write_command_data(0x36,1,0x00); //rotation
write_command_data(0xF0,1,0x00); //PIXEL data interface - 8-bit
write_command_data(0x3A,1,0b01110000); //PIXEL data interface 24-bit
write_command_data(0x26,1,0x01); uSec( 10000); //gamma curve
write_command_data(0x29,0); //display on
write_command_data(0xBE,6,0x06,0xF0,0x01,0xF0,0x00,0x00); //set PWM for B/L
write_command_data(0xd0,1,0x0D);
//Set Hres and VRes
if(Option->DISPLAY_ORIENTATION==PORTRAIT){
if (Option->LCD_CD<6) t=0xA0;
else t=0xE0;
}
if(Option->DISPLAY_ORIENTATION==RPORTRAIT){
if (Option->LCD_CD<6) t=0x60;
else t=0x20;
}
if(Option->DISPLAY_ORIENTATION==LANDSCAPE){
if (Option->LCD_CD<6) t=0x00;
else t=0x40;
}
if(Option->DISPLAY_ORIENTATION==RLANDSCAPE){
if (Option->LCD_CD<6) t=0xC0;
else t=0x80;
}
write_command_data(0x36,1,t);
if(Option->DISPLAY_ORIENTATION&1){
HRes=HorizontalRes;
VRes=VerticalRes;
} else {
VRes=HorizontalRes;
HRes=VerticalRes;
}

//Set the DrawRectangle vector to point to our function
DrawRectangleVector=DrawRectangleVectorOffset;


//Set the DrawBitmap vector to point to our function
DrawBitmapVector=DrawBitmapVectorOffset;

//CLS
DrawRectangle(0,0,HRes-1,VRes-1,0x000000);
return 0;
}





 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3165
Posted: 01:39pm 28 Jan 2016
Copy link to clipboard 
Print this post

Great work.

  matherp said  There is one "feature" related to the way Geoff has implemented the space character as a rectangle in the backgound colour rather than as an actual character - unfortunately a space will always overwrite the display in the background colour.

That should not be an issue in V5.1. From what I remember it was only a problem with font #1 and I changed it to draw an actual blank character rather than erase a rectangle. The erased rectangle is now only used far an invalid character.

Geoff Edited by Geoffg 2016-01-30
Geoff Graham - http://geoffg.net
 
Print this page


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

© JAQ Software 2024