├── Docs ├── README.md └── I2C_Scanner.txt ├── CODEOWNERS ├── examples └── PowerStat │ ├── platformio.ini │ ├── main.cpp │ └── PowerStat.ino ├── library.properties ├── .github └── FUNDING.yml ├── library.json ├── .gitignore ├── LICENSE ├── README.md ├── src ├── Definition.h └── Console.h └── keywords.txt /Docs/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @akkoyun -------------------------------------------------------------------------------- /examples/PowerStat/platformio.ini: -------------------------------------------------------------------------------- 1 | ; PlatformIO Project Configuration File 2 | ; 3 | ; Build options: build flags, source filter 4 | ; Upload options: custom upload port, speed and extra flags 5 | ; Library options: dependencies, extra library storages 6 | ; Advanced options: extra scripting 7 | ; 8 | ; Please visit documentation for the other options and examples 9 | ; https://docs.platformio.org/page/projectconf.html 10 | 11 | [env:nanoatmega328new] 12 | platform = atmelavr 13 | board = nanoatmega328new 14 | framework = arduino 15 | lib_deps = akkoyun/Console@^1.8.0 16 | -------------------------------------------------------------------------------- /library.properties: -------------------------------------------------------------------------------- 1 | name=Console 2 | version=1.8.6 3 | author=Gunce Akkoyun 4 | maintainer=Gunce Akkoyun 5 | sentence=Arduino based VT100 comparable serial console library. 6 | paragraph=Virtual terminal sequences are control character sequences that can control cursor movement, color/font mode, and other operations when written to the output stream. Sequences may also be received on the input stream in response to an output stream query information sequence or as an encoding of user input when the appropriate mode is set. 7 | category=Communication 8 | url=https://github.com/akkoyun/Console 9 | architectures=* 10 | includes=Console.h 11 | types=Arduino -------------------------------------------------------------------------------- /examples/PowerStat/main.cpp: -------------------------------------------------------------------------------- 1 | // Define Debug Mode 2 | #define _DEBUG_ 3 | 4 | // Include Libraries 5 | #include 6 | 7 | // Define Object 8 | PowerStat_Console Terminal(Serial); 9 | 10 | void setup() { 11 | 12 | // Start Serial Stream 13 | Serial.begin(115200); 14 | 15 | // Start Terminal 16 | Terminal.Begin(); 17 | 18 | Terminal.AT_Command(F("AT+GMR")); 19 | delay(1000); 20 | Terminal.OK(true); 21 | 22 | // Show Message 23 | Terminal.Show_Message(_Console_BLUE_, F("Hello World!")); 24 | 25 | } 26 | 27 | void loop() { 28 | 29 | // Print Terminal Text 30 | Terminal.Text(2, 13, _Console_RED_, String(millis())); 31 | 32 | // Print Status Register 33 | Terminal.Show_Status(1, millis()); 34 | 35 | } -------------------------------------------------------------------------------- /examples/PowerStat/PowerStat.ino: -------------------------------------------------------------------------------- 1 | // Define Debug Mode 2 | #define _DEBUG_ 3 | 4 | // Include Libraries 5 | #include 6 | 7 | // Define Object 8 | PowerStat_Console Terminal(Serial); 9 | 10 | void setup() { 11 | 12 | // Start Serial Stream 13 | Serial.begin(115200); 14 | 15 | // Start Terminal 16 | Terminal.Begin(); 17 | 18 | Terminal.AT_Command(F("AT+GMR")); 19 | delay(1000); 20 | Terminal.OK(true); 21 | 22 | // Show Message 23 | Terminal.Show_Message(_Console_BLUE_, F("Hello World!")); 24 | 25 | } 26 | 27 | void loop() { 28 | 29 | // Print Terminal Text 30 | Terminal.Text(2, 13, _Console_RED_, String(millis())); 31 | 32 | // Print Status Register 33 | Terminal.Show_Status(1, millis()); 34 | 35 | } -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: akkoyun 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 13 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']% -------------------------------------------------------------------------------- /library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Console", 3 | "version": "1.8.6", 4 | "keywords": "Console, Serial, VT100, UART, Color, Terminal", 5 | "description": "Virtual terminal sequences are control character sequences that can control cursor movement, color/font mode, and other operations when written to the output stream. Sequences may also be received on the input stream in response to an output stream query information sequence or as an encoding of user input when the appropriate mode is set. Arduino based VT100 comparable serial console library.", 6 | "authors": 7 | { 8 | "name": "Mehmet Günce Akkoyun", 9 | "email": "akkoyun@me.com", 10 | "url": "https://github.com/akkoyun" 11 | }, 12 | "license": "MIT", 13 | "frameworks": "arduino", 14 | "headers": "Console.h", 15 | "platforms": 16 | [ 17 | "atmelavr", 18 | "atmelmegaavr" 19 | ], 20 | "repository": 21 | { 22 | "type": "git", 23 | "url": "https://github.com/akkoyun/Console.git" 24 | }, 25 | "examples": [ 26 | { 27 | "name": "PowerStat", 28 | "base": "examples/PowerStat", 29 | "files": [ 30 | "PowerStat.ino" 31 | ] 32 | } 33 | ] 34 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ### macOS ### 2 | # General 3 | .DS_Store 4 | .AppleDouble 5 | .LSOverride 6 | 7 | # Icon must end with two \r 8 | Icon 9 | 10 | # Thumbnails 11 | ._* 12 | 13 | # Files that might appear in the root of a volume 14 | .DocumentRevisions-V100 15 | .fseventsd 16 | .Spotlight-V100 17 | .TemporaryItems 18 | .Trashes 19 | .VolumeIcon.icns 20 | .com.apple.timemachine.donotpresent 21 | 22 | # Directories potentially created on remote AFP share 23 | .AppleDB 24 | .AppleDesktop 25 | Network Trash Folder 26 | Temporary Items 27 | .apdisk 28 | 29 | ### macOS Patch ### 30 | # iCloud generated files 31 | *.icloud 32 | 33 | ### PlatformIO ### 34 | .pioenvs 35 | .piolibdeps 36 | .clang_complete 37 | .gcc-flags.json 38 | .pio 39 | 40 | ### VisualStudioCode ### 41 | .vscode/* 42 | !.vscode/settings.json 43 | !.vscode/tasks.json 44 | !.vscode/launch.json 45 | !.vscode/extensions.json 46 | !.vscode/*.code-snippets 47 | 48 | # Local History for Visual Studio Code 49 | .history/ 50 | 51 | # Built Visual Studio Code Extensions 52 | *.vsix 53 | 54 | ### VisualStudioCode Patch ### 55 | # Ignore all local history of files 56 | .history 57 | .ionide 58 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Mehmet Günce Akkoyun 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # VT100 Console Library ^V1.8^ 2 | 3 | ![GitHub release (latest by date)](https://img.shields.io/github/v/release/akkoyun/Console) ![arduino-library-badge](https://www.ardu-badge.com/badge/Console.svg?) ![Visits Badge](https://badges.pufler.dev/visits/akkoyun/Console) ![GitHub stars](https://img.shields.io/github/stars/akkoyun/Console?style=flat&logo=github) ![Updated Badge](https://badges.pufler.dev/updated/akkoyun/Console) ![PlatformIO Registry](https://badges.registry.platformio.org/packages/akkoyun/library/Console.svg) 4 | 5 | --- 6 | 7 | ## Abstract 8 | 9 | Virtual terminal sequences are control character sequences that can control cursor movement, color/font mode, and other operations when written to the output stream. Sequences may also be received on the input stream in response to an output stream query information sequence or as an encoding of user input when the appropriate mode is set. 10 | 11 | Arduino based VT100 comparable serial console library. 12 |
13 | 14 |

15 | 16 | --- 17 | 18 | [![Support me](https://img.shields.io/badge/Support-PATREON-GREEN.svg)](https://www.patreon.com/bePatron?u=62967889) ![Twitter Follow](https://img.shields.io/twitter/follow/gunceakkoyun?style=social) ![YouTube Channel Views](https://img.shields.io/youtube/channel/views/UCIguQGdaBT1GnnVMz5qAZ2Q?style=social) ![Repos Badge](https://badges.pufler.dev/repos/akkoyun) [![E-Mail](https://img.shields.io/badge/E_Mail-Mehmet_Gunce_Akkoyun-blue.svg)](mailto:akkoyun@me.com) ![GitHub](https://img.shields.io/github/license/akkoyun/Statistical) 19 | -------------------------------------------------------------------------------- /src/Definition.h: -------------------------------------------------------------------------------- 1 | // Debug Mode Definitions 2 | //#define _DEBUG_ 3 | 4 | // Color Definitions 5 | #define _Console_BLACK_ (uint8_t)30 6 | #define _Console_RED_ (uint8_t)31 7 | #define _Console_GREEN_ (uint8_t)32 8 | #define _Console_YELLOW_ (uint8_t)33 9 | #define _Console_BLUE_ (uint8_t)34 10 | #define _Console_MAGENTA_ (uint8_t)35 11 | #define _Console_CYAN_ (uint8_t)36 12 | #define _Console_WHITE_ (uint8_t)37 13 | #define _Console_GRAY_ (uint8_t)90 14 | 15 | // Text Format Definitions 16 | #define _Console_RST_ (uint8_t)0 17 | #define _Console_BRIGHT_ (uint8_t)1 18 | #define _Console_DIM_ (uint8_t)2 19 | #define _Console_UNDERSCORE_ (uint8_t)4 20 | #define _Console_BLINK_ (uint8_t)5 21 | #define _Console_REVERSE_ (uint8_t)7 22 | #define _Console_HIDDEN_ (uint8_t)8 23 | 24 | // Clear Type Definitions 25 | #define _Console_LINE_AFTER_CURSOR_ (uint8_t)0 26 | #define _Console_LINE_TO_CURSOR_ (uint8_t)1 27 | #define _Console_LINE_ (uint8_t)2 28 | #define _Console_SCREEN_ (uint8_t)3 29 | #define _Console_ALL_ (uint8_t)4 30 | 31 | // Divider Definitions 32 | #define HORIZONTAL (bool)true 33 | #define VERTICAL (bool)false 34 | 35 | // Color Choice 36 | #define SELECT_COLOR(_VALUE, _MIN, _MAX) ((_VALUE) <= (_MIN) ? _Console_RED_ : ((_VALUE) >= (_MAX) ? _Console_GREEN_ : _Console_WHITE_)) 37 | 38 | // Console Definitions 39 | #ifndef _Console_Message_X_ 40 | #define _Console_Message_X_ (uint8_t)21 41 | #endif 42 | #ifndef _Console_Message_Y_ 43 | #define _Console_Message_Y_ (uint8_t)4 44 | #endif 45 | #ifndef _Console_AT_Status_X_ 46 | #define _Console_AT_Status_X_ (uint8_t)21 47 | #endif 48 | #ifndef _Console_AT_Status_Y_ 49 | #define _Console_AT_Status_Y_ (uint8_t)84 50 | #endif -------------------------------------------------------------------------------- /keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For Console 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatype (KEYWORD1) 7 | ####################################### 8 | 9 | Console KEYWORD1 10 | PowerStat_Console KEYWORD1 11 | I2C_Scanner_Console KEYWORD1 12 | TH_Meter_Console KEYWORD1 13 | Voltmeter_Console KEYWORD1 14 | MAX78630_Console KEYWORD1 15 | Analog_Pressure_Console KEYWORD1 16 | 17 | ####################################### 18 | # Methods and Functions (KEYWORD2) 19 | ####################################### 20 | 21 | Begin KEYWORD2 22 | Clear KEYWORD2 23 | Cursor KEYWORD2 24 | Box KEYWORD2 25 | Dot KEYWORD2 26 | Bracket KEYWORD2 27 | Divider KEYWORD2 28 | Text_Color KEYWORD2 29 | Background_Color KEYWORD2 30 | Text_Format KEYWORD2 31 | Set_Cursor KEYWORD2 32 | Beep KEYWORD2 33 | Text KEYWORD2 34 | OK KEYWORD2 35 | AT_Command KEYWORD2 36 | 37 | ####################################### 38 | # Constants (LITERAL1) 39 | ####################################### 40 | 41 | _Console LITERAL1 42 | _Console_BLACK_ LITERAL1 43 | _Console_RED_ LITERAL1 44 | _Console_GREEN_ LITERAL1 45 | _Console_YELLOW_ LITERAL1 46 | _Console_BLUE_ LITERAL1 47 | _Console_MAGENTA_ LITERAL1 48 | _Console_CYAN_ LITERAL1 49 | _Console_WHITE_ LITERAL1 50 | _Console_GRAY_ LITERAL1 51 | _Console_RST_ LITERAL1 52 | _Console_BRIGHT_ LITERAL1 53 | _Console_DIM_ LITERAL1 54 | _Console_UNDERSCORE_ LITERAL1 55 | _Console_BLINK_ LITERAL1 56 | _Console_REVERSE_ LITERAL1 57 | _Console_HIDDEN_ LITERAL1 58 | _Console_LINE_AFTER_CURSOR_ LITERAL1 59 | _Console_LINE_TO_CURSOR_ LITERAL1 60 | _Console_LINE_ LITERAL1 61 | _Console_SCREEN_ LITERAL1 62 | _Console_ALL_ LITERAL1 63 | HORIZONTAL LITERAL1 64 | VERTICAL LITERAL1 -------------------------------------------------------------------------------- /Docs/I2C_Scanner.txt: -------------------------------------------------------------------------------- 1 | ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ 2 | │ I2C Device Explorer │ 3 | ├───────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┤ 4 | │ │ 0x_0 │ 0x_1 │ 0x_2 │ 0x_3 │ 0x_4 │ 0x_5 │ 0x_6 │ 0x_7 │ 0x_8 │ 0x_9 │ 0x_a │ 0x_b │ 0x_c │ 0x_d │ 0x_e │ 0x_f │ 5 | ├───────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤ 6 | │ 0x0_ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ 7 | ├───────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤ 8 | │ 0x1_ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ 9 | ├───────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤ 10 | │ 0x2_ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ 11 | ├───────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤ 12 | │ 0x3_ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ 13 | ├───────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤ 14 | │ 0x4_ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ 15 | ├───────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤ 16 | │ 0x5_ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ 17 | ├───────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤ 18 | │ 0x6_ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ 19 | ├───────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤ 20 | │ 0x7_ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ 21 | ├───────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┤ 22 | │ Total connected device : Current Mux Channel [0-8] : │ 23 | └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ 24 | github.com/akkoyun -------------------------------------------------------------------------------- /src/Console.h: -------------------------------------------------------------------------------- 1 | #ifndef __Console__ 2 | #define __Console__ 3 | 4 | // Include Arduino Library 5 | #ifndef Arduino_h 6 | #include 7 | #endif 8 | 9 | // Include Definition File 10 | #include "Definition.h" 11 | 12 | // Console Class 13 | class Console { 14 | 15 | // Private Context 16 | private: 17 | 18 | // Stream Variable 19 | Stream * Console_Serial; 20 | 21 | // Variable Declaration 22 | struct Struct_Console_Buffer { 23 | 24 | // Text Color 25 | uint8_t Text_Color = 255; 26 | 27 | // Background Color 28 | uint8_t Background_Color = 255; 29 | 30 | // Text Format 31 | uint8_t Text_Format = 255; 32 | 33 | } Buffer; 34 | 35 | // Public Context 36 | public: 37 | 38 | // Construct a new Console object 39 | explicit Console(Stream &_Serial) { 40 | 41 | // Set Serial 42 | this->Console_Serial = &_Serial; 43 | 44 | } 45 | 46 | // Begin Console. 47 | void Begin(void) { 48 | 49 | // Control for Debug Mode 50 | #ifdef _DEBUG_ 51 | 52 | // Cursor Off 53 | this->Cursor(false); 54 | 55 | // Clear Screen 56 | this->Clear(_Console_SCREEN_); 57 | 58 | // Set Text Color 59 | this->Text_Color(_Console_WHITE_); 60 | 61 | // Reset Delay 62 | delay(5); 63 | 64 | #endif 65 | 66 | } 67 | 68 | // Clear Terminal Function. 69 | void Clear(const uint8_t _Type) { 70 | 71 | // Control for Debug Mode 72 | #ifdef _DEBUG_ 73 | 74 | // Clear Terminal Type 75 | switch (_Type) { 76 | 77 | // Clear Line After Cursor 78 | case _Console_LINE_AFTER_CURSOR_: { 79 | 80 | // Print Clear Line After Cursor Command 81 | Console_Serial->print(F("\e[K")); 82 | 83 | // End Case 84 | break; 85 | 86 | } 87 | 88 | // Clear Line to Cursor 89 | case _Console_LINE_TO_CURSOR_: { 90 | 91 | // Print Clear Line to Cursor Command 92 | Console_Serial->print(F("\e[1K")); 93 | 94 | // End Case 95 | break; 96 | 97 | } 98 | 99 | // Clear Line 100 | case _Console_LINE_: { 101 | 102 | // Print Clear Line Command 103 | Console_Serial->print(F("\e[2K")); 104 | 105 | // End Case 106 | break; 107 | 108 | } 109 | 110 | // Clear Screen 111 | case _Console_SCREEN_: { 112 | 113 | // Print Clear Screen Command 114 | Console_Serial->print(F("\e[2J")); 115 | 116 | // End Case 117 | break; 118 | 119 | } 120 | 121 | // Clear All 122 | case _Console_ALL_: { 123 | 124 | // Print Clear All Command 125 | Console_Serial->print(F("\e[1;1H\e[2J")); 126 | 127 | // End Case 128 | break; 129 | 130 | } 131 | 132 | // Default 133 | default: { 134 | 135 | // End Case 136 | break; 137 | 138 | } 139 | 140 | } 141 | 142 | #endif 143 | 144 | } 145 | 146 | // Change Cursor Visibility Function. 147 | void Cursor(const bool _State) { 148 | 149 | // Control for Debug Mode 150 | #ifdef _DEBUG_ 151 | 152 | // Cursor On 153 | if (_State) Console_Serial->print(F("\e[?25h")); 154 | 155 | // Cursor Off 156 | if (!_State) Console_Serial->print(F("\e[?25l")); 157 | 158 | #endif 159 | 160 | } 161 | 162 | // Set Cursor Position Function. 163 | void Set_Cursor(const uint8_t _X, const uint8_t _Y) { 164 | 165 | // Control for Debug Mode 166 | #ifdef _DEBUG_ 167 | 168 | // Print Cursor Position 169 | Console_Serial->print(F("\e[")); 170 | Console_Serial->print(_X); 171 | Console_Serial->print(F(";")); 172 | Console_Serial->print(_Y); 173 | Console_Serial->print(F("H")); 174 | 175 | #endif 176 | 177 | } 178 | 179 | // Set Text Color Function. 180 | void Text_Color(const uint8_t _Color) { 181 | 182 | // Control for Debug Mode 183 | #ifdef _DEBUG_ 184 | 185 | // Control for Buffer 186 | if (_Color != this->Buffer.Text_Color) { 187 | 188 | // Print Cursor Position 189 | Console_Serial->print(F("\e[")); 190 | Console_Serial->print(_Color); 191 | Console_Serial->print(F("m")); 192 | 193 | // Update Buffer Variable 194 | this->Buffer.Text_Color = _Color; 195 | 196 | } 197 | 198 | #endif 199 | 200 | } 201 | 202 | // Set Text Format Function 203 | void Text_Format(const uint8_t _Format) { 204 | 205 | // Control for Debug Mode 206 | #ifdef _DEBUG_ 207 | 208 | // Control for Buffer 209 | if (_Format != this->Buffer.Text_Format) { 210 | 211 | // Print Cursor Position 212 | Console_Serial->print(F("\e[")); 213 | Console_Serial->print(_Format); 214 | Console_Serial->print(F("m")); 215 | 216 | // Update Buffer Variable 217 | this->Buffer.Text_Format = _Format; 218 | 219 | } 220 | 221 | #endif 222 | 223 | } 224 | 225 | // Set Back Ground Color Function. 226 | void Background_Color(const uint8_t _Color) { 227 | 228 | // Control for Debug Mode 229 | #ifdef _DEBUG_ 230 | 231 | // Control for Buffer 232 | if (_Color != this->Buffer.Background_Color) { 233 | 234 | // Print Cursor Position 235 | Console_Serial->print(F("\e[")); 236 | Console_Serial->print((uint8_t)(_Color + 10)); 237 | Console_Serial->print(F("m")); 238 | 239 | // Update Buffer Variable 240 | this->Buffer.Background_Color = _Color; 241 | 242 | } 243 | 244 | #endif 245 | 246 | } 247 | 248 | // Print Text to Specified Position and Color. 249 | void Text(const uint8_t _X, const uint8_t _Y, const uint8_t _Color, const __FlashStringHelper * _Value) { 250 | 251 | // Control for Debug Mode 252 | #ifdef _DEBUG_ 253 | 254 | // Set Text Cursor Position 255 | this->Set_Cursor(_X, _Y); 256 | 257 | // Set Text Color 258 | this->Text_Color(_Color); 259 | 260 | // Print Text 261 | Console_Serial->print(_Value); 262 | 263 | #endif 264 | 265 | } 266 | void Text(const uint8_t _X, const uint8_t _Y, const uint8_t _Color, const char _Value) { 267 | 268 | // Control for Debug Mode 269 | #ifdef _DEBUG_ 270 | 271 | // Set Text Cursor Position 272 | this->Set_Cursor(_X, _Y); 273 | 274 | // Set Text Color 275 | this->Text_Color(_Color); 276 | 277 | // Print Text 278 | Console_Serial->print(_Value); 279 | 280 | #endif 281 | 282 | } 283 | void Text(const uint8_t _X, const uint8_t _Y, const uint8_t _Color, const char* _Value) { 284 | 285 | // Control for Debug Mode 286 | #ifdef _DEBUG_ 287 | 288 | // Set Text Cursor Position 289 | this->Set_Cursor(_X, _Y); 290 | 291 | // Set Text Color 292 | this->Text_Color(_Color); 293 | 294 | // Print Text 295 | Console_Serial->print(_Value); 296 | 297 | #endif 298 | 299 | } 300 | template void Text(const uint8_t _X, const uint8_t _Y, const uint8_t _Color, T _Value) { 301 | 302 | // Control for Debug Mode 303 | #ifdef _DEBUG_ 304 | 305 | // Set Text Cursor Position 306 | this->Set_Cursor(_X, _Y); 307 | 308 | // Set Text Color 309 | this->Text_Color(_Color); 310 | 311 | // Print Text 312 | Console_Serial->print(_Value); 313 | 314 | #endif 315 | 316 | } 317 | 318 | // Draw Box Function. 319 | void Box(const uint8_t _X1, const uint8_t _Y1, const uint8_t _X2, const uint8_t _Y2, const __FlashStringHelper * _Text, const uint8_t _Number = 0, const bool _Header = false, const bool _Footer = false) { 320 | 321 | // Control for Debug Mode 322 | #ifdef _DEBUG_ 323 | 324 | // Set Text Color 325 | this->Text_Color(_Console_WHITE_); 326 | 327 | // Set Text Format 328 | this->Text_Format(_Console_DIM_); 329 | 330 | // Print Corners 331 | this->Text(_X1, _Y1, _Console_WHITE_, F("┌")); 332 | this->Text(_X2, _Y1, _Console_WHITE_, F("└")); 333 | this->Text(_X1, _Y2, _Console_WHITE_, F("┐")); 334 | this->Text(_X2, _Y2, _Console_WHITE_, F("┘")); 335 | 336 | // Print Lines 337 | for (uint8_t i = _X1 + 1; i <= _X2 - 1; i++) { 338 | 339 | // Print Lines 340 | this->Text(i, _Y1, _Console_WHITE_, F("│")); 341 | this->Text(i, _Y2, _Console_WHITE_, F("│")); 342 | 343 | } 344 | for (uint8_t i = _Y1 + 1; i <= _Y2 - 1; i++) { 345 | 346 | // Print Lines 347 | this->Text(_X1, i, _Console_WHITE_, F("─")); 348 | this->Text(_X2, i, _Console_WHITE_, F("─")); 349 | 350 | } 351 | 352 | // Print Header 353 | this->Text(_X1, _Y1 + 2, _Console_YELLOW_, _Text); 354 | 355 | // Print Header Number 356 | 357 | // Print Header Number 358 | if (_Number > 0) { 359 | 360 | // Set Text Color 361 | this->Text_Color(_Console_GRAY_); 362 | 363 | // Set Cursor Position 364 | this->Set_Cursor(_X1, _Y2 - 5); 365 | 366 | // Print HEX 367 | Serial.printf(F("[%02hhu]"), _Number); 368 | 369 | } 370 | 371 | // Draw Header 372 | if (_Header) { 373 | 374 | // Print Corners 375 | this->Text(_X1 + 2, _Y1, _Console_WHITE_, F("├")); 376 | this->Text(_X1 + 2, _Y2, _Console_WHITE_, F("┤")); 377 | 378 | // Print Lines 379 | for (uint8_t i = _Y1 + 1; i <= _Y2 - 1; i++) this->Text(_X1 + 2, i, _Console_WHITE_, F("─")); 380 | 381 | } 382 | 383 | // Draw Footer 384 | if (_Footer) { 385 | 386 | // Print Corners 387 | this->Text(_X2 - 2, _Y1, _Console_WHITE_, F("├")); 388 | this->Text(_X2 - 2, _Y2, _Console_WHITE_, F("┤")); 389 | 390 | // Print Lines 391 | for (uint8_t i = _Y1 + 1; i <= _Y2 - 1; i++) this->Text(_X2 - 2, i, _Console_WHITE_, F("─")); 392 | 393 | } 394 | 395 | #endif 396 | 397 | } 398 | 399 | // Horizontal Line Divider Function. 400 | void Divider(const bool _Type, const uint8_t _X, const uint8_t _Y, const uint8_t _Length, const bool _End = false) { 401 | 402 | // Control for Debug Mode 403 | #ifdef _DEBUG_ 404 | 405 | // Control Horizontal divider type 406 | if (_Type == HORIZONTAL) { 407 | 408 | // Print Corners 409 | if (_End) { 410 | 411 | // Print Corners 412 | this->Text(_X, _Y, _Console_WHITE_, F("├")); 413 | this->Text(_X, _Y + _Length, _Console_WHITE_, F("┤")); 414 | 415 | } 416 | 417 | // Print Line 418 | for (uint8_t i = _Y + 1; i <= _Y + _Length - 1; i++) {this->Text(_X, i, _Console_WHITE_, F("─"));} 419 | 420 | } 421 | 422 | // Control Vertical divider type 423 | if (_Type == VERTICAL) { 424 | 425 | // Print Corners 426 | if (_End) { 427 | 428 | // Print Corners 429 | this->Text(_X, _Y, _Console_WHITE_, F("┬")); 430 | this->Text(_X + _Length, _Y, _Console_WHITE_, F("┴")); 431 | 432 | } 433 | 434 | // Print Line 435 | for (uint8_t i = _X + 1; i <= _X + _Length - 1; i++) this->Text(i, _Y, _Console_WHITE_, F("│")); 436 | 437 | } 438 | 439 | #endif 440 | 441 | } 442 | 443 | // Dot Print Function. 444 | void Dot(const uint8_t _X, const uint8_t _Y, const uint8_t _Count) { 445 | 446 | // Control for Debug Mode 447 | #ifdef _DEBUG_ 448 | 449 | // Print Dots 450 | for (uint8_t i = 0; i < _Count; i++) { 451 | 452 | // Print Dot 453 | this->Text(_X, _Y + i, _Console_GRAY_, F(".")); 454 | 455 | } 456 | 457 | #endif 458 | 459 | } 460 | 461 | // Dot Space Function. 462 | void Space(const uint8_t _X, const uint8_t _Y, const uint8_t _Count) { 463 | 464 | // Control for Debug Mode 465 | #ifdef _DEBUG_ 466 | 467 | // Print Dots 468 | for (uint8_t i = 0; i < _Count; i++) { 469 | 470 | // Print Dot 471 | this->Text(_X, _Y + i, _Console_GRAY_, F(" ")); 472 | 473 | } 474 | 475 | #endif 476 | 477 | } 478 | 479 | // Bracket Place Holder Function. 480 | void Bracket(const uint8_t _X, const uint8_t _Y, const uint8_t _Size) { 481 | 482 | // Control for Debug Mode 483 | #ifdef _DEBUG_ 484 | 485 | // Print Bracket Start 486 | this->Text(_X, _Y, _Console_WHITE_, F("[")); 487 | 488 | // Print Bracket Left 489 | this->Text(_X, _Y + _Size, _Console_WHITE_, F("]")); 490 | 491 | #endif 492 | 493 | } 494 | 495 | // GSM Command Proccess 496 | void AT_Command(const __FlashStringHelper * _Command) { 497 | 498 | // Control for Debug Mode 499 | #ifdef _DEBUG_ 500 | 501 | // Declare Line Size 502 | uint8_t _Message_Size = 35; 503 | 504 | // Clear Line 505 | this->Space(_Console_AT_Status_X_, _Console_AT_Status_Y_, _Message_Size); 506 | 507 | // Print Dot 508 | this->Dot(_Console_AT_Status_X_, _Console_AT_Status_Y_ + sizeof(_Command), _Message_Size - sizeof(_Command) - 5); 509 | 510 | // Print Command 511 | this->Text(_Console_AT_Status_X_, _Console_AT_Status_Y_, _Console_WHITE_, _Command); 512 | 513 | // Print Response Wait Bracket 514 | this->Bracket(_Console_AT_Status_X_, _Console_AT_Status_Y_ + _Message_Size - 5, 5); 515 | 516 | // Print Response Wait Dot 517 | this->Text(_Console_AT_Status_X_, _Console_AT_Status_Y_ + _Message_Size - 4, _Console_BLUE_, F(" .. ")); 518 | 519 | #endif 520 | 521 | } 522 | 523 | // OK Decide Function. 524 | void OK(const bool _Result) { 525 | 526 | // Control for Debug Mode 527 | #ifdef _DEBUG_ 528 | 529 | // Print Command State 530 | if (_Result) { 531 | 532 | // Success 533 | this->Text(_Console_AT_Status_X_, _Console_AT_Status_Y_ + 32, _Console_GREEN_, F("OK")); 534 | 535 | } else { 536 | 537 | // Fail 538 | this->Text(_Console_AT_Status_X_, _Console_AT_Status_Y_ + 31, _Console_RED_, F("FAIL")); 539 | 540 | } 541 | 542 | #endif 543 | 544 | } 545 | 546 | // Terminal Beep Sound Function. 547 | void Beep(void) { 548 | 549 | // Control for Debug Mode 550 | #ifdef _DEBUG_ 551 | 552 | // Beep Terminal. 553 | Console_Serial->print(F("\x07")); 554 | 555 | #endif 556 | 557 | } 558 | 559 | // Print HEX Function 560 | void Print_HEX(const uint8_t _X, const uint8_t _Y, const uint8_t _Color, const uint8_t _Value) { 561 | 562 | // Set Text Color 563 | this->Text_Color(_Color); 564 | 565 | // Set Cursor Position 566 | this->Set_Cursor(_X, _Y); 567 | 568 | // Print HEX 569 | Serial.printf(F("0x%02X"), _Value); 570 | 571 | } 572 | void Print_HEX(const uint8_t _X, const uint8_t _Y, const uint8_t _Color, const uint16_t _Value) { 573 | 574 | // Set Text Color 575 | this->Text_Color(_Color); 576 | 577 | // Set Cursor Position 578 | this->Set_Cursor(_X, _Y); 579 | 580 | // Print HEX 581 | Serial.printf(F("0x%02X%02X"), (_Value >> 8), (_Value & 0xFF)); 582 | 583 | } 584 | void Print_HEX(const uint8_t _X, const uint8_t _Y, const uint8_t _Color, const uint32_t _Value) { 585 | 586 | // Set Text Color 587 | this->Text_Color(_Color); 588 | 589 | // Set Cursor Position 590 | this->Set_Cursor(_X, _Y); 591 | 592 | // Set Low and High Byte 593 | uint8_t _MSB1 = (_Value >> 24) & 0xFF; 594 | uint8_t _MSB2 = (_Value >> 16) & 0xFF; 595 | uint8_t _LSB1 = (_Value >> 8) & 0xFF; 596 | uint8_t _LSB2 = (_Value & 0xFF); 597 | 598 | // Print HEX 599 | Serial.printf(F("0x%02X%02X%02X%02X"), _MSB1, _MSB2, _LSB1, _LSB2); 600 | 601 | } 602 | 603 | }; 604 | 605 | // Console Class 606 | class PowerStat_Console : public Console { 607 | 608 | // Public Context 609 | private: 610 | 611 | // Control for Debug Mode 612 | #ifdef _DEBUG_ 613 | 614 | // Hardware Diagnostic Box Print Function. 615 | void Diagnostic(const uint8_t _X1, const uint8_t _Y1, const uint8_t _X2, const uint8_t _Y2) { 616 | 617 | // Draw Hardware Diagnostic Box 618 | Console::Box(_X1, _Y1, _X2, _Y2, F("Hardware Diagnostic"), 1, false, false); 619 | 620 | // Print Text 621 | Console::Text(_X1 + 1, _Y1 + 2, _Console_WHITE_, F("I2C RTC (0x52)")); Console::Dot(_X1 + 1, _Y1 + 16, (_Y2 - 7) - (_Y1 + 16)); Console::Bracket(_X1 + 1, _Y2 - 7, 5); 622 | Console::Text(_X1 + 2, _Y1 + 2, _Console_WHITE_, F("I2C Serial ID (0x50)")); Console::Dot(_X1 + 2, _Y1 + 22, (_Y2 - 7) - (_Y1 + 22)); Console::Bracket(_X1 + 2, _Y2 - 7, 5); 623 | Console::Text(_X1 + 3, _Y1 + 2, _Console_WHITE_, F("I2C Temperature (0x40)")); Console::Dot(_X1 + 3, _Y1 + 24, (_Y2 - 7) - (_Y1 + 24)); Console::Bracket(_X1 + 3, _Y2 - 7, 5); 624 | Console::Text(_X1 + 4, _Y1 + 2, _Console_WHITE_, F("I2C Battery Gauge (0x36)")); Console::Dot(_X1 + 4, _Y1 + 26, (_Y2 - 7) - (_Y1 + 26)); Console::Bracket(_X1 + 4, _Y2 - 7, 5); 625 | Console::Text(_X1 + 5, _Y1 + 2, _Console_WHITE_, F("I2C Battery Charger (0x6B)")); Console::Dot(_X1 + 5, _Y1 + 28, (_Y2 - 7) - (_Y1 + 28)); Console::Bracket(_X1 + 5, _Y2 - 7, 5); 626 | Console::Text(_X1 + 6, _Y1 + 2, _Console_WHITE_, F("Energy Analyser")); Console::Dot(_X1 + 6, _Y1 + 17, (_Y2 - 7) - (_Y1 + 17)); Console::Bracket(_X1 + 6, _Y2 - 7, 5); 627 | 628 | } 629 | 630 | // Detail Box Print Function. 631 | void Device_Detail(const uint8_t _X1, const uint8_t _Y1, const uint8_t _X2, const uint8_t _Y2) { 632 | 633 | // Draw Hardware Diagnostic Box 634 | Console::Box(_X1, _Y1, _X2, _Y2, F("Hardware Detail"), 2, false, false); 635 | 636 | // Print Text 637 | Console::Text(_X1 + 1, _Y1 + 2, _Console_WHITE_, F("Serial ID")); Console::Dot(_X1 + 1, _Y1 + 11, (_Y2 - 19) - (_Y1 + 11)); Console::Bracket(_X1 + 1, _Y2 - 19, 17); 638 | Console::Text(_X1 + 2, _Y1 + 2, _Console_WHITE_, F("Firmware Version")); Console::Dot(_X1 + 2, _Y1 + 18, (_Y2 - 11) - (_Y1 + 18)); Console::Bracket(_X1 + 2, _Y2 - 11, 9); 639 | Console::Text(_X1 + 3, _Y1 + 2, _Console_WHITE_, F("Hardware Version")); Console::Dot(_X1 + 3, _Y1 + 18, (_Y2 - 11) - (_Y1 + 18)); Console::Bracket(_X1 + 3, _Y2 - 11, 9); 640 | Console::Text(_X1 + 4, _Y1 + 2, _Console_WHITE_, F("Module Temperature")); Console::Dot(_X1 + 4, _Y1 + 20, (_Y2 - 10) - (_Y1 + 20)); Console::Bracket(_X1 + 4, _Y2 - 10, 8); Console::Text(_X1 + 4, _Y2 - 3, _Console_WHITE_, F("C")); 641 | Console::Text(_X1 + 5, _Y1 + 2, _Console_WHITE_, F("Module Humidity")); Console::Dot(_X1 + 5, _Y1 + 17, (_Y2 - 10) - (_Y1 + 17)); Console::Bracket(_X1 + 5, _Y2 - 10, 8); Console::Text(_X1 + 5, _Y2 - 3, _Console_WHITE_, F("%")); 642 | Console::Text(_X1 + 6, _Y1 + 2, _Console_WHITE_, F("Send Interval")); Console::Dot(_X1 + 6, _Y1 + 15, (_Y2 - 10) - (_Y1 + 15)); Console::Bracket(_X1 + 6, _Y2 - 10, 8); Console::Text(_X1 + 6, _Y2 - 5, _Console_WHITE_, F("Min")); 643 | 644 | } 645 | 646 | // Battery Print Function. 647 | void Battery(const uint8_t _X1, const uint8_t _Y1, const uint8_t _X2, const uint8_t _Y2) { 648 | 649 | // Draw Hardware Diagnostic Box 650 | Console::Box(_X1, _Y1, _X2, _Y2, F("Battery"), 3, false, false); 651 | 652 | // Print Text 653 | Console::Text(_X1 + 1, _Y1 + 2, _Console_WHITE_, F("Instant Voltage")); Console::Dot(_X1 + 1, _Y1 + 17, (_Y2 - 9) - (_Y1 + 17)); Console::Bracket(_X1 + 1, _Y2 - 9, 7); Console::Text(_X1 + 1, _Y2 - 3, _Console_WHITE_, F("V")); 654 | Console::Text(_X1 + 2, _Y1 + 2, _Console_WHITE_, F("Temperature")); Console::Dot(_X1 + 2, _Y1 + 13, (_Y2 - 10) - (_Y1 + 13)); Console::Bracket(_X1 + 2, _Y2 - 10, 8); Console::Text(_X1 + 2, _Y2 - 3, _Console_WHITE_, F("C")); 655 | Console::Text(_X1 + 3, _Y1 + 2, _Console_WHITE_, F("Average Current")); Console::Dot(_X1 + 3, _Y1 + 17, (_Y2 - 13) - (_Y1 + 17)); Console::Bracket(_X1 + 3, _Y2 - 13, 11); Console::Text(_X1 + 3, _Y2 - 4, _Console_WHITE_, F("mA")); 656 | Console::Text(_X1 + 4, _Y1 + 2, _Console_WHITE_, F("State of Charge")); Console::Dot(_X1 + 4, _Y1 + 17, (_Y2 - 10) - (_Y1 + 17)); Console::Bracket(_X1 + 4, _Y2 - 10, 8); Console::Text(_X1 + 4, _Y2 - 3, _Console_WHITE_, F("%")); 657 | Console::Text(_X1 + 5, _Y1 + 2, _Console_WHITE_, F("Instant Battery Capacity")); Console::Dot(_X1 + 5, _Y1 + 26, (_Y2 - 10) - (_Y1 + 26)); Console::Bracket(_X1 + 5, _Y2 - 10, 8); Console::Text(_X1 + 5, _Y2 - 4, _Console_WHITE_, F("mA")); 658 | Console::Text(_X1 + 6, _Y1 + 2, _Console_WHITE_, F("Charge State")); Console::Dot(_X1 + 6, _Y1 + 14, (_Y2 - 15) - (_Y1 + 14)); Console::Bracket(_X1 + 6, _Y2 - 15, 13); 659 | 660 | } 661 | 662 | // GSM Detail Function. 663 | void GSM_Hardware(const uint8_t _X1, const uint8_t _Y1, const uint8_t _X2, const uint8_t _Y2) { 664 | 665 | // Draw GSM Connection Diagnostic Box 666 | Console::Box(_X1, _Y1, _X2, _Y2, F("GSM Detail"), 4, false, false); 667 | 668 | // Print Text 669 | Console::Text(_X1 + 1, _Y1 + 2, _Console_WHITE_, F("Manufacturer")); Console::Dot(_X1 + 1, _Y1 + 14, (_Y2 - 5) - (_Y1 + 14)); Console::Bracket(_X1 + 1, _Y2 - 5, 3); 670 | Console::Text(_X1 + 2, _Y1 + 2, _Console_WHITE_, F("Model")); Console::Dot(_X1 + 2, _Y1 + 7, (_Y2 - 5) - (_Y1 + 7)); Console::Bracket(_X1 + 2, _Y2 - 5, 3); 671 | Console::Text(_X1 + 3, _Y1 + 2, _Console_WHITE_, F("Firmware")); Console::Dot(_X1 + 3, _Y1 + 10, (_Y2 - 12) - (_Y1 + 10)); Console::Bracket(_X1 + 3, _Y2 - 12, 10); 672 | Console::Text(_X1 + 4, _Y1 + 2, _Console_WHITE_, F("IMEI")); Console::Dot(_X1 + 4, _Y1 + 6, (_Y2 - 18) - (_Y1 + 6)); Console::Bracket(_X1 + 4, _Y2 - 18, 16); 673 | Console::Text(_X1 + 5, _Y1 + 2, _Console_WHITE_, F("Serial ID")); Console::Dot(_X1 + 5, _Y1 + 11, (_Y2 - 13) - (_Y1 + 11)); Console::Bracket(_X1 + 5, _Y2 - 13, 11); 674 | Console::Text(_X1 + 6, _Y1 + 2, _Console_WHITE_, F("ICCID")); Console::Dot(_X1 + 6, _Y1 + 7, (_Y2 - 22) - (_Y1 + 7)); Console::Bracket(_X1 + 6, _Y2 - 22, 20); 675 | 676 | } 677 | 678 | // GSM Connection Detail Function. 679 | void GSM_Operator(const uint8_t _X1, const uint8_t _Y1, const uint8_t _X2, const uint8_t _Y2) { 680 | 681 | // Draw GSM Connection Diagnostic Box 682 | Console::Box(_X1, _Y1, _X2, _Y2, F("GSM Connection"), 5, false, false); 683 | 684 | // Print Text 685 | Console::Text(_X1 + 1, _Y1 + 2, _Console_WHITE_, F("Connection Time")); Console::Dot(_X1 + 1, _Y1 + 17, (_Y2 - 8) - (_Y1 + 17)); Console::Bracket(_X1 + 1, _Y2 - 8, 6); 686 | Console::Text(_X1 + 2, _Y1 + 2, _Console_WHITE_, F("Signal Level")); Console::Dot(_X1 + 2, _Y1 + 14, (_Y2 - 8) - (_Y1 + 14)); Console::Bracket(_X1 + 2, _Y2 - 8, 6); 687 | Console::Text(_X1 + 3, _Y1 + 2, _Console_WHITE_, F("GSM Operator")); Console::Dot(_X1 + 3, _Y1 + 14, (_Y2 - 8) - (_Y1 + 14)); Console::Bracket(_X1 + 3, _Y2 - 8, 6); 688 | Console::Text(_X1 + 4, _Y1 + 2, _Console_WHITE_, F("IP Address")); Console::Dot(_X1 + 4, _Y1 + 12, (_Y2 - 18) - (_Y1 + 12)); Console::Bracket(_X1 + 4, _Y2 - 18, 16); 689 | Console::Text(_X1 + 5, _Y1 + 2, _Console_WHITE_, F("Connection Type")); Console::Dot(_X1 + 5, _Y1 + 17, (_Y2 - 12) - (_Y1 + 17)); Console::Bracket(_X1 + 5, _Y2 - 12, 10); 690 | Console::Text(_X1 + 6, _Y1 + 2, _Console_WHITE_, F("Socket")); Console::Dot(_X1 + 6, _Y1 + 8, (_Y2 - 20) - (_Y1 + 8)); Console::Bracket(_X1 + 6, _Y2 - 20, 18); 691 | 692 | } 693 | 694 | // GSM FOTA 695 | void GSM_FOTA_Detail(const uint8_t _X1, const uint8_t _Y1, const uint8_t _X2, const uint8_t _Y2) { 696 | 697 | // Draw GSM Connection Diagnostic Box 698 | Console::Box(_X1, _Y1, _X2, _Y2, F("FOTA"), 6, false, false); 699 | 700 | // Print Text 701 | Console::Text(_X1 + 1, _Y1 + 2, _Console_WHITE_, F("File ID")); Console::Dot(_X1 + 1, _Y1 + 9, (_Y2 - 16) - (_Y1 + 9)); Console::Bracket(_X1 + 1, _Y2 - 16, 14); 702 | Console::Text(_X1 + 2, _Y1 + 2, _Console_WHITE_, F("Download Status")); Console::Dot(_X1 + 2, _Y1 + 17, (_Y2 - 7) - (_Y1 + 17)); Console::Bracket(_X1 + 2, _Y2 - 7, 5); 703 | Console::Text(_X1 + 3, _Y1 + 2, _Console_WHITE_, F("FTP File Size")); Console::Dot(_X1 + 3, _Y1 + 15, (_Y2 - 10) - (_Y1 + 15)); Console::Bracket(_X1 + 3, _Y2 - 10, 8); 704 | Console::Text(_X1 + 4, _Y1 + 2, _Console_WHITE_, F("SD File Size")); Console::Dot(_X1 + 4, _Y1 + 14, (_Y2 - 10) - (_Y1 + 14)); Console::Bracket(_X1 + 4, _Y2 - 10, 8); 705 | Console::Text(_X1 + 5, _Y1 + 2, _Console_WHITE_, F("Download Percent")); Console::Dot(_X1 + 5, _Y1 + 18, (_Y2 - 8) - (_Y1 + 18)); Console::Bracket(_X1 + 5, _Y2 - 8, 6); Console::Text(_X1 + 5, _Y2 - 3, _Console_WHITE_, F("%")); 706 | Console::Text(_X1 + 6, _Y1 + 2, _Console_WHITE_, F("Download Time")); Console::Dot(_X1 + 6, _Y1 + 15, (_Y2 - 11) - (_Y1 + 15)); Console::Bracket(_X1 + 6, _Y2 - 11, 9); Console::Text(_X1 + 6, _Y2 - 5, _Console_WHITE_, F("Sec")); 707 | 708 | } 709 | 710 | // Pressure Stats 711 | void Pressure(const uint8_t _X1, const uint8_t _Y1, const uint8_t _X2, const uint8_t _Y2) { 712 | 713 | // Draw GSM Connection Diagnostic Box 714 | Console::Box(_X1, _Y1, _X2, _Y2, F("Pressure"), 7, false, false); 715 | 716 | // Print Text 717 | Console::Text(_X1 + 1, _Y1 + 2, _Console_WHITE_, F("Instant")); Console::Dot(_X1 + 1, _Y1 + 9, (_Y2 - 12) - (_Y1 + 9)); Console::Bracket(_X1 + 1, _Y2 - 12, 10); Console::Text(_X1 + 1, _Y2 - 5, _Console_WHITE_, F("Bar")); 718 | Console::Text(_X1 + 2, _Y1 + 2, _Console_WHITE_, F("Min")); Console::Dot(_X1 + 2, _Y1 + 5, (_Y2 - 12) - (_Y1 + 5)); Console::Bracket(_X1 + 2, _Y2 - 12, 10); Console::Text(_X1 + 2, _Y2 - 5, _Console_WHITE_, F("Bar")); 719 | Console::Text(_X1 + 3, _Y1 + 2, _Console_WHITE_, F("Max")); Console::Dot(_X1 + 3, _Y1 + 5, (_Y2 - 12) - (_Y1 + 5)); Console::Bracket(_X1 + 3, _Y2 - 12, 10); Console::Text(_X1 + 3, _Y2 - 5, _Console_WHITE_, F("Bar")); 720 | Console::Text(_X1 + 4, _Y1 + 2, _Console_WHITE_, F("Average")); Console::Dot(_X1 + 4, _Y1 + 9, (_Y2 - 12) - (_Y1 + 9)); Console::Bracket(_X1 + 4, _Y2 - 12, 10); Console::Text(_X1 + 4, _Y2 - 5, _Console_WHITE_, F("Bar")); 721 | Console::Text(_X1 + 5, _Y1 + 2, _Console_WHITE_, F("Deviation")); Console::Dot(_X1 + 5, _Y1 + 11, (_Y2 - 12) - (_Y1 + 11)); Console::Bracket(_X1 + 5, _Y2 - 12, 10); Console::Text(_X1 + 5, _Y2 - 5, _Console_WHITE_, F("Bar")); 722 | Console::Text(_X1 + 6, _Y1 + 2, _Console_WHITE_, F("Slope")); Console::Dot(_X1 + 6, _Y1 + 7, (_Y2 - 12) - (_Y1 + 7)); Console::Bracket(_X1 + 6, _Y2 - 12, 10); Console::Text(_X1 + 6, _Y2 - 3, _Console_WHITE_, F("%")); 723 | Console::Text(_X1 + 7, _Y1 + 2, _Console_WHITE_, F("Data Count")); Console::Dot(_X1 + 7, _Y1 + 12, (_Y2 - 6) - (_Y1 + 12)); Console::Bracket(_X1 + 7, _Y2 - 6, 4); 724 | 725 | // Limit Detail 726 | Console::Text(_X1 + 2, _Y1 + 16, _Console_WHITE_, F("[ Bar]")); 727 | Console::Text(_X1 + 3, _Y1 + 16, _Console_WHITE_, F("[ Bar]")); 728 | Console::Text(_X1 + 6, _Y1 + 20, _Console_WHITE_, F("[ %]")); 729 | 730 | } 731 | 732 | // PowerStat V4 Publish Bit Table 733 | void Status_Detail(const uint8_t _X1, const uint8_t _Y1, const uint8_t _X2, const uint8_t _Y2) { 734 | 735 | // Draw GSM Connection Diagnostic Box 736 | Console::Box(_X1, _Y1, _X2, _Y2, F(""), 0, false, false); 737 | 738 | // Print Header 739 | Console::Text(_X1 + 1, _Y1 + 23, _Console_WHITE_, F("S CT CS CR - II VI HF LF HI HV LV - - - - - - PR PD HP LP - IN SA MP TH - T S R P")); 740 | 741 | // Print Divider 742 | Console::Divider(HORIZONTAL, _X1 + 2, _Y1 + 1, _Y2 - 4, false); 743 | 744 | // Print Text 745 | Console::Text(_X1 + 3, _Y1 + 2, _Console_WHITE_, F("Status")); 746 | Console::Text(_X1 + 4, _Y1 + 2, _Console_WHITE_, F("Publish")); 747 | Console::Text(_X1 + 5, _Y1 + 2, _Console_WHITE_, F("Stop")); 748 | 749 | // Print HEX 750 | Console::Bracket(_X1 + 3, _Y1 + 10, 11); 751 | Console::Bracket(_X1 + 4, _Y1 + 10, 11); 752 | Console::Bracket(_X1 + 5, _Y1 + 10, 11); 753 | 754 | // Print Status Placeholder 755 | Console::Text(_X1 + 3, _Y1 + 23, _Console_GRAY_, F("X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X")); 756 | Console::Text(_X1 + 4, _Y1 + 23, _Console_GRAY_, F("X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X")); 757 | Console::Text(_X1 + 5, _Y1 + 23, _Console_GRAY_, F("X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X")); 758 | 759 | } 760 | 761 | #endif 762 | 763 | // Private Context 764 | public: 765 | 766 | // Class Constructor 767 | explicit PowerStat_Console(Stream &_Serial) : Console(_Serial) {} 768 | 769 | // PowerStat V4 Batch Function. 770 | void Begin(const uint8_t _X = 1, const uint8_t _Y = 1) { 771 | 772 | // Control for Debug Mode 773 | #ifdef _DEBUG_ 774 | 775 | // Start VT100 Console 776 | Console::Begin(); 777 | 778 | // Draw Main Box 779 | Console::Box(_X, _Y, _X + 40, _Y + 121, F(""), 0, true, true); 780 | 781 | // Print Main Header Text 782 | Console::Text_Format(_Console_BRIGHT_); 783 | Console::Text(_X + 1, _Y + 54, _Console_WHITE_, F("PowerStat V4")); 784 | Console::Text_Format(_Console_RST_); 785 | 786 | // Header Titles 787 | Console::Text(_X + 1, _Y + 2, _Console_WHITE_, F("Up Time :")); 788 | // Console::Text(_X + 1, _Y + 98, _Console_WHITE_, F("Send Time (mS) :")); 789 | 790 | // Draw Hardware Diagnostic 791 | this->Diagnostic(_X + 3, _Y + 1, _X + 10, _Y + 40); 792 | 793 | // Draw Detail Box 794 | this->Device_Detail(_X + 3, _Y + 41, _X + 10, _Y + 80); 795 | 796 | // Draw Battery Box 797 | this->Battery(_X + 3, _Y + 81, _X + 10, _Y + 120); 798 | 799 | // Draw GSM Detail Box 800 | this->GSM_Hardware(_X + 11, _Y + 1, _X + 18, _Y + 40); 801 | 802 | // Draw GSM Connection Box 803 | this->GSM_Operator(_X + 11, _Y + 41, _X + 18, _Y + 80); 804 | 805 | // Draw FOTA Detail Box 806 | this->GSM_FOTA_Detail(_X + 11, _Y + 81, _X + 18, _Y + 120); 807 | 808 | // Draw Command Box 809 | Console::Box(_X + 19, _Y + 1, _X + 21, _Y + 80, F(""), 0, false, false); 810 | Console::Box(_X + 19, _Y + 81, _X + 21, _Y + 120, F(""), 0, false, false); 811 | 812 | // JSON Box 813 | Console::Box(_X + 22, _Y + 1, _X + 30, _Y + 80, F("JSON"), 0, false, false); 814 | 815 | // Pressure Detail 816 | this->Pressure(_X + 22, _Y + 81, _X + 30, _Y + 120); 817 | 818 | // Draw Voltage Box 819 | //Console::Box(_X + 31, _Y + 1, _X + 36, _Y + 40, F("Voltage"), 8, false, false); 820 | 821 | // Draw Current Box 822 | //Console::Box(_X + 31, _Y + 41, _X + 36, _Y + 80, F("Current"), 9, false, false); 823 | 824 | // Draw Power Box 825 | //Console::Box(_X + 31, _Y + 81, _X + 36, _Y + 120, F("Power"), 10, false, false); 826 | 827 | // Draw Mask 828 | this->Status_Detail(_X + 31, _Y + 1, _X + 37, _Y + 120); 829 | 830 | // Print Board Type 831 | #if defined(_B107AA_) 832 | Console::Text(_X + 39, _Y + 114, _Console_YELLOW_, F("B107AA")); 833 | #elif defined(_B108AA_) 834 | Console::Text(_X + 45, _Y + 114, _Console_YELLOW_, F("B108AA")); 835 | #endif 836 | 837 | // Print Interrupt Status Footer 838 | //Console::Text(_X + 44, _Y + 70, _Console_WHITE_, F("┬")); Console::Text(_X + 45, _Y + 70, _Console_WHITE_, F("│")); Console::Text(_X + 46, _Y + 70, _Console_WHITE_, F("┴")); 839 | //Console::Text(_X + 44, _Y + 80, _Console_WHITE_, F("┬")); Console::Text(_X + 45, _Y + 80, _Console_WHITE_, F("│")); Console::Text(_X + 46, _Y + 80, _Console_WHITE_, F("┴")); 840 | //Console::Text(_X + 44, _Y + 90, _Console_WHITE_, F("┬")); Console::Text(_X + 45, _Y + 90, _Console_WHITE_, F("│")); Console::Text(_X + 46, _Y + 90, _Console_WHITE_, F("┴")); 841 | //Console::Text(_X + 44, _Y + 100, _Console_WHITE_, F("┬")); Console::Text(_X + 45, _Y + 100, _Console_WHITE_, F("│")); Console::Text(_X + 46, _Y + 100, _Console_WHITE_, F("┴")); 842 | //Console::Text(_X + 44, _Y + 112, _Console_WHITE_, F("┬")); Console::Text(_X + 45, _Y + 112, _Console_WHITE_, F("│")); Console::Text(_X + 46, _Y + 112, _Console_WHITE_, F("┴")); 843 | //Console::Text(_X + 45, _Y + 72, _Console_WHITE_, F("EN1 [ ]")); 844 | //Console::Text(_X + 45, _Y + 82, _Console_WHITE_, F("EN2 [ ]")); 845 | //Console::Text(_X + 45, _Y + 92, _Console_WHITE_, F("ENV [ ]")); 846 | //Console::Text(_X + 45, _Y + 102, _Console_WHITE_, F("RS485 [ ]")); 847 | 848 | #endif 849 | 850 | } 851 | 852 | // Set Status 853 | void Show_Status(const uint8_t _Type, uint32_t _Register) { 854 | 855 | // Control for Debug Mode 856 | #ifdef _DEBUG_ 857 | 858 | // Print HEX Value 859 | this->Print_HEX(34 + _Type, 13, _Console_GRAY_, _Register); 860 | 861 | // Print Bits 862 | if (bitRead(_Register, 0)) {Console::Text(34+_Type, 118, _Console_GREEN_, F("H"));} else {Console::Text(34+_Type, 118, _Console_RED_, F("L"));} 863 | if (bitRead(_Register, 1)) {Console::Text(34+_Type, 115, _Console_GREEN_, F("H"));} else {Console::Text(34+_Type, 115, _Console_RED_, F("L"));} 864 | if (bitRead(_Register, 2)) {Console::Text(34+_Type, 112, _Console_GREEN_, F("H"));} else {Console::Text(34+_Type, 112, _Console_RED_, F("L"));} 865 | if (bitRead(_Register, 3)) {Console::Text(34+_Type, 109, _Console_GREEN_, F("H"));} else {Console::Text(34+_Type, 109, _Console_RED_, F("L"));} 866 | if (bitRead(_Register, 4)) {Console::Text(34+_Type, 106, _Console_GREEN_, F("H"));} else {Console::Text(34+_Type, 106, _Console_RED_, F("L"));} 867 | if (bitRead(_Register, 5)) {Console::Text(34+_Type, 103, _Console_GREEN_, F("H"));} else {Console::Text(34+_Type, 103, _Console_RED_, F("L"));} 868 | if (bitRead(_Register, 6)) {Console::Text(34+_Type, 100, _Console_GREEN_, F("H"));} else {Console::Text(34+_Type, 100, _Console_RED_, F("L"));} 869 | if (bitRead(_Register, 7)) {Console::Text(34+_Type, 97, _Console_GREEN_, F("H"));} else {Console::Text(34+_Type, 97, _Console_RED_, F("L"));} 870 | if (bitRead(_Register, 8)) {Console::Text(34+_Type, 94, _Console_GREEN_, F("H"));} else {Console::Text(34+_Type, 94, _Console_RED_, F("L"));} 871 | if (bitRead(_Register, 9)) {Console::Text(34+_Type, 91, _Console_GREEN_, F("H"));} else {Console::Text(34+_Type, 91, _Console_RED_, F("L"));} 872 | if (bitRead(_Register, 10)) {Console::Text(34+_Type, 88, _Console_GREEN_, F("H"));} else {Console::Text(34+_Type, 88, _Console_RED_, F("L"));} 873 | if (bitRead(_Register, 11)) {Console::Text(34+_Type, 85, _Console_GREEN_, F("H"));} else {Console::Text(34+_Type, 85, _Console_RED_, F("L"));} 874 | if (bitRead(_Register, 12)) {Console::Text(34+_Type, 82, _Console_GREEN_, F("H"));} else {Console::Text(34+_Type, 82, _Console_RED_, F("L"));} 875 | if (bitRead(_Register, 13)) {Console::Text(34+_Type, 79, _Console_GREEN_, F("H"));} else {Console::Text(34+_Type, 79, _Console_RED_, F("L"));} 876 | if (bitRead(_Register, 14)) {Console::Text(34+_Type, 76, _Console_GREEN_, F("H"));} else {Console::Text(34+_Type, 76, _Console_RED_, F("L"));} 877 | if (bitRead(_Register, 15)) {Console::Text(34+_Type, 73, _Console_GREEN_, F("H"));} else {Console::Text(34+_Type, 73, _Console_RED_, F("L"));} 878 | if (bitRead(_Register, 16)) {Console::Text(34+_Type, 70, _Console_GREEN_, F("H"));} else {Console::Text(34+_Type, 70, _Console_RED_, F("L"));} 879 | if (bitRead(_Register, 17)) {Console::Text(34+_Type, 67, _Console_GREEN_, F("H"));} else {Console::Text(34+_Type, 67, _Console_RED_, F("L"));} 880 | if (bitRead(_Register, 18)) {Console::Text(34+_Type, 64, _Console_GREEN_, F("H"));} else {Console::Text(34+_Type, 64, _Console_RED_, F("L"));} 881 | if (bitRead(_Register, 19)) {Console::Text(34+_Type, 61, _Console_GREEN_, F("H"));} else {Console::Text(34+_Type, 61, _Console_RED_, F("L"));} 882 | if (bitRead(_Register, 20)) {Console::Text(34+_Type, 58, _Console_GREEN_, F("H"));} else {Console::Text(34+_Type, 58, _Console_RED_, F("L"));} 883 | if (bitRead(_Register, 21)) {Console::Text(34+_Type, 55, _Console_GREEN_, F("H"));} else {Console::Text(34+_Type, 55, _Console_RED_, F("L"));} 884 | if (bitRead(_Register, 22)) {Console::Text(34+_Type, 52, _Console_GREEN_, F("H"));} else {Console::Text(34+_Type, 52, _Console_RED_, F("L"));} 885 | if (bitRead(_Register, 23)) {Console::Text(34+_Type, 49, _Console_GREEN_, F("H"));} else {Console::Text(34+_Type, 49, _Console_RED_, F("L"));} 886 | if (bitRead(_Register, 24)) {Console::Text(34+_Type, 46, _Console_GREEN_, F("H"));} else {Console::Text(34+_Type, 46, _Console_RED_, F("L"));} 887 | if (bitRead(_Register, 25)) {Console::Text(34+_Type, 43, _Console_GREEN_, F("H"));} else {Console::Text(34+_Type, 43, _Console_RED_, F("L"));} 888 | if (bitRead(_Register, 26)) {Console::Text(34+_Type, 40, _Console_GREEN_, F("H"));} else {Console::Text(34+_Type, 40, _Console_RED_, F("L"));} 889 | if (bitRead(_Register, 27)) {Console::Text(34+_Type, 37, _Console_GREEN_, F("H"));} else {Console::Text(34+_Type, 37, _Console_RED_, F("L"));} 890 | if (bitRead(_Register, 28)) {Console::Text(34+_Type, 34, _Console_GREEN_, F("H"));} else {Console::Text(34+_Type, 34, _Console_RED_, F("L"));} 891 | if (bitRead(_Register, 29)) {Console::Text(34+_Type, 31, _Console_GREEN_, F("H"));} else {Console::Text(34+_Type, 31, _Console_RED_, F("L"));} 892 | if (bitRead(_Register, 30)) {Console::Text(34+_Type, 28, _Console_GREEN_, F("H"));} else {Console::Text(34+_Type, 28, _Console_RED_, F("L"));} 893 | if (bitRead(_Register, 31)) {Console::Text(34+_Type, 25, _Console_GREEN_, F("H"));} else {Console::Text(34+_Type, 25, _Console_RED_, F("L"));} 894 | 895 | #endif 896 | 897 | } 898 | 899 | // Show Message 900 | void Show_Message(const uint8_t _Color, const __FlashStringHelper *_Message) { 901 | 902 | // Control for Debug Mode 903 | #ifdef _DEBUG_ 904 | 905 | // Clear Message Area 906 | Console::Space(_Console_Message_X_, _Console_Message_Y_, 75); 907 | 908 | // Print Message 909 | Console::Text(_Console_Message_X_, _Console_Message_Y_, _Color, _Message); 910 | 911 | #endif 912 | 913 | } 914 | void Show_Message(const uint8_t _Color, const char _Message) { 915 | 916 | // Control for Debug Mode 917 | #ifdef _DEBUG_ 918 | 919 | // Clear Message Area 920 | Console::Space(_Console_Message_X_, _Console_Message_Y_, 75); 921 | 922 | // Print Message 923 | Console::Text(_Console_Message_X_, _Console_Message_Y_, _Color, _Message); 924 | 925 | #endif 926 | 927 | } 928 | void Show_Message(const uint8_t _Color, const char * _Message) { 929 | 930 | // Control for Debug Mode 931 | #ifdef _DEBUG_ 932 | 933 | // Clear Message Area 934 | Console::Space(_Console_Message_X_, _Console_Message_Y_, 75); 935 | 936 | // Print Message 937 | Console::Text(_Console_Message_X_, _Console_Message_Y_, _Color, _Message); 938 | 939 | #endif 940 | 941 | } 942 | 943 | // Show RSSI 944 | void Show_RSSI(const uint8_t _X = 1, const uint8_t _Y = 1, const uint8_t _RSSI = 0) { 945 | 946 | // Control for Debug Mode 947 | #ifdef _DEBUG_ 948 | 949 | // Set Text Color 950 | this->Text_Color(_Console_WHITE_); 951 | 952 | // Set Cursor Position 953 | this->Set_Cursor(_X, _Y); 954 | 955 | // Print HEX 956 | Serial.printf(F("[-%3hhu]"), _RSSI); 957 | 958 | #endif 959 | 960 | } 961 | 962 | // Show Signal Quality 963 | void Show_Signal_Quality(const uint8_t _X = 1, const uint8_t _Y = 1, const uint8_t _Quality = 0) { 964 | 965 | // Control for Debug Mode 966 | #ifdef _DEBUG_ 967 | 968 | // Print Signal Level Placeholder 969 | Console::Text(_X, _Y, _Console_GRAY_, F("_____")); 970 | 971 | // Print Signal Level Bar 972 | for (uint8_t i = 1; i <= _Quality; i++) Console::Text(_X, (_Y - 1) + i, _Console_GRAY_, F("X")); 973 | 974 | #endif 975 | 976 | } 977 | 978 | // Connection Type Function 979 | void Show_Connection_Type(const uint8_t _X = 1, const uint8_t _Y = 1, const uint8_t _Type = 0) { 980 | 981 | // Control for Debug Mode 982 | #ifdef _DEBUG_ 983 | 984 | // Print Connection Type 985 | if (_Type == 0) this->Text(_X, _Y, _Console_RED_, F("---")); 986 | else if (_Type == 1) this->Text(_X, _Y, _Console_GREEN_, F(" 2G")); 987 | else if (_Type == 2) this->Text(_X, _Y, _Console_GREEN_, F(" 3G")); 988 | else if (_Type == 3) this->Text(_X, _Y, _Console_GREEN_, F("LTE")); 989 | else if (_Type == 4) this->Text(_X, _Y, _Console_GREEN_, F("TDS")); 990 | 991 | #endif 992 | 993 | } 994 | 995 | }; 996 | 997 | #endif /* defined(__Console__) */ --------------------------------------------------------------------------------