From b8eccbe162c02837aa5ecbbf85da3e8227a4a2e0 Mon Sep 17 00:00:00 2001 From: Jens True Date: Wed, 3 Nov 2021 10:13:25 +0000 Subject: [PATCH] Documentation cleanup --- Doxyfile | 3 ++- lib/CommandHandler/CommandHandler.cpp | 4 ++-- lib/CommandHandler/CommandHandler.h | 21 +++++++++++++++++++-- lib/DisplayProxy/DisplayProxy.h | 3 +++ lib/DisplayProxy/DisplayProxyMAX7456.h | 20 +++++++++++++++++--- src/main.cpp | 2 +- 6 files changed, 44 insertions(+), 9 deletions(-) diff --git a/Doxyfile b/Doxyfile index fb66889..6221ab7 100644 --- a/Doxyfile +++ b/Doxyfile @@ -1,6 +1,7 @@ PROJECT_NAME = "MinimOSD-JSON" OUTPUT_DIRECTORY = "docs/" -INPUT = "src" "lib" +INPUT = "README.md" "src" "lib" RECURSIVE = YES WARNINGS = YES GENERATE_LATEX = NO +USE_MDFILE_AS_MAINPAGE = README.md diff --git a/lib/CommandHandler/CommandHandler.cpp b/lib/CommandHandler/CommandHandler.cpp index 0977de8..c819cff 100644 --- a/lib/CommandHandler/CommandHandler.cpp +++ b/lib/CommandHandler/CommandHandler.cpp @@ -8,7 +8,7 @@ CommandHandler::CommandHandler(DisplayProxy *display) this->display = display; } -bool CommandHandler::parse(const char *cmd) +bool CommandHandler::parseJSON(const char *cmd) { Serial.print("Handling: "); Serial.println(cmd); @@ -23,7 +23,7 @@ bool CommandHandler::parse(const char *cmd) return false; } - const char *command = doc["command"]; + const char *command = doc["cmd"]; if (strcmp("write", command) == 0 && doc["text"].is() && doc["x"].is() && doc["y"].is()) { const char *text = doc["text"]; diff --git a/lib/CommandHandler/CommandHandler.h b/lib/CommandHandler/CommandHandler.h index 8fb1d6d..d1b8047 100644 --- a/lib/CommandHandler/CommandHandler.h +++ b/lib/CommandHandler/CommandHandler.h @@ -3,14 +3,31 @@ #include "DisplayProxy.h" /** - * Parse a JSON command and convert it into a display command + * Parse a JSON command and convert it into display command(s) */ class CommandHandler { public: + /** + * Constructor. + * + * @param display Takes an implementation of DisplayProxy through polymorphism. + */ explicit CommandHandler(DisplayProxy *display); - bool parse(const char *cmd); + /** + * Parse a command in JSON format + * @code{.json} + * {"cmd":"write","x": 2, "y": 10, "text":"Hello World"} + * @endcode + * + * @param cmd String to parse + * @return True if the input was parsed correctly. + */ + bool parseJSON(const char *cmd); private: + /** + * Internal helper for printing debug strings + */ void debugWrite(int x, int y, const char *text); DisplayProxy *display; diff --git a/lib/DisplayProxy/DisplayProxy.h b/lib/DisplayProxy/DisplayProxy.h index c3c91f1..0c0d92d 100644 --- a/lib/DisplayProxy/DisplayProxy.h +++ b/lib/DisplayProxy/DisplayProxy.h @@ -3,6 +3,7 @@ /** * Generic interface for a graphical display allowing for placement of text. + * Focused on TUI. */ class DisplayProxy { @@ -12,6 +13,7 @@ public: * @return True if successful. */ virtual bool on() = 0; + /** * Turn off the display. * @return True if successful. @@ -27,6 +29,7 @@ public: * @return True if successful. */ virtual bool write(int x, int y, const char *text) = 0; + /** * Clear the entire screen. * @return True if successful. diff --git a/lib/DisplayProxy/DisplayProxyMAX7456.h b/lib/DisplayProxy/DisplayProxyMAX7456.h index 7e877ae..2713311 100644 --- a/lib/DisplayProxy/DisplayProxyMAX7456.h +++ b/lib/DisplayProxy/DisplayProxyMAX7456.h @@ -6,12 +6,14 @@ /** - * Text-User-Interface on a Max7456 + * Text-User-Interface on a MAX7456 * - * The Max7456 provides On-Screen-Display rendering for composite video. + * The MAX7456 provides On-Screen-Display rendering for composite video. * (Think old school VCR menu overlay) * - * @link https://www.maximintegrated.com/en/products/analog/video-products/MAX7456.html + * To find the offical documentation for the part please refer to the Maxim page for the MAX7456. + * [Maxim Page](https://www.maximintegrated.com/en/products/analog/video-products/MAX7456.html) + * */ class DisplayProxyMAX7456 : public DisplayProxy { @@ -45,7 +47,19 @@ public: * Since the signal is analog the characters might be rendered outside the display area */ bool setOffset(int x, int y); + + /** + * Turn off the external video feed + * If the external feed is disabled the background will be grey + * @param enabled True to turn on the external video input + */ bool externalVideo(bool enabled); + + /** + * Turn on the overlay + * + * @param enabled True to turn on the overlay + */ bool onScreenDisplay(bool enabled); private: diff --git a/src/main.cpp b/src/main.cpp index 16e0114..7e8d63d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -49,6 +49,6 @@ void loop() while (Serial.available() > 0) { String input = Serial.readStringUntil('\n'); - cmd_handler.parse(input.c_str()); + cmd_handler.parseJSON(input.c_str()); } } \ No newline at end of file