From 8ce16da28165fe52b936f3f03a77a0ccd1bebeee Mon Sep 17 00:00:00 2001 From: Christian Colglazier Date: Sat, 26 Sep 2020 21:00:57 -0400 Subject: [PATCH] Documented functions for main, menu, and util --- src/main.h | 30 +++++++++++++++- src/menu.h | 65 +++++++++++++++++++++++++++++++-- src/util.h | 104 ++++++++++++++++++++++++++++++++++++++--------------- 3 files changed, 167 insertions(+), 32 deletions(-) diff --git a/src/main.h b/src/main.h index c624118..cfdcd3d 100644 --- a/src/main.h +++ b/src/main.h @@ -19,10 +19,38 @@ Menu menu(&patch); Droplet* droplet; float sample_rate; +/* + * Processes user controls and inputs. + */ void ProcessControls(); + +/* + * Processes information to be displayed on the screen. + */ void ProcessOled(); + +/* + * Processes patch outputs. + */ 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(); #endif // CASCADE_MAIN_H_ diff --git a/src/menu.h b/src/menu.h index 6386b9b..e7800c4 100644 --- a/src/menu.h +++ b/src/menu.h @@ -16,15 +16,74 @@ class Menu { private: DaisyPatch* patch; 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(); + + /* + * Sets if the user is in the menu. + * + * @param menu active + */ void SetInMenu(bool); + + /* + * Keeps menu selection within the bounds of the menu's size. + */ 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(); + + /* + * Updates menu position based on user input from the encoder. + */ void UpdateMenuPosition(); + + /* + * Returns the name of the currently selected menu item. + * + * @return selected menu item's name + */ std::string SelectedName(); + + /* + * Returns the currently selected menu item. + * + * @return menu state + */ MenuState GetState(); }; diff --git a/src/util.h b/src/util.h index b22ba9b..2ef02e8 100644 --- a/src/util.h +++ b/src/util.h @@ -9,37 +9,85 @@ using namespace daisy; -void DrawSolidRect(DaisyPatch, - uint8_t, - uint8_t, - uint8_t, - uint8_t, - bool); +/* + * Draws a solid rectangle on screen. + * + * @param patch daisy patch board + * @param x1 x coordinate of the first point + * @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, - int, - FontDef, - std::string, - bool); +/* + * Draws text on screen flushed left. + * + * @param patch daisy patch board + * @param x start of text x coordinate + * @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, - int, - FontDef, - std::string); +/* + * Draws text on screen flushed left. + * + * @param patch daisy patch board + * @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, - int, - FontDef, - std::string, - bool); +/* + * Draws text on screen centered. + * + * @param patch daisy patch board + * @param x center of text x coordinate + * @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, - int, - FontDef, - std::string); +/* + * Draws text on screen centered. + * + * @param patch daisy patch board + * @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_