Compare commits
No commits in common. "5312071d1c3388e4657fc3fa34287783c195897b" and "77a91448375255adca40b6834f8411ae5e01cf89" have entirely different histories.
5312071d1c
...
77a9144837
@ -34,7 +34,7 @@ The device will scan for WiFi networks on boot. Once the list is displayed, you
|
|||||||
###### IRC commands
|
###### IRC commands
|
||||||
| Command | Description |
|
| Command | Description |
|
||||||
| --------------- | --------------------------- |
|
| --------------- | --------------------------- |
|
||||||
| `/info` | Show hardware information |
|
| `/debug` | Show hardware information |
|
||||||
| `/me <message>` | Send an ACTION message |
|
| `/me <message>` | Send an ACTION message |
|
||||||
| `/nick <new>` | Change your NICK on IRC |
|
| `/nick <new>` | Change your NICK on IRC |
|
||||||
| `/raw <data>` | Send RAW data to the server |
|
| `/raw <data>` | Send RAW data to the server |
|
||||||
@ -98,4 +98,4 @@ The device will scan for WiFi networks on boot. Once the list is displayed, you
|
|||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
###### Mirrors for this repository: [acid.vegas](https://git.acid.vegas/acid-drop) • [SuperNETs](https://git.supernets.org/acidvegas/acid-drop) • [GitHub](https://github.com/acidvegas/acid-drop) • [GitLab](https://gitlab.com/acidvegas/acid-drop) • [Codeberg](https://codeberg.org/acidvegas/acid-drop)
|
###### Mirrors for this repository: [acid.vegas](https://git.acid.vegas/acid-drop) • [SuperNETs](https://git.supernets.org/acidvegas/acid-drop) • [GitHub](https://github.com/acidvegas/acid-drop) • [GitLab](https://gitlab.com/acidvegas/acid-drop) • [Codeberg](https://codeberg.org/acidvegas/acid-drop)
|
46
src/main.ino
46
src/main.ino
@ -555,31 +555,18 @@ int calculateLinesRequired(String message) {
|
|||||||
int linesRequired = 1;
|
int linesRequired = 1;
|
||||||
int lineWidth = 0;
|
int lineWidth = 0;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < message.length(); i++) {
|
for (char c : message) {
|
||||||
char c = message[i];
|
lineWidth += tft.textWidth(String(c));
|
||||||
if (c == '\x03') {
|
if (lineWidth > SCREEN_WIDTH) {
|
||||||
// Skip color code sequences from calculate instead of render to solve nick overlay issue
|
linesRequired++;
|
||||||
while (i < message.length() && (isdigit(message[i + 1]) || message[i + 1] == ',')) {
|
lineWidth = tft.textWidth(String(c));
|
||||||
i++;
|
|
||||||
if (isdigit(message[i + 1])) {
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
if (message[i] == ',' && isdigit(message[i + 1])) {
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (c != '\x02' && c != '\x0F' && c != '\x1F') { // Ignore other formatting codes as they are not as prevalent
|
|
||||||
lineWidth += tft.textWidth(String(c));
|
|
||||||
if (lineWidth > SCREEN_WIDTH) {
|
|
||||||
linesRequired++;
|
|
||||||
lineWidth = tft.textWidth(String(c));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return linesRequired;
|
return linesRequired;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void displayCenteredText(String text) {
|
void displayCenteredText(String text) {
|
||||||
tft.fillScreen(TFT_BLACK);
|
tft.fillScreen(TFT_BLACK);
|
||||||
tft.setTextDatum(MC_DATUM);
|
tft.setTextDatum(MC_DATUM);
|
||||||
@ -885,29 +872,10 @@ void displayLines() {
|
|||||||
tft.fillRect(0, STATUS_BAR_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT - STATUS_BAR_HEIGHT - INPUT_LINE_HEIGHT, TFT_BLACK);
|
tft.fillRect(0, STATUS_BAR_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT - STATUS_BAR_HEIGHT - INPUT_LINE_HEIGHT, TFT_BLACK);
|
||||||
|
|
||||||
int cursorY = STATUS_BAR_HEIGHT;
|
int cursorY = STATUS_BAR_HEIGHT;
|
||||||
int totalLinesHeight = 0;
|
|
||||||
std::vector<int> lineHeights;
|
|
||||||
|
|
||||||
// Calculate total height needed for all lines
|
|
||||||
for (const String& line : lines) {
|
|
||||||
int lineHeight = calculateLinesRequired(line) * CHAR_HEIGHT;
|
|
||||||
lineHeights.push_back(lineHeight);
|
|
||||||
totalLinesHeight += lineHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove lines from the top if they exceed the screen height
|
|
||||||
while (totalLinesHeight > SCREEN_HEIGHT - STATUS_BAR_HEIGHT - INPUT_LINE_HEIGHT) {
|
|
||||||
totalLinesHeight -= lineHeights.front();
|
|
||||||
lines.erase(lines.begin());
|
|
||||||
mentions.erase(mentions.begin());
|
|
||||||
lineHeights.erase(lineHeights.begin());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Render each line
|
|
||||||
for (size_t i = 0; i < lines.size(); ++i) {
|
for (size_t i = 0; i < lines.size(); ++i) {
|
||||||
const String& line = lines[i];
|
const String& line = lines[i];
|
||||||
bool mention = mentions[i];
|
bool mention = mentions[i];
|
||||||
|
|
||||||
tft.setCursor(0, cursorY);
|
tft.setCursor(0, cursorY);
|
||||||
|
|
||||||
if (line.startsWith("JOIN ")) {
|
if (line.startsWith("JOIN ")) {
|
||||||
|
Loading…
Reference in New Issue
Block a user