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
Go to the documentation of this file.
1
10#pragma once
11
12//==============================================================================
13// Includes
14//==============================================================================
15
16#include <stdint.h>
17#include "hdw-btn.h"
18
19#define MAX_ADJ1_LEN 10 // Length of longest word in list
20#define MAX_ADJ2_LEN 10 // Length of longest word in list
21#define MAX_NOUN_LEN 10 // Length of longest word in list
22
23// +3 for number, +1 for end, +3 for '-' = +7
24#define USERNAME_MAX_LEN (MAX_ADJ1_LEN + MAX_ADJ2_LEN + MAX_NOUN_LEN + 7)
25
31#define GET_PACKED_USERNAME(nd) ((nd.idxs[0] << 24) | (nd.idxs[1] << 16) | (nd.idxs[2] << 8) | nd.randCode)
32
33//==============================================================================
34// Structs
35//==============================================================================
36
37typedef struct
38{
39 int8_t idxs[3];
40 uint8_t randCode;
43 bool user;
45
46//==============================================================================
47// Function Declarations
48//==============================================================================
49
54void initUsernameSystem(void);
55
62
69
76
86void setUsernameFromIdxs(nameData_t* nd, int idx1, int idx2, int idx3, int randomCode);
87
97
104
111
118
125void setUsernameFrom32(nameData_t* nd, int32_t packed);
A button event containing the button that triggered the event, whether it was pressed or released,...
Definition hdw-btn.h:117
void setUsernameFromND(nameData_t *nd)
Sets the username from a predefined nd.
Definition nameList.c:202
void generateRandUsername(nameData_t *nd)
Generates a random username.
Definition nameList.c:182
void generateMACUsername(nameData_t *nd)
Generates a username based on the MAC of the swadge.
Definition nameList.c:172
nameData_t * getSystemUsername(void)
Get the System Username object.
Definition nameList.c:380
uint8_t randCode
Definition nameList.h:40
#define USERNAME_MAX_LEN
Definition nameList.h:24
char nameBuffer[USERNAME_MAX_LEN]
Definition nameList.h:42
int arrayIdx
Definition nameList.h:41
bool handleUsernamePickerInput(buttonEvt_t *evt, nameData_t *nd)
Handles the input of the username.
Definition nameList.c:229
void setUsernameFrom32(nameData_t *nd, int32_t packed)
Set the Username from a int32.
Definition nameList.c:391
void drawUsernamePicker(nameData_t *nd)
Draws the picker input.
Definition nameList.c:321
bool user
Definition nameList.h:43
void setSystemUsername(nameData_t *nd)
Saves the username to NVS.
Definition nameList.c:385
int8_t idxs[3]
Definition nameList.h:39
void setUsernameFromIdxs(nameData_t *nd, int idx1, int idx2, int idx3, int randomCode)
Set the Username From indices. Useful for loading data from swadgepass.
Definition nameList.c:219
void initUsernameSystem(void)
Call this to initialize the MAC variable. Call inside the swadge2024.h file.
Definition nameList.c:146
Definition nameList.h:38