Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 02:25 17 Jun 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 : MM+: SSD1289 Loadable driver

Author Message
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8648
Posted: 11:34am 16 Oct 2015
Copy link to clipboard 
Print this post

The SSD1289 controller based TFT displays are very cheap with 240x320 resolution and have a proper touch controller and SD card slot (e.g. )

By modifying them as specified here they work well in RGB666 mode with an 8 bit databus.





This driver allows them to be used on a 64-pin MM+. It won't work on a 100-pin as the pin allocations for RS and WR are different in the way Geoff has set up the 100-pin.

For the 64-pin MM+ use the standard pins as defined in the "Advanced Features" Manual for the SSD1963. All MM+ commands including GUI and full touch will work as normal.

Using the display as a console nearly works - I need to discuss with Geoff why the text doesn't scroll and if this is fixable but for normal output it works superbly and updates very quickly.


sub mm.startup
LOCAL CFuncAddr%
CFuncAddr%=PEEK(CFUNADDR SSD1289_plus64)
SSD1289_plus64(CFuncAddr%, 1) 'Address of the CFunction, orientation
end sub

'**********Append this code and below onto the end of your MMBasic program***********
'
' Author: Peter Mather 2015
'
' 64-pin MM+ Display Driver for SSD1289 controlled TFT LCD Panel in 8-bit databus, 18-bit mode
' i.e. RGB666.
'
' SSD1289_plus64 initialises the loadable CFunction driver
' After calling SSD1289_plus64, any of the usual MM Graphic commands may be used
' in your MMBasic program, eg BOX, TEXT, LINE, CIRCLE, GUI etc
'
' Orientations are: LANDSCAPE=1,PORTRAIT=2,RLANDSCAPE=3 ,RPORTRAIT=4
'
'
' Note: you must use pins defined in the Micromite manual for the SSD1963
' Tie CS Low and tie RD high
'
' Ver 1.0 2015-10-16 Initial Release
'
'**********************************************************************************

'
CSUB SSD1289_plus64
00000026
'writeRegister
3C03BF88 24071000 AC676134 3C02BF81 8C46F220 7C863A00 AC666430 8C46F220
24060800 AC666134 8C48F220 AC666138 8C48F220 308400FF AC646430 8C44F220
AC666134 8C44F220 AC666138 8C44F220 AC676138 8C44F220 7CA43A00 AC646430
8C44F220 AC666134 8C44F220 AC666138 8C44F220 30A500FF AC656430 8C44F220
AC666134 8C44F220 AC666138 8C42F220 03E00008 00000000
'main
27BDFFB0 AFBF004C AFB40048 AFB30044 AFB20040 AFB1003C AFB00038 0080A021
3C029D00 8C430090 2404001C A064002E 8C420090 8CA30000 A0430015 2402003C
AFA20018 2402003D AFA2001C 2402003E AFA20020 2402003F AFA20024 24020040
AFA20028 24020001 AFA2002C 24020002 AFA20030 24020003 AFA20034 27B20018
27B30038 3C109D00 8E510000 8E020010 02202021 24050008 0040F809 00003021
8E020010 02202021 24050065 0040F809 00003021 8E02001C 02202021 0040F809
24050005 26520004 5653FFF0 8E510000 3C109D00 8E020010 2404001B 24050008
0040F809 00003021 8E020010 2404001B 24050065 0040F809 00003021 3C11BF88
24021000 AE226138 3C12BF81 8E42F220 8E020010 24040018 24050008 0040F809
00003021 8E020010 24040018 24050065 0040F809 00003021 24020800 AE226138
8E53F220 8E030090 8E020010 8064002E 24050008 0040F809 00003021 8E030090
8E020010 8064002E 24050065 0040F809 00003021 8E030090 8E02001C 8064002E
0040F809 24050006 8E020090 8044002D 10800006 3C029D00 3C029D00 8C42001C
0040F809 24050006 3C029D00 24420098 3C129D00 26520818 0242182B 10600004
02429023 8E830000 10000003 02439021 8E830000 02439021 3C119D00 26310A2C
0222182B 10600004 02228823 8E830000 10000003 02238821 8E830000 02238821
3C109D00 8E030090 8E02001C 8064002E 0040F809 24050006 8E020004 0040F809
24042710 8E030090 8E02001C 8064002E 0040F809 24050005 8E020004 0040F809
24042710 8E030090 8E02001C 8064002E 0040F809 24050006 8E020004 0040F809
24042710 00002021 24050001 0411FF3E 00000000 24040003 3405A8A4 0411FF3A
00000000 2404000C 00002821 0411FF36 00000000 2404000D 2405080C 0411FF32
00000000 2404000E 24052B00 0411FF2E 00000000 2404001E 240500B7 0411FF2A
00000000 24040001 24052B3F 0411FF26 00000000 24040002 24050600 0411FF22
00000000 24040010 00002821 0411FF1E 00000000 24040011 24056070 0411FF1A
00000000 24040005 00002821 0411FF16 00000000 24040006 00002821 0411FF12
00000000 24040016 3405EF1C 0411FF0E 00000000 24040017 24050003 0411FF0A
00000000 24040007 24050233 0411FF06 00000000 2404000B 00002821 0411FF02
00000000 2404000F 00002821 0411FEFE 00000000 24040041 00002821 0411FEFA
00000000 24040042 00002821 0411FEF6 00000000 24040048 00002821 0411FEF2
00000000 24040049 2405013F 0411FEEE 00000000 2404004A 00002821 0411FEEA
00000000 2404004B 00002821 0411FEE6 00000000 24040030 24050707 0411FEE2
00000000 24040031 24050204 0411FEDE 00000000 24040032 24050204 0411FEDA
00000000 24040033 24050502 0411FED6 00000000 24040034 24050507 0411FED2
00000000 24040035 24050204 0411FECE 00000000 24040036 24050204 0411FECA
00000000 24040037 24050502 0411FEC6 00000000 2404003A 24050302 0411FEC2
00000000 2404003B 24050302 0411FEBE 00000000 24040023 00002821 0411FEBA
00000000 24040024 00002821 0411FEB6 00000000 24040025 34058000 0411FEB2
00000000 8E020090 80420015 24030002 10430008 24030004 1043000C 24054040
24030001 10430008 02602821 10000003 38420003 24054070 38420003 24034058
10000002 0062280A 24054068 24040011 0411FE9D 00000000 3C029D00 8C420090
90420015 30420001 10400008 3C029D00 8C430098 240400F0 AC640000 8C420094
24030140 10000007 AC430000 8C430094 240400F0 AC640000 8C420098 24030140
AC430000 3C029D00 8C430048 AC720000 8C43004C AC710000 8C430048 8C440094
8C860000 8C420098 8C470000 AFA00010 8C620000 00002021 00002821 24C6FFFF
0040F809 24E7FFFF 24020064 00001821 8FBF004C 8FB40048 8FB30044 8FB20040
8FB1003C 8FB00038 03E00008 27BD0050
'defineregion
27BDFFD8 AFBF0024 AFB30020 AFB2001C AFB10018 AFB00014 2488FFFF 01064021
24A6FFFF 00C73021 3C0A9D00 8D470094 8CE90000 8D470098 8CEA0000 012A382B
10E00003 01405821 01205821 01404821 3C079D00 8CE70090 80EA0015 24070002
15470008 24070004 00801821 01001021 00A08821 00C08021 00A09821 10000019
00809021 1547000C 24070001 00084027 010B1821 00041027 004B1021 00063027
00C98821 00058027 02098021 02009821 10000016 00409021 1547000B 24070003
00063027 00CB1821 00051027 004B1021 00808821 01008021 00809821 1000000B
00409021 24070003 15470008 00084027 00A01821 00C01021 01098821 00048027
02098021 02009821 00A09021 00021200 24040044 00432825 0411FE27 00000000
24040045 02202821 0411FE23 00000000 24040046 02002821 0411FE1F 00000000
2404004E 02402821 0411FE1B 00000000 2404004F 02602821 0411FE17 00000000
3C03BF88 24051000 AC656134 3C02BF81 8C44F220 AC606430 8C44F220 24040800
AC646134 8C46F220 AC646138 8C46F220 24060022 AC666430 8C46F220 AC646134
8C46F220 AC646138 8C44F220 AC656138 8C42F220 8FBF0024 8FB30020 8FB2001C
8FB10018 8FB00014 03E00008 27BD0028
'DrawRectangle_SSD1289
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 0411FF5A 00000000 00103403 30C600FC 00103A03 321000FC 10D00005
30E700FC 1620002D 2625FFFF 10000045 8FBF001C 14C7FFFB 3C03BF88 AC666430
3C02BF81 8C44F220 24040800 AC646134 8C45F220 AC646138 8C45F220 AC646134
8C45F220 AC646138 8C45F220 AC646134 8C45F220 AC646138 8C42F220 2631FFFF
1220002F 2631FFFF 3C04BF88 24030800 3C02BF81 2405FFFF AC836134 8C46F220
AC836138 8C46F220 AC836134 8C46F220 AC836138 8C46F220 AC836134 8C46F220
AC836138 8C46F220 2631FFFF 1625FFF2 8FBF001C 1000001C 8FB10018 3C03BF88
3C02BF81 24040800 2408FFFF AC666430 8C49F220 AC646134 8C49F220 AC646138
8C49F220 AC676430 8C49F220 AC646134 8C49F220 AC646138 8C49F220 AC706430
8C49F220 AC646134 8C49F220 AC646138 8C49F220 24A5FFFF 14A8FFEC 00000000
8FBF001C 8FB10018 8FB00014 03E00008 27BD0020
'DrawBitmap_SSD1289
27BDFFA8 AFBF0054 AFBE0050 AFB7004C AFB60048 AFB50044 AFB40040 AFB3003C
AFB20038 AFB10034 AFB00030 AFA40058 AFA5005C 00C09021 AFA70064 8FB00068
8FB7006C 8FB40070 8FB30074 3C029D00 8C430094 8C710000 8C420098 8C420000
AFA2001C 00171403 304200FC AFA20010 0017F203 33DE00FC 32F700FC 0014B403
32D600FC 0014AA03 32B500FC 72063002 72073802 0411FEE1 00000000 8FA20064
1840007A 329400FC 0200C021 8FA3005C AFA30020 00122023 AFA40028 70521002
2442FFFF AFA20018 AFB2002C 00007821 AFA00024 24190001 3C06BF88 3C05BF81
10000066 24070800 04400031 0051202B 50800030 24630001 0542002E 24630001
5180002C 24630001 91C40000 008D2024 10800015 8FA40010 ACC46430 8CA4F220
ACC76134 8CA4F220 ACC76138 8CA4F220 ACDE6430 8CA4F220 ACC76134 8CA4F220
ACC76138 8CA4F220 ACD76430 8CA4F220 ACC76134 8CA4F220 ACC76138 8CA4F220
10000014 24630001 ACD66430 8CA4F220 ACC76134 8CA4F220 ACC76138 8CA4F220
ACD56430 8CA4F220 ACC76134 8CA4F220 ACC76138 8CA4F220 ACD46430 8CA4F220
ACC76134 8CA4F220 ACC76138 8CA4F220 24630001 1470FFCC 24420001 25080001
2529FFFF 11120010 01785821 010F1021 24430007 284E0000 006E100B 000270C3
026E7021 000917C3 00021742 01226821 31AD0007 01A26823 01B96804 01601021
1000FFB9 00001821 8FA20014 24420001 AFA20014 14500004 254A0001 10000009
8FA40024 AFA00014 1A40FFF7 8FAB0058 8FA90018 00004021 8FA3001C 1000FFE3
0143602B 24840001 AFA40024 8FA20020 00581021 AFA20020 8FA30018 8FA40028
00641821 AFA30018 8FA2002C 8FA30024 8FA40064 10640005 01E27821 1E00FFE9
8FAA0020 1000FFEF 8FA40024 8FBF0054 8FBE0050 8FB7004C 8FB60048 8FB50044
8FB40040 8FB3003C 8FB20038 8FB10034 8FB00030 03E00008 27BD0058
End CSUB
Edited by matherp 2015-10-18
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8648
Posted: 04:01am 24 Jun 2016
Copy link to clipboard 
Print this post

Updated version of the SSD1289 driver that implements improved error checking on text which overlaps the screen real-estate

Seen here being used to run Geoff's Super Clock software on a 44-pin MM backpack PCB





44-pin version - see comments section for pin usage

sub mm.startup
SSD1289_44(42,1) ' reset pin, orientation
end sub

'**********Append this code and below onto the end of your MMBasic program***********
'
' Copyright (c) Peter Mather 2015
'
' Initialise the Display Driver for SSD1289 controlled TFT LCD Panel in 8-bit databus, 18-bit mode
' i.e. RGB666. This is optimised for the 44-pin uM2 and uses defined pinout except for the reset pin
'
' SSD1289_44 initialises the loadable CFunction driver so that you can use all of the
' MMBasic graphic commands in your program.
' Parameters:
' RST% is pin number of Reset signal
' Orient% LANDSCAPE=1,PORTRAIT=2,RLANDSCAPE=3,RPORTRAIT=4
'
' After Calling SSD1289_44, 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
' you must use pin 4 for RS and pin 5 for WR
' Tie CS Low and tie RD high
'
' Ver 1.2 2016-06-24 Improved bitmap error handling
'
'**********************************************************************************

'
CSUB SSD1289_44
000001AA
'writeRegister
7C833A00 34630200 3C02BF88 AC436230 24030200 AC436234 AC436238 308400FF
34840200 AC446230 AC436234 AC436238 7CA43A00 34840300 AC446230 AC436234
AC436238 30A500FF 34A50300 AC456230 AC436234 AC436238 03E00008 00000000
'defineregion
27BDFFD8 AFBF0024 AFB30020 AFB2001C AFB10018 AFB00014 2490FFFF 02063021
24B0FFFF 02078021 3C089D00 8D020094 8C430000 8D020098 8C480000 0068102B
10400003 01004821 00604821 01001821 3C029D00 8C420090 80480015 24020002
11020009 00801021 24020004 1102000B 00061027 24020001 5502001A 00A01021
10000010 00108027 00C04021 00A08821 00A09821 1000001A 00809021 00491021
00042027 00894021 00108027 02038821 00058027 02038021 02009821 10000010
01009021 02091021 00052827 00A94021 00808821 00C08021 00809821 10000008
01009021 02004021 00068827 02238821 00048027 02038021 02009821 00A09021
00082A00 24040044 00A22825 0411FFA4 00000000 24040045 02202821 0411FFA0
00000000 24040046 02002821 0411FF9C 00000000 2404004E 02402821 0411FF98
00000000 2404004F 02602821 0411FF94 00000000 3C02BF88 24030200 AC436230
AC436234 AC436238 24040222 AC446230 AC436234 AC436238 8FBF0024 8FB30020
8FB2001C 8FB10018 8FB00014 03E00008 27BD0028
'DrawBitmap_SSD1289
27BDFFB8 AFBF0044 AFBE0040 AFB7003C AFB60038 AFB50034 AFB40030 AFB3002C
AFB20028 AFB10024 AFB00020 0080F021 AFA5004C 00C0B021 AFA70054 8FB3005C
8FB00060 8FB70064 28A50000 8FA2004C 0005100B 00402821 28840000 00003021
03C4300A 00C02021 27C3FFFF 8FA20058 70563002 00C31821 3C029D00 8C420094
8C420000 0062302B 2442FFFF 0046180A 24A2FFFF 8FA60058 70C74002 01021021
3C069D00 8CC60098 8CC60000 0046382B 24C6FFFF 00C7100A 0013AC03 32B500FC
36B50300 0013A203 329400FC 36940300 327300FC 36730300 00109403 325200FC
36520300 00108A03 323100FC 36310300 321000FC 24070001 00E43023 00E53823
00C33021 00E23821 0411FF58 00000000 8FA20054 18400064 36100300 00162823
AFA50014 7056C802 2739FFFF AFB60018 8FAF004C 00006021 AFA00010 8FAE0058
3C079D00 240D0001 3C03BF88 10000051 24040200 25EF0001 25E2FFFF 04400042
00000000 8CE20098 8C420000 004F102B 1440004E 8FBF0044 1EC0002B 03205021
10000039 00000000 24420001 2445FFFF 04A0001E 00000000 8CE50094 8CA50000
00A2282B 14A00019 00000000 91250000 00A82824 10A0000C 00000000 AC756230
AC646234 AC646238 AC746230 AC646234 AC646238 AC736230 AC646234 AC646238
1000000A 00000000 AC726230 AC646234 AC646238 AC716230 AC646234 AC646238
AC706230 AC646234 AC646238 5446FFDF 24420001 256B0001 15760005 254AFFFF
10000011 00000000 03C01021 00005821 016C2821 24A60007 28A90000 00C9280B
000548C3 02E94821 000A2FC3 00052F42 01454021 31080007 01054023 010D4004
1000FFC9 004E3021 55F8FFBB 25EF0001 8FA20010 24420001 AFA20010 8FA50014
0325C821 8FA60018 8FA80054 10480006 01866021 8FA20058 1C40FFAE 01E2C021
1000FFF4 8FA20010 8FBF0044 8FBE0040 8FB7003C 8FB60038 8FB50034 8FB40030
8FB3002C 8FB20028 8FB10024 8FB00020 03E00008 27BD0048
'DrawRectangle_SSD1289
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 0411FEB3 00000000 00102C03 30A500FC 34A50300 00103203 30C600FC
321000FC 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
'getFPC
27BDFFF8 AFBF0004 00852023 03E42021 ACC40000 8FBF0004 03E00008 27BD0008
'main
27BDFFA8 AFBF0054 AFB40050 AFB3004C AFB20048 AFB10044 AFB00040 00809021
00A08821 27B30038 00002021 3C059D00 24A506E8 02603021 0411FFE9 00000000
8FA20038 3C149D00 26940A00 0282A021 8FA30038 3C109D00 8E02002C 3C049D00
24840A90 0040F809 00832021 8E020090 8E230000 A0430015 8E020090 8E430000
A043002E 24020019 AFA20018 2402001A AFA2001C 2402001B AFA20020 24020024
AFA20024 24020025 AFA20028 24020026 AFA2002C 24020002 AFA20030 24020003
AFA20034 27B20018 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 8E030090 8E02001C 8064002E 0040F809 24050006 8E030090
8E02001C 8064002E 0040F809 24050006 8E020004 0040F809 24042710 8E030090
8E02001C 8064002E 0040F809 24050005 8E020004 0040F809 24042710 8E030090
8E02001C 8064002E 0040F809 24050006 8E020004 0040F809 24042710 02808021
00008821 24120048 96040000 96050002 0411FDC9 00000000 26310002 1632FFFA
26100004 3C029D00 8C420090 80420015 24030002 10430009 24054070 24030004
10430006 24054040 38420001 24034058 24044068 00602821 0082280A 24040011
0411FDB5 00000000 3C029D00 8C420090 90420015 30420001 10400008 3C029D00
8C430098 240400F0 AC640000 8C420094 24030140 10000007 AC430000 8C430094
240400F0 AC640000 8C420098 24030140 AC430000 8FA50038 3C029D00 8C430048
3C049D00 248404CC 00852021 AC640000 8FA50038 8C43004C 3C049D00 248401F4
00852021 AC640000 8C430048 8C440094 8C860000 8C420098 8C470000 AFA00010
8C620000 00002021 00002821 24C6FFFF 0040F809 24E7FFFF 8FBF0054 8FB40050
8FB3004C 8FB20048 8FB10044 8FB00040 03E00008 27BD0058
'.rodata
'_initData
00010000 A8A40003 0000000C 080C000D 2B00000E 00B7001E 2B3F0001 06000002
00000010 60700011 00000005 00000006 0EF10016 00030017 02330007 0000000B
0000000F 00000041 00000042 00000048 013F0049 0000004A 0000004B 07070030
02040031 02040032 05020033 05070034 02040035 02040036 05020037 0302003A
0302003B 00000023 00000024 80000025
'_testData
64616F4C 20676E69 31445353 20393832 76697264 0A0D7265 00000000
End CSUB


64-pin version

sub mm.startup
SSD1289_V64 1 ' parameter is the orientation )
end sub

'**********Append this code and below onto the end of your MMBasic program***********
'
' Copyright (c) Peter Mather 2015
'
' 64-pin MM+ Display Driver for SSD1289 controlled TFT LCD Panel in 8-bit databus, 18-bit mode
' i.e. RGB666.
'
' SSD1289 initialises the loadable CFunction driver
' After calling SSD1289, any of the usual MM Graphic commands may be used
' in your MMBasic program, eg BOX, TEXT, LINE, CIRCLE, GUI etc
'
' Orientations are: LANDSCAPE=1,PORTRAIT=2,RLANDSCAPE=3 ,RPORTRAIT=4
'
'
' Note: you must use pins defined in the Micromite manual for the SSD1963
' Tie CS Low and tie RD high
'
' Ver 1.2 2016-06-24 Improved bitmap error handling
'
'**********************************************************************************

'
CSUB SSD1289_V64
000001EE
'writeRegister
3C02BF88 24071000 AC476134 3C03BF81 8C66F220 7C863A00 34C60800 AC466430
24060800 AC466134 8C68F220 AC466138 8C68F220 308400FF 34840800 AC446430
AC466134 8C64F220 AC476138 8C64F220 AC466138 8C64F220 7CA43A00 34841800
AC446430 AC466134 8C64F220 AC466138 8C64F220 30A500FF 34A51800 AC456430
AC466134 8C64F220 AC466138 8C62F220 03E00008 00000000
'defineregion
27BDFFD8 AFBF0024 AFB30020 AFB2001C AFB10018 AFB00014 2490FFFF 02063021
24B0FFFF 02078021 3C089D00 8D020094 8C430000 8D020098 8C480000 0068102B
10400003 01004821 00604821 01001821 3C029D00 8C420090 80480015 24020002
11020009 00801021 24020004 1102000B 00061027 24020001 5502001A 00A01021
10000010 00108027 00C04021 00A08821 00A09821 1000001A 00809021 00491021
00042027 00894021 00108027 02038821 00058027 02038021 02009821 10000010
01009021 02091021 00052827 00A94021 00808821 00C08021 00809821 10000008
01009021 02004021 00068827 02238821 00048027 02038021 02009821 00A09021
00082A00 24040044 00A22825 0411FF96 00000000 24040045 02202821 0411FF92
00000000 24040046 02002821 0411FF8E 00000000 2404004E 02402821 0411FF8A
00000000 2404004F 02602821 0411FF86 00000000 3C02BF88 24031000 AC436134
3C03BF81 8C64F220 24040800 AC446430 AC446134 8C65F220 AC446138 8C65F220
24050822 AC456430 AC446134 8C65F220 AC446138 8C62F220 8FBF0024 8FB30020
8FB2001C 8FB10018 8FB00014 03E00008 27BD0028
'DrawBitmap_SSD1289
27BDFFB8 AFBF0044 AFBE0040 AFB7003C AFB60038 AFB50034 AFB40030 AFB3002C
AFB20028 AFB10024 AFB00020 AFA40048 AFA5004C 00C0B021 AFA70054 8FB3005C
8FB00060 8FB70064 28A50000 8FA2004C 0005100B 00402821 28840000 8FA60048
0004300B 00C02021 8FA70048 24E3FFFF 8FA20058 70563002 00C31821 3C029D00
8C420094 8C420000 0062302B 2442FFFF 0046180A 24A2FFFF 8FA60058 8FA70054
70C74002 01021021 3C069D00 8CC60098 8CC60000 0046382B 24C6FFFF 00C7100A
0013AC03 32B503FC 36B51800 0013A203 329403FC 36941800 327303FC 36731800
00109403 325203FC 36521800 00108A03 323103FC 36311800 321003FC 36101800
24070001 00E43023 00E53823 00C33021 00E23821 0411FF4D 00000000 24031000
3C02BF88 AC436138 3C02BF81 8C42F220 8FA20054 18400070 00163023 AFA60014
7056F002 27DEFFFF AFB60018 8FB8004C 00006821 AFA00010 8FAF0058 3C089D00
240E0001 3C03BF88 24050800 1000005D 3C04BF81 27180001 2702FFFF 0440004E
00000000 8D020098 8C420000 0058102B 1440005A 8FBF0044 1EC00037 03C05821
10000045 00000000 24420001 2446FFFF 04C0002A 00000000 8D060094 8CC60000
00C2302B 14C00025 00000000 91460000 00C93024 10C00012 00000000 AC756430
AC656134 8C86F220 AC656138 8C86F220 AC746430 AC656134 8C86F220 AC656138
8C86F220 AC736430 AC656134 8C86F220 AC656138 8C86F220 10000010 00000000
AC726430 AC656134 8C86F220 AC656138 8C86F220 AC716430 AC656134 8C86F220
AC656138 8C86F220 AC706430 AC656134 8C86F220 AC656138 8C86F220 5447FFD3
24420001 258C0001 15960005 256BFFFF 10000011 00000000 8FA20048 00006021
018D3021 24C70007 28CA0000 00EA300B 000650C3 02EA5021 000B37C3 00063742
01664821 31290007 01264823 012E4804 1000FFBD 004F3821 5719FFAF 27180001
8FA20010 24420001 AFA20010 8FA60014 03C6F021 8FA70018 8FA60054 10460006
01A76821 8FA70058 1CE0FFA2 0307C821 1000FFF4 8FA20010 8FBF0044 8FBE0040
8FB7003C 8FB60038 8FB50034 8FB40030 8FB3002C 8FB20028 8FB10024 8FB00020
03E00008 27BD0048
'DrawRectangle_SSD1289
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 0411FE97 00000000 24031000 3C02BF88 AC436138 3C02BF81 8C42F220
00103403 30C603FC 34C61800 00103A03 30E703FC 321003FC 36101800 10D00005
34E71800 1620002C 2625FFFF 10000041 8FBF001C 14C7FFFB 3C02BF88 AC466430
24040800 AC446134 3C03BF81 8C65F220 AC446138 8C65F220 AC446134 8C65F220
AC446138 8C65F220 AC446134 8C65F220 AC446138 8C62F220 2631FFFF 1220002C
2631FFFF 3C04BF88 24030800 3C02BF81 2405FFFF AC836134 8C46F220 AC836138
8C46F220 AC836134 8C46F220 AC836138 8C46F220 AC836134 8C46F220 AC836138
8C46F220 2631FFFF 1625FFF2 8FBF001C 10000019 8FB10018 3C02BF88 24040800
3C03BF81 2408FFFF AC466430 AC446134 8C69F220 AC446138 8C69F220 AC476430
AC446134 8C69F220 AC446138 8C69F220 AC506430 AC446134 8C69F220 AC446138
8C69F220 24A5FFFF 14A8FFEF 00000000 8FBF001C 8FB10018 8FB00014 03E00008
27BD0020
'getFPC
27BDFFF8 AFBF0004 00852023 03E42021 ACC40000 8FBF0004 03E00008 27BD0008
'main
27BDFFA8 AFBF0054 AFB40050 AFB3004C AFB20048 AFB10044 AFB00040 00808821
27B30038 00002021 3C059D00 24A507F4 02603021 0411FFEA 00000000 8FA20038
3C149D00 26940B18 0282A021 8FA30038 3C109D00 8E02002C 3C049D00 24840BA8
0040F809 00832021 8E020090 8E230000 A0430015 8E020090 2403001C A043002E
2402003C AFA20018 2402003D AFA2001C 2402003E AFA20020 2402003F AFA20024
24020040 AFA20028 24020001 AFA2002C 24020002 AFA20030 24020003 AFA20034
27B20018 8E510000 8E020010 02202021 24050008 0040F809 00003021 8E020010
02202021 24050065 0040F809 00003021 8E02001C 02202021 0040F809 24050005
26520004 5653FFF0 8E510000 3C109D00 8E020010 2404001B 24050008 0040F809
00003021 8E020010 2404001B 24050065 0040F809 00003021 3C11BF88 24021000
AE226138 3C12BF81 8E42F220 8E020010 24040018 24050008 0040F809 00003021
8E020010 24040018 24050065 0040F809 00003021 24020800 AE226138 8E42F220
8E030090 8E020010 8064002E 24050008 0040F809 00003021 8E030090 8E020010
8064002E 24050065 0040F809 00003021 8E030090 8E02001C 8064002E 0040F809
24050006 8E030090 8E02001C 8064002E 0040F809 24050006 8E020004 0040F809
24042710 8E030090 8E02001C 8064002E 0040F809 24050005 8E020004 0040F809
24042710 8E030090 8E02001C 8064002E 0040F809 24050006 8E020004 0040F809
24042710 02808021 00008821 24120048 96040000 96050002 0411FD83 00000000
26310002 1632FFFA 26100004 3C029D00 8C420090 80420015 24030002 10430009
24054070 24030004 10430006 24054040 38420001 24034058 24044068 00602821
0082280A 24040011 0411FD6F 00000000 3C029D00 8C420090 90420015 30420001
10400008 3C029D00 8C430098 240400F0 AC640000 8C420094 24030140 10000007
AC430000 8C430094 240400F0 AC640000 8C420098 24030140 AC430000 8FA50038
3C029D00 8C430048 3C049D00 24840574 00852021 AC640000 8FA50038 8C43004C
3C049D00 2484024C 00852021 AC640000 8C430048 8C440094 8C860000 8C420098
8C470000 AFA00010 8C620000 00002021 00002821 24C6FFFF 0040F809 24E7FFFF
8FBF0054 8FB40050 8FB3004C 8FB20048 8FB10044 8FB00040 03E00008 27BD0058
'.rodata
'_initData
00010000 A8A40003 0000000C 080C000D 2B00000E 00B7001E 2B3F0001 06000002
00000010 60700011 00000005 00000006 0EF10016 00030017 02330007 0000000B
0000000F 00000041 00000042 00000048 013F0049 0000004A 0000004B 07070030
02040031 02040032 05020033 05070034 02040035 02040036 05020037 0302003A
0302003B 00000023 00000024 80000025
'_testData
64616F4C 20676E69 31445353 20393832 76697264 0A0D7265 00000000
End CSUB


C source

/*******************************************************************************
*
* Driver for SSD1289 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
* Driver_SSD1289
*
* Entry point is function long long main(long long *MyAddress,long long *func,
* long long *RST,
* long long *orientation)
*
* V1.0 2015-07-21 Peter Mather
* V1.01 Change orientation codes to 1:landscape, 2:portrait, 3:rlandscape, 4:rportrait
* V1.1 2016-01-28 Selectable 44 or 64-pin
* V1.21 2016-06-24 Improved bitmap error handling
*
******************************************************************************/
#include <stdarg.h>
#include <xc.h> // Required for SFR defs
#include <sys/attribs.h> // Required to use __longramfunc__


#define Version 120 //Version 1.20

#include "../cfunctions.h"
#define MX470
#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;wt=DEVID;}
#define RSHi {setport=RS_Pin;wt=DEVID;}
#define WRLo {clrport=WR_Pin;wt=DEVID;}
#define WRHi {setport=WR_Pin;wt=DEVID;}
#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 writeRegister(unsigned int command, unsigned int data){
#ifdef MX470
int wt;
RSLo;
#endif
port=(((command>>8) & 0xFF) | WR_Pin);
WRLo;
// int i=DEVID;
WRHi;
port=(((command) & 0xFF) | WR_Pin);
WRLo;
// i=DEVID;
#ifdef MX470
RSHi;
#endif
WRHi;
port=(((data>>8) & 0xFF) | Both);
WRLo;
// i=DEVID;
WRHi;
port=(((data) & 0xFF) | Both);
WRLo;
// i=DEVID;
WRHi;
return;
}
/*******************************************************************************
*
* defines start/end coordinates for memory access from host to SSD1289
* 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){ //SSD1289
long x1=x,x2=x+width-1,y1=y,y2=y+height-1;
unsigned long xstart,xend,ystart,yend,xp,yp,Vertical,Horizontal;
if(HRes<VRes){
Vertical=VRes;
Horizontal=HRes;
}
else {
Vertical=HRes;
Horizontal=VRes;
}
switch(Option->DISPLAY_ORIENTATION){
case PORTRAIT:
xstart = x1;
xend = x2;
ystart = y1;
yend = y2;
xp=xstart; yp=ystart;
break;
case RPORTRAIT:
xstart = (Horizontal - 1) - x2;
xend = (Horizontal - 1) - x1;
ystart = (Vertical - 1) - y2;
yend = (Vertical - 1) - y1;
xp=xend; yp=yend;
break;
case LANDSCAPE:
xstart = (Horizontal - 1) - y2;
xend = (Horizontal - 1) - y1;
ystart = x1;
yend = x2;
xp=xend; yp=ystart;
break;
default:
xstart = y1;
xend = y2;
ystart = (Vertical - 1) - x2;
yend = (Vertical - 1) - x1;
xp=xstart; yp=yend;
break;
}
writeRegister(0x44,xstart | (xend<<8));
writeRegister(0x45,ystart);
writeRegister(0x46,yend);
writeRegister(0x4E,xp);
writeRegister(0x4F,yp);
#ifdef MX470
int wt;
RSLo;
#endif
port= WR_Pin;
WRLo;
WRHi;
port=(0x22 | WR_Pin);
WRLo;
WRHi;
}



/***********************************************************************************************
* 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_SSD1289(int x1, int y1, int width, int height, int scale, int fc, int bc, unsigned char *bitmap ){
long i, j, k, m;
unsigned int fch,fcm,fcl,bch,bcm,bcl;
int vertCoord, horizCoord, XStart, XEnd, YEnd;
// adjust when part of the bitmap is outside the displayable coordinates
vertCoord = y1; if(y1 < 0) y1 = 0; // the y coord is above the top of the screen
XStart = x1; if(XStart < 0) XStart = 0; // the x coord is to the left of the left marginn
XEnd = x1 + (width * scale) - 1; if(XEnd >= HRes) XEnd = HRes - 1; // the width of the bitmap will extend beyond the right margin
YEnd = y1 + (height * scale) - 1; if(YEnd >= VRes) YEnd = VRes - 1;// the height of the bitmap will extend beyond the bottom margin

fch=(fc>>16) & 0x3FC | Both;
fcm=(fc>>8) & 0x3FC | Both;
fcl=fc & 0x3FC | Both;
bch=(bc>>16) & 0x3FC | Both;
bcm=(bc>>8) & 0x3FC | Both;
bcl=bc & 0x3FC | Both;


defineregion(XStart,y1,XEnd-XStart+1,YEnd-y1+1);
#ifdef MX470
int wt;
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
if(vertCoord++ < 0) continue; // we are above the top of the screen
if(vertCoord > VRes) return; // we have extended beyond the bottom of the screen
horizCoord = x1;
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(horizCoord++ < 0) continue; // we have not reached the left margin
if(horizCoord > HRes) continue; // we are beyond the right margin
if((bitmap[((i * width) + k)/8] >> (((height * width) - ((i * width) + k) - 1) %8)) & 1) {
port=fch;WRLo;WRHi;
port=fcm;WRLo;WRHi;
port=fcl;WRLo;WRHi;
} else {
port=bch;WRLo;WRHi;
port=bcm;WRLo;WRHi;
port=bcl;WRLo;WRHi;
}
}
}
}
}
}

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

void DrawRectangle_SSD1289(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
int wt;
RSHi;
#endif
// convert the colours to 565 format
ch=(fc>>16) & 0x3FC | Both;
cm=(fc>>8) & 0x3FC | Both;
cl=fc & 0x3FC | 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;
}
}
}
__attribute__((noinline)) void getFPC(void *a, void *b, volatile unsigned int *c)
{
*c = (unsigned int) (__builtin_return_address (0) - (b -a)) ;
}

/*******************************************************************************
*
* Driver_SSD1289 : Initialise the CFunction Driver Sub-System
*
* Function called to initialise the driver SubSystem
*
* OpenDriver_SSD1289 is ALWAYS called from an MMBasic program
* On exit, vectors DrawRectangleVector, and DrawBitmapVector will
* be set to point to the CFunctions DrawRectangle_SSD1289 and
* DrawBitmap_SSD1289 respectively
*
******************************************************************************/
//CFunction Driver_SSD1289
#ifdef MX470
void main(long long *orientation){
#else
void main(long long *RST,long long *orientation){
#endif //Close Driver Request ?
int t,HorizontalRes,VerticalRes;


int j;
unsigned int p[8];
volatile unsigned int libAddr ;
getFPC(NULL,&&getFPCLab,&libAddr) ; // warning can be ignored, stupid editor
getFPCLab: { }

static const unsigned short _initData[] = {
0x00,0x0001,0x03,0xA8A4,0x0C,0x0000,0x0D,0x080C,0x0E,0x2B00,0x1E,0x00B7,
0x01,0x2B3F,0x02,0x0600,0x10,0x0000,0x11,0x6070,0x05,0x0000,0x06,0x0000,
0x16,0xEF1,0x17,0x0003,0x07,0x0233,0x0B,0x0000,0x0F,0x0000,0x41,0x0000,
0x42,0x0000,0x48,0x0000,0x49,0x013F,0x4A,0x0000,0x4B,0x0000,0x30,0x0707,
0x31,0x0204,0x32,0x0204,0x33,0x0502,0x34,0x0507,0x35,0x0204,0x36,0x0204,
0x37,0x0502,0x3A,0x0302,0x3B,0x0302,0x23,0x0000,0x24,0x0000,0x25,0x8000};
unsigned short * initData = (unsigned short *)((void *)_initData + libAddr );
static const char _testData[]="Loading SSD1289 driver\r\n";
unsigned char * testData = (unsigned char *)((void *)_testData + libAddr );
MMPrintString(testData);
Option->DISPLAY_ORIENTATION=*orientation;
#ifdef MX470
int wt;
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;

ExtCfg(Option->LCD_Reset,EXT_DIG_OUT,0);ExtCfg(Option->LCD_Reset,EXT_BOOT_RESERVED,0);
PinSetBit(Option->LCD_Reset, LATSET);


HorizontalRes=240;
VerticalRes=320;

/************************************************
*
* Initialise the SSD1289
*
***********************************************/

//Reset the SSD1289
PinSetBit(Option->LCD_Reset,LATSET);
uSec(10000);
PinSetBit(Option->LCD_Reset,LATCLR);
uSec(10000);
PinSetBit(Option->LCD_Reset,LATSET);
uSec(10000);
for(j=0;j<72;j+=2)writeRegister(initData[j],initData[j+1]);
//Set Hres and VRes
switch(Option->DISPLAY_ORIENTATION){
case PORTRAIT:
t=0x4070;
break;

case RPORTRAIT:
t=0x4040;
break;

case LANDSCAPE:
t=0x4068;
break;

default:
t=0x4058;
}
writeRegister(0x11,t);
if(Option->DISPLAY_ORIENTATION&1){ //landscape is not default
VRes=HorizontalRes;
HRes=VerticalRes;
} else {
HRes=HorizontalRes;
VRes=VerticalRes;
}

//Save the current values of the Vectors

//Set the DrawRectangle vector to point to our function
DrawRectangleVector= (unsigned int)&DrawRectangle_SSD1289 + libAddr;

//Set the DrawBitmap vector to point to our function
DrawBitmapVector=(unsigned int)&DrawBitmap_SSD1289 + libAddr;

//Draw a black box = CLS
DrawRectangle(0,0,HRes-1,VRes-1,0x000000);

}


 
Print this page


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

© JAQ Software 2024