Simplified example I2C setup
This commit is contained in:
parent
4dadeb0d4d
commit
862806f357
|
@ -1,4 +1,5 @@
|
|||
from pimoroni_i2c import PimoroniI2C
|
||||
from pimoroni import BREAKOUT_GARDEN_I2C_PINS # or PICO_EXPLORER_I2C_PINS or HEADER_I2C_PINS
|
||||
from breakout_encoder_wheel import BreakoutEncoderWheel, UP, DOWN, LEFT, RIGHT, CENTRE, NUM_BUTTONS, NUM_LEDS
|
||||
|
||||
"""
|
||||
|
@ -7,14 +8,11 @@ A demonstration of reading the 5 buttons on Encoder Wheel.
|
|||
Press Ctrl+C to stop the program.
|
||||
"""
|
||||
|
||||
PINS_BREAKOUT_GARDEN = {"sda": 4, "scl": 5}
|
||||
PINS_PICO_EXPLORER = {"sda": 20, "scl": 21}
|
||||
|
||||
# Constants
|
||||
BUTTON_NAMES = ["Up", "Down", "Left", "Right", "Centre"]
|
||||
|
||||
# Create a new BreakoutEncoderWheel
|
||||
i2c = PimoroniI2C(**PINS_BREAKOUT_GARDEN)
|
||||
i2c = PimoroniI2C(**BREAKOUT_GARDEN_I2C_PINS)
|
||||
wheel = BreakoutEncoderWheel(i2c)
|
||||
|
||||
# Variables
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import random
|
||||
from pimoroni_i2c import PimoroniI2C
|
||||
from pimoroni import BREAKOUT_GARDEN_I2C_PINS # or PICO_EXPLORER_I2C_PINS or HEADER_I2C_PINS
|
||||
from breakout_encoder_wheel import BreakoutEncoderWheel, NUM_LEDS
|
||||
|
||||
"""
|
||||
|
@ -10,10 +11,7 @@ When you reach the goal, the goal will move to a new random position.
|
|||
Press Ctrl+C to stop the program.
|
||||
"""
|
||||
|
||||
PINS_BREAKOUT_GARDEN = {"sda": 4, "scl": 5}
|
||||
PINS_PICO_EXPLORER = {"sda": 20, "scl": 21}
|
||||
|
||||
i2c = PimoroniI2C(**PINS_BREAKOUT_GARDEN)
|
||||
i2c = PimoroniI2C(**BREAKOUT_GARDEN_I2C_PINS)
|
||||
wheel = BreakoutEncoderWheel(i2c)
|
||||
|
||||
# The band colour hues to show in Angle mode
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import time
|
||||
from machine import RTC
|
||||
|
||||
from pimoroni_i2c import PimoroniI2C
|
||||
from pimoroni import BREAKOUT_GARDEN_I2C_PINS # or PICO_EXPLORER_I2C_PINS or HEADER_I2C_PINS
|
||||
from breakout_encoder_wheel import BreakoutEncoderWheel, NUM_LEDS
|
||||
|
||||
"""
|
||||
|
@ -10,9 +10,6 @@ Displays a 12 hour clock on Encoder Wheel's LED ring, getting time from the syst
|
|||
Press Ctrl+C to stop the program.
|
||||
"""
|
||||
|
||||
PINS_BREAKOUT_GARDEN = {"sda": 4, "scl": 5}
|
||||
PINS_PICO_EXPLORER = {"sda": 20, "scl": 21}
|
||||
|
||||
# Datetime Indices
|
||||
HOUR = 4
|
||||
MINUTE = 5
|
||||
|
@ -30,8 +27,10 @@ MILLIS_PER_HOUR = MILLIS_PER_MINUTE * 60
|
|||
MILLIS_PER_HALF_DAY = MILLIS_PER_HOUR * 12
|
||||
|
||||
# Create a new BreakoutEncoderWheel
|
||||
i2c = PimoroniI2C(**PINS_BREAKOUT_GARDEN)
|
||||
i2c = PimoroniI2C(**BREAKOUT_GARDEN_I2C_PINS)
|
||||
wheel = BreakoutEncoderWheel(i2c)
|
||||
|
||||
# Access the built-in RTC
|
||||
rtc = RTC()
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import time
|
||||
|
||||
from pimoroni_i2c import PimoroniI2C
|
||||
from pimoroni import BREAKOUT_GARDEN_I2C_PINS # or PICO_EXPLORER_I2C_PINS or HEADER_I2C_PINS
|
||||
from breakout_encoder_wheel import BreakoutEncoderWheel, UP, DOWN, LEFT, RIGHT, CENTRE, NUM_LEDS
|
||||
|
||||
"""
|
||||
|
@ -16,9 +16,6 @@ Press the centre to hide the selection marker
|
|||
Press Ctrl+C to stop the program.
|
||||
"""
|
||||
|
||||
PINS_BREAKOUT_GARDEN = {"sda": 4, "scl": 5}
|
||||
PINS_PICO_EXPLORER = {"sda": 20, "scl": 21}
|
||||
|
||||
# Constants
|
||||
BRIGHTNESS_STEP = 0.02 # How much to increase or decrease the brightness each update
|
||||
SATURATION_STEP = 0.02 # How much to increase or decrease the saturation each update
|
||||
|
@ -26,7 +23,7 @@ UPDATES = 50 # How many times to update the LEDs per second
|
|||
UPDATE_RATE_US = 1000000 // UPDATES
|
||||
|
||||
# Create a new BreakoutEncoderWheel
|
||||
i2c = PimoroniI2C(**PINS_BREAKOUT_GARDEN)
|
||||
i2c = PimoroniI2C(**BREAKOUT_GARDEN_I2C_PINS)
|
||||
wheel = BreakoutEncoderWheel(i2c)
|
||||
|
||||
# Variables
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from pimoroni_i2c import PimoroniI2C
|
||||
from pimoroni import BREAKOUT_GARDEN_I2C_PINS # or PICO_EXPLORER_I2C_PINS or HEADER_I2C_PINS
|
||||
from breakout_encoder_wheel import BreakoutEncoderWheel
|
||||
|
||||
"""
|
||||
|
@ -11,7 +12,7 @@ PINS_BREAKOUT_GARDEN = {"sda": 4, "scl": 5}
|
|||
PINS_PICO_EXPLORER = {"sda": 20, "scl": 21}
|
||||
|
||||
# Create a new BreakoutEncoderWheel
|
||||
i2c = PimoroniI2C(**PINS_BREAKOUT_GARDEN)
|
||||
i2c = PimoroniI2C(**BREAKOUT_GARDEN_I2C_PINS)
|
||||
wheel = BreakoutEncoderWheel(i2c)
|
||||
|
||||
# Variables
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import math
|
||||
import time
|
||||
|
||||
from breakout_ioexpander import BreakoutIOExpander
|
||||
from pimoroni_i2c import PimoroniI2C
|
||||
from pimoroni import BREAKOUT_GARDEN_I2C_PINS # or PICO_EXPLORER_I2C_PINS or HEADER_I2C_PINS
|
||||
from breakout_encoder_wheel import BreakoutEncoderWheel, CENTRE, GPIOS, NUM_GPIOS
|
||||
from breakout_ioexpander import PWM
|
||||
|
||||
"""
|
||||
Output a sine wave PWM sequence on the Encoder Wheel's side GPIO pins.
|
||||
|
@ -11,16 +11,14 @@ Output a sine wave PWM sequence on the Encoder Wheel's side GPIO pins.
|
|||
Press the centre button or Ctrl+C to stop the program.
|
||||
"""
|
||||
|
||||
PINS_BREAKOUT_GARDEN = {"sda": 4, "scl": 5}
|
||||
PINS_PICO_EXPLORER = {"sda": 20, "scl": 21}
|
||||
|
||||
# Constants
|
||||
SPEED = 5 # The speed that the PWM will cycle at
|
||||
UPDATES = 50 # How many times to update LEDs and Servos per second
|
||||
UPDATE_RATE_US = 1000000 // UPDATES
|
||||
FREQUENCY = 1000 # The frequency to run the PWM at
|
||||
|
||||
# Create a new BreakoutEncoderWheel
|
||||
i2c = PimoroniI2C(**PINS_BREAKOUT_GARDEN)
|
||||
i2c = PimoroniI2C(**BREAKOUT_GARDEN_I2C_PINS)
|
||||
wheel = BreakoutEncoderWheel(i2c)
|
||||
|
||||
# Set the PWM frequency for the GPIOs
|
||||
|
@ -28,8 +26,9 @@ period = wheel.gpio_pwm_frequency(FREQUENCY)
|
|||
|
||||
# Set the GPIO pins to PWM outputs
|
||||
for g in GPIOS:
|
||||
wheel.gpio_pin_mode(g, BreakoutIOExpander.PIN_PWM)
|
||||
wheel.gpio_pin_mode(g, PWM)
|
||||
|
||||
# Variables
|
||||
offset = 0.0
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import time
|
||||
|
||||
from pimoroni_i2c import PimoroniI2C
|
||||
from pimoroni import BREAKOUT_GARDEN_I2C_PINS # or PICO_EXPLORER_I2C_PINS or HEADER_I2C_PINS
|
||||
from breakout_encoder_wheel import BreakoutEncoderWheel, NUM_LEDS
|
||||
|
||||
"""
|
||||
|
@ -9,9 +9,6 @@ Displays a rotating rainbow pattern on Encoder Wheel's LED ring.
|
|||
Press Ctrl+C to stop the program.
|
||||
"""
|
||||
|
||||
PINS_BREAKOUT_GARDEN = {"sda": 4, "scl": 5}
|
||||
PINS_PICO_EXPLORER = {"sda": 20, "scl": 21}
|
||||
|
||||
# Constants
|
||||
SPEED = 5 # The speed that the LEDs will cycle at
|
||||
BRIGHTNESS = 1.0 # The brightness of the LEDs
|
||||
|
@ -19,7 +16,7 @@ UPDATES = 50 # How many times the LEDs will be updated per second
|
|||
UPDATE_RATE_US = 1000000 // UPDATES
|
||||
|
||||
# Create a new BreakoutEncoderWheel
|
||||
i2c = PimoroniI2C(**PINS_BREAKOUT_GARDEN)
|
||||
i2c = PimoroniI2C(**BREAKOUT_GARDEN_I2C_PINS)
|
||||
wheel = BreakoutEncoderWheel(i2c)
|
||||
|
||||
# Variables
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import math
|
||||
import time
|
||||
|
||||
from pimoroni_i2c import PimoroniI2C
|
||||
from pimoroni import BREAKOUT_GARDEN_I2C_PINS # or PICO_EXPLORER_I2C_PINS or HEADER_I2C_PINS
|
||||
from breakout_encoder_wheel import BreakoutEncoderWheel, CENTRE, NUM_LEDS
|
||||
|
||||
"""
|
||||
|
@ -12,9 +12,6 @@ Press the centre button to start the stopwatch, then again to pause and resume.
|
|||
Press Ctrl+C to stop the program.
|
||||
"""
|
||||
|
||||
PINS_BREAKOUT_GARDEN = {"sda": 4, "scl": 5}
|
||||
PINS_PICO_EXPLORER = {"sda": 20, "scl": 21}
|
||||
|
||||
# Constants
|
||||
BRIGHTNESS = 1.0 # The brightness of the LEDs when the stopwatch is running
|
||||
UPDATES = 50 # How many times the LEDs will be updated per second
|
||||
|
@ -29,7 +26,8 @@ UPDATES_PER_PULSE = IDLE_PULSE_TIME * UPDATES
|
|||
|
||||
IDLE, COUNTING, PAUSED = range(3) # The state constants used for program flow
|
||||
|
||||
i2c = PimoroniI2C(**PINS_BREAKOUT_GARDEN)
|
||||
# Create a new BreakoutEncoderWheel
|
||||
i2c = PimoroniI2C(**BREAKOUT_GARDEN_I2C_PINS)
|
||||
wheel = BreakoutEncoderWheel(i2c)
|
||||
|
||||
# Variables
|
||||
|
|
Loading…
Reference in New Issue