Answers.Body: <p>This isn't a direct answer to your question, but it would be one way to solve the problem. Instead of using the hubs from SPIKE or Robot Inventor, you could use the Control+ hub:</p>
  <p><a href="https://i.sstatic.net/ot1PD.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ot1PD.png" alt="Control+ Hub" /></a></p>
  <p>This hub unfortunately only supports 4 peripherals, so you would need three of them. This hub is not programmable, but it can be controlled over Bluetooth. You can pair up to 7 hubs to a single device this way, so you could control up to 7⨯4=28 LED matrices fairly easily.</p>
  <p>There are a couple software options to get this running. One popular one that I've had some experience with is <code>node-poweredup</code>. Here's an <a href="https://github.com/nathankellenicki/node-poweredup/blob/master/examples/light_matrix.js" rel="nofollow noreferrer">example from the docs</a> to control a 3x3 LED matrix attached to a Control+ hub:</p>
  <pre><code>const PoweredUP = require(&quot;..&quot;);
  
  const poweredUP = new PoweredUP.PoweredUP();
  poweredUP.scan(); // Start scanning for hubs
  
  console.log(&quot;Looking for Hubs...&quot;);
  
  poweredUP.on(&quot;discover&quot;, async (hub) =&gt; { // Wait to discover hubs
  
      await hub.connect(); // Connect to hub
      console.log(`Connected to ${hub.name}!`);
  
      const matrix = await hub.waitForDeviceByType(PoweredUP.Consts.DeviceType.TECHNIC_3X3_COLOR_LIGHT_MATRIX);
  
      // setMatrix accepts an array of 9 items - Either standard color values (number),
      // or Color objects with brightness (brightness values are 0 to 100%)
      // It can also accept just a single color to set all 9 lights to the same color
      matrix.setMatrix([
          // Red at 100%, green at 20%, red at 100%
          PoweredUP.Consts.Color.RED, new PoweredUP.Color(PoweredUP.Consts.Color.GREEN, 20), PoweredUP.Consts.Color.RED,
          // Green at 100%, yellow at 100%, green at 100%
          PoweredUP.Consts.Color.GREEN, PoweredUP.Consts.Color.YELLOW, PoweredUP.Consts.Color.GREEN,
          // Red at 100%, green at 20%, red at 100%
          PoweredUP.Consts.Color.RED, new PoweredUP.Color(PoweredUP.Consts.Color.GREEN, 20), PoweredUP.Consts.Color.RED,
      ]);
  
      hub.on(&quot;disconnect&quot;, () =&gt; {
          console.log(&quot;Hub disconnected&quot;);
      })
  
  });
  </code></pre>
  <p>The above example would need to be extended to support a number of hubs and lights and provide some management to write large images in a coherent way.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-11-06T00:20:06.983Z
Answers.LastActivityDate: 2021-11-07T10:51:02.230Z
Answers.LastEditDate: 2021-11-07T10:51:02.230Z
Answers.UserDisplayName: jncraton
Body: <p>Recently the Spike essentials set was released, including the very interesting 3x3 led matrix part:</p>
  <p><a href="https://i.sstatic.net/uGWDx.png" rel="noreferrer"><img src="https://i.sstatic.net/uGWDx.png" alt="led matrix" /></a></p>
  <p>The matrix allows to set each individual pixel in the 3x3 array to 10 different shades of 10 different colors.</p>
  <p>The led matrix also works with the Spike Prime set, however, it seems currently unsupported in the Mindstorms Robotics inventor set, at least there are no word blocks for it in the IDE that you can download for the set.</p>
  <p>I'd wish to control more than one such led matrix and have purchased an additional 8 with the intention of placing them in a 3x3 array to have a larger 9x9 matrix.</p>
  <p>The hub has however only 6 ports, so I'll need an additional hub and hub to hub communication.
  Unfortunately it seems that straightforward hub to hub communication is only supported in the Robotic Inventor IDE which in turn does not support the led-matrix.</p>
  <p>What would be the easiest way to have both ? I.e. have both hub-to-hub communication and control for this new led-matrix component?</p>
  <p>I'm willing to consider micropython solutions, but would need some pointers there:</p>
  <ul>
  <li>what class do I need for the hub to hub communication in the python implementation with the native Spike Prime or Robotic Inventor firmware?</li>
  <li>what class do I need for the led matrix control with the native Spike Prime or Robotic Inventor firmware?</li>
  <li>same questions for when I would install the PyBricks micropython implementation.</li>
  </ul>
  <p>Additional question, is there any way to set the color of ONE pixel without setting an entire 3x3 picture? Seems to be missing from the word blocks while setting the brightness is present...</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-01-31T08:44:02.637Z
Comments.Text: PyBricks will probably be easier as it'll act the same on both hubs and can also be used on cheaper hubs.  (I guess that's what you've done by now since I've seen your stuff). [The PyBricks doc on the light matrix](https://code.pybricks.com/static/docs/v2.12.0/pupdevices/colorlightmatrix.html#) doesn't provide a way to address an individual light; not sure if that limitation is due to PyBricks or the hardware itself but it seems you should better keep track of lights status youself.
Comments.UserDisplayName: Joubarc
Tags: <programming><robot-inventor><spike-prime>
Title: robotic inventor\spike prime hubs: Hub 2 hub communication AND led matrix control
UserDisplayName: Michael Verschaeve
ThreadText: # robotic inventor\spike prime hubs: Hub 2 hub communication AND led matrix control
  
  (Asked by: username_0 on 2021-10-26)
  
  Recently the Spike essentials set was released, including the very interesting 3x3 led matrix part:
  
  [![led matrix](https://i.sstatic.net/uGWDx.png)](https://i.sstatic.net/uGWDx.png)
  
  The matrix allows to set each individual pixel in the 3x3 array to 10 different shades of 10 different colors.
  
  The led matrix also works with the Spike Prime set, however, it seems currently unsupported in the Mindstorms Robotics inventor set, at least there are no word blocks for it in the IDE that you can download for the set.
  
  I'd wish to control more than one such led matrix and have purchased an additional 8 with the intention of placing them in a 3x3 array to have a larger 9x9 matrix.
  
  The hub has however only 6 ports, so I'll need an additional hub and hub to hub communication.
  Unfortunately it seems that straightforward hub to hub communication is only supported in the Robotic Inventor IDE which in turn does not support the led-matrix.
  
  What would be the easiest way to have both ? I.e. have both hub-to-hub communication and control for this new led-matrix component?
  
  I'm willing to consider micropython solutions, but would need some pointers there:
  
  * what class do I need for the hub to hub communication in the python implementation with the native Spike Prime or Robotic Inventor firmware?
  * what class do I need for the led matrix control with the native Spike Prime or Robotic Inventor firmware?
  * same questions for when I would install the PyBricks micropython implementation.
  
  Additional question, is there any way to set the color of ONE pixel without setting an entire 3x3 picture? Seems to be missing from the word blocks while setting the brightness is present...
  
  **Tags:** programming, robot-inventor, spike-prime
  
  > **Comments:**
  > **username_1**: PyBricks will probably be easier as it'll act the same on both hubs and can also be used on cheaper hubs.  (I guess that's what you've done by now since I've seen your stuff). [The PyBricks doc on the light matrix](https://code.pybricks.com/static/docs/v2.12.0/pupdevices/colorlightmatrix.html#) doesn't provide a way to address an individual light; not sure if that limitation is due to PyBricks or the hardware itself but it seems you should better keep track of lights status youself.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2021-11-06. Score: 2
  
  This isn't a direct answer to your question, but it would be one way to solve the problem. Instead of using the hubs from SPIKE or Robot Inventor, you could use the Control+ hub:
  
  [![Control+ Hub](https://i.sstatic.net/ot1PD.png)](https://i.sstatic.net/ot1PD.png)
  
  This hub unfortunately only supports 4 peripherals, so you would need three of them. This hub is not programmable, but it can be controlled over Bluetooth. You can pair up to 7 hubs to a single device this way, so you could control up to 7⨯4=28 LED matrices fairly easily.
  
  There are a couple software options to get this running. One popular one that I've had some experience with is `node-poweredup`. Here's an [example from the docs](https://github.com/nathankellenicki/node-poweredup/blob/master/examples/light_matrix.js) to control a 3x3 LED matrix attached to a Control+ hub:
  
  ```
  const PoweredUP = require("..");
  
  const poweredUP = new PoweredUP.PoweredUP();
  poweredUP.scan(); // Start scanning for hubs
  
  console.log("Looking for Hubs...");
  
  poweredUP.on("discover", async (hub) => { // Wait to discover hubs
  
      await hub.connect(); // Connect to hub
      console.log(`Connected to ${hub.name}!`);
  
      const matrix = await hub.waitForDeviceByType(PoweredUP.Consts.DeviceType.TECHNIC_3X3_COLOR_LIGHT_MATRIX);
  
      // setMatrix accepts an array of 9 items - Either standard color values (number),
      // or Color objects with brightness (brightness values are 0 to 100%)
      // It can also accept just a single color to set all 9 lights to the same color
      matrix.setMatrix([
          // Red at 100%, green at 20%, red at 100%
          PoweredUP.Consts.Color.RED, new PoweredUP.Color(PoweredUP.Consts.Color.GREEN, 20), PoweredUP.Consts.Color.RED,
          // Green at 100%, yellow at 100%, green at 100%
          PoweredUP.Consts.Color.GREEN, PoweredUP.Consts.Color.YELLOW, PoweredUP.Consts.Color.GREEN,
          // Red at 100%, green at 20%, red at 100%
          PoweredUP.Consts.Color.RED, new PoweredUP.Color(PoweredUP.Consts.Color.GREEN, 20), PoweredUP.Consts.Color.RED,
      ]);
  
      hub.on("disconnect", () => {
          console.log("Hub disconnected");
      })
  
  });
  
  ```
  
  The above example would need to be extended to support a number of hubs and lights and provide some management to write large images in a coherent way.
  
  
  ---
  
  