Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
nameList.h File Reference

Detailed Description

Provides index-based usernames that will avoid the issues inherent in free text entry.

Author
Jeremy Stintzcum (jerem.nosp@m.y.st.nosp@m.intzc.nosp@m.um@g.nosp@m.mail..nosp@m.com)
Date
2025-05-02

Go to the source code of this file.

Data Structures

struct  nameData_t
 

Macros

#define MAX_ADJ1_LEN   10
 
#define MAX_ADJ2_LEN   10
 
#define MAX_NOUN_LEN   10
 
#define USERNAME_MAX_LEN   (MAX_ADJ1_LEN + MAX_ADJ2_LEN + MAX_NOUN_LEN + 7)
 
#define GET_PACKED_USERNAME(nd)
 Gets the packed 32 bit representation of a username.
 

Functions

void initUsernameSystem (void)
 Call this to initialize the MAC variable. Call inside the swadge2024.h file.
 
void generateMACUsername (nameData_t *nd)
 Generates a username based on the MAC of the swadge.
 
void generateRandUsername (nameData_t *nd)
 Generates a random username.
 
void setUsernameFromND (nameData_t *nd)
 Sets the username from a predefined nd.
 
void setUsernameFromIdxs (nameData_t *nd, int idx1, int idx2, int idx3, int randomCode)
 Set the Username From indices. Useful for loading data from swadgepass.
 
bool handleUsernamePickerInput (buttonEvt_t *evt, nameData_t *nd)
 Handles the input of the username.
 
void drawUsernamePicker (nameData_t *nd)
 Draws the picker input.
 
nameData_tgetSystemUsername (void)
 Get the System Username object.
 
void setSystemUsername (nameData_t *nd)
 Saves the username to NVS.
 
void setUsernameFrom32 (nameData_t *nd, int32_t packed)
 Set the Username from a int32.
 

Data Structure Documentation

◆ nameData_t

struct nameData_t
Data Fields
int8_t idxs[3]
uint8_t randCode
int arrayIdx
char nameBuffer[USERNAME_MAX_LEN]
bool user

Macro Definition Documentation

◆ MAX_ADJ1_LEN

#define MAX_ADJ1_LEN   10

◆ MAX_ADJ2_LEN

#define MAX_ADJ2_LEN   10

◆ MAX_NOUN_LEN

#define MAX_NOUN_LEN   10

◆ USERNAME_MAX_LEN

#define USERNAME_MAX_LEN   (MAX_ADJ1_LEN + MAX_ADJ2_LEN + MAX_NOUN_LEN + 7)

◆ GET_PACKED_USERNAME

#define GET_PACKED_USERNAME ( nd)
Value:
((nd.idxs[0] << 24) | (nd.idxs[1] << 16) | (nd.idxs[2] << 8) | nd.randCode)

Gets the packed 32 bit representation of a username.

Parameters
ndnameData_t pointer to pack

Function Documentation

◆ initUsernameSystem()

void initUsernameSystem ( void )

Call this to initialize the MAC variable. Call inside the swadge2024.h file.

◆ generateMACUsername()

void generateMACUsername ( nameData_t * nd)

Generates a username based on the MAC of the swadge.

Parameters
ndData struct the name is saved to

◆ generateRandUsername()

void generateRandUsername ( nameData_t * nd)

Generates a random username.

Parameters
ndData struct the name is saved to

◆ setUsernameFromND()

void setUsernameFromND ( nameData_t * nd)

Sets the username from a predefined nd.

Parameters
ndnd containing the data

◆ setUsernameFromIdxs()

void setUsernameFromIdxs ( nameData_t * nd,
int idx1,
int idx2,
int idx3,
int randomCode )

Set the Username From indices. Useful for loading data from swadgepass.

Parameters
ndData struct to receive the objects
idx1First index
idx2Second index
idx3Third index
randomCodenumbers at the end of the swadge

◆ handleUsernamePickerInput()

bool handleUsernamePickerInput ( buttonEvt_t * evt,
nameData_t * nd )

Handles the input of the username.

Parameters
evtThe button event object
ndData structure to store data in
Returns
true If the user presses A to finalize the name
false If the user is still selecting a name

◆ drawUsernamePicker()

void drawUsernamePicker ( nameData_t * nd)

Draws the picker input.

Parameters
ndThe data

◆ getSystemUsername()

nameData_t * getSystemUsername ( void )

Get the System Username object.

Returns
nameData_t* The username for the system at large

◆ setSystemUsername()

void setSystemUsername ( nameData_t * nd)

Saves the username to NVS.

Parameters
ndusername to save

◆ setUsernameFrom32()

void setUsernameFrom32 ( nameData_t * nd,
int32_t packed )

Set the Username from a int32.

Parameters
ndnameData_t to initialize
packedint32_t to load name from