Change default pin assignments, add UF2 build script

This commit is contained in:
Skylar Ittner 2025-04-10 16:15:01 -06:00
parent c3b50d46e1
commit aa0fdfe6a2
5 changed files with 30 additions and 13 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
build/workspace
build/out
build/workspace/*
build/out/*

12
build/dimensioner.sh Normal file → Executable file
View File

@ -1,10 +1,14 @@
#!/bin/bash
mkdir workspace
mkdir -p workspace/src/dimensioner
cp -r ../src/dimensioner/* workspace/src/dimensioner/
cd workspace
git clone https://github.com/micropython/micropython.git
git clone https://github.com/micropython/micropython.git --branch=master --depth=1
cd micropython
make -C ports/rp2 submodules
make -C mpy-cross
cd ports/rp2
make submodules
make BOARD=RPI_PICO FROZEN_MANIFEST=../../../../src/dimensioner/manifest.py
make FROZEN_MANIFEST=../../../src/dimensioner/manifest.py
cd ../../../../
mkdir -p out
mv workspace/micropython/ports/rp2/build-RPI_PICO/firmware.uf2 out/dimensioner.uf2

View File

@ -46,10 +46,17 @@ import math
ENABLE_DISPLAY = True # Set to False to ignore display commands
DISPLAY_WIDTH = 128
DISPLAY_HEIGHT = 64
DISPLAY_SDA_PIN = 0
DISPLAY_SCL_PIN = 1
# Available pin combinations for I2C:
# I2C 0 SDA: GP0/GP4/GP8/GP12/GP16/GP20
# I2C 0 SCL: GP1/GP5/GP9/GP13/GP17/GP21
# I2C 1 SDA: GP2/GP6/GP10/GP14/GP18/GP26
# I2C 1 SCL: GP3/GP7/GP11/GP15/GP19/GP27
# Just don't conflict with the pin assignments for the sensor and buttons!
DISPLAY_SDA_PIN = 6
DISPLAY_SCL_PIN = 7
DISPLAY_I2C_CONTROLLER = 1
i2c = I2C(0,sda=Pin(DISPLAY_SDA_PIN), scl=Pin(DISPLAY_SCL_PIN), freq=400000)
i2c = I2C(DISPLAY_I2C_CONTROLLER, sda=Pin(DISPLAY_SDA_PIN), scl=Pin(DISPLAY_SCL_PIN), freq=400000)
oled = SSD1306_I2C(DISPLAY_WIDTH, DISPLAY_HEIGHT, i2c)

View File

@ -77,9 +77,10 @@ from dimensioner_screen import updateDisplay, errorDisplay, bootDisplay, clearDi
SENSOR_TYPE = "US-100" # "PING" for Parallax PING))) or "US-100" for US-100
SENSOR_MAX_MM = 3000 # Maximum range sensor supports and is accurate within
SENSOR_MIN_MM = 100 # Minimum range below which sensor is not accurate
SENSOR_PIN = 18 # Analog pin for PING sensor
SENSOR_TX = 4 # Digital pin for US-100
SENSOR_RX = 5 # Digital pin for US-100
SENSOR_PIN = 17 # Analog pin for PING sensor
SENSOR_TX = 16 # Digital pin for US-100
SENSOR_RX = 17 # Digital pin for US-100
UART_ID = 0 # TX/RX: UART 0: 12/13, 16/17; UART 1: 4/5, 8/9
ZERO_RANGE_MM = 10 # +/- mm away from zero before a non-zero value is transmitted
SAMPLE_SIZE = 20 # Number of times to sample distance per reading, averaging the results
UNSTABLE_DELTA_MM = 50 # Max difference between largest and smallest samples (before averaging), larger than this will report as unstable
@ -97,7 +98,7 @@ PID = 0xA002 # USB Product ID
MANU = "PostalPortal LLC" # USB manufacturer string
PROD = "PostalPoint Parcel Dimensioner" # USB product string
INTERFACE = "PostalPoint" # Interface string
USBHID_ENABLED = False # Disable USB, use serial output only (good for debugging)
USBHID_ENABLED = True # Disable USB, use serial output only (good for debugging)
class USBHIDInterface(HIDInterface):
def __init__(self):
@ -311,7 +312,7 @@ def getAverageDistanceMM(samples = SAMPLE_SIZE):
loadSettings()
if SENSOR_TYPE == "US-100":
sensorUart = UART(1, baudrate=9600, tx=Pin(4), rx=Pin(5))
sensorUart = UART(UART_ID, baudrate=9600, tx=Pin(SENSOR_TX), rx=Pin(SENSOR_RX))
sensorUart.init(bits=8, parity=None, stop=2)
try:

View File

@ -1,4 +1,5 @@
# Build manifest for PostalPoint Parcel Dimensioner
include("$(MPY_DIR)/ports/rp2/boards/manifest.py")
require("usb-device-hid")
require("ssd1306")
module("dimensioner_utils.py")