diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7636ab8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +build/workspace +build/out +build/workspace/* +build/out/* diff --git a/build/dimensioner.sh b/build/dimensioner.sh old mode 100644 new mode 100755 index d8701e7..72240c0 --- a/build/dimensioner.sh +++ b/build/dimensioner.sh @@ -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 diff --git a/src/dimensioner/dimensioner_screen.py b/src/dimensioner/dimensioner_screen.py index 465ce71..80d7d87 100644 --- a/src/dimensioner/dimensioner_screen.py +++ b/src/dimensioner/dimensioner_screen.py @@ -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) diff --git a/src/dimensioner/main.py b/src/dimensioner/main.py index c63224c..63c00d6 100644 --- a/src/dimensioner/main.py +++ b/src/dimensioner/main.py @@ -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: diff --git a/src/dimensioner/manifest.py b/src/dimensioner/manifest.py index 00911e8..df622cf 100644 --- a/src/dimensioner/manifest.py +++ b/src/dimensioner/manifest.py @@ -1,7 +1,8 @@ # Build manifest for PostalPoint Parcel Dimensioner +include("$(MPY_DIR)/ports/rp2/boards/manifest.py") require("usb-device-hid") require("ssd1306") module("dimensioner_utils.py") module("dimensioner_screen.py") module("ssd1306big.py") -module("main.py") \ No newline at end of file +module("main.py")