Add font
This commit is contained in:
parent
d5ac1b340a
commit
f4a6715134
66
src/main.cc
66
src/main.cc
|
@ -12,6 +12,39 @@
|
|||
|
||||
static bool failure = false;
|
||||
|
||||
#define INVALID_CH (0xff8181ff)
|
||||
|
||||
static uint32_t charset[127] = {
|
||||
INVALID_CH, INVALID_CH, INVALID_CH, INVALID_CH, INVALID_CH, INVALID_CH, INVALID_CH, INVALID_CH,
|
||||
INVALID_CH, INVALID_CH, INVALID_CH, INVALID_CH, INVALID_CH, INVALID_CH, INVALID_CH, INVALID_CH,
|
||||
INVALID_CH, INVALID_CH, INVALID_CH, INVALID_CH, INVALID_CH, INVALID_CH, INVALID_CH, INVALID_CH,
|
||||
INVALID_CH, INVALID_CH, INVALID_CH, INVALID_CH, INVALID_CH, INVALID_CH, INVALID_CH, 0x00000000, // this is space
|
||||
// !, ", #, $, %, &, ', (,
|
||||
0x00bf0000, 0x03000300, 0x5ce85ce8, 0x24ff4a24, 0xc3cc33c3, 0x4834a458, 0x00030000, 0x81423c00,
|
||||
// ), *, +, ,, -, ., /, 0
|
||||
0x3c428100, 0x09060609, 0x00083e08, 0x00408000, 0x08080808, 0x00030300, 0x030c30c0, 0x7E81817E,
|
||||
// 1, 2, 3, 4, 5, 6, 7, 8
|
||||
0x80FF8280, 0x868991E2, 0x76898162, 0xff121418, 0x7189894f, 0x7289897e, 0x0709f101, 0x76898976,
|
||||
// 9, :, ;, <, =, >, ?, @
|
||||
0x7e898946, 0x00666600, 0x00264600, 0x82442810, 0x28282828, 0x10284482, 0x0609b102, INVALID_CH,
|
||||
// A, B, C, D, E, F, G, H
|
||||
0xfe1111fe, 0x768989ff, 0x6681817e, 0x7e8181ff, 0x818989ff, 0x010909ff, 0x7691817e, 0xff0808ff,
|
||||
// I, J, K, L, M, N, O, P
|
||||
0x81ffff81, 0x01ff8141, 0xe31408ff, 0x808080ff, 0xff0606ff, 0xff0804ff, 0x7E81817E, 0x060909ff,
|
||||
// Q, R, S, T, U, V, W, X
|
||||
0xbe41413e, 0xee1111ff, 0x66918966, 0x01ff0101, 0x7f80807f, 0x1fe0e01f, 0xff6060ff, 0xe71818e7,
|
||||
// Y, Z, [, \, ], ^, _, *
|
||||
0x7f90904f, 0x878991e1, 0x818181ff, 0xc0300c03, 0xff818181, 0x0c03030c, 0x80808080, 0x00060600,
|
||||
// a, b, c, d, e, f, g, h
|
||||
0xf0a8a840, 0x609090fe, 0x50888870, 0xfe909060, 0x30a8a870, 0x000212fc, 0x60a48478, 0xe01010fe,
|
||||
// i, j, k, l, m, n, o, p
|
||||
0x00f40000, 0x00748040, 0x885020fe, 0x80807e02, 0xf03030f0, 0xe01010f8, 0x60909060, 0x182424f8,
|
||||
// q, r, s, t, u, v, w, x
|
||||
0xb0484830, 0x000808f0, 0x48a49448, 0x0080907c, 0x70808070, 0x70c0c070, 0x70e0e070, 0x90606090,
|
||||
// y, z, {, |, }, ~, DEL
|
||||
0x7c90904c, 0x90b0d090, 0x81816618, 0x00ff0000, 0x81816618, 0x10081008, INVALID_CH,
|
||||
};
|
||||
|
||||
int main(void) {
|
||||
stdio_init_all();
|
||||
|
||||
|
@ -31,6 +64,9 @@ int main(void) {
|
|||
|
||||
busy_wait_ms(100);
|
||||
|
||||
disp.fill(0);
|
||||
disp.puts(0, 0, "Hello, World!");
|
||||
disp.flush();
|
||||
while (true) {
|
||||
/*
|
||||
gpio_put(25, false);
|
||||
|
@ -38,12 +74,6 @@ int main(void) {
|
|||
gpio_put(25, true);
|
||||
busy_wait_ms(failure ? 50 : 500);
|
||||
*/
|
||||
disp.fill(0);
|
||||
disp.flush();
|
||||
busy_wait_ms(500);
|
||||
disp.fill(0xFF);
|
||||
disp.flush();
|
||||
busy_wait_ms(500);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -106,10 +136,7 @@ ssd1306::ssd1306() {
|
|||
}
|
||||
|
||||
void ssd1306::test() {
|
||||
static bool flip = true;
|
||||
fill(flip?0xFF:0x00);
|
||||
flip = !flip;
|
||||
flush();
|
||||
memcpy(m_display_buffer+1, &charset['i'-1], 4*16);
|
||||
}
|
||||
|
||||
void ssd1306::fill(uint8_t val) {
|
||||
|
@ -139,3 +166,22 @@ void ssd1306::flush() {
|
|||
printf("data succ\n");
|
||||
}
|
||||
}
|
||||
|
||||
void ssd1306::put_char(uint8_t row, uint8_t col, char c) {
|
||||
if (row % 4 != 0) return;
|
||||
|
||||
memcpy(&m_display_buffer[1 + (row + (128*col))], &charset[c-1], 4);
|
||||
}
|
||||
|
||||
void ssd1306::puts(uint8_t row, uint8_t col, const char *str) {
|
||||
// Start index
|
||||
size_t buf_idx = 1+(row + (128*col));
|
||||
|
||||
while(*str != '\0') {
|
||||
memcpy(m_display_buffer+buf_idx, &charset[*str-1], 4);
|
||||
|
||||
buf_idx+=4;
|
||||
str++;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -38,5 +38,9 @@ public:
|
|||
void flush();
|
||||
|
||||
void set_coordinates(uint8_t start_x, uint8_t end_x, uint8_t start_y, uint8_t end_y);
|
||||
|
||||
void put_char(uint8_t row, uint8_t col, char c);
|
||||
|
||||
void puts(uint8_t row, uint8_t col, const char* str);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue