本帖最后由 gaoyang9992006 于 2023-4-26 15:31 编辑
补充一个实现反色显示数字的函数unsigned char code num[][16]={
{0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00},/*"0",0*/
{0x00,0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00},/*"1",1*/
{0x00,0x70,0x08,0x08,0x08,0x08,0xF0,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00},/*"2",2*/
{0x00,0x30,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x18,0x20,0x21,0x21,0x22,0x1C,0x00},/*"3",3*/
{0x00,0x00,0x80,0x40,0x30,0xF8,0x00,0x00,0x00,0x06,0x05,0x24,0x24,0x3F,0x24,0x24},/*"4",4*/
{0x00,0xF8,0x88,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x20,0x20,0x20,0x11,0x0E,0x00},/*"5",5*/
{0x00,0xE0,0x10,0x88,0x88,0x90,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x20,0x1F,0x00},/*"6",6*/
{0x00,0x18,0x08,0x08,0x88,0x68,0x18,0x00,0x00,0x00,0x00,0x3E,0x01,0x00,0x00,0x00},/*"7",7*/
{0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00},/*"8",8*/
{0x00,0xF0,0x08,0x08,0x08,0x10,0xE0,0x00,0x00,0x01,0x12,0x22,0x22,0x11,0x0F,0x00},/*"9",9*/
};
void numberx(unsigned char numb, unsigned char x, unsigned char y, unsigned char flag) {
unsigned char i;
for (i = 0; i < 16; i++) {
if (i == 0 || i == 15) {
OLED_Set_Pos(x + i, y + 0);
OLED_WR_Byte(flag ? ~0xFF : 0xFF, OLED_DATA);
OLED_Set_Pos(x + i, y + 1);
OLED_WR_Byte(flag ? ~0xFF : 0xFF, OLED_DATA);
} else if ((i > 0 && i < 4) || (i > 12 && i < 16)) {
OLED_Set_Pos(x + i, y + 0);
OLED_WR_Byte(flag ? ~0x01 : 0x01, OLED_DATA);
OLED_Set_Pos(x + i, y + 1);
OLED_WR_Byte(flag ? ~0x80 : 0x80, OLED_DATA);
} else {
OLED_Set_Pos(x + i, y + 0);
OLED_WR_Byte(flag ? ~(0x01 | num[numb][i - 4]) : (0x01 | num[numb][i - 4]), OLED_DATA);
OLED_Set_Pos(x + i, y + 1);
OLED_WR_Byte(flag ? ~(0x80 | num[numb][i + 4]) : (0x80 | num[numb][i + 4]), OLED_DATA);
}
}
}
效果测试
|