Difference between revisions of "Template:RPi User Guides for 4.2inch e-Paper Cloud"

From Waveshare Wiki
Jump to: navigation, search
m (Text replacement - "https://www.waveshare.com/w/upload/" to "https://files.waveshare.com/upload/")
 
(2 intermediate revisions by one other user not shown)
Line 16: Line 16:
 
<pre>
 
<pre>
 
sudo apt-get install p7zip-full
 
sudo apt-get install p7zip-full
sudo wget https://www.waveshare.com/w/upload/2/2e/Cloud_RPI.7z
+
sudo wget https://files.waveshare.com/upload/2/2e/Cloud_RPI.7z
 
7z x Cloud_RPI.7z
 
7z x Cloud_RPI.7z
 
cd Cloud_RPI  
 
cd Cloud_RPI  
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]]
  
 
==tcp_sver.py==
 
==tcp_sver.py==
Path:Cloud_RPI/lib/tcp_server <br />
+
Path: Cloud_RPI/lib/tcp_server <br />
Vreate a tcp_server class in tcp_sver.py file. You need to inherits the class and refactor the handle function when using.
+
Create a tcp_server class in the tcp_sver.py file. You need to inherit the class and refactor the handle function when using.
 
<pre>
 
<pre>
 
def handle(self)
 
def handle(self)
 
</pre>
 
</pre>
Every time the new client connected, it should call the handle function.
+
Every time a new client is connected, it should call the handle function.
  
 
==='''Receive Message'''===
 
==='''Receive Message'''===
Line 58: Line 58:
 
def Send_cmd(self,cmd)
 
def Send_cmd(self,cmd)
 
</pre>
 
</pre>
Parameter cmd is the command sent<br />
+
Parameter cmd is the command sent.<br />
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
Line 69: Line 69:
 
def Send_data(self,data)
 
def Send_data(self,data)
 
</pre>
 
</pre>
The parameter data is message transmitte (inlcuded addree and lenghta nd so on) data.<br />
+
The parameter data is a message transmitted (including address and lenghta nd so on) data.<br />
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
Line 81: Line 81:
 
def set_size(self,w,h)
 
def set_size(self,w,h)
 
</pre>
 
</pre>
w: The width of image; h: The height of image.<br />
+
w: The width of the image; h: The height of the image.<br />
Take bicolor e-Paper as example, 1 bit stands of one pixel, then you we gets<br />
+
Take bicolor e-Paper as an example, 1 bit stands for one pixel, then you get.<br />
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
Line 96: Line 96:
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
! Paramter!!Send times!! Lenght of every frame(len) !! Content
+
! Parameter!!Send times!! Length 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
+
| DATA(Image data) || Total length of image data/length of singal frame(len)|| 1024 Byte(Configurable) || 0x57+4 Byte addr+ 4 Byte len +1 Byte num + len Byte data+Parity
 
|}
 
|}
<font color="red">'''The lenght of singal transmittion should less than 1100 Byte, or it will cause data loss.'''</font><br />
+
<font color="red">''' The length of signal transmission should less than 1100 Byte, or it will cause data loss.'''</font><br />
 
 
 
 
  
 
=='''Check voltage of battery'''==
 
=='''Check voltage of battery'''==
*Get the current voltage
+
*Get the current voltage.
 
<pre>
 
<pre>
 
def check_batter(self)
 
def check_batter(self)
 
</pre>
 
</pre>
 
=='''Power Off Function'''==
 
=='''Power Off Function'''==
*Power off or low power state
+
*Power off or low power state.
 
  def Shutdown(self)
 
  def Shutdown(self)
  

Latest revision as of 06:42, 2 September 2023

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://files.waveshare.com/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.
Cloud ESP32 e-Paper Board manual 10.png

tcp_sver.py

Path: Cloud_RPI/lib/tcp_server
Create a tcp_server class in the tcp_sver.py file. You need to inherit the class and refactor the handle function when using.

def handle(self)

Every time a new client is 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 a message transmitted (including address and lenghta nd so on) data.

Command
data 0x57+data+ Parity

Set size

def set_size(self,w,h)

w: The width of the image; h: The height of the image.
Take bicolor e-Paper as an example, 1 bit stands for one pixel, then you get.

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.

Parameter Send times Length of every frame(len) Content DATA(Image data) Total length of image data/length of singal frame(len) 1024 Byte(Configurable) 0x57+4 Byte addr+ 4 Byte len +1 Byte num + len Byte data+Parity

The length of signal transmission should less than 1100 Byte, or it will cause data loss.

Check voltage of battery

  • Get the current voltage.
def check_batter(self)

Power Off Function

  • Power off or low power state.
def Shutdown(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):

waveshare_epd.py

Directory: Cloud_RPI/lib/waveshare_epd
Convert image information to queue

def getbuffer(self, image):