1

Topic: Button "hold" time....

It would be great if the RemoteXY buttons had a parameter that says the button has to be down for a minimum time before it is sent to the host.

Using touch screen phones it would be easy to create nuisance button presses which could be disastrous ....

Yes, I know we can code for that scenario in our sketches, but it would be much much simpler to set the timing parameter in the RemoteXY GUI.

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

2

Re: Button "hold" time....

I made an operation here, I think this may be useful for you, so I can find out how many seconds the button was pressed.

const int KISABASMA = 1000; // 1000 milliseconds
const int UZUNBASMA  = 1000; // 1000 milliseconds

int PRESET1SONDURUM = LOW;  // the previous state from the input pin
int PRESET1DURUM;     // the current reading from the input pin
unsigned long PRESET1BASILMA  = 0;
unsigned long PRESET1CEKME = 0;

void PRESET1 ()
{
  PRESET1DURUM = RemoteXY.PRESET1;

  if(PRESET1SONDURUM == LOW && PRESET1DURUM == HIGH)        // BUTONA BASILDIGINDA
    PRESET1BASILMA = millis();
  else if(PRESET1SONDURUM == HIGH && PRESET1DURUM == LOW) { // BUTONDAN CEKILDIGINDE
    PRESET1CEKME = millis();

    long PRESET1BASILMASURESI = PRESET1CEKME - PRESET1BASILMA;

    if( PRESET1BASILMASURESI < KISABASMA )
    {
    Serial.println("PRESET-1 CAGIRILDI");
    RemoteXY.RGB_1_r = EEPROM.read(15);
    RemoteXY.RGB_1_g = EEPROM.read(16);
    RemoteXY.RGB_1_b = EEPROM.read(17);
    RemoteXY.RGB_2_r = EEPROM.read(18);
    RemoteXY.RGB_2_g = EEPROM.read(19);
    RemoteXY.RGB_2_b = EEPROM.read(20);
    RemoteXY.RGB_3_r = EEPROM.read(21);
    RemoteXY.RGB_3_g = EEPROM.read(22);
    RemoteXY.RGB_3_b = EEPROM.read(23);
    RemoteXY.RGB_4_r = EEPROM.read(24);
    RemoteXY.RGB_4_g = EEPROM.read(25);
    RemoteXY.RGB_4_b = EEPROM.read(26);
    RemoteXY.RGB_5_r = EEPROM.read(27);
    RemoteXY.RGB_5_g = EEPROM.read(28);
    RemoteXY.RGB_5_b = EEPROM.read(29);
    EPPROMLARAYAZ ();
    }


    if( PRESET1BASILMASURESI > UZUNBASMA )
    {
    Serial.println("PRESET-1 KAYDEDILDI");
    EEPROM.write(15,RemoteXY.RGB_1_r);
    EEPROM.commit();
    EEPROM.write(16,RemoteXY.RGB_1_g);
    EEPROM.commit();
    EEPROM.write(17,RemoteXY.RGB_1_b);
    EEPROM.commit();
    EEPROM.write(18,RemoteXY.RGB_2_r);
    EEPROM.commit();
    EEPROM.write(19,RemoteXY.RGB_2_g);
    EEPROM.commit();
    EEPROM.write(20,RemoteXY.RGB_2_b);
    EEPROM.commit();
    EEPROM.write(21,RemoteXY.RGB_3_r);
    EEPROM.commit();
    EEPROM.write(22,RemoteXY.RGB_3_g);
    EEPROM.commit();
    EEPROM.write(23,RemoteXY.RGB_3_b);
    EEPROM.commit();
    EEPROM.write(24,RemoteXY.RGB_4_r);
    EEPROM.commit();
    EEPROM.write(25,RemoteXY.RGB_4_g);
    EEPROM.commit();
    EEPROM.write(26,RemoteXY.RGB_4_b);
    EEPROM.commit();
    EEPROM.write(27,RemoteXY.RGB_5_r);
    EEPROM.commit();
    EEPROM.write(28,RemoteXY.RGB_5_g);
    EEPROM.commit();
    EEPROM.write(29,RemoteXY.RGB_5_b);
    EEPROM.commit();
    EPPROMLARAYAZ ();
    RemoteXY.PRESET1RGBLED1_r = EEPROM.read(15);
    RemoteXY.PRESET1RGBLED1_g = EEPROM.read(16);
    RemoteXY.PRESET1RGBLED1_b = EEPROM.read(17);
    RemoteXY.PRESET1RGBLED2_r = EEPROM.read(18);
    RemoteXY.PRESET1RGBLED2_g = EEPROM.read(19);
    RemoteXY.PRESET1RGBLED2_b = EEPROM.read(20);
    RemoteXY.PRESET1RGBLED3_r = EEPROM.read(21);
    RemoteXY.PRESET1RGBLED3_g = EEPROM.read(22);
    RemoteXY.PRESET1RGBLED3_b = EEPROM.read(23);
    RemoteXY.PRESET1RGBLED4_r = EEPROM.read(24);
    RemoteXY.PRESET1RGBLED4_g = EEPROM.read(25);
    RemoteXY.PRESET1RGBLED4_b = EEPROM.read(26);
    RemoteXY.PRESET1RGBLED5_r = EEPROM.read(27);
    RemoteXY.PRESET1RGBLED5_g = EEPROM.read(28);
    RemoteXY.PRESET1RGBLED5_b = EEPROM.read(29);
    }
  }
  PRESET1SONDURUM = PRESET1DURUM;
}

3

Re: Button "hold" time....

FIRE button and entering a password when it is pressed)). Yes, it is interesting. Let's think.

4

Re: Button "hold" time....

remotexy wrote:

FIRE button and entering a password when it is pressed)). Yes, it is interesting. Let's think.

I like it, "Confirm with your password", a switchable attribute, not all elements will need it.

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

5

Re: Button "hold" time....

remotexy wrote:

FIRE button and entering a password when it is pressed)). Yes, it is interesting. Let's think.

Another interesting idea ....

You are using a uint8_t variable to convey the state of a button, 0 or 1.

Could you not use the other 7 bits to convey a 100mS count of how long the button was pressed. Doing so would relieve the tedium of having to do our own timing in our sketches.  7 bits would allow for a count of 127, allowing for a "hold" timer of up to 12.7 seconds, plenty long enough for most functions.

Even better if the variable = zero, button up, and if non-zero, the button is down, and the positive count is the number of 100mS clocks it was held for, giving up to 25.5 seconds before rollover.  That initial 100mS before the button is declared down would be a useful "de-bounce" time.

I'm all for using the space you have already allocated for something useful, and my suggestion would not incur any data transfer or bandwidth penalties.

I'm guessing the 100mS clock count doesn't need to be that accurate either, around 25 seconds would be more than ample for detecting a button "held" situation.

Here's the code I am using to implement a "reset timers" function....

// reset button code
switch(GUI.hours_reset) {
  case 0:
    reset_start_time = millis();  // keep tracking while button off
    break;
  case 1:
  // reset button has to be held for 10 seconds
  if(millis() >= reset_start_time + 10000) {
    EPD.hours_run = EPD.minutes_run = seconds_run = 0;
    update_EPD();
    GUI.hours_reset = 0;          // kill the button
    } // if(millis() >= reset_start_time + 10000)
    break;
} // switch(GUI.hours_reset)

How much simpler it could be....

// reset button code
if(GUI.hours_reset>100) {      // 100 * 100mS = 10 Seconds
    EPD.hours_run = EPD.minutes_run = seconds_run = 0;
    update_EPD();
    GUI.hours_reset = 0;          // kill the button
} // if(GUI.hours_reset>100)
2B, or not 2B, that is the pencil ...