Skip to content

[ON-HOLD][Feature] V3 Board Calibration GUI#186

Draft
connorgallopo wants to merge 28 commits intomainfrom
feature/v3-calibration-webui
Draft

[ON-HOLD][Feature] V3 Board Calibration GUI#186
connorgallopo wants to merge 28 commits intomainfrom
feature/v3-calibration-webui

Conversation

@connorgallopo
Copy link
Copy Markdown
Collaborator

@connorgallopo connorgallopo commented Mar 21, 2026

Description

This PR take the foundations from #181 and updates them to be merge ready.

image image image image

What does this PR do?

Refactors #181 to remove script anti-pattern, moving everything into the gui for an intuitive user experience.

Why is this change needed?

See #181. This change is required on top of 181 as we have removed manual scripts, so using them again is an anti-pattern and a step backwards.

Changes Made

  • Refactored original script into a python class
  • Added Tests
  • Added Controller / API layer
  • Added gui for functionality on the existing calibration page

Testing Performed

  • Full gui testing, and the written pytests.

Test Environment

Macbook Dev Env

Hardware Compatibility

  • Tested on Pi 5
  • Tested on Pi 4
  • Tested with single Pi setup
  • Tested with dual Pi setup

Documentation

  • No documentation needed
  • Documentation updated in this PR
  • Documentation PR to follow
  • Updated relevant sections:
    • README
    • Hardware guide
    • Software guide
    • Troubleshooting guide

AI (Vibe-Coded) Content Description

  • Tests for original script were generated, then rewritten to test against refactored version to ensure same functionality.

Checklist

Code Quality

  • Code follows existing patterns and conventions
  • No unnecessary comments added
  • Error handling implemented appropriately

Build & Test

  • Successfully builds with ./packaging/build.sh build
  • All existing tests pass
  • New tests added for new functionality
  • Tested on actual Raspberry Pi hardware (not just CI)

Submission Requirements

  • Commits squashed if needed (git rebase -i HEAD~n)
  • CLA signed
  • PR title follows format: [PR TYPE] Brief description
  • Branch is up-to-date with main

Additional Context


@peteattayek

@peteattayek
Copy link
Copy Markdown

The GUI images look great! This was a much more substantial PR than I was expecting, nice work!

I'll run this with my V3 board and LED and review the functional algo soon

try:
try:
param = os.sched_param(os.sched_get_priority_max(os.SCHED_FIFO))
os.sched_setscheduler(0, os.SCHED_FIFO, param)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This requires root privileges to set, is that already implemented?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ill have to verify the perms of the web-server. But im pretty sure its non-root. From what i read in the original that was a nice to have not a need to have. Is that the case?

If so this does handle it gracefully if it doesnt have root.

@peteattayek
Copy link
Copy Markdown

peteattayek commented Mar 22, 2026

@connorgallopo should I rebase/merge this (locally) with feature/build-cleanup branch before testing? I'm planning on doing a completely fresh build to test the dependencies

@connorgallopo
Copy link
Copy Markdown
Collaborator Author

@connorgallopo should I rebase/merge this (locally) with feature/build-cleanup branch before testing? I'm planning on doing a completely fresh build to test the dependencies

if you use the github cli you can just check out the PR - which in my opinion is the best/easiest way. You just will have to have a remote set for this upstream

@connorgallopo connorgallopo force-pushed the feature/v3-calibration-webui branch from 92272ed to c042fb0 Compare March 22, 2026 17:46
@peteattayek
Copy link
Copy Markdown

This did not work.
build_log.txt

I did a fresh install of 64 bit trixie, then ran:
sudo apt update
sudp apt -y full-upgrade

I did a fresh build of PiTrac off of this branch. The build log is attached.

Smaller issue first: This also did not setup /boot/firmware/config.txt when the cameras were not attached. I intended this to setup all non-camera parameters (like force_turbo=1, dtoverlay=spi1-cs2, etc).

Bigger issue: It seems like there is still an lgpio issue. In the build log I see:
The following packages have unmet dependencies: python3-lgpio : Depends: liblgpio1 (= 0.2.2-1~rpt1+trixie) but 0.2.2-1~trixie1 is to be installed [WARN] Could not install python3-lgpio
This is the same issue I ran into before. I can get calibration to work if I run:
sudo apt install --allow-downgrades liblgpio1=0.2.2-1~rpt1+trixie python3-lgpio python3-rpi-lgpio python3-gpiozero

@connorgallopo
Copy link
Copy Markdown
Collaborator Author

connorgallopo commented Mar 23, 2026

This did not work. build_log.txt

I did a fresh install of 64 bit trixie, then ran: sudo apt update sudp apt -y full-upgrade

I did a fresh build of PiTrac off of this branch. The build log is attached.

Smaller issue first: This also did not setup /boot/firmware/config.txt when the cameras were not attached. I intended this to setup all non-camera parameters (like force_turbo=1, dtoverlay=spi1-cs2, etc).

Bigger issue: It seems like there is still an lgpio issue. In the build log I see: The following packages have unmet dependencies: python3-lgpio : Depends: liblgpio1 (= 0.2.2-1~rpt1+trixie) but 0.2.2-1~trixie1 is to be installed [WARN] Could not install python3-lgpio This is the same issue I ran into before. I can get calibration to work if I run: sudo apt install --allow-downgrades liblgpio1=0.2.2-1~rpt1+trixie python3-lgpio python3-rpi-lgpio python3-gpiozero

Why did you do full upgrade? That is destructive to the default packages that this was tested against.

@peteattayek
Copy link
Copy Markdown

This did not work. build_log.txt
I did a fresh install of 64 bit trixie, then ran: sudo apt update sudp apt -y full-upgrade
I did a fresh build of PiTrac off of this branch. The build log is attached.
Smaller issue first: This also did not setup /boot/firmware/config.txt when the cameras were not attached. I intended this to setup all non-camera parameters (like force_turbo=1, dtoverlay=spi1-cs2, etc).
Bigger issue: It seems like there is still an lgpio issue. In the build log I see: The following packages have unmet dependencies: python3-lgpio : Depends: liblgpio1 (= 0.2.2-1~rpt1+trixie) but 0.2.2-1~trixie1 is to be installed [WARN] Could not install python3-lgpio This is the same issue I ran into before. I can get calibration to work if I run: sudo apt install --allow-downgrades liblgpio1=0.2.2-1~rpt1+trixie python3-lgpio python3-rpi-lgpio python3-gpiozero

Why did you do full upgrade? That is destructive to the default packages that this was tested against.

I did it to upgrade rpicam and libcamera. It should not have affected lgpio, but if you want me to re-do it, I can.

@connorgallopo
Copy link
Copy Markdown
Collaborator Author

This did not work. build_log.txt
I did a fresh install of 64 bit trixie, then ran: sudo apt update sudp apt -y full-upgrade
I did a fresh build of PiTrac off of this branch. The build log is attached.
Smaller issue first: This also did not setup /boot/firmware/config.txt when the cameras were not attached. I intended this to setup all non-camera parameters (like force_turbo=1, dtoverlay=spi1-cs2, etc).
Bigger issue: It seems like there is still an lgpio issue. In the build log I see: The following packages have unmet dependencies: python3-lgpio : Depends: liblgpio1 (= 0.2.2-1~rpt1+trixie) but 0.2.2-1~trixie1 is to be installed [WARN] Could not install python3-lgpio This is the same issue I ran into before. I can get calibration to work if I run: sudo apt install --allow-downgrades liblgpio1=0.2.2-1~rpt1+trixie python3-lgpio python3-rpi-lgpio python3-gpiozero

Why did you do full upgrade? That is destructive to the default packages that this was tested against.

I did it to upgrade rpicam and libcamera. It should not have affected lgpio, but if you want me to re-do it, I can.

I would retry - and follow the install docs. The install script should handle all the versioning.

@peteattayek
Copy link
Copy Markdown

I have retried following the instructions on the wiki by the letter, and I have the exact same issues

@connorgallopo
Copy link
Copy Markdown
Collaborator Author

I have retried following the instructions on the wiki by the letter, and I have the exact same issues

Ahh this is because James never committed his changes from working on my branch. let me see.

@connorgallopo
Copy link
Copy Markdown
Collaborator Author

@peteattayek put his changes in.

@peteattayek
Copy link
Copy Markdown

peteattayek commented Mar 23, 2026

I ran sudo ./build.sh dev force this time instead of re-imaging the sd card with a fresh piOS.

I have the exact same issues. config.txt was not setup and the calibration fails because of lgpio issues.

When I run sudo ./configure-cameras.sh I get:
pitrac@pitrac:~/PiTrac/packaging/scripts $ sudo ./configure-cameras.sh [INFO] PiTrac Camera Configuration [INFO] ============================ [INFO] Detecting connected cameras... [WARN] Could not run camera detection - skipping camera configuration [INFO] This may be normal on non-Pi systems or if cameras are not connected

so this is hitting the else condition immediately of if camera_json=$(sudo python3 /usr/lib/pitrac/web-server/camera_detector.py --json 2>/dev/null); then

if I look at the pitrac-web logs when I try to calibrate the LED, I get:
Mar 23 14:38:47 pitrac pitrac-web[6622]: /usr/local/lib/python3.13/dist-packages/gpiozero/devices.py:300: PinFactoryFallback: Falling back from lgpio: No module named 'lgpio' Mar 23 14:38:47 pitrac pitrac-web[6622]: warnings.warn( Mar 23 14:38:47 pitrac pitrac-web[6622]: /usr/local/lib/python3.13/dist-packages/gpiozero/devices.py:300: PinFactoryFallback: Falling back from rpigpio: No module named 'RPi' Mar 23 14:38:47 pitrac pitrac-web[6622]: warnings.warn( Mar 23 14:38:47 pitrac pitrac-web[6622]: /usr/local/lib/python3.13/dist-packages/gpiozero/devices.py:300: PinFactoryFallback: Falling back from pigpio: No module named 'pigpio' Mar 23 14:38:47 pitrac pitrac-web[6622]: warnings.warn( Mar 23 14:38:47 pitrac pitrac-web[6622]: /usr/local/lib/python3.13/dist-packages/gpiozero/devices.py:300: PinFactoryFallback: Falling back from native: unable to open /dev/gpiomem or /dev/mem; upgrade your kernel or run as root Mar 23 14:38:47 pitrac pitrac-web[6622]: warnings.warn( Mar 23 14:38:47 pitrac pitrac-web[6622]: 2026-03-23 14:38:47,515 - strobe_calibration_manager - ERROR - Calibration exception: Unable to load any default pin factory!

I can run sudo apt install --allow-downgrades liblgpio1=0.2.2-1~rpt1+trixie python3-lgpio python3-rpi-lgpio python3-gpiozero to fix the issue

@connorgallopo
Copy link
Copy Markdown
Collaborator Author

If you did not do it fresh or properly clean up dependencies, you would still have the previous deps.

I ran sudo ./build.sh dev force this time instead of re-imaging the sd card with a fresh piOS.

I have the exact same issues. config.txt was not setup and the calibration fails because of lgpio issues.

When I run sudo ./configure-cameras.sh I get: pitrac@pitrac:~/PiTrac/packaging/scripts $ sudo ./configure-cameras.sh [INFO] PiTrac Camera Configuration [INFO] ============================ [INFO] Detecting connected cameras... [WARN] Could not run camera detection - skipping camera configuration [INFO] This may be normal on non-Pi systems or if cameras are not connected

so this is hitting the else condition immediately of if camera_json=$(sudo python3 /usr/lib/pitrac/web-server/camera_detector.py --json 2>/dev/null); then

if I look at the pitrac-web logs when I try to calibrate the LED, I get: Mar 23 14:38:47 pitrac pitrac-web[6622]: /usr/local/lib/python3.13/dist-packages/gpiozero/devices.py:300: PinFactoryFallback: Falling back from lgpio: No module named 'lgpio' Mar 23 14:38:47 pitrac pitrac-web[6622]: warnings.warn( Mar 23 14:38:47 pitrac pitrac-web[6622]: /usr/local/lib/python3.13/dist-packages/gpiozero/devices.py:300: PinFactoryFallback: Falling back from rpigpio: No module named 'RPi' Mar 23 14:38:47 pitrac pitrac-web[6622]: warnings.warn( Mar 23 14:38:47 pitrac pitrac-web[6622]: /usr/local/lib/python3.13/dist-packages/gpiozero/devices.py:300: PinFactoryFallback: Falling back from pigpio: No module named 'pigpio' Mar 23 14:38:47 pitrac pitrac-web[6622]: warnings.warn( Mar 23 14:38:47 pitrac pitrac-web[6622]: /usr/local/lib/python3.13/dist-packages/gpiozero/devices.py:300: PinFactoryFallback: Falling back from native: unable to open /dev/gpiomem or /dev/mem; upgrade your kernel or run as root Mar 23 14:38:47 pitrac pitrac-web[6622]: warnings.warn( Mar 23 14:38:47 pitrac pitrac-web[6622]: 2026-03-23 14:38:47,515 - strobe_calibration_manager - ERROR - Calibration exception: Unable to load any default pin factory!

I can run sudo apt install --allow-downgrades liblgpio1=0.2.2-1~rpt1+trixie python3-lgpio python3-rpi-lgpio python3-gpiozero to fix the issue

Yeah that makes sense - as the previous version was still installing the custom lib.

@peteattayek
Copy link
Copy Markdown

I did a fresh Trixie install and still have lgpio issues, see the attached build log
meson-log.txt

@peteattayek
Copy link
Copy Markdown

These changes fix the issue. They were suggested by Claude Code and I don't know what the other ramifications of these changes would be, but hopefully it can point you in the right direction
5f6642a

@connorgallopo
Copy link
Copy Markdown
Collaborator Author

@peteattayek I wiped a pi and installed with 0 build issues. Please provide the full scope of what OS you install, and your install steps.

@jamespilgrim are you able to test this?

@connorgallopo
Copy link
Copy Markdown
Collaborator Author

I am going to say this gets put on ice until we get another set of eyes on it.

@peteattayek
Copy link
Copy Markdown

@peteattayek I wiped a pi and installed with 0 build issues. Please provide the full scope of what OS you install, and your install steps.

@jamespilgrim are you able to test this?

I am using the Raspberry Pi Imager v2.06 to image a 64GB SD card with Raspberry Pi OS (64 bit). The description on the imager says it is a port of Debian Trixie and was released 2025-12-04.

Once I put the SD card into a Raspberry Pi 5, I follow the PiTrac wiki and run:
`sudo apt update
sudo apt -y upgrade
sudo reboot now

git clone https://github.com/PiTracLM/PiTrac.git
cd PiTrac
git checkout feature/v3-calibration-webui
cd packaging
sudo ./build.sh dev`

James is traveling this week. I'll see if anyone else can test it.

@connorgallopo is this what you are doing to build with 0 issues? What are you doing?

@connorgallopo
Copy link
Copy Markdown
Collaborator Author

James is traveling this week. I'll see if anyone else can test it.

There is no rush - Either way it will require testing / approval from a reviewer.

If that is all you are doing why is the working directory changed?

Yes those are the steps.

@peteattayek
Copy link
Copy Markdown

peteattayek commented Mar 24, 2026

I am not sure the working directory change is necessary, but Claude Code said it was to ensure there was write access. And it did fix the errors when I tried to run calibration from the web ui

I don't understand how you can even get PiTrac to build without getting an error about finding the lgpio package without changing line 73 of meson.build since there is no lgpio.pc on the image?? (5f6642a#diff-7852c36152187ba2962691d983613a42aa860af0941298706736e5f1bd805920L73)

Determining dependency 'lgpio' with pkg-config executable '/usr/bin/pkg-config'
env[PKG_CONFIG_PATH]: /usr/lib/aarch64-linux-gnu/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig
env[PKG_CONFIG]: /usr/bin/pkg-config
-----------
Called: `/usr/bin/pkg-config --modversion lgpio` -> 1
stderr:
Package lgpio was not found in the pkg-config search path.
Perhaps you should add the directory containing `lgpio.pc'
to the PKG_CONFIG_PATH environment variable
Package 'lgpio', required by 'virtual:world', not found
-----------
CMake binary for host machine is not cached
CMake binary missing from cross or native file, or env var undefined.
Trying a default CMake fallback at cmake
Did not find CMake 'cmake'
Found CMake: NO
Dependency lookup for lgpio with method 'cmake' failed: CMake binary for machine host machine not found. Giving up.
Run-time dependency lgpio found: NO (tried pkgconfig)

meson.build:73:12: ERROR: Dependency "lgpio" not found, tried pkgconfig

@connorgallopo
Copy link
Copy Markdown
Collaborator Author

It is handled elsewhere.

Claude fueling this debugging seems like it is causing more trouble than anything. And you waited til now to tell me it was having you change paths etc.

So I am going to just run through again myself, and put this on hold for now.

I appreciate your testing efforts

@peteattayek
Copy link
Copy Markdown

peteattayek commented Mar 24, 2026

It is handled elsewhere.

It wasn't handled when I built PiTrac

Claude fueling this debugging seems like it is causing more trouble than anything. And you waited til now to tell me it was having you change paths etc.

I told you the first time I changed something with Claude a few comments ago from this morning (#186 (comment)). It is the first thing that has allowed me to both build successfully and run calibration.

@connorgallopo connorgallopo changed the title [Feature] V3 Board Calibration GUI [ON-HOLD][Feature] V3 Board Calibration GUI Mar 24, 2026
@peteattayek
Copy link
Copy Markdown

The latest commit let's me build successfully! There is still an issue with gpiozero needing write access to the working directory. I made a PR to this branch with a suggested change to just use direct liblgpio calls. I have tested this with my hardware and it works.

I did not update test_strobe_calibration_manager.py yet though

@peteattayek
Copy link
Copy Markdown

peteattayek commented Mar 26, 2026

Screenshot 2026-03-26 054607 With the latest commit I can now successfully:
  1. Build from source on an RPi5 with a fresh PiOS (Trixie 64bit) install
  2. The config.txt file is modified with non-camera parameters even if cameras are not present
  3. Run calibration successfully!

Remaining major issues:

  1. the "Read Diagnostics" button is dangerous and should only be an "advanced" feature. If the LED is pulsed with the LDO voltage too high (we don't have a good number for this) it can blow out the LED and/or MOSFETS.

Remaining minor issues/suggestions:

  1. After calibration, the LDO voltage is not reported correctly
  2. I suggest adding part of the progress bar to the _find_dac_start function else it looks like calibration hangs at the beginning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants