double click without clickbutton.h

Hi

I am starting a new thread because I am locked out of the old one. I have no idea why. Anyway, please find attached the sketch I have been working on to get a double click without using clickbutton.h.

I have given up completely. I think this comes down to my lack of knowledge of the other functions. Anyway, any help to code a double click would be great. I understand I would have to tune it, but once there I can start to write the dive routines, and then the surfacing routines.

It would be so good to get past this block.

Note the code here drives the relays to my satisfaction. I haven’t cleaned it up yet, and you can see the wreckage of my attempts to get it going.

John

doubleclickattempt.txt (13.9 KB)

Can you please give me a clue as to where in the 500+ lines of code you posted you are trying to implement a double click ? An indication of what the program is supposed to do would also be helpful.

UKHeliBob:
Can you please give me a clue as to where in the 500+ lines of code you posted you are trying to implement a double click ? An indication of what the program is supposed to do would also be helpful.

I asked for that THREE times in the previous Thread

...R

I also tole you I couldn’t post it all etc etc and tried to send you only the bits that were needed then to be told to provide the whpo;le thing. Scroll down and I have noted where I have been trying to get this done

doubleclickattempt.txt (14 KB)

I think you’re missing the point that while you well understand what you’re trying to do, it is not at all obvious to the newcomers to your project that you’re seeking help from.

However, see if you can make any use of the below - I’ve left placeholders from your code to show where I put my three pieces.

unsigned long DIVECLICKONEtimer;

const unsigned long CLICK_INTERVAL = 500; // Max time in milliseconds between 'click' events to be recognized as a double click
unsigned long       ClickTime;            // Time when a 'click' (unBallastIn > 1800) was seen
unsigned long       PrevunBallastIn;      // Prior value ofunBallastIn - used to detect a transition over 1800 - a 'click'
  if (LATCH1, HIGH)
  {         
    digitalWrite(DIVECLICKTWO, HIGH);     
  }
  
  if(unBallastIn > 1800 && PrevunBallastIn < 1800) // Just went over 1800. Might want to add a little hysteresis here.
    {
    PrevunBallastIn = unBallastIn; // Stop this triggering again
    if(millis()-ClickTime < CLICK_INTERVAL)
      {
      Serial.println("Double click detected"); 
      ClickTime = 0L; // Stop any more double clicks being detected using this one
      }
    else
      {
      ClickTime = millis();  
      }  
    }
  // check shared update flags to see if any channels have a new signal
  if(bUpdateFlagsShared)
  {
    PrevunBallastIn = unBallastIn;

Not tested, obviously.

wildbill:
I think you're missing the point that while you well understand what you're trying to do, it is not at all obvious to the newcomers to your project that you're seeking help from.

Exactly.

...R

R

Thank you very much. It works very nicely and I think I would need to be a long way down the arduino track to replicate it. I will now get to work to try to understand it, and then finish this project off. Once thanks so much!

John

Sorry it is Wild Bill

Thank you very much. It works very nicely and I think I would need to be a long way down the arduino track to replicate it. I will now get to work to try to understand it, and then finish this project off. Once thanks so much!

John

  if (LATCH1, HIGH)

What do you think this crap is doing? That it hasn't yet bitten you in the ass does NOT mean that it is right or that it is working.