Skip to content

Commit

Permalink
Explorer: Adjusted how servos are init
Browse files Browse the repository at this point in the history
  • Loading branch information
thirdr committed Oct 2, 2024
1 parent 7941413 commit 828da34
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 66 deletions.
11 changes: 3 additions & 8 deletions examples/lib/pimoroni_explorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@
AMP_CORRECTION = const(4)
DEFAULT_VOLUME = const(0.2)

# Store the servos here if the user inits them.
servos = []

# Set up the i2c for Qw/st and Breakout Garden
i2c = PimoroniI2C(I2C_SDA_PIN, I2C_SCL_PIN, 100000)

Expand All @@ -87,6 +84,9 @@
# Setup the display
display = PicoGraphics(display=DISPLAY_EXPLORER)

# setup servos
servos = [Servo(SERVO_1_PIN - i) for i in range(4)]


def play_tone(frequency):
try:
Expand Down Expand Up @@ -126,8 +126,3 @@ def set_volume(volume=None):

def mute_audio(value=True):
_amp_en.off() if value else _amp_en.on()


def init_servos():
global servos
servos = [Servo(SERVO_1_PIN - i) for i in range(4)]
9 changes: 2 additions & 7 deletions examples/multi-sensor-breakout/double_tap.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
import time
from machine import I2C
from lsm6ds3 import LSM6DS3, NORMAL_MODE_104HZ
from picographics import PicoGraphics, DISPLAY_EXPLORER, PEN_P8
from pimoroni_explorer import display, i2c, BLACK, WHITE

display = PicoGraphics(display=DISPLAY_EXPLORER, pen_type=PEN_P8)
WIDTH, HEIGHT = display.get_bounds()

# Some colours we'll need later on
# Define our own pen here
BG = display.create_pen(70, 130, 180)
WHITE = display.create_pen(255, 255, 255)
BLACK = display.create_pen(0, 0, 0)

# Create the I2C instance and pass that to LSM6DS3
i2c = I2C(0, scl=21, sda=20)
sensor = LSM6DS3(i2c, mode=NORMAL_MODE_104HZ)

# Text size and Offset for the drop shadow. We'll use these later!
Expand Down
11 changes: 3 additions & 8 deletions examples/multi-sensor-breakout/double_tap_async.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
from machine import I2C
from pimoroni_explorer import display, i2c, BLACK, WHITE
from lsm6ds3 import LSM6DS3, NORMAL_MODE_104HZ
from picographics import PicoGraphics, DISPLAY_EXPLORER, PEN_P8
import asyncio

display = PicoGraphics(display=DISPLAY_EXPLORER, pen_type=PEN_P8)

WIDTH, HEIGHT = display.get_bounds()

# Some colours we'll need later on
# Define our own pen for the background
BG = display.create_pen(70, 130, 180)
WHITE = display.create_pen(255, 255, 255)
BLACK = display.create_pen(0, 0, 0)

# Create the I2C instance and pass that to LSM6DS3
i2c = I2C(0, scl=21, sda=20)
# Create an LSM6DS3
sensor = LSM6DS3(i2c, mode=NORMAL_MODE_104HZ)

# Text size and Offset for the drop shadow. We'll use these later!
Expand Down
18 changes: 4 additions & 14 deletions examples/multi-sensor-breakout/explorer_sensor_stick_demo.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,13 @@
# Display readings from the multi-sensor stick on the Explorer screen
from pimoroni_explorer import PimoroniExplorer
from pimoroni_explorer import display, i2c, BLACK, WHITE
from breakout_ltr559 import BreakoutLTR559
from lsm6ds3 import LSM6DS3
from breakout_bme280 import BreakoutBME280
import time

board = PimoroniExplorer()

ltr = BreakoutLTR559(board.i2c)
lsm = LSM6DS3(board.i2c)
bme = BreakoutBME280(board.i2c)

display = board.display

# lets set up some pen colours to make drawing easier
WHITE = display.create_pen(255, 255, 255)
BLACK = display.create_pen(0, 0, 0)
RED = display.create_pen(255, 0, 0)
GREY = display.create_pen(125, 125, 125)
ltr = BreakoutLTR559(i2c)
lsm = LSM6DS3(i2c)
bme = BreakoutBME280(i2c)

while True:
lux, _, _, _, _, _, prox = ltr.get_reading()
Expand Down
24 changes: 3 additions & 21 deletions examples/multi-sensor-breakout/shake.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,12 @@
import time
from machine import I2C, Pin
from lsm6ds3 import LSM6DS3, NORMAL_MODE_104HZ
from picographics import PicoGraphics, DISPLAY_EXPLORER, PEN_P8
from pimoroni_explorer import display, i2c, button_a, button_b, button_c, button_x, button_z, BLACK, WHITE, RED, GREEN, BLUE

display = PicoGraphics(display=DISPLAY_EXPLORER, pen_type=PEN_P8)
WIDTH, HEIGHT = display.get_bounds()

# Some colours we'll need later on
WHITE = display.create_pen(255, 255, 255)
BLACK = display.create_pen(0, 0, 0)
RED = display.create_pen(255, 0, 0)
GREEN = display.create_pen(0, 255, 0)
BLUE = display.create_pen(0, 0, 255)
BG = WHITE

# Create the I2C instance and pass that to LSM6DS3
i2c = I2C(0, scl=21, sda=20)
# Setup the LSM6DS3
sensor = LSM6DS3(i2c, mode=NORMAL_MODE_104HZ)

# Setup the pins used by the Buttons
button_a = Pin(16, Pin.IN, Pin.PULL_UP)
button_b = Pin(15, Pin.IN, Pin.PULL_UP)
button_c = Pin(14, Pin.IN, Pin.PULL_UP)
button_x = Pin(17, Pin.IN, Pin.PULL_UP)
button_z = Pin(19, Pin.IN, Pin.PULL_UP)


class PALETTE(object):

Expand Down Expand Up @@ -83,7 +65,7 @@ def process_input(self):

def draw(self):
# Clear the screen
display.set_pen(BG)
display.set_pen(WHITE)
display.clear()

display.set_pen(RED)
Expand Down
10 changes: 2 additions & 8 deletions examples/multi-sensor-breakout/step_counter.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
import time
import pngdec
from machine import I2C
from lsm6ds3 import LSM6DS3, NORMAL_MODE_104HZ
from picographics import PicoGraphics, DISPLAY_EXPLORER, PEN_P8

display = PicoGraphics(display=DISPLAY_EXPLORER, pen_type=PEN_P8)
from pimoroni_explorer import display, i2c, BLACK, WHITE
png = pngdec.PNG(display)

WIDTH, HEIGHT = display.get_bounds()

# Some colours we'll need later on
BG = display.create_pen(255, 99, 71)
WHITE = display.create_pen(255, 255, 255)
BLACK = display.create_pen(0, 0, 0)

# Create the I2C instance and pass that to LSM6DS3
i2c = I2C(0, scl=21, sda=20)
# Setup LSM6DS3
sensor = LSM6DS3(i2c, mode=NORMAL_MODE_104HZ)

# Text size and Offset for the drop shadow. We'll use these later!
Expand Down

0 comments on commit 828da34

Please sign in to comment.