HnR'26 badge 0.0.3
Hack&Roll 2026 hardware badge I/O library
Loading...
Searching...
No Matches
hnr26_badge.h File Reference

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.

Typedefs

typedef uint8_t hnr26_badge_dice_t
 Dice face number from 1 to 10 inclusive.

Enumerations

enum  hnr26_badge_button_t {
  HNR26_BADGE_BTN_UP = 12 , HNR26_BADGE_BTN_DOWN = 13 , HNR26_BADGE_BTN_LEFT = 14 , HNR26_BADGE_BTN_RIGHT = 15 ,
  HNR26_BADGE_BTN_A = 6 , HNR26_BADGE_BTN_B = 7
}
 AW9523 GPIO expander virtual pin number of a button. More...

Functions

esp_err_t hnr26_badge_destroy ()
 Destructor function to remove resources when no longer used.
bool hnr26_badge_get_button_is_held (const hnr26_badge_button_t button)
 Check if the given button is being held down.
bool hnr26_badge_get_button_is_idle (const hnr26_badge_button_t button)
 Check if the given button has not been pressed during the last 2 checked states.
bool hnr26_badge_get_button_is_pressed (const hnr26_badge_button_t button)
 Check if the given button has just been pressed.
bool hnr26_badge_get_button_is_released (const hnr26_badge_button_t button)
 Check if the given button has just been released.
bool hnr26_badge_get_button_state (const hnr26_badge_button_t button)
 Get the last known state of the given button.
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.
bool hnr26_badge_get_previous_button_state (const hnr26_badge_button_t button)
 Get the second last known state of the given button.
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.
esp_err_t hnr26_badge_init ()
 Initialise the I/O library.
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.
esp_err_t hnr26_badge_update_virtual_pins_state ()
 Update the GPIO status of all virtual pins on the AW9523 GPIO expander.

Detailed Description

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

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.

Enumeration Type Documentation

◆ 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 

Virtual pin number of removed A button

HNR26_BADGE_BTN_B 

Virtual pin number of removed B button

Function Documentation

◆ 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()

bool hnr26_badge_get_button_is_held ( const hnr26_badge_button_t button)

Check if the given button is being held down.

Parameters
[in]buttonButton 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()

bool hnr26_badge_get_button_is_idle ( const hnr26_badge_button_t button)

Check if the given button has not been pressed during the last 2 checked states.

Parameters
[in]buttonButton 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()

bool hnr26_badge_get_button_is_pressed ( const hnr26_badge_button_t button)

Check if the given button has just been pressed.

Parameters
[in]buttonButton 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()

bool hnr26_badge_get_button_is_released ( const hnr26_badge_button_t button)

Check if the given button has just been released.

Parameters
[in]buttonButton 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()

bool hnr26_badge_get_button_state ( const hnr26_badge_button_t button)

Get the last known state of the given button.

Parameters
[in]buttonButton 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_numGiven dice face number
[out]is_onWhether the LED is on or off
Returns
esp_err_t ESP error constants

◆ hnr26_badge_get_previous_button_state()

bool hnr26_badge_get_previous_button_state ( const hnr26_badge_button_t button)

Get the second last known state of the given button.

Parameters
[in]buttonButton 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_numGiven dice face number
[out]pin_numCalculated 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_numGiven dice face number
[in]is_onWhether 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