From d9f10ced480d5b6cc049c3c84b44771bc94a64bc Mon Sep 17 00:00:00 2001 From: jposada202020 Date: Sat, 11 Jan 2025 23:47:27 -0500 Subject: [PATCH 1/4] adding_displayio_example --- docs/examples.rst | 17 ++++++++ examples/mmc56x3_displayio_simpletest.py | 50 ++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 examples/mmc56x3_displayio_simpletest.py diff --git a/docs/examples.rst b/docs/examples.rst index a416a83..3716c67 100644 --- a/docs/examples.rst +++ b/docs/examples.rst @@ -6,3 +6,20 @@ Ensure your device works with this simple test. .. literalinclude:: ../examples/mmc56x3_simpletest.py :caption: examples/mmc56x3_simpletest.py :linenos: + +Continuous mode test +-------------------- +Test using continuous mode. + +.. literalinclude:: ../examples/mmc56x3_continuous.py + :caption: examples/mmc56x3_continuoust.py + :linenos: + +DisplayIO Simpletest +--------------------- + +This is a simple test for boards with built-in display. + +.. literalinclude:: ../examples/mmc56x3_displayio_simpletest.py + :caption: examples/mmc56x3_displayio_simpletest.py + :linenos: diff --git a/examples/mmc56x3_displayio_simpletest.py b/examples/mmc56x3_displayio_simpletest.py new file mode 100644 index 0000000..d703aac --- /dev/null +++ b/examples/mmc56x3_displayio_simpletest.py @@ -0,0 +1,50 @@ +# SPDX-FileCopyrightText: 2024 Tim Cocks for Adafruit Industries +# SPDX-FileCopyrightText: 2024 Jose D. Montoya +# +# SPDX-License-Identifier: MIT + +import time + +import board +from adafruit_display_text.bitmap_label import Label +from displayio import Group +from terminalio import FONT + +import adafruit_mmc56x3 + +# Simple demo of using the built-in display. +# create a main_group to hold anything we want to show on the display. +main_group = Group() +# Initialize I2C bus and sensor. +i2c = board.I2C() # uses board.SCL and board.SDA +sensor = adafruit_mmc56x3.MMC5603(i2c) + +# Create Label(s) to show the readings. If you have a very small +# display you may need to change to scale=1. +display_output_label = Label(FONT, text="", scale=2) + +# place the label(s) in the middle of the screen with anchored positioning +display_output_label.anchor_point = (0, 0) +display_output_label.anchored_position = ( + 4, + board.DISPLAY.height // 2 - 60, +) + +# add the label(s) to the main_group +main_group.append(display_output_label) + +# set the main_group as the root_group of the built-in DISPLAY +board.DISPLAY.root_group = main_group + +# begin main loop +while True: + # update the text of the label(s) to show the sensor readings + mag_x, mag_y, mag_z = sensor.magnetic + display_output_label.text = ( + f"Acceleration\n" + + f"x: {mag_x:.1f} uT\n" + + f"y: {mag_y:.1f} uT\n" + + f"z: {mag_z:.1f} uT" + ) + # wait for a bit + time.sleep(0.5) From ed055e67a849fd86a31d7f0388035ffd7882a414 Mon Sep 17 00:00:00 2001 From: jposada202020 Date: Sat, 11 Jan 2025 23:51:35 -0500 Subject: [PATCH 2/4] line_fix --- examples/mmc56x3_displayio_simpletest.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/examples/mmc56x3_displayio_simpletest.py b/examples/mmc56x3_displayio_simpletest.py index d703aac..37fafad 100644 --- a/examples/mmc56x3_displayio_simpletest.py +++ b/examples/mmc56x3_displayio_simpletest.py @@ -41,10 +41,7 @@ # update the text of the label(s) to show the sensor readings mag_x, mag_y, mag_z = sensor.magnetic display_output_label.text = ( - f"Acceleration\n" - + f"x: {mag_x:.1f} uT\n" - + f"y: {mag_y:.1f} uT\n" - + f"z: {mag_z:.1f} uT" + f"x: {mag_x:.1f} uT\ny: {mag_y:.1f} uT\nz: {mag_z:.1f} uT" ) # wait for a bit time.sleep(0.5) From 3e7b26ba8e59c4475a7ae76b37d1074a6fd2aad6 Mon Sep 17 00:00:00 2001 From: jposada202020 Date: Sat, 11 Jan 2025 23:59:38 -0500 Subject: [PATCH 3/4] line_fix_3 --- examples/mmc56x3_displayio_simpletest.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/examples/mmc56x3_displayio_simpletest.py b/examples/mmc56x3_displayio_simpletest.py index 37fafad..5cbb100 100644 --- a/examples/mmc56x3_displayio_simpletest.py +++ b/examples/mmc56x3_displayio_simpletest.py @@ -40,8 +40,6 @@ while True: # update the text of the label(s) to show the sensor readings mag_x, mag_y, mag_z = sensor.magnetic - display_output_label.text = ( - f"x: {mag_x:.1f} uT\ny: {mag_y:.1f} uT\nz: {mag_z:.1f} uT" - ) + display_output_label.text = f"x: {mag_x:.1f}uT\ny: {mag_y:.1f} uT\nz: {mag_z:.1f} uT" # wait for a bit time.sleep(0.5) From 3f617de9ea4d02051cc907d8f8c476a09325b2c7 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Wed, 22 Jan 2025 10:26:07 -0600 Subject: [PATCH 4/4] fix typo in filename --- docs/examples.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/examples.rst b/docs/examples.rst index 3716c67..0be860d 100644 --- a/docs/examples.rst +++ b/docs/examples.rst @@ -12,7 +12,7 @@ Continuous mode test Test using continuous mode. .. literalinclude:: ../examples/mmc56x3_continuous.py - :caption: examples/mmc56x3_continuoust.py + :caption: examples/mmc56x3_continuous.py :linenos: DisplayIO Simpletest