some functions moved to low_level
This commit is contained in:
+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