diff --git a/scripts/examples/00-HelloWorld/blinky.py b/scripts/examples/00-HelloWorld/blinky.py new file mode 100644 index 000000000..3577f2f6e --- /dev/null +++ b/scripts/examples/00-HelloWorld/blinky.py @@ -0,0 +1,12 @@ +# Blinky example + +import time +from machine import LED + +led = LED("LED_BLUE") + +while True: + led.on() + time.sleep_ms(500) + led.off() + time.sleep_ms(500) diff --git a/scripts/examples/01-Camera/00-Snapshot/emboss_snapshot.py b/scripts/examples/01-Camera/00-Snapshot/emboss_snapshot.py index b2e6f9ac8..830f86b9b 100644 --- a/scripts/examples/01-Camera/00-Snapshot/emboss_snapshot.py +++ b/scripts/examples/01-Camera/00-Snapshot/emboss_snapshot.py @@ -1,32 +1,28 @@ # Emboss Snapshot Example # # Note: You will need an SD card to run this example. -# # You can use your OpenMV Cam to save modified image files. import sensor -import pyb - -RED_LED_PIN = 1 -BLUE_LED_PIN = 3 +import time +import machine sensor.reset() # Reset and initialize the sensor. sensor.set_pixformat(sensor.RGB565) # Set pixel format to RGB565 (or GRAYSCALE) sensor.set_framesize(sensor.QVGA) # Set frame size to QVGA (320x240) sensor.skip_frames(time=2000) # Wait for settings take effect. -pyb.LED(RED_LED_PIN).on() -sensor.skip_frames(time=2000) # Give the user time to get ready. +led = machine.LED("LED_BLUE") -pyb.LED(RED_LED_PIN).off() -pyb.LED(BLUE_LED_PIN).on() +start = time.ticks_ms() +while time.ticks_diff(time.ticks_ms(), start) < 3000: + sensor.snapshot() + led.toggle() + +led.off() -print("You're on camera!") img = sensor.snapshot() - img.morph(1, [+2, +1, +0, +1, +1, -1, +0, -1, -2]) # Emboss the image. - img.save("example.jpg") # or "example.bmp" (or others) -pyb.LED(BLUE_LED_PIN).off() -print("Done! Reset the camera to see the saved image.") +raise (Exception("Please reset the camera to see the new file.")) diff --git a/scripts/examples/01-Camera/00-Snapshot/snapshot.py b/scripts/examples/01-Camera/00-Snapshot/snapshot.py index 6945eab9e..49093626e 100644 --- a/scripts/examples/01-Camera/00-Snapshot/snapshot.py +++ b/scripts/examples/01-Camera/00-Snapshot/snapshot.py @@ -1,28 +1,27 @@ # Snapshot Example # # Note: You will need an SD card to run this example. -# # You can use your OpenMV Cam to save image files. import sensor -import pyb - -RED_LED_PIN = 1 -BLUE_LED_PIN = 3 +import time +import machine sensor.reset() # Reset and initialize the sensor. sensor.set_pixformat(sensor.RGB565) # Set pixel format to RGB565 (or GRAYSCALE) sensor.set_framesize(sensor.QVGA) # Set frame size to QVGA (320x240) sensor.skip_frames(time=2000) # Wait for settings take effect. -pyb.LED(RED_LED_PIN).on() -sensor.skip_frames(time=2000) # Give the user time to get ready. +led = machine.LED("LED_BLUE") -pyb.LED(RED_LED_PIN).off() -pyb.LED(BLUE_LED_PIN).on() +start = time.ticks_ms() +while time.ticks_diff(time.ticks_ms(), start) < 3000: + sensor.snapshot() + led.toggle() -print("You're on camera!") -sensor.snapshot().save("example.jpg") # or "example.bmp" (or others) +led.off() -pyb.LED(BLUE_LED_PIN).off() -print("Done! Reset the camera to see the saved image.") +img = sensor.snapshot() +img.save("example.jpg") # or "example.bmp" (or others) + +raise (Exception("Please reset the camera to see the new file.")) diff --git a/scripts/examples/01-Camera/00-Snapshot/snapshot_on_face_detection.py b/scripts/examples/01-Camera/00-Snapshot/snapshot_on_face_detection.py index 38eaad9e7..39d5e19b3 100644 --- a/scripts/examples/01-Camera/00-Snapshot/snapshot_on_face_detection.py +++ b/scripts/examples/01-Camera/00-Snapshot/snapshot_on_face_detection.py @@ -7,16 +7,16 @@ import sensor import image -import pyb - -RED_LED_PIN = 1 -BLUE_LED_PIN = 3 +import random +import machine sensor.reset() # Reset and initialize the sensor. sensor.set_pixformat(sensor.GRAYSCALE) # Set pixel format to RGB565 (or GRAYSCALE) -sensor.set_framesize(sensor.HQVGA) # Set frame size to HQVGA +sensor.set_framesize(sensor.QVGA) # Set frame size to QVGA sensor.skip_frames(time=2000) # Wait for settings take effect. +led = machine.LED("LED_RED") + # Load up a face detection HaarCascade. This is object that your OpenMV Cam # can use to detect faces using the find_features() method below. Your OpenMV # Cam has fontalface HaarCascade built-in. By default, all the stages of the @@ -26,15 +26,12 @@ sensor.skip_frames(time=2000) # Wait for settings take effect. face_cascade = image.HaarCascade("frontalface", stages=25) while True: - pyb.LED(RED_LED_PIN).on() print("About to start detecting faces...") sensor.skip_frames(time=2000) # Give the user time to get ready. - pyb.LED(RED_LED_PIN).off() print("Now detecting faces!") - pyb.LED(BLUE_LED_PIN).on() - diff = 10 # We'll say we detected a face after 10 frames. + while diff: img = sensor.snapshot() # Threshold can be between 0.0 and 1.0. A higher threshold results in a @@ -46,7 +43,7 @@ while True: diff -= 1 for r in faces: img.draw_rectangle(r) - - pyb.LED(BLUE_LED_PIN).off() + led.on() print("Face detected! Saving image...") - sensor.snapshot().save("snapshot-%d.jpg" % pyb.rng()) # Save Pic. + sensor.snapshot().save("snapshot-%d.jpg" % random.getrandbits(32)) # Save Pic. + led.off() diff --git a/scripts/examples/01-Camera/00-Snapshot/snapshot_on_movement.py b/scripts/examples/01-Camera/00-Snapshot/snapshot_on_movement.py index 13efcf554..fdd30826c 100644 --- a/scripts/examples/01-Camera/00-Snapshot/snapshot_on_movement.py +++ b/scripts/examples/01-Camera/00-Snapshot/snapshot_on_movement.py @@ -6,11 +6,9 @@ # motion detection. After motion is detected your OpenMV Cam will take picture. import sensor -import pyb +import random import os - -RED_LED_PIN = 1 -BLUE_LED_PIN = 3 +import machine sensor.reset() # Reset and initialize the sensor. sensor.set_pixformat(sensor.RGB565) # Set pixel format to RGB565 (or GRAYSCALE) @@ -18,18 +16,17 @@ sensor.set_framesize(sensor.QVGA) # Set frame size to QVGA (320x240) sensor.skip_frames(time=2000) # Wait for settings take effect. sensor.set_auto_whitebal(False) # Turn off white balance. +led = machine.LED("LED_RED") + if not "temp" in os.listdir(): os.mkdir("temp") # Make a temp directory while True: - pyb.LED(RED_LED_PIN).on() print("About to save background image...") sensor.skip_frames(time=2000) # Give the user time to get ready. - pyb.LED(RED_LED_PIN).off() sensor.snapshot().save("temp/bg.bmp") print("Saved background image - Now detecting motion!") - pyb.LED(BLUE_LED_PIN).on() diff = 10 # We'll say we detected motion after 10 frames of motion. while diff: @@ -42,6 +39,7 @@ while True: if stats[5] > 20: diff -= 1 - pyb.LED(BLUE_LED_PIN).off() + led.on() print("Movement detected! Saving image...") - sensor.snapshot().save("temp/snapshot-%d.jpg" % pyb.rng()) # Save Pic. + sensor.snapshot().save("temp/snapshot-%d.jpg" % random.getrandbits(32)) # Save Pic. + led.off() diff --git a/scripts/examples/01-Camera/00-Snapshot/time_lapse_photos.py b/scripts/examples/01-Camera/00-Snapshot/time_lapse_photos.py index ead56211a..f89e951c0 100644 --- a/scripts/examples/01-Camera/00-Snapshot/time_lapse_photos.py +++ b/scripts/examples/01-Camera/00-Snapshot/time_lapse_photos.py @@ -8,21 +8,19 @@ # pictures it will run the bootloader each time. Please power the camera # from something other than USB to not have the bootloader run. -import pyb import machine import sensor import os # Create and init RTC object. This will allow us to set the current time for # the RTC and let us set an interrupt to wake up later on. -rtc = pyb.RTC() +rtc = machine.RTC() newFile = False try: os.stat("time.txt") -except ( - OSError -): # If the log file doesn't exist then set the RTC and set newFile to True +except OSError: + # If the log file doesn't exist then set the RTC and set newFile to True # datetime format: year, month, day, weekday (Monday=1, Sunday=7), # hours (24 hour clock), minutes, seconds, subseconds (counts down from 255 to 0) rtc.datetime((2018, 3, 9, 5, 13, 0, 0, 0)) @@ -38,9 +36,8 @@ minute = "%02d" % dateTime[5] second = "%02d" % dateTime[6] subSecond = str(dateTime[7]) -newName = ( - "I" + year + month + day + hour + minute + second -) # Image file name based on RTC +# Image file name based on RTC +newName = "I" + year + month + day + hour + minute + second # Enable RTC interrupts every 10 seconds, camera will RESET after wakeup from deepsleep Mode. rtc.wakeup(10000) @@ -52,65 +49,31 @@ sensor.set_pixformat(sensor.GRAYSCALE) sensor.set_framesize(sensor.VGA) sensor.skip_frames(time=1000) # Let new settings take affect. -# Let folks know we are about to take a picture. -pyb.LED(BLUE_LED_PIN).on() +led = machine.LED("LED_BLUE") -if newFile: # If log file does not exist then create it. - with open( - "time.txt", "a" - ) as timeFile: # Write text file to keep track of date, time and image number. +if newFile: + # If log file does not exist then create it. + with open("time.txt", "a") as timeFile: + # Write text file to keep track of date, time and image number. + timeFile.write("name, year, month, day, hours, minutes, seconds, subseconds\n") timeFile.write( - "Date and time format: year, month, day, hours, minutes, seconds, subseconds" - + "\n" - ) - timeFile.write( - newName - + "," - + year - + "," - + month - + "," - + day - + "," - + hour - + "," - + minute - + "," - + second - + "," - + subSecond - + "\n" + f"{newName},{year},{month},{day},{hour},{minute},{second},{subSecond}\n" ) else: - with open( - "time.txt", "a" - ) as timeFile: # Append to date, time and image number to text file. + with open("time.txt", "a") as timeFile: + # Append to date, time and image number to text file. timeFile.write( - newName - + "," - + year - + "," - + month - + "," - + day - + "," - + hour - + "," - + minute - + "," - + second - + "," - + subSecond - + "\n" + f"{newName},{year},{month},{day},{hour},{minute},{second},{subSecond}\n" ) if not "images" in os.listdir(): os.mkdir("images") # Make a temp directory # Take photo and save to SD card +led.on() img = sensor.snapshot() img.save("images/" + newName, quality=90) -pyb.LED(BLUE_LED_PIN).off() +led.off() # Enter Deepsleep Mode (i.e. the OpenMV Cam effectively turns itself off except for the RTC). machine.deepsleep() diff --git a/scripts/examples/01-Camera/01-Video-Recording/gif.py b/scripts/examples/01-Camera/01-Video-Recording/gif.py index 85cdbc2ea..3ba272910 100644 --- a/scripts/examples/01-Camera/01-Video-Recording/gif.py +++ b/scripts/examples/01-Camera/01-Video-Recording/gif.py @@ -9,26 +9,19 @@ import sensor import time import gif -import pyb - -RED_LED_PIN = 1 -BLUE_LED_PIN = 3 +import machine sensor.reset() # Reset and initialize the sensor. sensor.set_pixformat(sensor.RGB565) # Set pixel format to RGB565 (or GRAYSCALE) sensor.set_framesize(sensor.QQVGA) # Set frame size to QQVGA (160x120) sensor.skip_frames(time=2000) # Wait for settings take effect. -clock = time.clock() # Create a clock object to track the FPS. -pyb.LED(RED_LED_PIN).on() -sensor.skip_frames(time=2000) # Give the user time to get ready. - -pyb.LED(RED_LED_PIN).off() -pyb.LED(BLUE_LED_PIN).on() +led = machine.LED("LED_RED") +led.on() g = gif.Gif("example.gif", loop=True) -print("You're on camera!") +clock = time.clock() # Create a clock object to track the FPS. for i in range(100): clock.tick() # clock.avg() returns the milliseconds between frames - gif delay is in @@ -36,5 +29,6 @@ for i in range(100): print(clock.fps()) g.close() -pyb.LED(BLUE_LED_PIN).off() -print("Done! Reset the camera to see the saved recording.") +led.off() + +raise (Exception("Please reset the camera to see the new file.")) diff --git a/scripts/examples/01-Camera/01-Video-Recording/gif_on_face_detection.py b/scripts/examples/01-Camera/01-Video-Recording/gif_on_face_detection.py index bf7881db8..248ecfbd9 100644 --- a/scripts/examples/01-Camera/01-Video-Recording/gif_on_face_detection.py +++ b/scripts/examples/01-Camera/01-Video-Recording/gif_on_face_detection.py @@ -13,16 +13,16 @@ import sensor import image import time import gif -import pyb - -RED_LED_PIN = 1 -BLUE_LED_PIN = 3 +import machine +import random sensor.reset() # Initialize the camera sensor. sensor.set_pixformat(sensor.GRAYSCALE) # Set pixel format to RGB565 (or GRAYSCALE) -sensor.set_framesize(sensor.QQVGA) # Set frame size to QQVGA (160x120) +sensor.set_framesize(sensor.QVGA) # Set frame size to QVGA sensor.skip_frames(time=2000) # Wait for settings take effect. +led = machine.LED("LED_RED") + # Load up a face detection HaarCascade. This is object that your OpenMV Cam # can use to detect faces using the find_features() method below. Your OpenMV # Cam has fontalface HaarCascade built-in. By default, all the stages of the @@ -32,13 +32,10 @@ sensor.skip_frames(time=2000) # Wait for settings take effect. face_cascade = image.HaarCascade("frontalface", stages=25) while True: - pyb.LED(RED_LED_PIN).on() print("About to start detecting faces...") sensor.skip_frames(time=2000) # Give the user time to get ready. - pyb.LED(RED_LED_PIN).off() print("Now detecting faces!") - pyb.LED(BLUE_LED_PIN).on() diff = 10 # We'll say we detected a face after 10 frames. while diff: @@ -53,10 +50,10 @@ while True: for r in faces: img.draw_rectangle(r) - g = gif.Gif("example-%d.gif" % pyb.rng(), loop=True) + led.on() + g = gif.Gif("example-%d.gif" % random.getrandbits(32), loop=True) clock = time.clock() # Tracks FPS. - print("You're on camera!") for i in range(100): clock.tick() # clock.avg() returns the milliseconds between frames - gif delay is in @@ -64,5 +61,5 @@ while True: print(clock.fps()) g.close() - pyb.LED(BLUE_LED_PIN).off() + led.off() print("Restarting...") diff --git a/scripts/examples/01-Camera/01-Video-Recording/gif_on_movement.py b/scripts/examples/01-Camera/01-Video-Recording/gif_on_movement.py index 52d4e5387..9abdde078 100644 --- a/scripts/examples/01-Camera/01-Video-Recording/gif_on_movement.py +++ b/scripts/examples/01-Camera/01-Video-Recording/gif_on_movement.py @@ -12,11 +12,9 @@ import sensor import time import gif -import pyb import os - -RED_LED_PIN = 1 -BLUE_LED_PIN = 3 +import machine +import random sensor.reset() # Reset and initialize the sensor. sensor.set_pixformat(sensor.RGB565) # Set pixel format to RGB565 (or GRAYSCALE) @@ -24,18 +22,17 @@ sensor.set_framesize(sensor.QQVGA) # Set frame size to QQVGA (160x120) sensor.skip_frames(time=2000) # Wait for settings take effect. sensor.set_auto_whitebal(False) # Turn off white balance. +led = machine.LED("LED_RED") + if not "temp" in os.listdir(): os.mkdir("temp") # Make a temp directory while True: - pyb.LED(RED_LED_PIN).on() print("About to save background image...") sensor.skip_frames(time=2000) # Give the user time to get ready. - pyb.LED(RED_LED_PIN).off() sensor.snapshot().save("temp/bg.bmp") print("Saved background image - Now detecting motion!") - pyb.LED(BLUE_LED_PIN).on() diff = 10 # We'll say we detected motion after 10 frames of motion. while diff: @@ -48,10 +45,10 @@ while True: if stats[5] > 20: diff -= 1 - g = gif.Gif("example-%d.gif" % pyb.rng(), loop=True) + led.on() + g = gif.Gif("example-%d.gif" % random.getrandbits(32), loop=True) clock = time.clock() # Tracks FPS. - print("You're on camera!") for i in range(100): clock.tick() # clock.avg() returns the milliseconds between frames - gif delay is in @@ -59,5 +56,5 @@ while True: print(clock.fps()) g.close() - pyb.LED(BLUE_LED_PIN).off() + led.off() print("Restarting...") diff --git a/scripts/examples/01-Camera/01-Video-Recording/imageio_read.py b/scripts/examples/01-Camera/01-Video-Recording/imageio_read.py index a541f1467..d1656ae8b 100644 --- a/scripts/examples/01-Camera/01-Video-Recording/imageio_read.py +++ b/scripts/examples/01-Camera/01-Video-Recording/imageio_read.py @@ -1,10 +1,10 @@ # Image Reader Example # -# USE THIS EXAMPLE WITH A USD CARD! +# NOTE: This example requires an SD card. # # This example shows how to use the Image Reader object to replay snapshots of what your # OpenMV Cam saw saved by the Image Writer object for testing machine vision algorithms. - +# # Altered to allow full speed reading from SD card for extraction of sequences to the network etc. # Set the new pause parameter to false diff --git a/scripts/examples/01-Camera/01-Video-Recording/imageio_write.py b/scripts/examples/01-Camera/01-Video-Recording/imageio_write.py index 1ab3df3b2..0878e5902 100644 --- a/scripts/examples/01-Camera/01-Video-Recording/imageio_write.py +++ b/scripts/examples/01-Camera/01-Video-Recording/imageio_write.py @@ -1,6 +1,6 @@ # Image Writer Example # -# USE THIS EXAMPLE WITH A USD CARD! Reset the camera after recording to see the file. +# NOTE: This example requires an SD card. # # This example shows how to use the Image Writer object to record snapshots of what your # OpenMV Cam sees for later analysis using the Image Reader object. Images written to disk @@ -8,8 +8,8 @@ import sensor import image -import pyb import time +import machine record_time = 10000 # 10 seconds in milliseconds @@ -19,13 +19,14 @@ sensor.set_framesize(sensor.QQVGA) # Set frame size to QQVGA (160x120) sensor.skip_frames(time=2000) # Wait for settings take effect. clock = time.clock() # Create a clock object to track the FPS. +led = machine.LED("LED_RED") stream = image.ImageIO("/stream.bin", "w") # Red LED on means we are capturing frames. -pyb.LED(1).on() +led.on() -start = pyb.millis() -while pyb.elapsed_millis(start) < record_time: +start = time.ticks_ms() +while time.ticks_diff(time.ticks_ms(), start) < record_time: clock.tick() img = sensor.snapshot() # Modify the image if you feel like here... @@ -33,7 +34,6 @@ while pyb.elapsed_millis(start) < record_time: print(clock.fps()) stream.close() +led.off() -# Blue LED on means we are done. -pyb.LED(1).off() -pyb.LED(3).on() +raise (Exception("Please reset the camera to see the new file.")) diff --git a/scripts/examples/01-Camera/01-Video-Recording/mjpeg.py b/scripts/examples/01-Camera/01-Video-Recording/mjpeg.py index 94a54b49c..dc1e0c388 100644 --- a/scripts/examples/01-Camera/01-Video-Recording/mjpeg.py +++ b/scripts/examples/01-Camera/01-Video-Recording/mjpeg.py @@ -10,31 +10,25 @@ import sensor import time import mjpeg -import pyb - -RED_LED_PIN = 1 -BLUE_LED_PIN = 3 +import machine sensor.reset() # Reset and initialize the sensor. sensor.set_pixformat(sensor.RGB565) # Set pixel format to RGB565 (or GRAYSCALE) sensor.set_framesize(sensor.QVGA) # Set frame size to QVGA (320x240) sensor.skip_frames(time=2000) # Wait for settings take effect. -clock = time.clock() # Create a clock object to track the FPS. -pyb.LED(RED_LED_PIN).on() -sensor.skip_frames(time=2000) # Give the user time to get ready. - -pyb.LED(RED_LED_PIN).off() -pyb.LED(BLUE_LED_PIN).on() +led = machine.LED("LED_RED") +led.on() m = mjpeg.Mjpeg("example.mjpeg") -print("You're on camera!") +clock = time.clock() # Create a clock object to track the FPS. for i in range(200): clock.tick() m.add_frame(sensor.snapshot()) print(clock.fps()) m.close(clock.fps()) -pyb.LED(BLUE_LED_PIN).off() -print("Done! Reset the camera to see the saved recording.") +led.off() + +raise (Exception("Please reset the camera to see the new file.")) diff --git a/scripts/examples/01-Camera/01-Video-Recording/mjpeg_on_face_detection.py b/scripts/examples/01-Camera/01-Video-Recording/mjpeg_on_face_detection.py index 16e0bd11a..eb586d484 100644 --- a/scripts/examples/01-Camera/01-Video-Recording/mjpeg_on_face_detection.py +++ b/scripts/examples/01-Camera/01-Video-Recording/mjpeg_on_face_detection.py @@ -14,16 +14,15 @@ import sensor import image import time import mjpeg -import pyb - -RED_LED_PIN = 1 -BLUE_LED_PIN = 3 +import random sensor.reset() # Reset and initialize the sensor. sensor.set_pixformat(sensor.GRAYSCALE) # Set pixel format to RGB565 (or GRAYSCALE) sensor.set_framesize(sensor.QQVGA) # Set frame size to QQVGA (160x120) sensor.skip_frames(time=2000) # Wait for settings take effect. +led = machine.LED("LED_RED") + # Load up a face detection HaarCascade. This is object that your OpenMV Cam # can use to detect faces using the find_features() method below. Your OpenMV # Cam has fontalface HaarCascade built-in. By default, all the stages of the @@ -33,13 +32,10 @@ sensor.skip_frames(time=2000) # Wait for settings take effect. face_cascade = image.HaarCascade("frontalface", stages=25) while True: - pyb.LED(RED_LED_PIN).on() print("About to start detecting faces...") sensor.skip_frames(time=2000) # Give the user time to get ready. - pyb.LED(RED_LED_PIN).off() print("Now detecting faces!") - pyb.LED(BLUE_LED_PIN).on() diff = 10 # We'll say we detected a face after 10 frames. while diff: @@ -54,15 +50,15 @@ while True: for r in faces: img.draw_rectangle(r) - m = mjpeg.Mjpeg("example-%d.mjpeg" % pyb.rng()) + led.on() + m = mjpeg.Mjpeg("example-%d.mjpeg" % random.getrandbits(32)) clock = time.clock() # Tracks FPS. - print("You're on camera!") for i in range(200): clock.tick() m.add_frame(sensor.snapshot()) print(clock.fps()) m.close(clock.fps()) - pyb.LED(BLUE_LED_PIN).off() + led.off() print("Restarting...") diff --git a/scripts/examples/01-Camera/01-Video-Recording/mjpeg_on_movement.py b/scripts/examples/01-Camera/01-Video-Recording/mjpeg_on_movement.py index d37a8a139..ff4269e0a 100644 --- a/scripts/examples/01-Camera/01-Video-Recording/mjpeg_on_movement.py +++ b/scripts/examples/01-Camera/01-Video-Recording/mjpeg_on_movement.py @@ -13,11 +13,9 @@ import sensor import time import mjpeg -import pyb import os - -RED_LED_PIN = 1 -BLUE_LED_PIN = 3 +import machine +import random sensor.reset() # Reset and initialize the sensor. sensor.set_pixformat(sensor.RGB565) # Set pixel format to RGB565 (or GRAYSCALE) @@ -25,18 +23,17 @@ sensor.set_framesize(sensor.QVGA) # Set frame size to QVGA (320x240) sensor.skip_frames(time=2000) # Wait for settings take effect. sensor.set_auto_whitebal(False) # Turn off white balance. +led = machine.LED("LED_RED") + if not "temp" in os.listdir(): os.mkdir("temp") # Make a temp directory while True: - pyb.LED(RED_LED_PIN).on() print("About to save background image...") sensor.skip_frames(time=2000) # Give the user time to get ready. - pyb.LED(RED_LED_PIN).off() sensor.snapshot().save("temp/bg.bmp") print("Saved background image - Now detecting motion!") - pyb.LED(BLUE_LED_PIN).on() diff = 10 # We'll say we detected motion after 10 frames of motion. while diff: @@ -49,15 +46,15 @@ while True: if stats[5] > 20: diff -= 1 - m = mjpeg.Mjpeg("example-%d.mjpeg" % pyb.rng()) + led.on() + m = mjpeg.Mjpeg("example-%d.mjpeg" % random.getrandbits(32)) clock = time.clock() # Tracks FPS. - print("You're on camera!") for i in range(200): clock.tick() m.add_frame(sensor.snapshot()) print(clock.fps()) m.close(clock.fps()) - pyb.LED(BLUE_LED_PIN).off() + led.off() print("Restarting...") diff --git a/scripts/examples/02-Image-Processing/00-Drawing/arrow_drawing.py b/scripts/examples/02-Image-Processing/00-Drawing/arrow_drawing.py index 693016074..f09efb9a4 100644 --- a/scripts/examples/02-Image-Processing/00-Drawing/arrow_drawing.py +++ b/scripts/examples/02-Image-Processing/00-Drawing/arrow_drawing.py @@ -4,7 +4,7 @@ import sensor import time -import pyb +from random import randint sensor.reset() sensor.set_pixformat(sensor.RGB565) # or GRAYSCALE... @@ -18,13 +18,14 @@ while True: img = sensor.snapshot() for i in range(10): - x0 = (pyb.rng() % (2 * img.width())) - (img.width() // 2) - y0 = (pyb.rng() % (2 * img.height())) - (img.height() // 2) - x1 = (pyb.rng() % (2 * img.width())) - (img.width() // 2) - y1 = (pyb.rng() % (2 * img.height())) - (img.height() // 2) - r = (pyb.rng() % 127) + 128 - g = (pyb.rng() % 127) + 128 - b = (pyb.rng() % 127) + 128 + x0 = randint(0, 2 * img.width()) - img.width() // 2 + y0 = randint(0, 2 * img.height()) - img.height() // 2 + x1 = randint(0, 2 * img.width()) - img.width() // 2 + y1 = randint(0, 2 * img.height()) - img.height() // 2 + + r = randint(0, 127) + 128 + g = randint(0, 127) + 128 + b = randint(0, 127) + 128 # If the first argument is a scaler then this method expects # to see x0, y0, x1, and y1. Otherwise, it expects a (x0,y0,x1,y1) tuple. diff --git a/scripts/examples/02-Image-Processing/00-Drawing/circle_drawing.py b/scripts/examples/02-Image-Processing/00-Drawing/circle_drawing.py index 943bf1421..2365fd3ed 100644 --- a/scripts/examples/02-Image-Processing/00-Drawing/circle_drawing.py +++ b/scripts/examples/02-Image-Processing/00-Drawing/circle_drawing.py @@ -4,7 +4,7 @@ import sensor import time -import pyb +from random import randint sensor.reset() sensor.set_pixformat(sensor.RGB565) # or GRAYSCALE... @@ -18,13 +18,13 @@ while True: img = sensor.snapshot() for i in range(10): - x = (pyb.rng() % (2 * img.width())) - (img.width() // 2) - y = (pyb.rng() % (2 * img.height())) - (img.height() // 2) - radius = pyb.rng() % (max(img.height(), img.width()) // 2) + x = randint(0, 2 * img.width()) - img.width() // 2 + y = randint(0, 2 * img.height()) - img.height() // 2 + radius = randint(0, max(img.height(), img.width()) // 2) - r = (pyb.rng() % 127) + 128 - g = (pyb.rng() % 127) + 128 - b = (pyb.rng() % 127) + 128 + r = randint(0, 127) + 128 + g = randint(0, 127) + 128 + b = randint(0, 127) + 128 # If the first argument is a scaler then this method expects # to see x, y, and radius. Otherwise, it expects a (x,y,radius) tuple. diff --git a/scripts/examples/02-Image-Processing/00-Drawing/cross_drawing.py b/scripts/examples/02-Image-Processing/00-Drawing/cross_drawing.py index a5bccb7e0..d3865a745 100644 --- a/scripts/examples/02-Image-Processing/00-Drawing/cross_drawing.py +++ b/scripts/examples/02-Image-Processing/00-Drawing/cross_drawing.py @@ -4,7 +4,7 @@ import sensor import time -import pyb +from random import randint sensor.reset() sensor.set_pixformat(sensor.RGB565) # or GRAYSCALE... @@ -18,11 +18,12 @@ while True: img = sensor.snapshot() for i in range(10): - x = (pyb.rng() % (2 * img.width())) - (img.width() // 2) - y = (pyb.rng() % (2 * img.height())) - (img.height() // 2) - r = (pyb.rng() % 127) + 128 - g = (pyb.rng() % 127) + 128 - b = (pyb.rng() % 127) + 128 + x = randint(0, 2 * img.width()) - img.width() // 2 + y = randint(0, 2 * img.height()) - img.height() // 2 + + r = randint(0, 127) + 128 + g = randint(0, 127) + 128 + b = randint(0, 127) + 128 # If the first argument is a scaler then this method expects # to see x and y. Otherwise, it expects a (x,y) tuple. diff --git a/scripts/examples/02-Image-Processing/00-Drawing/ellipse_drawing.py b/scripts/examples/02-Image-Processing/00-Drawing/ellipse_drawing.py index 51ded014a..f0273625a 100644 --- a/scripts/examples/02-Image-Processing/00-Drawing/ellipse_drawing.py +++ b/scripts/examples/02-Image-Processing/00-Drawing/ellipse_drawing.py @@ -4,7 +4,7 @@ import sensor import time -import pyb +from random import randint sensor.reset() sensor.set_pixformat(sensor.RGB565) # or GRAYSCALE... @@ -18,21 +18,21 @@ while True: img = sensor.snapshot() for i in range(10): - x = (pyb.rng() % (2 * img.width())) - (img.width() // 2) - y = (pyb.rng() % (2 * img.height())) - (img.height() // 2) - radius_x = pyb.rng() % (max(img.height(), img.width()) // 2) - radius_y = pyb.rng() % (max(img.height(), img.width()) // 2) - rot = pyb.rng() + x = randint(0, 2 * img.width()) - img.width() // 2 + y = randint(0, 2 * img.height()) - img.height() // 2 + rx = randint(0, max(img.height(), img.width()) // 2) + ry = randint(0, max(img.height(), img.width()) // 2) + rot = randint(0, 360) - r = (pyb.rng() % 127) + 128 - g = (pyb.rng() % 127) + 128 - b = (pyb.rng() % 127) + 128 + r = randint(0, 127) + 128 + g = randint(0, 127) + 128 + b = randint(0, 127) + 128 # If the first argument is a scaler then this method expects # to see x, y, radius x, and radius y. - # Otherwise, it expects a (x,y,radius_x,radius_y) tuple. + # Otherwise, it expects a (x,y,rx,ry) tuple. img.draw_ellipse( - x, y, radius_x, radius_y, rot, color=(r, g, b), thickness=2, fill=False + x, y, rx, ry, rot, color=(r, g, b), thickness=2, fill=False ) print(clock.fps()) diff --git a/scripts/examples/02-Image-Processing/00-Drawing/keypoints_drawing.py b/scripts/examples/02-Image-Processing/00-Drawing/keypoints_drawing.py index f5909bc48..e6ac7e368 100644 --- a/scripts/examples/02-Image-Processing/00-Drawing/keypoints_drawing.py +++ b/scripts/examples/02-Image-Processing/00-Drawing/keypoints_drawing.py @@ -5,7 +5,7 @@ import sensor import time -import pyb +from random import randint sensor.reset() sensor.set_pixformat(sensor.RGB565) # or GRAYSCALE... @@ -19,13 +19,13 @@ while True: img = sensor.snapshot() for i in range(20): - x = (pyb.rng() % (2 * img.width())) - (img.width() // 2) - y = (pyb.rng() % (2 * img.height())) - (img.height() // 2) - rot = pyb.rng() % 360 + x = randint(0, 2 * img.width()) - img.width() // 2 + y = randint(0, 2 * img.height()) - img.height() // 2 + rot = randint(0, 360) - r = (pyb.rng() % 127) + 128 - g = (pyb.rng() % 127) + 128 - b = (pyb.rng() % 127) + 128 + r = randint(0, 127) + 128 + g = randint(0, 127) + 128 + b = randint(0, 127) + 128 # This method draws a keypoints object or a list of (x, y, rot) tuples... img.draw_keypoints( diff --git a/scripts/examples/02-Image-Processing/00-Drawing/line_drawing.py b/scripts/examples/02-Image-Processing/00-Drawing/line_drawing.py index 0b48ef2ad..ec9335960 100644 --- a/scripts/examples/02-Image-Processing/00-Drawing/line_drawing.py +++ b/scripts/examples/02-Image-Processing/00-Drawing/line_drawing.py @@ -4,7 +4,7 @@ import sensor import time -import pyb +from random import randint sensor.reset() sensor.set_pixformat(sensor.RGB565) # or GRAYSCALE... @@ -18,13 +18,14 @@ while True: img = sensor.snapshot() for i in range(10): - x0 = (pyb.rng() % (2 * img.width())) - (img.width() // 2) - y0 = (pyb.rng() % (2 * img.height())) - (img.height() // 2) - x1 = (pyb.rng() % (2 * img.width())) - (img.width() // 2) - y1 = (pyb.rng() % (2 * img.height())) - (img.height() // 2) - r = (pyb.rng() % 127) + 128 - g = (pyb.rng() % 127) + 128 - b = (pyb.rng() % 127) + 128 + x0 = randint(0, 2 * img.width()) - img.width() // 2 + y0 = randint(0, 2 * img.height()) - img.height() // 2 + x1 = randint(0, 2 * img.width()) - img.width() // 2 + y1 = randint(0, 2 * img.height()) - img.height() // 2 + + r = randint(0, 127) + 128 + g = randint(0, 127) + 128 + b = randint(0, 127) + 128 # If the first argument is a scaler then this method expects # to see x0, y0, x1, and y1. Otherwise, it expects a (x0,y0,x1,y1) tuple. diff --git a/scripts/examples/02-Image-Processing/00-Drawing/rectangle_drawing.py b/scripts/examples/02-Image-Processing/00-Drawing/rectangle_drawing.py index 9bd07c4e4..f69edd6da 100644 --- a/scripts/examples/02-Image-Processing/00-Drawing/rectangle_drawing.py +++ b/scripts/examples/02-Image-Processing/00-Drawing/rectangle_drawing.py @@ -4,7 +4,7 @@ import sensor import time -import pyb +from random import randint sensor.reset() sensor.set_pixformat(sensor.RGB565) # or GRAYSCALE... @@ -18,13 +18,14 @@ while True: img = sensor.snapshot() for i in range(10): - x = (pyb.rng() % (2 * img.width())) - (img.width() // 2) - y = (pyb.rng() % (2 * img.height())) - (img.height() // 2) - w = pyb.rng() % (img.width() // 2) - h = pyb.rng() % (img.height() // 2) - r = (pyb.rng() % 127) + 128 - g = (pyb.rng() % 127) + 128 - b = (pyb.rng() % 127) + 128 + x = randint(0, 2 * img.width()) - img.width() // 2 + y = randint(0, 2 * img.height()) - img.height() // 2 + w = randint(0, img.width() // 2) + h = randint(0, img.height() // 2) + + r = randint(0, 127) + 128 + g = randint(0, 127) + 128 + b = randint(0, 127) + 128 # If the first argument is a scaler then this method expects # to see x, y, w, and h. Otherwise, it expects a (x,y,w,h) tuple. diff --git a/scripts/examples/02-Image-Processing/00-Drawing/text_drawing.py b/scripts/examples/02-Image-Processing/00-Drawing/text_drawing.py index b0fc602b1..c76f2004e 100644 --- a/scripts/examples/02-Image-Processing/00-Drawing/text_drawing.py +++ b/scripts/examples/02-Image-Processing/00-Drawing/text_drawing.py @@ -4,7 +4,7 @@ import sensor import time -import pyb +from random import randint sensor.reset() sensor.set_pixformat(sensor.RGB565) # or GRAYSCALE... @@ -18,11 +18,12 @@ while True: img = sensor.snapshot() for i in range(10): - x = (pyb.rng() % (2 * img.width())) - (img.width() // 2) - y = (pyb.rng() % (2 * img.height())) - (img.height() // 2) - r = (pyb.rng() % 127) + 128 - g = (pyb.rng() % 127) + 128 - b = (pyb.rng() % 127) + 128 + x = randint(0, 2 * img.width()) - img.width() // 2 + y = randint(0, 2 * img.height()) - img.height() // 2 + + r = randint(0, 127) + 128 + g = randint(0, 127) + 128 + b = randint(0, 127) + 128 # If the first argument is a scaler then this method expects # to see x, y, and text. Otherwise, it expects a (x,y,text) tuple. diff --git a/scripts/examples/02-Image-Processing/01-Image-Filters/vflip_hmirror_transpose.py b/scripts/examples/02-Image-Processing/01-Image-Filters/vflip_hmirror_transpose.py index 0fde158e3..fd2c084df 100644 --- a/scripts/examples/02-Image-Processing/01-Image-Filters/vflip_hmirror_transpose.py +++ b/scripts/examples/02-Image-Processing/01-Image-Filters/vflip_hmirror_transpose.py @@ -10,7 +10,6 @@ import sensor import time -import pyb sensor.reset() sensor.set_pixformat(sensor.RGB565) @@ -18,7 +17,7 @@ sensor.set_framesize(sensor.QVGA) sensor.skip_frames(time=2000) clock = time.clock() -mills = pyb.millis() +ticks = time.ticks_ms() counter = 0 while True: @@ -30,8 +29,8 @@ while True: transpose=(counter // 8) % 2, ) - if pyb.millis() > (mills + 1000): - mills = pyb.millis() + if time.ticks_diff(time.ticks_ms(), ticks) > 1000: + ticks = time.ticks_ms() counter += 1 print(clock.fps()) diff --git a/scripts/examples/05-Feature-Detection/keypoints_save.py b/scripts/examples/05-Feature-Detection/keypoints_save.py index 35aa00f99..1263a8ec6 100644 --- a/scripts/examples/05-Feature-Detection/keypoints_save.py +++ b/scripts/examples/05-Feature-Detection/keypoints_save.py @@ -2,8 +2,6 @@ # This example shows how to save a keypoints descriptor to file. Show the camera an object # and then run the script. The script will extract and save a keypoints descriptor and the image. # You can use the keypoints_editor.py util to remove unwanted keypoints. -# -# NOTE: Please reset the camera after running this script to see the new file. import sensor import time import image @@ -36,4 +34,5 @@ img.save("/%s.pgm" % (FILE_NAME)) img.draw_keypoints(kpts) sensor.snapshot() time.sleep_ms(1000) -raise (Exception("Done! Please reset the camera")) + +raise (Exception("Please reset the camera to see the new file.")) diff --git a/scripts/examples/06-April-Tags/find_apriltags.py b/scripts/examples/06-April-Tags/find_apriltags.py index 807ad35b3..9ffb9ebb8 100644 --- a/scripts/examples/06-April-Tags/find_apriltags.py +++ b/scripts/examples/06-April-Tags/find_apriltags.py @@ -10,9 +10,7 @@ import math sensor.reset() sensor.set_pixformat(sensor.RGB565) -sensor.set_framesize( - sensor.QQVGA -) # we run out of memory if the resolution is much bigger... +sensor.set_framesize(sensor.QQVGA) sensor.skip_frames(time=2000) sensor.set_auto_gain(False) # must turn this off to prevent image washout... sensor.set_auto_whitebal(False) # must turn this off to prevent image washout... diff --git a/scripts/examples/06-April-Tags/find_apriltags_3d_pose.py b/scripts/examples/06-April-Tags/find_apriltags_3d_pose.py index 30dd18581..ea34cc2da 100644 --- a/scripts/examples/06-April-Tags/find_apriltags_3d_pose.py +++ b/scripts/examples/06-April-Tags/find_apriltags_3d_pose.py @@ -9,9 +9,7 @@ import math sensor.reset() sensor.set_pixformat(sensor.RGB565) -sensor.set_framesize( - sensor.QQVGA -) # we run out of memory if the resolution is much bigger... +sensor.set_framesize(sensor.QQVGA) sensor.skip_frames(time=2000) sensor.set_auto_gain(False) # must turn this off to prevent image washout... sensor.set_auto_whitebal(False) # must turn this off to prevent image washout... diff --git a/scripts/examples/06-April-Tags/find_apriltags_max_res.py b/scripts/examples/06-April-Tags/find_apriltags_max_res.py index d52ea1f65..184b4d08b 100644 --- a/scripts/examples/06-April-Tags/find_apriltags_max_res.py +++ b/scripts/examples/06-April-Tags/find_apriltags_max_res.py @@ -11,9 +11,8 @@ import omv sensor.reset() sensor.set_pixformat(sensor.GRAYSCALE) -sensor.set_framesize( - sensor.VGA -) # we run out of memory if the resolution is much bigger... +sensor.set_framesize(sensor.VGA) + # AprilTags works on a maximum of < 64K pixels. if omv.board_type() == "H7": sensor.set_windowing((240, 240)) diff --git a/scripts/examples/06-April-Tags/find_apriltags_w_lens_zoom.py b/scripts/examples/06-April-Tags/find_apriltags_w_lens_zoom.py index 9df106b3f..6de5089fa 100644 --- a/scripts/examples/06-April-Tags/find_apriltags_w_lens_zoom.py +++ b/scripts/examples/06-April-Tags/find_apriltags_w_lens_zoom.py @@ -9,9 +9,7 @@ import math sensor.reset() sensor.set_pixformat(sensor.RGB565) -sensor.set_framesize( - sensor.VGA -) # we run out of memory if the resolution is much bigger... +sensor.set_framesize(sensor.VGA) sensor.set_windowing((160, 120)) # Look at center 160x120 pixels of the VGA resolution. sensor.skip_frames(time=2000) sensor.set_auto_gain(False) # must turn this off to prevent image washout... diff --git a/scripts/examples/07-Interface-Library/02-MAVLink/mavlink_apriltags_landing_target.py b/scripts/examples/07-Interface-Library/02-MAVLink/mavlink_apriltags_landing_target.py index e95e85b85..90f256f59 100644 --- a/scripts/examples/07-Interface-Library/02-MAVLink/mavlink_apriltags_landing_target.py +++ b/scripts/examples/07-Interface-Library/02-MAVLink/mavlink_apriltags_landing_target.py @@ -6,17 +6,15 @@ # P4 = TXD import math -import pyb import sensor import struct import time +import machine -# Parameters ################################################################# - -uart_baudrate = 115200 - +UART_BAUDRATE = 115200 MAV_system_id = 1 MAV_component_id = 0x54 +packet_sequence = 0 lens_mm = 2.8 # Standard Lens. lens_to_camera_mm = 22 # Standard Lens. @@ -35,10 +33,8 @@ valid_tag_ids = { 2: 165, # 8.5" x 11" tag black border size in mm } -############################################################################## # Camera Setup - sensor.reset() sensor.set_pixformat(sensor.GRAYSCALE) sensor.set_framesize(sensor.QQVGA) @@ -54,22 +50,17 @@ h_fov = 2 * math.atan((sensor_w_mm / 2) / lens_mm) v_fov = 2 * math.atan((sensor_h_mm / 2) / lens_mm) -def translation_to_mm(translation, tag_size): # translation is in decimeters... +def translation_to_mm(translation, tag_size): + # translation is in decimeters... return ((translation * 100) * tag_size) / 210 # Link Setup - -uart = pyb.UART(3, uart_baudrate, timeout_char=1000) - -# Helper Stuff - -packet_sequence = 0 +uart = machine.UART(3, UART_BAUDRATE, timeout_char=1000) -def checksum( - data, extra -): # https://github.com/mavlink/c_library_v1/blob/master/checksum.h +# https://github.com/mavlink/c_library_v1/blob/master/checksum.h +def checksum(data, extra): output = 0xFFFF for i in range(len(data)): tmp = data[i] ^ (output & 0xFF) @@ -123,8 +114,8 @@ def send_landing_target_packet(tag, dist_mm, w, h): # LED control -led_success = pyb.LED(2) # Red LED = 1, Green LED = 2, Blue LED = 3, IR LEDs = 4. -led_fail = pyb.LED(1) +led_success = machine.LED("LED_GREEN") +led_fail = machine.LED("LED_RED") led_counter = 0 diff --git a/scripts/examples/07-Interface-Library/02-MAVLink/mavlink_opticalflow.py b/scripts/examples/07-Interface-Library/02-MAVLink/mavlink_opticalflow.py index 29f71d5c4..ae602e8a3 100644 --- a/scripts/examples/07-Interface-Library/02-MAVLink/mavlink_opticalflow.py +++ b/scripts/examples/07-Interface-Library/02-MAVLink/mavlink_opticalflow.py @@ -5,25 +5,21 @@ # # P4 = TXD -import pyb import sensor import struct import time +import machine -# Parameters ################################################################# - -uart_baudrate = 115200 - +UART_BAUDRATE = 115200 MAV_system_id = 1 MAV_component_id = 0x54 -MAV_OPTICAL_FLOW_confidence_threshold = ( - 0.1 # Below 0.1 or so (YMMV) and the results are just noise. -) +packet_sequence = 0 -############################################################################## +# Below 0.1 or so (YMMV) and the results are just noise. +MAV_OPTICAL_FLOW_confidence_threshold = (0.1) # LED control -led = pyb.LED(2) # Red LED = 1, Green LED = 2, Blue LED = 3, IR LEDs = 4. +led = machine.LED("LED_BLUE") led_state = 0 @@ -38,17 +34,11 @@ def update_led(): # Link Setup - -uart = pyb.UART(3, uart_baudrate, timeout_char=1000) - -# Helper Stuff - -packet_sequence = 0 +uart = machine.UART(3, UART_BAUDRATE, timeout_char=1000) -def checksum( - data, extra -): # https://github.com/mavlink/c_library_v1/blob/master/checksum.h +# https://github.com/mavlink/c_library_v1/blob/master/checksum.h +def checksum(data, extra): output = 0xFFFF for i in range(len(data)): tmp = data[i] ^ (output & 0xFF) diff --git a/scripts/examples/07-Interface-Library/03-Modbus/modbus_apriltag.py b/scripts/examples/07-Interface-Library/03-Modbus/modbus_apriltag.py index 97123cb82..d972ec2e6 100644 --- a/scripts/examples/07-Interface-Library/03-Modbus/modbus_apriltag.py +++ b/scripts/examples/07-Interface-Library/03-Modbus/modbus_apriltag.py @@ -1,13 +1,11 @@ import sensor import time -from pyb import UART +from machine import UART from modbus import ModbusRTU sensor.reset() sensor.set_pixformat(sensor.GRAYSCALE) -sensor.set_framesize( - sensor.QQVGA -) # we run out of memory if the resolution is much bigger... +sensor.set_framesize(sensor.QQVGA) uart = UART(3, 115200, parity=None, stop=2, timeout=1, timeout_char=4) modbus = ModbusRTU(uart, register_num=9999) diff --git a/scripts/examples/07-Interface-Library/03-Modbus/modbus_rtu_slave.py b/scripts/examples/07-Interface-Library/03-Modbus/modbus_rtu_slave.py index 173a64ee3..569738800 100644 --- a/scripts/examples/07-Interface-Library/03-Modbus/modbus_rtu_slave.py +++ b/scripts/examples/07-Interface-Library/03-Modbus/modbus_rtu_slave.py @@ -1,5 +1,5 @@ import time -from pyb import UART +from machine import UART from modbus import ModbusRTU uart = UART(3, 115200, parity=None, stop=2, timeout=1, timeout_char=4) diff --git a/scripts/examples/09-OpenMV-Boards/00-Board-Control/blinky.py b/scripts/examples/09-OpenMV-Boards/00-Board-Control/blinky.py deleted file mode 100644 index 4d3dc2a7d..000000000 --- a/scripts/examples/09-OpenMV-Boards/00-Board-Control/blinky.py +++ /dev/null @@ -1,14 +0,0 @@ -# Blinky example - -import time -from machine import Pin - -# This is the only LED pin available on the Nano RP2040, -# other than the RGB LED connected to Nina WiFi module. -led = Pin("LED_BLUE", Pin.OUT) - -while True: - led.on() - time.sleep_ms(250) - led.off() - time.sleep_ms(250) diff --git a/scripts/examples/09-OpenMV-Boards/11-Low-Power/deep_sleep.py b/scripts/examples/09-OpenMV-Boards/11-Low-Power/deep_sleep.py index f0cdee5d3..975df38ba 100644 --- a/scripts/examples/09-OpenMV-Boards/11-Low-Power/deep_sleep.py +++ b/scripts/examples/09-OpenMV-Boards/11-Low-Power/deep_sleep.py @@ -2,12 +2,11 @@ # This example demonstrates the low-power deep sleep mode plus sensor shutdown. # Note the camera will reset after wake-up from deep sleep. To find out if the cause of reset # is deep sleep, call the machine.reset_cause() function and test for machine.DEEPSLEEP_RESET -import pyb import machine import sensor # Create and init RTC object. -rtc = pyb.RTC() +rtc = machine.RTC() # (year, month, day[, hour[, minute[, second[, microsecond[, tzinfo]]]]]) rtc.datetime((2014, 5, 1, 4, 13, 0, 0, 0)) diff --git a/scripts/examples/10-Arduino-Boards/Nano-33-BLE-Sense/00-Board-Control/blinky.py b/scripts/examples/10-Arduino-Boards/Nano-33-BLE-Sense/00-Board-Control/blinky.py deleted file mode 100644 index 000d401bf..000000000 --- a/scripts/examples/10-Arduino-Boards/Nano-33-BLE-Sense/00-Board-Control/blinky.py +++ /dev/null @@ -1,28 +0,0 @@ -# Blinky example - -import time -from board import LED - -led_red = LED(1) -led_green = LED(2) -led_blue = LED(3) -led_yellow = LED(4) - -while True: - led_blue.on() - time.sleep_ms(250) - led_blue.off() - - led_red.on() - time.sleep_ms(250) - led_red.off() - - led_green.on() - time.sleep_ms(250) - led_green.off() - - led_yellow.on() - time.sleep_ms(250) - led_yellow.off() - - time.sleep_ms(500) diff --git a/scripts/examples/10-Arduino-Boards/Nano-RP2040/00-Board-Control/blinky.py b/scripts/examples/10-Arduino-Boards/Nano-RP2040/00-Board-Control/blinky.py deleted file mode 100644 index aa9098f92..000000000 --- a/scripts/examples/10-Arduino-Boards/Nano-RP2040/00-Board-Control/blinky.py +++ /dev/null @@ -1,14 +0,0 @@ -# Blinky example - -import time -from machine import Pin - -# This is the only LED pin available on the Nano RP2040, -# other than the RGB LED connected to Nina WiFi module. -led = Pin(6, Pin.OUT) - -while True: - led.on() - time.sleep_ms(250) - led.off() - time.sleep_ms(250) diff --git a/scripts/examples/10-Arduino-Boards/Nicla-Vision/00-Board-Control/blinky.py b/scripts/examples/10-Arduino-Boards/Nicla-Vision/00-Board-Control/blinky.py deleted file mode 100644 index 4d3dc2a7d..000000000 --- a/scripts/examples/10-Arduino-Boards/Nicla-Vision/00-Board-Control/blinky.py +++ /dev/null @@ -1,14 +0,0 @@ -# Blinky example - -import time -from machine import Pin - -# This is the only LED pin available on the Nano RP2040, -# other than the RGB LED connected to Nina WiFi module. -led = Pin("LED_BLUE", Pin.OUT) - -while True: - led.on() - time.sleep_ms(250) - led.off() - time.sleep_ms(250) diff --git a/scripts/examples/10-Arduino-Boards/Nicla-Vision/05-Low-Power/deep_sleep.py b/scripts/examples/10-Arduino-Boards/Nicla-Vision/05-Low-Power/deep_sleep.py index 4fb26c7b2..6988189ae 100644 --- a/scripts/examples/10-Arduino-Boards/Nicla-Vision/05-Low-Power/deep_sleep.py +++ b/scripts/examples/10-Arduino-Boards/Nicla-Vision/05-Low-Power/deep_sleep.py @@ -2,12 +2,11 @@ # This example demonstrates the low-power deep sleep mode plus sensor shutdown. # Note the camera will reset after wake-up from deep sleep. To find out if the cause of reset # is deep sleep, call the machine.reset_cause() function and test for machine.DEEPSLEEP_RESET -import pyb import machine import sensor # Create and init RTC object. -rtc = pyb.RTC() +rtc = machine.RTC() # (year, month, day[, hour[, minute[, second[, microsecond[, tzinfo]]]]]) rtc.datetime((2014, 5, 1, 4, 13, 0, 0, 0)) diff --git a/scripts/examples/10-Arduino-Boards/Portenta-H7/00-Board-Control/blinky.py b/scripts/examples/10-Arduino-Boards/Portenta-H7/00-Board-Control/blinky.py deleted file mode 100644 index 4d3dc2a7d..000000000 --- a/scripts/examples/10-Arduino-Boards/Portenta-H7/00-Board-Control/blinky.py +++ /dev/null @@ -1,14 +0,0 @@ -# Blinky example - -import time -from machine import Pin - -# This is the only LED pin available on the Nano RP2040, -# other than the RGB LED connected to Nina WiFi module. -led = Pin("LED_BLUE", Pin.OUT) - -while True: - led.on() - time.sleep_ms(250) - led.off() - time.sleep_ms(250) diff --git a/scripts/examples/10-Arduino-Boards/Portenta-H7/06-Low-Power/deep_sleep.py b/scripts/examples/10-Arduino-Boards/Portenta-H7/06-Low-Power/deep_sleep.py index 4fb26c7b2..6988189ae 100644 --- a/scripts/examples/10-Arduino-Boards/Portenta-H7/06-Low-Power/deep_sleep.py +++ b/scripts/examples/10-Arduino-Boards/Portenta-H7/06-Low-Power/deep_sleep.py @@ -2,12 +2,11 @@ # This example demonstrates the low-power deep sleep mode plus sensor shutdown. # Note the camera will reset after wake-up from deep sleep. To find out if the cause of reset # is deep sleep, call the machine.reset_cause() function and test for machine.DEEPSLEEP_RESET -import pyb import machine import sensor # Create and init RTC object. -rtc = pyb.RTC() +rtc = machine.RTC() # (year, month, day[, hour[, minute[, second[, microsecond[, tzinfo]]]]]) rtc.datetime((2014, 5, 1, 4, 13, 0, 0, 0))