From 1defe49ddc70996343362764ccba4223eab46fed Mon Sep 17 00:00:00 2001 From: Mike Causer Date: Sat, 24 Jun 2017 16:32:05 +1000 Subject: [PATCH] Shorter method names _write_cmd() renamed to cmd() _write_data() renamed to data() --- README.md | 29 +++++++++++++++++++++-------- docs/pcd8544-horizontal.gif | Bin 0 -> 12230 bytes docs/pcd8544-vertical.gif | Bin 0 -> 12230 bytes pcd8544.py | 20 ++++++++++---------- setup.py | 2 +- 5 files changed, 32 insertions(+), 19 deletions(-) create mode 100644 docs/pcd8544-horizontal.gif create mode 100644 docs/pcd8544-vertical.gif diff --git a/README.md b/README.md index aeb4127..ccdee91 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ -PCD8544 -======= +# MicroPython PCD8544 A MicroPython library for the PCD8544 84x48 LCD, used by the Nokia 5110 display. @@ -55,16 +54,16 @@ BL = Pin(12, Pin.OUT, value=1) lcd = pcd8544.PCD8544(spi, CE, DC, RST) # test pattern (50% on) -lcd._write_data(bytearray([0x55, 0xAA] * 42 * 6)) +lcd.data(bytearray([0x55, 0xAA] * 42 * 6)) # bitmap smiley (horzontal msb) lcd.clear() # draw 8x16 in bank 0 lcd.position(0, 0) -lcd._write_data(bytearray(b'\xE0\x38\xE4\x22\xA2\xE1\xE1\x61\xE1\x21\xA2\xE2\xE4\x38\xE0\x00')) +lcd.data(bytearray(b'\xE0\x38\xE4\x22\xA2\xE1\xE1\x61\xE1\x21\xA2\xE2\xE4\x38\xE0\x00')) # draw 8x16 in bank 1 lcd.position(0, 1) -lcd._write_data(bytearray(b'\x03\x0C\x10\x21\x21\x41\x48\x48\x48\x49\x25\x21\x10\x0C\x03\x00')) +lcd.data(bytearray(b'\x03\x0C\x10\x21\x21\x41\x48\x48\x48\x49\x25\x21\x10\x0C\x03\x00')) # toggle display, DDRAM persists image lcd.power_off() @@ -72,7 +71,7 @@ lcd.power_on() # nokia logo bitmap lcd.clear() -lcd._write_data(bytearray(b'\x80\x00\x00\x80\x00\x00\x80\x00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\xDD\xB6\x69\xD6\xBF\xE8\x55\xEF\xB9\xD6\xED\xB5\x5B\xAB\xFF\xFD\xF7\xFF\x01\x01\x01\x01\xE1\xC1\x81\x03\x05\x0F\x1D\x2F\x7E\x01\x00\x01\x01\xFF\xFE\x03\x01\x01\x00\xF1\xF0\xF1\x71\xF1\xF1\xB1\xF1\x01\x01\x01\x03\xFE\xFF\x01\x01\x01\x01\xBE\x1B\x0D\x07\x03\x41\xE1\xF1\xF9\x6D\xFF\xFF\x00\x01\x01\x01\xFF\xFF\xEB\x3E\x0D\x03\x01\x41\x71\x70\x41\x01\x03\x0E\x3B\xEF\xFE\xFB\xEE\x7D\xF7\xFF\xFF\xFF\xFF\xFE\xFF\xF0\xF0\xF0\xF0\xFF\xFF\xFF\xFF\xFE\xFC\xF8\xF0\xF0\xF0\xF0\xF0\xF0\xFF\xFF\xF8\xF0\xF0\xF0\xF1\xF1\xF1\xF1\xF1\xF1\xF1\xF1\xF0\xF0\xF0\xF8\xFF\xFF\xF0\xF0\xF0\xF0\xFF\xFF\xFE\xFC\xF8\xF0\xF0\xF1\xF3\xF7\xFF\xFF\xF0\xF0\xF0\xF0\xFF\xF3\xF0\xF0\xF0\xFC\xFC\xFC\xFC\xFC\xFC\xFC\xFC\xF0\xF0\xF0\xF3\xFF\xFF\xFF\xFF\xFF')) lcd.invert(True) lcd.invert(False) @@ -106,14 +105,28 @@ framebuf.rect(40, 16, 8, 8, 1) framebuf.fill_rect(16, 32, 8, 8, 1) lcd.position(0, 0) -lcd._write_data(buffer) +lcd.data(buffer) framebuf.fill(0) -lcd._write_data(buffer) +lcd.data(buffer) ``` See [pcd8544_examples.py](pcd8544_examples.py) for more. +## Addressing + +Each animation frame represents 1 of 504 bytes written to the DDRAM. `lcd.data(bytearray(b'\xFF'))` + +In horizontal mode you can use framebuf with MONO_VLSB format. Vertical mode does not have a compatible framebuf format. + +**Horizontal** + +![Horizontal](docs/pcd8544-horizontal.gif) + +**Vertical** + +![Vertical](docs/pcd8544-vertical.gif) + ## Parts * [WeMos D1 Mini](https://www.aliexpress.com/store/product/D1-mini-Mini-NodeMcu-4M-bytes-Lua-WIFI-Internet-of-Things-development-board-based-ESP8266/1331105_32529101036.html) $4.00 USD diff --git a/docs/pcd8544-horizontal.gif b/docs/pcd8544-horizontal.gif new file mode 100644 index 0000000000000000000000000000000000000000..9b5c28a21c8d8bfebf33a5158e82e6b7c5258284 GIT binary patch literal 12230 zcmZ|QId5ZC7zW@wcAUhq6Fd8!*jb%DaW*H;o;c3pI8HKufR=_of!Ifg1{x}mW&|w= z8cHN2wh9ReAqonR1~Jkw0t85eq(UG+x4L@t-S?bZobwis4|8iz-3{i0*FwR~^W^bQ z*VorKFX`)8xp4Ptf45S|&d!JL+|nO4kst^K)3<}Sp9GOt1Uxnx3Yw&e=9=-wJgm1yO z;XCkM_#S*8egH4P58*}l5&Rf_0zZY9;AikM{2X3^U%)TnSMcDb+pC@5TdU?Fco<#- zkHBl;b?|z46y5-j!Q=2ocoRGUPr{qwE$~)&8@wIf0q=x&!Mou-@LqTyydORQAB3mi zY4{L)7(N0Yg^$6<;TiY@d=fqdpN7xCXW?`3dH4c63txmU!I$AH@KtyYz6M{1=iwXh zP52gk8@>bIh3~=l;Ro;n{19G*AHk2|C-75v34R7I!_VOr_yznDegzMLWYr$O0}sK& z@EUjoUJI{-*TbXm26zk}hd08T;0bsV-VASnx5C@t?eGqGC%g;Z4ex>X!u#O;@B#QB zJOxj~hv38T5%?&43_cFez$f67@G1B-dpTbMZ8F z^I>=mJOZzU*TL)IQFsG929LuV;Z5)aJPB`xx4>KBZSZz@2fP#B1@DIUzTFjpM}rC=iv+REPN5Z1Yd@)z*pfp_!@j2 zo`-M1H{o0GZTJp+7rqDIhabQT@I!bJegr>;pTJMyCHNV<3_pig;1}>q_!T?|Qt0>U z9>RPWUIUN7YvFb9dUzDx0FS}r@J4tOJONL_o8c|+R(Kn{9o_-&gm=Na;XUwPcptnU zJ^&wtr{HP$5PTRu0w0Bs!N=h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