One button code lock

Moderators: grovkillen, Stuntteam, TD-er

Message
Author
User avatar
Ath
Normal user
Posts: 3520
Joined: 10 Jun 2018, 12:06
Location: NL

Re: One button code lock

#51 Post by Ath » 26 Oct 2023, 11:30

Why is this in your log?

Code: Select all

Command unknown: 1=11 and 1=3
Something strange in your rules?
/Ton (PayPal.me)

Dick60
Normal user
Posts: 243
Joined: 11 Feb 2018, 17:35
Location: The Netherlands

Re: One button code lock

#52 Post by Dick60 » 26 Oct 2023, 12:31

Thanks for the tip, I checked the code and now is this part working.
I typed Elseif and not Else if.
Here the correct code

Code: Select all

on Switch#State do
 if %eventvalue1%=1
 let,1,[int#1]+1 // Count pulses
    timerset,1,1 // Set timer to clear the counter    
  else
  if  %eventvalue1%=11 and [int#1]=3
    // Accept the code
    let,1,0 // Clear counter
   GPIO,12,0
  endif
  endif
endon

on rules#timer=1 do
  let,1,0 // Clear counter
endon

Dick60
Normal user
Posts: 243
Joined: 11 Feb 2018, 17:35
Location: The Netherlands

Re: One button code lock

#53 Post by Dick60 » 26 Oct 2023, 16:57

Is it possible, instead of counting only the button pushes, to sum the value of the GPIO. For example: 2 short and 2 long results in a 24 (1+1+11+11) so I can do something with the value of the sum and the number or pushes. (switch on an led or something. This is my setup, sofar. The problem is that GPIO,12,0 is not executed. I see both the long and short pulses, the reset of the Variables by Timer 1 but no execution of GPIO,2,0.

Code: Select all

on Switch#State do
 if %eventvalue1%=1
 let,1,[int#1]+1 // Count pulses
    timerset,1,1 // Set timer1 to clear the counter    
  else
if  %eventvalue1%=11
let,2,[int#2]+1 //Count long press 
timerset,1,1
else
  if  [int#2]=2 and [int#1]=5 //2 long and 3 short
    // Accept the code
    let,1,0 // Clear counter 1
    let,2,0 // Clear counter 2
   GPIO,12,0
timerset,2,5 //Set timer 2 to turn off led
  endif
  endif
  endif
endon 

on rules#timer=1 do
  let,1,0 // Clear counter 1
  let,2,0 //Clear counter 2
endon

on rules#timer=2 do
  GPIO,12,1 
endon

Dick60
Normal user
Posts: 243
Joined: 11 Feb 2018, 17:35
Location: The Netherlands

Re: One button code lock

#54 Post by Dick60 » 27 Oct 2023, 11:25

After a lot of testing, the final script is working . I played with the timer and this is the final working solution:

Code: Select all

on Switch#State do
 if %eventvalue1%=1
 let,1,[int#1]+1 // Count pulses
    timerset,1,3 // Set timer to clear the counter    
  elseif %eventvalue1%=11
let,2,[int#2]+1 //sum long press 
timerset,1,3
else
  if  [int#2]=1 and [int#1]=2 //1 long and 1 short
    // Accept the code
    let,1,0 // Clear counter
    let,2,0 // Clear counter
   GPIO,12,0
timerset,2,5
  endif
  endif
endon 

on rules#timer=1 do
  let,1,0 // Clear counter
  let,2,0
endon

on rules#timer=2 do
  GPIO,12,1 
endon

Dick60
Normal user
Posts: 243
Joined: 11 Feb 2018, 17:35
Location: The Netherlands

Re: One button code lock

#55 Post by Dick60 » 25 Nov 2023, 11:27

Is there already some time for reviewing and optimization of the E-button plugin? If not, see it as a reminder.

Dick60
Normal user
Posts: 243
Joined: 11 Feb 2018, 17:35
Location: The Netherlands

Re: One button code lock

#56 Post by Dick60 » 16 Apr 2024, 08:01

Anyone time for optimizing the Ibutton plugin?

Post Reply

Who is online

Users browsing this forum: No registered users and 31 guests