summaryrefslogtreecommitdiffstatshomepage
path: root/examples/hwapi
diff options
context:
space:
mode:
Diffstat (limited to 'examples/hwapi')
-rw-r--r--examples/hwapi/button_reaction.py8
-rw-r--r--examples/hwapi/hwconfig_dragonboard410c.py6
-rw-r--r--examples/hwapi/hwconfig_esp8266_esp12.py6
-rw-r--r--examples/hwapi/hwconfig_pyboard.py13
-rw-r--r--examples/hwapi/hwconfig_z_96b_carbon.py9
-rw-r--r--examples/hwapi/hwconfig_z_frdm_k64f.py4
-rw-r--r--examples/hwapi/soft_pwm.py4
-rw-r--r--examples/hwapi/soft_pwm2_uasyncio.py2
8 files changed, 37 insertions, 15 deletions
diff --git a/examples/hwapi/button_reaction.py b/examples/hwapi/button_reaction.py
index 5e1890d5aa..b72e813e4c 100644
--- a/examples/hwapi/button_reaction.py
+++ b/examples/hwapi/button_reaction.py
@@ -11,9 +11,9 @@ Ready? Cliiiiick!
""")
while 1:
- try:
- delay = machine.time_pulse_us(BUTTON, 1, 10*1000*1000)
- print("You are as slow as %d microseconds!" % delay)
- except OSError:
+ delay = machine.time_pulse_us(BUTTON, 1, 10*1000*1000)
+ if delay < 0:
print("Well, you're *really* slow")
+ else:
+ print("You are as slow as %d microseconds!" % delay)
utime.sleep_ms(10)
diff --git a/examples/hwapi/hwconfig_dragonboard410c.py b/examples/hwapi/hwconfig_dragonboard410c.py
index 8061d7b743..eec3582039 100644
--- a/examples/hwapi/hwconfig_dragonboard410c.py
+++ b/examples/hwapi/hwconfig_dragonboard410c.py
@@ -1,4 +1,4 @@
-from machine import Pin
+from machine import Pin, Signal
# 96Boards/Qualcomm DragonBoard 410c
#
@@ -13,10 +13,10 @@ from machine import Pin
# echo -n "gpio_keys" >/sys/class/input/input1/device/driver/unbind
# User LED 1 on gpio21
-LED = Pin(21, Pin.OUT)
+LED = Signal(Pin(21, Pin.OUT))
# User LED 2 on gpio120
-LED2 = Pin(120, Pin.OUT)
+LED2 = Signal(Pin(120, Pin.OUT))
# Button S3 on gpio107
BUTTON = Pin(107, Pin.IN)
diff --git a/examples/hwapi/hwconfig_esp8266_esp12.py b/examples/hwapi/hwconfig_esp8266_esp12.py
index e8cf2d12e1..2e855ee3d3 100644
--- a/examples/hwapi/hwconfig_esp8266_esp12.py
+++ b/examples/hwapi/hwconfig_esp8266_esp12.py
@@ -1,5 +1,5 @@
-from machine import Pin
+from machine import Pin, Signal
# ESP12 module as used by many boards
-# Blue LED on pin 2
-LED = Pin(2, Pin.OUT)
+# Blue LED on pin 2, active low (inverted)
+LED = Signal(2, Pin.OUT, invert=True)
diff --git a/examples/hwapi/hwconfig_pyboard.py b/examples/hwapi/hwconfig_pyboard.py
new file mode 100644
index 0000000000..fb260033e5
--- /dev/null
+++ b/examples/hwapi/hwconfig_pyboard.py
@@ -0,0 +1,13 @@
+from machine import Pin, Signal
+
+# Red LED on pin LED_RED also kown as A13
+LED = Signal('LED_RED', Pin.OUT)
+
+# Green LED on pin LED_GREEN also known as A14
+LED2 = Signal('LED_GREEN', Pin.OUT)
+
+# Yellow LED on pin LED_YELLOW also known as A15
+LED3 = Signal('LED_YELLOW', Pin.OUT)
+
+# Blue LED on pin LED_BLUE also known as B4
+LED4 = Signal('LED_BLUE', Pin.OUT)
diff --git a/examples/hwapi/hwconfig_z_96b_carbon.py b/examples/hwapi/hwconfig_z_96b_carbon.py
new file mode 100644
index 0000000000..97fd57a07f
--- /dev/null
+++ b/examples/hwapi/hwconfig_z_96b_carbon.py
@@ -0,0 +1,9 @@
+from machine import Signal
+
+# 96Boards Carbon board
+# USR1 - User controlled led, connected to PD2
+# USR2 - User controlled led, connected to PA15
+# BT - Bluetooth indicator, connected to PB5.
+# Note - 96b_carbon uses (at the time of writing) non-standard
+# for Zephyr port device naming convention.
+LED = Signal(("GPIOA", 15), Pin.OUT)
diff --git a/examples/hwapi/hwconfig_z_frdm_k64f.py b/examples/hwapi/hwconfig_z_frdm_k64f.py
index c45e3e7567..377c638787 100644
--- a/examples/hwapi/hwconfig_z_frdm_k64f.py
+++ b/examples/hwapi/hwconfig_z_frdm_k64f.py
@@ -1,5 +1,5 @@
-from machine import Pin
+from machine import Pin, Signal
# Freescale/NXP FRDM-K64F board
# Blue LED on port B, pin 21
-LED = Pin(("GPIO_1", 21), Pin.OUT)
+LED = Signal(("GPIO_1", 21), Pin.OUT)
diff --git a/examples/hwapi/soft_pwm.py b/examples/hwapi/soft_pwm.py
index a9a5561717..72291b0ecd 100644
--- a/examples/hwapi/soft_pwm.py
+++ b/examples/hwapi/soft_pwm.py
@@ -14,10 +14,10 @@ def pwm_cycle(led, duty, cycles):
duty_off = 20 - duty
for i in range(cycles):
if duty:
- led.value(1)
+ led.on()
utime.sleep_ms(duty)
if duty_off:
- led.value(0)
+ led.off()
utime.sleep_ms(duty_off)
diff --git a/examples/hwapi/soft_pwm2_uasyncio.py b/examples/hwapi/soft_pwm2_uasyncio.py
index abeb4b1bfc..908ef2d8ac 100644
--- a/examples/hwapi/soft_pwm2_uasyncio.py
+++ b/examples/hwapi/soft_pwm2_uasyncio.py
@@ -27,5 +27,5 @@ async def fade_in_out(LED):
loop = uasyncio.get_event_loop()
loop.create_task(fade_in_out(LED))
-loop.call_later_ms_(800, fade_in_out(LED2))
+loop.call_later_ms(800, fade_in_out(LED2))
loop.run_forever()