Who can help? Im confused on button

Hi All,

On my device, we have one button with following DTS.

     buttons {
         compatible = "gpio-keys";
         config {
             label = "Config Button";
             gpios = <&gpio 118 1>;
             linux,code = <171>;  
         };
     };

And, I try to add script config to /etc/rc.button/config, it works.
According to https://openwrt.org/docs/guide-user/hardware/hardware.button, procd help on it. GOOD.

Next part is Hotplug Buttons. First, I do this, it works. I can see the log print out when push/release button.

mkdir -p /etc/hotplug.d/button
 
cat << "EOF" > /etc/hotplug.d/button/buttons
logger "the button was ${BUTTON} and the action was ${ACTION}"
EOF

But, when I try to run following cmds to try. It did not work.

uci add system button
uci set system.@button[-1].button="config"
uci set system.@button[-1].action="pressed"
uci set system.@button[-1].handler="logger config pressed"
uci commit system 
reload_config

Questions:

  1. Hotplug Buttons still work on 19.07.4? If yes, which I'm wrong?
  2. Which case we should use hotplug buttons? Looks like procd already cover all features hotplug buttons have.

Please help. Thanks.

KISS :slight_smile:
See base-file package for details.

Hi 123serge123,

What should I check? I know those scripts will be run if dts is correct.
Thanks a lot.

You reinvent the wheel or I don't understand your question.
SImple create script named as label in dts add add processing of button.

Hi 123serge123,

Sorry for my poor English. Just simple question, how can I get following settings to work? Thanks.

uci add system button
uci set system.@button[-1].button="config"
uci set system.@button[-1].action="pressed"
uci set system.@button[-1].handler="logger config pressed"
uci commit system 

Hi 123serge123,

Looks like I need to have 00-button script to learn uci config and call correct handler to handle it. Thanks.

Hi 123serge123,

By the way, is it possible to handle following case?

  1. Press button
  2. Turn on red led for 0~3s.
  3. Turn off red led and turn on yellow led for 3~6s.
  4. Turn off yellow led and turn on green led for 6~10s.

Basically, I need to notify user via differ led when user keep pressing the button. Thanks.

Ok. Let's your dts contain something like:

	keys {
		compatible = "gpio-keys";

		myconfig {
			label = "config";
			.
			.

		};
	};

Then you need to create /etc/rc.button/config:

#! /bin/sh

logger "${BUTTON} of ${TYPE} is ${ACTION} after ${SEEN} time"

Or append any processing.

1 Like

Hi 123serge123,

Yes, your suggestions are working on my device. Thanks.

Mon Sep 28 08:39:21 2020 user.notice root: config of  is pressed after 13 time
Mon Sep 28 08:39:23 2020 user.notice root: config of  is released after 2 time

If your problem is solved, please consider marking this topic as [Solved]. See How to mark a topic as [Solved] for a short how-to.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.