import time from pimoroni_i2c import PimoroniI2C from breakout_msa301 import BreakoutMSA301 PINS_BREAKOUT_GARDEN = {"sda": 4, "scl": 5} PINS_PICO_EXPLORER = {"sda": 20, "scl": 21} i2c = PimoroniI2C(**PINS_BREAKOUT_GARDEN) msa = BreakoutMSA301(i2c) part_id = msa.part_id() print("Found MSA301. Part ID: 0x", '{:02x}'.format(part_id), sep="") msa.enable_interrupts(BreakoutMSA301.FREEFALL | BreakoutMSA301.ORIENTATION) while True: print("X:", msa.get_x_axis(), end=",\t") print("Y:", msa.get_y_axis(), end=",\t") print("Z:", msa.get_z_axis(), end=",\t") print("Freefall?", msa.read_interrupt(BreakoutMSA301.FREEFALL), end=",\t") print("Orientation:", msa.get_orientation()) time.sleep(0.1)
import utime from breakout_bme68x import BreakoutBME68X from pimoroni_i2c import PimoroniI2C # Pico Explorer boilerplate import picoexplorer as display width = display.get_width() height = display.get_height() display_buffer = bytearray(width * height * 2) display.init(display_buffer) PINS_BREAKOUT_GARDEN = {"sda": 4, "scl": 5} PINS_PICO_EXPLORER = {"sda": 20, "scl": 21} i2c = PimoroniI2C(**PINS_PICO_EXPLORER) bme = BreakoutBME68X(i2c) # lets set up some pen colours to make drawing easier tempcolour = display.create_pen(255, 255, 255) # this colour will get changed in a bit white = display.create_pen(255, 255, 255) black = display.create_pen(0, 0, 0) red = display.create_pen(255, 0, 0) # converts the temperature into a barometer-type description and pen colour def describe_temperature(temperature): global tempcolour if temperature < 10: description = "very cold" tempcolour = display.create_pen(0, 255, 255)
# Pick *one* LED type by uncommenting the relevant line below: # APA102 / DotStar™ LEDs led_strip = plasma.APA102(NUM_LEDS, 0, 0, plasma2040.DAT, plasma2040.CLK) # WS2812 / NeoPixel™ LEDs # led_strip = plasma.WS2812(NUM_LEDS, 0, 0, plasma2040.DAT) user_sw = Button(plasma2040.USER_SW, repeat_time=0) button_a = Button(plasma2040.BUTTON_A, repeat_time=0) button_b = Button(plasma2040.BUTTON_B, repeat_time=0) led = RGBLED(plasma2040.LED_R, plasma2040.LED_G, plasma2040.LED_B) PINS_PLASMA2040 = {"sda": plasma2040.SDA, "scl": plasma2040.SCL} i2c = PimoroniI2C(**PINS_PLASMA2040) msa = BreakoutMSA301(i2c) ANGLE, VELOCITY = range(2) # Maps a value from one range to another def map(x, in_min, in_max, out_min, out_max): return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min # Shows a band and goal with the given widths at the positions on the strip def colour_band(centre_position, width, goal_position, goal_width, hue): if centre_position >= 0.0 and width > 0.0 and goal_width > 0.0: band_pixels_start = centre_position - (width / 2) band_pixels_end = centre_position + (width / 2)
from pimoroni_i2c import PimoroniI2C from breakout_as7262 import BreakoutAS7262 import picoexplorer as display import time width = display.get_width() height = display.get_height() bar_width = width // 6 bar_height = height display_buffer = bytearray(width * height * 2) # 2-bytes per pixel (RGB565) display.init(display_buffer) i2c = PimoroniI2C(20, 21) as7 = BreakoutAS7262(i2c) integration_time = 10 # integration time in milliseconds, max ~90ms as7.set_gain(as7.X64) as7.set_integration_time(integration_time) as7.set_measurement_mode(as7.CONT_ROYGBR) as7.set_leds(True, True) def draw_bar(v, i): current_bar_top = int(bar_height - (bar_height * v)) # Drawing outside of the display region will cause horrible, horrible crashes current_bar_top = max(0, current_bar_top) current_bar_height = bar_height - current_bar_top display.rectangle(i * bar_width, current_bar_top, bar_width,