#include #include #include #include #include "config.h" #include "index.h" #include "fonts.h" #include "lowLevel.h" #ifdef __AVR__ #include // Required for 16 MHz Adafruit Trinket #endif Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); TextNode text_nodes[MAX_TEXT_NODES_COUNT]; void addNewTextNode ( char text[TEXT_MAX_LENGTH + 1], uint32_t color = 0x00010101, unsigned short pos_x = 65535, unsigned short pos_y = 0, bool is_small = true ) { unsigned char text_length = strlen(text); if (text_length == 0){return;} for (unsigned char i = 0; i < MAX_TEXT_NODES_COUNT; i++) { if (text_nodes[i].is_deleted) { strncpy(text_nodes[i].content, text, TEXT_MAX_LENGTH); text_nodes[i].color = color; text_nodes[i].pos_x = (pos_x == 65535) ? PANEL_MAX_X + 1 : pos_x; text_nodes[i].pos_y = pos_y; text_nodes[i].characterSize.height = is_small ? SMALL_TEXT_HEIGHT : MEDIUM_TEXT_HEIGHT; text_nodes[i].characterSize.width = is_small ? SMALL_TEXT_WIDTH : MEDIUM_TEXT_WIDTH; text_nodes[i].character_count = text_length; text_nodes[i].is_deleted = false; break; } } } void drawTextNodes() { for (unsigned char i = 0; i < MAX_TEXT_NODES_COUNT; i++) { if (!text_nodes[i].is_deleted) { Cursor cursor; cursor.x = text_nodes[i].pos_x; cursor.y = text_nodes[i].pos_y; for (unsigned char j = 0; j < text_nodes[i].character_count; j++) { char ch = text_nodes[i].content[j]; if (ch < '!' || ch > '~') { ch = ' '; } drawCharacter(font7x5[ch - '!'], text_nodes[i].characterSize.height, text_nodes[i].characterSize.width, text_nodes[i].color, &cursor); } } } } // void scrollTextNodeByAmount(unsigned ) void setup() { Serial.begin(115200); pixels.begin(); pixels.clear(); addNewTextNode("TEst", 0x0001700, 0, 0, true); drawTextNodes(); pixels.show(); start_server(); } void loop() { shiftGivenRectangleLefr(0, 0, 23, 7, 1); pixels.show(); handle_server(); }