#include <GyverGFX.h>
// пример наследования в класс. Нужно реализовать методы dot и update
class TV : public GyverGFX {
public:
TV(int w=9, int h=9) : GyverGFX(w, h) {
buf = new uint8_t[(uint32_t)w * h / 8];
_pixel_time = 1000000 / 12.5 / h / w;
}
void dot(int x, int y, uint8_t fill = GFX_FILL) {
uint32_t idx = x + (uint32_t)y * width();
Serial.print(idx >> 3);
Serial.print(" ");
Serial.print((idx & 0b111));
Serial.print(" ");
Serial.print(x);
Serial.print(" ");
Serial.print(y);
Serial.print(" ");
Serial.println(fill>0);
if (!buf) return;
bitWrite(buf[idx >> 3], (idx & 0b111), fill!=0);
//bitWrite(buf[idx/8], (7 - idx & 8), fill);
}
void update() {
// ...
}
void tick() {}
uint8_t* buf = nullptr;
private:
int _p = 0;
int _pixel_time;
};
TV tv;
const uint8_t a_9x9[] PROGMEM = {
0x80, 0x20, 0x40, 0x10, 0x20, 0x08, 0x10, 0x04, 0x08, 0x02, 0x04, 0x01, 0x02, 0x00, 0x01, 0x00, 0x00, 0x80
};
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
//tv.lineH(1, 1, 30);
tv.dot(1, 1);
//tv.lineV(0, 0, 30);
//tv.buf = &v;
tv.drawBitmap(0, 0, a_9x9, 9, 9);
//for(int i=0; i<64;i++) Serial.println(bitRead(tv.buf[i/8], i%8));
for(int y=0;y<9;y++) {for(int x=0;x<9;x++) Serial.print(bitRead(tv.buf[(y*9+x)/8], (y*9+x)%8)); Serial.println();}
}
void loop() {
// put your main code here, to run repeatedly:
tv.tick();
}