Skip to content

Commit

Permalink
Merge pull request #9 from brainelectronics/feature/add-support-for-p…
Browse files Browse the repository at this point in the history
…ointer-functions

Add support for pointer thickness functions
  • Loading branch information
brainelectronics authored Jul 29, 2022
2 parents ec2d5c1 + a30e6d8 commit 1ed28f1
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 5 deletions.
13 changes: 12 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ r"^\#\# \[\d{1,}[.]\d{1,}[.]\d{1,}\] \- \d{4}\-\d{2}-\d{2}$"
-->

## Released
## [0.7.0] - 2022-07-29
### Added
- Support `Get_pointer_thickness_wid` and `Set_pointer_thickness_wid` by new
class `CommonPointerMixin` in [`common`](nextion/common.py)

### Changed
- Inherit from `CommonPointerMixin` in
- Gauge
- Slider

## [0.6.0] - 2022-07-29
### Added
- Support `Get_place_xcen`, `Set_place_xcen`, `Get_place_ycen` and
Expand Down Expand Up @@ -108,8 +118,9 @@ r"^\#\# \[\d{1,}[.]\d{1,}[.]\d{1,}\] \- \d{4}\-\d{2}-\d{2}$"
- [Example HMI file](examples/everything.HMI) to be used for all examples

<!-- Links -->
[Unreleased]: https://github.com/brainelectronics/micropython-nextion/compare/0.6.0...develop
[Unreleased]: https://github.com/brainelectronics/micropython-nextion/compare/0.7.0...develop

[0.7.0]: https://github.com/brainelectronics/micropython-nextion/tree/0.7.0
[0.6.0]: https://github.com/brainelectronics/micropython-nextion/tree/0.6.0
[0.5.0]: https://github.com/brainelectronics/micropython-nextion/tree/0.5.0
[0.4.0]: https://github.com/brainelectronics/micropython-nextion/tree/0.4.0
Expand Down
29 changes: 29 additions & 0 deletions examples/gauge/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
gauge_value = randint(10, 350)
background_color_value = 63488 # red
font_color_value = 31 # blue
pointer_thickness = 5

# request the value of gauge "z0"
print('Requesting gauge "{}" value ...'.format(z0.name))
Expand Down Expand Up @@ -114,6 +115,34 @@
if response != font_color_value:
print('WARNING: GET value did not match SET value')

time.sleep(1)

# request the pointer thickness of gauge "z0"
print('Requesting pointer thickness of gauge "{}" ...'.format(z0.name))
response = z0.Get_pointer_thickness_wid()
print('Pointer thickness of gauge "{}" is: "{}"'.format(z0.name, response))
print()

time.sleep(1)

# modify the pointer thickness of gauge "z0"
print('Set pointer thickness of gauge "{}" to "{}"'.
format(z0.name, pointer_thickness))
z0.Set_pointer_thickness_wid(pointer_thickness)
print()

time.sleep(1)

# request the pointer thickness of gauge "z0" again
print('Requesting pointer thickness of gauge "{}" ...'.format(z0.name))
response = z0.Get_pointer_thickness_wid()
print('Pointer thickness of gauge "{}" is: "{}"'.format(z0.name, response))
print()

# sanity check
if response != pointer_thickness:
print('WARNING: GET value did not match SET value')

print('Returning to REPL in 5 seconds')

# wait for 5 more seconds to safely finish the may still running threads
Expand Down
29 changes: 29 additions & 0 deletions examples/slider/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
slider_value = choice([randint(5, 40), randint(60, 100)])
background_color_value = 63488 # red
font_color_value = 31 # blue
pointer_thickness = 5

# request the value of slider "h0"
print('Requesting slider "{}" value ...'.format(h0.name))
Expand Down Expand Up @@ -118,6 +119,34 @@
if response != font_color_value:
print('WARNING: GET value did not match SET value')

time.sleep(1)

# request the pointer thickness of slider "h0"
print('Requesting pointer thickness of slider "{}" ...'.format(h0.name))
response = h0.Get_pointer_thickness_wid()
print('Pointer thickness of slider "{}" is: "{}"'.format(h0.name, response))
print()

time.sleep(1)

# modify the pointer thickness of slider "h0"
print('Set pointer thickness of slider "{}" to "{}"'.
format(h0.name, pointer_thickness))
h0.Set_pointer_thickness_wid(pointer_thickness)
print()

time.sleep(1)

# request the pointer thickness of slider "h0" again
print('Requesting pointer thickness of slider "{}" ...'.format(h0.name))
response = h0.Get_pointer_thickness_wid()
print('Pointer thickness of slider "{}" is: "{}"'.format(h0.name, response))
print()

# sanity check
if response != pointer_thickness:
print('WARNING: GET value did not match SET value')

print('Returning to REPL in 5 seconds')

# wait for 5 more seconds to safely finish the may still running threads
Expand Down
4 changes: 2 additions & 2 deletions nextion/nextion_gauge.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
"""

# custom packages
from .common import Common, CommonBackgroundColorMixin, CommonFontMixin, CommonValueMixin
from .common import Common, CommonBackgroundColorMixin, CommonFontMixin, CommonPointerMixin, CommonValueMixin


class NexGaugeError(Exception):
"""Base class for exceptions in this module."""
pass


class NexGauge(Common, CommonBackgroundColorMixin, CommonFontMixin, CommonValueMixin):
class NexGauge(Common, CommonBackgroundColorMixin, CommonFontMixin, CommonPointerMixin, CommonValueMixin):
"""docstring for NexGauge"""
def __init__(self, nh, pid: int, cid: int, name: str) -> None:
"""
Expand Down
4 changes: 2 additions & 2 deletions nextion/nextion_slider.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
"""

# custom packages
from .common import Common, CommonBackgroundColorMixin, CommonFontMixin, CommonValueMixin
from .common import Common, CommonBackgroundColorMixin, CommonFontMixin, CommonPointerMixin, CommonValueMixin


class NexSliderError(Exception):
"""Base class for exceptions in this module."""
pass


class NexSlider(Common, CommonBackgroundColorMixin, CommonFontMixin, CommonValueMixin):
class NexSlider(Common, CommonBackgroundColorMixin, CommonFontMixin, CommonPointerMixin, CommonValueMixin):
"""docstring for NexSlider"""
def __init__(self, nh, pid: int, cid: int, name: str) -> None:
"""
Expand Down

0 comments on commit 1ed28f1

Please sign in to comment.