Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set LED pin in config, set animation in config, sleep timer fix, ping function #164

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

davidsalb
Copy link

Hi,

maybe the things I've done or parts of it are useful. The contribution consists of four commits:

  • I moved the LED pin declaration into the configuration file so that others can set the wiring more flexible without code edits. (I figured since temperature sensor pin is declared in the config file, it may also be the right place for the LED pin.) Also contributed my own wiring.
  • I discoverd that the sleep timer didn't work because of two reasons:
    -1. In the config-file the time settings had inline comments which messed with the readout of the parameters. I changed the descriptive comments to be one line above the time-parameters.
    -2. The actual decision making to activate sleep mode wasn't working. I changed it and it works for me (also skipping the sleep cycle works)
  • I implemented a ping function. every minute it pings for certain devices in the local network. if a certain time (shut_off_duration) has passed without successful ping, the brightness is set to 0 to save energy. The activation of the ping_function, the IP's of the devices to be pinged and the shut_off_duration are set in the configuration file.
  • Lastly I made the animation feature optinal in config file. It can be choosen between: no_animation, typewriter, fadeOutIn.

@davidsalb davidsalb changed the title Develop set LED pin in config, set animation in config, sleep timer fix, ping function Jul 18, 2020
changed led_pin = 18, as it is the documented pin
# Conflicts:
#	wordclock_config/wordclock_config.example.cfg

def setBrightness(self, brightness):
# def setBrightness(self, brightness):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please resolve

@@ -22,15 +22,20 @@ developer_mode = False
language = german

# Choose wiring layout here. Options are: bernds_wiring, christians_wiring, ... (possibly you need your own wiring layout)
wiring_layout = bernds_wiring
wiring_layout = davids_wiring
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please reset to default value (bernds_wiring is part of the docs on how to build the hardware and therefore widely used).


# Fonts available at /usr/share/fonts/... (e.g. some types listed in truetype/freefont)
# FreeMono FreeMonoBoldOblique FreeSans FreeSansBoldOblique FreeSerif FreeSerifBoldItalic
# FreeMonoBold FreeMonoOblique FreeSansBold FreeSansOblique FreeSerifBold FreeSerifItalic
default_font = wcfont

# Set the brightness of the display (between 1 and 255)
brightness = 200
brightness = 255
use_brightness_sensor = True
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set default value to "False"

# animate new time with typewriter animation
typewriter = false
typewriter_speed = 10
# animate new time. Options: no_animation, typewriter, fadeOutIn
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Implementation wasn't properly updated to a (hopefully growing) number of animations so far.


[ping_checker]
# ping device IPs to check if somebody home, if not turn off brightness
activate = True
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please deactivate by default.

self.animation = "typewriter" if self.typewriter else "fadeOutIn"
if not any([self.animation == animation_type for animation_type in ['typewriter', 'fadeOutIn']]):
self.animation = None
# self.animation = "typewriter" if self.animation else "fadeOutIn"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove commented code. Overall, however, a very nice improvement!

self.ping_activated = config.getboolean('ping_checker', 'activate')
except:
print('Do not ping devices.')
self.ping_activated = True
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set to False, if ping_checker is not set...

try:
self.ping_activated = config.getboolean('ping_checker', 'activate')
except:
print('Do not ping devices.')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use logging.info(...)

self.LED_PIN = config.getint('wordclock_display', 'led_pin') # GPIO pin connected to the pixels (must support PWM!).
except:
# For backward compatibility
self.LED_PIN = 10
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set to 18, in order to be backward compatible

@bk1285
Copy link
Owner

bk1285 commented Jul 24, 2021

Hi @davidsalb,

thanks for opening the PR. Please take a look a the review and consider according changes.

Best,
Bernd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants