Skip to content

Commit

Permalink
Merge pull request #7 from Ths2-9Y-LqJt6/dev-3
Browse files Browse the repository at this point in the history
Dev 3
  • Loading branch information
Ths2-9Y-LqJt6 authored Dec 13, 2019
2 parents 2637f9e + 2884c10 commit fefa8e5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Oled.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def display(self, text):

# Draw a black filled box to clear the image.
self.draw.rectangle((0, 0, self.width, self.height), outline=0, fill=0)
self.draw.text((0, top + 10), str(text), font=self.font, fill=255)
self.draw.text((0, top), str(text), font=self.font, fill=255)

# Display image.
self.disp.image(self.image)
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@ can kinda make out Google Home update as well:
This project is very much a work in progress. Don't
use unless you're looking to learn and experiment like am right now ;)

Currently it seems pretty stable when not using the screen. This is the default
in the config (`use_display = False`).
Currently it seems pretty stable. You have to manually start it though, and I haven't
tested daemonizing it.

When using the screen I see this error which I need to chase down per
[#1](https://github.com/Ths2-9Y-LqJt6/cattmate/issues/1)

## Hardware

Expand Down Expand Up @@ -55,6 +53,8 @@ specifying the config included in this repo: `/usr/bin/powermate -c powermate.to

# Releases

* 13 Dec 2019 v0.12 - Add MIN/MAX alerts per [#2](https://github.com/Ths2-9Y-LqJt6/cattmate/issues/2), fix
[#1](https://github.com/Ths2-9Y-LqJt6/cattmate/issues/1)
* 10 Dec 2019 v0.11 - refactor `ssd1306` lib to `Csd1306` class, simplify calls to same, refactor for cleaner code
* 10 Dec 2019 v0.10 - first decently functional code, known issue
in [#1](https://github.com/Ths2-9Y-LqJt6/cattmate/issues/1) though.
23 changes: 21 additions & 2 deletions cattmate.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ def get_cast_handle(name_or_ip):
cast = cat_api.CattDevice(name=config.chromecasts[0])
return cast


def main():
logging.basicConfig(filename=os.path.dirname(os.path.abspath(__file__)) + "/error.log")

Expand Down Expand Up @@ -89,13 +88,33 @@ def main():
need_update = True
if config.use_display:
try:
screen.display(current_volume)

# if above 100 or below 0, briefly show a MAX or MIN
update_file_volume = False
if int(current_volume) < 0:
screen.display('MIN!')
time.sleep(.5)
update_file_volume = '0'
current_volume = '0'
elif int(current_volume) > 100:
screen.display('MAX!')
time.sleep(.5)
update_file_volume = '100'
current_volume = '100'

if update_file_volume:
lock = FileLock(cattmate_config.volumefile_lock, timeout=1)
with lock:
open(cattmate_config.volumefile, "w").write(update_file_volume)

except Exception as e:
logging.error(logging.exception(e))

os.system('clear')
print(volume)

screen.display(current_volume)

# wait 400ms since last local volume change before sending update to chromecast
if need_update & (milli_time() - last_volume_update > 400):
need_update = False
Expand Down

0 comments on commit fefa8e5

Please sign in to comment.