-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from kaulketh/develop
Develop
- Loading branch information
Showing
7 changed files
with
50 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,12 +5,20 @@ | |
author: Thomas Kaulke, [email protected] | ||
""" | ||
|
||
# TODO: improve and fix imports, load vars from global lib!!! | ||
# from __future__ import absolute_import | ||
# import conf.lib_global as lib | ||
import subprocess | ||
from time import sleep | ||
from PIL import Image, ImageFont, ImageDraw | ||
from lib_oled96 import Ssd1306 | ||
from smbus import SMBus | ||
from ...conf.lib_global import commit_id, cloned_branch, bot_dir | ||
from lib_oled96 import Ssd1306 | ||
|
||
|
||
latest_release = '/greenhouseLatestRelease.id' | ||
commit_id = '/greenhouseRepoCommit.id' | ||
cloned_branch = '/greenhouseRepoBranch.name' | ||
bot_dir = '/home/pi/scripts/TelegramBot/' | ||
|
||
|
||
# Display setup, methods and members | ||
|
@@ -24,10 +32,20 @@ | |
switch_time = 15 | ||
|
||
|
||
def get_last_commit(): | ||
commit = None | ||
branch = None | ||
def __get_release(): | ||
try: | ||
release = open(str(latest_release)).read() | ||
if release is None: | ||
release = '-----' | ||
else: | ||
release = release | ||
except Exception: | ||
release = '-----' | ||
return release | ||
return release | ||
|
||
|
||
def __get_last_commit(): | ||
try: | ||
commit = open(str(commit_id)).read() | ||
if commit is None: | ||
|
@@ -47,7 +65,7 @@ def get_last_commit(): | |
return build | ||
|
||
|
||
def get_core_temp(): | ||
def __get_core_temp(): | ||
temp = int(open('/sys/class/thermal/thermal_zone0/temp').read()) | ||
one = str(temp).__getitem__(0) | ||
two = str(temp).__getitem__(1) | ||
|
@@ -60,23 +78,23 @@ def get_core_temp(): | |
font2 = ImageFont.truetype(str(bot_dir) + 'peripherals/oled/fonts/FreeSans.ttf', 12) | ||
|
||
|
||
def animate(time): | ||
def __animate(time): | ||
# Display clear | ||
oled.cls() | ||
oled.display() | ||
# header | ||
draw.text((18, top), "GREENHOUSE", font=font, fill=1) | ||
draw.text((left, top), "GREENHOUSE v" + __get_release(), font=font, fill=1) | ||
# build | ||
draw.text((left, top + 18), "Build: " + get_last_commit(), font=font2, fill=1) | ||
draw.text((left, top + 18), "Build: " + __get_last_commit(), font=font2, fill=1) | ||
# line | ||
draw.line((left, top + 35, oled.width - left + 128, top + 35), fill=1) | ||
# core temp | ||
draw.text((left, top + 45), "Core Temperature: " + get_core_temp(), font=font2, fill=1) | ||
draw.text((left, top + 45), "Core Temperature: " + __get_core_temp(), font=font2, fill=1) | ||
oled.display() | ||
sleep(time) | ||
|
||
|
||
def show_pi(time): | ||
def __show_pi(time): | ||
oled.cls() | ||
# image inverted | ||
draw.rectangle((32, top - 3, 95, 63), outline=1, fill=1) | ||
|
@@ -85,7 +103,7 @@ def show_pi(time): | |
sleep(time) | ||
|
||
|
||
def show_state(time): | ||
def __show_state(time): | ||
oled.cls() | ||
oled.display() | ||
""" | ||
|
@@ -116,9 +134,9 @@ def show_state(time): | |
while True: | ||
|
||
try: | ||
animate(switch_time) | ||
show_pi(3) | ||
show_state(switch_time) | ||
__animate(switch_time) | ||
__show_pi(3) | ||
__show_state(switch_time) | ||
|
||
except KeyboardInterrupt: | ||
print('Oled interrupted.') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,6 @@ | |
minor adaptions: Thomas Kaulke, [email protected] | ||
""" | ||
|
||
from __future__ import absolute_import | ||
from PIL import Image, ImageDraw | ||
|
||
|
||
|
@@ -103,7 +102,7 @@ def display(self): | |
buf.append(byte) | ||
i -= 1 | ||
|
||
self._data(buf) # push out the whole lot | ||
self._data(buf) # push out the whole lot | ||
|
||
def cls(self): | ||
self.canvas.rectangle((0, 0, self.width-1, self.height-1), outline=0, fill=0) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters