writign words might work
This commit is contained in:
+57
-34
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user