# micropython-pcd8544 **Repository Path**: Yed_kee/micropython-pcd8544 ## Basic Information - **Project Name**: micropython-pcd8544 - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2024-03-25 - **Last Updated**: 2024-03-25 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # MicroPython PCD8544 A MicroPython library for the Philips PCD8544 84x48 monochrome LCD, used by the Nokia 5110 display. ![demo](docs/demo.jpg) #### Pinout | ![demo](docs/nokia5110_pinout.jpg) | ![demo](docs/esp8266_pinout.jpg) | |-|-| Pin | Name | Description :--:|:----:|:-------------------------------- 1 | RST | External reset input, active low 2 | CE | Chip enable, active low 3 | D/C | Data high / Command low 4 | DIN | Serial data input 5 | CLK | Serial clock, up to 4 Mbits/s 6 | VCC | Supply voltage 2.7-3.3V 7 | BL | Backlight 8 | GND | Ground ## Example Copy the file to your device, using ampy, webrepl or compiling and deploying. eg. ```bash $ ampy put pcd8544.py ``` **Basic Example** ```python import pcd8544 from machine import Pin, SPI spi = SPI(1) spi.init(baudrate=2000000, polarity=0, phase=0) cs = Pin(2) dc = Pin(15) rst = Pin(0) # backlight on bl = Pin(12, Pin.OUT, value=1) lcd = pcd8544.PCD8544(spi, cs, dc, rst) # test pattern (50% on) lcd.data(bytearray([0x55, 0xAA] * 42 * 6)) # bitmap smiley (horzontal msb) lcd.clear() # draw 8x16 in bank 0 (rows 0..7) lcd.position(0, 0) 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 (rows 8..15) lcd.position(0, 1) lcd.data(bytearray(b'\x03\x0C\x10\x21\x21\x41\x48\x48\x48\x49\x25\x21\x10\x0C\x03\x00')) # toggle display, image persists in DDRAM lcd.power_off() lcd.power_on() # nokia logo bitmap lcd.clear() lcd.data(bytearray(b'\x80\x00\x00\x80\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DF\xBF\x5F\xDF\x7F\xDF\x7F\xDF\xAF\x7F\xEE\x8E\xF1\x6E\x99\xF7\x6A\xDD\xB2\x6E\xD5\x7A\xD7\xAC\x75\xDB\x6D\xD5\x7A\xD7\xAC\x7B\xE5\xDE\xA9\x77\xDA\xB5\xEE\x59\xB6\xEB\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) lcd.reset() lcd.init() # swtich to vertical addressing lcd.init(horizontal=False) # adjust contrast, bias and temp lcd.contrast(0x1f, pcd8544.BIAS_1_40, pcd8544.TEMP_COEFF_0) lcd.contrast(0x3f, pcd8544.BIAS_1_48, pcd8544.TEMP_COEFF_0) lcd.contrast(0x3c, pcd8544.BIAS_1_40, pcd8544.TEMP_COEFF_0) lcd.contrast(0x42, pcd8544.BIAS_1_48, pcd8544.TEMP_COEFF_0) lcd.contrast(0x3f, pcd8544.BIAS_1_40, pcd8544.TEMP_COEFF_2) ``` See [/examples](/examples) 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) See [/examples/addressing](/examples/addressing) for more details. ## 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 * [Nokia 5110 LCD Display](https://www.aliexpress.com/item/1pcs-High-Quality-84-48-84x48-LCD-Module-White-backlight-adapter-PCB-for-Nokia-5110-for/32609308327.html) $2.00 USD ## Connections WeMos D1 Mini | PCD8544 LCD ------------- | ---------- D3 (GPIO0) | 1 RST D4 (GPIO2) | 2 CE D8 (GPIO15) | 3 DC D7 (GPIO13) | 4 Din D5 (GPIO14) | 5 Clk 3V3 | 6 Vcc D6 (GPIO12) | 7 BL G | 8 Gnd ## Links * [WeMos D1 Mini](https://wiki.wemos.cc/products:d1:d1_mini) * [micropython.org](http://micropython.org) * [Adafruit Ampy](https://learn.adafruit.com/micropython-basics-load-files-and-run-code/install-ampy) * [PCD8544 Datasheet](docs/PCD8544.pdf) ## License Licensed under the [MIT License](http://opensource.org/licenses/MIT).