add or remove button in overlay file

Hi,

Using VisualStudioCode/NRF Connect:  Im looking into the sample 'button'.  (this because i like to add GPIO-pins to connect to an interrupt)

In the button example  an interrupt means is used on a button, so thats fine.

Now i would like to add a button  in an overlay-file 

there are 4 buttons in nrf5340_cpuapp_common.dts

Is it possible to ADD buttons in an overlay file  nrf5340dk_nrf5340_cpuapp.overlay

..what should i need to put in that overlay file?

 

(And is it possible to remove a button ?, how is that to be done?)

Best Regards,

Theo  

Parents
  • Hi,

    As you can see, in the code, only one button is used. So if you need to add more buttons, you will have to do the change in the main.c first. 

    In the dts file, the sw0 is set to button0, sw1 is set to button1 and so on.

    So you will just have to add more sw nodes in the main.c

    But if you need to make a change, say, change the current button to button1, you can write that in the overlay file.

    For eg, now you get the output at button0 and if you want that in button1, you can create the following overlay file:

    /{
    
    aliases {
    		sw0 = &button1;
    		
    	};
    
    };

    More information about writing the overlay file can be found in the Devicetree HOWTOs of Zephyr.

    Regards,

    Priyanka

Reply
  • Hi,

    As you can see, in the code, only one button is used. So if you need to add more buttons, you will have to do the change in the main.c first. 

    In the dts file, the sw0 is set to button0, sw1 is set to button1 and so on.

    So you will just have to add more sw nodes in the main.c

    But if you need to make a change, say, change the current button to button1, you can write that in the overlay file.

    For eg, now you get the output at button0 and if you want that in button1, you can create the following overlay file:

    /{
    
    aliases {
    		sw0 = &button1;
    		
    	};
    
    };

    More information about writing the overlay file can be found in the Devicetree HOWTOs of Zephyr.

    Regards,

    Priyanka

Children
Related