wdisp.py fertig.
This commit is contained in:
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
db.ini
|
||||||
|
*.bak
|
||||||
|
LCD1602.py
|
||||||
|
__pycache__
|
40
degdisp.py
40
degdisp.py
@@ -1,40 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
# encoding: utf-8
|
|
||||||
|
|
||||||
import time
|
|
||||||
import configparser
|
|
||||||
import logging
|
|
||||||
import LCD1602
|
|
||||||
try:
|
|
||||||
import smbus2
|
|
||||||
except ImportError: # Wenn smbus2 nicht zu importieren ist, nehmen wir smbus
|
|
||||||
from smbus import SMBus
|
|
||||||
import mysql.connector
|
|
||||||
|
|
||||||
port = 1
|
|
||||||
adresse_lcd1602 = 0x25
|
|
||||||
deg = 0o1212
|
|
||||||
|
|
||||||
logging.basicConfig( format='%(asctime)s [%(levelname)s] %(funcName)s: %(message)s', level=logging.DEBUG)
|
|
||||||
|
|
||||||
|
|
||||||
def info(msg):
|
|
||||||
logging.info(msg)
|
|
||||||
|
|
||||||
def debug(msg):
|
|
||||||
logging.debug(msg)
|
|
||||||
|
|
||||||
def print_weather():
|
|
||||||
lcd.setCursor(0, 0)
|
|
||||||
lcd.printout('0o{0:o}'.format(deg))
|
|
||||||
|
|
||||||
|
|
||||||
#LCD1602 initialisieren
|
|
||||||
lcd=LCD1602.LCD1602(16,2)
|
|
||||||
|
|
||||||
try:
|
|
||||||
while True:
|
|
||||||
print_weather()
|
|
||||||
except(KeyboardInterrupt):
|
|
||||||
lcd.clear()
|
|
||||||
|
|
8
wdisp.py
8
wdisp.py
@@ -27,11 +27,13 @@ def debug(msg):
|
|||||||
|
|
||||||
def print_weather(temperature, humidity, pressure):
|
def print_weather(temperature, humidity, pressure):
|
||||||
lcd.setCursor(0, 0)
|
lcd.setCursor(0, 0)
|
||||||
lcd.printout('{:05.2f}\223C'.format(temperature)
|
lcd.printout('T:{:5.1f}'.format(temperature))
|
||||||
lcd.printout(' {:05.2f}hPa'.format(pressure))
|
lcd.printout(' D:{:5.1f}'.format(pressure))
|
||||||
|
|
||||||
lcd.setCursor(0, 1)
|
lcd.setCursor(0, 1)
|
||||||
lcd.printout('{:05.2f}%'.format(humidity))
|
lcd.printout('F:{:5.2f}%'.format(humidity))
|
||||||
|
|
||||||
|
|
||||||
# Datenbankverbindung herstellen.
|
# Datenbankverbindung herstellen.
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
config.read('db.ini')
|
config.read('db.ini')
|
||||||
|
Reference in New Issue
Block a user