Documented functions for main, menu, and util

This commit is contained in:
Christian Colglazier 2020-09-26 21:00:57 -04:00
parent a351030fe4
commit 8ce16da281
3 changed files with 167 additions and 32 deletions

View File

@ -19,10 +19,38 @@ Menu menu(&patch);
Droplet* droplet; Droplet* droplet;
float sample_rate; float sample_rate;
/*
* Processes user controls and inputs.
*/
void ProcessControls(); void ProcessControls();
/*
* Processes information to be displayed on the screen.
*/
void ProcessOled(); void ProcessOled();
/*
* Processes patch outputs.
*/
void ProcessOutputs(); void ProcessOutputs();
static void AudioThrough(float **, float **, size_t);
/*
* Processes audio input and outputs with a faster and higher priority control
* loop.
*
* @param in the audio inputs for the patch
* @param out the audio outputs for the patch
* @param size the number of inputs and outputs
*/
static void AudioThrough(float** in,
float** out,
size_t size);
/*
* Initializes a new audio processing droplet based on menu state.
*
* @return a droplet
*/
Droplet* GetDroplet(); Droplet* GetDroplet();
#endif // CASCADE_MAIN_H_ #endif // CASCADE_MAIN_H_

View File

@ -16,15 +16,74 @@ class Menu {
private: private:
DaisyPatch* patch; DaisyPatch* patch;
public: public:
Menu(DaisyPatch*); /*
* Constructor for a menu system to control the state of the patch.
*
* @param m_patch pointer to patch
*/
Menu(DaisyPatch* m_patch);
/*
* Gives if the user is currently in the menu.
*
* @return menu active
*/
bool InMenu(); bool InMenu();
/*
* Sets if the user is in the menu.
*
* @param menu active
*/
void SetInMenu(bool); void SetInMenu(bool);
/*
* Keeps menu selection within the bounds of the menu's size.
*/
void FilterMenuSelection(); void FilterMenuSelection();
std::string FilterMenuText(int);
void CreateMenuItem(std::string, int, bool); /*
* Returns item name based on given position and if out of the menu
* returns a blank string.
*
* @param position place in the menu
* @return menu item name
*/
std::string FilterMenuText(int position);
/*
* Draws a menu item on screen.
*
* @param text menu item name
* @param position menu items position in the menu
* @param highlighted state of menu items selection
*/
void CreateMenuItem(std::string text,
int position,
bool highlighted);
/*
* Draws droplet information on the screen.
*/
void ProcessMenuOled(); void ProcessMenuOled();
/*
* Updates menu position based on user input from the encoder.
*/
void UpdateMenuPosition(); void UpdateMenuPosition();
/*
* Returns the name of the currently selected menu item.
*
* @return selected menu item's name
*/
std::string SelectedName(); std::string SelectedName();
/*
* Returns the currently selected menu item.
*
* @return menu state
*/
MenuState GetState(); MenuState GetState();
}; };

View File

@ -9,37 +9,85 @@
using namespace daisy; using namespace daisy;
void DrawSolidRect(DaisyPatch, /*
uint8_t, * Draws a solid rectangle on screen.
uint8_t, *
uint8_t, * @param patch daisy patch board
uint8_t, * @param x1 x coordinate of the first point
bool); * @param y1 y coordinate of the first point
* @param x2 x coordinate of the second point
* @param y2 y coordinate of the second point
* @param on draw screen on or off
*/
void DrawSolidRect(DaisyPatch patch,
uint8_t x1,
uint8_t y1,
uint8_t x2,
uint8_t y2,
bool on);
void WriteString(DaisyPatch, /*
int, * Draws text on screen flushed left.
int, *
FontDef, * @param patch daisy patch board
std::string, * @param x start of text x coordinate
bool); * @param y start of text y coordinate
* @param font text font
* @param text text to be written
* @param on draw screen on or off
*/
void WriteString(DaisyPatch patch,
int x,
int y,
FontDef font,
std::string text,
bool on);
void WriteString(DaisyPatch, /*
int, * Draws text on screen flushed left.
int, *
FontDef, * @param patch daisy patch board
std::string); * @param x start of text x coordinate
* @param y start of text y coordinate
* @param font text font
* @param text text to be written
*/
void WriteString(DaisyPatch patch,
int x,
int y,
FontDef font,
std::string text);
void WriteCenteredString(DaisyPatch, /*
int, * Draws text on screen centered.
int, *
FontDef, * @param patch daisy patch board
std::string, * @param x center of text x coordinate
bool); * @param y start of text y coordinate
* @param font text font
* @param text text to be written
* @param on draw screen on or off
*/
void WriteCenteredString(DaisyPatch patch,
int x,
int y,
FontDef font,
std::string font,
bool on);
void WriteCenteredString(DaisyPatch, /*
int, * Draws text on screen centered.
int, *
FontDef, * @param patch daisy patch board
std::string); * @param x center of text x coordinate
* @param y start of text y coordinate
* @param font text font
* @param text text to be written
*/
void WriteCenteredString(DaisyPatch patch,
int x,
int y,
FontDef font,
std::string text);
#endif // CASCADE_UTIL_H_ #endif // CASCADE_UTIL_H_