From 446d0f2d8dbf380015cb0e75d8d190442c6e157a Mon Sep 17 00:00:00 2001 From: SpaceyKasey <87594618+SpaceyKasey@users.noreply.github.com> Date: Sat, 21 Jan 2023 01:40:12 -0500 Subject: [PATCH] GFX fixes --- .vscode/settings.json | 3 ++- TrigorMortse.ino | 4 ++-- src/MortseGfx.cpp | 10 ++++----- src/MortseGfx.h | 25 +++++++++++----------- src/MortseUi.cpp | 49 ++++++++++++++++++++++--------------------- src/MortseUi.h | 8 +++---- 6 files changed, 51 insertions(+), 48 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 27f2cfd..0124600 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,6 @@ { "files.associations": { - "ios": "cpp" + "ios": "cpp", + "cstddef": "cpp" } } \ No newline at end of file diff --git a/TrigorMortse.ino b/TrigorMortse.ino index b3d7b82..158ff50 100644 --- a/TrigorMortse.ino +++ b/TrigorMortse.ino @@ -1,6 +1,6 @@ #include #include -//#include "src/MortseUi.h" +#include "src/MortseUi.h" const byte MorseTable[] = {0b00000000,0,0b00010010,0,0,0,0,0b00011110,0b10110110,0b00101101,0,0b10101010,0b00110011,0b00100001,0b00010101,0b10110010,0b10111111,0b10101111,0b10100111,0b10100011,0b10100001,0b10100000,0b10110000,0b10111000,0b10111100,0b10111111,0b00111000,0b00101010,0,0b10110001,0,0b00001100,0b00011010,0b01000001,0b10001000,0b10001010,0b01100100,0b00100000,0b10000010,0b01100110,0b10000000,0b01000000,0b10000111,0b01100101,0b10000100,0b01000011,0b01000010,0b01100111,0b10000110,0b10001101,0b01100010,0b01100000,0b00100001,0b01100001,0b10000001,0b01100011,0b10001001,0b10001011,0b10001100,0b10110110,0,0b00101101,0,0b00001101,0b00011110,0b01000001,0b10001000,0b10001010,0b01100100,0b00100000,0b10000010,0b01100110,0b10000000,0b01000000,0b10000111,0b01100101,0b10000100,0b01000011,0b01000010,0b01100111,0b10000110,0b10001101,0b01100010,0b01100000,0b00100001,0b01100001,0b10000001,0b01100011,0b10001001,0b10001011,0b10001100,0b10110110,0,0b00101101,0}; @@ -176,7 +176,7 @@ void loop() { //Insert Beat Output here! char outputChar = TestText[Channel1Index]; - if (outputChar == '/0'){ + if (outputChar == '\0'){ Channel1Index = 0; outputChar = TestText[Channel1Index]; } diff --git a/src/MortseGfx.cpp b/src/MortseGfx.cpp index 85f478e..d08b78c 100644 --- a/src/MortseGfx.cpp +++ b/src/MortseGfx.cpp @@ -1,13 +1,13 @@ #include "MortseGfx.h" -byte MortseGfx::cursor_x = 0; -byte MortseGfx::cursor_y = 0; -enum cursorState MortseGfx::cursor_state = hidden; -void MortseGfx::MortseGfx(){ +MortseGfx::MortseGfx(){ + cursor_x = 0; + cursor_y = 0; + cursor_state = hidden; } void MortseGfx::MoveCursor(byte row, byte column){ @@ -23,5 +23,5 @@ void MortseGfx::ClearChar(byte row, byte column){ } void MortseGfx::SetCursorState(cursorState state){ - + } \ No newline at end of file diff --git a/src/MortseGfx.h b/src/MortseGfx.h index 43fbb5b..ebaf1a9 100644 --- a/src/MortseGfx.h +++ b/src/MortseGfx.h @@ -2,10 +2,10 @@ #define MORTSE_GFX_H #include -#include -#include -#include -#include +//#include +//#include +//#include +//#include #define SCREEN_WIDTH 128 // OLED display width, in pixels #define SCREEN_HEIGHT 32 // OLED display height, in pixels @@ -26,6 +26,13 @@ #define LOGO_WIDTH 16 //static const unsigned char PROGMEM + +enum cursorState { + hidden, + below +}; + + class MortseGfx { private: @@ -35,8 +42,7 @@ class MortseGfx public: - - void MortseGfx(); + MortseGfx(); void MoveCursor(byte row, byte column); @@ -47,11 +53,6 @@ class MortseGfx void SetCursorState(cursorState state); -} - -enum cursorState { - hidden, - below -} +}; #endif \ No newline at end of file diff --git a/src/MortseUi.cpp b/src/MortseUi.cpp index 5ddc4ce..47ed035 100644 --- a/src/MortseUi.cpp +++ b/src/MortseUi.cpp @@ -2,33 +2,32 @@ #include "MortseUi.h" - -//Private Variables -unsigned long MortseUI::nextCursorFlash = 0; -MortseGfx MortseUI::_gfx(); - -enum cursorState MortseUI::_cursorStyle = below; -bool MortseUI::_cursor_visible = true; - -byte MortseUI::_cursorLine = 0; -byte MortseUI::_cursorPosition = 0; -byte MortseUI::_cursorLine_buff = 0; -byte MortseUI::_cursorPosition_buff = 0; -bool MortseUI::_updateCursor = false; - -char MortseUI::_line1[LINE_LENGTH]; -char MortseUI::_line2[LINE_LENGTH]; -char MortseUI::_line1_buff[LINE_LENGTH]; -char MortseUI::_line2_buff[LINE_LENGTH]; -bool MortseUI::_updateLine1 = false; -bool MortseUI::_updateLine2 = false; - //Public Methods /// @brief Constructor for Mortse UI -void MortseUi::MortseUi(){ + +MortseUI::MortseUI(byte port) +{ + _nextCursorFlash = 0; + _gfx = new MortseGfx(); + + _cursorStyle = below; + _cursor_visible = true; + + _cursorLine = 0; + _cursorPosition = 0; + _cursorLine_buff = 0; + _cursorPosition_buff = 0; + _updateCursor = false; + + _line1[LINE_LENGTH]; + _line2[LINE_LENGTH]; + _line1_buff[LINE_LENGTH]; + _line2_buff[LINE_LENGTH]; + _updateLine1 = false; + _updateLine2 = false; + this->_incrementCursor(); - this ->_cursor = visible_blink; //Initialize lines to be blank for(int ix = 0; ix < LINE_LENGTH; ix++){ @@ -105,4 +104,6 @@ void MortseUi::_updateLine(byte *lineRef, byte *lineBuff, byte lineNo){ _gfx->SetChar(lineNo, ix, lineRef[ix]); } } -} \ No newline at end of file +} + + diff --git a/src/MortseUi.h b/src/MortseUi.h index 0a73975..e8d1cd1 100644 --- a/src/MortseUi.h +++ b/src/MortseUi.h @@ -1,8 +1,8 @@ #ifndef MORTSE_UI_H #define MORTSE_UI_H -#define CURSOR_DELAY_MS 500; -#define LINE_LENGTH 16; +#define CURSOR_DELAY_MS 500 +#define LINE_LENGTH 16 #include #include "MortseGfx.h" @@ -11,7 +11,7 @@ class MortseUI{ private: //Graphics Library - MortseGfx _gfx(); + MortseGfx *_gfx(); //Cursor State enum cursorState _cursorStyle; @@ -70,6 +70,6 @@ class MortseUI{ /// @brief Lets the graphics library know that the cursor position should be updated on the screen void UpdateCursor(); -} +}; #endif \ No newline at end of file