General Purpose library for Freestanding C++ and POSIX systems
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.
 
 

268 lines
3.7 KiB

#pragma once
#include "gp/array.hpp"
using display_char = gp::array<uint8_t, 8>;
constexpr display_char ascii_tr(unsigned char c) {
display_char whitespace{
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000
};
display_char invalid{
0b11111111,
c,
0b10101011,
0b10101011,
0b10011001,
0b10100101,
0b11000011,
0b11111111
};
switch(c) {
case '\0':
return whitespace;
case ' ':
return whitespace;
case '!':
return {
0b00000000,
0b00010000,
0b00010000,
0b00010000,
0b00010000,
0b00000000,
0b00010000,
0b00000000
};
case '"':
return {
0b00000000,
0b00101000,
0b00101000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000
};
case '#':
return {
0b00010010,
0b00100100,
0b11111110,
0b00100100,
0b01001000,
0b11111110,
0b01001000,
0b10010000
};
case '$':
return {
0b01111000,
0b10100100,
0b10100000,
0b01111000,
0b00100100,
0b00100100,
0b01111000,
0b00100000
};
case '%':
return {
0b11100001,
0b10100010,
0b11100100,
0b00001000,
0b00010000,
0b00100111,
0b01000101,
0b10000111
};
case '&':
return {
0b00011000,
0b00100100,
0b01000000,
0b00100000,
0b01010100,
0b10001000,
0b01110100,
0b00000000
};
case '\'':
return {
0b00000000,
0b00010000,
0b00010000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000
};
case '(':
return {
0b00100000,
0b01000000,
0b10000000,
0b10000000,
0b10000000,
0b01000000,
0b00100000,
0b00000000
};
case ')':
return {
0b00100000,
0b00010000,
0b00001000,
0b00001000,
0b00001000,
0b00010000,
0b00100000,
0b00000000
};
case '*':
return {
0b00000000,
0b00010000,
0b01111100,
0b00101000,
0b00000000,
0b00000000,
0b00000000,
0b00000000
};
case '+':
return {
0b00000000,
0b00000000,
0b00010000,
0b00010000,
0b01111100,
0b00010000,
0b00010000,
0b00000000
};
case ',':
return {
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00001000,
0b00010000,
0b00000000
};
case '-':
return {
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b01111100,
0b00000000,
0b00000000,
0b00000000
};
case '.':
return {
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00011000,
0b00011000,
0b00000000
};
case '/':
return {
0b00000100,
0b00001000,
0b00001000,
0b00010000,
0b00100000,
0b00100000,
0b01000000,
0b00000000
};
case '0':
return {
0b00111000,
0b01000100,
0b10001010,
0b10010010,
0b10100010,
0b01000100,
0b00111000,
0b00000000
};
case '1':
return {
0b00100000,
0b01100000,
0b00100000,
0b00100000,
0b00100000,
0b00100000,
0b00100000,
0b00000000
};
case '2':
return {
0b00111000,
0b01000100,
0b00000100,
0b00001000,
0b00010000,
0b00100000,
0b11111100,
0b00000000
};
case '3':
return {
0b00111000,
0b01000100,
0b00000100,
0b00011000,
0b00000100,
0b01000100,
0b00111000,
0b00000000
};
case '4':
return {
0b00001000,
0b00011000,
0b00101000,
0b01001000,
0b11111100,
0b00001000,
0b00001000,
0b00000000
};
case '5':
return {
0b01111110,
0b01000000,
0b00111100,
0b00000010,
0b00000010,
0b00000010,
0b01111100,
0b00000000
};
default:
return invalid;
}
}