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

Added support for a physical button and led strip #26

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

emouty
Copy link

@emouty emouty commented Mar 21, 2021

Hello,

I have added :

  • support for a physical button to control the light.
  • support for a led strip using the rpi_ws281x library

I also did some refactoring in the __init__.py, so there might be some conflicts with other ongoing pull request.

Note: I haven't found why (might just be my Pi) but the board was stuck in BCM mode so i switch the GPIO mode to BCM

@gigibu5
Copy link
Owner

gigibu5 commented Mar 21, 2021

Thank you for your pull request. Saddly, I do not have any RGB strips at hand to test it. If you could resolve the confilcts (some stuff was merged) and send me a video of it working as well as some screenshots of the setting panel and user interface, I would be happy to merge it.

@gigibu5
Copy link
Owner

gigibu5 commented Mar 21, 2021

Also, please change the indentation from 4 spaces to a single tab.

@emouty
Copy link
Author

emouty commented Apr 4, 2021

I did the rebase on your repository, I also added the change of the light icon in the UI when you press the physical button to turn on and off the light. I will send you the video soon, I just need to finish some wiring on the printer before

self._logger.info("watching events on pin : {}".format(
button
))
GPIO.setup(button, GPIO.IN, pull_up_down=GPIO.PUD_UP)
Copy link

Choose a reason for hiding this comment

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

@emouty you need to wrap button in this line and below (or in L96 and 108) with int()

otherwise an exception is thrown

octoprint.server.api - ERROR - Error calling SimpleApiPlugin octolight
Traceback (most recent call last):
  File "/home/pi/oprint/lib/python3.7/site-packages/octoprint/server/api/__init__.py", line 94, in pluginData
    response = api_plugin.on_api_get(request)
  File "/home/pi/oprint/lib/python3.7/site-packages/octoprint/util/__init__.py", line 1737, in wrapper
    return f(*args, **kwargs)
  File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_octolight/__init__.py", line 108, in on_api_get
    self.enable_watch_button(self._settings.get([BUTTON_PIN]))
  File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_octolight/__init__.py", line 128, in enable_watch_button
    GPIO.setup(button, GPIO.IN, pull_up_down=GPIO.PUD_UP)
ValueError: Channel must be an integer or list/tuple of integers

@eloo
Copy link

eloo commented Oct 31, 2021

i've tested your PR and except the one bug it seems to work properly

(normal light pin and button, i have not tested the LED strip feature)


if self._settings.get([BUTTON_PIN]) != self._settings.get([PREVIOUS_BUTTON_PIN]):
# stop watching on the previous pin
GPIO.remove_event_detect(
Copy link

Choose a reason for hiding this comment

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

also here we need to wrap with int()

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.

3 participants