node-red-node-pi-gpio 2.0.0 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/36-rpi-gpio.html CHANGED
@@ -1,5 +1,6 @@
1
1
  <style>
2
2
  .rpi-gpio-pinTable {
3
+ color: #555;
3
4
  width: 340px;
4
5
  display: inline-table;
5
6
  font-size: 13px;
package/nrgpio CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  python_cmd='python3'
4
4
  # Fallback to Python 2, if Python 3 is not available
5
- command -v python3 > /dev/null || python_cmd=`python`
5
+ command -v python3 > /dev/null || python_cmd='python'
6
6
 
7
7
  BASEDIR=$(dirname $0)
8
8
  $python_cmd -u $BASEDIR/nrgpio.py $@
package/nrgpio.py CHANGED
@@ -171,24 +171,19 @@ if len(sys.argv) > 2:
171
171
  data = 0
172
172
 
173
173
  elif cmd == "mouse": # catch mice button events
174
- file = open( "/dev/input/mice", "rb" )
174
+ f = open( "/dev/input/mice", "rb" )
175
175
  oldbutt = 0
176
176
 
177
- def getMouseEvent():
178
- global oldbutt
179
- global pin
180
- buf = file.read(3)
181
- pin = pin & 0x07
182
- button = ord( buf[0] ) & pin # mask out just the required button(s)
183
- if button != oldbutt: # only send if changed
184
- oldbutt = button
185
- print(button)
186
-
187
177
  while True:
188
178
  try:
189
- getMouseEvent()
179
+ buf = f.read(3)
180
+ pin = pin & 0x07
181
+ button = struct.unpack('3b',buf)[0] & pin # mask out just the required button(s)
182
+ if button != oldbutt: # only send if changed
183
+ oldbutt = button
184
+ print(button)
190
185
  except:
191
- file.close()
186
+ f.close()
192
187
  sys.exit(0)
193
188
 
194
189
  elif cmd == "kbd": # catch keyboard button events
@@ -196,7 +191,7 @@ if len(sys.argv) > 2:
196
191
  while not os.path.isdir("/dev/input/by-path"):
197
192
  sleep(10)
198
193
  infile = subprocess.check_output("ls /dev/input/by-path/ | grep -m 1 'kbd'", shell=True).strip()
199
- infile_path = "/dev/input/by-path/" + infile
194
+ infile_path = "/dev/input/by-path/" + infile.decode("utf-8")
200
195
  EVENT_SIZE = struct.calcsize('llHHI')
201
196
  file = open(infile_path, "rb")
202
197
  event = file.read(EVENT_SIZE)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-node-pi-gpio",
3
- "version": "2.0.0",
3
+ "version": "2.0.3",
4
4
  "description": "The basic Node-RED node for Pi GPIO",
5
5
  "dependencies" : {
6
6
  },
package/testgpio CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  python_cmd='python3'
4
4
  # Fallback to Python 2, if Python 3 is not available
5
- command -v python3 > /dev/null || python_cmd=`python`
5
+ command -v python3 > /dev/null || python_cmd='python'
6
6
 
7
7
  BASEDIR=$(dirname $0)
8
8
  $python_cmd -u $BASEDIR/testgpio.py $@