Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
YawgNetWiki
Search
Search
Appearance
Log in
Personal tools
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
PiHUD
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=Setup= ===SD Card=== Add the wpa_supplicant.conf file to the boot drive with: <pre> country=US ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 network={ ssid="WIFI_SSID" scan_ssid=1 psk="WIFI_PASSWORD" key_mgmt=WPA-PSK }</pre> Additionally you need to uncomment the spi line in config.txt as well as add the ssh file. ==Libraries== BCM2835 <pre> wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.70.tar.gz tar zxvf bcm2835-1.70.tar.gz cd bcm2835-1.70/ sudo ./configure sudo make sudo make check sudo make install</pre> WiringPi is needed on Pi4 <pre>wget https://project-downloads.drogon.net/wiringpi-latest.deb sudo dpkg -i wiringpi-latest.deb gpio -v</pre> Grab examples <pre>sudo apt-get install p7zip-full python3-pip python3-pil python3-numpy sudo pip3 install RPi.GPIO sudo pip3 install spidev sudo pip3 install picamera sudo wget https://www.waveshare.net/w/upload/a/a8/LCD_Module_RPI_code.7z 7z x LCD_Module_RPI_code.7z -O./LCD_Module_code </pre> ==Python== Just some sample code snips for ref ====Camera==== <pre> ## PiCamera from time import sleep from picamera import PiCamera camera = PiCamera() camera.resolution = (240, 240) camera.capture("camera.bmp") camera.close() </pre> ====2.5 Snippet==== <pre> import os import sys import time import logging import spidev as SPI from picamera import PiCamera sys.path.append("..") from lib import LCD_2inch4 from PIL import Image,ImageDraw,ImageFont # Raspberry Pi pin configuration: RST = 27 DC = 25 BL = 18 bus = 0 device = 0 camera = PiCamera() camera.resolution = (240, 320) camera.capture("camera.bmp") camera.close() disp = LCD_2inch4.LCD_2inch4() disp.Init() disp.clear() image1 = Image.new("RGB", (disp.width, disp.height), "WHITE") draw = ImageDraw.Draw(image1) image = Image.open('camera.bmp') disp.ShowImage(image) time.sleep(3) disp.module_exit() exit() </pre> ====1.54 Demo==== <pre> ## 1inch54 import os import sys import time import logging import spidev as SPI sys.path.append("..") from lib import LCD_1inch54 from PIL import Image,ImageDraw,ImageFont # Raspberry Pi pin configuration: RST = 27 DC = 25 BL = 18 bus = 0 device = 0 logging.basicConfig(level=logging.DEBUG) try: # display with hardware SPI: ''' Warning!!!Don't creation of multiple displayer objects!!! ''' #disp = LCD_1inch54.LCD_1inch54(spi=SPI.SpiDev(bus, device),spi_freq=10000000,rst=RST,dc=DC,bl=BL) disp = LCD_1inch54.LCD_1inch54() # Initialize library. disp.Init() # Clear display. disp.clear() # Create blank image for drawing. image1 = Image.new("RGB", (disp.width, disp.height), "WHITE") draw = ImageDraw.Draw(image1) logging.info("draw point") draw.rectangle((5,10,6,11), fill = "BLACK") draw.rectangle((5,25,7,27), fill = "BLACK") draw.rectangle((5,40,8,43), fill = "BLACK") draw.rectangle((5,55,9,59), fill = "BLACK") logging.info("draw line") draw.line([(20, 10),(70, 60)], fill = "RED",width = 1) draw.line([(70, 10),(20, 60)], fill = "RED",width = 1) draw.line([(170,15),(170,55)], fill = "RED",width = 1) draw.line([(150,35),(190,35)], fill = "RED",width = 1) logging.info("draw rectangle") draw.rectangle([(20,10),(70,60)],fill = "WHITE",outline="BLUE") draw.rectangle([(85,10),(130,60)],fill = "BLUE") logging.info("draw circle") draw.arc((150,15,190,55),0, 360, fill =(0,255,0)) draw.ellipse((150,65,190,105), fill = (0,255,0)) logging.info("draw text") Font1 = ImageFont.truetype("../Font/Font01.ttf",25) Font2 = ImageFont.truetype("../Font/Font01.ttf",35) Font3 = ImageFont.truetype("../Font/Font02.ttf",32) draw.rectangle([(0,65),(140,100)],fill = "WHITE") draw.text((5, 68), 'Hello world', fill = "BLACK",font=Font1) draw.rectangle([(0,115),(190,160)],fill = "RED") draw.text((5, 118), 'WaveShare', fill = "WHITE",font=Font2) draw.text((5, 160), '1234567890', fill = "GREEN",font=Font3) text= u"ๅพฎ้ช็ตๅญ" draw.text((5, 200),text, fill = "BLUE",font=Font3) im_r=image1.rotate(270) disp.ShowImage(im_r) time.sleep(3) logging.info("show image") image = Image.open('../pic/LCD_1inch54.jpg') im_r=image.rotate(270) disp.ShowImage(im_r) time.sleep(3) disp.module_exit() logging.info("quit:") except IOError as e: logging.info(e) except KeyboardInterrupt: disp.module_exit() logging.info("quit:") exit() </pre> ====2.4 Attempt==== <pre> ## 2.4inch import os import sys import time import io import picamera import logging import socketserver from threading import Condition import spidev as SPI sys.path.append("..") from lib import LCD_2inch4 from PIL import Image,ImageDraw,ImageFont # Raspberry Pi pin configuration: RST = 27 DC = 25 BL = 18 bus = 0 device = 0 disp = LCD_2inch4.LCD_2inch4() class StreamingOutput(object): def __init__(self): self.frame = None self.buffer = io.BytesIO() self.condition = Condition() def write(self, buf): if buf.startswith(b'\xff\xd8'): # New frame, copy the existing buffer's content and notify all # clients it's available self.buffer.truncate() with self.condition: self.frame = self.buffer.getvalue() self.condition.notify_all() self.buffer.seek(0) return self.buffer.write(buf) with picamera.PiCamera(resolution='240x320', framerate=30) as camera: output = StreamingOutput() camera.start_recording(output, format='mjpeg') try: disp.Init() disp.clear() time.sleep(30) finally: camera.stop_recording() disp.module_exit() exit() </pre>
Summary:
Please note that all contributions to YawgNetWiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
YawgNetWiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
PiHUD
(section)
Add topic