RGB LED added, untested!
This commit is contained in:
@@ -26,6 +26,13 @@ exit_pin = 24
|
|||||||
trigger_pin = 23
|
trigger_pin = 23
|
||||||
# BOARD pin 7 (BCM pin 4) switches the lamp on and off
|
# BOARD pin 7 (BCM pin 4) switches the lamp on and off
|
||||||
lamp_pin = 4
|
lamp_pin = 4
|
||||||
|
# BOARD pin (BCM pin 17) switches the blue channel
|
||||||
|
chan_b_pin = 17
|
||||||
|
# BOARD pin (BCM pin 27) switches the red channel
|
||||||
|
chan_r_pin = 27
|
||||||
|
# BOARD pin (BCM pin 22) switches the green channel
|
||||||
|
chan_g_pin = 22
|
||||||
|
|
||||||
|
|
||||||
[Printer]
|
[Printer]
|
||||||
# Enable printing (True/False)
|
# Enable printing (True/False)
|
||||||
|
|||||||
@@ -46,12 +46,18 @@ class Gpio:
|
|||||||
trigger_pin = config.getInt('Gpio', 'trigger_pin')
|
trigger_pin = config.getInt('Gpio', 'trigger_pin')
|
||||||
exit_pin = config.getInt('Gpio', 'exit_pin')
|
exit_pin = config.getInt('Gpio', 'exit_pin')
|
||||||
|
|
||||||
|
rgb_pin = (config.getInt('Gpio', 'chan_r_pin'),
|
||||||
|
config.getInt('Gpio', 'chan_g_pin'),
|
||||||
|
config.getInt('Gpio', 'chan_b_pin'))
|
||||||
|
|
||||||
logging.info(('GPIO enabled (lamp_pin=%d, trigger_pin=%d, '
|
logging.info(('GPIO enabled (lamp_pin=%d, trigger_pin=%d, '
|
||||||
'exit_pin=%d)'), lamp_pin, trigger_pin, exit_pin)
|
'exit_pin=%d, rgb_pins=(%d, %d, %d))'),
|
||||||
|
lamp_pin, trigger_pin, exit_pin, *rgb_pin)
|
||||||
|
|
||||||
self._gpio.setButton(trigger_pin, self.trigger)
|
self._gpio.setButton(trigger_pin, self.trigger)
|
||||||
self._gpio.setButton(exit_pin, self.exit)
|
self._gpio.setButton(exit_pin, self.exit)
|
||||||
self._lamp = self._gpio.setLamp(lamp_pin)
|
self._lamp = self._gpio.setLamp(lamp_pin)
|
||||||
|
self._rgb = self._gpio.setRgb(rgb_pin)
|
||||||
else:
|
else:
|
||||||
logging.info('GPIO disabled')
|
logging.info('GPIO disabled')
|
||||||
|
|
||||||
@@ -97,6 +103,21 @@ class Gpio:
|
|||||||
self._is_trigger = False
|
self._is_trigger = False
|
||||||
self._gpio.lampOff(self._lamp)
|
self._gpio.lampOff(self._lamp)
|
||||||
|
|
||||||
|
def setRgbColor(self, r, g, b):
|
||||||
|
|
||||||
|
if self._is_enabled:
|
||||||
|
self._gpio.rgbColor(self._rgb, (r, g, b))
|
||||||
|
|
||||||
|
def rgbOn(self):
|
||||||
|
|
||||||
|
if self._is_enabled:
|
||||||
|
self._gpio.rgbOn(self._rgb)
|
||||||
|
|
||||||
|
def rgbOff(self):
|
||||||
|
|
||||||
|
if self._is_enabled:
|
||||||
|
self._gpio.rgbOff(self._rgb)
|
||||||
|
|
||||||
def trigger(self):
|
def trigger(self):
|
||||||
|
|
||||||
if self._is_trigger:
|
if self._is_trigger:
|
||||||
@@ -123,11 +144,12 @@ class Gpio:
|
|||||||
|
|
||||||
def showCapture(self):
|
def showCapture(self):
|
||||||
|
|
||||||
pass
|
self.rgbOn()
|
||||||
|
self.setRgbColor(1, 1, 1)
|
||||||
|
|
||||||
def showAssemble(self):
|
def showAssemble(self):
|
||||||
|
|
||||||
pass
|
self.rgbOff()
|
||||||
|
|
||||||
def showReview(self):
|
def showReview(self):
|
||||||
|
|
||||||
@@ -146,10 +168,12 @@ class Entities:
|
|||||||
|
|
||||||
import gpiozero
|
import gpiozero
|
||||||
self.LED = gpiozero.LED
|
self.LED = gpiozero.LED
|
||||||
|
self.RGBLED = gpiozero.RGBLED
|
||||||
self.Button = gpiozero.Button
|
self.Button = gpiozero.Button
|
||||||
|
|
||||||
self._buttons = []
|
self._buttons = []
|
||||||
self._lamps = []
|
self._lamps = []
|
||||||
|
self._rgb = []
|
||||||
|
|
||||||
def setButton(self, bcm_pin, handler):
|
def setButton(self, bcm_pin, handler):
|
||||||
|
|
||||||
@@ -161,6 +185,11 @@ class Entities:
|
|||||||
self._lamps.append(self.LED(bcm_pin))
|
self._lamps.append(self.LED(bcm_pin))
|
||||||
return len(self._lamps) - 1
|
return len(self._lamps) - 1
|
||||||
|
|
||||||
|
def setRgb(self, bcm_pins):
|
||||||
|
|
||||||
|
self._rgb.append(self.RGBLED(*bcm_pins))
|
||||||
|
return len(self._lamps) - 1
|
||||||
|
|
||||||
def lampOn(self, index):
|
def lampOn(self, index):
|
||||||
|
|
||||||
self._lamps[index].on()
|
self._lamps[index].on()
|
||||||
@@ -172,3 +201,15 @@ class Entities:
|
|||||||
def lampToggle(self, index):
|
def lampToggle(self, index):
|
||||||
|
|
||||||
self._lamps[index].toggle()
|
self._lamps[index].toggle()
|
||||||
|
|
||||||
|
def rgbOn(self, index):
|
||||||
|
|
||||||
|
self._rgb[index].on()
|
||||||
|
|
||||||
|
def rgbOff(self, index):
|
||||||
|
|
||||||
|
self._rgb[index].off()
|
||||||
|
|
||||||
|
def rgbColor(self, index, color):
|
||||||
|
|
||||||
|
self._rgb[index].color = color
|
||||||
|
|||||||
Reference in New Issue
Block a user