Skip to content

Commit

Permalink
Made the evil pass_time function private.
Browse files Browse the repository at this point in the history
  • Loading branch information
berndporr committed Nov 26, 2020
1 parent 5c185dd commit 18b404a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
11 changes: 6 additions & 5 deletions examples/blink.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@
# The "Hello World" demo how to change a digital port synchronously.
#
# Warning: this is just an example of how to accesss the digital ports.
# For precise timing please use timers and not the pass_time command
# which locks up processing and is not precise.
# For precise timing please use timers or callback handlers
# and not the sleep() command which locks up processing
# and is not precise.
#

import pyfirmata2

import time

PIN = 13 # Pin 13 is used
DELAY = 1 # 1 second delay
Expand All @@ -53,6 +54,6 @@
# Loop for blinking the led
while True:
board.digital[PIN].write(1) # Set the LED pin to 1 (HIGH)
board.pass_time(DELAY)
time.sleep(1)
board.digital[PIN].write(0) # Set the LED pin to 0 (LOW)
board.pass_time(DELAY)
time.sleep(1)
4 changes: 2 additions & 2 deletions examples/digital-in.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
# delay opertation.

import pyfirmata2

import time

# Adjust that the port match your system, see samples below:
# On Linux: /dev/tty.usbserial-A6008rIF, /dev/ttyACM0,
Expand All @@ -57,6 +57,6 @@
print("Button not pressed")
else:
print("Button has never been pressed")
board.pass_time(0.5)
time.sleep(0.1)

board.exit()
2 changes: 1 addition & 1 deletion examples/realtime_scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __init__(self):
# create an empty line
self.line, = self.ax.plot(self.plotbuffer)
# axis
self.ax.set_ylim(0, 1)
self.ax.set_ylim(0, 1.5)
# That's our ringbuffer which accumluates the samples
# It's emptied every time when the plot window below
# does a repaint
Expand Down
6 changes: 3 additions & 3 deletions pyfirmata2/pyfirmata2.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def __init__(self, port, layout=None, baudrate=57600, name=None, timeout=None):
# Alas, Firmata blinks its version before printing it to serial
# For 2.3, even 5 seconds might not be enough.
# TODO Find a more reliable way to wait until the board is ready
self.pass_time(BOARD_SETUP_WAIT_TIME)
self.__pass_time(BOARD_SETUP_WAIT_TIME)
self.name = name
self._layout = layout
if not self.name:
Expand Down Expand Up @@ -213,7 +213,7 @@ def auto_setup(self):
"""
self.add_cmd_handler(CAPABILITY_RESPONSE, self._handle_report_capability_response)
self.send_sysex(CAPABILITY_QUERY, [])
self.pass_time(0.1) # Serial SYNC
self.__pass_time(0.1) # Serial SYNC

while self.bytes_available():
self.iterate()
Expand Down Expand Up @@ -282,7 +282,7 @@ def get_pin(self, pin_def):
pin.enable_reporting()
return pin

def pass_time(self, t):
def __pass_time(self, t):
"""Non-blocking time-out for ``t`` seconds."""
cont = time.time() + t
while time.time() < cont:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setup(
name='pyFirmata2',
version='2.0.1',
version='2.1.0',
description="Use your Arduino as a data acquisition card under Python",
long_description=long_description,
author='Bernd Porr',
Expand Down

0 comments on commit 18b404a

Please sign in to comment.