Skip to content

Conversation

@flyingeek
Copy link

@flyingeek flyingeek commented Feb 5, 2026

Hello Andreas,

I suggest you include the following to improve 3stated:

  • adds an offset so that we can see the focus (especially useful when you use the scroll wheel)
  • adds a contextual menu to reset the source (as in the frsky Value widget)
  • adds dynamic thresholds (precision, minimum, maximum) on source change

As I'm coding on a Mac, I also edited the gitignore file.

Regards,
Eric Delord

Zusammenfassung von Sourcery

Fügt dem 3‑Zustands-Widget einen visuellen Fokusabstand, einen Kontextmenüeintrag zum Zurücksetzen der Quelle und dynamische Schwellwertbereiche hinzu, zusammen mit Aktualisierungen der Lokalisierung und der Repository-Ignorierliste.

Neue Funktionen:

  • Hinzufügen eines Kontextmenüeintrags am Widget, um kompatible Quellen direkt aus dem Widget zurückzusetzen.
  • Dynamische Konfiguration der Schwellwerte basierend auf dem Minimum und Maximum der ausgewählten Quelle, sofern verfügbar.

Verbesserungen:

  • Versetzen der Hintergrund-, Titel-, Fußzeilen- und Haupttextdarstellung, um einen inneren transparenten Rand zu erzeugen, der den Widget-Fokus anzeigt.
  • Aktualisierung der lokalisierten Zeichenketten in allen unterstützten Sprachen, um die neue Beschriftung für den Menüeintrag zum Zurücksetzen der Quelle einzuschließen.

Build:

  • Anpassen der .gitignore-Einträge für das Repository.
Original summary in English

Summary by Sourcery

Add visual focus padding, a source-reset context menu entry, and dynamic threshold ranges to the 3-state widget, along with localization and repo ignore updates.

New Features:

  • Add a widget context menu entry to reset compatible sources directly from the widget.
  • Configure threshold values dynamically based on the minimum and maximum of the selected source when available.

Enhancements:

  • Offset the background, title, footer, and main text drawing to create an inner transparent border indicating widget focus.
  • Update localized strings in all supported languages to include the new source reset menu label.

Build:

  • Adjust .gitignore entries for the repository.

Neue Funktionen:

  • Hinzufügen eines Eintrags im Kontextmenü, um kompatible Widget-Quellen direkt über das Widget zurückzusetzen.
  • Einführung dynamischer Schwellwert-Konfigurationsbereiche basierend auf den Minimal- und Maximalwerten der ausgewählten Quelle.

Verbesserungen:

  • Versetzen des Widget-Hintergrunds sowie der Titel-, Fußzeilen- und Textzeichnung, um den Fokus visuell über einen inneren Transparenzrand anzuzeigen.
  • Aktualisierung lokalisierter Zeichenketten, um die neue Menübezeichnung zum Zurücksetzen der Quelle in allen bestehenden Sprachen zu unterstützen.

Build:

  • Anpassung der .gitignore-Konfiguration (Details sind im Diff nicht sichtbar).
Original summary in English

Zusammenfassung von Sourcery

Fügt dem 3‑Zustands-Widget einen visuellen Fokusabstand, einen Kontextmenüeintrag zum Zurücksetzen der Quelle und dynamische Schwellwertbereiche hinzu, zusammen mit Aktualisierungen der Lokalisierung und der Repository-Ignorierliste.

Neue Funktionen:

  • Hinzufügen eines Kontextmenüeintrags am Widget, um kompatible Quellen direkt aus dem Widget zurückzusetzen.
  • Dynamische Konfiguration der Schwellwerte basierend auf dem Minimum und Maximum der ausgewählten Quelle, sofern verfügbar.

Verbesserungen:

  • Versetzen der Hintergrund-, Titel-, Fußzeilen- und Haupttextdarstellung, um einen inneren transparenten Rand zu erzeugen, der den Widget-Fokus anzeigt.
  • Aktualisierung der lokalisierten Zeichenketten in allen unterstützten Sprachen, um die neue Beschriftung für den Menüeintrag zum Zurücksetzen der Quelle einzuschließen.

Build:

  • Anpassen der .gitignore-Einträge für das Repository.
Original summary in English

Summary by Sourcery

Add visual focus padding, a source-reset context menu entry, and dynamic threshold ranges to the 3-state widget, along with localization and repo ignore updates.

New Features:

  • Add a widget context menu entry to reset compatible sources directly from the widget.
  • Configure threshold values dynamically based on the minimum and maximum of the selected source when available.

Enhancements:

  • Offset the background, title, footer, and main text drawing to create an inner transparent border indicating widget focus.
  • Update localized strings in all supported languages to include the new source reset menu label.

Build:

  • Adjust .gitignore entries for the repository.

@sourcery-ai
Copy link

sourcery-ai bot commented Feb 5, 2026

🧙 Sourcery hat die Überprüfung deines Pull Requests abgeschlossen!


Tipps und Befehle

Interaktion mit Sourcery

  • Neue Überprüfung auslösen: Kommentiere @sourcery-ai review im Pull Request.
  • Diskussionen fortsetzen: Antworte direkt auf Sourcerys Review-Kommentare.
  • GitHub-Issue aus einem Review-Kommentar erstellen: Bitte Sourcery, aus
    einem Review-Kommentar ein Issue zu erstellen, indem du darauf antwortest. Du kannst auch auf
    einen Review-Kommentar mit @sourcery-ai issue antworten, um daraus ein Issue zu erstellen.
  • Pull-Request-Titel generieren: Schreibe @sourcery-ai irgendwo in den
    Pull-Request-Titel, um jederzeit einen Titel zu generieren. Du kannst auch
    @sourcery-ai title im Pull Request kommentieren, um den Titel jederzeit (neu) zu generieren.
  • Pull-Request-Zusammenfassung generieren: Schreibe @sourcery-ai summary irgendwo in
    den Pull-Request-Text, um jederzeit genau an dieser Stelle eine PR-Zusammenfassung zu generieren.
    Du kannst auch @sourcery-ai summary im Pull Request kommentieren, um die Zusammenfassung
    jederzeit (neu) zu generieren.
  • Review-Leitfaden generieren: Kommentiere @sourcery-ai guide im Pull Request,
    um den Review-Leitfaden jederzeit (neu) zu generieren.
  • Alle Sourcery-Kommentare als erledigt markieren: Kommentiere @sourcery-ai resolve
    im Pull Request, um alle Sourcery-Kommentare als erledigt zu markieren. Nützlich, wenn du alle
    Kommentare bereits bearbeitet hast und sie nicht mehr sehen möchtest.
  • Alle Sourcery-Reviews verwerfen: Kommentiere @sourcery-ai dismiss im Pull
    Request, um alle bestehenden Sourcery-Reviews zu verwerfen. Besonders nützlich, wenn du mit
    einer neuen Überprüfung ganz von vorne beginnen möchtest – vergiss nicht, @sourcery-ai review
    zu kommentieren, um eine neue Überprüfung zu starten!

Dein Erlebnis anpassen

Rufe dein Dashboard auf, um:

  • Review-Funktionen wie die von Sourcery generierte Pull-Request-Zusammenfassung,
    den Review-Leitfaden und andere zu aktivieren oder zu deaktivieren.
  • Die Reviewsprache zu ändern.
  • Eigene Review-Anweisungen hinzuzufügen, zu entfernen oder zu bearbeiten.
  • Weitere Review-Einstellungen anzupassen.

Hilfe erhalten

Original review guide in English

🧙 Sourcery has finished reviewing your pull request!


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey – ich habe zwei Probleme gefunden und ein paar Hinweise auf höherer Ebene hinterlassen:

  • In configure() ist im Zweig für die Standard-Schwellenwerte die Reihenfolge von thresholdUp/thresholdDown im Vergleich sowohl zum vorherigen Code als auch zum dynamischen Range-Zweig vertauscht; halte die Feldreihenfolge nach Möglichkeit konsistent, um Verwirrung oder unerwartete Probleme bei der Konfigurationspersistenz zu vermeiden.
  • Das neue Footer-Rechteck in w_paint.footer übergibt widget.height - (2 * wPaint.TRANSPARENCY_Y_OFFSET) als Höhen-Argument, was ein absoluter unterer Koordinatenwert und nicht die Footer-Höhe ist; das zeichnet wahrscheinlich mehr als beabsichtigt und sollte stattdessen vermutlich footerHeight verwenden.
  • In der neuen Funktion menu() definierst du CATEGORY_LUA lokal, verlässt dich aber bei CATEGORY_TIMER und CATEGORY_TELEMETRY_SENSOR auf globale Variablen; definiere oder importiere alle drei möglichst einheitlich, um versteckte Abhängigkeiten von externen Globals zu vermeiden.
Prompt für KI-Agenten
Bitte bearbeite die Kommentare aus diesem Code-Review:

## Gesamtkommentare
- In `configure()` ist im Zweig für die Standard-Schwellenwerte die Reihenfolge von `thresholdUp`/`thresholdDown` im Vergleich sowohl zum vorherigen Code als auch zum dynamischen Range-Zweig vertauscht; halte die Feldreihenfolge nach Möglichkeit konsistent, um Verwirrung oder unerwartete Probleme bei der Konfigurationspersistenz zu vermeiden.
- Das neue Footer-Rechteck in `w_paint.footer` übergibt `widget.height - (2 * wPaint.TRANSPARENCY_Y_OFFSET)` als Höhen-Argument, was ein absoluter unterer Koordinatenwert und nicht die Footer-Höhe ist; das zeichnet wahrscheinlich mehr als beabsichtigt und sollte stattdessen vermutlich `footerHeight` verwenden.
- In der neuen Funktion `menu()` definierst du `CATEGORY_LUA` lokal, verlässt dich aber bei `CATEGORY_TIMER` und `CATEGORY_TELEMETRY_SENSOR` auf globale Variablen; definiere oder importiere alle drei möglichst einheitlich, um versteckte Abhängigkeiten von externen Globals zu vermeiden.

## Einzelne Kommentare

### Kommentar 1
<location> `main.lua:362-372` </location>
<code_context>
     elseif horizontalAlign == TEXT_RIGHT then
-        lcd.drawText(widget.width - wPaint.FREE_RIGHT, textPosY, text, TEXT_RIGHT)
+        lcd.drawText(widget.width - wPaint.FREE_RIGHT - wPaint.TRANSPARENCY_X_OFFSET, textPosY, text, TEXT_RIGHT)
     else
         lcd.drawText((widget.width / 2), textPosY, text, TEXT_CENTERED)
     end
</code_context>

<issue_to_address>
**suggestion (bug_risk):** Die Reihenfolge der Felder thresholdUp/thresholdDown ist zwischen den beiden Zweigen vertauscht.

Wenn sich irgendwelche UI- oder Konfigurations-Tools auf eine stabile Feldreihenfolge verlassen, könnte diese Abweichung zu inkonsistenten Layouts zwischen den beiden Fällen führen. Um subtile UI-Probleme zu vermeiden, gleiche die Einfügereihenfolge in beiden Zweigen an.

```suggestion
    -- thresholds
    if wHelper.existSource(widget.source) and widget.source.maximum and widget.source.minimum then
        -- Not perfect since to have this code working you will need
        -- to configure the widget to set the source first
        -- and then to configure again to set the remaining parameters
        wConfig.addNumberField("thresholdUp", widget.source:minimum(), widget.source:maximum(), THRESHOLD_PRECISION)
        wConfig.addNumberField("thresholdDown", widget.source:minimum(), widget.source:maximum(), THRESHOLD_PRECISION)
    else
        wConfig.addNumberField("thresholdUp", -THRESHOLD_RANGE, THRESHOLD_RANGE, THRESHOLD_PRECISION)
        wConfig.addNumberField("thresholdDown", -THRESHOLD_RANGE, THRESHOLD_RANGE, THRESHOLD_PRECISION)
    end
```
</issue_to_address>

### Kommentar 2
<location> `lib/w_paint.lua:147` </location>
<code_context>
         footerHeight = wPaint.FREE_ABOVE + footerHeight
         lcd.color(footerBGColor)
-        lcd.drawFilledRectangle(0, widget.height - footerHeight, widget.width, widget.height)
+        lcd.drawFilledRectangle(wPaint.TRANSPARENCY_X_OFFSET, widget.height - footerHeight - (2 * wPaint.TRANSPARENCY_Y_OFFSET), widget.width - (2 * wPaint.TRANSPARENCY_X_OFFSET), widget.height - (2 * wPaint.TRANSPARENCY_Y_OFFSET))
     end
     --- draw footer text
</code_context>

<issue_to_address>
**issue (bug_risk):** Das Footer-Rechteck scheint untere Koordinatenwerte zu verwenden, wo Breite/Höhe erwartet werden.

Andere Aufrufe von `lcd.drawFilledRectangle` verwenden die 3. und 4. Parameter als Breite/Höhe, aber hier ist das 4. Argument (`widget.height - (2 * wPaint.TRANSPARENCY_Y_OFFSET)`) effektiv eine untere Y-Koordinate. In Kombination mit der Reduzierung des Y-Ursprungs um `2 * wPaint.TRANSPARENCY_Y_OFFSET` verschiebt das den Footer vermutlich nach oben und verkleinert ihn fehlerhaft. Bitte ändere diesen Aufruf so, dass der letzte Parameter die Footer-Höhe ist (ähnlich wie bei den anderen Verwendungen) und nicht eine untere Koordinate, z. B.:

```lua
lcd.drawFilledRectangle(
  wPaint.TRANSPARENCY_X_OFFSET,
  widget.height - footerHeight - wPaint.TRANSPARENCY_Y_OFFSET,
  widget.width - (2 * wPaint.TRANSPARENCY_X_OFFSET),
  footerHeight
)
```
</issue_to_address>

Sourcery ist für Open Source kostenlos – wenn dir unsere Reviews gefallen, teile sie gerne ✨
Hilf mir, nützlicher zu werden! Bitte klicke bei jedem Kommentar auf 👍 oder 👎 – ich nutze das Feedback, um zukünftige Reviews zu verbessern.
Original comment in English

Hey - I've found 2 issues, and left some high level feedback:

  • In configure(), the default thresholds branch reverses the order of thresholdUp/thresholdDown compared to both the previous code and the dynamic-Range branch; consider keeping a consistent field order to avoid confusion or unexpected config persistence issues.
  • The new footer rectangle in w_paint.footer passes widget.height - (2 * wPaint.TRANSPARENCY_Y_OFFSET) as the height argument, which is an absolute bottom coordinate rather than the footer height; this likely overdraws more than intended and should probably use footerHeight instead.
  • In the new menu() function you define CATEGORY_LUA locally but rely on CATEGORY_TIMER and CATEGORY_TELEMETRY_SENSOR as globals; consider defining or importing all three consistently to avoid hidden dependencies on external globals.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `configure()`, the default thresholds branch reverses the order of `thresholdUp`/`thresholdDown` compared to both the previous code and the dynamic-Range branch; consider keeping a consistent field order to avoid confusion or unexpected config persistence issues.
- The new footer rectangle in `w_paint.footer` passes `widget.height - (2 * wPaint.TRANSPARENCY_Y_OFFSET)` as the height argument, which is an absolute bottom coordinate rather than the footer height; this likely overdraws more than intended and should probably use `footerHeight` instead.
- In the new `menu()` function you define `CATEGORY_LUA` locally but rely on `CATEGORY_TIMER` and `CATEGORY_TELEMETRY_SENSOR` as globals; consider defining or importing all three consistently to avoid hidden dependencies on external globals.

## Individual Comments

### Comment 1
<location> `main.lua:362-372` </location>
<code_context>
     elseif horizontalAlign == TEXT_RIGHT then
-        lcd.drawText(widget.width - wPaint.FREE_RIGHT, textPosY, text, TEXT_RIGHT)
+        lcd.drawText(widget.width - wPaint.FREE_RIGHT - wPaint.TRANSPARENCY_X_OFFSET, textPosY, text, TEXT_RIGHT)
     else
         lcd.drawText((widget.width / 2), textPosY, text, TEXT_CENTERED)
     end
</code_context>

<issue_to_address>
**suggestion (bug_risk):** The order of thresholdUp/thresholdDown fields is swapped between the two branches.

If any UI or config tooling relies on a stable field order, this discrepancy could cause inconsistent layouts between the two cases. To avoid subtle UI issues, align the insertion order in both branches.

```suggestion
    -- thresholds
    if wHelper.existSource(widget.source) and widget.source.maximum and widget.source.minimum then
        -- Not perfect since to have this code working you will need
        -- to configure the widget to set the source first
        -- and then to configure again to set the remaining parameters
        wConfig.addNumberField("thresholdUp", widget.source:minimum(), widget.source:maximum(), THRESHOLD_PRECISION)
        wConfig.addNumberField("thresholdDown", widget.source:minimum(), widget.source:maximum(), THRESHOLD_PRECISION)
    else
        wConfig.addNumberField("thresholdUp", -THRESHOLD_RANGE, THRESHOLD_RANGE, THRESHOLD_PRECISION)
        wConfig.addNumberField("thresholdDown", -THRESHOLD_RANGE, THRESHOLD_RANGE, THRESHOLD_PRECISION)
    end
```
</issue_to_address>

### Comment 2
<location> `lib/w_paint.lua:147` </location>
<code_context>
         footerHeight = wPaint.FREE_ABOVE + footerHeight
         lcd.color(footerBGColor)
-        lcd.drawFilledRectangle(0, widget.height - footerHeight, widget.width, widget.height)
+        lcd.drawFilledRectangle(wPaint.TRANSPARENCY_X_OFFSET, widget.height - footerHeight - (2 * wPaint.TRANSPARENCY_Y_OFFSET), widget.width - (2 * wPaint.TRANSPARENCY_X_OFFSET), widget.height - (2 * wPaint.TRANSPARENCY_Y_OFFSET))
     end
     --- draw footer text
</code_context>

<issue_to_address>
**issue (bug_risk):** Footer rectangle seems to be using bottom coordinate values where width/height are expected.

Other `lcd.drawFilledRectangle` calls use the 3rd/4th parameters as width/height, but here the 4th argument (`widget.height - (2 * wPaint.TRANSPARENCY_Y_OFFSET)`) is effectively a bottom Y coordinate. Combined with reducing the Y origin by `2 * wPaint.TRANSPARENCY_Y_OFFSET`, this likely shifts the footer up and shrinks it incorrectly. Please change this call so the last parameter is the footer height (similar to other usages) rather than a bottom coordinate, e.g.:

```lua
lcd.drawFilledRectangle(
  wPaint.TRANSPARENCY_X_OFFSET,
  widget.height - footerHeight - wPaint.TRANSPARENCY_Y_OFFSET,
  widget.width - (2 * wPaint.TRANSPARENCY_X_OFFSET),
  footerHeight
)
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey – ich habe 2 Probleme gefunden und noch ein paar übergeordnete Hinweise hinterlassen:

  • Die dynamische Threshold‑Bereichsprüfung in configure verwendet widget.source.maximum/minimum als Felder, ruft sie dann aber als Methoden auf. Dadurch ist die Bedingung immer false, falls diese nur als Methoden verfügbar sind. Überlege, stattdessen auf widget.source.maximum ~= nil zu prüfen oder durchgängig die Methoden‑API zu verwenden.
  • Im else‑Zweig der configure‑Funktion ist die Reihenfolge der Zahlenfelder thresholdUp und thresholdDown im Vergleich zum Original (Down dann Up) vertauscht, was unbeabsichtigt die Bindings vertauschen und Nutzer verwirren kann. Richte die Reihenfolge an der bestehenden UI aus.
  • Die menu‑Funktion führt einen hart codierten Kategorienwert CATEGORY_LUA = 29 ein. Wenn möglich, verwende bestehende Kategorie‑Konstanten wieder oder zentralisiere diese Werte, um Magic Numbers zu vermeiden und das Kategorie‑Handling über Widgets hinweg konsistent zu halten.
Prompt für KI‑Agenten
Bitte bearbeite die Kommentare aus diesem Code‑Review:

## Allgemeine Kommentare
- Die dynamische Threshold‑Bereichsprüfung in `configure` verwendet `widget.source.maximum`/`minimum` als Felder, ruft sie dann aber als Methoden auf. Dadurch ist die Bedingung immer false, falls diese nur als Methoden verfügbar sind. Überlege, stattdessen auf `widget.source.maximum ~= nil` zu prüfen oder durchgängig die Methoden‑API zu verwenden.
- Im `else`‑Zweig der `configure`‑Funktion ist die Reihenfolge der Zahlenfelder `thresholdUp` und `thresholdDown` im Vergleich zum Original (Down dann Up) vertauscht, was unbeabsichtigt die Bindings vertauschen und Nutzer verwirren kann. Richte die Reihenfolge an der bestehenden UI aus.
- Die `menu`‑Funktion führt einen hart codierten Kategorienwert `CATEGORY_LUA = 29` ein. Wenn möglich, verwende bestehende Kategorie‑Konstanten wieder oder zentralisiere diese Werte, um Magic Numbers zu vermeiden und das Kategorie‑Handling über Widgets hinweg konsistent zu halten.

## Einzelne Kommentare

### Kommentar 1
<location> `main.lua:363-372` </location>
<code_context>

     -- thresholds
-    wConfig.addNumberField("thresholdDown", -THRESHOLD_RANGE, THRESHOLD_RANGE, THRESHOLD_PRECISION)
-    wConfig.addNumberField("thresholdUp", -THRESHOLD_RANGE, THRESHOLD_RANGE, THRESHOLD_PRECISION)
+    if wHelper.existSource(widget.source) and widget.source.maximum and widget.source.minimum then
+        -- Not perfect since to have this code working you will need
+        -- to configure the widget to set the source first
+        -- and then to configure again to set the remaining parameters
+        wConfig.addNumberField("thresholdDown", widget.source:minimum(), widget.source:maximum(), THRESHOLD_PRECISION)
+        wConfig.addNumberField("thresholdUp", widget.source:minimum(), widget.source:maximum(), THRESHOLD_PRECISION)
+    else
+        wConfig.addNumberField("thresholdUp", -THRESHOLD_RANGE, THRESHOLD_RANGE, THRESHOLD_PRECISION)
+        wConfig.addNumberField("thresholdDown", -THRESHOLD_RANGE, THRESHOLD_RANGE, THRESHOLD_PRECISION)
+    end

</code_context>

<issue_to_address>
**suggestion:** Threshold‑Felder werden je nach Branch unterschiedlich angeordnet, was zu einem inkonsistenten UI‑Layout führen kann.

Im `if`‑Zweig werden die Felder als `thresholdDown` und dann `thresholdUp` hinzugefügt, im `else`‑Zweig jedoch in umgekehrter Reihenfolge. Wenn die Konfig‑UI die Deklarationsreihenfolge berücksichtigt, unterscheidet sich dadurch das Layout je nachdem, ob eine gültige Quelle existiert. Bitte richte die Reihenfolge in beiden Zweigen aneinander aus.

```suggestion
    if wHelper.existSource(widget.source) and widget.source.maximum and widget.source.minimum then
        -- Not perfect since to have this code working you will need
        -- to configure the widget to set the source first
        -- and then to configure again to set the remaining parameters
        wConfig.addNumberField("thresholdDown", widget.source:minimum(), widget.source:maximum(), THRESHOLD_PRECISION)
        wConfig.addNumberField("thresholdUp", widget.source:minimum(), widget.source:maximum(), THRESHOLD_PRECISION)
    else
        wConfig.addNumberField("thresholdDown", -THRESHOLD_RANGE, THRESHOLD_RANGE, THRESHOLD_PRECISION)
        wConfig.addNumberField("thresholdUp", -THRESHOLD_RANGE, THRESHOLD_RANGE, THRESHOLD_PRECISION)
    end
```
</issue_to_address>

### Kommentar 2
<location> `lib/w_paint.lua:147` </location>
<code_context>
         footerHeight = wPaint.FREE_ABOVE + footerHeight
         lcd.color(footerBGColor)
-        lcd.drawFilledRectangle(0, widget.height - footerHeight, widget.width, widget.height)
+        lcd.drawFilledRectangle(wPaint.TRANSPARENCY_X_OFFSET, widget.height - footerHeight - (2 * wPaint.TRANSPARENCY_Y_OFFSET), widget.width - (2 * wPaint.TRANSPARENCY_X_OFFSET), widget.height - (2 * wPaint.TRANSPARENCY_Y_OFFSET))
     end
     --- draw footer text
</code_context>

<issue_to_address>
**issue (bug_risk):** Die Höhe des Footer‑Rechtecks wirkt inkonsistent mit dem vorgesehenen Footer‑Band und mit der Verwendung der Transparenz‑Offsets für Titel und Hintergrund.

Beim Titel und beim Haupt‑Hintergrund entspricht das `height`‑Argument jeweils nur dem zu zeichnenden Bereich (z. B. `widget.height - (2 * TRANSPARENCY_Y_OFFSET)` für den Hintergrund, `titleHeight - TRANSPARENCY_Y_OFFSET` für den Titel). Hier wird `y` des Footers auf `widget.height - footerHeight - 2 * TRANSPARENCY_Y_OFFSET` verschoben, aber `height` ist `widget.height - 2 * TRANSPARENCY_Y_OFFSET`, sodass das Rechteck weit oberhalb des Footer‑Bands reicht. Verwende besser `footerHeight` (oder `footerHeight - TRANSPARENCY_Y_OFFSET`) für die Footer‑Höhe, damit das Rechteck auf den Footer‑Bereich innerhalb der Transparenzbox begrenzt ist.
</issue_to_address>

Sourcery ist für Open Source kostenlos – wenn dir unsere Reviews gefallen, freuen wir uns, wenn du sie teilst ✨
Hilf mir, noch nützlicher zu werden! Bitte klicke bei jedem Kommentar auf 👍 oder 👎 – ich nutze dein Feedback, um zukünftige Reviews zu verbessern.
Original comment in English

Hey - I've found 2 issues, and left some high level feedback:

  • The dynamic threshold range check in configure uses widget.source.maximum/minimum as fields but then calls them as methods, so the condition will always be false if these are only exposed as methods; consider checking via widget.source.maximum ~= nil or directly using the method API consistently.
  • In the configure function’s else branch, the order of thresholdUp and thresholdDown number fields is reversed compared to the original (Down then Up), which may unintentionally swap the bindings and confuse users; align the order with the existing UI.
  • The menu function introduces a hard‑coded category value CATEGORY_LUA = 29; if possible, reuse existing category constants or centralize these values to avoid magic numbers and keep category handling consistent across widgets.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The dynamic threshold range check in `configure` uses `widget.source.maximum`/`minimum` as fields but then calls them as methods, so the condition will always be false if these are only exposed as methods; consider checking via `widget.source.maximum ~= nil` or directly using the method API consistently.
- In the `configure` function’s `else` branch, the order of `thresholdUp` and `thresholdDown` number fields is reversed compared to the original (Down then Up), which may unintentionally swap the bindings and confuse users; align the order with the existing UI.
- The `menu` function introduces a hard‑coded category value `CATEGORY_LUA = 29`; if possible, reuse existing category constants or centralize these values to avoid magic numbers and keep category handling consistent across widgets.

## Individual Comments

### Comment 1
<location> `main.lua:363-372` </location>
<code_context>

     -- thresholds
-    wConfig.addNumberField("thresholdDown", -THRESHOLD_RANGE, THRESHOLD_RANGE, THRESHOLD_PRECISION)
-    wConfig.addNumberField("thresholdUp", -THRESHOLD_RANGE, THRESHOLD_RANGE, THRESHOLD_PRECISION)
+    if wHelper.existSource(widget.source) and widget.source.maximum and widget.source.minimum then
+        -- Not perfect since to have this code working you will need
+        -- to configure the widget to set the source first
+        -- and then to configure again to set the remaining parameters
+        wConfig.addNumberField("thresholdDown", widget.source:minimum(), widget.source:maximum(), THRESHOLD_PRECISION)
+        wConfig.addNumberField("thresholdUp", widget.source:minimum(), widget.source:maximum(), THRESHOLD_PRECISION)
+    else
+        wConfig.addNumberField("thresholdUp", -THRESHOLD_RANGE, THRESHOLD_RANGE, THRESHOLD_PRECISION)
+        wConfig.addNumberField("thresholdDown", -THRESHOLD_RANGE, THRESHOLD_RANGE, THRESHOLD_PRECISION)
+    end

</code_context>

<issue_to_address>
**suggestion:** Threshold fields are added in different order depending on the source branch, which may lead to inconsistent UI layout.

In the `if` branch the fields are added as `thresholdDown` then `thresholdUp`, but in the `else` branch they are added in the opposite order. If the config UI respects declaration order, this will cause the layout to differ depending on whether a valid source exists. Please align the order in both branches.

```suggestion
    if wHelper.existSource(widget.source) and widget.source.maximum and widget.source.minimum then
        -- Not perfect since to have this code working you will need
        -- to configure the widget to set the source first
        -- and then to configure again to set the remaining parameters
        wConfig.addNumberField("thresholdDown", widget.source:minimum(), widget.source:maximum(), THRESHOLD_PRECISION)
        wConfig.addNumberField("thresholdUp", widget.source:minimum(), widget.source:maximum(), THRESHOLD_PRECISION)
    else
        wConfig.addNumberField("thresholdDown", -THRESHOLD_RANGE, THRESHOLD_RANGE, THRESHOLD_PRECISION)
        wConfig.addNumberField("thresholdUp", -THRESHOLD_RANGE, THRESHOLD_RANGE, THRESHOLD_PRECISION)
    end
```
</issue_to_address>

### Comment 2
<location> `lib/w_paint.lua:147` </location>
<code_context>
         footerHeight = wPaint.FREE_ABOVE + footerHeight
         lcd.color(footerBGColor)
-        lcd.drawFilledRectangle(0, widget.height - footerHeight, widget.width, widget.height)
+        lcd.drawFilledRectangle(wPaint.TRANSPARENCY_X_OFFSET, widget.height - footerHeight - (2 * wPaint.TRANSPARENCY_Y_OFFSET), widget.width - (2 * wPaint.TRANSPARENCY_X_OFFSET), widget.height - (2 * wPaint.TRANSPARENCY_Y_OFFSET))
     end
     --- draw footer text
</code_context>

<issue_to_address>
**issue (bug_risk):** Footer rectangle height looks inconsistent with the intended footer band and with the title/background usage of transparency offsets.

For the title and main background, the `height` argument matches only the region being drawn (e.g., `widget.height - (2 * TRANSPARENCY_Y_OFFSET)` for the background, `titleHeight - TRANSPARENCY_Y_OFFSET` for the title). Here, the footer `y` is shifted by `widget.height - footerHeight - 2 * TRANSPARENCY_Y_OFFSET`, but `height` is `widget.height - 2 * TRANSPARENCY_Y_OFFSET`, so the rectangle extends well above the footer band. Consider using `footerHeight` (or `footerHeight - TRANSPARENCY_Y_OFFSET`) for the footer height so the rectangle is limited to the footer area within the transparency box.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

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.

1 participant