Skip to content

Commit b03d054

Browse files
authored
Merge pull request #53 from TheFinalJoke/add_more_time
More options for time
2 parents c566c3d + 309ab9e commit b03d054

File tree

3 files changed

+39
-28
lines changed

3 files changed

+39
-28
lines changed

lib/config/ohmyoled.conf

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[basic]
2+
testing = False
23
# Log Level for Python
34
# Critcal = 50
45
# Error = 40
@@ -8,56 +9,52 @@
89
loglevel = 20
910
# Tokens will have to be Supported used with Approriate Modules
1011
#### Not Supported Yet #####
11-
# sport_token = 'SPORT_TOKEN'
12+
# sport_token =
1213
##############################
1314
# Stock Token based in FINN TOKEN https://finnhub.io/docs/api/introduction
14-
# stock_api_token = YOUR_FINN_TOKEN
15+
#stock_api_token =
1516

1617
# Open Weather Token in https://openweathermap.org/
17-
open_weather_token = 80ce462129470ef2f5d55e6f65d32eef
18+
# open_weather_token =
1819

1920
[matrix]
2021
chain_length = 1
2122
parallel = 1
2223
# Brightness from 0-100
23-
brightness = 60
24+
brightness = 20
2425
oled_slowdown = 3
2526

26-
[weather]
27+
[time]
2728
Run=True
29+
color = (255,255,255)
30+
31+
[weather]
32+
Run=False
2833
# Build the city as Dallas, US, For more accurate data, use zipcode
2934
current_location=True
3035
#city =
31-
zipcode =
36+
# zipcode =
3237
# Format
3338
# The Units, The options are standard, metric, imperial
3439
format = imperial
3540

3641
[stock]
3742
Run=False
38-
39-
# symbol=
40-
41-
# Runs Quote data for stocks
42-
# quote=True
43-
44-
# Historical and days need
45-
# historical=True
46-
# days_ago=30
43+
symbol=fb
4744

4845
##### Sports Not Supported it #####
49-
# [sport]
50-
# Run=False
46+
[sport]
47+
Run=False
5148
# football
5249
# baseball
5350
# hockey
5451
# basketball
5552
# formula 1
56-
# sport=baseball
53+
sport=baseball
5754
# For Team IDs Baseball https://dashboard.api-football.com/baseball/ids/teams
5855
# For Team IDs Basketball https://dashboard.api-football.com/basketball/ids/teams/USA
5956
# Only Support USA
60-
# team_id = 6
57+
team_id = 6
6158
# optional Will pull all data for all unless specified
6259

6360
# Baseball

main.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ def get_modules_to_run(self):
5555
self.logger.info("Getting Modules")
5656
for section, runtime in parsed.items():
5757
if runtime:
58+
if section == 'time':
59+
self.logger.debug("Time midule selected from config")
60+
api_modules.update({'time': " "})
5861
if section == 'weather':
5962
self.logger.debug("Weather Module Selected From Config")
6063
api_modules.update({'weather': WeatherApi(self.config)})
@@ -79,8 +82,11 @@ def poll_rgbmatrix(self):
7982
return rgboptions
8083

8184
async def init_matrix(self, matrix):
82-
verified_modules = [TimeMatrix(matrix)]
85+
verified_modules = []
8386
modules = self.get_modules_to_run()
87+
if 'time' in modules:
88+
self.logger.debug("Initialized Time")
89+
verified_modules.append(TimeMatrix(matrix, self.config['time']))
8490
if 'weather' in modules:
8591
self.logger.debug("Initialized Weather")
8692
verified_modules.append(WeatherMatrix(matrix, modules['weather'], logger))

matrix/time.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
#!/usr/bin/env python3
22

33
from PIL.Image import Image
4-
from matrix.matrix import Matrix, MatrixBase, FontException
5-
from datetime import date, datetime
6-
from rgbmatrix import RGBMatrix, RGBMatrixOptions, graphics
4+
from matrix.matrix import MatrixBase
5+
from datetime import datetime
76
from PIL import Image, ImageDraw, ImageFont
8-
import sys
7+
from enum import Enum
98
import time
109

10+
class TimeFormat(Enum):
11+
TWELEVE = 1
12+
TWENTYFOUR = 2
1113
class TimeMatrix(MatrixBase):
12-
def __init__(self, matrix) -> None:
14+
def __init__(self, matrix, config) -> None:
1315
super().__init__(matrix)
1416
self.matrix = matrix
17+
self.config = config
1518
self.logger.debug("Time Matrix Initalized")
19+
1620
def return_time(self, fmt: str):
1721
return datetime.now().strftime(fmt)
1822

@@ -22,17 +26,21 @@ async def poll_api(self):
2226
"""
2327
self.logger.debug("No Api call reqiured for time module")
2428
return None
29+
30+
def build_fmt(self):
31+
return "%I:%M:%S %p" if TimeFormat.TWELEVE else "%H:%M:%S"
32+
2533
def render(self, poll):
2634
# Build something that Loads in corner for all the modules loaded
2735
self.logger.info("Running Module TimeMatrix")
2836
counter = 0
29-
while counter < 15:
37+
while counter < 30:
3038
self.logger.debug(f'Counter for module run {counter}')
3139
font = ImageFont.truetype("/usr/share/fonts/truetype/noto/NotoMono-Regular.ttf", 10)
3240
self.set_image(Image.new("RGB", (64, 32)))
3341
self.set_draw(ImageDraw.Draw(self.get_image))
34-
self.draw_text((3, 5), f"{self.return_time('%m/%d/%Y')}", font=font, fill=(71, 181, 214,255))
35-
self.draw_text((8, 16), f"{self.return_time('%I:%M:%S')}", font=font, fill=(71, 181, 214,255))
42+
self.draw_text((3, 5), f"{self.return_time('%m/%d/%Y')}", font=font, fill=eval(self.config.get('color')))
43+
self.draw_text((8, 16), f"{self.return_time('%I:%M:%S')}", font=font, fill=eval(self.config.get('color')))
3644
self.render_image()
3745
counter = counter + 1
3846
time.sleep(1)

0 commit comments

Comments
 (0)