Name | GfxLCD JSON |
Version |
0.8.5
JSON |
| download |
home_page | None |
Summary | gfxlcd is a lib for graphical lcds: ILI9328, SSD1306, SH1106, NJU6450, touch panel: AD7843 @ Raspberry Pi. |
upload_time | 2024-12-27 12:22:26 |
maintainer | None |
docs_url | None |
author | None |
requires_python | None |
license | Copyright (c) 2017 Bartosz Kościów <kosci1@gmail.com> The MIT License Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
gfxlcd
raspberry pi
ili9328
ssd1306
nju6450
lcd
graphical lcd
touch panel
ad7843
ili9486
xpt2046
ad7846
sh1106
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
What it is
===
Library for graphical LCDs for Python on Raspberry Pi. Creates a united interface for supported devices
Supported:
- ili9486 via SPI
- ili9325 via GPIO
- ssd1306 via SPI
- nju6450 via GPIO
- sh1106 via SPI
And for touch panels:
- ad7843 via SPI, uses irq or not
- ad7846/xpt2046
Bonus
- HD44780 emulation (works with CharLCD)
On NJU and SSD uses buffer to keep current content as help for page operations.
Wiring is below
Demos are in demos directory
LCD initialization
===
## SSD1306
### SPI
from driver.ssd1306.spi import SPI
from driver.ssd1306.ssd1306 import SSD1306
drv = SPI()
o = SSD1306(128, 64, drv)
o.init()
If you want to set your own pins:
drv = SPI()
drv.pins = {
'RST': 13,
'DC': 6,
'CS': None,
}
o = SSD1306(128, 64, drv)
o.init()
or
drv = SPI(RST=31, CS=3)
You can add point transformation callback, used during flush:
def transform_ij(lcd, i, j):
offset_width = lcd.height // 2
if 0 <= i < offset_width:
i = i + offset_width
else:
i = i - offset_width
return (i,j)
lcd.xy_callback = transform_ij
## SH1106
Based on SSD1306, has the same functions
### SPI
from gfxlcd.driver.sh1106.spi import SPI
from gfxlcd.driver.sh1106.sh1106 import SH1106
drv = SPI()
lcd = SH1106(132, 64, drv)
or
lcd = SH1106(132, 64, SPI(CS=21))
## NJU6450
### GPIO
from gfxlcd.driver.nju6450.gpio import GPIO
from gfxlcd.driver.nju6450.nju6450 import NJU6450
drv = GPIO()
o = NJU6450(122, 32, drv)
o.init()
Custom wiring:
from gfxlcd.driver.nju6450.gpio import GPIO
from gfxlcd.driver.nju6450.nju6450 import NJU6450
drv = GPIO()
drv.pins = {
'A0': 17,
'E1': 22,
'E2': 21,
'D0': 23,
'D1': 24,
'D2': 25,
'D3': 12,
'D4': 16,
'D5': 20,
'D6': 26,
'D7': 19,
'RST': 5,
}
o = NJU6450(122, 32, drv)
o.init()
## ILI9325
### GPIO
from gfxlcd.driver.ili9325.gpio import GPIO
from gfxlcd.driver.ili9325.ili9325 import ILI9325
drv = GPIO()
o = ILI9325(240, 320, drv)
o.init()
Custom pins:
from gfxlcd.driver.ili9325.gpio import GPIO
from gfxlcd.driver.ili9325.ili9325 import ILI9325
drv = GPIO()
drv.pins = {
'RS': 27,
'W': 17,
'DB8': 22,
'DB9': 23,
'DB10': 24,
'DB11': 5,
'DB12': 12,
'DB13': 16,
'DB14': 20,
'DB15': 21,
'RST': 25,
'LED': None,
'CS': None
}
o = ILI9325(240, 320, drv)
o.init()
## ILI9486
### SPI
from gfxlcd.driver.ili9486.spi import SPI
from gfxlcd.driver.ili9486.ili9486 import ILI9486
drv = SPI()
o = ILI9486(320, 480, drv)
o.rotation = 270
o.init()
Drawing functions
===
draw_pixel(x, y)
draw_line(from_x, from_y, to_x, to_y)
draw_rect(x1, y1, x2, y2)
draw_circle(x1, y1, radius)
draw_arc(x1, y1, radius, from_angle, to_angle
fill_rect(x1, y1, x2, y2)
draw_image(x, y, PIL.Image)
draw_text(x, y, text)
Colours
===
lcd.color = (r, g, b)
lcd.background_color = (r, g ,b)
lcd.threshold = 255 - for images a threshold between black and white (on monochrome)
lcd.transparency_color = [110, 57] #110 - color(s) that are skipped during drawing an image
Fonts
===
Font class implements Font abstract and is a class that has a dictionary with each char:
(..)
[0x3C, 0x66, 0x03, 0x03, 0x73, 0x66, 0x7C, 0x00], # U+0047 (G)
(..)
There is one font for now, 8x8 and named **Font8x8** and is used by default.
Touch panels
===
## AD7843
Constructor:
AD7843(width, height, (int_pin), (callback), (cs_pin))
Can be used with int_pin and cs_pin
def callback(position):
print('(x,y)', position)
touch = AD7843(240, 320, 26, callback, 17)
touch.init()
or without:
touch = AD7843(240, 320)
touch.init()
while True:
try:
time.sleep(0.05)
ret = touch.get_position()
if ret:
print(ret[0], ret[1])
except KeyboardInterrupt:
touch.close()
There is no automatic calibration. It must be done manually.
self.correction = {
'x': 364,
'y': 430,
'ratio_x': 14.35,
'ratio_y': 10.59
}
Wiring
===
## SSD1306
### SPI
SPI wiring + 2 additional pins. Defaults:
LCD Raspberry Pi
GND ----------- GND
+3.3V ----------- +3.3V
SCL ----------- G11
SDA ----------- G10
RST ----------- G13
D/C ----------- G6
## NJU6450
### GPIO
Default wiring:
LCD Raspberry Pi
1 (Vss) ------- GND
2 (Vdd) ------- +5V
3 (V0) ---[-\-] 10k
\--- GND
4 (A0) ---------------------- G17
5 (E1) ---------------------- G22
6 (E2) ---------------------- G21
7 (R/W) ------- GND
8 (D0) ---------------------- G23
9 (D1) ---------------------- G24
10 (D2) ---------------------- G25
11 (D3) ---------------------- G12
12 (D4) ---------------------- G16
13 (D5) ---------------------- G20
14 (D6) ---------------------- G26
15 (D7) ---------------------- G19
16 (RST) ------- +5V
17 (A) ------- +5V
18 (K) ------- GND
## ILI9325
### GPIO
Default:
TFT Raspberry Pi 2B
GND ------------------------ GND
Vcc ------------------------ 3.3
RS ------------------------ G27 (data[H]/cmd[L])
WR ------------------------ G17
RD ------------------------ 3.3 (never read from screen)
DB8 ------------------------ G22
DB9 ------------------------ G23
DB10 ------------------------ G24
DB11 ------------------------ G5
DB12 ------------------------ G12
DB13 ------------------------ G16
DB14 ------------------------ G20
DB15 ------------------------ G21
CS ------------------------ GND (always selected) (or connect to GPIO pin)
REST ------------------------ G25
LED_A ------------------------ 3.3 (can be connected to GPIO pin)
## ILI9486 (Waveshare)
### SPI
Default:
RPi Shield
G17 ----------------- TP_IRQ
G24 ----------------- RS
G25 ----------------- RST
G9 ----------------- LCD_CS
G7 ----------------- TP_CS
HD44780 emulation
===
This driver can work with CharLCD and emulate char LCD
ili_drv = ILIGPIO()
ili_drv.pins['LED'] = 6
ili_drv.pins['CS'] = 18
lcd = ILI9325(240, 320, ili_drv)
lcd.auto_flush = False
lcd.rotation = 0
drv = HD44780(lcd)
lcd = CharLCD(drv.width, drv.height, drv, 0, 0)
lcd.init()
lcd.write('-!Second blarg!')
lcd.write("-second line", 0, 1)
lcd.flush()
Raw data
{
"_id": null,
"home_page": null,
"name": "GfxLCD",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "gfxlcd, raspberry pi, ili9328, ssd1306, nju6450, lcd, graphical lcd, touch panel, ad7843, ili9486, xpt2046, ad7846, sh1106",
"author": null,
"author_email": "Bartosz Ko\u015bci\u00f3w <kosci1@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/19/16/e98437b26b1582485b68e801001d90280020cfce48459e457024becf0c86/gfxlcd-0.8.5.tar.gz",
"platform": null,
"description": "What it is\n===\n\nLibrary for graphical LCDs for Python on Raspberry Pi. Creates a united interface for supported devices\n\nSupported:\n\n- ili9486 via SPI\n- ili9325 via GPIO\n- ssd1306 via SPI\n- nju6450 via GPIO\n- sh1106 via SPI\n\nAnd for touch panels:\n\n- ad7843 via SPI, uses irq or not\n- ad7846/xpt2046\n\nBonus\n\n- HD44780 emulation (works with CharLCD)\n\n\nOn NJU and SSD uses buffer to keep current content as help for page operations.\n\nWiring is below\n\nDemos are in demos directory\n\n\nLCD initialization\n===\n## SSD1306 \n### SPI\n\n from driver.ssd1306.spi import SPI\n from driver.ssd1306.ssd1306 import SSD1306\n drv = SPI()\n o = SSD1306(128, 64, drv)\n o.init()\n \nIf you want to set your own pins:\n\n drv = SPI()\n drv.pins = {\n 'RST': 13,\n 'DC': 6,\n 'CS': None,\n }\n o = SSD1306(128, 64, drv)\n o.init()\n\nor\n\n drv = SPI(RST=31, CS=3)\n\n\nYou can add point transformation callback, used during flush:\n\n def transform_ij(lcd, i, j):\n offset_width = lcd.height // 2\n if 0 <= i < offset_width:\n i = i + offset_width\n else:\n i = i - offset_width\n \n return (i,j)\n\n\n lcd.xy_callback = transform_ij\n\n## SH1106\n\nBased on SSD1306, has the same functions\n\n### SPI\n\n from gfxlcd.driver.sh1106.spi import SPI\n from gfxlcd.driver.sh1106.sh1106 import SH1106\n drv = SPI()\n lcd = SH1106(132, 64, drv)\n\nor\n \n lcd = SH1106(132, 64, SPI(CS=21))\n\n\n## NJU6450\n### GPIO\n \n from gfxlcd.driver.nju6450.gpio import GPIO\n from gfxlcd.driver.nju6450.nju6450 import NJU6450\n drv = GPIO()\n o = NJU6450(122, 32, drv)\n o.init()\n \nCustom wiring:\n \n from gfxlcd.driver.nju6450.gpio import GPIO\n from gfxlcd.driver.nju6450.nju6450 import NJU6450\n drv = GPIO()\n drv.pins = {\n 'A0': 17,\n 'E1': 22,\n 'E2': 21,\n 'D0': 23,\n 'D1': 24,\n 'D2': 25,\n 'D3': 12,\n 'D4': 16,\n 'D5': 20,\n 'D6': 26,\n 'D7': 19,\n 'RST': 5,\n }\n o = NJU6450(122, 32, drv)\n o.init()\n\n## ILI9325\n### GPIO\n\n from gfxlcd.driver.ili9325.gpio import GPIO\n from gfxlcd.driver.ili9325.ili9325 import ILI9325\n drv = GPIO()\n o = ILI9325(240, 320, drv)\n o.init()\n \nCustom pins:\n \n from gfxlcd.driver.ili9325.gpio import GPIO\n from gfxlcd.driver.ili9325.ili9325 import ILI9325\n drv = GPIO()\n drv.pins = {\n 'RS': 27,\n 'W': 17,\n 'DB8': 22,\n 'DB9': 23,\n 'DB10': 24,\n 'DB11': 5,\n 'DB12': 12,\n 'DB13': 16,\n 'DB14': 20,\n 'DB15': 21,\n 'RST': 25,\n 'LED': None,\n 'CS': None\n }\n o = ILI9325(240, 320, drv)\n o.init()\n\n## ILI9486\n### SPI\n\n from gfxlcd.driver.ili9486.spi import SPI\n from gfxlcd.driver.ili9486.ili9486 import ILI9486\n drv = SPI()\n o = ILI9486(320, 480, drv)\n o.rotation = 270\n o.init()\n\nDrawing functions\n===\ndraw_pixel(x, y)\n\ndraw_line(from_x, from_y, to_x, to_y)\n\ndraw_rect(x1, y1, x2, y2)\n\ndraw_circle(x1, y1, radius)\n\ndraw_arc(x1, y1, radius, from_angle, to_angle\n\nfill_rect(x1, y1, x2, y2)\n\ndraw_image(x, y, PIL.Image)\n\ndraw_text(x, y, text)\n\nColours\n===\nlcd.color = (r, g, b)\n\nlcd.background_color = (r, g ,b)\n\nlcd.threshold = 255 - for images a threshold between black and white (on monochrome)\n\nlcd.transparency_color = [110, 57] #110 - color(s) that are skipped during drawing an image\n\nFonts\n===\nFont class implements Font abstract and is a class that has a dictionary with each char:\n\n (..)\n [0x3C, 0x66, 0x03, 0x03, 0x73, 0x66, 0x7C, 0x00], # U+0047 (G)\n (..)\n\nThere is one font for now, 8x8 and named **Font8x8** and is used by default.\n\nTouch panels\n===\n\n## AD7843\n\nConstructor:\n \n AD7843(width, height, (int_pin), (callback), (cs_pin))\n \nCan be used with int_pin and cs_pin\n\n def callback(position):\n print('(x,y)', position)\n \n touch = AD7843(240, 320, 26, callback, 17)\n touch.init()\n\nor without:\n\n touch = AD7843(240, 320)\n touch.init()\n\n while True:\n try:\n time.sleep(0.05)\n ret = touch.get_position()\n if ret:\n print(ret[0], ret[1])\n \n except KeyboardInterrupt:\n touch.close()\n\nThere is no automatic calibration. It must be done manually.\n \n self.correction = {\n 'x': 364,\n 'y': 430,\n 'ratio_x': 14.35,\n 'ratio_y': 10.59\n }\n \nWiring\n===\n\n## SSD1306\n### SPI\nSPI wiring + 2 additional pins. Defaults:\n\n LCD Raspberry Pi\n GND ----------- GND\n +3.3V ----------- +3.3V\n SCL ----------- G11\n SDA ----------- G10\n RST ----------- G13\n D/C ----------- G6\n\n\n## NJU6450\n### GPIO\nDefault wiring:\n\n LCD Raspberry Pi\n 1 (Vss) ------- GND\n 2 (Vdd) ------- +5V\n 3 (V0) ---[-\\-] 10k\n \\--- GND\n 4 (A0) ---------------------- G17\n 5 (E1) ---------------------- G22\n 6 (E2) ---------------------- G21\n 7 (R/W) ------- GND\n 8 (D0) ---------------------- G23\n 9 (D1) ---------------------- G24\n 10 (D2) ---------------------- G25\n 11 (D3) ---------------------- G12\n 12 (D4) ---------------------- G16\n 13 (D5) ---------------------- G20\n 14 (D6) ---------------------- G26\n 15 (D7) ---------------------- G19\n 16 (RST) ------- +5V\n 17 (A) ------- +5V\n 18 (K) ------- GND\n\n## ILI9325\n### GPIO\nDefault:\n\n TFT Raspberry Pi 2B\n \n GND ------------------------ GND\n Vcc ------------------------ 3.3\n RS ------------------------ G27 (data[H]/cmd[L])\n WR ------------------------ G17 \n RD ------------------------ 3.3 (never read from screen)\n DB8 ------------------------ G22\n DB9 ------------------------ G23\n DB10 ------------------------ G24\n DB11 ------------------------ G5\n DB12 ------------------------ G12\n DB13 ------------------------ G16\n DB14 ------------------------ G20\n DB15 ------------------------ G21\n CS ------------------------ GND (always selected) (or connect to GPIO pin)\n REST ------------------------ G25\n LED_A ------------------------ 3.3 (can be connected to GPIO pin) \n\n## ILI9486 (Waveshare)\n### SPI\nDefault:\n\n RPi Shield\n G17 ----------------- TP_IRQ\n G24 ----------------- RS\n G25 ----------------- RST\n G9 ----------------- LCD_CS\n G7 ----------------- TP_CS\n\n\nHD44780 emulation\n===\n\nThis driver can work with CharLCD and emulate char LCD\n\n ili_drv = ILIGPIO()\n ili_drv.pins['LED'] = 6\n ili_drv.pins['CS'] = 18\n lcd = ILI9325(240, 320, ili_drv)\n lcd.auto_flush = False\n lcd.rotation = 0\n\n drv = HD44780(lcd)\n lcd = CharLCD(drv.width, drv.height, drv, 0, 0)\n lcd.init()\n\n lcd.write('-!Second blarg!')\n lcd.write(\"-second line\", 0, 1)\n lcd.flush()\n",
"bugtrack_url": null,
"license": "Copyright (c) 2017 Bartosz Ko\u015bci\u00f3w <kosci1@gmail.com> The MIT License Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
"summary": "gfxlcd is a lib for graphical lcds: ILI9328, SSD1306, SH1106, NJU6450, touch panel: AD7843 @ Raspberry Pi.",
"version": "0.8.5",
"project_urls": {
"Homepage": "https://github.com/bkosciow/gfxlcd"
},
"split_keywords": [
"gfxlcd",
" raspberry pi",
" ili9328",
" ssd1306",
" nju6450",
" lcd",
" graphical lcd",
" touch panel",
" ad7843",
" ili9486",
" xpt2046",
" ad7846",
" sh1106"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "61ec6428c679a08eaab5a2eb6b75a9a45e6bb7e6dcc22f3c00e5cadd119fb8ff",
"md5": "0e5a5694e564311c38d7da7a9cebf7b5",
"sha256": "2820a27d0a3978044a476d24940f1b65d75df7b8bba904c14a9ed2946edf9891"
},
"downloads": -1,
"filename": "GfxLCD-0.8.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "0e5a5694e564311c38d7da7a9cebf7b5",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 53252,
"upload_time": "2024-12-27T12:22:24",
"upload_time_iso_8601": "2024-12-27T12:22:24.212241Z",
"url": "https://files.pythonhosted.org/packages/61/ec/6428c679a08eaab5a2eb6b75a9a45e6bb7e6dcc22f3c00e5cadd119fb8ff/GfxLCD-0.8.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "1916e98437b26b1582485b68e801001d90280020cfce48459e457024becf0c86",
"md5": "ebb5232ef0fe93ee08c1cc7ed4c21d32",
"sha256": "1ef21d40b2fee62c5da0d25bbabfd7ff6de69dab767adbdb692f04bc22c2161a"
},
"downloads": -1,
"filename": "gfxlcd-0.8.5.tar.gz",
"has_sig": false,
"md5_digest": "ebb5232ef0fe93ee08c1cc7ed4c21d32",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 29350,
"upload_time": "2024-12-27T12:22:26",
"upload_time_iso_8601": "2024-12-27T12:22:26.878630Z",
"url": "https://files.pythonhosted.org/packages/19/16/e98437b26b1582485b68e801001d90280020cfce48459e457024becf0c86/gfxlcd-0.8.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-27 12:22:26",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "bkosciow",
"github_project": "gfxlcd",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"tox": true,
"lcname": "gfxlcd"
}