some functions moved to low_level
This commit is contained in:
@@ -0,0 +1,8 @@
|
|||||||
|
struct Cursor {
|
||||||
|
unsigned short x;
|
||||||
|
unsigned short y;
|
||||||
|
|
||||||
|
Cursor() : x(0), y(0) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
Cursor cursor1;
|
||||||
@@ -4,6 +4,8 @@
|
|||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
#include "index.h"
|
#include "index.h"
|
||||||
#include "fonts.h"
|
#include "fonts.h"
|
||||||
|
#include "cursor.h"
|
||||||
|
#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
|
||||||
@@ -14,153 +16,21 @@
|
|||||||
#define PANEL_PIXEL_COUNT 16
|
#define PANEL_PIXEL_COUNT 16
|
||||||
#define PANEL_COUNT 3
|
#define PANEL_COUNT 3
|
||||||
#define NUMPIXELS PANEL_PIXEL_COUNT*PANEL_PIXEL_COUNT*PANEL_COUNT
|
#define NUMPIXELS PANEL_PIXEL_COUNT*PANEL_PIXEL_COUNT*PANEL_COUNT
|
||||||
|
#define TEXT_BUFFOR_SIZE 64
|
||||||
|
|
||||||
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
|
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
|
||||||
|
|
||||||
unsigned char saved_images_count = 0;
|
ScrollableTextData scrollableTexts[4] = {0};
|
||||||
unsigned short horizontal_cursor1_position = 0;
|
unsigned char scrollableTextsCount = 0;
|
||||||
|
char rightTextBuffor[TEXT_BUFFOR_SIZE] = {0};
|
||||||
uint32_t saved_imaged[12][16][16] = {
|
|
||||||
{
|
|
||||||
{
|
|
||||||
0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000
|
|
||||||
},
|
|
||||||
{
|
|
||||||
0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000
|
|
||||||
},
|
|
||||||
{
|
|
||||||
0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000
|
|
||||||
},
|
|
||||||
{
|
|
||||||
0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFF000000, 0xFF000000, 0xFF000000
|
|
||||||
},
|
|
||||||
{
|
|
||||||
0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFF000000, 0xFF000000, 0xFF000000
|
|
||||||
},
|
|
||||||
{
|
|
||||||
0xFF000000, 0xFF000000, 0xFFFFFF00, 0xFFFFFF00, 0xFF000000, 0xFF000000, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFF000000, 0xFF000000, 0xFFFFFF00, 0xFFFFFF00, 0xFF000000, 0xFF000000
|
|
||||||
},
|
|
||||||
{
|
|
||||||
0xFF000000, 0xFF000000, 0xFFFFFF00, 0xFFFFFF00, 0xFF000000, 0xFF000000, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFF000000, 0xFF000000, 0xFFFFFF00, 0xFFFFFF00, 0xFF000000, 0xFF000000
|
|
||||||
},
|
|
||||||
{
|
|
||||||
0xFF000000, 0xFF000000, 0xFFFFFF00, 0xFFFFFF00, 0xFF000000, 0xFF000000, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFF000000, 0xFF000000, 0xFFFFFF00, 0xFFFFFF00, 0xFF000000, 0xFF000000
|
|
||||||
},
|
|
||||||
{
|
|
||||||
0xFF000000, 0xFF000000, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFF000000, 0xFF000000
|
|
||||||
},
|
|
||||||
{
|
|
||||||
0xFF000000, 0xFF000000, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFF000000, 0xFF000000, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFF000000, 0xFF000000
|
|
||||||
},
|
|
||||||
{
|
|
||||||
0xFF000000, 0xFF000000, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFF000000, 0xFF000000, 0xFFFFFF00, 0xFF000000, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFF000000, 0xFF000000
|
|
||||||
},
|
|
||||||
{
|
|
||||||
0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFF000000, 0xFF000000, 0xFFFFFF00, 0xFF000000, 0xFFFFFF00, 0xFFFFFF00, 0xFF000000, 0xFF000000, 0xFF000000
|
|
||||||
},
|
|
||||||
{
|
|
||||||
0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFF000000, 0xFF000000, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFF000000, 0xFF000000, 0xFF000000
|
|
||||||
},
|
|
||||||
{
|
|
||||||
0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000
|
|
||||||
},
|
|
||||||
{
|
|
||||||
0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000
|
|
||||||
},
|
|
||||||
{
|
|
||||||
0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
void setPixel(unsigned short x, unsigned short y, uint32_t color)
|
|
||||||
{
|
|
||||||
if (x % 2 == 1)
|
|
||||||
{
|
|
||||||
y = PANEL_PIXEL_COUNT - 1 - y;
|
|
||||||
}
|
|
||||||
pixels.setPixelColor(y + (x * PANEL_PIXEL_COUNT), color);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t getPixelColor(unsigned short x, unsigned short y) {
|
void writeSmallScrollabreTextInBuffor(char (*text)[TEXT_BUFFOR_SIZE + 1], pos_y = 0) {
|
||||||
if (x % 2 == 1)
|
for (unsigned char i = 0; i < TEXT_BUFFOR_SIZE; i++) {
|
||||||
{
|
if (text[i]) {
|
||||||
y = PANEL_PIXEL_COUNT - 1 - y;
|
unsigned char text_iterator
|
||||||
}
|
while()
|
||||||
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++) {
|
|
||||||
uint32_t px_color = saved_imaged[i][row][col];
|
|
||||||
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) {
|
|
||||||
setPixel(pixel_x, pixel_y, px_color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void drawCharacter(const bool (*character)[5], unsigned char height, unsigned char width, unsigned short offset_x, unsigned short offset_y, 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 + offset_x + horizontal_cursor1_position;
|
|
||||||
unsigned short pixel_y = row + offset_y;
|
|
||||||
|
|
||||||
if (pixel_x >= 0 && pixel_x < NUMPIXELS &&
|
|
||||||
pixel_y >= 0 && pixel_y < NUMPIXELS) {
|
|
||||||
setPixel(pixel_x, pixel_y, color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
horizontal_cursor1_position += width + offset_x + 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 (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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void shiftGivenRectangle(unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, unsigned char shiftBy) {
|
|
||||||
if (x1 > x2) {
|
|
||||||
unsigned short tmp = x1; x1 = x2; x2 = 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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -172,15 +42,16 @@ void setup() {
|
|||||||
pixels.begin();
|
pixels.begin();
|
||||||
pixels.clear();
|
pixels.clear();
|
||||||
|
|
||||||
drawCharacter(font7x5['P' - '!'], 7, 5, 4, 0, 0x00030100);
|
drawCharacter(font7x5['P' - '!'], 7, 5, 0x00030100);
|
||||||
drawCharacter(font7x5['T' - '!'], 7, 5, 0, 0, 0x00030100);
|
drawCharacter(font7x5['T' - '!'], 7, 5, 0x00030100);
|
||||||
drawCharacter(font7x5['I' - '!'], 7, 5, 0, 0, 0x00030100);
|
drawCharacter(font7x5['I' - '!'], 7, 5, 0x00030100);
|
||||||
shiftGivenRectangle(0, 0, 19, 7, 3);
|
|
||||||
|
|
||||||
pixels.show();
|
pixels.show();
|
||||||
start_server();
|
start_server();
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
shiftGivenRectangle(0, 0, 19, 7, 1);
|
||||||
|
pixels.show();
|
||||||
handle_server();
|
handle_server();
|
||||||
}
|
}
|
||||||
+154
@@ -0,0 +1,154 @@
|
|||||||
|
unsigned char saved_images_count = 0;
|
||||||
|
|
||||||
|
uint32_t saved_imaged[12][16][16] = {
|
||||||
|
{
|
||||||
|
{
|
||||||
|
0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFF000000, 0xFF000000, 0xFF000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFF000000, 0xFF000000, 0xFF000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
0xFF000000, 0xFF000000, 0xFFFFFF00, 0xFFFFFF00, 0xFF000000, 0xFF000000, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFF000000, 0xFF000000, 0xFFFFFF00, 0xFFFFFF00, 0xFF000000, 0xFF000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
0xFF000000, 0xFF000000, 0xFFFFFF00, 0xFFFFFF00, 0xFF000000, 0xFF000000, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFF000000, 0xFF000000, 0xFFFFFF00, 0xFFFFFF00, 0xFF000000, 0xFF000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
0xFF000000, 0xFF000000, 0xFFFFFF00, 0xFFFFFF00, 0xFF000000, 0xFF000000, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFF000000, 0xFF000000, 0xFFFFFF00, 0xFFFFFF00, 0xFF000000, 0xFF000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
0xFF000000, 0xFF000000, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFF000000, 0xFF000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
0xFF000000, 0xFF000000, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFF000000, 0xFF000000, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFF000000, 0xFF000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
0xFF000000, 0xFF000000, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFF000000, 0xFF000000, 0xFFFFFF00, 0xFF000000, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFF000000, 0xFF000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFF000000, 0xFF000000, 0xFFFFFF00, 0xFF000000, 0xFFFFFF00, 0xFFFFFF00, 0xFF000000, 0xFF000000, 0xFF000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFF000000, 0xFF000000, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFF000000, 0xFF000000, 0xFF000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFFFFFF00, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
0xFF000000, 0xFF000000, 0xunsigned FF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ScrollableTextData {
|
||||||
|
unsigned short pos_x;
|
||||||
|
unsigned short pos_y;
|
||||||
|
unsigned char width;
|
||||||
|
bool isSmall;
|
||||||
|
ScrollableTextData() : pos_x(0), pos_y(0), width(0), isSmall(false) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
void setPixel(unsigned short x, unsigned short y, uint32_t color) {
|
||||||
|
if (x % 2 == 1)
|
||||||
|
{
|
||||||
|
y = PANEL_PIXEL_COUNT - 1 - y;
|
||||||
|
}
|
||||||
|
pixels.setPixelColor(y + (x * PANEL_PIXEL_COUNT), color);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t getPixelColor(unsigned short x, unsigned short y) {
|
||||||
|
if (x % 2 == 1)
|
||||||
|
{
|
||||||
|
y = PANEL_PIXEL_COUNT - 1 - 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++) {
|
||||||
|
uint32_t px_color = saved_imaged[i][row][col];
|
||||||
|
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) {
|
||||||
|
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;
|
||||||
|
|
||||||
|
if (pixel_x >= 0 && pixel_x < NUMPIXELS &&
|
||||||
|
pixel_y >= 0 && pixel_y < NUMPIXELS) {
|
||||||
|
setPixel(pixel_x, pixel_y, color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cursor1.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 (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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void shiftGivenRectangle(unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, unsigned char shiftBy) {
|
||||||
|
if (!shiftBy) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (x1 > x2) {
|
||||||
|
unsigned short tmp = x1; x1 = x2; x2 = 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user