refactor(steami_screen): move constants to dedicated const.py file.#424
Open
MatteoCnda1 wants to merge 1 commit intomainfrom
Open
refactor(steami_screen): move constants to dedicated const.py file.#424MatteoCnda1 wants to merge 1 commit intomainfrom
MatteoCnda1 wants to merge 1 commit intomainfrom
Conversation
b491fe4 to
5475760
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Refactor
steami_screenmodule by extracting all constants fromdevice.pyinto a dedicatedconst.pyfile, aligning with the project convention of having aconst.pyper module (as inapds9960,hts221,bq27441, etc.).Closes #358
Context
The project convention recommends having a
const.pyfile in each module to group constants. Insteami_screen, constants such as colors andFACESwere previously defined directly indevice.py, making the file more cluttered and diverging from the established structure used elsewhere in the repository.Changes
New file
lib/steami_screen/steami_screen/const.py— centralizes all module constantsConstants moved from
device.pytoconst.pyBLACK,DARK,GRAY,LIGHT,WHITE,GREEN,RED,BLUE,YELLOWFACESdictionary (8x8 pixel-art expressions)New constants extracted from inline magic numbers
STEAMI_CHAR_W/STEAMI_CHAR_H— framebuf font dimensions (previously inline class attributes)STEAMI_DEFAULT_WIDTH/STEAMI_DEFAULT_HEIGHT— default screen size (previously hardcoded128)STEAMI_GAUGE_START_ANGLE/STEAMI_GAUGE_SWEEP— gauge widget anglesSTEAMI_GRAPH_MARGIN,STEAMI_GRAPH_X_OFFSET,STEAMI_GRAPH_Y,STEAMI_GRAPH_HEIGHT,STEAMI_GRAPH_VALUE_Y,STEAMI_GRAPH_DASH,STEAMI_GRAPH_GAP— graph widget layoutGRID_DARK— graph grid color (previously inline(51, 51, 51)tuple)Updated files
device.py— imports constants fromconst.py, no functional changes__init__.py— colors andFACESare now re-exported directly fromconst.py(single source of truth)Motivation
device.pydevice.pyconst.pyper module)API compatibility
No public API breakage.
Screen.CHAR_WandScreen.CHAR_Hremain exposed as class attributes for backward compatibilityFACESremain importable from the top-level package:from steami_screen import WHITE, FACESlib/steami_screen/examples/work without modificationValidation
ruff checkpassespython -m pytest tests/ -k mock -vpassescomfort_bar_demo.pyruns successfully viampremoteNotes
This is a pure refactor with no functional changes. The
apds9960module'sconst.pywas used as the reference for naming convention (STEAMI_*prefix for module-specific constants, short names for shared color tuples).