diff --git a/.drone.yml b/.drone.yml index 981614c..a398b28 100644 --- a/.drone.yml +++ b/.drone.yml @@ -8,6 +8,10 @@ steps: - pip install platformio - pio run - pio check --skip-packages +- name: build + image: corentinaltepe/doxygen + commands: + - doxygen - name: release image: plugins/gitea-release settings: diff --git a/.gitignore b/.gitignore index 2de98ab..11d3482 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .pio .pioenvs .piolibdeps +docs/ .vscode/.browse.c_cpp.db* .vscode/c_cpp_properties.json .vscode/launch.json diff --git a/Doxyfile b/Doxyfile new file mode 100644 index 0000000..fb66889 --- /dev/null +++ b/Doxyfile @@ -0,0 +1,6 @@ +PROJECT_NAME = "MinimOSD-JSON" +OUTPUT_DIRECTORY = "docs/" +INPUT = "src" "lib" +RECURSIVE = YES +WARNINGS = YES +GENERATE_LATEX = NO diff --git a/lib/CommandHandler/CommandHandler.cpp b/lib/CommandHandler/CommandHandler.cpp index 02f6e54..0977de8 100644 --- a/lib/CommandHandler/CommandHandler.cpp +++ b/lib/CommandHandler/CommandHandler.cpp @@ -44,7 +44,7 @@ bool CommandHandler::parse(const char *cmd) { int x = doc["x"]; int y = doc["y"]; - this->display->setOffset(x, y); + //this->display->setOffset(x, y); } return true; diff --git a/lib/CommandHandler/CommandHandler.h b/lib/CommandHandler/CommandHandler.h index c5d6ab4..8fb1d6d 100644 --- a/lib/CommandHandler/CommandHandler.h +++ b/lib/CommandHandler/CommandHandler.h @@ -2,6 +2,9 @@ #define COMMANDHANDLER_H #include "DisplayProxy.h" +/** + * Parse a JSON command and convert it into a display command + */ class CommandHandler { public: diff --git a/lib/DisplayProxy/DisplayProxy.h b/lib/DisplayProxy/DisplayProxy.h index 36c24f1..c3c91f1 100644 --- a/lib/DisplayProxy/DisplayProxy.h +++ b/lib/DisplayProxy/DisplayProxy.h @@ -1,10 +1,36 @@ #ifndef DISPLAYPROXY_H #define DISPLAYPROXY_H + +/** + * Generic interface for a graphical display allowing for placement of text. + */ class DisplayProxy { public: + /** + * Turn on the display. + * @return True if successful. + */ + virtual bool on() = 0; + /** + * Turn off the display. + * @return True if successful. + */ + virtual bool off() = 0; + + /** + * Write a string to the display. + * + * @param x Horizontal starting position. From left to right. (0 indexed) + * @param y Vertical starting position. From top to bottom. (0 indexed) + * @param text String to write + * @return True if successful. + */ virtual bool write(int x, int y, const char *text) = 0; + /** + * Clear the entire screen. + * @return True if successful. + */ virtual bool clear() = 0; - virtual bool setOffset(int x, int y) = 0; }; #endif \ No newline at end of file diff --git a/lib/DisplayProxy/DisplayProxyMAX7456.cpp b/lib/DisplayProxy/DisplayProxyMAX7456.cpp index 4d869e3..ad5f312 100644 --- a/lib/DisplayProxy/DisplayProxyMAX7456.cpp +++ b/lib/DisplayProxy/DisplayProxyMAX7456.cpp @@ -11,32 +11,35 @@ DisplayProxyMAX7456::DisplayProxyMAX7456(Max7456 *osd) onScreenDisplay(true); } -/** - * Write a text string to the display at the given position - * @param x Position along the X axis - * @param y Position along the Y axis - * @param text The string to print - * @return Success or false - */ + +bool DisplayProxyMAX7456::on() +{ + onScreenDisplay(true); + return true; +} + +bool DisplayProxyMAX7456::off() +{ + externalVideo(false); + onScreenDisplay(false); + return true; +} + + + bool DisplayProxyMAX7456::write(int x, int y, const char *text) { this->osd->print(text, x, y); return true; } -/** - * Clear the entire screen - */ bool DisplayProxyMAX7456::clear() { this->osd->clearScreen(); return true; } -/** - * Adjust the display offset. - * Since the signal is analog the characters might be rendered outside the display area - */ + bool DisplayProxyMAX7456::setOffset(int x, int y) { this->osd->setDisplayOffsets(x, y); diff --git a/lib/DisplayProxy/DisplayProxyMAX7456.h b/lib/DisplayProxy/DisplayProxyMAX7456.h index 44c3bff..7e877ae 100644 --- a/lib/DisplayProxy/DisplayProxyMAX7456.h +++ b/lib/DisplayProxy/DisplayProxyMAX7456.h @@ -4,14 +4,47 @@ #include "DisplayProxy.h" #include "max7456.h" + +/** + * Text-User-Interface on a Max7456 + * + * 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 + */ class DisplayProxyMAX7456 : public DisplayProxy { public: + /** + * Initalize a Max7456 Style display + * - Initialize with CS on Pin 6. + * - Clear the display + * - Initialize blinking frequency. + * - Disable external video + * - Enable OSD. + */ explicit DisplayProxyMAX7456(Max7456 *osd); + /** + * OSD on, external video left untouched. + */ + bool on(); + /** + * OSD off, external video off. + */ + bool off(); + /** + * Depending on the font loaded into the Max7456 the output might not be ASCII compatible. + */ bool write(int x, int y, const char *text) override; bool clear() override; - bool setOffset(int x, int y) override; + + /** + * Adjust the display offset. + * Since the signal is analog the characters might be rendered outside the display area + */ + bool setOffset(int x, int y); bool externalVideo(bool enabled); bool onScreenDisplay(bool enabled); diff --git a/src/main.cpp b/src/main.cpp index 6eb5c53..16e0114 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -10,6 +10,11 @@ Max7456 osd; DisplayProxyMAX7456 display(&osd); CommandHandler cmd_handler(&display); +/** + * Setup handler (Arduino Style) + * + * Write some debug information to the serial port and initialize the display. + */ void setup() { Serial.begin(BAUDRATE); @@ -34,6 +39,11 @@ void setup() Serial.println("Ready!"); } +/** + * Loop handler (Arduino Style) + * + * Continously read the serial port if input is available. On line change send to the command handler. + */ void loop() { while (Serial.available() > 0)