1 (edited by Guillaume 2017-01-14 16:43:48)

Topic: Ability to set the state of Controls, from code.

Hi,

Currently we can set the color of a Led, modify a Text, etc, but why can't we set the state of Controls ?

Let's say I have a Switch to control a relay, but the code can also take control of the relay. So if the code change the state of the relay, actually, the UI can't reflect this change.

In code words, why are such variables read-only ?

uint8_t switch_1; /* =1 if switch ON and =0 if OFF */
uint8_t select_1; /* =0 if select position A, =1 if position B, =2 if position C, ... */
... and all other controls, except Button maybe :)

More than a new feature to be added, I actually think it's a bug to be fixed big_smile

2

Re: Ability to set the state of Controls, from code.

It is not bug.
Variable is transmitted in one direction.

How use two modes "Manual" and "Auto"?
I want to show the simple project "PUMP SIMULATION".

Interfase: http://remotexy.com/en/editor/85eecbc8b … 6d813ccb6/
Full code for bluetooth HC-06:

//////////////////////////////////////////////
//        RemoteXY include library          //
//     use  library  version 2.2.5 or up    //
//   use ANDROID app version 3.7.1 or up    //
//////////////////////////////////////////////

/* 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[] = 
  { 4,2,237,0,6,0,2,7,54,4
  ,30,32,10,4,70,32,11,5,2,0
  ,4,10,31,10,4,12,31,10,2,77
  ,65,78,85,65,76,0,65,85,84,79
  ,0,2,0,4,49,31,10,4,39,31
  ,10,2,79,78,0,79,70,70,0,66
  ,1,44,3,36,47,41,6,10,77,5
  ,65,4,48,52,9,9,16,87,9,9
  ,2,129,0,6,30,18,6,4,75,0
  ,6,0,0,129,0,82,45,9,6,53
  ,79,6,4,9,48,37,0,129,0,82
  ,24,9,6,53,42,8,4,9,53,48
  ,37,0,129,0,81,3,15,6,52,7
  ,11,4,9,49,48,48,37,0,129,0
  ,4,23,31,6,4,64,24,5,8,65
  ,117,116,111,32,108,101,118,101,108,58
  ,0,129,0,3,3,34,6,4,5,29
  ,5,8,80,117,109,112,32,109,111,100
  ,101,0,129,0,4,43,21,6,4,32
  ,18,5,8,77,97,110,117,97,108,0
  ,130,1,3,22,36,19,2,30,35,23
  ,0,130,1,3,42,36,18,2,58,35
  ,25,0,129,0,60,54,18,6,28,89
  ,26,6,3,80,117,109,112,32,111,110
  ,0 }; 
   
/* this structure defines all the variables of your control interface */ 
struct { 

    /* input variable */
  int16_t edit_level;  /* −32767.. +32767 */
  uint8_t switch_manual; /* =1 if switch ON and =0 if OFF */
  uint8_t switch_pump; /* =1 if switch ON and =0 if OFF */

    /* output variable */
  int8_t level; /* =0..100 level position */
  uint8_t led_on_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          // 
///////////////////////////////////////////// 

float level = 50.0;
boolean pump = false;

void setup()  
{ 
  RemoteXY_Init ();  
   
  RemoteXY.edit_level = 50;
   
} 

long pt=0;

void loop()  
{  
  RemoteXY_Handler (); 

  // TIME COUNTER
  long t = millis ();
  long dt = t - pt;
  pt = t;
  
  // PUMP EMULATION 
  level = level + 0.001*dt; 
  if (pump) level=level-0.003*dt;
  if (level<0) level = 0;
  if (level>100) level = 100;

  // MAIN CODE
  if (RemoteXY.switch_manual == 1) {
    if (RemoteXY.switch_pump == 1) pump = true;
    else pump = false;
  }
  else {
    if ((level>RemoteXY.edit_level+5) && (!pump)) pump = true;
    if ((level<RemoteXY.edit_level-5) && (pump)) pump = false;    
  }
   
  RemoteXY.level = level;
  if (pump) RemoteXY.led_on_r = 255;
  else RemoteXY.led_on_r = 0;

  delay (2);
}

3

Re: Ability to set the state of Controls, from code.

thats fine for your 'pump-station'
but things, which are connected to the internet may want to change some values over the air or via integrated sensors - and if that happens, you never recognize this in this app.

4

Re: Ability to set the state of Controls, from code.

changes displayed by reconnecting

5

Re: Ability to set the state of Controls, from code.

mefi73 wrote:

changes displayed by reconnecting

Yes I noticed this too. So instead of reconnecting, and if this feature that we are discussing is not added, maybe we could at least have a function RemoteXY.UpdateInputs() or something like that ? smile

6

Re: Ability to set the state of Controls, from code.

Guillaume wrote:

Yes I noticed this too. So instead of reconnecting, and if this feature that we are discussing is not added, maybe we could at least have a function RemoteXY.UpdateInputs() or something like that ? smile

I like it. Will think)

7

Re: Ability to set the state of Controls, from code.

Hello, is there a solution in this case? otherwise we would have to deal with a webserver, which we do not want at the moment, because this software is otherwise absolutely top. regards

8

Re: Ability to set the state of Controls, from code.

remotexy wrote:

I like it. Will think)

Have you had enough time to think ?

The control should not display what it is sending - it should be displaying what is set in the control code, Read before write, and only write (once) if the control is activated on the phone.  Currently the phone app is sending all the time, which means we cannot overwrite it.  If it was reading all the time, and only sending when changed on the phone, we could update the value at either location, and the control would reflect any changes.

2B, or not 2B, that is the pencil ...