Swadge ESP32-S2  2.0.0
APIs to develop for the Magfest Swadge
Loading...
Searching...
No Matches
swadgesona.c File Reference

Detailed Description

The data structures and Helper functions for utilizing Swadgesonas.

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

Macros

#define SWSN_HEIGHT   64
#define SWSN_WIDTH   64

Enumerations

enum  paletteSwap_t {
  COLOR_HAIR , COLOR_SKIN , COLOR_EYES , COLOR_CLOTHES ,
  COLOR_HAT , COLOR_GLASSES
}

Functions

void saveSwadgesona (swadgesona_t *sw, int idx)
 Saves the Swadgesona to the NVS in the given slot.
void loadSwadgesona (swadgesona_t *sw, int idx)
 Loads a swadgesona from the NVS.
void copySwadgesona (swadgesona_t *to, swadgesona_t *from)
 Copy one swadgesona to another.
void generateRandomSwadgesona (swadgesona_t *sw)
 Generates a random Swadgesona automatically.
void generateSwadgesonaImage (swadgesona_t *sw, bool drawBody)
 Generates the image based on the included data.
void loadSPSona (swadgesonaCore_t *sw)
 Loads the swadgepass sona.
bool getFeatureWSG (swadgesona_t *sw, features_t feature, wsg_t *dest)
 Copy the sprite and color at an index to a wsg_t. This function allocates memory for the wsg_t, please freeWsg() when done with image.

Variables

const char spSonaNVSKey [] = "spSona"

Macro Definition Documentation

◆ SWSN_HEIGHT

#define SWSN_HEIGHT   64

◆ SWSN_WIDTH

#define SWSN_WIDTH   64

Enumeration Type Documentation

◆ paletteSwap_t

Enumerator
COLOR_HAIR 
COLOR_SKIN 
COLOR_EYES 
COLOR_CLOTHES 
COLOR_HAT 
COLOR_GLASSES 

Function Documentation

◆ saveSwadgesona()

void saveSwadgesona ( swadgesona_t * sw,
int idx )

Saves the Swadgesona to the NVS in the given slot.

Parameters
swSwadgesona data to save. provide the entire wrapper
idxIndex of slot to put swadgesona into

◆ loadSwadgesona()

void loadSwadgesona ( swadgesona_t * sw,
int idx )

Loads a swadgesona from the NVS.

Parameters
swSwadgesona data to load. Will be randomized if the data doesn't exist.
idxIndex of slot to put swadgesona into

◆ copySwadgesona()

void copySwadgesona ( swadgesona_t * to,
swadgesona_t * from )

Copy one swadgesona to another.

Parameters
toThe swadgesona to copy to
fromThe source swadgesona

◆ generateRandomSwadgesona()

void generateRandomSwadgesona ( swadgesona_t * sw)

Generates a random Swadgesona automatically.

Parameters
swSwadgesona to load data into.

◆ generateSwadgesonaImage()

void generateSwadgesonaImage ( swadgesona_t * sw,
bool drawBody )

Generates the image based on the included data.

Parameters
swSwadgesona wrapper used ot generate the image
drawBodyWhether or not to draw the shirt/neck

◆ loadSPSona()

void loadSPSona ( swadgesonaCore_t * sw)

Loads the swadgepass sona.

Parameters
swData out. Is set to NULL if nothing is loaded

◆ getFeatureWSG()

bool getFeatureWSG ( swadgesona_t * sw,
features_t feature,
wsg_t * dest )

Copy the sprite and color at an index to a wsg_t. This function allocates memory for the wsg_t, please freeWsg() when done with image.

Note
Please note that there are probably some issues with this:
  • Human ears are default, and will provide a "false" signal
  • There are some special cases I have not handled, including vitiligo, Hair that has to go front and back, etc.
Parameters
swSwadgesona to extract wsg from
featureThe feature to load
destThe place to save the file into
Returns
bool True if it found a sprite, false otherwise

Variable Documentation

◆ spSonaNVSKey

const char spSonaNVSKey[] = "spSona"