Skip to content

Commit 5ecb69d

Browse files
PR feedback addressed
1 parent 76c39e7 commit 5ecb69d

File tree

7 files changed

+552
-447
lines changed

7 files changed

+552
-447
lines changed

boards/ESP32_ESP32DEV/pins_OAE_V1.hpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@
44

55
#pragma once
66

7-
/**
8-
* @brief a pins configuration file for an ESP32-based OAT.
9-
*/
10-
11-
#pragma once
12-
137
// DRIVER_TYPE_TMC2209_UART requires 4 digital pins in Arduino pin numbering
148
#ifndef RA_STEP_PIN
159
#define RA_STEP_PIN 14 // STEP
@@ -131,4 +125,4 @@
131125
#endif
132126
#ifndef DEC_PULLEY_TEETH
133127
#define DEC_PULLEY_TEETH 1
134-
#endif
128+
#endif

src/InfoDisplayRender.hpp

Lines changed: 107 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,116 @@
11
#pragma once
22
#include <Arduino.h>
3-
4-
class Mount;
3+
#include <String.h>
4+
#include "OLEDDisplay.h"
5+
#include "fonts128x64.h"
6+
#include "../Configuration.hpp"
57

68
// Base class to implement a
79
class InfoDisplayRender
810
{
11+
const static int MAX_CONSOLE_LINES = 16; // Maximum number of lines of text to buffer in console mode
12+
const static int DISPLAY_CONSOLE_LINES = 6; // Number of lines to display in console mode
13+
14+
protected:
15+
OLEDDisplay *_display;
16+
long _lastNumCmds;
17+
bool _consoleMode;
18+
String _textList[MAX_CONSOLE_LINES];
19+
int _curLine;
20+
921
public:
10-
InfoDisplayRender() {};
22+
InfoDisplayRender()
23+
{
24+
_consoleMode = true;
25+
_curLine = 0;
26+
for (int i = 0; i < MAX_CONSOLE_LINES; i++)
27+
{
28+
_textList[i] = "";
29+
}
30+
};
31+
32+
virtual void init()
33+
{
34+
_display->init();
35+
_display->clear();
36+
_display->displayOn();
37+
};
38+
39+
OLEDDisplay *getDisplayDevice()
40+
{
41+
return _display;
42+
};
43+
44+
virtual void renderScreen(void *context) =0;
45+
46+
// Build the display from the mount
47+
virtual void render(void (*drawContentFunction)(void*))
48+
{
49+
_display->clear();
50+
if (drawContentFunction)
51+
{
52+
drawContentFunction(this);
53+
}
54+
55+
if (_consoleMode)
56+
{
57+
// Console lines
58+
int y = 21;
59+
_display->setFont(Bitmap3x5);
60+
// Start 6 lines back from current line and display next 6 lines
61+
int indexStart = max(0, _curLine - DISPLAY_CONSOLE_LINES);
62+
int indexEnd = min(indexStart + DISPLAY_CONSOLE_LINES, MAX_CONSOLE_LINES);
63+
for (int i = indexStart; i < indexEnd; i++)
64+
{
65+
if (_textList[i].length() != 0)
66+
{
67+
String text = _textList[i];
68+
text.toUpperCase();
69+
_display->drawString(0, y, text);
70+
}
71+
y += 7;
72+
}
73+
}
74+
else
75+
{
76+
}
77+
78+
_display->display();
79+
};
80+
81+
virtual void setConsoleMode(bool active)
82+
{
83+
_consoleMode = active;
84+
};
85+
86+
virtual int addConsoleText(const String& text, bool tinyFont = true)
87+
{
88+
int returnIndex = 0;
89+
if (_curLine > MAX_CONSOLE_LINES - 1)
90+
{
91+
for (int i = 0; i < MAX_CONSOLE_LINES - 1; i++)
92+
{
93+
_textList[i] = _textList[i + 1];
94+
}
95+
_curLine = MAX_CONSOLE_LINES - 1;
96+
_textList[_curLine] = text;
97+
returnIndex = _curLine;
98+
}
99+
else
100+
{
101+
returnIndex = _curLine;
102+
_textList[_curLine++] = text;
103+
}
104+
render(nullptr);
105+
return returnIndex;
106+
};
11107

12-
virtual void init() {};
13-
virtual void render(Mount *mount) {};
14-
virtual void setConsoleMode(bool active) {};
15-
virtual int addConsoleText(String text, bool tinyFont = true);
16-
virtual void updateConsoleText(int line, String newText);
108+
virtual void updateConsoleText(int line, String text)
109+
{
110+
if (line >= 0 && line < MAX_CONSOLE_LINES)
111+
{
112+
_textList[line] = text;
113+
}
114+
render(nullptr);
115+
};
17116
};

src/Mount.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3332,6 +3332,7 @@ void Mount::setupInfoDisplay()
33323332
infoDisplay = new SDD1306OLED128x64(INFO_DISPLAY_I2C_ADDRESS, INFO_DISPLAY_I2C_SDA_PIN, INFO_DISPLAY_I2C_SCL_PIN);
33333333
LOG(DEBUG_ANY, "[SYSTEM]: SSD1306 OLED created... initializing");
33343334
infoDisplay->init();
3335+
infoDisplay->setConsoleMode(true);
33353336
LOG(DEBUG_DISPLAY, "[DISPLAY]: Created and initialized SSD1306 OLED class...");
33363337
#endif
33373338
}
@@ -3358,7 +3359,7 @@ void Mount::updateInfoDisplay()
33583359
if (now - _lastInfoUpdate > (1000 / refreshRateHz))
33593360
{
33603361
LOG(DEBUG_DISPLAY, "[DISPLAY]: Render state to OLED ...");
3361-
infoDisplay->render(this);
3362+
infoDisplay->renderScreen((void*)this);
33623363
LOG(DEBUG_DISPLAY, "[DISPLAY]: Rendered state to OLED ...");
33633364
_lastInfoUpdate = now;
33643365
}

0 commit comments

Comments
 (0)