Buttons

The next component we are going to work with are capacitive buttons. The Rainbow HAT has three of them, labeled A, B, and C. Buttons can be handled in two different ways, using Buttons and using InputDrivers.

While Buttons are similar in behavior to the ones we place on a traditional UI, InputDrivers are similar to HID keyboards; they allow us to integrate with the operating system and send key press events, letting us handle our button presses as standard keys.

We will look at both of them with the same example: we will turn the red LED on when button A is pressed and off when it is not.

Let's start with the button driver.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.156.140