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

65 lines
1.4 KiB

/**
* Loading
*/
#include <stdint.h>
#include <stdbool.h>
#include "ssd1306.h"
#include "user_interface.h"
void show_loading_screen(uint8_t progress_percent, bool clear)
{
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
);
}