Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configuration options to memtemp.py (fields, position, vertical line spacing) #918

Merged
merged 8 commits into from
Apr 18, 2021

Conversation

crahan
Copy link
Contributor

@crahan crahan commented Sep 19, 2020

Description

Memtemp

Added CPU frequency
I believe this is useful data to have as an option. It's not enabled by default but users can configure it through settings as one of the three fields shown in the plugin (see below).

Made field types and order configurable (max 3 fields)
The field types and order of the fields has been made configurable through main.plugins.memtemp.fields. If a user prefers to use "cpu,temp,freq" or "mem,freq,cpu" then they can configure this accordingly in the settings. The fields config setting takes a comma separate list of field names. Whitespace is stripped in the code. Default value is "mem,cpu,temp".

Made line spacing and position configurable
Some users might prefer to slightly tweak the position or the vertical line spacing of the UI element for their specific screen. This can now be set using main.plugins.memtemp.position and main.plugins.memtemp.linespacing, respectively. Default values are the position as is currently defined for each display, but the vertical line spacing has been reduced to 10 pixels to align with the GPS module. position is a comma separated string of an x and y position (white space is again stripped). linespacing is an integer value. Some examples (horizontal layout settings example exaggerated to show effect of linespacing and position config settings) :

IMG_3254

main.plugins.memtemp.enabled = true
main.plugins.memtemp.scale = "celsius"
main.plugins.memtemp.orientation = "horizontal"
main.plugins.memtemp.fields = "temp,mem,freq"
main.plugins.memtemp.position = "178, 70"
main.plugins.memtemp.linespacing = 17

IMG_3255

main.plugins.memtemp.enabled = true
main.plugins.memtemp.scale = "celsius"
main.plugins.memtemp.orientation = "vertical"
main.plugins.memtemp.fields = "cpu,temp,freq"

Updated the code to dynamically generate UI elements
To support the configurable fields, position, and vertical line spacing, the UI elements are now dynamically generated as needed. If the user configures the plugin with 2 fields, then 2 LabeledValue objects are created (for vertical alignment). Horizontal UI elements are now Text objects (since they have no label anyway) and are split in a header and data UI element (of which the latter is the updated with current values).

Changed horizontal UI elements to Text
See the previous section.

Updated to version 1.0.2
Given the number of changes I felt an version bump was in order.

### GPS Handled in #919

There were some redundant spaces and incorrect coordinates which have now been fixed.

Motivation and Context

Fixes #920

  • I have raised an issue to propose this change (required)

Making the plugin more configurable and dynamic by adding settings for position, vertical line spacing, and field types and their order ensures that the plugin output can be configured to more user's personal tastes and requirements (some people want to know the CPU load, some want to see frequency. Some like small vertical spacing and have it align with the GPS module's output, some like a wider layout and slight shift in position).

How Has This Been Tested?

This has been tested on a pi zero and pi 3b running 1.5.3. Default values for screen positioning have not been altered from the previous version (but individual line positioning variables have been reduced to a single horizontal and vertical coordinate as the position for each line is now automatically calculated). Vertical line spacing was reduced to 10 to align with the output of the GPS module and now configurable vs the static line spacing a newline character resulted in. Any incorrect position on screen for other displays than the WaveShare v2 (which has been tested), can be quickly adjusted via a configuration setting until the default is updated in the code.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I've read the CONTRIBUTION guide
  • I have signed-off my commits with git commit -s

@crahan crahan changed the title memtemp,py refactoring and gps.py cleanup memtemp.py rework and gps.py cleanup Sep 19, 2020
Align fields right when less than 3 fields are shown in horizontal mode, using a 5-pixel character width with a 5-character width for each field (i.e. 25 pixels per field).
@crahan
Copy link
Contributor Author

crahan commented Sep 19, 2020

2 additional screenshots showing the default positioning and vertical line spacing for a WaveShare v2, but with only 2 fields instead of the default 3.

IMG_3257

IMG_3258

@crahan
Copy link
Contributor Author

crahan commented Sep 20, 2020

I removed the gps.py fixes from this pull request and moved them to #919

@crahan crahan changed the title memtemp.py rework and gps.py cleanup Add configuration options to memtemp.py (fields, position, vertical line spacing) Sep 20, 2020
@crahan
Copy link
Contributor Author

crahan commented Sep 20, 2020

Fixes #920

@evilsocket evilsocket merged commit f795598 into evilsocket:master Apr 18, 2021
@crahan crahan deleted the memtemp_gps_fixes branch April 18, 2021 15:57
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.

Add fields, position, and linespacing configuration options to memtemp.py
2 participants