playground project testing RP2040 (Pico) with SSD1309 2.42" OLED from AliExpress
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

165 lines
3.9 KiB

2 years ago
#include <stdlib.h>
#include <stdio.h>
#include "framebuffer.h"
#include "font.h"
#include "fb_7seg.h"
#include "fb_text.h"
void main() {
fb_clear();
const uint8_t ryba[14] = {
0b11000011,
0b01100110,
0b01111110,
0b00111100,
0b00011000,
0b00111100,
0b01111110,
0b11111111,
0b11111111,
0b11111011,
0b11111111,
0b01111110,
0b00111100,
0b00011000,
};
#define ZIR_W 12
#define ZIR_H 24
const uint8_t zirafa[(ZIR_H/8) * ZIR_W] = {
// levo
0b10000000,
0b01000000,
0b00100000,
0b00010000,
0b00001000,
0b00000100,
0b00000010,
0b00011001,
0b00011111,
0b11111000,
0b00011111,
0b00001000,
//
0b10000000,
0b01000000,
0b00100000,
0b00010000,
0b00001000,
0b00000100,
0b00000010,
0b00000001,
0b10000000,
0b11111111,
0b00100000,
0b00010000,
//
0b00110000,
0b10001000,
0b11111000,
0b00011000,
0b11111000,
0b10011000,
0b00011000,
0b10011000,
0b11111000,
0b00011111,
0b11111000,
0b10000000,
};
//fb_bitmap(0, pos, 14, 8, ryba, 1);
// fb_bitmap(0, 0, ZIR_W, ZIR_H, zirafa, 1);
// fb_bitmap(ZIR_W+2, 12, ZIR_W, ZIR_H, zirafa, 1);
// fb_bitmap((ZIR_W + 2) * 2, 2, ZIR_W, ZIR_H, zirafa, 1);
fb_frame(0, 0, 140, 40, 2, 1);
// uint8_t x = 3;
// uint8_t w = 7;
// uint8_t h = 10;
// uint8_t th = 1;
// uint8_t sp = 3;
// x += fb_7seg_dig(x, 3, w, h, th, /*val*/ 7, /*color*/ 1) + sp;
// x += fb_7seg_dig(x, 3, w, h, th, /*val*/ 9, /*color*/ 1) + sp;
// x += fb_7seg_period(x, 3, w, h, th, /*color*/ 1) + sp;
// x += fb_7seg_dig(x, 3, w, h, th, /*val*/ 5, /*color*/ 1) + sp;
//fb_circle(60, 15, 10, 1, 1);
// fb_circle(60, 15, 5, 1, 1);
//fb_fill_pattern("\xAA\x55", 2, 0);
//fb_invert();
// fb_text(40, 12, "▶Ahoj→!", FONT_BOLD, 1);
fb_text(15, 15, "MEOW", FONT_DOUBLEH, 1);
fb_text(40, 15, "MEOW", FONT_DOUBLEW, 1);
fb_text(40, 23, "MEOW", FONT_BOLD, 1);
fb_text(5, 5, "Tiny 3x5", FONT_3X5, 1);
fb_text(40, 5, "Tiny 4x5 MEOW", FONT_4X5, 1);
fb_frame(12,12,80,20,1,1);
// fb_text(36, 5, "-123456789.0 CPM°", FONT_TINY, 1);
// struct Utf8Iterator iter;
//// Utf8Iterator_Init_P(&iter, str);
// Utf8Iterator_Init(&iter, str);
//
// struct Utf8Char uchar;
// x = 3;
// while ((uchar = Utf8Iterator_Next(&iter)).uint) {
// const font_bitmap_t *sym = font_getsym(&uchar);
// fb_bitmap_P(x, 15, 5, 8, sym->data, 1);
// x += 7;
// }
//
//uint8_t xx[] = {
// 0x1f, 0x11, 0x11, 0x1f,
// 0x02, 0x05, 0x02, 0x00,
// 0x00, 0x04, 0x04, 0x04,
// 0x0e, 0x11, 0x11, 0x0a,
// 0x1f, 0x05, 0x05, 0x02,
// 0x1f, 0x01, 0x02, 0x1f,
// 0x00, 0x18, 0x18, 0x00,
//};
//
//for(int i=0;i<sizeof(xx);i++) {
// uint8_t v = xx[i];
// uint8_t out = 0;
// for(int i=0;i<8;i++) {
// out |= ((v>>i) & 1) << (7-i);
// }
//
// if(i%4==0) printf("\n");
// printf("0x%02x, ", out);
//}
fb_blit();
}
void fb_blit() {
for(int y = 0; y < FBH; y++) {
for(int x = 0; x < FBW; x++) {
bool b = fb[(y/8)*FBW + x] & (1 << (y%8));
if (b) {
printf("\x1b[1;32m█\x1b[m");
} else {
if (y%8 == 0) {
printf("\x1b[34m.\x1b[m");
} else {
printf(".");
}
}
}
printf("\r\n");
}
printf("\r\n");
}