![]() |
Forum Index : Microcontroller and PC projects : MM2(+): V5.1 OLED drivers, I2C, SPI
Page 1 of 2 ![]() ![]() |
|||||
Author | Message | ||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10066 |
Prompted by Kermess's issue with the Nokia 5110, I have also updated the loadable SPI driver for the SSD1306 OLED display which would have had the same problem under 5.1. This driver was written for the MM2 but should run on the MM+ using SPI1 rather than SPI2 but this is untested. I have also created a loadable driver for the SSD1306 OLED running on I2C. This will run on either the MM2 or MM+ and incorporates Geoff's bitbang I2C routines so the display can be connected to any two pins (these must have pullup resistors e.g. 10K). The I2C driver should support both the 128x64 screens and also the 96x16 version referenced here (jman, please could you test? just set the size parameter to 2) I2C driver sub mm.startup
SSD1306(&H3C,2,3,1,1) 'I2C-address, SCK-pin, SDA-pin, Size , orientation 'NB flexible pin useage for I2C, pullup resistors must be used 'size: 0 for 0.96", 1 for 1.3", 2 for 96x16 resolution 'orientations: LANDSCAPE 1, PORTRAIT 2, RLANDSCAPE 3, RPORTRAIT 4 end sub ' ' CSUB SSD1306 0000035C 'Delay 40024800 00442021 40024800 0044102B 1440FFFD 00000000 03E00008 00000000 'BBStart 27BDFFE0 AFBF001C AFB10018 AFB00014 00808821 3C109D00 8E030090 8E02001C 8064002E 0040F809 2405FFFE 8E030090 8E02001C 8064002C 0040F809 2405FFFE 40034800 00711821 40024800 0043102B 1440FFFD 3C029D00 8C430090 8C42001C 8064002E 0040F809 2405FFFD 40034800 00711821 40024800 0043102B 1440FFFD 3C029D00 8C430090 8C42001C 8064002C 0040F809 2405FFFD 40024800 00518821 40024800 0051102B 1440FFFD 8FBF001C 8FB10018 8FB00014 03E00008 27BD0020 'BBStop 27BDFFE0 AFBF001C AFB10018 AFB00014 00808821 3C109D00 8E030090 8E02001C 8064002C 0040F809 2405FFFD 8E030090 8E02001C 8064002E 0040F809 2405FFFD 40034800 00711821 40024800 0043102B 1440FFFD 3C029D00 8C430090 8C42001C 8064002C 0040F809 2405FFFE 40034800 00711821 40024800 0043102B 1440FFFD 3C029D00 8C430090 8C42001C 8064002E 0040F809 2405FFFE 40024800 00518821 40024800 0051102B 1440FFFD 8FBF001C 8FB10018 8FB00014 03E00008 27BD0020 'BBWriteBit 27BDFFE0 AFBF001C AFB20018 AFB10014 AFB00010 00809021 10C00009 00A08821 3C029D00 8C430090 8C42001C 8064002E 0040F809 2405FFFE 10000008 3C029D00 3C029D00 8C430090 8C42001C 8064002E 0040F809 2405FFFD 3C029D00 8C430090 8C42001C 8064002C 0040F809 2405FFFE 00001021 40824800 10000005 3C109D00 40024800 0051102A 10400013 8FBF001C 8E030090 8E020020 0040F809 8064002C 1040FFF7 00000000 40024800 00529021 40024800 0052102B 1440FFFD 3C029D00 8C430090 8C42001C 8064002C 0040F809 2405FFFD 8FBF001C 8FB20018 8FB10014 8FB00010 03E00008 27BD0020 'BBReadBit 27BDFFE0 AFBF001C AFB10018 AFB00014 00808021 00A08821 3C029D00 8C430090 8C42001C 8064002E 0040F809 2405FFFE 40034800 00701821 40024800 0043102B 1440FFFD 3C029D00 8C430090 8C42001C 8064002C 0040F809 2405FFFE 40024800 00508021 40024800 0050102B 1440FFFD 00000000 40824800 10000005 3C109D00 40024800 0051102A 50400014 00008021 8E030090 8E020020 0040F809 8064002C 1040FFF7 00000000 3C119D00 8E230090 8E220020 0040F809 8064002E 00408021 8E230090 8E22001C 8064002C 0040F809 2405FFFD 10000002 02001021 02001021 8FBF001C 8FB10018 8FB00014 03E00008 27BD0020 'BBWriteByte 27BDFFD0 AFBF002C AFB60028 AFB50024 AFB40020 AFB3001C AFB20018 AFB10014 AFB00010 0080B021 00A08821 00C09821 00009021 3C109D00 0000A021 24150008 32620080 10400007 8E030090 8E02001C 8064002E 0040F809 2405FFFE 10000006 8E030090 8E02001C 8064002E 0040F809 2405FFFD 8E030090 8E02001C 8064002C 0040F809 2405FFFE 02801021 40824800 10000006 8E030090 40024800 0051102A 50400013 26520001 8E030090 8E020020 0040F809 8064002C 1040FFF7 00000000 40034800 00761821 40024800 0043102B 1440FFFD 00000000 8E030090 8E02001C 8064002C 0040F809 2405FFFD 26520001 1655FFD3 00139840 3C029D00 8C430090 8C42001C 8064002E 0040F809 2405FFFE 40034800 00761821 40024800 0043102B 1440FFFD 3C029D00 8C430090 8C42001C 8064002C 0040F809 2405FFFE 40024800 0056B021 40024800 0056102B 1440FFFD 00000000 40824800 10000005 3C109D00 40024800 0051102A 50400014 00008021 8E030090 8E020020 0040F809 8064002C 1040FFF7 00000000 3C119D00 8E230090 8E220020 0040F809 8064002E 00408021 8E230090 8E22001C 8064002C 0040F809 2405FFFD 10000002 2E020001 2E020001 8FBF002C 8FB60028 8FB50024 8FB40020 8FB3001C 8FB20018 8FB10014 8FB00010 03E00008 27BD0030 'writei2c 27BDFFD0 AFBF002C AFB60028 AFB50024 AFB40020 AFB3001C AFB20018 AFB10014 AFB00010 0080B021 00A0A821 00C08821 3C029D00 8C420000 8C500000 3C140018 26946A00 0214001B 028001F4 0000A012 00009812 00002012 0411FE97 00000000 240207D0 0202001B 004001F4 00008012 00101080 001029C0 00A22823 00B08021 00102880 02058021 001028C0 00A09021 02802021 00153040 0411FF5F 00000000 10400013 00001821 02C08021 10000007 2415FFFF 02402821 92260000 0411FF56 00000000 10400009 26310001 2610FFFF 1615FFF8 02602021 02802021 0411FEA6 00000000 10000002 24030001 00001821 00601021 8FBF002C 8FB60028 8FB50024 8FB40020 8FB3001C 8FB20018 8FB10014 8FB00010 03E00008 27BD0030 'oled_write_command 27BDFFE0 AFBF001C A3A00010 A3A40011 3C029D00 8C420090 24040002 8045003D 27A60010 0411FFAF 00000000 8FBF001C 03E00008 27BD0020 'OLED_setxy 27BDFFE8 AFBF0014 AFB00010 00808021 3C029D00 8C420090 9043003C 30630001 24820002 0043800B 24A4FFB0 308400FF 0411FFE5 00000000 7E041900 34840010 0411FFE1 00000000 3204000F 0411FFDE 00000000 8FBF0014 8FB00010 03E00008 27BD0018 'updatedisplay 27BDFFD0 AFBF002C AFB50028 AFB40024 AFB30020 AFB2001C AFB10018 AFB00014 3C029D00 8C42008C 8C500000 82020400 10400016 00008821 A2000400 2610FFFF 24140040 3C129D00 24150008 00002021 02202821 0411FFD1 00000000 82130000 A2140000 8E420090 24040081 8045003D 02003021 0411FF74 00000000 A2130000 26310001 1635FFF1 26100080 8FBF002C 8FB50028 8FB40024 8FB30020 8FB2001C 8FB10018 8FB00014 03E00008 27BD0030 'DrawRectangleMEM 27BDFFD0 AFBF002C AFB50028 AFB40024 AFB30020 AFB2001C AFB10018 AFB00014 00808821 00A09821 00C09021 00E0A021 3C029D00 8C42008C 8C420000 90440401 240300F5 10830009 8FB00040 3C159D00 8EA2003C 0040F809 24040500 8EA3008C AC620000 2403FFF5 A0430401 3C039D00 8C630090 80630015 24040002 14640009 24040003 2403007F 00742023 00731823 0220A021 02409821 00609021 10000012 00808821 14640008 24040004 2403007F 00718823 00729023 2403003F 00739823 10000009 0074A023 14640007 2403003F 00712023 00721823 02809021 0060A021 02608821 00809821 0232182A 14600005 0274182A 02201821 02408821 00609021 0274182A 14600005 2A230000 02601821 02809821 0060A021 2A230000 0003880B 2403007F 2A240080 0064880A 2A440000 0004900B 2A440080 0064900A 2A630000 0003980B 2403003F 2A640040 0064980A 2A840000 0004A00B 2A840040 0064A00A 0251182A 10600025 0293402A 10000028 24030001 24640007 28650000 0065200A 000428C3 000529C0 00B12821 000327C3 00042742 00643021 30C60007 00C42023 00872004 12000006 308400FF 00452821 90A60000 00862025 10000006 A0A40000 00452821 00042027 90A60000 00C42024 A0A40000 24630001 0283202A 1080FFE6 24640007 26310001 0251182A 10600004 24030001 10000007 A0430400 24070001 1100FFDC 02601821 1000FFF7 26310001 A0430400 8FBF002C 8FB50028 8FB40024 8FB30020 8FB2001C 8FB10018 8FB00014 03E00008 27BD0030 'DrawBitmapMEM 27BDFFB0 AFBF004C AFBE0048 AFB70044 AFB60040 AFB5003C AFB40038 AFB30034 AFB20030 AFB1002C AFB00028 AFA40050 00A0A821 00C08821 AFA7005C 8FB00060 8FB30068 3C029D00 8C42008C 8C420000 90440401 240300F5 10830009 8FB2006C 3C149D00 8E82003C 0040F809 24040500 8E83008C AC620000 2403FFF5 A0430401 8FA3005C 1860008F 0200B821 AFB5001C 00112023 AFA40020 70711802 2463FFFF AFA30014 AFB10024 0000B021 AFA00018 24190001 3C079D00 24080002 240A0003 1000007C 240C0004 8CE60090 80CF0015 15E80007 00602021 8CE40098 8C840000 2484FFFF 00603021 10000013 008B2023 15EA000A 00000000 8CE40094 8C840000 2484FFFF 00832023 8CE60098 8CC60000 24C6FFFF 10000008 00CB3023 15EC0006 01203021 8CE60094 8CC60000 24C6FFFF 00C33023 01202021 2C8F0080 51E0002C 24A50001 04C00029 28CF0040 51E00028 24A50001 24CF0007 28DE0000 00DE780A 000F78C3 000F79C0 01E42021 00067FC3 000F7F42 00CF3021 30C60007 00CF3023 00D93004 30C600FF 0006F027 92AF0000 01F47824 11E0000C 33DE00FF 8FAF0064 11E00005 00442021 908F0000 00CF3025 1000000E A0860000 90860000 03C6F024 1000000A A09E0000 12600005 00442021 908F0000 00CF3025 10000004 A0860000 90860000 03C6F024 A09E0000 24A50001 14B0FFB5 24630001 25AD0001 25CEFFFF 11B10010 0317C021 01B61821 24640007 28750000 0095180B 0003A8C3 0255A821 000E1FC3 00031F42 01C3A021 32940007 0283A023 0299A004 03001821 1000FFA2 00002821 8FA30010 24630001 AFA30010 14700004 256B0001 10000008 8FA40018 AFA00010 1A20FFF7 01604821 8FB80050 8FAE0014 1000FFE4 00006821 24840001 AFA40018 8FAF001C 01F77821 AFAF001C 8FA30014 8FA40020 00641821 AFA30014 8FAF0024 8FA30018 8FA4005C 10640005 02CFB021 1E00FFEA 8FAB001C 1000FFEF 8FA40018 24030001 A0430400 8FBF004C 8FBE0048 8FB70044 8FB60040 8FB5003C 8FB40038 8FB30034 8FB20030 8FB1002C 8FB00028 03E00008 27BD0050 'getFPC 27BDFFF8 AFBF0004 00852023 03E42021 ACC40000 8FBF0004 03E00008 27BD0008 'pstring 27BDFFE0 AFBF001C AFB00018 00808021 00002021 3C059D00 24A50D4C 27A60010 0411FFEF 00000000 8FA40010 3C029D00 8C42002C 0040F809 02042021 8FBF001C 8FB00018 03E00008 27BD0020 'main 27BDFFC8 AFBF0034 AFB40030 AFB3002C AFB20028 AFB10024 AFB00020 0080A021 00A09821 00C09021 00E08821 00002021 3C059D00 24A50DB4 27A60018 0411FFD5 00000000 3C109D00 8E020090 8E430000 A043002E 8E020090 8E630000 A043002C 8E020090 8E230000 A043003C 8E020090 8E830000 A043003D 8E020090 8FA30048 8C630000 A0430015 8E02003C 0040F809 24040500 8E03008C AC620000 2403FFF5 A0430401 8E030090 8E02001C 8064002E 0040F809 24050005 8E030090 8E020010 8064002E 24050008 0040F809 00003021 8E030090 8E020010 8064002E 24050065 0040F809 00003021 8E030090 8E02001C 8064002C 0040F809 24050005 8E030090 8E020010 8064002C 24050008 0040F809 00003021 8E030090 8E020010 8064002C 24050065 0040F809 00003021 8E220004 1C400054 240400AE 14400005 00000000 8E220000 2C420002 1040004E 00000000 0411FDF0 00000000 240400D5 0411FDED 00000000 24040080 0411FDEA 00000000 240400A8 0411FDE7 00000000 2404003F 0411FDE4 00000000 240400D3 0411FDE1 00000000 00002021 0411FDDE 00000000 24040040 0411FDDB 00000000 2404008D 0411FDD8 00000000 24040014 0411FDD5 00000000 24040020 0411FDD2 00000000 00002021 0411FDCF 00000000 240400A1 0411FDCC 00000000 240400C8 0411FDC9 00000000 240400DA 0411FDC6 00000000 24040012 0411FDC3 00000000 24040081 0411FDC0 00000000 240400CF 0411FDBD 00000000 240400D9 0411FDBA 00000000 240400F1 0411FDB7 00000000 240400DB 0411FDB4 00000000 24040040 0411FDB1 00000000 240400A4 0411FDAE 00000000 240400A6 0411FDAB 00000000 240400AF 0411FDA8 00000000 24020040 10000056 24030080 0411FDA3 00000000 24040020 0411FDA0 00000000 24040010 0411FD9D 00000000 240400B0 0411FD9A 00000000 240400C8 0411FD97 00000000 00002021 0411FD94 00000000 24040010 0411FD91 00000000 24040040 0411FD8E 00000000 24040081 0411FD8B 00000000 240400AF 0411FD88 00000000 240400A1 0411FD85 00000000 240400A6 0411FD82 00000000 240400A8 0411FD7F 00000000 2404000F 0411FD7C 00000000 240400A4 0411FD79 00000000 240400D3 0411FD76 00000000 00002021 0411FD73 00000000 240400D5 0411FD70 00000000 240400F0 0411FD6D 00000000 240400D9 0411FD6A 00000000 24040022 0411FD67 00000000 240400DA 0411FD64 00000000 24040002 0411FD61 00000000 240400DB 0411FD5E 00000000 24040049 0411FD5B 00000000 2404008D 0411FD58 00000000 24040014 0411FD55 00000000 240400AF 0411FD52 00000000 24020010 24030060 3C049D00 8C840090 90840015 30840001 10800006 3C049D00 8C850094 ACA30000 8C830098 10000005 AC620000 8C850098 ACA30000 8C830094 AC620000 8FA50018 3C029D00 8C430048 3C049D00 248407D0 00852021 AC640000 8FA50018 8C43004C 3C049D00 24840A08 00852021 AC640000 8FA50018 8C4300A4 3C049D00 24840720 00852021 AC640000 8C430048 8C440094 8C860000 8C420098 8C470000 AFA00010 8C620000 00002021 00002821 24C6FFFF 0040F809 24E7FFFF 3C049D00 24841230 0411FEC6 00000000 8FBF0034 8FB40030 8FB3002C 8FB20028 8FB10024 8FB00020 03E00008 27BD0038 '.rodata 'startup 31445353 20363033 20433249 76697264 6C207265 6564616F 000A0D64 End CSUB SPI driver sub mm.startup
SSD1306(2,3,4,1,1) 'DCpin, RSTpin, CSpin, Size (1 for 1.3", 0 for 0.96"), orientation 'orientations: LANDSCAPE 1, PORTRAIT 2, RLANDSCAPE 3, RPORTRAIT 4 end sub ' ' CSUB SSD1306 000001F6 'spi_write_command 27BDFFE0 AFBF001C AFB10018 AFB00014 309100FF 3C109D00 8E030090 8E02001C 8064002C 0040F809 24050005 8E030090 8E02001C 8064002D 0040F809 24050005 3C02BF80 AC515820 3C03BF80 8C625810 30420080 1040FFFD 3C02BF80 8C425820 3C029D00 8C430090 8C42001C 8064002D 0040F809 24050006 8FBF001C 8FB10018 8FB00014 03E00008 27BD0020 'OLED_setxy 27BDFFE8 AFBF0014 AFB00010 00808021 3C029D00 8C420090 8043003C 24820002 0043800B 24A4FFB0 308400FF 0411FFD1 00000000 7E041900 34840010 0411FFCD 00000000 3204000F 0411FFCA 00000000 8FBF0014 8FB00010 03E00008 27BD0018 'updatedisplay 27BDFFC8 AFBF0034 AFB70030 AFB6002C AFB50028 AFB40024 AFB30020 AFB2001C AFB10018 AFB00014 3C029D00 8C42008C 8C530000 82620400 10400039 3C02BF80 A2600400 8C555830 8C565800 8C575840 34038060 AC435800 24030002 AC435830 24030C00 AC435840 00009021 3C119D00 3C10BF80 24140008 00002021 02402821 0411FFC7 00000000 8E230090 8E22001C 8064002D 0040F809 24050005 8E230090 8E22001C 8064002C 0040F809 24050006 001219C0 26520001 001211C0 0062102A 1040000C 26640080 02601821 80620000 AE025820 8E025810 30420080 1040FFFD 00000000 8E025820 24630001 5464FFF8 80620000 8E230090 8E22001C 8064002D 0040F809 24050005 1654FFDB 26730080 3C02BF80 AC555830 AC565800 AC575840 8FBF0034 8FB70030 8FB6002C 8FB50028 8FB40024 8FB30020 8FB2001C 8FB10018 8FB00014 03E00008 27BD0038 'DrawRectangleMEM 27BDFFD0 AFBF002C AFB50028 AFB40024 AFB30020 AFB2001C AFB10018 AFB00014 00808821 00A09821 00C09021 00E0A021 3C029D00 8C42008C 8C420000 90440401 240300F5 10830009 8FB00040 3C159D00 8EA2003C 0040F809 24040500 8EA3008C AC620000 2403FFF5 A0430401 3C039D00 8C630090 80630015 24040002 14640009 24040003 2403007F 00742023 00731823 0220A021 02409821 00609021 10000012 00808821 14640008 24040004 2403007F 00718823 00729023 2403003F 00739823 10000009 0074A023 14640007 2403003F 00712023 00721823 02809021 0060A021 02608821 00809821 0232182A 14600005 0274182A 02201821 02408821 00609021 0274182A 14600005 2A230000 02601821 02809821 0060A021 2A230000 0003880B 2403007F 2A240080 0064880A 2A440000 0004900B 2A440080 0064900A 2A630000 0003980B 2403003F 2A640040 0064980A 2A840000 0004A00B 2A840040 0064A00A 0251182A 10600025 0293402A 10000028 24030001 24640007 28650000 0065200A 000428C3 000529C0 00B12821 000327C3 00042742 00643021 30C60007 00C42023 00872004 12000006 308400FF 00452821 90A60000 00862025 10000006 A0A40000 00452821 00042027 90A60000 00C42024 A0A40000 24630001 0283202A 1080FFE6 24640007 26310001 0251182A 10600004 24030001 10000007 A0430400 24070001 1100FFDC 02601821 1000FFF7 26310001 A0430400 8FBF002C 8FB50028 8FB40024 8FB30020 8FB2001C 8FB10018 8FB00014 03E00008 27BD0030 'DrawBitmapMEM 27BDFFB0 AFBF004C AFBE0048 AFB70044 AFB60040 AFB5003C AFB40038 AFB30034 AFB20030 AFB1002C AFB00028 AFA40050 00A0A821 00C08821 AFA7005C 8FB00060 8FB30068 3C029D00 8C42008C 8C420000 90440401 240300F5 10830009 8FB2006C 3C149D00 8E82003C 0040F809 24040500 8E83008C AC620000 2403FFF5 A0430401 8FA3005C 1860008F 0200B821 AFB5001C 00112023 AFA40020 70711802 2463FFFF AFA30014 AFB10024 0000B021 AFA00018 24190001 3C079D00 24080002 240A0003 1000007C 240C0004 8CE60090 80CF0015 15E80007 00602021 8CE40098 8C840000 2484FFFF 00603021 10000013 008B2023 15EA000A 00000000 8CE40094 8C840000 2484FFFF 00832023 8CE60098 8CC60000 24C6FFFF 10000008 00CB3023 15EC0006 01203021 8CE60094 8CC60000 24C6FFFF 00C33023 01202021 2C8F0080 51E0002C 24A50001 04C00029 28CF0040 51E00028 24A50001 24CF0007 28DE0000 00DE780A 000F78C3 000F79C0 01E42021 00067FC3 000F7F42 00CF3021 30C60007 00CF3023 00D93004 30C600FF 0006F027 92AF0000 01F47824 11E0000C 33DE00FF 8FAF0064 11E00005 00442021 908F0000 00CF3025 1000000E A0860000 90860000 03C6F024 1000000A A09E0000 12600005 00442021 908F0000 00CF3025 10000004 A0860000 90860000 03C6F024 A09E0000 24A50001 14B0FFB5 24630001 25AD0001 25CEFFFF 11B10010 0317C021 01B61821 24640007 28750000 0095180B 0003A8C3 0255A821 000E1FC3 00031F42 01C3A021 32940007 0283A023 0299A004 03001821 1000FFA2 00002821 8FA30010 24630001 AFA30010 14700004 256B0001 10000008 8FA40018 AFA00010 1A20FFF7 01604821 8FB80050 8FAE0014 1000FFE4 00006821 24840001 AFA40018 8FAF001C 01F77821 AFAF001C 8FA30014 8FA40020 00641821 AFA30014 8FAF0024 8FA30018 8FA4005C 10640005 02CFB021 1E00FFEA 8FAB001C 1000FFEF 8FA40018 24030001 A0430400 8FBF004C 8FBE0048 8FB70044 8FB60040 8FB5003C 8FB40038 8FB30034 8FB20030 8FB1002C 8FB00028 03E00008 27BD0050 'getFPC 27BDFFF8 AFBF0004 00852023 03E42021 ACC40000 8FBF0004 03E00008 27BD0008 'pstring 27BDFFE0 AFBF001C AFB00018 00808021 00002021 3C059D00 24A507B4 27A60010 0411FFEF 00000000 8FA40010 3C029D00 8C42002C 0040F809 02042021 8FBF001C 8FB00018 03E00008 27BD0020 'main 27BDFFC0 AFBF003C AFB50038 AFB40034 AFB30030 AFB2002C AFB10028 AFB00024 00809021 00A08821 00C0A021 00E09821 00002021 3C059D00 24A50820 27A60018 0411FFD4 00000000 3C109D00 8E020090 8E230000 A043002E 8E020090 8E430000 A043002C 8E020090 8E630000 A043003C 8E020090 8E830000 A043002D 8E020090 8FA30050 8C630000 A0430015 8E02003C 0040F809 24040500 8E03008C AC620000 2403FFF5 A0430401 8E030090 8E020010 8064002E 24050008 0040F809 00003021 8E030090 8E020010 8064002E 24050065 0040F809 00003021 8E030090 8E02001C 8064002E 0040F809 24050006 8E030090 8E020010 8064002C 24050008 0040F809 00003021 8E030090 8E020010 8064002C 24050065 0040F809 00003021 8E030090 8E02001C 8064002C 0040F809 24050006 8E030090 8E020010 8064002D 24050008 0040F809 00003021 8E030090 8E020010 8064002D 24050065 0040F809 00003021 8E030090 8E02001C 8064002D 0040F809 24050006 3C02BF81 8C44F220 7C84D800 3C030661 3463A053 1083000B 24020050 3C02BF81 8C43F220 7C63D800 3C020660 3442A053 00621026 24030050 2404000C 0082180B 00601021 3C039D00 8C630088 00431021 8C430000 24020064 54620007 00008821 3C02BF80 8C515830 8C525800 8C555840 10000003 3C029D00 00009021 3C029D00 8C420010 3C03BF81 8C65F220 7CA5D800 3C030661 3463A053 10A3000B 24040014 3C03BF81 8C64F220 7C84D800 3C030660 3463A053 00832026 24030014 24050003 00A4180B 00602021 24050008 0040F809 00003021 3C029D00 8C420010 3C03BF81 8C65F220 7CA5D800 3C030661 3463A053 10A3000B 24040014 3C03BF81 8C64F220 7C84D800 3C030660 3463A053 00832026 24030014 24050003 00A4180B 00602021 24050065 0040F809 00003021 3C029D00 8C420010 3C03BF81 8C65F220 7CA5D800 3C030661 3463A053 10A3000B 24040029 3C03BF81 8C64F220 7C84D800 3C030660 3463A053 00832026 24030029 2405000E 00A4180B 00602021 24050002 0040F809 00003021 3C029D00 8C420010 3C03BF81 8C65F220 7CA5D800 3C030661 3463A053 10A3000B 24040029 3C03BF81 8C64F220 7C84D800 3C030660 3463A053 00832026 24030029 2405000E 00A4180B 00602021 24050065 0040F809 00003021 3C029D00 8C420010 3C03BF81 8C65F220 7CA5D800 3C030661 3463A053 10A3000B 2404000E 3C03BF81 8C64F220 7C84D800 3C030660 3463A053 00832026 2403000E 24050019 00A4180B 00602021 24050008 0040F809 00003021 3C029D00 8C420010 3C03BF81 8C65F220 7CA5D800 3C030661 3463A053 10A3000B 2404000E 3C03BF81 8C64F220 7C84D800 3C030660 3463A053 00832026 2403000E 24050019 00A4180B 00602021 24050065 0040F809 00003021 3C02BF81 8C43FA84 24040001 7C831804 AC43FA84 3C02BF81 8C43FB04 24040003 7C831804 AC43FB04 3C02BF80 34038060 AC435800 24030002 AC435830 24030C00 AC435840 16200005 3C109D00 8C515830 8C525800 8C555840 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 240400AE 0411FCD9 00000000 240400D5 0411FCD6 00000000 24040080 0411FCD3 00000000 240400A8 0411FCD0 00000000 2404003F 0411FCCD 00000000 240400D3 0411FCCA 00000000 00002021 0411FCC7 00000000 24040040 0411FCC4 00000000 2404008D 0411FCC1 00000000 24040014 0411FCBE 00000000 24040020 0411FCBB 00000000 00002021 0411FCB8 00000000 240400A1 0411FCB5 00000000 240400C8 0411FCB2 00000000 240400DA 0411FCAF 00000000 24040012 0411FCAC 00000000 24040081 0411FCA9 00000000 240400CF 0411FCA6 00000000 240400D9 0411FCA3 00000000 240400F1 0411FCA0 00000000 240400DB 0411FC9D 00000000 24040040 0411FC9A 00000000 240400A4 0411FC97 00000000 240400A6 0411FC94 00000000 240400AF 0411FC91 00000000 8E020090 90420015 30420001 10400008 3C029D00 8C430094 24040080 AC640000 8C420098 24030040 10000007 AC430000 8C430098 24040080 AC640000 8C420094 24030040 AC430000 8FA50018 3C029D00 8C430048 3C049D00 24840238 00852021 AC640000 8FA50018 8C43004C 3C049D00 24840470 00852021 AC640000 8FA50018 8C430084 3C049D00 248400EC 00852021 AC640000 8C430048 8C440094 8C860000 8C420098 8C470000 AFA00010 8C620000 00002021 00002821 24C6FFFF 0040F809 24E7FFFF 3C02BF80 AC515830 AC525800 AC555840 3C049D00 24840EC8 0411FE3B 00000000 8FBF003C 8FB50038 8FB40034 8FB30030 8FB2002C 8FB10028 8FB00024 03E00008 27BD0040 '.rodata 'startup 31445353 20363033 20495053 76697264 6C207265 6564616F 000A0D64 End CSUB C source /******************************************************************************* * * Driver for SSD1306 Display written as CFunctions * * Author: 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 * SSD1306 * * Entry point is function long long main(long long *address //i2c only * * long long *DC, * long long *RST * long long *CS //SPI only * long long *size //zero for 0.96", non-zero for 1.3" * long long *orientation) * * V1.0 2015-10-15 Peter Mather * V2.0 2016-2-29 V5.0 compatibility, I2C bitbang impemlentation ******************************************************************************/ #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 i2c //define for compilation for I2c, comment out for SPI #define LANDSCAPE 1 #define PORTRAIT 2 #define RLANDSCAPE 3 #define RPORTRAIT 4 #define screenwidth 128 #define screenheight 64 #define screenrows screenheight/8 #define update screenwidth*screenrows //location for status to force screen write #define magic update+1 // SPI pin numbers and registers #define SPI_INP_PIN (HAS_44PINS ? 41 : 14) #define SPI_OUT_PIN (HAS_44PINS ? 20 : 3) #define SPI_CLK_PIN (HAS_44PINS ? 14 : 25) #define SPI_PPS_OPEN PPSInput(2, SDI1, RPB5); PPSOutput(2, RPA1, SDO1) #define SPI_PPS_CLOSE PPSOutput(2, RPA1, NULL) #define SPICON *(volatile unsigned int *)(0xbf805800) //SPI status register #define SPISTAT *(volatile unsigned int *)(0xbf805810) //SPI status register #define SPIBUF *(volatile unsigned int *)(0xbf805820) //SPI output buffer #define SPIBRG *(volatile unsigned int *)(0xbf805830) //SPI output buffer #define SPICON2 *(volatile unsigned int *)(0xbf805840) //SPI status register #define SPIsend(a) {int j;SPIBUF=a; while((SPISTAT & 0x80)==0); j=SPIBUF;} #ifdef i2c #define dat Option->LCD_Reset #define clk Option->LCD_CD #define SetHi(p) PinSetBit(p, TRISSET) #define SetLo(p) PinSetBit(p, TRISCLR) // delay for a certain number of core timer ticks (one tick every 50nS at 40MHz CPU speed, 100nS at 20MHz, etc) inline void Delay(unsigned int ticks) { unsigned int current_ticks; asm volatile("mfc0 %0, $9" : "=r"(current_ticks)); // get the core timer ticks ticks += current_ticks; // this is what we want to count up to do { asm volatile("mfc0 %0, $9" : "=r"(current_ticks)); // get the core timer ticks } while(current_ticks < ticks); } // bit banged I2C Start condition, data line goes low when clock is high void BBStart(int speed) { SetHi(dat); SetHi(clk); Delay(speed); SetLo(dat); Delay(speed); SetLo(clk); Delay(speed); } // bit banged I2C Stop condition, clock goes high when data is low void BBStop (int speed) { SetLo(clk); SetLo(dat); Delay(speed); SetHi(clk); Delay(speed); SetHi(dat); Delay(speed); } // bit banged I2C write a bit inline void BBWriteBit(int speed, int timeout, int bit) { int i = 0; if(bit) SetHi(dat); else SetLo(dat); SetHi(clk); asm volatile("mtc0 %0, $9": "+r"(i)); // set the core timer to zero while(!PinRead(clk)) { // Wait for clock to go high - clock stretching asm volatile("mfc0 %0, $9" : "=r"(i)); // get the core timer ticks if(i >= timeout) return; // return nothing if there is a timeout } Delay(speed); SetLo(clk); } // bit banged I2C read a bit inline int BBReadBit(int speed, int timeout) { int i = 0; SetHi(dat); Delay(speed); SetHi(clk); Delay(speed); asm volatile("mtc0 %0, $9": "+r"(i)); // set the core timer to zero while(!PinRead(clk)) { // Wait for clock to go high - clock stretching asm volatile("mfc0 %0, $9" : "=r"(i)); // get the core timer ticks if(i >= timeout) return 0; // return nothing if there is a timeout } i = PinRead(dat); SetLo(clk); return i; } // bit banged I2C Write, returns true if ACK received int BBWriteByte(int speed, int timeout, int data) { int i; for(i = 0; i < 8; i++) { BBWriteBit(speed, timeout, (data & 0x80)); data <<= 1; } return !BBReadBit(speed, timeout); // read the ACK bit and return true is ACK received } int writei2c (int nbr, int addr, unsigned char *data) { unsigned int i=nbr, speed= (CurrentCpuSpeed/1600000); unsigned int timeout = (CurrentCpuSpeed/2000) * 5000; // calculate the number of core timer ticks for the timeout (5mS) BBStart(speed); if(!BBWriteByte(speed, timeout, (addr << 1))) return 0; while(i--) if(!BBWriteByte(speed, timeout, *data++)) return 0; BBStop(speed); return 1; } void oled_write_command(unsigned char data){ char sc[2]; sc[0]=0; sc[1]=data; writei2c(2,Option->pins[1],sc); } #else void oled_write_command(unsigned char data){ PinSetBit(Option->LCD_CD, LATCLR); PinSetBit(Option->LCD_CS, LATCLR); SPIsend(data); PinSetBit(Option->LCD_CS, LATSET); } #endif void OLED_setxy(int x,int y){ if(Option->pins[0] & 1)x+=2; oled_write_command(0xB0+y) ; //set page address oled_write_command(0x10 | ((x>>4) & 0x0F)) ; //set high col address oled_write_command(x & 0x0f) ; //set low col address } #ifdef i2c void updatedisplay(void){ char* p=(void *)(unsigned int)CFuncRam[0]; if(p[update]){ char *q; char saveit; int n; p[update]=0; for(n=0;n<screenrows;n++){ OLED_setxy(0,n); q=p+n*screenwidth-1; saveit=q[0]; q[0]=0x40; writei2c(screenwidth+1,Option->pins[1],q); q[0]=saveit; } } } #else void updatedisplay(void){ char* p=(void *)(unsigned int)CFuncRam[0]; if(p[update]){ int m,n; unsigned int consave=0,brgsave=0,con2save; p[update]=0; brgsave=SPIBRG; //save any user SPI setup consave=SPICON; con2save=SPICON2; SPICON=0x8060; SPIBRG=2; SPICON2=0xC00; for(n=0;n<screenrows;n++){ OLED_setxy(0,n); PinSetBit(Option->LCD_CS, LATCLR); PinSetBit(Option->LCD_CD, LATSET); for(m=n*screenwidth;m<(n+1)*screenwidth;m++){ SPIsend(p[m]); } PinSetBit(Option->LCD_CS, LATCLR); } SPIBRG=brgsave; //restore user (or my) setup SPICON=consave; SPICON2=con2save; } } #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(screenwidth*screenheight/8+256); //Save the address for other CFunctions CFuncRam[0]=(unsigned int)(p); p[magic]=0xF5; } int i,j,loc,t; unsigned char mask; if(Option->DISPLAY_ORIENTATION==PORTRAIT){ t=x1; x1=screenwidth-y2-1; y2=t; t=x2; x2=screenwidth-y1-1; y1=t; } if(Option->DISPLAY_ORIENTATION==RLANDSCAPE){ x1=screenwidth-x1-1; x2=screenwidth-x2-1; y1=screenheight-y1-1; y2=screenheight-y2-1; } if(Option->DISPLAY_ORIENTATION==RPORTRAIT){ t=y1; y1=screenheight-x1-1; x1=t; t=y2; y2=screenheight-x2-1; x2=t; } 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; for(i=x1;i<=x2;i++){ for(j=y1;j<=y2;j++){ loc=i+(j/8)*screenwidth; //get the byte address for this bit mask=1<<(j % 8); //get the bit position for this bit if(c){ p[loc]|=mask; } else { p[loc]&=(~mask); } } } p[update]=1; } 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,t, loc; unsigned char omask, amask; unsigned char* p=(void *)(unsigned int)CFuncRam[0]; if(p[magic]!=0xF5){ p = GetMemory(screenwidth*screenheight/8+256); //Save the address for other CFunctions CFuncRam[0]=(unsigned int)(p); p[magic]=0xF5; } 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(Option->DISPLAY_ORIENTATION==PORTRAIT){ t=x; x=VRes-y-1; y=t; } if(Option->DISPLAY_ORIENTATION==RLANDSCAPE){ x=HRes-x-1; y=VRes-y-1; } if(Option->DISPLAY_ORIENTATION==RPORTRAIT){ t=y; y=HRes-x-1; x=t; } loc=x+(y/8)*screenwidth; //get the byte address for this bit omask=1<<(y % 8); //get the bit position for this bit amask=~omask; 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(fc){ p[loc]|=omask; } else { p[loc]&=amask; } } else { if(bc){ p[loc]|=omask; } else { p[loc]&=amask; } } } } } } } p[update]=1; } __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 #ifdef i2c long long main(long long *address, long long *CD, long long *RST, long long *size, long long *orientation){ // for i2c RST is used for SDA, CD is used for SCK #else long long main(long long *CD, long long *RST, long long *CS,long long *size, long long *orientation){ #endif volatile unsigned int libAddr ; getFPC(NULL,&&getFPCLab,&libAddr) ; // warning can be ignored, stupid editor getFPCLab: { } int HorizontalRes=screenwidth,VerticalRes=screenheight; Option->LCD_Reset=*RST; Option->LCD_CD=*CD; Option->pins[0]=*size; Option->pins[1]=*address; #ifndef i2c unsigned int consave=0,brgsave=0,con2save; Option->LCD_CS=*CS; #endif Option->DISPLAY_ORIENTATION=*orientation; //Get some persistent memory unsigned char * p = GetMemory(HorizontalRes*VerticalRes/8+256); //Save the address for other CFunctions CFuncRam[0]=(unsigned int)(p); p[magic]=0xF5; PinSetBit(Option->LCD_Reset, LATCLR); ExtCfg(Option->LCD_Reset,EXT_DIG_OUT,0);ExtCfg(Option->LCD_Reset,EXT_BOOT_RESERVED,0); PinSetBit(Option->LCD_CD, LATCLR); ExtCfg(Option->LCD_CD,EXT_DIG_OUT,0);ExtCfg(Option->LCD_CD,EXT_BOOT_RESERVED,0); #ifndef i2c ExtCfg(Option->LCD_CS,EXT_DIG_OUT,0);ExtCfg(Option->LCD_CS,EXT_BOOT_RESERVED,0); PinSetBit(Option->LCD_CS, LATSET); if(ExtCurrentConfig[SPI_OUT_PIN] == EXT_RESERVED) { //already open brgsave=SPIBRG; consave=SPICON; con2save=SPICON2; } ExtCfg(SPI_OUT_PIN, EXT_DIG_OUT, 0); ExtCfg(SPI_OUT_PIN, EXT_BOOT_RESERVED, 0); ExtCfg(SPI_INP_PIN, EXT_DIG_IN, 0); ExtCfg(SPI_INP_PIN, EXT_BOOT_RESERVED, 0); ExtCfg(SPI_CLK_PIN, EXT_DIG_OUT, 0); ExtCfg(SPI_CLK_PIN, EXT_BOOT_RESERVED, 0); SPI_PPS_OPEN; SPICON=0x8060; SPIBRG=2; SPICON2=0xC00;// this is defined in IOPorts.h if(!brgsave){ //save my settings brgsave=SPIBRG; consave=SPICON; con2save=SPICON2; } //Reset the SSD1306 PinSetBit(Option->LCD_Reset,LATSET); uSec(10000); PinSetBit(Option->LCD_Reset,LATCLR); uSec(10000); PinSetBit(Option->LCD_Reset,LATSET); uSec(10000); #endif #ifdef i2c if(*size<2){ #endif oled_write_command(0xAE); //DISPLAYOFF) oled_write_command(0xD5); //DISPLAYCLOCKDIV oled_write_command(0x80); //the suggested ratio 0x80 oled_write_command(0xA8); //MULTIPLEX oled_write_command(0x3F); // oled_write_command(0xD3); //DISPLAYOFFSET oled_write_command(0x0); //no offset oled_write_command(0x40); //STARTLINE oled_write_command(0x8D); //CHARGEPUMP oled_write_command(0x14) ; oled_write_command(0x20); //MEMORYMODE oled_write_command(0x00); //0x0 act like ks0108 oled_write_command(0xA1); //SEGREMAP OR 1 oled_write_command(0xC8); //COMSCANDEC oled_write_command(0xDA); //COMPINS oled_write_command(0x12) ; oled_write_command(0x81); //SETCONTRAST oled_write_command(0xCF) ; oled_write_command(0xd9); //SETPRECHARGE oled_write_command(0xF1) ; oled_write_command(0xDB); //VCOMDETECT oled_write_command(0x40) ; oled_write_command(0xA4); //DISPLAYALLON_RESUME oled_write_command(0xA6); //NORMALDISPLAY oled_write_command(0xAF); //DISPLAYON #ifdef i2c } else { HorizontalRes=96; VerticalRes=16; oled_write_command(0xAE) ; //display off oled_write_command(0x20) ; //Set Memory Addressing Mode oled_write_command(0x10) ; //00,Horizontal Addressing Mode01,Vertical Addressing Mode10,Page Addressing Mode (RESET)11,Invalid oled_write_command(0xb0) ; //Set Page Start Address for Page Addressing Mode,0-7 oled_write_command(0xc8) ; //Set COM Output Scan Direction oled_write_command(0x00) ; //---set low column address oled_write_command(0x10) ; //---set high column address oled_write_command(0x40) ; //--set start line address oled_write_command(0x81) ; //--set contrast control register oled_write_command(0xaf) ; //--contrast value oled_write_command(0xa1) ; //--set segment re-map 0 to 95 oled_write_command(0xa6) ; //--set normal display oled_write_command(0xa8) ; //--set multiplex ratio(1 to 16) oled_write_command(0x0f) ; // oled_write_command(0xa4) ; //0xa4,Output follows RAM content0xa5,Output ignores RAM content oled_write_command(0xd3) ; //-set display offset oled_write_command(0x00) ; //-not offset oled_write_command(0xd5) ; //--set display clock divide ratio/oscillator frequency oled_write_command(0xf0) ; //--set divide ratio oled_write_command(0xd9) ; //--set pre-charge period oled_write_command(0x22) ; // oled_write_command(0xda) ; //--set com pins hardware configuration oled_write_command(0x02) ; oled_write_command(0xdb) ; //--set vcomh oled_write_command(0x49) ; //0x20,0.83xVcc oled_write_command(0x8d) ; //--set DC-DC enable oled_write_command(0x14) ; // oled_write_command(0xaf) ; //--turn on oled panel } #endif if(Option->DISPLAY_ORIENTATION&1){ HRes=HorizontalRes; VRes=VerticalRes; } else { VRes=HorizontalRes; HRes=VerticalRes; } //Set the DrawRectangle vector to point to our function DrawRectangleVector= (unsigned int)&DrawRectangleMEM + libAddr; //Set the DrawBitmap vector to point to our function DrawBitmapVector=(unsigned int)&DrawBitmapMEM + libAddr; CFuncInt=(unsigned int)&updatedisplay + libAddr; //CLS DrawRectangle(0,0,HRes-1,VRes-1,0); #ifndef i2c SPIBRG=brgsave; //restore user (or my) setup SPICON=consave; SPICON2=con2save; static const char startup[]="SSD1306 SPI driver loaded\r\n"; #else static const char startup[]="SSD1306 I2C driver loaded\r\n"; #endif pstring(startup); } |
||||
jman![]() Guru ![]() Joined: 12/06/2011 Location: New ZealandPosts: 711 |
Hi Peter [quote] (jman, please could you test? just set the size parameter to 2) [/quote] Sure can and I can confirm this driver works perfectly with SSD1306 OLED running on I2C @ 96x16 Thanks Heaps Jman |
||||
kermess Regular Member ![]() Joined: 04/04/2013 Location: SpainPosts: 45 |
Hi Peter. You can review the display Cfunction KS0108 to uMite V 5.1 My idea is that. I have several displays of this kind and want to give I2C output connection and use them. Thank you. David |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10066 |
I'm not sure what you are asking for. KS0108 is parallel interface with lots of pins (14). It is also a 5V only device so really need level conversion between it and the Micromite as the data pins switch between inputs and outputs to test the "busy" status There is a working set of code for it here. I don't currently intend to convert this to a loadable driver, the coding isn't too difficult but it takes ages to get it set up and working on the breadboard before you can test anything. |
||||
viscomjim Guru ![]() Joined: 08/01/2014 Location: United StatesPosts: 925 |
This is awesome Matherp!!!! Thanks for these, will come in extremely handy. Are the commands to use the I2C version of the 1306 the same as what you had in the earlier driver? Also, if I am using the normal I2C pins on the 28 and 44 pinners, is there anything different or will it just work with those pins also? |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10066 |
No: it is a loadable driver and so uses the in-built MM firmware commands BOX, TEXT,RBOX etc. The only thing is that there are only two colours "0" and "anything-else" |
||||
viscomjim Guru ![]() Joined: 08/01/2014 Location: United StatesPosts: 925 |
OH!!! That is awesome. Does that mean fonts can work also???? |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10066 |
Yes, everything that would work on any other type of display except colour yes, but I can't guarantee if it will co-exist with other I2C devices. better to use other pins |
||||
viscomjim Guru ![]() Joined: 08/01/2014 Location: United StatesPosts: 925 |
Matherp, just tried this out using .96" I2C Oled. Alls I can say is... THANK YOU!!!!!!! Now these little displays look AWESOME! What a great CFunction! |
||||
jman![]() Guru ![]() Joined: 12/06/2011 Location: New ZealandPosts: 711 |
Hi Not sure if this the correct place to post this but as I am using this FINE driver with an I2C OLED I thought this the correct spot to post. I am trying to control the Text command but I am having an issue with the orintation example below x=0:y=0:T$="Hello":o$="L" F1=1:F2=2 Text x,y,T$,O$,F1,F2 ''This one will produce an orientation error Text x,y,T$,L,F1,F2 'This one works as expected Regards Jman |
||||
WhiteWizzard Guru ![]() Joined: 05/04/2013 Location: United KingdomPosts: 2927 |
@jman, The syntax of the TEXT command requires a 'justification parameter' after the string. The justification parameter is, for example, something like CM (for centre, middle). Refer to User Manual for other justification options. So in your first example, you are passing a second string' and hence the error ![]() WW |
||||
jman![]() Guru ![]() Joined: 12/06/2011 Location: New ZealandPosts: 711 |
Correct but I want to pass the justifaction paramter via a string or some other method. I see from the manual these can be 1 or 2 letters as if the second letter is missing then the default will apply (Top) Regards Jman |
||||
WhiteWizzard Guru ![]() Joined: 05/04/2013 Location: United KingdomPosts: 2927 |
I don't believe you can pass it as a string, and if this is the case then you will have to look for another way to achieve whatever you wish to do. If you have the desired justification stored in O$ (or even as a value in a variable), then why not simply use SELECT CASE O$ with each CASE line of code then using the justification parameter in its required format (i.e. just one or two letters that are not in quotes) |
||||
jman![]() Guru ![]() Joined: 12/06/2011 Location: New ZealandPosts: 711 |
Hi Thats the way I did it :) was hoping there was a tidier method Thanks for the reply Regards Jman |
||||
jman![]() Guru ![]() Joined: 12/06/2011 Location: New ZealandPosts: 711 |
Hi Peter I have been playing with a 96x16 OLED and noticed a small issue the CLS command does not work. If I start the driver with the screen size option set to 0 then the CLS commands works if I set it to option 2 then the CLS command does not work Any ideas Regards Jman |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10066 |
As a workround does the following work ?: BOX 0,0,96,16,0,0,0 |
||||
jman![]() Guru ![]() Joined: 12/06/2011 Location: New ZealandPosts: 711 |
Hi Peter Unfortunately not I also noticed that the Box,Rbox and Circle don't work. Rather odd. If I change the display to a 128x64 one this all works but the text is the incorrect size (as we know) Regards Jman |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10066 |
Jman This doesn't make any sense as the driver is in two parts. When you call circle it writes to a memory image of the screen which is exactly what text does. The routines are identical irrespective of screen size. Then the actual write is done at the end of the Basic command by a separate routine. Again there is no difference Please could you try different orientations and let me know the result. |
||||
jman![]() Guru ![]() Joined: 12/06/2011 Location: New ZealandPosts: 711 |
HI With the orientation set to 1 it works I originally had it set to 3 Now the commands work but one odd thing to get a box around the edges I have to use box 0,0,95,15,1 and not box 0,0,96,16,1 with orientations 1 and 2 cls works with 3 and 4 it does not. I did not try all the commands in each orientation but can do if required Hope that helps Many Thanks Jman |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10066 |
This is a feature in Geoff's code that I have already discussed with him. No need, I understand the issue but I'm not sure I can fix it easily without a display to test with. Can you live with orientations 1 & 2 only? |
||||
Page 1 of 2 ![]() ![]() |
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |