Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
Loading...
Searching...
No Matches
swadge2024.h
Go to the documentation of this file.
1
161#ifndef _SWADGE_MODE_H_
162#define _SWADGE_MODE_H_
163
164// Standard C includes
165#include <stdint.h>
166#include <inttypes.h>
167#include <stdbool.h>
168#include <stdlib.h>
169#include <stdio.h>
170#include <string.h>
171
172// Useful ESP things
173#include <esp_heap_caps.h>
174#include <esp_log.h>
175
176// Hardware interfaces
177#include "crashwrap.h"
178#include "hdw-imu.h"
179#include "hdw-battmon.h"
180#include "hdw-btn.h"
181#include "hdw-dac.h"
182#include "hdw-esp-now.h"
183#include "hdw-led.h"
184#include "hdw-mic.h"
185#include "hdw-nvs.h"
186#include "hdw-temperature.h"
187#include "hdw-tft.h"
188#include "hdw-usb.h"
189
190// Drawing interfaces
191#include "palette.h"
192#include "color_utils.h"
193#include "font.h"
194#include "wsg.h"
195#include "shapes.h"
196#include "fill.h"
197#include "menu.h"
198#include "menuManiaRenderer.h"
199
200// Asset loaders
201#include "cnfs.h"
202#include "fs_wsg.h"
203#include "fs_font.h"
204#include "fs_txt.h"
205#include "fs_json.h"
206
207// Connection interface
208#include "p2pConnection.h"
209
210// General utilities
211#include "linked_list.h"
212#include "macros.h"
213#include "trigonometry.h"
214#include "vector2d.h"
215#include "geometry.h"
216#include "settingsManager.h"
217#include "touchUtils.h"
218#include "vectorFl2d.h"
219#include "geometryFl.h"
220
221// Sound utilities
222#include "soundFuncs.h"
223#include "swSynth.h"
224#include "midiPlayer.h"
225
226#define EXIT_TIME_US 1000000
228#define DEFAULT_FRAME_RATE_US (1000000 / 40)
229
235typedef struct
236{
240 const char* modeName;
241
248
254
260
266
273
277 void (*fnEnterMode)(void);
278
282 void (*fnExitMode)(void);
283
290 void (*fnMainLoop)(int64_t elapsedUs);
291
299 void (*fnAudioCallback)(uint16_t* samples, uint32_t sampleCnt);
300
311 void (*fnBackgroundDrawCallback)(int16_t x, int16_t y, int16_t w, int16_t h, int16_t up, int16_t upNum);
312
321 void (*fnEspNowRecvCb)(const esp_now_recv_info_t* esp_now_info, const uint8_t* data, uint8_t len, int8_t rssi);
322
330 void (*fnEspNowSendCb)(const uint8_t* mac_addr, esp_now_send_status_t status);
331
342 int16_t (*fnAdvancedUSB)(uint8_t* buffer, uint16_t length, uint8_t isGet);
343
350
352
355
356void deinitSystem(void);
357
358void openQuickSettings(void);
359void setFrameRateUs(uint32_t newFrameRateUs);
360uint32_t getFrameRateUs(void);
361
362void switchToSpeaker(void);
363void switchToMicrophone(void);
364
365#endif
A button event containing the button that triggered the event, whether it was pressed or released,...
Definition hdw-btn.h:117
void(* fnDacCallback_t)(uint8_t *samples, int16_t len)
A callback which requests DAC samples from the application.
Definition hdw-dac.h:94
wifiMode_t
The different WiFi modes.
Definition hdw-esp-now.h:99
A struct of all the function pointers necessary for a swadge mode. If a mode does not need a particul...
Definition swadge2024.h:236
wifiMode_t wifiMode
This is a setting, not a function pointer. Set it to NO_WIFI to save power by not using WiFi at all....
Definition swadge2024.h:247
const char * modeName
This swadge mode's name, used in menus. This is not a function pointer.
Definition swadge2024.h:240
fnDacCallback_t fnDacCb
This function is called to fill sample buffers for the DAC. If this is NULL, then globalMidiPlayerFil...
Definition swadge2024.h:348
bool overrideSelectBtn
If this is false, then PB_SELECT events will only be used to return to the main menu or open the quic...
Definition swadge2024.h:272
bool overrideUsb
If this is false, then the default TinyUSB driver will be installed (HID gamepad)....
Definition swadge2024.h:253
bool usesThermometer
If this is false, the thermometer will not be initialized and readTemperatureSensor() will not work....
Definition swadge2024.h:265
bool usesAccelerometer
If this is false, the accelerometer will not be initialized and accelGetAccelVec() will not work....
Definition swadge2024.h:259
void setFrameRateUs(uint32_t newFrameRateUs)
Set the framerate, in microseconds.
Definition swadge2024.c:810
void softSwitchToPendingSwadge(void)
Switch to the pending Swadge mode without restarting the system.
Definition swadge2024.c:717
bool checkButtonQueueWrapper(buttonEvt_t *evt)
Service the queue of button events that caused interrupts This only returns a single event,...
Definition swadge2024.c:758
void switchToMicrophone(void)
Enable the microphone and disable the speaker (and battery monitor)
Definition swadge2024.c:868
void deinitSystem(void)
Deinitialize all components in the system.
Definition swadge2024.c:614
void switchToSwadgeMode(swadgeMode_t *mode)
Definition swadge2024.c:706
uint32_t getFrameRateUs(void)
Get the current framerate, in microseconds.
Definition swadge2024.c:820
void switchToSpeaker(void)
Enable the speaker (and battery monitor) and disable the microphone.
Definition swadge2024.c:849
void openQuickSettings(void)
Definition swadge2024.c:797