1

Topic: Edit Field, Returns only value of zero

Hello!

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.

I created a test project and a test sketch to reproduce the issue outside my production program and was able to isolate and  reproduce the issue.

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.

I am hoping I'm not missing anything obvious because that wouldn't be the first time. I have been at this for days and can't figure it out.

I appreciate any input you can give and kind regards!

http://remotexy.com/en/editor/a04c8ef80 … 4c34f0624/

/*
   -- 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 <SoftwareSerial.h>

#include <RemoteXY.h>

// 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;
    }
}

2 (edited by Guillaume 2020-02-03 17:40:23)

Re: Edit Field, Returns only value of zero

Welcome,

int val1 = atoi (RemoteXY.edit_1);

How does this even compiles ? atoi is to convert a char array into int, but RemoteXY.edit_1 is already an int.

I can only assume that in the remotexy editor, the type of "edit_1" was String, and then you changed the type to Integer.

And if you really want the type to be Integer, then I suppose you simply want to do this:

itoa(RemoteXY.edit_1, RemoteXY.text_1, 10);

A side note about improving your code, it'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 :

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;
  }
}