Led function help.
 
Notifications
Clear all

Led function help.

3 Posts
2 Users
0 Reactions
31 Views
(@bob73)
New Member
Joined: 3 days ago
Posts: 2
Topic starter  

I have a rotary encoder mapped to give me two additional function layers using Control Mappers FN input. 

using the Ncalc formula.   getcontrollerbuttonstate(‘0xc872,0x200b, 4) 

I can get the associated led to blink when I turn the rotary in that direction, and if I replace the 4 with 5. I get a result for the turning the rotary in the other direction.

i am trying to add a static on/off light to the assigned led, ie one click for On, one click for off but all I am getting is a short blink. 

what I am missing? 


   
Quote
(@waylonwesley)
New Member
Joined: 1 day ago
Posts: 1
 

Ensure that you are maintaining the state of the LED (on/off) between clicks. You might need a variable to keep track of whether the LED should be on or off. if (getcontrollerbuttonstate('0xc872,0x200b, 4') == 1) {
// Toggle the state 
ledState = !ledState; // Assuming ledState is a boolean variable
setLedState(ledState); // Function to set LED state  
}

Rotary encoders can produce multiple signals for a single turn due to bouncing. Implement a debounce mechanism to ignore rapid signals and only register a change every few milliseconds.

This post was modified 1 day ago 3 times by waylonwesley

   
ReplyQuote
(@bob73)
New Member
Joined: 3 days ago
Posts: 2
Topic starter  

@waylonwesley thank you for the help i will give that a try later on today.


   
ReplyQuote
Share: