Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Run RaspberryPi HATs On PiSquare Using Application(GUI)/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# PiSQUARE GUI CONTROLLER

<img src = "https://github.com/sbcshop/PiSquare/blob/main/images/img29.png" />

### SPI Control
<img src = "https://github.com/sbcshop/PiSquare/blob/main/images/img30.png" />

### GPIO Control
<img src = "https://github.com/sbcshop/PiSquare/blob/main/images/img31.png" />

### **pisquare_gui_controller.py - Run this file in raspberry pi**
### **config_protocol.py - this file is the configuration file**


Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
class I2C_Socket():
def I2C_Read(device):
ir = 'I2C'+ ',' + 'R' + ',' + device
return ir


def I2C_Write(device,data):
wr = 'I2C' + ',' + 'W' + ',' + device + ',' + data
return wr


class UART_Socket():
def UART_Read(device):
ur = 'UART'+','+ 'R' + ',' + device
return ur

def UART_Write(device,data):
uw = 'UART'+ ','+'W' + ',' + + device + ',' + data
return uw


class GPIO_Socket():
def GPIO_Read(gpio):
gr = 'GPIO'+ ',' + gpio + ',' + 'R'
return gr


def GPIO_Write(gpio,state):
gw = 'GPIO'+ ',' + gpio + ',' + 'W' + ',' + state
return gw

class SPI_Socket():

def SPI_Read(device):
sr = 'SPI'+',' + 'R' + ',' + device
return sr

def SPI_Write(device,data):
sw = 'SPI'+ ',' + 'W' + ',' + device + ',' + data
return sw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,12 @@ def UART_Pin_Read(device):

oled = SSD1306_I2C(WIDTH, HEIGHT, i2c) # Init oled display

oled.fill(0)
oled.text("RFID HAT",30,5)
oled.show()
time.sleep(2)
oled.fill(0)
oled.show()
for i in range(2):
while 1:
data_Read = rfid.readline(12)#read data comming from other pico lora expansion
if data_Read is not None:
data=data_Read.decode("utf-8")
Expand All @@ -265,6 +264,7 @@ def UART_Pin_Read(device):
oled.fill(0)
oled.show()
return data
break
time.sleep(2)

elif device == "barcode_hat":
Expand All @@ -283,17 +283,19 @@ def info():
tft.fill_rect(0, 105, 240,10, st7789.RED)

info()
time.sleep(4)
time.sleep(2)
tft.fill(0)
data_Read = barcode.readline()#read data comming from other pico lora expansion
for i in range(2):
while 1:
data_Read = barcode.readline()#read data comming from other pico lora expansion
if data_Read:
if '\r' in data_Read:
data=data_Read.decode("utf-8")
tft.text(font,data, 0,50 ,st7789.GREEN)
tft.fill_rect(0, 95, 240,10, st7789.RED)
return data[:-1]

if '\r' in data_Read:
data=data_Read.decode("utf-8")
tft.text(font,data, 0,50 ,st7789.GREEN)
tft.fill_rect(0, 95, 240,10, st7789.RED)
return data[:-1]
break


time.sleep(2)

elif device == 'gps_hat':
Expand Down Expand Up @@ -330,7 +332,7 @@ def RMC_Read():
longi = convert_to_degrees(longi)
return lat,longi,nmea_time,speed_over_ground,date

for _ in range(1000):
while 1:
x = RMC_Read() #Recommended minimum specific GNSS data
if x is not None:
a = list(x)
Expand Down Expand Up @@ -405,7 +407,7 @@ def I2C_Pin_Write(device,Data):
def SPI_Pin_Write(device,data):
spi = SPI(1, baudrate=40000000, sck=Pin(10), mosi=Pin(11))
if device == 'lcd1.3':
tft = st7789.ST7789(spi,240,240,reset=Pin(8, Pin.OUT),cs=Pin(5, Pin.OUT),dc=Pin(22, Pin.OUT),backlight=Pin(26, Pin.OUT),rotation=1)#SPI interface for tft screen
tft = st7789.ST7789(spi,240,240,reset=Pin(8, Pin.OUT),cs=Pin(9, Pin.OUT),dc=Pin(22, Pin.OUT),backlight=Pin(26, Pin.OUT),rotation=1)#SPI interface for tft screen
tft.init()
time.sleep(0.5)#time delay
tft.text(font,data, 10,40,st7789.YELLOW)# print on tft screen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,12 @@ def UART_Pin_Read(device):

oled = SSD1306_I2C(WIDTH, HEIGHT, i2c) # Init oled display

oled.fill(0)
oled.text("RFID HAT",30,5)
oled.show()
time.sleep(2)
oled.fill(0)
oled.show()
for i in range(2):
while 1:
data_Read = rfid.readline(12)#read data comming from other pico lora expansion
if data_Read is not None:
data=data_Read.decode("utf-8")
Expand All @@ -265,6 +264,7 @@ def UART_Pin_Read(device):
oled.fill(0)
oled.show()
return data
break
time.sleep(2)

elif device == "barcode_hat":
Expand All @@ -283,17 +283,19 @@ def info():
tft.fill_rect(0, 105, 240,10, st7789.RED)

info()
time.sleep(4)
time.sleep(2)
tft.fill(0)
data_Read = barcode.readline()#read data comming from other pico lora expansion
for i in range(2):
while 1:
data_Read = barcode.readline()#read data comming from other pico lora expansion
if data_Read:
if '\r' in data_Read:
data=data_Read.decode("utf-8")
tft.text(font,data, 0,50 ,st7789.GREEN)
tft.fill_rect(0, 95, 240,10, st7789.RED)
return data[:-1]

if '\r' in data_Read:
data=data_Read.decode("utf-8")
tft.text(font,data, 0,50 ,st7789.GREEN)
tft.fill_rect(0, 95, 240,10, st7789.RED)
return data[:-1]
break


time.sleep(2)

elif device == 'gps_hat':
Expand Down Expand Up @@ -330,7 +332,7 @@ def RMC_Read():
longi = convert_to_degrees(longi)
return lat,longi,nmea_time,speed_over_ground,date

for _ in range(1000):
while 1:
x = RMC_Read() #Recommended minimum specific GNSS data
if x is not None:
a = list(x)
Expand Down Expand Up @@ -405,7 +407,7 @@ def I2C_Pin_Write(device,Data):
def SPI_Pin_Write(device,data):
spi = SPI(1, baudrate=40000000, sck=Pin(10), mosi=Pin(11))
if device == 'lcd1.3':
tft = st7789.ST7789(spi,240,240,reset=Pin(8, Pin.OUT),cs=Pin(5, Pin.OUT),dc=Pin(22, Pin.OUT),backlight=Pin(26, Pin.OUT),rotation=1)#SPI interface for tft screen
tft = st7789.ST7789(spi,240,240,reset=Pin(8, Pin.OUT),cs=Pin(9, Pin.OUT),dc=Pin(22, Pin.OUT),backlight=Pin(26, Pin.OUT),rotation=1)#SPI interface for tft screen
tft.init()
time.sleep(0.5)#time delay
tft.text(font,data, 10,40,st7789.YELLOW)# print on tft screen
Expand Down
Binary file added images/img29.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/img30.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/img31.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.