5 #include <Adafruit_ImageReader.h> 6 #include <Adafruit_SPIFlash.h> 7 #include <Adafruit_WavePlayer.h> 10 #if defined(USE_TINYUSB) 11 #include "Adafruit_TinyUSB.h" 14 #if defined(ARCADA_USE_JSON) 15 #include <ArduinoJson.h> 18 #define SD_MAX_FILENAME_SIZE 80 19 #define ARCADA_DEFAULT_CONFIGURATION_FILENAME "/arcada_config.json" 21 typedef void (*arcada_callback_t)(void);
24 typedef enum _FilesystemType {
28 ARCADA_FILESYS_SD_AND_QSPI
29 } Arcada_FilesystemType;
76 void printf(
const char *format, ...);
80 Arcada_FilesystemType desiredFilesys = ARCADA_FILESYS_SD_AND_QSPI);
82 const char *extensionFilter = NULL);
83 bool chdir(
const char *path);
84 File
open(
const char *path = NULL, uint32_t flags = O_READ);
86 uint32_t flags = O_READ,
87 const char *extensionFilter = NULL);
89 bool exists(
const char *path);
90 bool mkdir(
const char *path);
91 bool remove(
const char *path);
96 Arcada_FilesystemType desiredFilesys = ARCADA_FILESYS_SD_AND_QSPI);
98 bool chooseFile(
const char *path,
char *filename, uint16_t filename_max,
99 const char *extensionFilter = NULL);
137 return _canvas ? _canvas->getBuffer() : NULL;
140 bool bigEndian =
false, Adafruit_SPITFT *display = NULL);
141 uint16_t
ColorHSV565(int16_t H, uint8_t S, uint8_t V);
143 bool setBacklight(uint8_t brightness,
bool saveToDisk =
false);
145 bool setVolume(uint8_t volume,
bool saveToDisk =
false);
150 void alertBox(
const char *
string, uint16_t boxColor, uint16_t textColor,
151 uint32_t continueButtonMask);
152 void infoBox(
const char *
string,
153 uint32_t continueButtonMask = ARCADA_BUTTONMASK_A);
154 void warnBox(
const char *
string,
155 uint32_t continueButtonMask = ARCADA_BUTTONMASK_A);
157 uint32_t continueButtonMask = ARCADA_BUTTONMASK_A);
158 void haltBox(
const char *
string);
159 uint8_t
menu(
const char **menu_strings, uint8_t menu_num, uint16_t boxColor,
160 uint16_t textColor,
bool cancellable =
false);
164 const char *filename = ARCADA_DEFAULT_CONFIGURATION_FILENAME);
166 const char *filename = ARCADA_DEFAULT_CONFIGURATION_FILENAME);
188 #ifdef ARCADA_USE_JSON 189 StaticJsonDocument<256>
194 ImageReturnCode
drawBMP(
char *filename, int16_t x, int16_t y,
195 Adafruit_SPITFT *tft = 0x0,
boolean transact =
true);
198 wavStatus
WavLoad(
char *filename, uint32_t *samplerate);
199 wavStatus
WavLoad(File f, uint32_t *samplerate);
218 uint32_t last_buttons,
223 justreleased_buttons;
227 void _initAlertFonts(
void);
229 int16_t _joyx_center = 512;
230 int16_t _joyy_center = 512;
232 Arcada_FilesystemType _filesys_type = ARCADA_FILESYS_NONE;
235 GFXcanvas16 *_canvas = NULL;
236 bool _first_frame =
true;
238 uint8_t _volume = 255, _brightness = 255;
240 TouchScreen *_touchscreen;
241 int16_t _ts_xmin = 0, _ts_xmax = 1023, _ts_ymin = 0, _ts_ymax = 1023;
243 Adafruit_WavePlayer *player = NULL;
245 volatile bool _wav_readflag =
true;
246 volatile bool _wav_playing =
false;
248 float _callback_freq = 0;
249 arcada_callback_t _callback_func = NULL;
252 int8_t _sd_cs, _speaker_en, _neopixel_pin, _backlight_pin, _touch_xp,
253 _touch_yp, _touch_xm, _touch_ym,
254 _start_button = -1, _select_button, _a_button, _b_button, _up_button,
255 _down_button, _left_button, _right_button, _button_latch, _button_clock,
256 _button_data, _battery_sensor, _light_sensor, _joystick_x, _joystick_y;
257 uint8_t _neopixel_num = 0, _shift_up, _shift_down, _shift_left, _shift_right,
258 _shift_a, _shift_b, _shift_select, _shift_start;
bool _has_wifi
Internally tracked variable if wifi module was found.
Definition: arcadatype.h:209
bool setBacklight(uint8_t brightness, bool saveToDisk=false)
Set the backlight brightness and save to the configuration.
Definition: Adafruit_Arcada.cpp:182
void haltBox(const char *string)
Display an error box and halt operation.
Definition: Adafruit_Arcada_Alerts.cpp:63
uint16_t * getFrameBuffer(void)
Return address of internal framebuffer (NULL if not allocated)
Definition: arcadatype.h:136
wavStatus WavReadFile()
Reads another buffer's full of wave data into the internal buffer from the filesystem.
Definition: Adafruit_Arcada_Wav.cpp:84
bool recentUSB(uint32_t timeout=100)
Hints whether we're doing a bunch of USB stuff recently.
Definition: Adafruit_Arcada_USBMSD.cpp:127
bool loadConfigurationFile(const char *filename=ARCADA_DEFAULT_CONFIGURATION_FILENAME)
Loads the configuration JSON from the filesystem (which must be initialized before this function is c...
Definition: Adafruit_Arcada_Config.cpp:16
float getTimerCallbackFreq(void)
Get the final frequency created for the callback helper.
Definition: Adafruit_Arcada.cpp:334
Arcada_FilesystemType filesysBegin(Arcada_FilesystemType desiredFilesys=ARCADA_FILESYS_SD_AND_QSPI)
Initialize the filesystem, either SD or QSPI.
Definition: Adafruit_Arcada_Filesystem.cpp:44
bool _has_accel
Internally tracked variable if accelerometer was found.
Definition: arcadatype.h:207
bool hasControlPad(void)
Does this board have a control pad - latch, buttons or analog joystick?
Definition: Adafruit_Arcada.cpp:780
wavStatus WavLoad(char *filename, uint32_t *samplerate)
Load up a wave file from the filesystem, to prepare for playback.
Definition: Adafruit_Arcada_Wav.cpp:29
bool hasAccel(void)
Getter for accelerometer existance.
Definition: arcadatype.h:178
uint32_t readButtons(void)
Read all buttons/joystick and return a bitmask of which buttons are pressed, check ARCADA_BUTTONMASK_...
Definition: Adafruit_Arcada.cpp:435
virtual uint32_t variantReadButtons(void)=0
Perform any variant input reading (say if we use seesaw or whatnot)
Adafruit_ImageReader * QSPI_imagereader
If initalized, the imagereader for the QSPI filesystem.
Definition: arcadatype.h:212
int16_t readJoystickX(uint8_t oversampling=3)
Read X analog joystick.
Definition: Adafruit_Arcada.cpp:390
bool saveConfigurationFile(const char *filename=ARCADA_DEFAULT_CONFIGURATION_FILENAME)
Saves the configuration JSON to the filesystem (which must be initialized before this function is cal...
Definition: Adafruit_Arcada_Config.cpp:53
uint8_t * writeFileToFlash(const char *filename)
Opens a file and writes the data contents to the internal chip flash memory. NOT the QSPI flash but t...
Definition: Adafruit_Arcada_InternalFlash.cpp:215
void infoBox(const char *string, uint32_t continueButtonMask=ARCADA_BUTTONMASK_A)
Display an info box with optional 'press to continue' button.
Definition: Adafruit_Arcada_Alerts.cpp:26
bool chdir(const char *path)
Set working filesys directory to a given path (makes file naming easier)
Definition: Adafruit_Arcada_Filesystem.cpp:102
bool chooseFile(const char *path, char *filename, uint16_t filename_max, const char *extensionFilter=NULL)
Presents a navigation menu for choosing a file from the filesys.
Definition: Adafruit_Arcada_Filesystem.cpp:362
GFXcanvas16 * getCanvas(void)
Return pointer to GFX canvas (NULL if not allocated)
Definition: arcadatype.h:129
uint16_t ColorHSV565(int16_t H, uint8_t S, uint8_t V)
Convert hue, saturation and value into a packed 16-bit RGB color that can be passed to TFT...
Definition: Adafruit_Arcada.cpp:800
uint16_t readLightSensor(void)
Read the light sensor onboard if there is one.
Definition: Adafruit_Arcada.cpp:590
bool setVolume(uint8_t volume, bool saveToDisk=false)
Set the audio volume (not working at this time)
Definition: Adafruit_Arcada.cpp:220
Adafruit_Arcada_SPITFT(void)
Instantiator for Arcada class, will allso inistantiate (but not init) the TFT.
Definition: Adafruit_Arcada.cpp:27
uint32_t justReleasedButtons(void)
What buttons were just released as of the last readButtons() call. Use ARCADA_BUTTONMASK_* defines to...
Definition: Adafruit_Arcada.cpp:580
bool hasTouchscreen(void)
Does this board have a touchscreen.
Definition: Adafruit_Arcada.cpp:690
bool hasWiFi(void)
Gets the status of the ESP32 module connected via SPI.
Definition: arcadatype.h:186
bool filesysBeginMSD(Arcada_FilesystemType desiredFilesys=ARCADA_FILESYS_SD_AND_QSPI)
Make the raw filesystem of the Arcada board available over USB.
Definition: Adafruit_Arcada_USBMSD.cpp:36
bool blitFrameBuffer(uint16_t x, uint16_t y, bool blocking=false, bool bigEndian=false, Adafruit_SPITFT *display=NULL)
Write the internal framebuffer to the display at coord (x, y)
Definition: Adafruit_Arcada.cpp:660
uint8_t getVolume(void)
Get the audio volume (not working at this time)
Definition: Adafruit_Arcada.cpp:237
uint8_t menu(const char **menu_strings, uint8_t menu_num, uint16_t boxColor, uint16_t textColor, bool cancellable=false)
Draws a menu and lets a user select one of the menu items.
Definition: Adafruit_Arcada_Alerts.cpp:200
uint8_t getBacklight(void)
Get the backlight brightness.
Definition: Adafruit_Arcada.cpp:209
void alertBox(const char *string, uint16_t boxColor, uint16_t textColor, uint32_t continueButtonMask)
Display an alert box with optional 'press to continue' button.
Definition: Adafruit_Arcada_Alerts.cpp:80
Adafruit_SPITFT * display
The Adafruit_GFX subclass display which the variant must create.
Definition: arcadatype.h:41
Adafruit_NeoPixel pixels
The neopixel strip, of length ARCADA_NEOPIXEL_NUM.
Definition: arcadatype.h:169
virtual void displayBegin(void)=0
Initialize TFT display, doesn't turn on the backlight.
bool mkdir(const char *path)
Make a directory in the filesys.
Definition: Adafruit_Arcada_Filesystem.cpp:215
Adafruit_ImageReader * SD_imagereader
If initalized, the imagereader for the SD card filesystem.
Definition: arcadatype.h:214
void setTouchscreenCalibration(int16_t xmin, int16_t xmax, int16_t ymin, int16_t ymax)
Set the X/Y calibration values for the touchscreen.
Definition: Adafruit_Arcada.cpp:701
uint32_t justPressedButtons(void)
What buttons were just pressed as of the last readButtons() call. Use ARCADA_BUTTONMASK_* defines to ...
Definition: Adafruit_Arcada.cpp:568
int16_t filesysListFiles(const char *path=NULL, const char *extensionFilter=NULL)
Debugging helper, prints to Serial a list of files in a path.
Definition: Adafruit_Arcada_Filesystem.cpp:144
bool createFrameBuffer(uint16_t width, uint16_t height)
Create (allocate) an internal GFX canvas of given width and height.
Definition: Adafruit_Arcada.cpp:620
virtual bool variantBegin(void)=0
Perform any specialized variant setup such as initializing accelerometers, seesaw, etc.
uint8_t * writeDataToFlash(uint8_t *data, uint32_t len)
Write a block of data in RAM to the NEXT AVAILABLE position in flash memory (NOT a specific location)...
Definition: Adafruit_Arcada_InternalFlash.cpp:80
void errorBox(const char *string, uint32_t continueButtonMask=ARCADA_BUTTONMASK_A)
Display an error box with optional 'press to continue' button.
Definition: Adafruit_Arcada_Alerts.cpp:52
int16_t readJoystickY(uint8_t oversampling=3)
Read Y analog joystick.
Definition: Adafruit_Arcada.cpp:412
uint32_t availableFlash(void)
Determine amount of unused flash memory remaining.
Definition: Adafruit_Arcada_InternalFlash.cpp:28
bool timerCallback(float freq, arcada_callback_t callback)
Create a repetative callback to a function using a timer.
Definition: Adafruit_Arcada.cpp:260
wavStatus WavPlayNextSample(void)
Output the next sample to the DAC(s) - should be called at 'samplerate'!
Definition: Adafruit_Arcada_Wav.cpp:108
void printf(const char *format,...)
printf wrapper to serial debug, handy for logging config, C inclusion
Definition: Adafruit_Arcada.cpp:374
void enableSpeaker(bool flag)
Turn on the speaker amplifier.
Definition: Adafruit_Arcada.cpp:245
TSPoint getTouchscreenPoint(void)
Get a calibrated point that corresponds to the TFT.
Definition: Adafruit_Arcada.cpp:718
File openFileByIndex(const char *path, uint16_t index, uint32_t flags=O_READ, const char *extensionFilter=NULL)
Opens a file as an indexed # in a directory (0 is first file), and returns the object.
Definition: Adafruit_Arcada_Filesystem.cpp:312
void timerStop(void)
Stop a previously-initiated timer.
Definition: Adafruit_Arcada.cpp:362
wavStatus WavPlayComplete(char *filename)
Play a wave file completely thru by blocking until end of file.
Definition: Adafruit_Arcada_Wav.cpp:155
bool arcadaBegin(void)
Initialize GPIO, NeoPixels, and speaker.
Definition: Adafruit_Arcada.cpp:77
arcada_callback_t getTimerCallback(void)
Get the previous callback function we were using.
Definition: Adafruit_Arcada.cpp:349
bool exists(const char *path)
Tests if a file exists on the filesys.
Definition: Adafruit_Arcada_Filesystem.cpp:199
File open(const char *path=NULL, uint32_t flags=O_READ)
Opens a file and returns the object, a wrapper for our filesystem.
Definition: Adafruit_Arcada_Filesystem.cpp:263
ImageReturnCode drawBMP(char *filename, int16_t x, int16_t y, Adafruit_SPITFT *tft=0x0, boolean transact=true)
Loads BMP image file from QSPI or SD card directly to SPITFT screen.
Definition: Adafruit_Arcada_ImageReader.cpp:23
Adafruit_ImageReader * getImageReader(void)
Reques the ImageReader object used, either for SD or QSPI.
Definition: Adafruit_Arcada_ImageReader.cpp:43
void warnBox(const char *string, uint32_t continueButtonMask=ARCADA_BUTTONMASK_A)
Display an warning box with optional 'press to continue' button.
Definition: Adafruit_Arcada_Alerts.cpp:39
float readBatterySensor(void)
Read the batterysensor onboard if there is one.
Definition: Adafruit_Arcada.cpp:604
bool WavReadyForData()
Checks if we need to load the double buffer with WavReadFile() soon!
Definition: Adafruit_Arcada_Wav.cpp:99
An abstraction class for something with a display, and possibly button controls or speaker...
Definition: arcadatype.h:38