diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..ab1f416
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,10 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Ignored default folder with query files
+/queries/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
+# Editor-based HTTP Client requests
+/httpRequests/
diff --git a/.idea/copilot.data.migration.ask2agent.xml b/.idea/copilot.data.migration.ask2agent.xml
new file mode 100644
index 0000000..1f2ea11
--- /dev/null
+++ b/.idea/copilot.data.migration.ask2agent.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/editor.xml b/.idea/editor.xml
new file mode 100644
index 0000000..95e2b51
--- /dev/null
+++ b/.idea/editor.xml
@@ -0,0 +1,98 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..bc7b9f1
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/pti-ledy.iml b/.idea/pti-ledy.iml
new file mode 100644
index 0000000..bc2cd87
--- /dev/null
+++ b/.idea/pti-ledy.iml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..8306744
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/fonts.h b/fonts.h
index 37a73f4..60c09ef 100644
--- a/fonts.h
+++ b/fonts.h
@@ -1,4 +1,5 @@
-constexpr bool font7x5[95][7][5] = {
+constexpr bool font7x5[95][7][5] =
+{
// ! (ASCII 33)
{
{false, false, true, false, false},
diff --git a/ledy.ino b/ledy.ino
index 6e902a6..e31864f 100644
--- a/ledy.ino
+++ b/ledy.ino
@@ -16,27 +16,100 @@
#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);
+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);
pixels.begin();
pixels.clear();
-
- drawCharacter(font7x5['P' - '!'], 7, 5, 0x00030100);
- drawCharacter(font7x5['T' - '!'], 7, 5, 0x00030100);
- drawCharacter(font7x5['I' - '!'], 7, 5, 0x00030100);
-
+
+ addLeftScrollableTextOnScreen("Its alive!");
+
pixels.show();
start_server();
}
-void loop() {
+void loop()
+{
shiftGivenRectangle(0, 0, 19, 7, 1);
pixels.show();
handle_server();
diff --git a/lowLevel.ino b/lowLevel.ino
index 790bfab..4aff7c1 100644
--- a/lowLevel.ino
+++ b/lowLevel.ino
@@ -4,7 +4,8 @@ unsigned char saved_images_count = 0;
Cursor cursor1;
-uint32_t saved_imaged[12][16][16] = {
+uint32_t saved_imaged[2][16][16] =
+{
{
{
0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000
@@ -57,7 +58,8 @@ uint32_t saved_imaged[12][16][16] = {
}
};
-void setPixel(unsigned short x, unsigned short y, uint32_t color) {
+void setPixel(unsigned short x, unsigned short y, uint32_t color)
+{
if (x % 2 == 1)
{
y = PANEL_PIXEL_COUNT - 1 - y;
@@ -65,7 +67,8 @@ void setPixel(unsigned short x, unsigned short y, uint32_t color) {
pixels.setPixelColor(y + (x * PANEL_PIXEL_COUNT), color);
}
-uint32_t getPixelColor(unsigned short x, unsigned short y) {
+uint32_t getPixelColor(unsigned short x, unsigned short y)
+{
if (x % 2 == 1)
{
y = PANEL_PIXEL_COUNT - 1 - y;
@@ -73,78 +76,98 @@ uint32_t getPixelColor(unsigned short x, unsigned short y) {
return pixels.getPixelColor(y + (x * PANEL_PIXEL_COUNT));
}
-void drawImageFromSaved(unsigned short offset_x, unsigned short offset_y, unsigned char i) {
- for (int row = 0; row < 16; row++) {
- for (int col = 0; col < 16; col++) {
+void drawImageFromSaved(unsigned short offset_x, unsigned short offset_y, unsigned char i)
+{
+ for (int row = 0; row < 16; row++)
+ {
+ for (int col = 0; col < 16; col++)
+ {
uint32_t px_color = saved_imaged[i][row][col];
- if (!px_color) {
+ if (!px_color)
+ {
continue;
}
unsigned short pixel_x = col + offset_x;
unsigned short pixel_y = row + offset_y;
if (pixel_x >= 0 && pixel_x < NUMPIXELS &&
- pixel_y >= 0 && pixel_y < NUMPIXELS) {
+ pixel_y >= 0 && pixel_y < NUMPIXELS)
+ {
setPixel(pixel_x, pixel_y, px_color);
}
}
}
}
-void drawCharacter(const bool (*character)[5], unsigned char height, unsigned char width, uint32_t color) {
- for (unsigned char row = 0; row < 7; row++) {
- for (unsigned char col = 0; col < 5; col++) {
- if (character[row][col]) {
- unsigned short pixel_x = col + cursor1.x;
- unsigned short pixel_y = row + cursor1.y;
+void drawCharacter(const bool (*character)[5], unsigned char height, unsigned char width, uint32_t color, Cursor (*used_cursor))
+{
+ for (unsigned char row = 0; row < 7; row++)
+ {
+ for (unsigned char col = 0; col < 5; col++)
+ {
+ if (character[row][col])
+ {
+ unsigned short pixel_x = col + used_cursor.x;
+ unsigned short pixel_y = row + used_cursor.y;
if (pixel_x >= 0 && pixel_x < NUMPIXELS &&
- pixel_y >= 0 && pixel_y < NUMPIXELS) {
+ pixel_y >= 0 && pixel_y < NUMPIXELS)
+ {
setPixel(pixel_x, pixel_y, color);
}
}
}
}
- cursor1.x += width + 1;
+ used_cursor.x += width + 1;
}
void fillPixels(unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, uint32_t color)
{
- if (x1 > x2) {
- unsigned short tmp = x1; x1 = x2; x2 = tmp;
+ if (x1 > x2)
+ {
+ unsigned short tmp = x1; x1 = x2; x2 = tmp;
}
- if (y1 > y2) {
- unsigned short tmp = y1; y1 = y2; y2 = tmp;
+ if (y1 > y2)
+ {
+ unsigned short tmp = y1; y1 = y2; y2 = tmp;
}
unsigned short width = (unsigned short)(x2 - x1 + 1);
unsigned short height = (unsigned short)(y2 - y1 + 1);
- for (unsigned short i = 0; i < height; i++) {
- for (unsigned short j = 0; j < width; j++) {
- setPixel(x1 + j, y1 + i, color);
- }
+ for (unsigned short i = 0; i < height; i++)
+ {
+ for (unsigned short j = 0; j < width; j++)
+ {
+ setPixel(x1 + j, y1 + i, color);
+ }
}
}
-void shiftGivenRectangle(unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, unsigned char shiftBy) {
- if (!shiftBy) {
+void shiftGivenRectangle(unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, unsigned char shift_by)
+{
+ if (!shift_by)
+ {
return;
}
- if (x1 > x2) {
- unsigned short tmp = x1; x1 = x2; x2 = tmp;
+ if (x1 > x2)
+ {
+ unsigned short tmp = x1; x1 = x2; x2 = tmp;
}
- if (y1 > y2) {
- unsigned short tmp = y1; y1 = y2; y2 = tmp;
+ if (y1 > y2)
+ {
+ unsigned short tmp = y1; y1 = y2; y2 = tmp;
}
unsigned short width = (unsigned short)(x2 - x1 + 1);
unsigned short height = (unsigned short)(y2 - y1 + 1);
- for (unsigned short i = 0; i < height; i++) {
- for (unsigned short j = 0; j < width + shiftBy; j++) {
- setPixel(x1 + j - shiftBy, y1 + i, getPixelColor(x1 + j, y1 + i));
- setPixel(x1 + j, y1 + i, 0x00000000);
+ for (unsigned short i = 0; i < height; i++)
+ {
+ for (unsigned short j = 0; j < width + shift_by; j++)
+ {
+ setPixel(x1 + j - shift_by, y1 + i, getPixelColor(x1 + j, y1 + i));
+ setPixel(x1 + j, y1 + i, 0x00000000);
}
}
}
\ No newline at end of file
diff --git a/server.ino b/server.ino
index 68bc2b0..3fba0d3 100644
--- a/server.ino
+++ b/server.ino
@@ -10,12 +10,15 @@ WebServer server(80);
Pixel new_image[16][16];
-void handleRoot() {
+void handleRoot()
+{
server.send(200, "text/html", index_html);
}
-void handleUpload() {
- if (server.hasArg("plain") == false) {
+void handleUpload()
+{
+ if (server.hasArg("plain") == false)
+ {
server.send(400, "text/plain", "body not received");
return;
}
@@ -24,9 +27,11 @@ void handleUpload() {
deserializeJson(doc, body);
JsonArray arr = doc.as();
int row = 0;
- for (JsonVariant val : arr) {
+ for (JsonVariant val : arr)
+ {
int col = 0;
- for (JsonVariant val2 : val.as()) {
+ for (JsonVariant val2 : val.as())
+ {
unsigned long color = strtoul(val2.as(), NULL, 16);
new_image[row][col] = { (unsigned short)col, (unsigned short)row, (uint32_t)color };
col++;
@@ -35,13 +40,16 @@ void handleUpload() {
}
// Save the new image to the next slot
- if (saved_images_count < 11) { // Ensure we don't overflow (max index is 11)
+ if (saved_images_count < 11)
+ { // Ensure we don't overflow (max index is 11)
saved_images_count++;
}
// Copy new_image data to saved_imaged array
- for (int r = 0; r < 16; r++) {
- for (int c = 0; c < 16; c++) {
+ for (int r = 0; r < 16; r++)
+ {
+ for (int c = 0; c < 16; c++)
+ {
saved_imaged[saved_images_count][r][c] = new_image[r][c].color;
}
}
@@ -52,16 +60,19 @@ void handleUpload() {
server.send(200, "text/plain", "OK");
}
-void handleShowSaved() {
+void handleShowSaved()
+{
pixels.clear();
drawImageFromSaved(0, 0, 0);
pixels.show();
server.send(200, "text/plain", "OK");
}
-void start_server() {
+void start_server()
+{
WiFi.begin(ssid, password);
- while (WiFi.status() != WL_CONNECTED) {
+ while (WiFi.status() != WL_CONNECTED)
+ {
delay(1000);
Serial.println("Connecting to WiFi...");
}
@@ -74,6 +85,7 @@ void start_server() {
server.begin();
}
-void handle_server() {
+void handle_server()
+{
server.handleClient();
}
diff --git a/structs.h b/structs.h
index 677be6f..bcb433c 100644
--- a/structs.h
+++ b/structs.h
@@ -1,12 +1,31 @@
-struct Cursor {
+struct Cursor
+{
unsigned short x;
unsigned short y;
Cursor() : x(0), y(0) {}
};
-struct Pixel {
+struct Pixel
+{
unsigned short x;
unsigned short y;
uint32_t color;
+};
+
+struct Text
+{
+ char content[SCROLLABLE_TEXT_MAX_LENGTH];
+ uint32_t color;
+ unsigned short pos_x;
+ unsigned short pos_y;
+ struct CharacterSize
+ {
+ unsigned short height;
+ unsigned short width;
+ } characterSize;
+ unsigned char character_count;
+ bool deleted;
+
+ Text() : color(0), pos_x(0), pos_y(0), character_count(0), characterSize({7,5,0}), deleted(true) {}
};
\ No newline at end of file