<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[RemoteXY community — Arrays of devices - indirect addressing]]></title>
	<link rel="self" href="https://forum.remotexy.com/extern.php?action=feed&amp;tid=1906&amp;type=atom" />
	<updated>2025-01-07T09:18:57Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.remotexy.com/viewtopic.php?id=1906</id>
		<entry>
			<title type="html"><![CDATA[Re: Arrays of devices - indirect addressing]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=5852#p5852" />
			<content type="html"><![CDATA[<p>I have sorted the problem with the app crashing.</p><p>I had a page where I could see the called numbers.</p><p>I moved all of the indicators to the main page, but left the empty page in the configuration. That causes the app to crash on trying to connect.&nbsp; I deleted the page and everything works again.</p>]]></content>
			<author>
				<name><![CDATA[Daba]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=630</uri>
			</author>
			<updated>2025-01-07T09:18:57Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=5852#p5852</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Arrays of devices - indirect addressing]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=5851#p5851" />
			<content type="html"><![CDATA[<p>OK, so I think I&#039;ve got this working.</p><p>Had an issue where the led that lit up was 1 greater than the *ledLinks[{variable}], and then I noticed that the links are addressed from 0.&nbsp; Changed my code accordingly, and think it&#039;s going to work, but I cannot test because every time I try to connect with the board, the app just shuts down.&nbsp; I&#039;ve tried with both my iPad, and iPhone, they both do the same. Both can see the WiFi, so I don&#039;t know what the problem is.</p><p>I&#039;ve shared link to the RemoteXY project, hope you can see if there is anything wrong with it.</p><p><a target="_blank" href="https://remotexy.com/en/editor/d62dd980139c277dc84c9a8692356677/">https://remotexy.com/en/editor/d62dd980 … 692356677/</a></p><p>And here&#039;s the project code.&nbsp; Not complete just yet, bit of more work to do....&nbsp; Note the GUI configuration is on another tab, and included. You can regenerate it from the shared project&nbsp; ?</p><div class="codebox"><pre><code>// pRojeCt BINGO
// 
// License: Public Domain.

// Bingo number colours
#define bingo_blu 1
#define bingo_grn 2
#define bingo_red 3
#define bingo_yel 4
#define bingo_pnk 5

#include &quot;RemoteXY.hpp&quot; 
#include &lt;EEPROM.h&gt;

uint8_t topoftheshop;
uint8_t ball_called;
uint16_t called_number_sound = 1046;
uint16_t called_number_timing = 300;

uint8_t *ledLinks[] = {
  &amp;RemoteXY.led_01,
  &amp;RemoteXY.led_02,
  &amp;RemoteXY.led_03,
  &amp;RemoteXY.led_04,
  &amp;RemoteXY.led_05,
  &amp;RemoteXY.led_06,
  &amp;RemoteXY.led_07,
  &amp;RemoteXY.led_08,
  &amp;RemoteXY.led_09,
  &amp;RemoteXY.led_10,
  &amp;RemoteXY.led_11,
  &amp;RemoteXY.led_12,
  &amp;RemoteXY.led_13,
  &amp;RemoteXY.led_14,
  &amp;RemoteXY.led_15,
  &amp;RemoteXY.led_16,
  &amp;RemoteXY.led_17,
  &amp;RemoteXY.led_18,
  &amp;RemoteXY.led_19,
  &amp;RemoteXY.led_20,
  &amp;RemoteXY.led_21,
  &amp;RemoteXY.led_22,
  &amp;RemoteXY.led_23,
  &amp;RemoteXY.led_24,
  &amp;RemoteXY.led_25,
  &amp;RemoteXY.led_26,
  &amp;RemoteXY.led_27,
  &amp;RemoteXY.led_28,
  &amp;RemoteXY.led_29,
  &amp;RemoteXY.led_30,
  &amp;RemoteXY.led_31,
  &amp;RemoteXY.led_32,
  &amp;RemoteXY.led_33,
  &amp;RemoteXY.led_34,
  &amp;RemoteXY.led_35,
  &amp;RemoteXY.led_36,
  &amp;RemoteXY.led_37,
  &amp;RemoteXY.led_38,
  &amp;RemoteXY.led_39,
  &amp;RemoteXY.led_40,
  &amp;RemoteXY.led_41,
  &amp;RemoteXY.led_42,
  &amp;RemoteXY.led_43,
  &amp;RemoteXY.led_44,
  &amp;RemoteXY.led_45,
  &amp;RemoteXY.led_46,
  &amp;RemoteXY.led_47,
  &amp;RemoteXY.led_48,
  &amp;RemoteXY.led_49,
  &amp;RemoteXY.led_50,
  &amp;RemoteXY.led_51,
  &amp;RemoteXY.led_52,
  &amp;RemoteXY.led_53,
  &amp;RemoteXY.led_54,
  &amp;RemoteXY.led_55,
  &amp;RemoteXY.led_56,
  &amp;RemoteXY.led_57,
  &amp;RemoteXY.led_58,
  &amp;RemoteXY.led_59,
  &amp;RemoteXY.led_60,
  &amp;RemoteXY.led_61,
  &amp;RemoteXY.led_62,
  &amp;RemoteXY.led_63,
  &amp;RemoteXY.led_64,
  &amp;RemoteXY.led_65,
  &amp;RemoteXY.led_66,
  &amp;RemoteXY.led_67,
  &amp;RemoteXY.led_68,
  &amp;RemoteXY.led_69,
  &amp;RemoteXY.led_70,
  &amp;RemoteXY.led_71,
  &amp;RemoteXY.led_72,
  &amp;RemoteXY.led_73,
  &amp;RemoteXY.led_74,
  &amp;RemoteXY.led_75,
  &amp;RemoteXY.led_76,
  &amp;RemoteXY.led_77,
  &amp;RemoteXY.led_78,
  &amp;RemoteXY.led_79,
  &amp;RemoteXY.led_80,
  &amp;RemoteXY.led_81,
  &amp;RemoteXY.led_82,
  &amp;RemoteXY.led_83,
  &amp;RemoteXY.led_84,
  &amp;RemoteXY.led_85,
  &amp;RemoteXY.led_86,
  &amp;RemoteXY.led_87,
  &amp;RemoteXY.led_88,
  &amp;RemoteXY.led_89,
  &amp;RemoteXY.led_90
};


void setup() {
  // put your setup code here, to run once:
  RemoteXY_Init();
  randomSeed(analogRead(A0));
  called_number_indicators_reset();
  Serial.begin(115200);
  
  
}

void loop() {
  // put your main code here, to run repeatedly:

  RemoteXY_Handler();

  switch(RemoteXY.game_select) {
    case 0:  // 1-75
      topoftheshop = 75;
      RemoteXY.hide_76_80 = 1;
      RemoteXY.hide_81_90 = 1;
      break;

    case 1:  // 1-80
      topoftheshop = 80;
      RemoteXY.hide_76_80 = 0;
      RemoteXY.hide_81_90 = 1;
      break; 

    case 2: // 1-90
      topoftheshop = 90;
      RemoteXY.hide_76_80 = 0;
      RemoteXY.hide_81_90 = 0;
      break;    
  }

  if(RemoteXY.ball_gen) {
    RemoteXY.ball_gen = 0;

    // get a new random number
    // and test to see if ok
    do (ball_called=random(1, topoftheshop + 1));
    while (*ledLinks[ball_called] == 1);

    // called ball is valid, and new
    Serial.print(&quot;Ball Called &quot;);
    Serial.println(ball_called);

    RemoteXY.called_number = ball_called;
    RemoteXY.called_sound = called_number_sound;
    delay(called_number_timing);
    RemoteXY.called_sound = 0;
    
    *ledLinks[ball_called - 1] = 1;
    
  }


}

void called_number_indicators_reset() {
  for (int i = 0; i &lt; 90; i++) {
   *ledLinks[i] = 0;
   }
  }</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Daba]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=630</uri>
			</author>
			<updated>2025-01-06T16:38:36Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=5851#p5851</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Arrays of devices - indirect addressing]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=5850#p5850" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>remotexy wrote:</cite><blockquote><p>yes, that&#039;s an interesting idea, maybe we&#039;ll do that in the future. There are more important tasks now. But I&#039;ll give you an example of how you can simplify your code. You can create a second array with references to variables in the RemoteXY structure and use it for cyclic operations.</p><div class="codebox"><pre><code>struct {
    // output variables
  uint8_t led_03; // from 0 to 1
  uint8_t led_05; // from 0 to 1
  uint8_t led_01; // from 0 to 1
  uint8_t led_04; // from 0 to 1
  uint8_t led_02; // from 0 to 1

} RemoteXY;  

uint8_t *ledLinks[] = {
  &amp;RemoteXY.led_01, 
  &amp;RemoteXY.led_02,
  &amp;RemoteXY.led_03,
  &amp;RemoteXY.led_04,
  &amp;RemoteXY.led_05
};

void loop() 
{ 
  RemoteXY_Handler ();

  for (int i = 0; i &lt; 5; i++) {
     *ledLinks[i] = 1;
  }
}</code></pre></div></blockquote></div><p>It looks like that is exactly what I am hoping for, but you said &quot;for cyclic tasks). Does this mean there&#039;s no relationship to the LED numbers, and the ledlinks just go through the RemoteXY array in the order they appear in the interface struct ?</p><p>If I have skillfully created my LEDs in the correct order, can I address them individually ?</p><p>Like....</p><div class="codebox"><pre><code>void called_number_indicators_reset() {
 for (int i = 0; i &lt; 91; i++) {
     *ledLinks[i] = 0;
  }
}

void called_number_indicators() {
   *ledLinks[ball_called] = 1;

  
//  if(ball_called == 1) RemoteXY.led_01 = 1;
//  if(ball_called == 2) RemoteXY.led_02 = 1;
//  if(ball_called == 3) RemoteXY.led_03 = 1;
//  if(ball_called == 4) RemoteXY.led_04 = 1;
....
//  if(ball_called == 90) RemoteXY.led_90 = 1;</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Daba]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=630</uri>
			</author>
			<updated>2025-01-06T13:35:46Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=5850#p5850</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Arrays of devices - indirect addressing]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=5846#p5846" />
			<content type="html"><![CDATA[<p>yes, that&#039;s an interesting idea, maybe we&#039;ll do that in the future. There are more important tasks now. But I&#039;ll give you an example of how you can simplify your code. You can create a second array with references to variables in the RemoteXY structure and use it for cyclic operations.</p><div class="codebox"><pre><code>struct {
    // output variables
  uint8_t led_03; // from 0 to 1
  uint8_t led_05; // from 0 to 1
  uint8_t led_01; // from 0 to 1
  uint8_t led_04; // from 0 to 1
  uint8_t led_02; // from 0 to 1

} RemoteXY;  

uint8_t *ledLinks[] = {
  &amp;RemoteXY.led_01, 
  &amp;RemoteXY.led_02,
  &amp;RemoteXY.led_03,
  &amp;RemoteXY.led_04,
  &amp;RemoteXY.led_05
};

void loop() 
{ 
  RemoteXY_Handler ();

  for (int i = 0; i &lt; 5; i++) {
     *ledLinks[i] = 1;
  }
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[remotexy]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=2</uri>
			</author>
			<updated>2025-01-06T08:56:43Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=5846#p5846</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Arrays of devices - indirect addressing]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=5841#p5841" />
			<content type="html"><![CDATA[<p>I&#039;m tasked with creating a Bingo calling machine. Don&#039;t ask why, but it&#039;s there.</p><p>My code is sprawling out of control, because I have to address each &quot;Called Number Indication&quot; LED on the GUI independently. </p><p>So I have 90 statements to reset them, 90 statements to turn them on, 90 statements to map the internal array to the RemoteXY GUI, etc. etc. It is getting tedious to the extreme.</p><p>It would be great, and I have touched on this subject before, if we could have <strong>arrays</strong> of devices like Buttons and LEDs, addressing them by their index number.&nbsp; This would certainly make coding easier in many applications.</p><p>I don&#039;t see why this technique couldn&#039;t be extended to all of the GUI elements.</p>]]></content>
			<author>
				<name><![CDATA[Daba]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=630</uri>
			</author>
			<updated>2025-01-05T06:31:44Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=5841#p5841</id>
		</entry>
</feed>
