error hinzugefügt
This commit is contained in:
parent
7fc8488fde
commit
a79f4e44c7
6 changed files with 156 additions and 3 deletions
|
|
@ -1 +1 @@
|
||||||
@reboot sleep 30 && /usr/bin/python3 /home/christof/lcd/test3.py >> /var/log/start_after_boot.log 2>&1
|
@reboot sleep 30 && /usr/bin/python3 /home/christof/lcd/LCD.py >> /var/log/start_after_boot.log 2>&1
|
||||||
|
|
@ -46,7 +46,7 @@ def main():
|
||||||
print("Alle Container sind running + healthy.")
|
print("Alle Container sind running + healthy.")
|
||||||
|
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
["python3", "test.py"],
|
["python3", "/home/christof/lcd/test.py"],
|
||||||
check=True
|
check=True
|
||||||
)
|
)
|
||||||
return 0
|
return 0
|
||||||
|
|
@ -54,6 +54,10 @@ def main():
|
||||||
time.sleep(SLEEP_S)
|
time.sleep(SLEEP_S)
|
||||||
|
|
||||||
print("Timeout: Container nicht rechtzeitig healthy.", file=sys.stderr)
|
print("Timeout: Container nicht rechtzeitig healthy.", file=sys.stderr)
|
||||||
|
subprocess.run(
|
||||||
|
["python3", "/home/christof/lcd/error.py"],
|
||||||
|
check=True
|
||||||
|
)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
@ -2,4 +2,9 @@ python3 -m pip config set global.break-system-packages true
|
||||||
|
|
||||||
sudo pip3 install adafruit-blinka
|
sudo pip3 install adafruit-blinka
|
||||||
|
|
||||||
|
|
||||||
|
sudo pip3 install adafruit-circuitpython-ssd1306
|
||||||
|
|
||||||
|
sudo pip3 install Pillow
|
||||||
|
|
||||||
<img src="Pi.png" alt="mqtt" width="300"/>
|
<img src="Pi.png" alt="mqtt" width="300"/>
|
||||||
|
|
|
||||||
72
Python/error.py
Normal file
72
Python/error.py
Normal file
|
|
@ -0,0 +1,72 @@
|
||||||
|
import board
|
||||||
|
import digitalio
|
||||||
|
from PIL import Image, ImageDraw, ImageFont
|
||||||
|
import adafruit_ssd1306
|
||||||
|
import socket
|
||||||
|
import time
|
||||||
|
|
||||||
|
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||||
|
s.connect(("8.8.8.8", 80)) # keine echte Verbindung, nur Routing
|
||||||
|
ip_address = s.getsockname()[0]
|
||||||
|
s.close()
|
||||||
|
|
||||||
|
|
||||||
|
# Initialize OLED display dimensions
|
||||||
|
WIDTH = 128
|
||||||
|
HEIGHT = 64
|
||||||
|
|
||||||
|
# Set up I2C communication with the OLED display
|
||||||
|
i2c = board.I2C() # Utilizes board's SCL and SDA pins
|
||||||
|
oled = adafruit_ssd1306.SSD1306_I2C(WIDTH, HEIGHT, i2c, addr=0x3C)
|
||||||
|
|
||||||
|
# Clear the OLED display
|
||||||
|
oled.fill(0)
|
||||||
|
oled.show()
|
||||||
|
|
||||||
|
# Create a new image with 1-bit color for drawing
|
||||||
|
image = Image.new("1", (oled.width, oled.height))
|
||||||
|
|
||||||
|
# Obtain a drawing object to manipulate the image
|
||||||
|
draw = ImageDraw.Draw(image)
|
||||||
|
|
||||||
|
# Draw a filled white rectangle as the background
|
||||||
|
draw.rectangle((0, 0, oled.width, oled.height), outline=255, fill=255)
|
||||||
|
|
||||||
|
# Define border size for an inner rectangle
|
||||||
|
BORDER = 5
|
||||||
|
# Draw a smaller black rectangle inside the larger one
|
||||||
|
draw.rectangle(
|
||||||
|
(BORDER, BORDER, oled.width - BORDER - 1, oled.height - BORDER - 1),
|
||||||
|
outline=0,
|
||||||
|
fill=0,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Load the default font for text
|
||||||
|
font = ImageFont.load_default()
|
||||||
|
|
||||||
|
def getfontsize(font, text):
|
||||||
|
# Calculate the size of the text in pixels
|
||||||
|
left, top, right, bottom = font.getbbox(text)
|
||||||
|
return right - left, bottom - top
|
||||||
|
|
||||||
|
# Define the text to be displayed
|
||||||
|
text = "! Error !"
|
||||||
|
# Get the width and height of the text in pixels
|
||||||
|
(font_width, font_height) = getfontsize(font, text)
|
||||||
|
# Draw the text, centered on the display
|
||||||
|
draw.text(
|
||||||
|
(oled.width // 2 - font_width // 2, oled.height // 2 - font_height // 2),
|
||||||
|
text,
|
||||||
|
font=font,
|
||||||
|
fill=255,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Send the image to the OLED display
|
||||||
|
oled.image(image)
|
||||||
|
oled.show()
|
||||||
|
|
||||||
|
DISPLAY_ON_TIME = 10 * 60
|
||||||
|
time.sleep(DISPLAY_ON_TIME)
|
||||||
|
|
||||||
|
# --- OLED sauber ausschalten ---
|
||||||
|
oled.poweroff()
|
||||||
72
Python/test.py
Normal file
72
Python/test.py
Normal file
|
|
@ -0,0 +1,72 @@
|
||||||
|
import board
|
||||||
|
import digitalio
|
||||||
|
from PIL import Image, ImageDraw, ImageFont
|
||||||
|
import adafruit_ssd1306
|
||||||
|
import socket
|
||||||
|
import time
|
||||||
|
|
||||||
|
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||||
|
s.connect(("8.8.8.8", 80)) # keine echte Verbindung, nur Routing
|
||||||
|
ip_address = s.getsockname()[0]
|
||||||
|
s.close()
|
||||||
|
|
||||||
|
|
||||||
|
# Initialize OLED display dimensions
|
||||||
|
WIDTH = 128
|
||||||
|
HEIGHT = 64
|
||||||
|
|
||||||
|
# Set up I2C communication with the OLED display
|
||||||
|
i2c = board.I2C() # Utilizes board's SCL and SDA pins
|
||||||
|
oled = adafruit_ssd1306.SSD1306_I2C(WIDTH, HEIGHT, i2c, addr=0x3C)
|
||||||
|
|
||||||
|
# Clear the OLED display
|
||||||
|
oled.fill(0)
|
||||||
|
oled.show()
|
||||||
|
|
||||||
|
# Create a new image with 1-bit color for drawing
|
||||||
|
image = Image.new("1", (oled.width, oled.height))
|
||||||
|
|
||||||
|
# Obtain a drawing object to manipulate the image
|
||||||
|
draw = ImageDraw.Draw(image)
|
||||||
|
|
||||||
|
# Draw a filled white rectangle as the background
|
||||||
|
draw.rectangle((0, 0, oled.width, oled.height), outline=255, fill=255)
|
||||||
|
|
||||||
|
# Define border size for an inner rectangle
|
||||||
|
BORDER = 5
|
||||||
|
# Draw a smaller black rectangle inside the larger one
|
||||||
|
draw.rectangle(
|
||||||
|
(BORDER, BORDER, oled.width - BORDER - 1, oled.height - BORDER - 1),
|
||||||
|
outline=0,
|
||||||
|
fill=0,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Load the default font for text
|
||||||
|
font = ImageFont.load_default()
|
||||||
|
|
||||||
|
def getfontsize(font, text):
|
||||||
|
# Calculate the size of the text in pixels
|
||||||
|
left, top, right, bottom = font.getbbox(text)
|
||||||
|
return right - left, bottom - top
|
||||||
|
|
||||||
|
# Define the text to be displayed
|
||||||
|
text = ip_address
|
||||||
|
# Get the width and height of the text in pixels
|
||||||
|
(font_width, font_height) = getfontsize(font, text)
|
||||||
|
# Draw the text, centered on the display
|
||||||
|
draw.text(
|
||||||
|
(oled.width // 2 - font_width // 2, oled.height // 2 - font_height // 2),
|
||||||
|
text,
|
||||||
|
font=font,
|
||||||
|
fill=255,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Send the image to the OLED display
|
||||||
|
oled.image(image)
|
||||||
|
oled.show()
|
||||||
|
|
||||||
|
DISPLAY_ON_TIME = 10 * 60
|
||||||
|
time.sleep(DISPLAY_ON_TIME)
|
||||||
|
|
||||||
|
# --- OLED sauber ausschalten ---
|
||||||
|
oled.poweroff()
|
||||||
|
|
@ -12,7 +12,7 @@ services:
|
||||||
ports:
|
ports:
|
||||||
- '3000:3000'
|
- '3000:3000'
|
||||||
volumes:
|
volumes:
|
||||||
- /home/christof/grafana/storage/:/var/lib/grafana'
|
- /home/christof/grafana/storage/:/var/lib/grafana
|
||||||
|
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue