Hack&Roll 2026 hardware badge I/O library.
More...
#include <stdbool.h>
#include <stdint.h>
#include "aw9523.h"
#include "esp_err.h"
Go to the source code of this file.
|
|
typedef uint8_t | hnr26_badge_dice_t |
| | Dice face number from 1 to 10 inclusive.
|
Hack&Roll 2026 hardware badge I/O library.
- Author
- Yik Jin (@yikjin) yikji.nosp@m.n@nu.nosp@m.shack.nosp@m.ers..nosp@m.org
- Version
- 0.0.3
- Date
- 2026-01-05
- Copyright
- Copyright (c) 2026 NUS Hackers
This component simplifies communicating with the I/O peripherals on the Hack&Roll 2026 hardware badge.
The buttons and LEDs are connected via the AW9523 GPIO expander module to its 16 virtual pins (consisting of 2 ports of 8 physical pins each). Communication with the AW9523 GPIO expander is handled via the aw9523 component.
◆ hnr26_badge_button_t
AW9523 GPIO expander virtual pin number of a button.
| Enumerator |
|---|
| HNR26_BADGE_BTN_UP | 12 | Virtual pin number of up button
|
| HNR26_BADGE_BTN_DOWN | 13 | Virtual pin number of down button
|
| HNR26_BADGE_BTN_LEFT | 14 | Virtual pin number of left button
|
| HNR26_BADGE_BTN_RIGHT | 15 | Virtual pin number of right button
|
| HNR26_BADGE_BTN_A | 6 | Virtual pin number of removed A button
|
| HNR26_BADGE_BTN_B | 7 | Virtual pin number of removed B button
|
◆ hnr26_badge_destroy()
| esp_err_t hnr26_badge_destroy |
( |
| ) |
|
Destructor function to remove resources when no longer used.
- Returns
- esp_err_t ESP error constants
◆ hnr26_badge_get_button_is_held()
Check if the given button is being held down.
- Parameters
-
| [in] | button | Button to check if it is being held down |
- Returns
- true Button is being held down
-
false Button is not being held down
◆ hnr26_badge_get_button_is_idle()
Check if the given button has not been pressed during the last 2 checked states.
- Parameters
-
| [in] | button | Button to check if it has not been pressed recently |
- Returns
- true Button has not been pressed recently
-
false Button has been pressed recently
◆ hnr26_badge_get_button_is_pressed()
Check if the given button has just been pressed.
- Parameters
-
| [in] | button | Button to check if it is just pressed |
- Returns
- true Button is just pressed
-
false Button has not just been pressed
◆ hnr26_badge_get_button_is_released()
Check if the given button has just been released.
- Parameters
-
| [in] | button | Button to check if it is just released |
- Returns
- true Button is just released
-
false Button has not just been released
◆ hnr26_badge_get_button_state()
Get the last known state of the given button.
- Parameters
-
| [in] | button | Button to get the last known state of |
- Returns
- true Button is pressed
-
false Button is released
◆ hnr26_badge_get_led()
| esp_err_t hnr26_badge_get_led |
( |
const hnr26_badge_dice_t | dice_num, |
|
|
aw9523_pin_data_digital_t * | is_on ) |
Get the LED status of a given dice face number.
- Parameters
-
| [in] | dice_num | Given dice face number |
| [out] | is_on | Whether the LED is on or off |
- Returns
- esp_err_t ESP error constants
◆ hnr26_badge_get_previous_button_state()
Get the second last known state of the given button.
- Parameters
-
| [in] | button | Button to get the second last known state of |
- Returns
- true Button was pressed
-
false Button was released
◆ hnr26_badge_get_virtual_pin_from_dice_num()
| esp_err_t hnr26_badge_get_virtual_pin_from_dice_num |
( |
const hnr26_badge_dice_t | dice_num, |
|
|
aw9523_pin_num_t * | pin_num ) |
Calculate the AW9523 GPIO expander virtual pin number from the given dice face number.
- Parameters
-
| [in] | dice_num | Given dice face number |
| [out] | pin_num | Calculated virtual pin number |
- Returns
- esp_err_t ESP error constants
◆ hnr26_badge_init()
| esp_err_t hnr26_badge_init |
( |
| ) |
|
Initialise the I/O library.
- Returns
- esp_err_t ESP error constants
◆ hnr26_badge_set_led()
| esp_err_t hnr26_badge_set_led |
( |
const hnr26_badge_dice_t | dice_num, |
|
|
const aw9523_pin_data_digital_t | is_on ) |
Set the LED status of a given dice face number.
- Parameters
-
| [in] | dice_num | Given dice face number |
| [in] | is_on | Whether to set the LED on or off |
- Returns
- esp_err_t ESP error constants
◆ hnr26_badge_update_virtual_pins_state()
| esp_err_t hnr26_badge_update_virtual_pins_state |
( |
| ) |
|
Update the GPIO status of all virtual pins on the AW9523 GPIO expander.
- Returns
- esp_err_t ESP error constants