some cleanup

This commit is contained in:
2026-01-28 08:46:28 +01:00
parent 58e3074b04
commit e85e3a4a8c
6 changed files with 22 additions and 92 deletions
+1 -1
View File
@@ -20,7 +20,7 @@
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BREAK_TEMPLATE_DECLARATION/@EntryValue" value="LINE_BREAK" type="string" /> <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BREAK_TEMPLATE_DECLARATION/@EntryValue" value="LINE_BREAK" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/CASE_BLOCK_BRACES/@EntryValue" value="NEXT_LINE" type="string" /> <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/CASE_BLOCK_BRACES/@EntryValue" value="NEXT_LINE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/CONTINUOUS_LINE_INDENT/@EntryValue" value="Double" type="string" /> <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/CONTINUOUS_LINE_INDENT/@EntryValue" value="Double" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/EMPTY_BLOCK_STYLE/@EntryValue" value="TOGETHER" type="string" /> <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/FREE_BLOCK_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_ACCESS_SPECIFIERS_FROM_CLASS/@EntryValue" value="false" type="bool" /> <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_ACCESS_SPECIFIERS_FROM_CLASS/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_CASE_FROM_SWITCH/@EntryValue" value="true" type="bool" /> <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_CASE_FROM_SWITCH/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_CLASS_MEMBERS_FROM_ACCESS_SPECIFIERS/@EntryValue" value="true" type="bool" /> <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_CLASS_MEMBERS_FROM_ACCESS_SPECIFIERS/@EntryValue" value="true" type="bool" />
+13
View File
@@ -0,0 +1,13 @@
#define PIN 12
// Panel Configuration
#define PANEL_PIXEL_COUNT 16
#define PANEL_COUNT 3
#define NUMPIXELS PANEL_PIXEL_COUNT*PANEL_PIXEL_COUNT*PANEL_COUNT
#define PANEL_MAX_X PANEL_PIXEL_COUNT * PANEL_COUNT - 1
#define PANEL_MAX_Y PANEL_PIXEL_COUNT - 1
#define TEXT_MAX_LENGTH 64
#define MAX_TEXT_NODES_COUNT 4
#define SMALL_TEXT_HEIGHT 7
#define SMALL_TEXT_WIDTH 5
-3
View File
@@ -1,3 +0,0 @@
#include "structs.h"
Cursor cursor1;
+1 -85
View File
@@ -2,99 +2,18 @@
#include <WiFi.h> #include <WiFi.h>
#include <WebServer.h> #include <WebServer.h>
#include <ArduinoJson.h> #include <ArduinoJson.h>
#include "config.h"
#include "index.h" #include "index.h"
#include "fonts.h" #include "fonts.h"
#include "cursor.h"
#include "lowLevel.ino" #include "lowLevel.ino"
#ifdef __AVR__ #ifdef __AVR__
#include <avr/power.h> // Required for 16 MHz Adafruit Trinket #include <avr/power.h> // Required for 16 MHz Adafruit Trinket
#endif #endif
#define PIN 12
#define PANEL_PIXEL_COUNT 16
#define PANEL_COUNT 3
#define NUMPIXELS PANEL_PIXEL_COUNT*PANEL_PIXEL_COUNT*PANEL_COUNT
#define PANEL_MAX_X PANEL_PIXEL_COUNT * PANEL_COUNT - 1
#define PANEL_MAX_Y PANEL_PIXEL_COUNT - 1
#define TEXT_MAX_LENGTH 64
#define SCROLLABLE_TEXT_MAX_COUNT 4
#define SMALL_TEXT_HEIGHT 7
#define SMALL_TEXT_WIDTH 5
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
Text scrollable_texts[SCROLLABLE_TEXT_MAX_COUNT];
void addLeftScrollableTextOnScreen(char text[TEXT_MAX_LENGTH], uint32_t color = 0x00010101, bool is_small = true, unsigned short pos_x = nullptr, unsigned short pos_y)
{
unsigned char character_index = 0;
for (unsigned char i = 0; i < SCROLLABLE_TEXT_MAX_COUNT; i++)
{
if (scrollable_texts[i].deleted)
{
scrollable_texts[i].deleted = false;
character_index = i;
break;
}
}
if (pos_x == nullptr)
{
for (unsigned char i = 0; true; i++)
{
if (!text[i])
{
pos_x = PANEL_MAX_X - ((characterSize.width + 1) * i);
}
}
}
for (unsigned char i = 0; i < TEXT_MAX_LENGTH; i++)
{
scrollable_texts[character_index].content[i] = text[i];
if (!text[i])
{
scrollable_texts[character_index].character_count = i;
break;
}
}
scrollable_texts[character_index].color = color;
scrollable_texts[character_index].pos_x = pos_x;
scrollable_texts[character_index].pos_y = pos_y;
if (is_small)
{
scrollable_texts[character_index].characterSize.height = SMALL_TEXT_HEIGHT;
scrollable_texts[character_index].characterSize.width = SMALL_TEXT_WIDTH;
}
}
void drawGivenLeftScrollableText(unsigned char index, Cursor (*used_cursor))
{
if (scrollable_texts[index].deleted)
{
return;
}
for (unsigned char i = 0; i < scrollable_texts[index].character_count; i++)
{
if (scrollable_texts[index].is_small)
{
for (unsigned char char_i = 0; char_i < scrollable_texts[index].character_count; char_i++)
{
used_cursor.x = scrollable_texts[index].pos_x;
used_cursor.y = scrollable_texts[index].pos_y;
drawCharacter(font7x5[scrollable_texts[index].content[char_i] - '!'], 7, 5, scrollable_texts[index].color, used_cursor);
}
}
}
}
void setup() void setup()
{ {
Serial.begin(115200); Serial.begin(115200);
@@ -102,15 +21,12 @@ void setup()
pixels.begin(); pixels.begin();
pixels.clear(); pixels.clear();
addLeftScrollableTextOnScreen("Its alive!");
pixels.show(); pixels.show();
start_server(); start_server();
} }
void loop() void loop()
{ {
shiftGivenRectangle(0, 0, 19, 7, 1);
pixels.show(); pixels.show();
handle_server(); handle_server();
} }
+1
View File
@@ -1,3 +1,4 @@
#include "config.h"
#include "structs.h" #include "structs.h"
unsigned char saved_images_count = 0; unsigned char saved_images_count = 0;
+6 -3
View File
@@ -1,3 +1,5 @@
#include "config.h"
struct Cursor struct Cursor
{ {
unsigned short x; unsigned short x;
@@ -15,7 +17,7 @@ struct Pixel
struct Text struct Text
{ {
char content[SCROLLABLE_TEXT_MAX_LENGTH]; char content[TEXT_MAX_LENGTH];
uint32_t color; uint32_t color;
unsigned short pos_x; unsigned short pos_x;
unsigned short pos_y; unsigned short pos_y;
@@ -27,5 +29,6 @@ struct Text
unsigned char character_count; unsigned char character_count;
bool deleted; bool deleted;
Text() : color(0), pos_x(0), pos_y(0), character_count(0), characterSize({7,5,0}), deleted(true) {}
}; Text() : color(0), pos_x(0), pos_y(0), character_count(0), characterSize({7,5}), deleted(true) {}
};