This commit is contained in:
DashyFox 2023-09-27 23:28:41 +03:00
parent 6ad23825b5
commit f432bc16be
4 changed files with 73 additions and 50 deletions

View File

@ -2,8 +2,8 @@
//#include <avr/iom328.h> //#include <avr/iom328.h>
#include "modules/LED_Ring.h" #include "modules/LED_Ring.h"
#include "implement/Display__Adafruit_SSD1306.h"
#include "misc/bitmaps.h" #include "misc/bitmaps.h"
#include "implement/Display__Adafruit_SSD1306.h"
LED_Ring_PINOUT pinout { 5, 6, 7, 8, 9 }; LED_Ring_PINOUT pinout { 5, 6, 7, 8, 9 };
@ -16,7 +16,7 @@ void setup() {
ring.begin(); ring.begin();
screen.begin(); screen.begin();
screen.adafruit->drawBitmap(0, 0, DashyFox_logo, 128, 32, WHITE); screen.drawBitmap(0, 0, DashyFox_logo, 128, 32);
screen.adafruit->display(); screen.adafruit->display();
} }
@ -26,11 +26,9 @@ ISR(TIMER1_COMPA_vect) { ring.isr(); }
void loop() { void loop() {
static uint32_t tmr; static uint32_t tmr;
static uint8_t arr[6] = { 0x3f >> 1, 0xf0 ,0x7f >> 3, 0xf8, 0x3f >> 1, 0xf0 };
static uint8_t arr2[6] = { 0 };
static bool f = false; static bool f = false;
if (millis() - tmr > 350) { if (millis() - tmr > 350) {
screen.adafruit->drawBitmap(105, 23, arr, 16, 3, f); screen.drawBitmap(105, 23, f ? DashyFox_logo_point_1 : DashyFox_logo_point_2, 16, 3);
screen.adafruit->display(); screen.adafruit->display();
tmr = millis(); tmr = millis();
f = !f; f = !f;

View File

@ -16,8 +16,8 @@ public:
} }
void writePixel() override { void writePixel(uint16_t x, uint16_t y, bool color) override {
adafruit->writePixel(x, y, color);
} }
~Display_Adafruit_SSD1306() { ~Display_Adafruit_SSD1306() {

View File

@ -36,3 +36,8 @@
/* 31 */ 0b11111111, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b11111111, /* 31 */ 0b11111111, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b11111111,
/* 32 */ 0b11111111, 0b11100000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000111, 0b11111111 /* 32 */ 0b11111111, 0b11100000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000111, 0b11111111
}; };
static uint8_t DashyFox_logo_point_1 [] = {
0x3f >> 1, 0xf0 ,0x7f >> 3, 0xf8, 0x3f >> 1, 0xf0
};
static uint8_t DashyFox_logo_point_2 [] = {0};

View File

@ -28,25 +28,45 @@ protected:
struct ScreenParam { struct ScreenParam {
uint16_t width, height, orientation; uint16_t width, height, orientation;
} screen; } screen;
uint8_t* screenBuffer;
uint16_t screenBufferSize;
uint8_t* buffer;
public: public:
Display(uint16_t width, uint16_t height, uint16_t orientation) { Display(uint16_t width, uint16_t height, uint16_t orientation) {
screen.width = width; screen.width = width;
screen.height = height; screen.height = height;
screenBufferSize = (width * height) / 8 + ((width * height) / 8) ? 1 : 0;
screen.orientation = orientation; screen.orientation = orientation;
buffer = new uint8_t[((width * height) / 8)]; screenBuffer = new uint8_t[screenBufferSize];
} }
virtual void writePixel() {}; virtual void writePixel(uint16_t x, uint16_t y, bool color) {};
void drawBbitmap(int16_t x, int16_t y, const uint8_t bitmap [], void drawBitmap(int16_t posX, int16_t posY, const uint8_t bitmap [], int16_t sizeX, int16_t sizeY) {
int16_t w, int16_t h) {
Picture<128, 32> logo; for (uint16_t iY = 1; iY <= sizeY; iY++) {
for (uint16_t iX = 1; iX <= sizeX; iX++) {
uint16_t local = iY * (sizeY - 1) + iX;
uint16_t global = screen.height * (posY + iY - 1) + (posX + iX);
bool localPixel = (bitmap[local / 8] >> (7 - (local % 8))) & 1;
bool globalPixel = (screenBuffer[global / 8] >> (7 - (global % 8))) & 1;
if (localPixel != globalPixel) {
_writePixel(posX + iX, posY + iY, localPixel);
}
}
}
} }
protected:
void _writePixel(uint16_t x, uint16_t y, bool color) {
uint16_t Y = screen.height * (y - 1);
if (color) {
screenBuffer[(Y + x) / 8] |= (1 << (7 - (Y + x) % 8)); // |= 0b00010000
} else {
screenBuffer[(Y + x) / 8] &= ~(1 << (7 - (Y + x) % 8)); // &= 11101111
}
writePixel(x, y, color);
}
}; };