mirror of
https://github.com/DashyFox/MusicRing.git
synced 2025-06-27 20:59:28 +00:00
wrapper
This commit is contained in:
@ -2,8 +2,8 @@
|
||||
//#include <avr/iom328.h>
|
||||
|
||||
#include "modules/LED_Ring.h"
|
||||
#include "implement/Display__Adafruit_SSD1306.h"
|
||||
#include "misc/bitmaps.h"
|
||||
#include "implement/Display__Adafruit_SSD1306.h"
|
||||
|
||||
LED_Ring_PINOUT pinout { 5, 6, 7, 8, 9 };
|
||||
|
||||
@ -16,7 +16,7 @@ void setup() {
|
||||
ring.begin();
|
||||
screen.begin();
|
||||
|
||||
screen.adafruit->drawBitmap(0, 0, DashyFox_logo, 128, 32, WHITE);
|
||||
screen.drawBitmap(0, 0, DashyFox_logo, 128, 32);
|
||||
screen.adafruit->display();
|
||||
|
||||
}
|
||||
@ -26,11 +26,9 @@ ISR(TIMER1_COMPA_vect) { ring.isr(); }
|
||||
void loop() {
|
||||
|
||||
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;
|
||||
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();
|
||||
tmr = millis();
|
||||
f = !f;
|
||||
|
@ -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() {
|
||||
|
@ -36,3 +36,8 @@
|
||||
/* 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
|
||||
};
|
||||
|
||||
static uint8_t DashyFox_logo_point_1 [] = {
|
||||
0x3f >> 1, 0xf0 ,0x7f >> 3, 0xf8, 0x3f >> 1, 0xf0
|
||||
};
|
||||
static uint8_t DashyFox_logo_point_2 [] = {0};
|
@ -28,25 +28,45 @@ protected:
|
||||
struct ScreenParam {
|
||||
uint16_t width, height, orientation;
|
||||
} screen;
|
||||
uint8_t* screenBuffer;
|
||||
uint16_t screenBufferSize;
|
||||
|
||||
uint8_t* buffer;
|
||||
public:
|
||||
Display(uint16_t width, uint16_t height, uint16_t orientation) {
|
||||
screen.width = width;
|
||||
screen.height = height;
|
||||
screenBufferSize = (width * height) / 8 + ((width * height) / 8) ? 1 : 0;
|
||||
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 [],
|
||||
int16_t w, int16_t h) {
|
||||
void drawBitmap(int16_t posX, int16_t posY, const uint8_t bitmap [], int16_t sizeX, int16_t sizeY) {
|
||||
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user