Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 03:26 10 May 2025 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 : uM2(+): 64x32 RGB LED matrix display

     Page 1 of 4    
Author Message
matherp
Guru

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



I've got a loadable driver for the 64x32 RGB LED displays like this one working (13x26cm).

This needs 13 pins to drive the display and an external 4A 5V power supply to light all pixels in white.

The driver allows you to use all the normal Micromite commands: BOX, TEXT, CLS etc. to drive the display and implements the background scanning transparently.

The driver currently implements 8 colours i.e. 3 bits per pixel but I can expand this if I optimise the code.

Let me know if this is interesting and I'll work to enhance the functionality.

Current refresh rate is 62.5FPS on an MX170 Micromite so everyone except WW should find it reasonably flicker free

I'll mock up a changing demo tomorrow to put on youtube
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3269
Posted: 11:55am 28 Jun 2016
Copy link to clipboard 
Print this post

Wow! The thing that impresses is that your code makes it look like a giant LCD.

Fantastic.
Geoff Graham - http://geoffg.net
 
Bill7300
Senior Member

Joined: 05/08/2014
Location: Australia
Posts: 159
Posted: 01:43pm 28 Jun 2016
Copy link to clipboard 
Print this post

It certainly is interesting Peter, so please continue to develop it.

Bill
Bill
 
Bill.b

Senior Member

Joined: 25/06/2011
Location: Australia
Posts: 232
Posted: 07:55pm 28 Jun 2016
Copy link to clipboard 
Print this post

This supplier will not ship to Australia.

here is an alternate supplier that will ship free to aus,
http://www.dhgate.com/store/product/64x32-led-display-module-dot-matrix-p4-smd/375713973.html.

price is approximately AU$30.00


Bill
In the interests of the environment, this post has been constructed entirely from recycled electrons.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10066
Posted: 12:15am 29 Jun 2016
Copy link to clipboard 
Print this post

Drivers for 44-pin MX170 and 64-pin MX470 attached below. These now support RGB222, i.e. 64 colours. Coding for the colours is in the top two bits. Pinout is defined in the files. The driver uses 4K of flash memory and 6K or RAM. A driver for the 28-pin part is possible but would be 8 colour only and would still take 13 output pins to drive the display.

64-pin

Option explicit
option default NONE
'
' 64x32 RGB LED display driver for 64-pin Micromite
' operates in RGB222 mode
'
' freely selectable pins
' OE
' CLK
' LAT
'
' connect other pins as follows
' HA=2
' HB=3
' HC=27
' HD=24
' R1=60
' G1=61
' B1=62
' R2=63
' G2=64
' B2=1
'
sub MM.startup
const OE=21
const CLK=51
const LAT=52
RGBled64(LAT, CLK, OE)
font 8
end sub

CSub RGBled64
000001F0
'updatedisplay
27BDFFD0 AFBF002C AFB50028 AFB40024 AFB30020 AFB2001C AFB10018 AFB00014
3C109D00 8E02008C 8C510000 8E030090 8E020028 0040F809 8064002D 24120001
00529004 8E030090 8E020024 8064002D 0040F809 24050006 0040A021 8E030090
8E020024 8064002D 0040F809 24050005 00409821 92301803 3A100002 24020080
24030040 0070100A 00408021 92351802 3C029D00 8C430090 8C42001C 8064002E
0040F809 24050006 92231801 240200F5 14620054 3C029D00 92221802 30420004
10400007 3C029D00 8C42001C 2404001B 0040F809 24050006 10000006 92221802
8C42001C 2404001B 0040F809 24050005 92221802 30420008 10400007 3C029D00
8C42001C 24040018 0040F809 24050006 10000006 001511C0 8C42001C 24040018
0040F809 24050005 001511C0 00151A40 00621823 24660180 0066102A 10400025
00711021 0015A980 3C08BF88 3C07BF81 32B500C0 90450000 02052824 36A40001
0085A80B 90450001 02052824 36A40002 0085A80B 90450002 02052824 36A40004
0085A80B 90450003 02052824 36A40008 0085A80B 90450004 02052824 36A40010
0085A80B 24630006 90450005 02052824 36A40020 0085A80B AD156430 AE920000
8CE4F220 AE720000 0066202A 1480FFE0 24420006 3C109D00 8E030090 8E02001C
8064002C 0040F809 24050006 8E030090 8E02001C 8064002C 0040F809 24050005
3C029D00 8C430090 8C42001C 8064002E 0040F809 24050005 92221802 24420001
3042000F 14400008 A2221802 92221803 24420001 304200FF 24030004 14430002
A2221803 A2201803 8FBF002C 8FB50028 8FB40024 8FB30020 8FB2001C 8FB10018
8FB00014 03E00008 27BD0030
'DrawRectangleMEM
27BDFFD0 AFBF002C AFB50028 AFB40024 AFB30020 AFB2001C AFB10018 AFB00014
00808021 00A09021 00C08821 00E09821 3C029D00 8C42008C 8C420000 90441801
240300F5 10830009 8FB40040 3C159D00 8EA2003C 0040F809 24041900 8EA3008C
AC620000 2403FFF5 A0431801 0211182A 14600005 0253182A 02001821 02208021
00608821 0253182A 14600005 2A030000 02401821 02609021 00609821 2A030000
0003800B 2403003F 2A040040 0064800A 2A240000 0004880B 2A240040 0064880A
2A430000 0003900B 2403001F 2A440020 0064900A 2A640000 0004980B 2A640020
0064980A 7E863C00 7E873A00 0230182A 14600022 329400FF 001219C0 00124240
01034023 00101840 001020C0 00831823 01034021 00484021 10000013 0272482A
28450010 50A00005 A0860000 A0660000 A0670001 10000003 A0740002 A0870001
A0940002 24420001 24630180 0262282A 10A0FFF3 24840180 26100001 0230102A
14400006 25080006 1520FFFB 02401021 2504E803 1000FFEA 01001821 8FBF002C
8FB50028 8FB40024 8FB30020 8FB2001C 8FB10018 8FB00014 03E00008 27BD0030
'DrawBitmapMEM
27BDFF80 AFBF007C AFBE0078 AFB70074 AFB60070 AFB5006C AFB40068 AFB30064
AFB20060 AFB1005C AFB00058 AFA40080 00A09021 00C0A021 AFA7008C 8FB00090
8FB30094 3C029D00 8C42008C 8C420000 90441801 240300F5 10830009 8FBE0098
3C119D00 8E22003C 0040F809 24041900 8E23008C AC620000 2403FFF5 A0431801
7E633C00 AFA30010 7E643A00 AFA40014 327300FF AFB30018 7FC53C00 AFA5001C
7FC73A00 AFA70020 8FA3008C 1860009A 33DE00FF 0200B021 AFB2003C 24030180
02030018 00002012 AFA40050 24040006 8FA50080 70A42002 72432802 00A41821
2463E803 00431821 AFA30038 00143823 AFA70044 8FA3008C 70741002 2442FFFF
AFA20034 AFB40048 0000A821 AFA00040 00101040 001090C0 02429023 02409821
24170001 AFBE0024 10000072 0280F021 00483821 2CE70040 50E00025 24420001
05220023 24420001 51800021 24420001 92270000 00F93824 10E0000F 00000000
12800007 8FA70010 A0C70000 8FA70014 A0C70001 8FA70018 10000014 A0C70002
A0670000 8FA70014 A0670001 8FA70018 1000000E A0670002 12800007 8FA7001C
A0870000 8FA70020 A0870001 8FA70024 10000006 A0870002 A0A70000 8FA70020
A0A70001 8FA70024 A0A70002 24420001 24630006 24840006 24A50006 1450FFD4
24C60006 254A0001 256BFFFF 01B26821 01D27021 01F37821 0313C021 115E0014
01164021 01551021 24430007 28510000 0071100B 000288C3 8FA2009C 00518821
000B17C3 00021742 0162C821 33390007 0322C823 0337C804 03003021 01E02821
01C02021 01A01821 1000FFB9 00001021 8FA30030 24630001 AFA30030 25290001
8FA40028 24840180 AFA40028 8FA5002C 24A50180 1070000C AFA5002C 1BC0FFF4
8FA80080 8FB8002C 8FAF0028 03007021 01E06821 8FAB0034 00005021 292C0020
1000FFD8 29340010 8FA70040 24E70001 AFA70040 8FA2003C 00561021 AFA2003C
8FA30038 8FA40050 00641821 AFA30038 8FA50034 8FA70044 00A72821 AFA50034
8FA20048 8FA30040 8FA4008C 1064000A 02A2A821 1A00FFEC 8FA50038 24A517FD
AFA5002C 8FA70038 AFA70028 8FA9003C 1000FFDA AFA00030 8FBF007C 8FBE0078
8FB70074 8FB60070 8FB5006C 8FB40068 8FB30064 8FB20060 8FB1005C 8FB00058
03E00008 27BD0080
'getFPC
27BDFFF8 AFBF0004 00852023 03E42021 ACC40000 8FBF0004 03E00008 27BD0008
'pstring
27BDFFE0 AFBF001C AFB00018 00808021 00002021 3C059D00 24A5079C 27A60010
0411FFEF 00000000 8FA40010 3C029D00 8C42002C 0040F809 02042021 8FBF001C
8FB00018 03E00008 27BD0020
'main
27BDFFA8 AFBF0054 AFB30050 AFB2004C AFB10048 AFB00044 00808021 00A08821
00C09021 00002021 3C059D00 24A507FC 27A60010 0411FFD7 00000000 3C029D00
8C430090 8E040000 A064002C 8C430090 8E240000 A064002D 8C420090 8E430000
A043002E 2402003C AFA20014 2402003D AFA20018 2402003E AFA2001C 2402003F
AFA20020 24020040 AFA20024 24020001 AFA20028 24020002 AFA2002C 24020003
AFA20030 2402001B AFA20034 24020018 AFA20038 27B20014 27B3003C 3C109D00
8E510000 8E020010 02202021 24050008 0040F809 00003021 8E020010 02202021
24050065 0040F809 00003021 8E02001C 02202021 0040F809 24050005 26520004
5653FFF0 8E510000 3C109D00 8E020094 24030040 AC430000 8E020098 24030020
AC430000 8E02003C 0040F809 24041900 00408821 8E02008C AC510000 2402FFF5
A2221801 8E030090 8E02001C 8064002E 0040F809 24050005 8E030090 8E020010
8064002E 24050008 0040F809 00003021 8E030090 8E020010 8064002E 24050065
0040F809 00003021 8E030090 8E02001C 8064002D 0040F809 24050005 8E030090
8E020010 8064002D 24050008 0040F809 00003021 8E030090 8E020010 8064002D
24050065 0040F809 00003021 8E030090 8E02001C 8064002C 0040F809 24050006
8E030090 8E020010 8064002C 24050008 0040F809 00003021 8E030090 8E020010
8064002C 24050065 0040F809 00003021 A2201802 A2201803 02201021 26311800
A0400000 24420001 5451FFFE A0400000 8FA50010 3C029D00 8C430048 3C049D00
2484026C 00852021 AC640000 8FA50010 8C43004C 3C049D00 2484040C 00852021
AC640000 8FA40010 8C4200B0 3C039D00 24630000 00641821 AC430000 24030320
3C02BF80 AC430E20 34038030 3C02BF80 AC430E00 2403001C 3C02BF88 AC4310E4
24030004 3C02BF88 AC4310E8 3C020100 3C03BF88 AC621034 3C03BF88 AC621064
3C03BF88 AC621068 3C049D00 24840AB4 0411FF38 00000000 8FBF0054 8FB30050
8FB2004C 8FB10048 8FB00044 03E00008 27BD0058
'.rodata
'startup
20424752 2064654C 76697264 6C207265 6564616F 000A0D64
End CSub
'
DefineFont #8 '8x6 font ideal for this display
5C200806
00000000 82200000 00800008 00004551 4F510000 0045F994 2B1CEA21 690000C2
B04C2090 AA104A62 84608046 00000000 40108410 81400081 00841004 A89C8A00
82000080 0080203E 30000000 00000042 0000003E 01000000 21000086 00004208
CAAA2972 82210027 00872008 21842072 42F8800F 00270A04 F824C510 0FFA0041
00270A02 8A3C0831 21F80027 00044108 8A9C2872 28720027 0027089E 61008601
86010080 00846000 40208410 0F000081 0000F880 10028140 20720084 00022084
BA9A2072 28720027 8028FAA2 8ABC28F2 2872002F 00278220 8AA248E2 08FA004E
800F823C 823C08FA 28720008 80278A2E 8ABE288A 82708028 00872008 12044138
4A8A0046 8048A230 82200882 6A8B800F 80288AAA 9AAA2C8A 28728028 00278AA2
82BC28F2 28720008 8046AAA2 A2BC28F2 087A8048 002F081C 200882F8 288A0082
00278AA2 89A2288A 288A0042 00A5AAAA 5208258A 288A8028 00822094 420821F8
0471800F 00074110 A9944AA9 4170804A 00471004 00804821 00000000 800F0000
00008140 07000000 80277A02 8A320B82 0700002F 00278220 8AA62608 07008027
0007FA22 41382431 E8010004 002778A2 8A320B82 06208028 00872008 12040310
09820046 0089C228 20088260 0D000087 8028AA2A 8A320B00 07008028 00278A22
F2220F00 06000008 802078A6 82320B00 07000008 002F7020 41100E41 08000023
80668AA2 89A20800 08000042 00A5AAA2 21940800 08008048 002778A2 21840F00
0400800F 0EE24028
End DefineFont


44-pin

Option explicit
option default NONE
'
' 64x32 RGB LED display driver for 44-pin Micromite
' operates in RGB222 mode
'
' freely selectable pins
' OE
' CLK
' LAT
'
' connect other pins as follows
' HA=2
' HB=3
' HC=4
' HD=5
' R1=25
' G1=26
' B1=27
' R2=36
' G2=37
' B2=38
'
sub MM.startup
const OE=13
const CLK=19
const LAT=12
RGBled44(LAT, CLK, OE)
font 8
end sub

CSub RGBled44
000001D2
'updatedisplay
27BDFFD0 AFBF002C AFB50028 AFB40024 AFB30020 AFB2001C AFB10018 AFB00014
3C109D00 8E02008C 8C540000 8E030090 8E020028 0040F809 8064003D 24110001
00518804 8E030090 8E020024 8064003D 0040F809 24050006 00409821 8E030090
8E020024 8064003D 0040F809 24050005 00409021 92901803 3A100002 24020080
24030040 0070100A 00408021 92951802 3C029D00 8C430090 8C42001C 8064003C
0040F809 24050006 92831801 240200F5 14620036 3C029D00 001511C0 00151A40
00621823 24660180 0066102A 10400023 00741021 0015A980 3C07BF88 32B503C0
90450000 02052824 36A40001 0085A80B 90450001 02052824 36A40002 0085A80B
90450002 02052824 36A40004 0085A80B 90450003 02052824 36A40008 0085A80B
90450004 02052824 36A40010 0085A80B 24630006 90450005 02052824 36A40020
0085A80B ACF56230 AE710000 AE510000 0066202A 1480FFE1 24420006 3C109D00
8E030090 8E02001C 8064003E 0040F809 24050006 8E030090 8E02001C 8064003E
0040F809 24050005 3C029D00 8C430090 8C42001C 8064003C 0040F809 24050005
92821802 24420001 3042000F 14400008 A2821802 92821803 24420001 304200FF
24030004 14430002 A2821803 A2801803 8FBF002C 8FB50028 8FB40024 8FB30020
8FB2001C 8FB10018 8FB00014 03E00008 27BD0030
'DrawRectangleMEM
27BDFFD0 AFBF002C AFB50028 AFB40024 AFB30020 AFB2001C AFB10018 AFB00014
00808021 00A09021 00C08821 00E09821 3C029D00 8C42008C 8C420000 90441801
240300F5 10830009 8FB40040 3C159D00 8EA2003C 0040F809 24041900 8EA3008C
AC620000 2403FFF5 A0431801 0211182A 14600005 0253182A 02001821 02208021
00608821 0253182A 14600005 2A030000 02401821 02609021 00609821 2A030000
0003800B 2403003F 2A040040 0064800A 2A240000 0004880B 2A240040 0064880A
2A430000 0003900B 2403001F 2A440020 0064900A 2A640000 0004980B 2A640020
0064980A 7E863C00 7E873A00 0230182A 14600022 329400FF 001219C0 00124240
01034023 00101840 001020C0 00831823 01034021 00484021 10000013 0272482A
28450010 50A00005 A0860000 A0660000 A0670001 10000003 A0740002 A0870001
A0940002 24420001 24630180 0262282A 10A0FFF3 24840180 26100001 0230102A
14400006 25080006 1520FFFB 02401021 2504E803 1000FFEA 01001821 8FBF002C
8FB50028 8FB40024 8FB30020 8FB2001C 8FB10018 8FB00014 03E00008 27BD0030
'DrawBitmapMEM
27BDFF80 AFBF007C AFBE0078 AFB70074 AFB60070 AFB5006C AFB40068 AFB30064
AFB20060 AFB1005C AFB00058 AFA40080 00A09021 00C0A021 AFA7008C 8FB00090
8FB30094 3C029D00 8C42008C 8C420000 90441801 240300F5 10830009 8FBE0098
3C119D00 8E22003C 0040F809 24041900 8E23008C AC620000 2403FFF5 A0431801
7E633C00 AFA30010 7E643A00 AFA40014 327300FF AFB30018 7FC53C00 AFA5001C
7FC73A00 AFA70020 8FA3008C 1860009A 33DE00FF 0200B021 AFB2003C 24030180
02030018 00002012 AFA40050 24040006 8FA50080 70A42002 72432802 00A41821
2463E803 00431821 AFA30038 00143823 AFA70044 8FA3008C 70741002 2442FFFF
AFA20034 AFB40048 0000A821 AFA00040 00101040 001090C0 02429023 02409821
24170001 AFBE0024 10000072 0280F021 00483821 2CE70040 50E00025 24420001
05220023 24420001 51800021 24420001 92270000 00F93824 10E0000F 00000000
12800007 8FA70010 A0C70000 8FA70014 A0C70001 8FA70018 10000014 A0C70002
A0670000 8FA70014 A0670001 8FA70018 1000000E A0670002 12800007 8FA7001C
A0870000 8FA70020 A0870001 8FA70024 10000006 A0870002 A0A70000 8FA70020
A0A70001 8FA70024 A0A70002 24420001 24630006 24840006 24A50006 1450FFD4
24C60006 254A0001 256BFFFF 01B26821 01D27021 01F37821 0313C021 115E0014
01164021 01551021 24430007 28510000 0071100B 000288C3 8FA2009C 00518821
000B17C3 00021742 0162C821 33390007 0322C823 0337C804 03003021 01E02821
01C02021 01A01821 1000FFB9 00001021 8FA30030 24630001 AFA30030 25290001
8FA40028 24840180 AFA40028 8FA5002C 24A50180 1070000C AFA5002C 1BC0FFF4
8FA80080 8FB8002C 8FAF0028 03007021 01E06821 8FAB0034 00005021 292C0020
1000FFD8 29340010 8FA70040 24E70001 AFA70040 8FA2003C 00561021 AFA2003C
8FA30038 8FA40050 00641821 AFA30038 8FA50034 8FA70044 00A72821 AFA50034
8FA20048 8FA30040 8FA4008C 1064000A 02A2A821 1A00FFEC 8FA50038 24A517FD
AFA5002C 8FA70038 AFA70028 8FA9003C 1000FFDA AFA00030 8FBF007C 8FBE0078
8FB70074 8FB60070 8FB5006C 8FB40068 8FB30064 8FB20060 8FB1005C 8FB00058
03E00008 27BD0080
'getFPC
27BDFFF8 AFBF0004 00852023 03E42021 ACC40000 8FBF0004 03E00008 27BD0008
'pstring
27BDFFE0 AFBF001C AFB00018 00808021 00002021 3C059D00 24A50724 27A60010
0411FFEF 00000000 8FA40010 3C029D00 8C42002C 0040F809 02042021 8FBF001C
8FB00018 03E00008 27BD0020
'main
27BDFFA8 AFBF0054 AFB30050 AFB2004C AFB10048 AFB00044 00808021 00A08821
00C09021 00002021 3C059D00 24A50784 27A60010 0411FFD7 00000000 3C029D00
8C430090 8E040000 A064003E 8C430090 8E240000 A064003D 8C420090 8E430000
A043003C 24020019 AFA20014 2402001A AFA20018 2402001B AFA2001C 24020024
AFA20020 24020025 AFA20024 24020026 AFA20028 24020002 AFA2002C 24020003
AFA20030 24020004 AFA20034 24020005 AFA20038 27B20014 27B3003C 3C109D00
8E510000 8E020010 02202021 24050008 0040F809 00003021 8E020010 02202021
24050065 0040F809 00003021 8E02001C 02202021 0040F809 24050005 26520004
5653FFF0 8E510000 3C109D00 8E020094 24030040 AC430000 8E020098 24030020
AC430000 8E02003C 0040F809 24041900 00408821 8E02008C AC510000 2402FFF5
A2221801 8E030090 8E02001C 8064003C 0040F809 24050005 8E030090 8E020010
8064003C 24050008 0040F809 00003021 8E030090 8E020010 8064003C 24050065
0040F809 00003021 8E030090 8E02001C 8064003D 0040F809 24050005 8E030090
8E020010 8064003D 24050008 0040F809 00003021 8E030090 8E020010 8064003D
24050065 0040F809 00003021 8E030090 8E02001C 8064003E 0040F809 24050006
8E030090 8E020010 8064003E 24050008 0040F809 00003021 8E030090 8E020010
8064003E 24050065 0040F809 00003021 A2201802 A2201803 02201021 26311800
A0400000 24420001 5451FFFE A0400000 8FA50010 3C029D00 8C430048 3C049D00
248401F4 00852021 AC640000 8FA50010 8C43004C 3C049D00 24840394 00852021
AC640000 8FA40010 8C4200AC 3C039D00 24630000 00641821 AC430000 24030320
3C02BF80 AC430620 34038010 3C02BF80 AC430600 2403001C 3C02BF88 AC4310A4
24030004 3C02BF88 AC4310A8 24020010 3C03BF88 AC621034 3C03BF88 AC621064
3C03BF88 AC621068 3C049D00 24840A3C 0411FF38 00000000 8FBF0054 8FB30050
8FB2004C 8FB10048 8FB00044 03E00008 27BD0058
'.rodata
'startup
20424752 2064654C 76697264 6C207265 6564616F 000A0D64
End CSub
'
DefineFont #8 '8x6 font ideal for this display
5C200806
00000000 82200000 00800008 00004551 4F510000 0045F994 2B1CEA21 690000C2
B04C2090 AA104A62 84608046 00000000 40108410 81400081 00841004 A89C8A00
82000080 0080203E 30000000 00000042 0000003E 01000000 21000086 00004208
CAAA2972 82210027 00872008 21842072 42F8800F 00270A04 F824C510 0FFA0041
00270A02 8A3C0831 21F80027 00044108 8A9C2872 28720027 0027089E 61008601
86010080 00846000 40208410 0F000081 0000F880 10028140 20720084 00022084
BA9A2072 28720027 8028FAA2 8ABC28F2 2872002F 00278220 8AA248E2 08FA004E
800F823C 823C08FA 28720008 80278A2E 8ABE288A 82708028 00872008 12044138
4A8A0046 8048A230 82200882 6A8B800F 80288AAA 9AAA2C8A 28728028 00278AA2
82BC28F2 28720008 8046AAA2 A2BC28F2 087A8048 002F081C 200882F8 288A0082
00278AA2 89A2288A 288A0042 00A5AAAA 5208258A 288A8028 00822094 420821F8
0471800F 00074110 A9944AA9 4170804A 00471004 00804821 00000000 800F0000
00008140 07000000 80277A02 8A320B82 0700002F 00278220 8AA62608 07008027
0007FA22 41382431 E8010004 002778A2 8A320B82 06208028 00872008 12040310
09820046 0089C228 20088260 0D000087 8028AA2A 8A320B00 07008028 00278A22
F2220F00 06000008 802078A6 82320B00 07000008 002F7020 41100E41 08000023
80668AA2 89A20800 08000042 00A5AAA2 21940800 08008048 002778A2 21840F00
0400800F 0EE24028
End DefineFont


C source


/*******************************************************************************
*
* Loadable Driver for 64 x 32 RGB LED panels in RGB222 mode
*
* Author: Peter Mather 2016 with acknowledgements to 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
* RGBled
*
* Entry point is function void main( long long *latpin,
* long long *clkpin
* long long *oepin
*
* V1.0 2016-06-29 Peter Mather
******************************************************************************/
#include <stdarg.h>

#define Version 200 //Version 2.00
#define _SUPPRESS_PLIB_WARNING // required for XC1.33 Later compiler versions will need PLIB to be installed
#include <plib.h> // the pre Harmony peripheral libraries
#include "../cfunctions.h"
#define MX470 //comment out to compile for MX170
#define screenwidth 64
#define screenheight 32
#define update screenwidth*screenheight*3 //location for status to force screen write
#define memsize update+256
#define magic update+1
#define nextrow update+2
#define nextbit update+3
#define lat Option->LCD_CD
#define clk Option->LCD_CS
#define oe Option->LCD_Reset
#define cport *(volatile unsigned int *)(0xbf886230) //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 eclrport *(volatile unsigned int *)(0xbf886434) //latch registers
#define esetport *(volatile unsigned int *)(0xbf886438) //latch registers
#define CLKLo (*(volatile unsigned int *)CLKclrport)=CLKpin
#define CLKHi (*(volatile unsigned int *)CLKsetport)=CLKpin
#define DEVID (*(volatile unsigned int *)0xBF80F220)

#ifndef MX470
void updatedisplay(void){
int n, endpos, build, CLKpin, CLKsetport, CLKclrport, bitmask;
unsigned char* p=(void *)(unsigned int)CFuncRam[0];
CLKpin=1<<GetPinBit(clk);
CLKsetport=(unsigned int)GetPortAddr(clk,LATSET);
CLKclrport=(unsigned int)GetPortAddr(clk,LATCLR);
if(p[nextbit]<2)bitmask=0x80;
if(p[nextbit]==2)bitmask=0x40;
build=p[nextrow]<<6;
n=(int)p[nextrow]*6*screenwidth;
endpos=n+6*screenwidth;
PinSetBit(oe,LATSET);
if(p[magic]==0xF5){
while (n<endpos){
build &= 0b1111000000;
if(p[n++] & bitmask)build|=1;
if(p[n++] & bitmask)build|=2;
if(p[n++] & bitmask)build|=4;
if(p[n++] & bitmask)build|=8;
if(p[n++] & bitmask)build|=16;
if(p[n++] & bitmask)build|=32;
cport=build;
CLKHi; CLKLo;
}
PinSetBit(lat,LATSET);PinSetBit(lat,LATCLR);
}
PinSetBit(oe,LATCLR);
p[nextrow]=(p[nextrow]+1) & 0xF; //16 rows
if(!p[nextrow]){
p[nextbit]++;
if(p[nextbit]==4)p[nextbit]=0;
}
}
#else
void updatedisplay(void){
int n, j,endpos, build, CLKpin, CLKsetport, CLKclrport, bitmask;
unsigned char* p=(void *)(unsigned int)CFuncRam[0];
CLKpin=1<<GetPinBit(clk);
CLKsetport=(unsigned int)GetPortAddr(clk,LATSET);
CLKclrport=(unsigned int)GetPortAddr(clk,LATCLR);
if(p[nextbit]<2)bitmask=0x80;
if(p[nextbit]==2)bitmask=0x40;
build=p[nextrow]<<6;
n=(int)p[nextrow]*6*screenwidth;
endpos=n+6*screenwidth;
PinSetBit(oe,LATSET);
if(p[magic]==0xF5){
p[nextrow]&0x4?PinSetBit(27,LATSET):PinSetBit(27,LATCLR);
p[nextrow]&0x8?PinSetBit(24,LATSET):PinSetBit(24,LATCLR);
while (n<endpos){
build &= 0b11000000;
if(p[n++] & bitmask)build|=1;
if(p[n++] & bitmask)build|=2;
if(p[n++] & bitmask)build|=4;
if(p[n++] & bitmask)build|=8;
if(p[n++] & bitmask)build|=16;
if(p[n++] & bitmask)build|=32;
eport=build;
CLKHi; j=DEVID;CLKLo; //wait state needed for clock
}
PinSetBit(lat,LATSET);PinSetBit(lat,LATCLR);
}
PinSetBit(oe,LATCLR);
p[nextrow]=(p[nextrow]+1) & 0xF; //16 rows
if(!p[nextrow]){
p[nextbit]++;
if(p[nextbit]==4)p[nextbit]=0;
}
}
#endif


long long DrawRectangleMEM(int x1, int y1, int x2, int y2, int c){
unsigned char* p=(void *)(unsigned int)CFuncRam[0];
if(p[magic]!=0xF5){
p = GetMemory(memsize);
//Save the address for other CFunctions
CFuncRam[0]=(unsigned int)(p);
p[magic]=0xF5;
}
int i,j,t,r,g,b;
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 >= screenwidth) x1 = screenwidth - 1;
if(x2 < 0) x2 = 0; if(x2 >= screenwidth) x2 = screenwidth - 1;
if(y1 < 0) y1 = 0; if(y1 >= screenheight) y1 = screenheight - 1;
if(y2 < 0) y2 = 0; if(y2 >= screenheight) y2 = screenheight - 1;
r=(c & 0xFF0000)>>16;
g=(c & 0xFF00)>>8;
b=c & 0xFF;
for(i=x1;i<=x2;i++){
for(j=y1;j<=y2;j++){
if(j<16){
p[i*6+j*384]=r;
p[i*6+j*384+1]=g;
p[i*6+j*384+2]=b;
} else {
p[i*6+(j-16)*384+3]=r;
p[i*6+(j-16)*384+4]=g;
p[i*6+(j-16)*384+5]=b;
}
}
}
}
void DrawBitmapMEM(int x1, int y1, int width, int height, int scale, int fc, int bc, unsigned char *bitmap){
int i, j, k, m, x, y;
unsigned char* p=(void *)(unsigned int)CFuncRam[0];
unsigned char rf,gf,bf,rb,gb,bb;
if(p[magic]!=0xF5){
p = GetMemory(memsize);

//Save the address for other CFunctions
CFuncRam[0]=(unsigned int)(p);
p[magic]=0xF5;
}
rf=(fc & 0xFF0000)>>16;
gf=(fc & 0xFF00)>>8;
bf=fc & 0xFF;
rb=(bc & 0xFF0000)>>16;
gb=(bc & 0xFF00)>>8;
bb=bc & 0xFF;

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
x=x1 + k * scale + m ;
y=y1 + i * scale + j ;
if(x >= 0 && x < screenwidth && y >= 0 && y < screenheight) { // if the coordinates are valid
if((bitmap[((i * width) + k)/8] >> (((height * width) - ((i * width) + k) - 1) %8)) & 1) {
if(y<16){
p[x*6+y*384]=rf;
p[x*6+y*384+1]=gf;
p[x*6+y*384+2]=bf;
} else {
p[x*6+(y-16)*384+3]=rf;
p[x*6+(y-16)*384+4]=gf;
p[x*6+(y-16)*384+5]=bf;
}
} else {
if(y<16){
p[x*6+y*384]=rb;
p[x*6+y*384+1]=gb;
p[x*6+y*384+2]=bb;
} else {
p[x*6+(y-16)*384+3]=rb;
p[x*6+(y-16)*384+4]=gb;
p[x*6+(y-16)*384+5]=bb;
}
}
}
}
}
}
}
}
__attribute__((noinline)) void getFPC(void *a, void *b, volatile unsigned int *c)
{
*c = (unsigned int) (__builtin_return_address (0) - (b -a)) ;
}
void pstring(const char *s){
volatile unsigned int libAddr ;
getFPC(NULL,&&getFPCLab,&libAddr) ; // warning can be ignored, stupid editor
getFPCLab: { }
unsigned char * testData = (unsigned char *)((void *)s + libAddr );
MMPrintString(testData);
}
//CFunction Driver_SSD1306

long long main(long long *latpin, long long *clkpin, long long *oepin){

volatile unsigned int libAddr ;
getFPC(NULL,&&getFPCLab,&libAddr) ; // warning can be ignored, stupid editor
getFPCLab: { }
unsigned int j,pn[10];
lat=*latpin;
clk=*clkpin;
oe=*oepin;
#ifndef MX470
pn[0]=25;
pn[1]=26;
pn[2]=27;
pn[3]=36;
pn[4]=37;
pn[5]=38;
pn[6]=2;
pn[7]=3;
pn[8]=4;
pn[9]=5;

#else
pn[0]=60;
pn[1]=61;
pn[2]=62;
pn[3]=63;
pn[4]=64;
pn[5]=1;
pn[6]=2;
pn[7]=3;
pn[8]=27;
pn[9]=24;
#endif
for(j=0;j<10;j++){
ExtCfg(pn[j],EXT_DIG_OUT,0);ExtCfg(pn[j],EXT_BOOT_RESERVED,0);
PinSetBit(pn[j],LATCLR);
}
HRes=screenwidth;VRes=screenheight;
//Get some persistent memory
unsigned char * p = GetMemory(memsize);
//Save the address for other CFunctions
CFuncRam[0]=(unsigned int)(p);
p[magic]=0xF5;
PinSetBit(oe, LATCLR);
ExtCfg(oe,EXT_DIG_OUT,0);ExtCfg(oe,EXT_BOOT_RESERVED,0);
PinSetBit(clk, LATCLR);
ExtCfg(clk,EXT_DIG_OUT,0);ExtCfg(clk,EXT_BOOT_RESERVED,0);
PinSetBit(lat, LATSET);
ExtCfg(lat,EXT_DIG_OUT,0);ExtCfg(lat,EXT_BOOT_RESERVED,0);
//Set the DrawRectangle vector to point to our function
p[nextrow]=0;
p[nextbit]=0;
for(j=0;j<update;j++)p[j]=0; //clear the display memory

DrawRectangleVector= (unsigned int)&DrawRectangleMEM + libAddr;

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

#ifndef MX470
CFuncT1=(unsigned int)&updatedisplay + libAddr; // using T1 which conflicts with IR
PR1 = 800;
T1CON = 0x8010 ; // T1 on, 8x prescaler as input
mT1SetIntPriority(1); // high priority
mT1ClearIntFlag(); // clear interrupt flag
mT1IntEnable(1);

#else
CFuncT5=(unsigned int)&updatedisplay + libAddr; //using T5, no conflicts on MX470
PR5 = 800;
T5CON = 0x8030 ; // T5 on, 8x prescaler as input
mT5SetIntPriority(1); // high priority
mT5ClearIntFlag(); // clear interrupt flag
mT5IntEnable(1);
#endif

static const char startup[]="RGB Led driver loaded\r\n";
pstring(startup);
}
Edited by matherp 2016-06-30
 
MicroBlocks

Guru

Joined: 12/05/2012
Location: Thailand
Posts: 2209
Posted: 01:14am 29 Jun 2016
Copy link to clipboard 
Print this post

I just ordered one of them as i have a little board with a PIC16F1559 that i need to test with this. The C-Source code will be very helpful.
Plan is to get it to work with USB and serial so it can be used both from a PC and an mcu.
Edited by MicroBlocks 2016-06-30
Microblocks. Build with logic.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10066
Posted: 02:42am 29 Jun 2016
Copy link to clipboard 
Print this post

Scrolling demo here




Simple code

Option explicit
option default NONE
dim integer i,x,a
cls
TEXT 2,16,"geoffg.net",lm,8,1,RGB(red)
DO
FOR x = 64 to -60 STEP -1
TEXT x,6,"Micromite+",lm,8,1,RGB(green)
a=4-x
TEXT a,26,"Micromite+",lm,8,1,RGB(magenta)
box a-64,22,64,8,0,0,rgb(black)
pause 50
NEXT x
LOOP



 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 06:50am 29 Jun 2016
Copy link to clipboard 
Print this post

That's totally amazing, I have one of these boards and was going to get a Raspberry pi to drive it, but now I can use a Micromite
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2927
Posted: 07:01am 29 Jun 2016
Copy link to clipboard 
Print this post

Very IMPRESSIVE



PS: I will let you know about any flicker when I try it out!

Without going through the code - can these be daisy-chained for bigger displays or would this have a detrimental effect on frame rate?

A BRILLIANT way to demonstrate the power of CSub driver on a MicroMite . . .
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 01:12am 05 Jul 2016
Copy link to clipboard 
Print this post

JUST to show how good these displays are - here's a video showing what can be done with these displays
The video is of a 96 X 48 board but it's the same principle
Youtube Video

and Here's how it was done
He used an STM32 controller and it's very impressive.

I'm happy with Peter's code, it does what I want
 
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1667
Posted: 10:00am 05 Jul 2016
Copy link to clipboard 
Print this post

  lew247 said   JUST to show how good these displays are - here's a video showing what can be done with these displays
The video is of a 96 X 48 board but it's the same principle
Youtube Video



Impressive!

Reminds me of a Pink Floyd Stage show.
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 01:01am 08 Jul 2016
Copy link to clipboard 
Print this post

Peter I've tried this and had success but I'd like to ask some questions if you don't mind me asking.

IF I want to write to a specific section of the display how would I do it?
an example - in the middle of the display IF I wanted to have in large red letters "TOO CLOSE" and underneath it "BACKUP" (flashing) how could I do this?

Also could you explain to me how your example code works please?
[code]TEXT 2,16,"geoffg.net",lm,8,1,RGB(red)
DO
FOR x = 64 to -60 STEP -1
TEXT x,6,"Micromite+",lm,8,1,RGB(green)
a=4-x
TEXT a,26,"Micromite+",lm,8,1,RGB(magenta)
box a-64,22,64,8,0,0,rgb(black)
pause 50
NEXT x
loop[/code]

Text obviously means write TEXT what are the 2,16 on the 1st line? also the 1m, 8, 1 for?
text a?
box box a-64,22,64,8,0,0,rgb(black) I don't get this line at all, I didn't see a box.

I'm guessing for x = 64 to - 60 STEP -1 means scroll to the left 1 letter at a time?
if you wanted to scroll right would you do STEP 1?

If I want to "flash" a letter/word could I do this easily?

It would look at first if I have a slightly different version of this board than you do - looking at my display working compared to yours.

Video of mine working HERE






EDIT: I've just realised that although the code says the 1st line should be GREEN it's actually RED - no idea why

EDIT 2: I originally had the OE and GND lines reversed, put them back but it didn;t change much, apart from the "M" on the last line is a bit "funny" now

EDIT 3: Here's the pinout of my connector


Edited by lew247 2016-07-09
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10066
Posted: 02:09am 08 Jul 2016
Copy link to clipboard 
Print this post

  Quote  1st line should be GREEN it's actually RED


You have the R1 and G1 wires reversed

  Quote  Text obviously means write TEXT what are the 2,16 on the 1st line? also the 1m, 8, 1 for?


This is Geoff's standard text routine: page 21 in the 5.1 manual, probably 22 in 5.2

  Quote   I don't get this line at all, I didn't see a box.


When you scroll left to right the leftmost line of pixels is left from the previous write. The BOX command writes a BLACK area to the screen to avoid this. Try running the program with that line commented out and you will see what I mean.

  Quote  If I want to "flash" a letter/word could I do this easily?


You have to do this by writing the text out and then rewriting it in the background colour

e.g.
[code]
DO
text 0,0,"hello",,,,RGB(white),rgb(black)
pause 400
text 0,0,"hello",,,,RGB(black),rgb(black)
pause 400
LOOP
[/code]

It is probably best to do this in a SETTICK timer
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 02:13am 08 Jul 2016
Copy link to clipboard 
Print this post

Thanks Peter
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 02:52am 08 Jul 2016
Copy link to clipboard 
Print this post

You were right - as usual, I had them backwards.

Worked perfectly after that until I tried this
[code]
TEXT 5,2,"TOO CLOSE",lm,8,1,RGB(red) [/code]

As far as I understand the manual that "should" have put the TEXT starting on the 5th LED from the left and the 2nd LED from the top?

Or have I understood it wrong?

EDIT:

I just noticed my display is upside down - the two connectors on the back, looking at the back the one on the left should be the interface to the Micromite which mine is
but the display is upside down?

I also noticed my pinout is NOT the one I posted, it has U2 instead of B2

I wonder if that is making a difference?












I flipped the display over on the short side (vertically) and the display seems to be upside dowm, or is this correct?


Edited by lew247 2016-07-09
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10066
Posted: 05:31am 08 Jul 2016
Copy link to clipboard 
Print this post

  Quote  As far as I understand the manual that "should" have put the TEXT starting on the 5th LED from the left and the 2nd LED from the top?

Or have I understood it wrong?


You are using LM

L says left justify
M says vertical placement Middle i.e. centre the text on line 2 hence the top of the chars is missing.

Use LT if you want the top of the char on line 2

Re the orientation - just use the display the way up that works
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2927
Posted: 06:15am 08 Jul 2016
Copy link to clipboard 
Print this post

@matherp

Will the 64pin code work on a 100pinner? If so, which pins to use? If not, is it easy to produce a version of code for the 100pinner?

No rush, still waiting for RGB matrix (hopefully here next week )
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10066
Posted: 07:22am 08 Jul 2016
Copy link to clipboard 
Print this post

  Quote  Will the 64pin code work on a 100pinner?


No

If not, is it easy to produce a version of code for the 100pinner?


Easy to make the change - pain in the a... to set up the test environment
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2927
Posted: 11:07am 08 Jul 2016
Copy link to clipboard 
Print this post

My little brain is just wondering about something and thought I would 'share'.

Those media panels you see everywhere now (i.e. electronic billboards) must consume a shed load of power.
If the resolution was lets say 640x320, then that is 100 lots of these 64x32 modules in affect.
So if one of these modules needs a decent 5A to drive (all RGB LEDs on), then a 640x320 would need 500A??

But a lot of those media panels are much bigger than 640x320 pixels . . . .

WOW - thats some power requirement

Any thoughts here?
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 10:15pm 08 Jul 2016
Copy link to clipboard 
Print this post

I really love this display, there are so many things you could do with it Edited by lew247 2016-07-10
 
     Page 1 of 4    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025