Author Topic: Multi click on button and power optimization  (Read 1231 times)

andri36

  • RFduino Newbie
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Multi click on button and power optimization
« on: April 04, 2015, 03:24:03 AM »
Hi to all,
I'm working on a project that requires 2 buttons with multiple state (click, double click and click+hold). I try to use ClickButton.h lib (https://code.google.com/p/clickbutton/) and it works well. My problem is that if I set a
Code: [Select]
RFduino_pinWake(buttonOnePin, HIGH); to the first pin or second, in the
Code: [Select]
loop() statement RFduino wake up and the power consumption raise. I'll try to use
Code: [Select]
RFduino_pinWoke() method and
Code: [Select]
RFduino_resetPinWake() method to send RFduino in ULP mode. But in this case the ClickButton.h lib stop to works correctly. My sketch is:

Code: [Select]
#include <RFduinoBLE.h>
#include "ClickButton.h"

int upButtonPin = 6;
ClickButton upButton(upButtonPin, HIGH, CLICKBTN_PULLUP);
int downButtonPin = 5;
ClickButton downButton(downButtonPin, HIGH, CLICKBTN_PULLUP);

void setup() {
  RFduinoBLE.deviceName = "RFduino";
  RFduinoBLE.advertisementData = "adv";
 
  pinMode(upButtonPin, INPUT);
  RFduino_pinWake(upButtonPin, HIGH);
 
  pinMode(downButtonPin, INPUT);
  RFduino_pinWake(downButtonPin, HIGH);

  RFduinoBLE.begin();
 
  Serial.begin(9600);
}

void loop() {
  RFduino_ULPDelay( INFINITE );
 
  if(RFduino_pinWoke(upButtonPin)) {
    Serial.print("Wake: ");

    upButton.Update();
   
    if (upButton.clicks != 0) { Serial.println(upButton.clicks); RFduinoBLE.sendInt(upButton.clicks); }

    RFduino_resetPinWake(upButtonPin);
   
  }
}

When RFduino wake up and read the buttons state the clicks is always 0. But if I remove the
Code: [Select]
RFduino_pinWoke() method and
Code: [Select]
RFduino_resetPinWake() method the buttons state read and send works well.

Thanks in advance to all.

 

anything