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.
 
 
 
atmega-geiger/src/graphic_loading.c

223 lines
4.4 KiB

/**
* Loading
*/
#include <stdint.h>
#include <stdbool.h>
#include "ssd1306.h"
#include "user_interface.h"
#include "framebuffer.h"
void show_loading_screen(uint8_t progress_percent, bool clear) {
// HACKS - GUI dev here
fb_clear();
fb_blit();
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 3
const uint8_t zirafa[ZIR_H * ZIR_W] = {
// levo
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000, // vrsek
0b00011000,
0b00011111,
0b11111000,
0b00011111,
0b00001000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b11111111,
0b00000000,
0b00000000,
0b00010000,
0b00001000,
0b11111000,
0b00011000,
0b11111000, // spodek
0b00011000,
0b00011000,
0b00011000,
0b11111000,
0b00011111,
0b11111000,
0b00000000,
};
#if 1
int pos=0;
for(;;) {
fb_clear();
//fb_bitmap(0, pos, 14, 8, ryba, 1);
fb_bitmap(0, pos, ZIR_W, ZIR_H, zirafa, 1);
fb_blit();
_delay_ms(500);
pos++;
if (pos>31) {
pos = 0;
}
}
#endif
int a = 10;
int b = 40;
for (;;) {
fb_bitmap(a, 0, ZIR_W, ZIR_H*8, zirafa, 0);
fb_bitmap(b, 16, 14, 8, ryba, 0);
a++;
b++;
if(a>127) {
a = 0;
}
if(b>127) {
b = 0;
}
fb_bitmap(a, 0, ZIR_W, ZIR_H*8, zirafa, 1);
fb_bitmap(b, 16, 14, 8, ryba, 1);
fb_blit();
_delay_ms(5);
}
for(;;) {}
//
#if 0
int a = 0, b = 0, ai = 1, bi = 1;
int c = 50, d = 5, ci = -1, di = 1;
int e = 70, f = 10, ei = 1, fi = -1;
int w=15;
int W=20;
for(;;){
fb_clear();
fb_rect(a, b, w, w, 1);
fb_rect(c, d, w, w, 1);
fb_rect(e, f, W, W, 1);
fb_rect(a+1, b+1, w-2, w-2, 0);
fb_rect(c+1, d+1, w-2, w-2, 0);
fb_rect(e+1, f+1, W-2, W-2, 0);
a += ai;
if (a == FBW-1-w) ai = -1;
if (a == 0) ai = 1;
b += bi;
if (b == FBH-1-w) bi = -1;
if (b == 0) bi = 1;
c += ci;
if (c == FBW-1-w) ci = -1;
if (c == 0) ci = 1;
d += di;
if (d == FBH-1-w) di = -1;
if (d == 0) di = 1;
e += ei;
if (e == FBW-1-W) ei = -1;
if (e == 0) ei = 1;
f += fi;
if (f == FBH-1-W) fi = -1;
if (f == 0) fi = 1;
fb_blit();
_delay_ms(5);
}
#endif
if (clear) {
ssd1306_clearScreen();
}
// bar in a box
#define hei 20
#define wid DISPLAY_W
#define thic 2
#define inpad 3
#define ofsx ((DISPLAY_W - wid)/2)
#define ofsy ((DISPLAY_H - hei)/2)
const uint8_t rects[4][4] = {
// top
{
0, 0,
wid - 1, thic - 1
},
// left
{
0, thic,
thic - 1, hei - thic - 1
},
// right
{
wid - thic, thic,
wid - 1, hei - thic - 1
},
// bot
{
0, hei - thic,
wid - 1, hei - 1
},
};
for (int i = 0; i < 4; i++) {
ssd1306_fillRect(
ofsx + rects[i][0],
ofsy + rects[i][1],
ofsx + rects[i][2],
ofsy + rects[i][3]
);
}
//
ssd1306_fillRect(
ofsx + thic + inpad,
ofsy + thic + inpad,
ofsx + (uint8_t)(((uint16_t)wid * (uint16_t)progress_percent)/(uint16_t)100) - thic - inpad - 1,
ofsy + hei - thic - inpad - 1
);
}