From 58ee3b1e97b62f777312132690801ac735a86b79 Mon Sep 17 00:00:00 2001 From: Gee Bartlett <122281230+ageeandakeyboard@users.noreply.github.com> Date: Mon, 30 Jan 2023 10:19:28 +0000 Subject: [PATCH 1/8] added boot button to module --- micropython/examples/interstate75/buttons.py | 15 ++++++++++++++- micropython/modules_py/interstate75.py | 7 ++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/micropython/examples/interstate75/buttons.py b/micropython/examples/interstate75/buttons.py index b60a3be6..40d64350 100644 --- a/micropython/examples/interstate75/buttons.py +++ b/micropython/examples/interstate75/buttons.py @@ -1,6 +1,6 @@ ''' buttons.py -Push either switch A or switch B to change the display +Push either switch A, switch B or the BOOT switch (in the case of the non-w version) to change the display ''' import interstate75 @@ -16,6 +16,9 @@ A_TEXT = graphics.create_pen(0xCE, 0x7E, 0x31) B_COLOR = graphics.create_pen(0xC3, 0x3C, 0xBD) B_TEXT = graphics.create_pen(0x3C, 0xC3, 0x42) +BOOT_COLOR = graphics.create_pen(0xC3, 0x3C, 0xBD) +BOOT_TEXT = graphics.create_pen(0x3C, 0xC3, 0x42) + BG = graphics.create_pen(0xC1, 0x99, 0x3E) @@ -35,6 +38,14 @@ def display_b(): i75.update() +def display_boot(): + graphics.set_pen(BOOT_COLOR) + graphics.clear() + graphics.set_pen(BOOT_TEXT) + graphics.text("BOOT", 0, 6, False, 3) + i75.update() + + graphics.set_pen(BG) graphics.clear() i75.update() @@ -44,3 +55,5 @@ while 1: display_a() if i75.switch_pressed(interstate75.SWITCH_B): display_b() + if i75.switch_pressed(interstate75.SWITCH_BOOT): + display_boot() diff --git a/micropython/modules_py/interstate75.py b/micropython/modules_py/interstate75.py index e261b4fb..52af70c5 100644 --- a/micropython/modules_py/interstate75.py +++ b/micropython/modules_py/interstate75.py @@ -6,12 +6,13 @@ import hub75 # Index Constants SWITCH_A = 0 SWITCH_B = 1 +SWITCH_BOOT = 2 class Interstate75: I2C_SDA_PIN = 20 I2C_SCL_PIN = 21 - SWITCH_PINS = (14, 15) + SWITCH_PINS = (14, 15, 23) LED_R_PIN = 16 LED_G_PIN = 17 LED_B_PIN = 18 @@ -36,7 +37,7 @@ class Interstate75: COLOR_ORDER_BGR = hub75.COLOR_ORDER_BGR # Count Constants - NUM_SWITCHES = 2 + NUM_SWITCHES = 3 def __init__(self, display, panel_type=hub75.PANEL_GENERIC, stb_invert=False, color_order=hub75.COLOR_ORDER_RGB): self.display = PicoGraphics(display=display) @@ -61,7 +62,7 @@ class Interstate75: def switch_pressed(self, switch): if switch < 0 or switch >= self.NUM_SWITCHES: - raise ValueError("switch out of range. Expected SWITCH_A (0), SWITCH_B (1)") + raise ValueError("switch out of range. Expected SWITCH_A (0), SWITCH_B (1) SWITCH_BOOT (2)") return self.__switches[switch].is_pressed def set_led(self, r, g, b): From 2a1c1e464fdf19a464fa8b7554f84eb70cfcca2b Mon Sep 17 00:00:00 2001 From: Gee Bartlett <122281230+ageeandakeyboard@users.noreply.github.com> Date: Mon, 30 Jan 2023 10:48:04 +0000 Subject: [PATCH 2/8] moved text size and placement --- micropython/examples/interstate75/buttons.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/micropython/examples/interstate75/buttons.py b/micropython/examples/interstate75/buttons.py index 40d64350..4f2ae996 100644 --- a/micropython/examples/interstate75/buttons.py +++ b/micropython/examples/interstate75/buttons.py @@ -42,7 +42,7 @@ def display_boot(): graphics.set_pen(BOOT_COLOR) graphics.clear() graphics.set_pen(BOOT_TEXT) - graphics.text("BOOT", 0, 6, False, 3) + graphics.text("BOOT", 5, 11, False, 1) i75.update() From 96c83f8ae439d90c1c296533cf7d6100a761a303 Mon Sep 17 00:00:00 2001 From: Gee Bartlett <122281230+ageeandakeyboard@users.noreply.github.com> Date: Mon, 30 Jan 2023 11:39:53 +0000 Subject: [PATCH 3/8] Update interstate75.md --- micropython/modules_py/interstate75.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/micropython/modules_py/interstate75.md b/micropython/modules_py/interstate75.md index 68ffc2b5..7987f188 100644 --- a/micropython/modules_py/interstate75.md +++ b/micropython/modules_py/interstate75.md @@ -47,12 +47,21 @@ To read a specific input, the `interstate75` module contains these handy constan * `SWITCH_A` = `0` * `SWITCH_B` = `1` +The Interstate 75 (non W) uses the boot button instead of `SWITCH_B` + +* `SWITCH_BOOT` = `2` + ```python if board.switch_pressed(SWITCH_A): # Do something interesting here! +# Either for Interstate 75W if board.switch_pressed(SWITCH_B): # Do something else even more interesting here! + +# Or for Interstate 75 +if board.switch_pressed(SWITCH_BOOT): + # Do something else even more interesting here! ``` From 979cc38b2ab226c7ab383369d5d534b77b96e201 Mon Sep 17 00:00:00 2001 From: Gee Bartlett <122281230+ageeandakeyboard@users.noreply.github.com> Date: Tue, 31 Jan 2023 09:33:46 +0000 Subject: [PATCH 4/8] updated button defs --- micropython/modules_py/interstate75.md | 16 ++++++++++++++-- micropython/modules_py/interstate75.py | 15 ++++++++++----- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/micropython/modules_py/interstate75.md b/micropython/modules_py/interstate75.md index 7987f188..5d25b39e 100644 --- a/micropython/modules_py/interstate75.md +++ b/micropython/modules_py/interstate75.md @@ -27,6 +27,7 @@ DISPLAY_INTERSTATE75_192X64 DISPLAY_INTERSTATE75_256X64 ``` +You are able to set which version of the Interstate75 that you are using with the `interstate75w=` as default this value is set to `False` to use the Interstate75 button layout by setting it to `True` the module will use the Intersate75W button layout. If you are using an Interstate75W it is important to set this value to `interstate75w=True`, otherwise this could disable the wifi in your project. ```python import interstate75 @@ -36,6 +37,16 @@ display = interstate75.DISPLAY_INTERSTATE75_32X32 board = interstate75.Interstate75(display=display) ``` +Or for an Interstate75W. + +```python +import interstate75 + +display = interstate75.DISPLAY_INTERSTATE75_32X32 + +board = interstate75.Interstate75(display=display, interstate75w=True) +``` + From here, all features can be accessed by calling functions on `board`. In addition, when using Qwiic / Stemma QT devices, the I2C channel to use can be accessed with `board.i2c`. ### Switches @@ -47,9 +58,10 @@ To read a specific input, the `interstate75` module contains these handy constan * `SWITCH_A` = `0` * `SWITCH_B` = `1` -The Interstate 75 (non W) uses the boot button instead of `SWITCH_B` +The Interstate75 (non W) uses the boot button instead of `SWITCH_B` -* `SWITCH_BOOT` = `2` +* `SWITCH_A` = `0` +* `SWITCH_BOOT` = `1` ```python if board.switch_pressed(SWITCH_A): diff --git a/micropython/modules_py/interstate75.py b/micropython/modules_py/interstate75.py index 52af70c5..64cba9c3 100644 --- a/micropython/modules_py/interstate75.py +++ b/micropython/modules_py/interstate75.py @@ -6,13 +6,14 @@ import hub75 # Index Constants SWITCH_A = 0 SWITCH_B = 1 -SWITCH_BOOT = 2 +SWITCH_BOOT = 1 class Interstate75: I2C_SDA_PIN = 20 I2C_SCL_PIN = 21 - SWITCH_PINS = (14, 15, 23) + SWITCH_PINS = (14, 23) + SWITCH_PINS_W = (14, 15) LED_R_PIN = 16 LED_G_PIN = 17 LED_B_PIN = 18 @@ -37,18 +38,22 @@ class Interstate75: COLOR_ORDER_BGR = hub75.COLOR_ORDER_BGR # Count Constants - NUM_SWITCHES = 3 + NUM_SWITCHES = 2 - def __init__(self, display, panel_type=hub75.PANEL_GENERIC, stb_invert=False, color_order=hub75.COLOR_ORDER_RGB): + def __init__(self, display, panel_type=hub75.PANEL_GENERIC, stb_invert=False, color_order=hub75.COLOR_ORDER_RGB, interstate75w=False): self.display = PicoGraphics(display=display) self.width, self.height = self.display.get_bounds() self.hub75 = hub75.Hub75(self.width, self.height, panel_type=panel_type, stb_invert=stb_invert, color_order=color_order) self.hub75.start() + if interstate75w: + self._switch_pins = self.SWITCH_PINS_W + else: + self._switch_pins = self.SWITCH_PINS # Set up the user switches self.__switches = [] for i in range(self.NUM_SWITCHES): - self.__switches.append(Button(self.SWITCH_PINS[i])) + self.__switches.append(Button(self._switch_pins[i])) self.__rgb = RGBLED(Interstate75.LED_R_PIN, Interstate75.LED_G_PIN, Interstate75.LED_B_PIN, invert=True) From 93a18a874ab7a84b9437aec350dd3f8a0eaa7081 Mon Sep 17 00:00:00 2001 From: Gee Bartlett <122281230+ageeandakeyboard@users.noreply.github.com> Date: Tue, 31 Jan 2023 10:12:22 +0000 Subject: [PATCH 5/8] updated examples --- .../examples/interstate75/75W/buttons.py | 49 +++++++++++++++++++ .../examples/interstate75/75W/cheerlights.py | 2 +- .../examples/interstate75/75W/clock.py | 2 +- micropython/examples/interstate75/buttons.py | 10 ---- 4 files changed, 51 insertions(+), 12 deletions(-) create mode 100644 micropython/examples/interstate75/75W/buttons.py diff --git a/micropython/examples/interstate75/75W/buttons.py b/micropython/examples/interstate75/75W/buttons.py new file mode 100644 index 00000000..7916dbc5 --- /dev/null +++ b/micropython/examples/interstate75/75W/buttons.py @@ -0,0 +1,49 @@ +''' +buttons.py +Push either switch A, switch B or the BOOT switch (in the case of the non-w version) to change the display +''' +import interstate75 + +i75 = interstate75.Interstate75(display=interstate75.DISPLAY_INTERSTATE75_32X32, interstate75w=True) +graphics = i75.display + +width = i75.width +height = i75.height + +A_COLOR = graphics.create_pen(0x31, 0x81, 0xCE) +A_TEXT = graphics.create_pen(0xCE, 0x7E, 0x31) + +B_COLOR = graphics.create_pen(0xC3, 0x3C, 0xBD) +B_TEXT = graphics.create_pen(0x3C, 0xC3, 0x42) + +BOOT_COLOR = graphics.create_pen(0xC3, 0x3C, 0xBD) +BOOT_TEXT = graphics.create_pen(0x3C, 0xC3, 0x42) + +BG = graphics.create_pen(0xC1, 0x99, 0x3E) + + +def display_a(): + graphics.set_pen(A_COLOR) + graphics.clear() + graphics.set_pen(A_TEXT) + graphics.text("A", 8, 6, False, 3) + i75.update() + + +def display_b(): + graphics.set_pen(B_COLOR) + graphics.clear() + graphics.set_pen(B_TEXT) + graphics.text("B", 8, 6, False, 3) + i75.update() + + +graphics.set_pen(BG) +graphics.clear() +i75.update() + +while 1: + if i75.switch_pressed(interstate75.SWITCH_A): + display_a() + if i75.switch_pressed(interstate75.SWITCH_B): + display_b() diff --git a/micropython/examples/interstate75/75W/cheerlights.py b/micropython/examples/interstate75/75W/cheerlights.py index 79d41231..14aff563 100644 --- a/micropython/examples/interstate75/75W/cheerlights.py +++ b/micropython/examples/interstate75/75W/cheerlights.py @@ -77,7 +77,7 @@ def update_leds(): print("LEDs updated!") -i75 = interstate75.Interstate75(display=interstate75.DISPLAY_INTERSTATE75_32X32) +i75 = interstate75.Interstate75(display=interstate75.DISPLAY_INTERSTATE75_32X32, interstate75w=True) graphics = i75.display width = i75.width diff --git a/micropython/examples/interstate75/75W/clock.py b/micropython/examples/interstate75/75W/clock.py index c95ca905..7be075c0 100644 --- a/micropython/examples/interstate75/75W/clock.py +++ b/micropython/examples/interstate75/75W/clock.py @@ -14,7 +14,7 @@ import network import ntptime from interstate75 import Interstate75, DISPLAY_INTERSTATE75_32X32 -i75 = Interstate75(display=DISPLAY_INTERSTATE75_32X32) +i75 = Interstate75(display=DISPLAY_INTERSTATE75_32X32, interstate75w=True) graphics = i75.display width = i75.width diff --git a/micropython/examples/interstate75/buttons.py b/micropython/examples/interstate75/buttons.py index 4f2ae996..57212468 100644 --- a/micropython/examples/interstate75/buttons.py +++ b/micropython/examples/interstate75/buttons.py @@ -30,14 +30,6 @@ def display_a(): i75.update() -def display_b(): - graphics.set_pen(B_COLOR) - graphics.clear() - graphics.set_pen(B_TEXT) - graphics.text("B", 8, 6, False, 3) - i75.update() - - def display_boot(): graphics.set_pen(BOOT_COLOR) graphics.clear() @@ -53,7 +45,5 @@ i75.update() while 1: if i75.switch_pressed(interstate75.SWITCH_A): display_a() - if i75.switch_pressed(interstate75.SWITCH_B): - display_b() if i75.switch_pressed(interstate75.SWITCH_BOOT): display_boot() From 8637967605b20a99aec4d8e639084d76dea13169 Mon Sep 17 00:00:00 2001 From: Gee Bartlett <122281230+ageeandakeyboard@users.noreply.github.com> Date: Fri, 3 Feb 2023 12:53:14 +0000 Subject: [PATCH 6/8] Made edits from review --- examples/interstate75/interstate75_example.cpp | 5 ++++- libraries/interstate75/README.md | 3 +++ libraries/interstate75/interstate75.hpp | 1 + micropython/modules_py/interstate75.md | 4 ++-- micropython/modules_py/interstate75.py | 2 +- 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/examples/interstate75/interstate75_example.cpp b/examples/interstate75/interstate75_example.cpp index 1ed37bd8..f36147d5 100644 --- a/examples/interstate75/interstate75_example.cpp +++ b/examples/interstate75/interstate75_example.cpp @@ -13,8 +13,11 @@ PicoGraphics_PenRGB888 graphics(hub75.width, hub75.height, nullptr); // And each button Button button_a(Interstate75::A); -Button button_b(Interstate75::B); +// For the Interstate75 +// Button button_b(Interstate75::BOOT); // Using this button definition on the Interstate75W will most likely disable the wifi make sure it is commented out if using Interstate75W +// Or for the Interstate75W +Button button_b(Interstate75::B); // This button is not present on the Interstate75 (non W version) // RGB LED RGBLED led(Interstate75::LED_R, Interstate75::LED_G, Interstate75::LED_B, ACTIVE_LOW); diff --git a/libraries/interstate75/README.md b/libraries/interstate75/README.md index 817fdf68..73f542f5 100644 --- a/libraries/interstate75/README.md +++ b/libraries/interstate75/README.md @@ -27,6 +27,9 @@ PicoGraphics_PenRGB888 graphics(hub75.width, hub75.height, nullptr); // And each button Button button_a(Interstate75::A); +// For the Interstate75 +Button button_b(Interstate75::BOOT); +// Or for the Interstate75W Button button_b(Interstate75::B); // RGB LED diff --git a/libraries/interstate75/interstate75.hpp b/libraries/interstate75/interstate75.hpp index 28ac8838..69c91866 100644 --- a/libraries/interstate75/interstate75.hpp +++ b/libraries/interstate75/interstate75.hpp @@ -9,6 +9,7 @@ namespace pimoroni { namespace Interstate75{ static const uint8_t A = 14; static const uint8_t B = 15; + static const uint8_t BOOT = 23; static const uint8_t LED_R = 16; static const uint8_t LED_G = 17; static const uint8_t LED_B = 18; diff --git a/micropython/modules_py/interstate75.md b/micropython/modules_py/interstate75.md index 5d25b39e..3baf0666 100644 --- a/micropython/modules_py/interstate75.md +++ b/micropython/modules_py/interstate75.md @@ -27,7 +27,7 @@ DISPLAY_INTERSTATE75_192X64 DISPLAY_INTERSTATE75_256X64 ``` -You are able to set which version of the Interstate75 that you are using with the `interstate75w=` as default this value is set to `False` to use the Interstate75 button layout by setting it to `True` the module will use the Intersate75W button layout. If you are using an Interstate75W it is important to set this value to `interstate75w=True`, otherwise this could disable the wifi in your project. +You are able to set which version of the Interstate75 that you are using with the `interstate75w=`. By default this value is set to `True` to use the Interstate75W button layout. By setting it to `False` the module will use the Interstate75 button layout. If you are using an Interstate75W it is important to set this value to interstate75w=True, otherwise this could disable the WiFi in your project ```python import interstate75 @@ -44,7 +44,7 @@ import interstate75 display = interstate75.DISPLAY_INTERSTATE75_32X32 -board = interstate75.Interstate75(display=display, interstate75w=True) +board = interstate75.Interstate75(display=display, interstate75w=False) #This is th e setup to be able to access the both A and BOOT on the Interstate75 (non W) ``` From here, all features can be accessed by calling functions on `board`. In addition, when using Qwiic / Stemma QT devices, the I2C channel to use can be accessed with `board.i2c`. diff --git a/micropython/modules_py/interstate75.py b/micropython/modules_py/interstate75.py index 64cba9c3..2637377e 100644 --- a/micropython/modules_py/interstate75.py +++ b/micropython/modules_py/interstate75.py @@ -67,7 +67,7 @@ class Interstate75: def switch_pressed(self, switch): if switch < 0 or switch >= self.NUM_SWITCHES: - raise ValueError("switch out of range. Expected SWITCH_A (0), SWITCH_B (1) SWITCH_BOOT (2)") + raise ValueError("switch out of range. Expected SWITCH_A (0), SWITCH_B/BOOT (1)") return self.__switches[switch].is_pressed def set_led(self, r, g, b): From 552339a49e47153c0c99f72d0f473a818658a36c Mon Sep 17 00:00:00 2001 From: Gee Bartlett <122281230+ageeandakeyboard@users.noreply.github.com> Date: Fri, 3 Feb 2023 13:13:13 +0000 Subject: [PATCH 7/8] Update interstate75.md --- micropython/modules_py/interstate75.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/micropython/modules_py/interstate75.md b/micropython/modules_py/interstate75.md index 3baf0666..b83810b5 100644 --- a/micropython/modules_py/interstate75.md +++ b/micropython/modules_py/interstate75.md @@ -44,7 +44,7 @@ import interstate75 display = interstate75.DISPLAY_INTERSTATE75_32X32 -board = interstate75.Interstate75(display=display, interstate75w=False) #This is th e setup to be able to access the both A and BOOT on the Interstate75 (non W) +board = interstate75.Interstate75(display=display, interstate75w=False) # This is the setup to be able to access the both A and BOOT on the Interstate75 (non W) ``` From here, all features can be accessed by calling functions on `board`. In addition, when using Qwiic / Stemma QT devices, the I2C channel to use can be accessed with `board.i2c`. From 5f9d4e33b3ca2416efb9aa9079a181a854762e82 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Wed, 22 Feb 2023 11:47:23 +0000 Subject: [PATCH 8/8] Interstate 75: Auto-detect board version. --- .../examples/interstate75/75W/buttons.py | 2 +- .../examples/interstate75/75W/cheerlights.py | 2 +- .../examples/interstate75/75W/clock.py | 2 +- micropython/modules_py/interstate75.md | 38 +++++++------------ micropython/modules_py/interstate75.py | 6 ++- 5 files changed, 21 insertions(+), 29 deletions(-) diff --git a/micropython/examples/interstate75/75W/buttons.py b/micropython/examples/interstate75/75W/buttons.py index 7916dbc5..dd3c36b0 100644 --- a/micropython/examples/interstate75/75W/buttons.py +++ b/micropython/examples/interstate75/75W/buttons.py @@ -4,7 +4,7 @@ Push either switch A, switch B or the BOOT switch (in the case of the non-w vers ''' import interstate75 -i75 = interstate75.Interstate75(display=interstate75.DISPLAY_INTERSTATE75_32X32, interstate75w=True) +i75 = interstate75.Interstate75(display=interstate75.DISPLAY_INTERSTATE75_32X32) graphics = i75.display width = i75.width diff --git a/micropython/examples/interstate75/75W/cheerlights.py b/micropython/examples/interstate75/75W/cheerlights.py index 14aff563..79d41231 100644 --- a/micropython/examples/interstate75/75W/cheerlights.py +++ b/micropython/examples/interstate75/75W/cheerlights.py @@ -77,7 +77,7 @@ def update_leds(): print("LEDs updated!") -i75 = interstate75.Interstate75(display=interstate75.DISPLAY_INTERSTATE75_32X32, interstate75w=True) +i75 = interstate75.Interstate75(display=interstate75.DISPLAY_INTERSTATE75_32X32) graphics = i75.display width = i75.width diff --git a/micropython/examples/interstate75/75W/clock.py b/micropython/examples/interstate75/75W/clock.py index 7be075c0..c95ca905 100644 --- a/micropython/examples/interstate75/75W/clock.py +++ b/micropython/examples/interstate75/75W/clock.py @@ -14,7 +14,7 @@ import network import ntptime from interstate75 import Interstate75, DISPLAY_INTERSTATE75_32X32 -i75 = Interstate75(display=DISPLAY_INTERSTATE75_32X32, interstate75w=True) +i75 = Interstate75(display=DISPLAY_INTERSTATE75_32X32) graphics = i75.display width = i75.width diff --git a/micropython/modules_py/interstate75.md b/micropython/modules_py/interstate75.md index b83810b5..f54bcc6b 100644 --- a/micropython/modules_py/interstate75.md +++ b/micropython/modules_py/interstate75.md @@ -4,9 +4,10 @@ This library offers convenient functions for interacting with [Interstate75](htt ## Table of Content - [Table of Content](#table-of-content) -- [Interstate75 Module](#interstate75-class) +- [Interstate75 Class](#interstate75-class) - [Switches](#switches) - [RGB LED](#rgb-led) +- [Display](#display) @@ -14,7 +15,18 @@ This library offers convenient functions for interacting with [Interstate75](htt The `Interstate75` class deals with RGB LED and buttons on the Interstate75 and 75W. To create one, import the `interstate75` module, then define a new `board` variable. -This is where you define the HUB75 matrix display size that you wish to use by defining `display=` + +```python +import interstate75 + +display = interstate75.DISPLAY_INTERSTATE75_32X32 + +board = interstate75.Interstate75(display=display) +``` + +The version of Intersate75 you're using should be automatically detected. Check `board.interstate75w` to verify this. It should be `True` on a W and `False` on a non-W. + +You can choose the HUB75 matrix display size that you wish to use by defining `display=` as one of the following: ```python DISPLAY_INTERSTATE75_32X32 @@ -27,28 +39,6 @@ DISPLAY_INTERSTATE75_192X64 DISPLAY_INTERSTATE75_256X64 ``` -You are able to set which version of the Interstate75 that you are using with the `interstate75w=`. By default this value is set to `True` to use the Interstate75W button layout. By setting it to `False` the module will use the Interstate75 button layout. If you are using an Interstate75W it is important to set this value to interstate75w=True, otherwise this could disable the WiFi in your project - -```python -import interstate75 - -display = interstate75.DISPLAY_INTERSTATE75_32X32 - -board = interstate75.Interstate75(display=display) -``` - -Or for an Interstate75W. - -```python -import interstate75 - -display = interstate75.DISPLAY_INTERSTATE75_32X32 - -board = interstate75.Interstate75(display=display, interstate75w=False) # This is the setup to be able to access the both A and BOOT on the Interstate75 (non W) -``` - -From here, all features can be accessed by calling functions on `board`. In addition, when using Qwiic / Stemma QT devices, the I2C channel to use can be accessed with `board.i2c`. - ### Switches Interstate75 and 75W have two switches in the front of the board. To read one of the switches, call `.switch_pressed(switch)`, where `switch` is a value from `0` to `.NUM_SWITCHES - 1`. This returns `True` when the specified switch is pressed, and `False` otherwise. diff --git a/micropython/modules_py/interstate75.py b/micropython/modules_py/interstate75.py index 2637377e..13f231e0 100644 --- a/micropython/modules_py/interstate75.py +++ b/micropython/modules_py/interstate75.py @@ -2,6 +2,7 @@ from pimoroni import RGBLED, Button from picographics import PicoGraphics, DISPLAY_INTERSTATE75_32X32, DISPLAY_INTERSTATE75_64X32, DISPLAY_INTERSTATE75_96X32, DISPLAY_INTERSTATE75_128X32, DISPLAY_INTERSTATE75_64X64, DISPLAY_INTERSTATE75_128X64, DISPLAY_INTERSTATE75_192X64, DISPLAY_INTERSTATE75_256X64 from pimoroni_i2c import PimoroniI2C import hub75 +import sys # Index Constants SWITCH_A = 0 @@ -40,12 +41,13 @@ class Interstate75: # Count Constants NUM_SWITCHES = 2 - def __init__(self, display, panel_type=hub75.PANEL_GENERIC, stb_invert=False, color_order=hub75.COLOR_ORDER_RGB, interstate75w=False): + def __init__(self, display, panel_type=hub75.PANEL_GENERIC, stb_invert=False, color_order=hub75.COLOR_ORDER_RGB): + self.interstate75w = "Pico W" in sys.implementation._machine self.display = PicoGraphics(display=display) self.width, self.height = self.display.get_bounds() self.hub75 = hub75.Hub75(self.width, self.height, panel_type=panel_type, stb_invert=stb_invert, color_order=color_order) self.hub75.start() - if interstate75w: + if self.interstate75w: self._switch_pins = self.SWITCH_PINS_W else: self._switch_pins = self.SWITCH_PINS