Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
6dc9272
a few UI issues with Hexpansion Manager when plugging and removing he…
lincoltd7 Apr 27, 2026
817ffb5
Add encoder smoke test and rotation rate sensor pair functionality
lincoltd7 Apr 27, 2026
f185519
make dev download more robust for where things are
lincoltd7 Apr 27, 2026
510f7c2
Refactor version retrieval logic in HexpansionMgr for improved clarit…
Robotmad Apr 30, 2026
54db4fa
Remove unused get_version method from GPSApp to streamline code
Robotmad Apr 30, 2026
e06f222
Remove unused get_version method from HexDriveApp to simplify code
Robotmad Apr 30, 2026
549c52b
colour sensor calibration, use hexpansion EEPROM VERSION, Switch to O…
Robotmad Apr 30, 2026
e7066a9
working driver
Robotmad Apr 30, 2026
3f77c17
wider use of diagnostics outputs, simplify white gains
Robotmad May 1, 2026
f36498d
hexpansion management improvements - cope with hexpansiosn that don't…
Robotmad May 2, 2026
dc37d2c
small mods
Robotmad May 2, 2026
cc02f4c
turn off print output
Robotmad May 3, 2026
7e8e1a1
tidy up to remove dummy hexpansion types now that we have explicit pe…
Robotmad May 3, 2026
584f68f
app part of removign dummy hexpansion types
Robotmad May 3, 2026
00bc81e
updates with real HexDrive2 s
Robotmad May 5, 2026
e836a2c
Big refactor to mange servos and motors shared use of PWM better.
Robotmad May 5, 2026
21e2a68
primitive board test featuresfull rpm vs power charting, start of ana…
Robotmad May 7, 2026
891a36f
initial draft of texhest app - with means to download via BadgeBot
Robotmad May 7, 2026
baf708f
hextest work
Robotmad May 8, 2026
ca570e5
fix a warning
Robotmad May 8, 2026
9cb3a74
fix plot x scaling issue
Robotmad May 8, 2026
5d4b89e
Merge branch 'QuadratureDecoding' into HexTest
lincoltd7 May 8, 2026
477f475
use to be released hexpansion utils
lincoltd7 May 9, 2026
efdff97
get hexdrive to fit in 8kEEPROM
lincoltd7 May 9, 2026
431e0a0
Vendor HexDrive2 for EEPROM deployment
lincoltd7 May 9, 2026
e80dbff
Clarify HexDrive support and PWM resource details
Robotmad May 9, 2026
ab8f249
Refactor HexDrive app to support optional hexpansion manager and clea…
lincoltd7 May 10, 2026
61ef43c
Update HexDrive2 subproject commit reference
lincoltd7 May 10, 2026
771c59a
more efficient persist method
Robotmad May 12, 2026
42ba9b1
minification
Robotmad May 13, 2026
7e39406
mpy minification
Robotmad May 13, 2026
8e77c99
hextest compatibility with older badgeOS
Robotmad May 14, 2026
cf26dfb
wip
Robotmad May 15, 2026
7c5673b
remember position in menus
Robotmad May 18, 2026
b091d5c
consistent use of _SLOTS across apps
Robotmad May 18, 2026
2eb9cb4
improved user experience for power and acceleration values
Robotmad May 18, 2026
fe73e54
renaming to make use of variables etc clearer
Robotmad May 18, 2026
d6d54bd
remember settings menu position
Robotmad May 18, 2026
dc4f38c
use of const & set a default hexdrive type (uncommitted) in case of …
Robotmad May 18, 2026
de26df9
use of const and some renaming to clarify use of variables etc
Robotmad May 18, 2026
ffc3ef4
Update vendor HexDrive2 submodule to latest
Robotmad May 19, 2026
217f4c6
remove hextest from BadgeBot - now runs as its own app
Robotmad May 31, 2026
d44c7ac
use new hexpansion support and make robust against micropython v1.28 …
Robotmad May 31, 2026
671110c
hextest - file id from hexpansion id when non-zero. settings for ir_p…
Robotmad May 31, 2026
6738aae
Update HexDrive2 submodule to latest commit
Robotmad May 31, 2026
46955f7
BLE
Robotmad Jun 4, 2026
be7ecb8
Add BLE logging support and motor override functionality
Robotmad Jun 4, 2026
d6c2361
Refactor HexTestApp logging and settings; update rotation rate parame…
Robotmad Jun 11, 2026
6df7909
fix formatting for BLE logging property
Robotmad Jun 11, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ BadgeBot.code-workspace
.editorconfig
.venv/
.venv-wsl*/

# minify.py build artefacts
vendor/**/*.min.py
vendor/**/*.renamed.py
EEPROM/*.renamed.py
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "vendor/HexDrive2"]
path = vendor/HexDrive2
url = https://github.com/TeamRobotmad/HexDrive2.git
27 changes: 4 additions & 23 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,7 @@
{
// Force pylint to use the shared project config in pyproject.toml.
// Force pylint to use the shared sim/apps config.
// This keeps CLI runs and VS Code diagnostics aligned.
"pylint.args": [
"--rcfile=${workspaceFolder}/pyproject.toml"
],

// Pylance diagnostics are separate from pylint.
// We disable missing-import noise for BadgeOS/MicroPython modules that
// only exist on-device, while keeping other analysis enabled.
"python.analysis.diagnosticSeverityOverrides": {
"reportMissingModuleSource": "none",
"reportMissingImports": "none"
},

// Point Pylance at local .pyi stubs for BadgeOS and MicroPython APIs.
// See typings/README.md for rationale and maintenance notes.
"python.analysis.stubPath": "typings",

// No additional import roots are needed because stubs are provided via
// python.analysis.stubPath and project files resolve from workspace root.
"python.analysis.extraPaths": [],

// Keep analysis enabled for all project files by default.
"python.analysis.ignore": []
}
"--rcfile=${workspaceFolder}/../pyproject.toml"
]
}
12 changes: 5 additions & 7 deletions EEPROM/gps.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,25 @@

# Minimal length method names to make the mpy file as small as possible so it might fit in the 2k hexpansion EEPROM.
# Minimal functionality to get a GPS fix
# This version is NOT for the App Store

VERSION = 1

# Hardware defintions:
TX_PIN = 1 # HS_G for TX
RX_PIN = 0 # HS_F for RX
RESET_PIN = 2 # HS_H for reset
PPS_PIN = 3 # HS_I for PPS

GREEN_LED_PIN = 2 # LS_C for green LED control
RED_LED_PIN = 3 # LS_D for red LED control

###JUST FOR USE WITH MY PROTOTYPE BOARD
ENABLE_PIN = 0 # First LS pin used to enable the SMPSU
###JUST FOR USE WITH MY PROTOTYPE BOARD

class GPSApp(app.App): # pylint: disable=no-member
""" App to get GPS data from a GPS module connected to the hexpansion and display it on the badge. """
VERSION = 1 # Increment this when making changes to the app that require the hexpansion app to be re-flashed with the new code.

def __init__(self, config: HexpansionConfig | None = None):
super().__init__()
# If run from EEPROM on the hexpansion, the config will be passed in with the correct pin objects
Expand Down Expand Up @@ -68,11 +71,6 @@ def deinit(self):
self.power_control.value(0) # Cut power to the GPS to save power when not in use


def get_version(self) -> int:
""" Get the version of the app - this is used to determine if an upgrade is required. """
return VERSION


async def s(self, event: RequestStopAppEvent):
""" Handle the RequestStopAppEvent so that we can release resources """
if event.app == self:
Expand Down
510 changes: 259 additions & 251 deletions EEPROM/hexdrive.py

Large diffs are not rendered by default.

2,525 changes: 2,525 additions & 0 deletions EEPROM/hextest.py

Large diffs are not rendered by default.

51 changes: 40 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# BadgeBot app

Companion app for the HexDrive hexpansion. Supports 2 brushed DC motors, 4 RC servos, 1 motor + 2 servos. Features Logo-style motor programming, PID line following with automatic gain tuning, I²C sensor testing, servo test mode, and persistent settings management.
Companion app for the HexDrive hexpansion. Supports 2 brushed DC motors, 4 RC servos (2 for HexDrive2), 1 motor + 2 servos (1 for HexDrive2). Features Logo-style motor programming, PID line following with automatic gain tuning, I²C sensor testing, servo test mode, and persistent settings management.

This guide is current for BadgeBot version 1.5

Expand All @@ -16,10 +16,9 @@ If your HexDrive software (stored on the EEPROM on the hexpansion) is not the la
- 1 Motor and 2 Servos
- Unknown

The board can drive 2 brushed DC motors, 4 RC servos, 1 DC motor and 2 servos.
Once you have selected the desired 'flavour' - please confirm by pressing the "C" (confirm) button.
There must be a HexDrive board plugged in and running the latest software to use the BadgeBot app. If this is not the case then you will see a warning that you need a HexDrive with a reference to this repo.

There must be a HexDrive board plugged in and running the latest software to use the BadgeBot app. If this is not the case then you will see a warning that you need a HexDrive with a reference to this repo.

### Main Menu ###

Expand Down Expand Up @@ -71,9 +70,9 @@ When running from badge power the current available is limited - the best way to

The maximum allowed servo range is VERY WIDE - most Servos will not be able to cope with this, so you probably want to reduce the ```servo_range``` setting to suit your servos.

Each Servo or Motor driver requires a PWM signals to control it, so a single HexDrive takes up four PWM resources on the ESP32. As there are 8 such resources, the 'flavour' of your HexDrives will determine how many you can run simultaneously as long as you don't have any other hexpansions or applications using PWM resources. Two '4 Servo' or 'Unknown' flavour HexDrives will use up all the available PWM channels, whereas you can run up to 4 HexDrives in '2 Motor' flavour. (While each motor driver does actually require two PWM signals we have been able to reduce this to one by swapping it between the active signal when the motor direction changes.)
Each Servo or Motor driver requires a PWM signal to control it, so a single HexDrive can take upto four PWM resources on the ESP32. As there are 8 such resources, the 'flavour' of your HexDrives will determine how many you can run simultaneously as long as you don't have any other hexpansions or applications using PWM resources. Two '4 Servo' flavour HexDrives will use up all the available PWM channels, whereas you can run up to 4 HexDrives in '2 Motor' flavour. (While each motor driver does actually require two PWM signals we have been able to reduce this to one by swapping it between the active signal when the motor direction changes.)

If you unplug a HexDrive the PWM resources will be released immediately so you can move them around the badge easily.
If you unplug a HexDrive the PWM resources will be released immediately so you can move them around the badge easily.


### Install guide
Expand All @@ -85,6 +84,7 @@ This repo contains lots of files that you don't need on your badge to use a HexD
+ metadata.json
+ app.py or app.mpy
+ EEPROM/hexdrive.mpy
+ EEPROM/hexdrive2.mpy
+ utils.mpy
+ hexpansion_mgr.mpy
+ motor_controller.mpy
Expand All @@ -100,18 +100,15 @@ This repo contains lots of files that you don't need on your badge to use a HexD
+ sensors/__init__.mpy
+ sensors/sensor_base.mpy
+ sensors/vl53l0x.mpy
+ sensors/vl6180x.mpy
+ sensors/tcs3472.mpy
+ sensors/tcs3430.mpy
+ sensors/opt4048.mpy
+ sensors/opt4060.mpy


### Hexpansion Recovery ###

If you have issues with a HexDrive, or for that matter any hexpansion fitted with an EEPROM, e.g. a software incompatibility with a particular badge software version, you can reset the EEPROM back to blank as follows:
1) Plug in the hexpansion to Slot 1 (will work with any slot but you have to change the "1" below to the slot number.
2) Connect your favourite Terminal program to the COM port presented by the Badge over USB.
3) Press "Ctrl" & "C" simultaneously. i.e. "Ctrl-C"
3) Press "Ctrl" & "C" simultaneously. i.e. "Ctrl-C"
4) You should now be presented with a prompt ">>>" which is called the python REPL. At this type in the following lines (the HexDrive EEPROM is 8kbytes so requires 16 bit addressing, hence the ```addrsize=16``` other hexpansions may use smaller EEPROMS where this is not required):
```
from machine import I2C
Expand Down Expand Up @@ -214,6 +211,38 @@ PYTHONPATH=/path/to/badge-2024-software ../.venv-wsl310/bin/python -m pytest tes
### Best practise
Run `isort` on in-app python files. Check `pylint` for linting errors.

### Minification

Hexpansion apps stored on EEPROM are minified before being compiled to `.mpy` to reduce their on-badge footprint. The following files are minified:

| Source | Artifact |
|--------|----------|
| `vendor/HexDrive2/hexdrive2.py` | `EEPROM/hexdrive2.mpy` |
| `EEPROM/hexdrive.py` | `EEPROM/hexdrive.mpy` |

The pipeline uses `dev/minify.py` which:
1. Renames internal `self.*` attributes to short names via an AST transform (source stays readable)
2. Strips docstrings with `python-minifier`
3. Compiles with `mpy-cross -O2`

Typical savings are ~5% compared with compiling from source directly.

The minifier is invoked **automatically** by `dev/download_to_device.py` for any `ModuleSpec` that has `minify=True`. You do not need to run it manually during normal development.

To run it standalone and see a before/after size comparison for all minified modules:
```
python dev/minify.py
```

Or to minify a single file (as `download_to_device.py` does):
```
python dev/minify.py --source EEPROM/hexdrive.py --artifact EEPROM/hexdrive.mpy
```

`python-minifier` is listed in `dev/dev_requirements.txt` and is installed as part of the standard dev-environment setup.

Intermediate build artefacts (`*.min.py`, `*.renamed.py`) are listed in `.gitignore` and should not be committed.

### Regenerating QR Code
QR generation is a development-time task and is intentionally kept out of normal
runtime loading for the app.
Expand Down
Loading
Loading