mirror of
https://github.com/Death916/deathclock.git
synced 2026-04-10 03:04:40 -07:00
cleaned up weather, added logging instead of prints, began radio control
This commit is contained in:
parent
28bd2c6078
commit
b2320fd073
3 changed files with 93 additions and 22 deletions
|
|
@ -1,12 +1,16 @@
|
|||
#!/usr/bin/python3
|
||||
# connect to rda5807 chip and control it and display the current station
|
||||
# TODO: reference rd library in readme
|
||||
import logging
|
||||
|
||||
import reflex as rx
|
||||
|
||||
# from utils.python_rd5807m.radio import Radio as Radio_lib
|
||||
# from utils.python_rd5807m.radio import Rda5807m as Radio_lib
|
||||
|
||||
DEBUG = True
|
||||
CURRENT_STATION = "90.9 FM"
|
||||
PLAYING = False
|
||||
HARDWARE = True
|
||||
|
||||
|
||||
class Radio(rx.Base):
|
||||
|
|
@ -32,14 +36,63 @@ class Radio(rx.Base):
|
|||
return radio_card
|
||||
|
||||
|
||||
"""
|
||||
class Radio_Control:
|
||||
|
||||
# Radio Control Class
|
||||
#uses rda5807m library, if debugging populates false values for display
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self.debug = DEBUG
|
||||
self.bus = 1
|
||||
self.poll_interval = 0.5
|
||||
self.current_station = CURRENT_STATION
|
||||
self.volume = 7
|
||||
self.playing = False
|
||||
self.signal = 0.0
|
||||
self._device = None
|
||||
self._display = None
|
||||
|
||||
def init_radio(self):
|
||||
self.radio = Radio_lib()
|
||||
self.radio.initialize()
|
||||
# self._device = Radio_lib(self.bus)
|
||||
self._device.init_chip()
|
||||
|
||||
def play_radio(self):
|
||||
pass
|
||||
if self.debug:
|
||||
logging.debug("Playing fake radio")
|
||||
self._display = rx.text("Playing") # may not work
|
||||
self.playing = True
|
||||
else:
|
||||
self._device.on()
|
||||
self.playing = True
|
||||
|
||||
def stop_radio(self):
|
||||
if self.debug:
|
||||
logging.debug("Stopping radio")
|
||||
self._display = rx.text("Stopped") # may not work
|
||||
self.playing = False
|
||||
else:
|
||||
self._device.off()
|
||||
self.playing = False
|
||||
|
||||
def set_volume(self, volume):
|
||||
if self.debug:
|
||||
logging.debug(f"Setting volume to {volume}")
|
||||
self.volume = volume
|
||||
else:
|
||||
self._device.set_volume(volume)
|
||||
self.volume = volume
|
||||
|
||||
def set_station(self, station):
|
||||
if self.debug:
|
||||
logging.debug(f"Setting station to {station}")
|
||||
self.current_station = station
|
||||
else:
|
||||
self._device.set_station(station)
|
||||
self.current_station = station
|
||||
logging.info(f"Station set to {station}")
|
||||
"""
|
||||
|
||||
## for testing chip
|
||||
# if __name__ == "__main__":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue