fix qr decoding, spool edit dialog, and opus 5 token budget

This commit is contained in:
Ian Gulliver
2026-07-25 09:15:32 -07:00
parent 700b53d50c
commit 82b652d7e4
3 changed files with 107 additions and 22 deletions
+10 -5
View File
@@ -219,8 +219,8 @@ func processImg(img image.Image, name string, auth claude.Auth, dryRun bool) res
r.Error = fmt.Sprintf("scale is set to imperial units (%s); switch it to grams", reading.Unit)
return r
}
if reading.Weight < 0 {
r.Error = fmt.Sprintf("scale read a negative weight (%g g); refusing to update", reading.Weight)
if reading.Weight <= 0 {
r.Error = fmt.Sprintf("scale read a non-positive weight (%g g); refusing to update", reading.Weight)
return r
}
r.Unit = reading.Unit
@@ -234,8 +234,8 @@ func processImg(img image.Image, name string, auth claude.Auth, dryRun bool) res
if info != nil {
r.NewWeight.Spool = ptr(info.EmptySpoolGrams)
r.NewWeight.Filament = ptr(reading.Weight - info.EmptySpoolGrams)
if reading.Weight-info.EmptySpoolGrams < 0 {
r.Error = fmt.Sprintf("measured total %g g is below the empty-spool weight %g g (negative filament); refusing to update", reading.Weight, info.EmptySpoolGrams)
if reading.Weight-info.EmptySpoolGrams <= 0 {
r.Error = fmt.Sprintf("measured total %g g leaves no filament above the empty-spool weight %g g; refusing to update", reading.Weight, info.EmptySpoolGrams)
return r
}
}
@@ -291,7 +291,12 @@ func spoolID(url string) string {
}
func decodeQR(img image.Image) (string, error) {
bmp, err := gozxing.NewBinaryBitmapFromImage(img)
// gozxing's NewBinaryBitmapFromImage uses a HybridBinarizer, whose adaptive
// per-block thresholding turns the paper texture of a full-resolution photo
// into noise and loses the code. The global-histogram binarizer thresholds
// the whole frame at once and reads these photos fine.
src := gozxing.NewLuminanceSourceFromImage(img)
bmp, err := gozxing.NewBinaryBitmap(gozxing.NewGlobalHistgramBinarizer(src))
if err != nil {
return "", err
}