<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[RemoteXY community — Edit Field, Returns only value of zero]]></title>
	<link rel="self" href="https://forum.remotexy.com/extern.php?action=feed&amp;tid=890&amp;type=atom" />
	<updated>2020-02-03T17:25:32Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.remotexy.com/viewtopic.php?id=890</id>
		<entry>
			<title type="html"><![CDATA[Re: Edit Field, Returns only value of zero]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=2543#p2543" />
			<content type="html"><![CDATA[<p>Welcome,</p><div class="codebox"><pre><code>int val1 = atoi (RemoteXY.edit_1);</code></pre></div><p>How does this even compiles ? atoi is to convert a char array into int, but RemoteXY.edit_1 is already an int.</p><p>I can only assume that in the remotexy editor, the type of &quot;edit_1&quot; was String, and then you changed the type to Integer.</p><p>And if you really want the type to be Integer, then I suppose you simply want to do this:<br /></p><div class="codebox"><pre><code>itoa(RemoteXY.edit_1, RemoteXY.text_1, 10);</code></pre></div><br /><p>A side note about improving your code, it&#039;s generally better to do something only when needed, instead of doing it every time loop() is run. You are constantly writing to RemoteXY.text_1 and RemoteXY.led_1_r, and it is more efficient (for your whole program, not for remotexy) to only do that when the values changed :<br /></p><div class="codebox"><pre><code>void loop() 
{ 
  RemoteXY_Handler ();

  static int16_t edit_1_previousValue = RemoteXY.edit_1;
  if (edit_1_previousValue != RemoteXY.edit_1)
  {
    edit_1_previousValue = RemoteXY.edit_1;
    itoa(RemoteXY.edit_1, RemoteXY.text_1, 10);
  }

  static uint8_t button_1_previousValue = RemoteXY.button_1;
  if (button_1_previousValue != RemoteXY.button_1)
  {
    button_1_previousValue = RemoteXY.button_1;
    RemoteXY.led_1_r = RemoteXY.button_1 == 1 ? 255 : 0;
  }
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Guillaume]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=23</uri>
			</author>
			<updated>2020-02-03T17:25:32Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=2543#p2543</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Edit Field, Returns only value of zero]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=2541#p2541" />
			<content type="html"><![CDATA[<p>Hello!</p><p>I am having an issue with the edit fields in my project... Simply put, no matter what value I enter into the field it returns zero. I have it configured as integer on both the project and in the Arduino sketch. Hardware is Arduino Nano and HC-06 with the app running on Galaxy S10.</p><p>I created a test project and a test sketch to reproduce the issue outside my production program and was able to isolate and&nbsp; reproduce the issue.</p><p>This was working flawlessly at one time and then it stopped working when I updated the Arduino with a new sketch. I did some trouble shooting and replacing every bit of hardware and exhausting every other resource lead me here for your help. I am using the latest library.</p><p>I am hoping I&#039;m not missing anything obvious because that wouldn&#039;t be the first time. I have been at this for days and can&#039;t figure it out.</p><p>I appreciate any input you can give and kind regards!</p><p><a target="_blank" href="http://remotexy.com/en/editor/a04c8ef80be7e66da00fbdf4c34f0624/">http://remotexy.com/en/editor/a04c8ef80 … 4c34f0624/</a></p><div class="codebox"><pre><code>/*
   -- TestEditField --
   
   This source code of graphical user interface 
   has been generated automatically by RemoteXY editor.
   To compile this code using RemoteXY library 2.4.3 or later version 
   download by link http://remotexy.com/en/library/
   To connect using RemoteXY mobile app by link http://remotexy.com/en/download/                   
     - for ANDROID 4.3.1 or later version;
     - for iOS 1.3.5 or later version;
    
   This source code is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version.    
*/

//////////////////////////////////////////////
//        RemoteXY include library          //
//////////////////////////////////////////////

// RemoteXY select connection mode and include library 
#define REMOTEXY_MODE__SOFTSERIAL
#include &lt;SoftwareSerial.h&gt;

#include &lt;RemoteXY.h&gt;

// RemoteXY connection settings 
#define REMOTEXY_SERIAL_RX 2
#define REMOTEXY_SERIAL_TX 3
#define REMOTEXY_SERIAL_SPEED 9600


// RemoteXY configurate  
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
  { 255,3,0,12,0,37,0,8,13,0,
  7,52,23,12,20,5,2,26,2,67,
  4,23,36,20,5,2,26,11,65,4,
  57,22,9,9,1,0,72,20,12,12,
  2,31,88,0 };
  
// this structure defines all the variables of your control interface 
struct {

    // input variable
  int16_t edit_1;  // −32767.. +32767 
  uint8_t button_1; // =1 if button pressed, else =0 

    // output variable
  char text_1[11];  // string UTF8 end zero 
  uint8_t led_1_r; // =0..255 LED Red brightness 

    // other variable
  uint8_t connect_flag;  // =1 if wire connected, else =0 

} RemoteXY;
#pragma pack(pop)

/////////////////////////////////////////////
//           END RemoteXY include          //
///////////////////////////////////////////// 



void setup() 
{
  RemoteXY_Init (); 
  
  
  // TODO you setup code
  
}

void loop() 
{ 
  RemoteXY_Handler ();
  int val1 = atoi (RemoteXY.edit_1);
  itoa(val1, RemoteXY.text_1, 10);

  if (RemoteXY.button_1 != 0)
    {
      RemoteXY.led_1_r = 255;
    }
    else
    {
      RemoteXY.led_1_r = 0;
    }
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[brodix32]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=1202</uri>
			</author>
			<updated>2020-02-02T18:13:30Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=2541#p2541</id>
		</entry>
</feed>
