-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.c
38 lines (30 loc) · 942 Bytes
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "pico/stdlib.h"
#include <fonts/liberation_sans_36.h>
#include <sharpdisp/sharpdisp.h>
#include <sharpdisp/bitmapshapes.h>
#include <sharpdisp/bitmaptext.h>
#define WIDTH 400
#define HEIGHT 240
uint8_t disp_buffer[BITMAP_SIZE(WIDTH, HEIGHT)];
int main() {
sleep_ms(100); // allow voltage to stabilize
// Initailize
struct SharpDisp sd;
sharpdisp_init_default(&sd, disp_buffer, WIDTH, HEIGHT, 0x00);
struct BitmapText text;
text_init(&text, liberation_sans_36, &sd.bitmap);
// Print Hello World!
const char* hello = "Hello World!";
text.x = (WIDTH - text_str_width(&text, hello)) / 2; // center the string
text.y = (HEIGHT - text_height(&text)) / 2;
text_str(&text, hello);
// Make a border
const uint16_t border = 15;
bitmap_rect(
&sd.bitmap, border, border, WIDTH - border * 2, HEIGHT - border * 2);
// Send to hardware
sharpdisp_refresh(&sd);
while (1) {
sleep_ms(1000);
}
}