mathoudebine / mathoudebine/turing-smart-screen-python

Combo widgets

Open
#178 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Rich Text Format
Stars
2.3k
Forks
412
Avg merge
21h 10m
Merged PRs (30d)
7

Description

Idea
It would be great to have the possibility to overlap "widgets". With this, we can create complex displays e.g. text on bar !

What is the current problem with this?
Each display (text or bar) is commit at creation using fake transparency. So two "widgets" embed their own background. This prevents overlapping "widgets".

Workaround
When creating a "widget" we can commit changes according to a boolean variable. If set to true, changes are not commit and another "widget" is created overlapping possibly the prior "widget".
AFAIK all themes only use a unique background. So we can use an instance variable (of LCD) for the background.
Each time we want to create overlapping "widgets", we use a copy of this background and create "widgets" on this background.

For example with simple-program.py example and two overlapping widgets:
example_back_overlap

When overlapping is finished, we commit changes:
example_full

In the code
Create four instance variables:

  • bg_image the background used in the theme
  • combo the boolean variable whether a "combowidget" is currently in progress
  • combo_image copy of bg_image with each "widget" of the "combowidget"
  • combo_bbox a list of bbox of each "widget" inside the "combowidget"

A commit display method:
DisplayCommit : it takes the combo_image and the combo_bbox and call DisplayPILImage for each bbox (with crop).

Complexity
As informations to be displayed would be the same, there are no additional drawings. But, as DisplayCommit would work on each bounding boxes, overlapping zones would be drawn several times... unless a smart algorithm identifies common zones.

In the yaml files
We can create a COMBO section in existing sections for example:

...
GPU:
    # In seconds. Longer intervals cause this to refresh more slowly.
    # Setting to lower values will display near real time data,
    # but may cause significant CPU usage or the display not to update properly
    INTERVAL: 1
    COMBO:
     BACKGROUND_IMAGE: background.png
     PERCENTAGE:
       GRAPH:
         SHOW: True
         X: 350
         Y: 200
         WIDTH: 125
         HEIGHT: 15
         MIN_VALUE: 0
         MAX_VALUE: 100
         BAR_COLOR: 0, 0, 255
         BAR_OUTLINE: False
       TEXT:
         SHOW: True
         SHOW_UNIT: True
         X: 360
         Y: 200
         FONT: jetbrains-mono/JetBrainsMono-Bold.ttf
         FONT_SIZE: 40
         FONT_COLOR: 255, 255, 255
...

Impact on today's themes
None of the current themes would be impacted.
Default behavior is to have combo boolean to falsy value so that each creation is commit immediately.

On Radial Progress Bar (PR)
It would allow to separate the radial bar from the text and users to place text independently of the radial bar.

edit: yaml

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the simple-program.py example and inspect the DisplayCommit and DisplayPILImage entry points described in the issue, along with the existing theme YAML structure. Determine how overlapping widgets should be represented and committed while preserving immediate commits for current themes. Done means overlapping widgets render together and the default behavior remains unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
embedded-iot
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.