Difference between revisions of "Template:RPi User Guides for 4.2inch e-Paper Cloud"
Line 32: | Line 32: | ||
=API Description= | =API Description= | ||
− | |||
There are three directories in lib,http_get、tcp_server和waveshare_epd, They are used to climb HTTP pictures, TCP service, and the functions of e-Paper. <br /> | There are three directories in lib,http_get、tcp_server和waveshare_epd, They are used to climb HTTP pictures, TCP service, and the functions of e-Paper. <br /> | ||
[[File:Cloud_ESP32_e-Paper_Board_manual_10.png|800px]] | [[File:Cloud_ESP32_e-Paper_Board_manual_10.png|800px]] |
Revision as of 09:51, 28 June 2022
Using Guides for RPI
Install Libraries
#python3 sudo apt-get update sudo apt-get install python3-pip sudo apt-get install python3-pil sudo apt-get install python3-tqdm sudo apt-get install python3-numpy sudo apt-get install python3-progressbar
Download the demo codes
Open a terminal and runthe following commands:
sudo apt-get install p7zip-full sudo wget https://www.waveshare.com/w/upload/2/2e/Cloud_RPI.7z 7z x Cloud_RPI.7z cd Cloud_RPI
python
- The demo codes can only support python3.
- Please go to the directory of Cloud_RPI and run the command:
#This code is used to climb the picture of the Waveshare website and transmit the image data to the slave device. sudo python3 ./examples/display_WS.py #The codes will draw figures and send the image data to the slave device. sudo python3 ./examples/display_EPD.py
API Description
There are three directories in lib,http_get、tcp_server和waveshare_epd, They are used to climb HTTP pictures, TCP service, and the functions of e-Paper.
tcp_sver.py
Path:Cloud_RPI/lib/tcp_server
Vreate a tcp_server class in tcp_sver.py file. You need to inherits the class and refactor the handle function when using.
def handle(self)
Every time the new client connected, it should call the handle function.
Receive Message
def Get_msg(self)
Command | Return |
---|---|
'$'+Data+'#' | Data |
Send Command
def Send_cmd(self,cmd)
Parameter cmd is the command sent
Command | |
---|---|
cmd | ‘;’+cmd+'/'+Parity |
Sent data
def Send_data(self,data)
The parameter data is message transmitte (inlcuded addree and lenghta nd so on) data.
Command | |
---|---|
data | 0x57+data+ Parity |
Set suze
def set_size(self,w,h)
w: The width of image; h: The height of image.
Take bicolor e-Paper as example, 1 bit stands of one pixel, then you we gets
Len of data=Width of image(w)*Height of image(h)/8 |
---|
Refer to 4.2inch e-Paper Module
Update function
def flush_buffer(self,DATA)
DATA; The image data. the image data can be get by the getbuffer function.
Paramter | Send times | Lenght of every frame(len) | Content | DATA(Image data) | Total lenght of image data/lenght of singal frame(len) | 1024 Byte(Configurable) | 0x57+4 Byte addr+ 4 Byte len +1 Byte num + len Byte data+Parity |
---|
The lenght of singal transmittion should less than 1100 Byte, or it will cause data loss.
Check voltage of battery
- Get the current voltage
def check_batter(self)
http_get.py
Path:Cloud_RPI/lib/http_get
- Download picture
def Get_PNG(Url,Name)
This function is used to download the picture from Url and save it to the current directory with Name
epd4in2.py
Path:Cloud_RPI/lib/waveshare_epd
- Convert the picture to image data.
def getbuffer(self, image):