arduino.py
Go to the documentation of this file.
1 # Copyright 2017 Mycroft AI Inc.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 
15 
17  """
18  Listens to enclosure commands for Mycroft's Arduino.
19 
20  Performs the associated command on Arduino by writing on the Serial port.
21  """
22 
23  def __init__(self, bus, writer):
24  self.bus = bus
25  self.writer = writer
26  self.__init_events()
27 
28  def __init_events(self):
29  self.bus.on('enclosure.system.reset', self.reset)
30  self.bus.on('enclosure.system.mute', self.mute)
31  self.bus.on('enclosure.system.unmute', self.unmute)
32  self.bus.on('enclosure.system.blink', self.blink)
33 
34  def reset(self, event=None):
35  self.writer.write("system.reset")
36 
37  def mute(self, event=None):
38  self.writer.write("system.mute")
39 
40  def unmute(self, event=None):
41  self.writer.write("system.unmute")
42 
43  def blink(self, event=None):
44  times = 1
45  if event and event.data:
46  times = event.data.get("times", times)
47  self.writer.write("system.blink=" + str(times))


mycroft_ros
Author(s):
autogenerated on Mon Apr 26 2021 02:35:40