some cleanup
This commit is contained in:
Generated
+1
-1
@@ -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/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/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_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" />
|
||||
|
||||
@@ -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
|
||||
@@ -2,99 +2,18 @@
|
||||
#include <WiFi.h>
|
||||
#include <WebServer.h>
|
||||
#include <ArduinoJson.h>
|
||||
#include "config.h"
|
||||
#include "index.h"
|
||||
#include "fonts.h"
|
||||
#include "cursor.h"
|
||||
#include "lowLevel.ino"
|
||||
|
||||
#ifdef __AVR__
|
||||
#include <avr/power.h> // Required for 16 MHz Adafruit Trinket
|
||||
#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);
|
||||
|
||||
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()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
@@ -102,15 +21,12 @@ void setup()
|
||||
pixels.begin();
|
||||
pixels.clear();
|
||||
|
||||
addLeftScrollableTextOnScreen("Its alive!");
|
||||
|
||||
pixels.show();
|
||||
start_server();
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
shiftGivenRectangle(0, 0, 19, 7, 1);
|
||||
pixels.show();
|
||||
handle_server();
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
#include "config.h"
|
||||
#include "structs.h"
|
||||
|
||||
unsigned char saved_images_count = 0;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#include "config.h"
|
||||
|
||||
struct Cursor
|
||||
{
|
||||
unsigned short x;
|
||||
@@ -15,7 +17,7 @@ struct Pixel
|
||||
|
||||
struct Text
|
||||
{
|
||||
char content[SCROLLABLE_TEXT_MAX_LENGTH];
|
||||
char content[TEXT_MAX_LENGTH];
|
||||
uint32_t color;
|
||||
unsigned short pos_x;
|
||||
unsigned short pos_y;
|
||||
@@ -27,5 +29,6 @@ struct Text
|
||||
unsigned char character_count;
|
||||
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) {}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user