diff --git a/pingo/examples/analog_bars.py b/pingo/examples/analog_bars.py index ccf9179..f733e77 100644 --- a/pingo/examples/analog_bars.py +++ b/pingo/examples/analog_bars.py @@ -1,11 +1,12 @@ import pingo +from pingo import Mode import time board = pingo.detect.get_board() # board = pingo.arduino.get_arduino() pot = board.pins['A0'] -pot.mode = pingo.ANALOG +pot.mode = Mode.ANALOG def bar(pin): diff --git a/pingo/examples/blink.py b/pingo/examples/blink.py index f6d8b26..48e4c48 100644 --- a/pingo/examples/blink.py +++ b/pingo/examples/blink.py @@ -9,10 +9,11 @@ import time import pingo +from pingo import Mode board = pingo.detect.get_board() led = board.pins[13] -led.mode = pingo.OUT +led.mode = Mode.OUT while True: led.toggle() diff --git a/pingo/examples/blink_firmata.py b/pingo/examples/blink_firmata.py index 8565541..3bbbc4c 100644 --- a/pingo/examples/blink_firmata.py +++ b/pingo/examples/blink_firmata.py @@ -9,11 +9,12 @@ import time import pingo +from pingo import Mode ard = pingo.arduino.ArduinoFirmata('/dev/tty.usbmodemfa1341') print('Connected to: %s' % ard) led = ard.pins[13] -led.mode = pingo.OUT +led.mode = Mode.OUT while True: led.toggle() diff --git a/pingo/examples/blink_firmata_auto.py b/pingo/examples/blink_firmata_auto.py index 4a08c52..e56fc5b 100644 --- a/pingo/examples/blink_firmata_auto.py +++ b/pingo/examples/blink_firmata_auto.py @@ -9,11 +9,12 @@ import time import pingo +from pingo import Mode ard = pingo.arduino.get_arduino() print('Connected to: %s' % ard) led = ard.pins[13] -led.mode = pingo.OUT +led.mode = Mode.OUT while True: led.toggle() diff --git a/pingo/examples/dimmer.py b/pingo/examples/dimmer.py index b86db10..4ce4b68 100644 --- a/pingo/examples/dimmer.py +++ b/pingo/examples/dimmer.py @@ -8,20 +8,21 @@ from pprint import pprint import pingo +from pingo import Mode import time board = pingo.detect.get_board() pot = board.pins['A0'] -pot.mode = pingo.ANALOG +pot.mode = Mode.ANALOG led = board.pins[6] -led.mode = pingo.PWM +led.mode = Mode.PWM display_pins = [board.pins[i] for i in range(8, 14) + [7]] seg_display = pingo.parts.led.SevenSegments(*display_pins) for pin in display_pins: - pin.mode = pingo.OUT + pin.mode = Mode.OUT def bar(pin): diff --git a/pingo/examples/dojo.py b/pingo/examples/dojo.py index e754ddd..00209f0 100644 --- a/pingo/examples/dojo.py +++ b/pingo/examples/dojo.py @@ -13,15 +13,16 @@ import time import pingo +from pingo import Mode board = pingo.detect.get_board() print('board: %s' % board) pot = board.pins['A0'] -pot.mode = pingo.ANALOG +pot.mode = Mode.ANALOG leds = board.digital_pins[6:14] for led in leds: - led.mode = pingo.OUT + led.mode = Mode.OUT led.low() while True: @@ -30,5 +31,5 @@ continue led.high() time.sleep(pot.ratio()) - print pot.ratio() + print(pot.ratio()) led.low() diff --git a/pingo/examples/dojo2.py b/pingo/examples/dojo2.py index 9652046..037c465 100644 --- a/pingo/examples/dojo2.py +++ b/pingo/examples/dojo2.py @@ -12,6 +12,7 @@ from time import sleep import pingo +from pingo import Mode POT_LOCATION = 'A0' PIN_LOCATIONS = range(6, 14) @@ -21,7 +22,7 @@ leds = (pingo.pins[loc] for loc in PIN_LOCATIONS if loc != 9) for led in leds: - led.mode = pingo.OUT + led.mode = Mode.OUT while True: for led in leds: diff --git a/pingo/examples/dojoxxl.py b/pingo/examples/dojoxxl.py index 609a07e..fe33d14 100644 --- a/pingo/examples/dojoxxl.py +++ b/pingo/examples/dojoxxl.py @@ -3,10 +3,11 @@ """ import pingo +from pingo import Mode import time ard = pingo.arduino.get_arduino() -print '*' * 60 +print('*' * 60) segments = [ 11, # A @@ -20,17 +21,17 @@ for seg in segments: pin = ard.pins[seg] - pin.mode = pingo.OUT + pin.mode = Mode.OUT pin.low() pot = ard.pins['A0'] -pot.mode = pingo.IN +pot.mode = Mode.IN while True: for seg in segments: pin = ard.pins[seg] pin.high() delay = pot.ratio() + 0.01 # add 0.01s delay for communication - print '%0.3f' % delay + print('%0.3f' % delay) time.sleep(delay) pin.low() diff --git a/pingo/examples/double_blink.py b/pingo/examples/double_blink.py index 60b2a53..df8461c 100644 --- a/pingo/examples/double_blink.py +++ b/pingo/examples/double_blink.py @@ -10,14 +10,15 @@ import time import pingo +from pingo import Mode board = pingo.rpi.RaspberryPiBPlus() local_led = board.pins[13] -local_led.mode = pingo.OUT +local_led.mode = Mode.OUT ard = pingo.arduino.get_arduino() remote_led = ard.pins[13] -remote_led.mode = pingo.OUT +remote_led.mode = Mode.OUT local_led.low() # for an common anode RGB LED remote_led.low() diff --git a/pingo/examples/dual_analog_bars.py b/pingo/examples/dual_analog_bars.py index 0660031..d9bfddc 100644 --- a/pingo/examples/dual_analog_bars.py +++ b/pingo/examples/dual_analog_bars.py @@ -1,20 +1,21 @@ import pingo import time +from pingo import Mode galileo = pingo.detect.get_board() arduino = pingo.arduino.get_arduino() pot_galileo = galileo.pins['A0'] -pot_galileo.mode = pingo.ANALOG +pot_galileo.mode = Mode.ANALOG pot_arduino = arduino.pins['A0'] -pot_arduino.mode = pingo.ANALOG +pot_arduino.mode = Mode.ANALOG def bar(pin1, pin2): bar1 = ('*' * int(pin1.ratio() * 40)).ljust(40) bar2 = ('*' * int(pin2.ratio() * 40)).rjust(40) - print bar2 + bar1 + print(bar2 + bar1) while True: bar(pot_galileo, pot_arduino) diff --git a/pingo/examples/galileo_analog_bars.py b/pingo/examples/galileo_analog_bars.py index 7cc2e98..ee34605 100644 --- a/pingo/examples/galileo_analog_bars.py +++ b/pingo/examples/galileo_analog_bars.py @@ -1,14 +1,15 @@ -import pingo import time +import pingo +from pingo import Mode board = pingo.galileo.Galileo2() pot = board.pins['A0'] -pot.mode = pingo.ANALOG +pot.mode = Mode.ANALOG def bar(pin): - print "*" * int(pin.ratio() * 70) + print("*" * int(pin.ratio() * 70)) while True: bar(pot) diff --git a/pingo/examples/map7segment.py b/pingo/examples/map7segment.py index 838fdd0..4da5111 100644 --- a/pingo/examples/map7segment.py +++ b/pingo/examples/map7segment.py @@ -3,14 +3,15 @@ """ import pingo +from pingo import Mode ard = pingo.arduino.get_arduino() -print '*' * 60 +print('*' * 60) segs = {} for i in range(14): pin = ard.pins[i] - pin.mode = pingo.OUT + pin.mode = Mode.OUT pin.hi() seg = raw_input('Pin %s -> segment: ' % i).strip() if seg: @@ -18,4 +19,4 @@ pin.low() for seg, pin in sorted(segs.items()): - print '%s, # %s' % (pin, seg) + print('%s, # %s' % (pin, seg)) diff --git a/pingo/examples/parts/7seg_demo.py b/pingo/examples/parts/7seg_demo.py index a48523a..9afd14d 100644 --- a/pingo/examples/parts/7seg_demo.py +++ b/pingo/examples/parts/7seg_demo.py @@ -1,7 +1,7 @@ """ Seven segment display demo using the Garoa Dojo Shield """ from time import sleep -from pingo import OUT, detect, parts +from pingo import Mode, detect, parts INTERVAL = 0.3 @@ -10,7 +10,7 @@ display_pins = [ard.pins[i] for i in range(8, 14) + [7]] for pin in display_pins: - pin.mode = OUT + pin.mode = Mode.OUT seg_display = parts.led.SevenSegments(*display_pins) diff --git a/pingo/examples/parts/led_demo.py b/pingo/examples/parts/led_demo.py index 0641029..c6b83df 100644 --- a/pingo/examples/parts/led_demo.py +++ b/pingo/examples/parts/led_demo.py @@ -13,5 +13,5 @@ a_state = '*A*' if a_led.lit else ' a ' b_state = '*B*' if b_led.lit else ' b ' - print time.strftime('%H:%M:%S'), a_state, b_state + print("%s %s %s" % (time.strftime('%H:%M:%S'), a_state, b_state)) time.sleep(.1) diff --git a/pingo/examples/pongo.py b/pingo/examples/pongo.py index 8e9e60c..5ffb221 100644 --- a/pingo/examples/pongo.py +++ b/pingo/examples/pongo.py @@ -14,6 +14,7 @@ import curses import pingo +from pingo import Mode import time import random @@ -64,10 +65,10 @@ def draw_paddle(x, y, color): arduino = pingo.arduino.get_arduino() pot_galileo = galileo.pins['A0'] - pot_galileo.mode = pingo.ANALOG + pot_galileo.mode = Mode.ANALOG pot_arduino = arduino.pins['A0'] - pot_arduino.mode = pingo.ANALOG + pot_arduino.mode = Mode.ANALOG # Read the initial values of the paddles paddle_1_pos = int(pot_arduino.ratio(to_min=MIN_Y, to_max=MAX_Y-PADDLE_SIZE)) diff --git a/pingo/examples/probe_pins.py b/pingo/examples/probe_pins.py index 508b292..40eb294 100644 --- a/pingo/examples/probe_pins.py +++ b/pingo/examples/probe_pins.py @@ -7,6 +7,7 @@ import sys import pingo +from pingo import Mode def probe(first, last): @@ -16,7 +17,7 @@ def probe(first, last): pins = board.digital_pins[first:last + 1] for pin in pins: - pin.mode = pingo.OUT + pin.mode = Mode.OUT for pin in pins: pin.hi() diff --git a/pingo/examples/pwm.py b/pingo/examples/pwm.py index e0a46e5..8d91669 100644 --- a/pingo/examples/pwm.py +++ b/pingo/examples/pwm.py @@ -5,14 +5,15 @@ from pprint import pprint import pingo +from pingo import Mode import time -board = pingo.detect.get_board() -print board +board = pingo.detect.get_board() +print(board) led = board.pins[6] -led.mode = pingo.PWM +led.mode = Mode.PWM pprint(board.pins, indent=4, width=1) diff --git a/pingo/examples/rgb_led.py b/pingo/examples/rgb_led.py index 18431af..a010e8d 100644 --- a/pingo/examples/rgb_led.py +++ b/pingo/examples/rgb_led.py @@ -1,13 +1,14 @@ import time import pingo +from pingo import Mode board = pingo.detect.get_board() rgb = [board.pins[i] for i in (11, 13, 15)] for pin in rgb: - pin.mode = pingo.OUT + pin.mode = Mode.OUT pin.low() while True: diff --git a/pingo/examples/rpi_examples/display7.py b/pingo/examples/rpi_examples/display7.py index 84f96db..06ba833 100644 --- a/pingo/examples/rpi_examples/display7.py +++ b/pingo/examples/rpi_examples/display7.py @@ -1,4 +1,5 @@ import pingo +from pingo import Mode import time rpi = pingo.rpi.RaspberryPi() @@ -9,7 +10,7 @@ if pin.location in led_locations] for pin in pins: - pin.mode = pingo.OUT + pin.mode = Mode.OUT for pin in pins: pin.high() diff --git a/pingo/examples/rpi_examples/display7_anim.py b/pingo/examples/rpi_examples/display7_anim.py index 4e61959..0699865 100644 --- a/pingo/examples/rpi_examples/display7_anim.py +++ b/pingo/examples/rpi_examples/display7_anim.py @@ -1,4 +1,5 @@ import pingo +from pingo import Mode from time import sleep rpi = pingo.rpi.RaspberryPi() @@ -9,7 +10,7 @@ pins = [rpi.pins[loc] for loc in led_locations[:6]] for pin in pins: - pin.mode = pingo.OUT + pin.mode = Mode.OUT pin.low() while True: diff --git a/pingo/examples/rpi_examples/display7_probe.py b/pingo/examples/rpi_examples/display7_probe.py index 9271cea..52df134 100644 --- a/pingo/examples/rpi_examples/display7_probe.py +++ b/pingo/examples/rpi_examples/display7_probe.py @@ -1,4 +1,5 @@ import pingo +from pingo import Mode rpi = pingo.rpi.RaspberryPi() @@ -7,7 +8,7 @@ pins = [rpi.pins[loc] for loc in led_locations] for pin in pins: - pin.mode = pingo.OUT + pin.mode = Mode.OUT pin.low() for pin in pins: diff --git a/pingo/examples/rpi_examples/display7_snake.py b/pingo/examples/rpi_examples/display7_snake.py index d20663e..e44b4c8 100644 --- a/pingo/examples/rpi_examples/display7_snake.py +++ b/pingo/examples/rpi_examples/display7_snake.py @@ -1,4 +1,5 @@ import pingo +from pingo import Mode from time import sleep rpi = pingo.rpi.RaspberryPi() @@ -9,7 +10,7 @@ pins = [rpi.pins[loc] for loc in led_sequence] for pin in pins: - pin.mode = pingo.OUT + pin.mode = Mode.OUT pin.low() prev_pin = pins[-1] diff --git a/pingo/examples/switch.py b/pingo/examples/switch.py index ed23ccc..f0f9889 100644 --- a/pingo/examples/switch.py +++ b/pingo/examples/switch.py @@ -15,13 +15,13 @@ def show_f(): global seg_display seg_display.digit = 0xF - print 'Fechado' # Closed + print('Fechado'- # Closed def show_a(): global seg_display seg_display.digit = 0xA - print 'Aberto' # Open + print('Aberto') # Open pin_sw = board.pins[3] my_switch = pingo.parts.Switch(pin_sw)