OLED12864 显示英文字符

  • 1 PC端生成列行式点阵数据
    • 1.1 控制台仿真显示逐行式8x16字符
      • 1.1.1 打印显示1个字节的位模式
      • 1.1.2 控制台仿真显示“逐行式” 8x16字符点阵
    • 1.2 逐行式HZK8x16向列行式转换
    • 1.3 输出列行式点阵数据
    • 1.4 测试用例
      • 1.4.1 生成 0 ~ 9 列行式数据
        • 代码
        • 结果
      • 1.4.2 生成 A~F 列行式数据
        • 代码
        • 结果
      • 1.4.3 生成紧凑的数组
        • 代码
        • 结果
  • 2 实现OLED12864显示数字
    • 1.1 建立一个小型字符字库
      • 1.1.1 列行式数据
      • 1.1.2 OLED显示 1 个8x16字符
        • 代码
    • 1.2 OLED显示有符号数字
      • 代码
    • 1.3 OLED显示十六进制无符号数字
      • 代码
  • 3 实现SPI读写FLASH
    • 3.1 SPI逻辑实现
      • 3.1.1 写字节
      • 3.1.2 读字节
    • 3.2 AT25F4096 相关代码
      • 3.2.1 读设备号
      • 3.2.2 写使能和写禁用
      • 3.2.3 页写
        • 3.2.3.1 写一页
        • 3.2.3.2 连续写(解决卷页问题)
      • 3.2.4 读状态(判断是否写入完成)
        • 3.2.4.1 读状态寄存器
        • 3.2.4.2 判断是否写入完成
      • 3.2.5 读字节
    • 3.3 测试例程
      • 3.3.1 Proteus面向软件编程的硬件模型
      • 3.3.2 PC上生成一个有规律的大数组
        • 3.3.2.1 电脑上生成测试数据的代码
        • 3.3.2.2 测试数据
      • 3.3.3 Keil上编写测试代码
      • 3.3.4 Proteus仿真现象与分析
        • 3.3.4.1 现象
        • 3.3.4.2 SPI数据传送分析
          • 写入过程分析
          • 等待写入完成
          • 读出1字节过程

1 PC端生成列行式点阵数据

1.1 控制台仿真显示逐行式8x16字符

1.1.1 打印显示1个字节的位模式

void show_binary(char ch){for(int temp = 0x80; temp; temp >>= 1){printf("%3c", (ch & temp)? 79 : 96);}
}

1.1.2 控制台仿真显示“逐行式” 8x16字符点阵

// "line by line" data
void show_8x16char(unsigned char *arr, int len){if(len < 16){return;}for(int i = 0; i < 16; i++){show_binary(arr[i]);printf("\r\n");}
}

1.2 逐行式HZK8x16向列行式转换

// "line by line" scan to "column by line"
void transfer_8x16character(unsigned char *arr, unsigned char *retArr){int j = 0;for(int temp = 0x80; temp; temp >>= 1){retArr[j] = 0; // Data must be clearedfor(int i = 0; i < 8; i++){retArr[j] |= ((arr[i] & temp) ? 1 : 0) << i;}j++;}for(int temp = 0x80; temp; temp >>= 1){retArr[j] = 0;for(int i = 8; i < 16; i++){retArr[j] |= ((arr[i] & temp) ? 1 : 0) << (i - 8);}j++;}
}

1.3 输出列行式点阵数据

void print_buf(unsigned char *buf, int len){int i = 0;for(i = 0; i < len; i++){printf("0x%.2x,", buf[i]);if((i+1) % 16 == 0){printf("\r\n");}}if(i % 16 != 0){printf("\r\n");}
}

1.4 测试用例

1.4.1 生成 0 ~ 9 列行式数据

代码

int main(int argc, char *argv[]){unsigned char buf1[16] = {0};unsigned char buf2[16] = {0};FILE *pf = fopen(".\\ASC8_16", "r");assert(pf != NULL);for(int j = '0'; j <= '9'; j++){long offset = j * 16;fseek(pf, offset, 0);fread(buf1, 1, 16, pf);printf(">>> raw data is: \r\n");print_buf(buf1, sizeof(buf1) / sizeof(buf1[0]));show_8x16char(buf1, sizeof(buf1) / sizeof(buf1[0]));transfer_8x16character(buf1, buf2);printf("...translated data is: \r\n");print_buf(buf2, sizeof(buf2) / sizeof(buf2[0]));}fclose(pf);return 0;
}

结果

>>> raw data is:
0x00,0x00,0x38,0x6c,0xc6,0xc6,0xd6,0xd6,0xc6,0xc6,0x6c,0x38,0x00,0x00,0x00,0x00,`  `  `  `  `  `  `  ``  `  `  `  `  `  `  ``  `  O  O  O  `  `  ``  O  O  `  O  O  `  `O  O  `  `  `  O  O  `O  O  `  `  `  O  O  `O  O  `  O  `  O  O  `O  O  `  O  `  O  O  `O  O  `  `  `  O  O  `O  O  `  `  `  O  O  ``  O  O  `  O  O  `  ``  `  O  O  O  `  `  ``  `  `  `  `  `  `  ``  `  `  `  `  `  `  ``  `  `  `  `  `  `  ``  `  `  `  `  `  `  `
...translated data is:
0xf0,0xf8,0x0c,0xc4,0x0c,0xf8,0xf0,0x00,0x03,0x07,0x0c,0x08,0x0c,0x07,0x03,0x00,
>>> raw data is:
0x00,0x00,0x18,0x38,0x78,0x18,0x18,0x18,0x18,0x18,0x18,0x7e,0x00,0x00,0x00,0x00,`  `  `  `  `  `  `  ``  `  `  `  `  `  `  ``  `  `  O  O  `  `  ``  `  O  O  O  `  `  ``  O  O  O  O  `  `  ``  `  `  O  O  `  `  ``  `  `  O  O  `  `  ``  `  `  O  O  `  `  ``  `  `  O  O  `  `  ``  `  `  O  O  `  `  ``  `  `  O  O  `  `  ``  O  O  O  O  O  O  ``  `  `  `  `  `  `  ``  `  `  `  `  `  `  ``  `  `  `  `  `  `  ``  `  `  `  `  `  `  `
...translated data is:
0x00,0x10,0x18,0xfc,0xfc,0x00,0x00,0x00,0x00,0x08,0x08,0x0f,0x0f,0x08,0x08,0x00,
>>> raw data is:
0x00,0x00,0x7c,0xc6,0x06,0x0c,0x18,0x30,0x60,0xc0,0xc6,0xfe,0x00,0x00,0x00,0x00,`  `  `  `  `  `  `  ``  `  `  `  `  `  `  ``  O  O  O  O  O  `  `O  O  `  `  `  O  O  ``  `  `  `  `  O  O  ``  `  `  `  O  O  `  ``  `  `  O  O  `  `  ``  `  O  O  `  `  `  ``  O  O  `  `  `  `  `O  O  `  `  `  `  `  `O  O  `  `  `  O  O  `O  O  O  O  O  O  O  ``  `  `  `  `  `  `  ``  `  `  `  `  `  `  ``  `  `  `  `  `  `  ``  `  `  `  `  `  `  `
...translated data is:
0x08,0x0c,0x84,0xc4,0x64,0x3c,0x18,0x00,0x0e,0x0f,0x09,0x08,0x08,0x0c,0x0c,0x00,
>>> raw data is:
0x00,0x00,0x7c,0xc6,0x06,0x06,0x3c,0x06,0x06,0x06,0xc6,0x7c,0x00,0x00,0x00,0x00,`  `  `  `  `  `  `  ``  `  `  `  `  `  `  ``  O  O  O  O  O  `  `O  O  `  `  `  O  O  ``  `  `  `  `  O  O  ``  `  `  `  `  O  O  ``  `  O  O  O  O  `  ``  `  `  `  `  O  O  ``  `  `  `  `  O  O  ``  `  `  `  `  O  O  `O  O  `  `  `  O  O  ``  O  O  O  O  O  `  ``  `  `  `  `  `  `  ``  `  `  `  `  `  `  ``  `  `  `  `  `  `  ``  `  `  `  `  `  `  `
...translated data is:
0x08,0x0c,0x44,0x44,0x44,0xfc,0xb8,0x00,0x04,0x0c,0x08,0x08,0x08,0x0f,0x07,0x00,
>>> raw data is:
0x00,0x00,0x0c,0x1c,0x3c,0x6c,0xcc,0xfe,0x0c,0x0c,0x0c,0x1e,0x00,0x00,0x00,0x00,`  `  `  `  `  `  `  ``  `  `  `  `  `  `  ``  `  `  `  O  O  `  ``  `  `  O  O  O  `  ``  `  O  O  O  O  `  ``  O  O  `  O  O  `  `O  O  `  `  O  O  `  `O  O  O  O  O  O  O  ``  `  `  `  O  O  `  ``  `  `  `  O  O  `  ``  `  `  `  O  O  `  ``  `  `  O  O  O  O  ``  `  `  `  `  `  `  ``  `  `  `  `  `  `  ``  `  `  `  `  `  `  ``  `  `  `  `  `  `  `
...translated data is:
0xc0,0xe0,0xb0,0x98,0xfc,0xfc,0x80,0x00,0x00,0x00,0x00,0x08,0x0f,0x0f,0x08,0x00,
>>> raw data is:
0x00,0x00,0xfe,0xc0,0xc0,0xc0,0xfc,0x06,0x06,0x06,0xc6,0x7c,0x00,0x00,0x00,0x00,`  `  `  `  `  `  `  ``  `  `  `  `  `  `  `O  O  O  O  O  O  O  `O  O  `  `  `  `  `  `O  O  `  `  `  `  `  `O  O  `  `  `  `  `  `O  O  O  O  O  O  `  ``  `  `  `  `  O  O  ``  `  `  `  `  O  O  ``  `  `  `  `  O  O  `O  O  `  `  `  O  O  ``  O  O  O  O  O  `  ``  `  `  `  `  `  `  ``  `  `  `  `  `  `  ``  `  `  `  `  `  `  ``  `  `  `  `  `  `  `
...translated data is:
0x7c,0x7c,0x44,0x44,0x44,0xc4,0x84,0x00,0x04,0x0c,0x08,0x08,0x08,0x0f,0x07,0x00,
>>> raw data is:
0x00,0x00,0x38,0x60,0xc0,0xc0,0xfc,0xc6,0xc6,0xc6,0xc6,0x7c,0x00,0x00,0x00,0x00,`  `  `  `  `  `  `  ``  `  `  `  `  `  `  ``  `  O  O  O  `  `  ``  O  O  `  `  `  `  `O  O  `  `  `  `  `  `O  O  `  `  `  `  `  `O  O  O  O  O  O  `  `O  O  `  `  `  O  O  `O  O  `  `  `  O  O  `O  O  `  `  `  O  O  `O  O  `  `  `  O  O  ``  O  O  O  O  O  `  ``  `  `  `  `  `  `  ``  `  `  `  `  `  `  ``  `  `  `  `  `  `  ``  `  `  `  `  `  `  `
...translated data is:
0xf0,0xf8,0x4c,0x44,0x44,0xc0,0x80,0x00,0x07,0x0f,0x08,0x08,0x08,0x0f,0x07,0x00,
>>> raw data is:
0x00,0x00,0xfe,0xc6,0x06,0x06,0x0c,0x18,0x30,0x30,0x30,0x30,0x00,0x00,0x00,0x00,`  `  `  `  `  `  `  ``  `  `  `  `  `  `  `O  O  O  O  O  O  O  `O  O  `  `  `  O  O  ``  `  `  `  `  O  O  ``  `  `  `  `  O  O  ``  `  `  `  O  O  `  ``  `  `  O  O  `  `  ``  `  O  O  `  `  `  ``  `  O  O  `  `  `  ``  `  O  O  `  `  `  ``  `  O  O  `  `  `  ``  `  `  `  `  `  `  ``  `  `  `  `  `  `  ``  `  `  `  `  `  `  ``  `  `  `  `  `  `  `
...translated data is:
0x0c,0x0c,0x04,0x84,0xc4,0x7c,0x3c,0x00,0x00,0x00,0x0f,0x0f,0x00,0x00,0x00,0x00,
>>> raw data is:
0x00,0x00,0x7c,0xc6,0xc6,0xc6,0x7c,0xc6,0xc6,0xc6,0xc6,0x7c,0x00,0x00,0x00,0x00,`  `  `  `  `  `  `  ``  `  `  `  `  `  `  ``  O  O  O  O  O  `  `O  O  `  `  `  O  O  `O  O  `  `  `  O  O  `O  O  `  `  `  O  O  ``  O  O  O  O  O  `  `O  O  `  `  `  O  O  `O  O  `  `  `  O  O  `O  O  `  `  `  O  O  `O  O  `  `  `  O  O  ``  O  O  O  O  O  `  ``  `  `  `  `  `  `  ``  `  `  `  `  `  `  ``  `  `  `  `  `  `  ``  `  `  `  `  `  `  `
...translated data is:
0xb8,0xfc,0x44,0x44,0x44,0xfc,0xb8,0x00,0x07,0x0f,0x08,0x08,0x08,0x0f,0x07,0x00,
>>> raw data is:
0x00,0x00,0x7c,0xc6,0xc6,0xc6,0x7e,0x06,0x06,0x06,0x0c,0x78,0x00,0x00,0x00,0x00,`  `  `  `  `  `  `  ``  `  `  `  `  `  `  ``  O  O  O  O  O  `  `O  O  `  `  `  O  O  `O  O  `  `  `  O  O  `O  O  `  `  `  O  O  ``  O  O  O  O  O  O  ``  `  `  `  `  O  O  ``  `  `  `  `  O  O  ``  `  `  `  `  O  O  ``  `  `  `  O  O  `  ``  O  O  O  O  `  `  ``  `  `  `  `  `  `  ``  `  `  `  `  `  `  ``  `  `  `  `  `  `  ``  `  `  `  `  `  `  `
...translated data is:
0x38,0x7c,0x44,0x44,0x44,0xfc,0xf8,0x00,0x00,0x08,0x08,0x08,0x0c,0x07,0x03,0x00,

1.4.2 生成 A~F 列行式数据

代码

int main(int argc, char *argv[]){unsigned char buf1[16] = {0};unsigned char buf2[16] = {0};FILE *pf = fopen(".\\ASC8_16", "r");assert(pf != NULL);for(int j = 'A'; j <= 'F'; j++){long offset = j * 16;fseek(pf, offset, 0);fread(buf1, 1, 16, pf);printf(">>> raw data is: \r\n");print_buf(buf1, sizeof(buf1) / sizeof(buf1[0]));show_8x16char(buf1, sizeof(buf1) / sizeof(buf1[0]));transfer_8x16character(buf1, buf2);printf("...translated data is: \r\n");print_buf(buf2, sizeof(buf2) / sizeof(buf2[0]));}fclose(pf);return 0;
}

结果

>>> raw data is:
0x00,0x00,0x10,0x38,0x6c,0xc6,0xc6,0xfe,0xc6,0xc6,0xc6,0xc6,0x00,0x00,0x00,0x00,`  `  `  `  `  `  `  ``  `  `  `  `  `  `  ``  `  `  O  `  `  `  ``  `  O  O  O  `  `  ``  O  O  `  O  O  `  `O  O  `  `  `  O  O  `O  O  `  `  `  O  O  `O  O  O  O  O  O  O  `O  O  `  `  `  O  O  `O  O  `  `  `  O  O  `O  O  `  `  `  O  O  `O  O  `  `  `  O  O  ``  `  `  `  `  `  `  ``  `  `  `  `  `  `  ``  `  `  `  `  `  `  ``  `  `  `  `  `  `  `
...translated data is:
0xe0,0xf0,0x98,0x8c,0x98,0xf0,0xe0,0x00,0x0f,0x0f,0x00,0x00,0x00,0x0f,0x0f,0x00,
>>> raw data is:
0x00,0x00,0xfc,0x66,0x66,0x66,0x7c,0x66,0x66,0x66,0x66,0xfc,0x00,0x00,0x00,0x00,`  `  `  `  `  `  `  ``  `  `  `  `  `  `  `O  O  O  O  O  O  `  ``  O  O  `  `  O  O  ``  O  O  `  `  O  O  ``  O  O  `  `  O  O  ``  O  O  O  O  O  `  ``  O  O  `  `  O  O  ``  O  O  `  `  O  O  ``  O  O  `  `  O  O  ``  O  O  `  `  O  O  `O  O  O  O  O  O  `  ``  `  `  `  `  `  `  ``  `  `  `  `  `  `  ``  `  `  `  `  `  `  ``  `  `  `  `  `  `  `
...translated data is:
0x04,0xfc,0xfc,0x44,0x44,0xfc,0xb8,0x00,0x08,0x0f,0x0f,0x08,0x08,0x0f,0x07,0x00,
>>> raw data is:
0x00,0x00,0x3c,0x66,0xc2,0xc0,0xc0,0xc0,0xc0,0xc2,0x66,0x3c,0x00,0x00,0x00,0x00,`  `  `  `  `  `  `  ``  `  `  `  `  `  `  ``  `  O  O  O  O  `  ``  O  O  `  `  O  O  `O  O  `  `  `  `  O  `O  O  `  `  `  `  `  `O  O  `  `  `  `  `  `O  O  `  `  `  `  `  `O  O  `  `  `  `  `  `O  O  `  `  `  `  O  ``  O  O  `  `  O  O  ``  `  O  O  O  O  `  ``  `  `  `  `  `  `  ``  `  `  `  `  `  `  ``  `  `  `  `  `  `  ``  `  `  `  `  `  `  `
...translated data is:
0xf0,0xf8,0x0c,0x04,0x04,0x0c,0x18,0x00,0x03,0x07,0x0c,0x08,0x08,0x0c,0x06,0x00,
>>> raw data is:
0x00,0x00,0xf8,0x6c,0x66,0x66,0x66,0x66,0x66,0x66,0x6c,0xf8,0x00,0x00,0x00,0x00,`  `  `  `  `  `  `  ``  `  `  `  `  `  `  `O  O  O  O  O  `  `  ``  O  O  `  O  O  `  ``  O  O  `  `  O  O  ``  O  O  `  `  O  O  ``  O  O  `  `  O  O  ``  O  O  `  `  O  O  ``  O  O  `  `  O  O  ``  O  O  `  `  O  O  ``  O  O  `  O  O  `  `O  O  O  O  O  `  `  ``  `  `  `  `  `  `  ``  `  `  `  `  `  `  ``  `  `  `  `  `  `  ``  `  `  `  `  `  `  `
...translated data is:
0x04,0xfc,0xfc,0x04,0x0c,0xf8,0xf0,0x00,0x08,0x0f,0x0f,0x08,0x0c,0x07,0x03,0x00,
>>> raw data is:
0x00,0x00,0xfe,0x66,0x62,0x68,0x78,0x68,0x60,0x62,0x66,0xfe,0x00,0x00,0x00,0x00,`  `  `  `  `  `  `  ``  `  `  `  `  `  `  `O  O  O  O  O  O  O  ``  O  O  `  `  O  O  ``  O  O  `  `  `  O  ``  O  O  `  O  `  `  ``  O  O  O  O  `  `  ``  O  O  `  O  `  `  ``  O  O  `  `  `  `  ``  O  O  `  `  `  O  ``  O  O  `  `  O  O  `O  O  O  O  O  O  O  ``  `  `  `  `  `  `  ``  `  `  `  `  `  `  ``  `  `  `  `  `  `  ``  `  `  `  `  `  `  `
...translated data is:
0x04,0xfc,0xfc,0x44,0xe4,0x0c,0x1c,0x00,0x08,0x0f,0x0f,0x08,0x08,0x0c,0x0e,0x00,
>>> raw data is:
0x00,0x00,0xfe,0x66,0x62,0x68,0x78,0x68,0x60,0x60,0x60,0xf0,0x00,0x00,0x00,0x00,`  `  `  `  `  `  `  ``  `  `  `  `  `  `  `O  O  O  O  O  O  O  ``  O  O  `  `  O  O  ``  O  O  `  `  `  O  ``  O  O  `  O  `  `  ``  O  O  O  O  `  `  ``  O  O  `  O  `  `  ``  O  O  `  `  `  `  ``  O  O  `  `  `  `  ``  O  O  `  `  `  `  `O  O  O  O  `  `  `  ``  `  `  `  `  `  `  ``  `  `  `  `  `  `  ``  `  `  `  `  `  `  ``  `  `  `  `  `  `  `
...translated data is:
0x04,0xfc,0xfc,0x44,0xe4,0x0c,0x1c,0x00,0x08,0x0f,0x0f,0x08,0x00,0x00,0x00,0x00,
PS D:\BaiduNetdiskWorkspace\MCU_51\Assigned1\VSCode_CharacterSet>

1.4.3 生成紧凑的数组

代码

int main(int argc, char *argv[]){unsigned char buf1[16] = {0};unsigned char buf2[16] = {0};FILE *pf = fopen(".\\ASC8_16", "r");assert(pf != NULL);for(int j = '0'; j <= '9'; j++){long offset = j * 16;fseek(pf, offset, 0);fread(buf1, 1, 16, pf);// printf(">>> raw data is: \r\n");// print_buf(buf1, sizeof(buf1) / sizeof(buf1[0]));// show_8x16char(buf1, sizeof(buf1) / sizeof(buf1[0]));transfer_8x16character(buf1, buf2);// printf("...translated data is: \r\n");printf("\\\\ \'%c\'\r\n", j);print_buf(buf2, sizeof(buf2) / sizeof(buf2[0]));}for(int j = 'A'; j <= 'F'; j++){long offset = j * 16;fseek(pf, offset, 0);fread(buf1, 1, 16, pf);// printf(">>> raw data is: \r\n");// print_buf(buf1, sizeof(buf1) / sizeof(buf1[0]));     // show_8x16char(buf1, sizeof(buf1) / sizeof(buf1[0]));transfer_8x16character(buf1, buf2);// printf("...translated data is: \r\n");printf("\\\\ \'%c\'\r\n", j);print_buf(buf2, sizeof(buf2) / sizeof(buf2[0]));}long offset = '+' * 16;fseek(pf, offset, 0);fread(buf1, 1, 16, pf);// printf(">>> raw data is: \r\n");// print_buf(buf1, sizeof(buf1) / sizeof(buf1[0]));// show_8x16char(buf1, sizeof(buf1) / sizeof(buf1[0]));transfer_8x16character(buf1, buf2);// printf("...translated data is: \r\n");printf("\\\\ \'%c\'\r\n", '+');print_buf(buf2, sizeof(buf2) / sizeof(buf2[0]));offset = '-' * 16;fseek(pf, offset, 0);fread(buf1, 1, 16, pf);// printf(">>> raw data is: \r\n");// print_buf(buf1, sizeof(buf1) / sizeof(buf1[0]));// show_8x16char(buf1, sizeof(buf1) / sizeof(buf1[0]));transfer_8x16character(buf1, buf2);// printf("...translated data is: \r\n");printf("\\\\ \'%c\'\r\n", '-');print_buf(buf2, sizeof(buf2) / sizeof(buf2[0]));offset = 'x' * 16;fseek(pf, offset, 0);fread(buf1, 1, 16, pf);// printf(">>> raw data is: \r\n");// print_buf(buf1, sizeof(buf1) / sizeof(buf1[0]));// show_8x16char(buf1, sizeof(buf1) / sizeof(buf1[0]));transfer_8x16character(buf1, buf2);// printf("...translated data is: \r\n");printf("\\\\ \'%c\'\r\n", 'x');print_buf(buf2, sizeof(buf2) / sizeof(buf2[0]));fclose(pf);return 0;
}

结果

\\ '0'
0xf0,0xf8,0x0c,0xc4,0x0c,0xf8,0xf0,0x00,0x03,0x07,0x0c,0x08,0x0c,0x07,0x03,0x00,
\\ '1'
0x00,0x10,0x18,0xfc,0xfc,0x00,0x00,0x00,0x00,0x08,0x08,0x0f,0x0f,0x08,0x08,0x00,
\\ '2'
0x08,0x0c,0x84,0xc4,0x64,0x3c,0x18,0x00,0x0e,0x0f,0x09,0x08,0x08,0x0c,0x0c,0x00,
\\ '3'
0x08,0x0c,0x44,0x44,0x44,0xfc,0xb8,0x00,0x04,0x0c,0x08,0x08,0x08,0x0f,0x07,0x00,
\\ '4'
0xc0,0xe0,0xb0,0x98,0xfc,0xfc,0x80,0x00,0x00,0x00,0x00,0x08,0x0f,0x0f,0x08,0x00,
\\ '5'
0x7c,0x7c,0x44,0x44,0x44,0xc4,0x84,0x00,0x04,0x0c,0x08,0x08,0x08,0x0f,0x07,0x00,
\\ '6'
0xf0,0xf8,0x4c,0x44,0x44,0xc0,0x80,0x00,0x07,0x0f,0x08,0x08,0x08,0x0f,0x07,0x00,
\\ '7'
0x0c,0x0c,0x04,0x84,0xc4,0x7c,0x3c,0x00,0x00,0x00,0x0f,0x0f,0x00,0x00,0x00,0x00,
\\ '8'
0xb8,0xfc,0x44,0x44,0x44,0xfc,0xb8,0x00,0x07,0x0f,0x08,0x08,0x08,0x0f,0x07,0x00,
\\ '9'
0x38,0x7c,0x44,0x44,0x44,0xfc,0xf8,0x00,0x00,0x08,0x08,0x08,0x0c,0x07,0x03,0x00,
\\ 'A'
0xe0,0xf0,0x98,0x8c,0x98,0xf0,0xe0,0x00,0x0f,0x0f,0x00,0x00,0x00,0x0f,0x0f,0x00,
\\ 'B'
0x04,0xfc,0xfc,0x44,0x44,0xfc,0xb8,0x00,0x08,0x0f,0x0f,0x08,0x08,0x0f,0x07,0x00,
\\ 'C'
0xf0,0xf8,0x0c,0x04,0x04,0x0c,0x18,0x00,0x03,0x07,0x0c,0x08,0x08,0x0c,0x06,0x00,
\\ 'D'
0x04,0xfc,0xfc,0x04,0x0c,0xf8,0xf0,0x00,0x08,0x0f,0x0f,0x08,0x0c,0x07,0x03,0x00,
\\ 'E'
0x04,0xfc,0xfc,0x44,0xe4,0x0c,0x1c,0x00,0x08,0x0f,0x0f,0x08,0x08,0x0c,0x0e,0x00,
\\ 'F'
0x04,0xfc,0xfc,0x44,0xe4,0x0c,0x1c,0x00,0x08,0x0f,0x0f,0x08,0x00,0x00,0x00,0x00,
\\ '+'
0x00,0x80,0x80,0xe0,0xe0,0x80,0x80,0x00,0x00,0x00,0x00,0x03,0x03,0x00,0x00,0x00,
\\ '-'
0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
\\ 'x'
0x20,0x60,0xc0,0x80,0xc0,0x60,0x20,0x00,0x08,0x0c,0x07,0x03,0x07,0x0c,0x08,0x00,

2 实现OLED12864显示数字

1.1 建立一个小型字符字库

1.1.1 列行式数据

uint8_t const code number8x16[304] = {0xf0,0xf8,0x0c,0xc4,0x0c,0xf8,0xf0,0x00,0x03,0x07,0x0c,0x08,0x0c,0x07,0x03,0x00, // 00x00,0x10,0x18,0xfc,0xfc,0x00,0x00,0x00,0x00,0x08,0x08,0x0f,0x0f,0x08,0x08,0x00, // 10x08,0x0c,0x84,0xc4,0x64,0x3c,0x18,0x00,0x0e,0x0f,0x09,0x08,0x08,0x0c,0x0c,0x00, // 20x08,0x0c,0x44,0x44,0x44,0xfc,0xb8,0x00,0x04,0x0c,0x08,0x08,0x08,0x0f,0x07,0x00, // 30xc0,0xe0,0xb0,0x98,0xfc,0xfc,0x80,0x00,0x00,0x00,0x00,0x08,0x0f,0x0f,0x08,0x00, // 40x7c,0x7c,0x44,0x44,0x44,0xc4,0x84,0x00,0x04,0x0c,0x08,0x08,0x08,0x0f,0x07,0x00, // 50xf0,0xf8,0x4c,0x44,0x44,0xc0,0x80,0x00,0x07,0x0f,0x08,0x08,0x08,0x0f,0x07,0x00, // 60x0c,0x0c,0x04,0x84,0xc4,0x7c,0x3c,0x00,0x00,0x00,0x0f,0x0f,0x00,0x00,0x00,0x00, // 70xb8,0xfc,0x44,0x44,0x44,0xfc,0xb8,0x00,0x07,0x0f,0x08,0x08,0x08,0x0f,0x07,0x00, // 80x38,0x7c,0x44,0x44,0x44,0xfc,0xf8,0x00,0x00,0x08,0x08,0x08,0x0c,0x07,0x03,0x00, // 90xe0,0xf0,0x98,0x8c,0x98,0xf0,0xe0,0x00,0x0f,0x0f,0x00,0x00,0x00,0x0f,0x0f,0x00, // 'A' 100x04,0xfc,0xfc,0x44,0x44,0xfc,0xb8,0x00,0x08,0x0f,0x0f,0x08,0x08,0x0f,0x07,0x00, // 'B' 110xf0,0xf8,0x0c,0x04,0x04,0x0c,0x18,0x00,0x03,0x07,0x0c,0x08,0x08,0x0c,0x06,0x00, // 'C' 120x04,0xfc,0xfc,0x04,0x0c,0xf8,0xf0,0x00,0x08,0x0f,0x0f,0x08,0x0c,0x07,0x03,0x00, // 'D' 130x04,0xfc,0xfc,0x44,0xe4,0x0c,0x1c,0x00,0x08,0x0f,0x0f,0x08,0x08,0x0c,0x0e,0x00, // 'E' 140x04,0xfc,0xfc,0x44,0xe4,0x0c,0x1c,0x00,0x08,0x0f,0x0f,0x08,0x00,0x00,0x00,0x00, // 'F' 15 0x00,0x80,0x80,0xe0,0xe0,0x80,0x80,0x00,0x00,0x00,0x00,0x03,0x03,0x00,0x00,0x00, // '+' 160x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // '-' 170x20,0x60,0xc0,0x80,0xc0,0x60,0x20,0x00,0x08,0x0c,0x07,0x03,0x07,0x0c,0x08,0x00, // 'x' 18
};

1.1.2 OLED显示 1 个8x16字符

代码

/**@brief show 0~9 number and '-' '+'*@param row, [0, 3]*@param col, [0, 15]*@param num, 0~15, '+' is 16, '-' is 17, 'x' is 18*/
uint8_t oled_show_number8x16(uint8_t row, uint8_t col, uint8_t num){uint8_t i = 0;uint8_t j = 0;if(num > 18 || row > 3 || col > 15){return 0;}col <<= 3; // 8 col per characterfor(j = 0; j < 2; j++){// Set GDDRAM Page Start Address(PAGE0~PAGE7) for Page Addressing Mode by X[2:0].oled_write_cmd(0xB0 | ((row << 1) + j)); // 0xB0|X[2:0]oled_write_cmd(0x00 | (col & 0xF)); // 0c00|X[3:0], Set Lower Column Start Address for Page Addressing Modeoled_write_cmd(0x10 | ((col & 0xF0) >> 4)); // 0x10|X[3:0], Set Higher Column Start Address for Page Addressing Modefor(i = 0; i < 8; i++){oled_write_dat(number8x16[ (num << 4) + ((j << 3) + i) ]); // 16 bytes per 8x16 character, 2 page per 8x16 character}}return 1;
}

1.2 OLED显示有符号数字

代码

/**@brief show -32767 ~ 32767 number*@param row, [0, 3]*@param col, [0, 15]*@param num, 0~9*/
uint8_t oled_show_number(uint8_t row, uint8_t col, int32_t num){uint8_t buf[5] = {0}; // Store the decomposed number [0 ~ 11]uint8_t i = 0;if(num < 0){ // Negative number Processingnum = -num;if(!oled_show_number8x16(row, col++, 17)){ // Show negative sign '-'return 0;}}else if(num == 0){ // Special number 0 Porcessingi = 1;}while(num){ // Decomposing the positive integer partbuf[i++] = num % 10;num /= 10;}do{i--;if(!oled_show_number8x16(row, col++, buf[i])){return 0;}}while(i != 0);return 1;
}

1.3 OLED显示十六进制无符号数字

代码

/***@param byte, [0~255] [0~65535] [0~4,294,967,296]**/
uint8_t oled_show_hex_byte(uint8_t row, uint8_t col, uint32_t num){uint8_t buf[8] = {0};uint8_t i = 0;if(num == 0){i = 1;}while(num){buf[i++] = num % 16;num /= 16;}if(!oled_show_number8x16(row, col++, 0)){return 0;}if(!oled_show_number8x16(row, col++, 18)){return 0;}do{i--;if(!oled_show_number8x16(row, col++, buf[i])){return 0;}}while(i != 0);return 1;
}

3 实现SPI读写FLASH

3.1 SPI逻辑实现

3.1.1 写字节

void spi_write_byte(uint8_t dat){uint8_t temp = 0x80;SPI_SCK = 0;for(temp = 0x80; temp; temp >>= 1){if(dat & temp){SPI_SI = 1;}else{SPI_SI = 0;}SPI_SCK = 1; // rising-edgeSPI_SCK = 0; // releasing the sck}
}

3.1.2 读字节

uint8_t spi_read_byte(void){uint8_t retVal = 0x00;uint8_t i = 0;SPI_SCK = 0;for(i = 0; i < 8; i++){SPI_SCK = 1;retVal <<= 1;retVal |= SPI_SO; // Getting a binarySPI_SCK = 0; // releasing the SCK}return retVal;
}

3.2 AT25F4096 相关代码

3.2.1 读设备号

// 0x1F == ATMEL 0x64 == AT25F4096
uint8_t flash_get_id(uint8_t *manufacturer, uint8_t *device){FLASH_CS0 = 0;spi_write_byte(AT25F4096_RDID);*manufacturer = spi_read_byte();*device = spi_read_byte();FLASH_CS0 = 1;if(*manufacturer != 0x1F){return 0;}return 1;
}

3.2.2 写使能和写禁用

使能:

void flash_enable_write(void){FLASH_CS0 = 0;spi_write_byte(AT25F4096_WREN);FLASH_CS0 = 1;
}

禁用

void flash_disable_write(void){FLASH_CS0 = 0;spi_write_byte(AT25F4096_WRDI);FLASH_CS0 = 1;
}

3.2.3 页写

3.2.3.1 写一页

void flash_write_page(uint8_t addr_H, uint8_t addr_M, uint8_t addr_L, uint8_t *arr, uint16_t len){uint16_t i = 0;if(len == 0){return;}if(addr_L + len <= 256){flash_enable_write();FLASH_CS0 = 0;spi_write_byte(AT25F4096_PROGRAM);spi_write_byte(addr_H);spi_write_byte(addr_M);spi_write_byte(addr_L);for(i = 0; i < len; i++){spi_write_byte(arr[i]);}FLASH_CS0 = 1;flash_disable_write();}
}

3.2.3.2 连续写(解决卷页问题)

uint8_t flash_write_continuous(uint8_t addr_H, uint8_t addr_M, uint8_t addr_L, uint8_t *arr, uint32_t len){uint16_t addr_high16_part = ((uint16_t)addr_H << 8) | addr_M;uint16_t first_page = 0;uint32_t remain_bytes = 0;uint8_t page_cnt = 0; // Counting the number of pagesif(addr_L + len > 524288){ // out of range(512 K)return 0;}if(addr_L + len <= 256){flash_write_page(addr_H, addr_M, addr_L, arr, len);}else{first_page = 256 - addr_L;flash_write_page(addr_H, addr_M, addr_L, arr, first_page);while(flash_isWriting()); // waiting to finish writing Flashremain_bytes = len - first_page;while(remain_bytes > 256){addr_high16_part++;addr_H = addr_high16_part / 256;addr_M = addr_high16_part % 256;flash_write_page(addr_H, addr_M, 0x00, &arr[first_page + page_cnt * 256], 256);while(flash_isWriting()); // waiting to finish writing Flashpage_cnt++;remain_bytes -= 256;}addr_high16_part++;addr_H = addr_high16_part / 256;addr_M = addr_high16_part % 256;flash_write_page(addr_H, addr_M, 0x00, &arr[first_page + page_cnt * 256], remain_bytes);while(flash_isWriting()); // waiting to finish writing Flash}return 1;
}

3.2.4 读状态(判断是否写入完成)

3.2.4.1 读状态寄存器

uint8_t flash_read_status(void){uint8_t status = 0x00;FLASH_CS0 = 0;spi_write_byte(AT25F4096_RDSR);status = spi_read_byte();FLASH_CS0 = 1;return status;
}

3.2.4.2 判断是否写入完成

// 1 - writing , 0 - standby
bit flash_isWriting(void){uint8_t status = 0x00;status = flash_read_status();return (status & 0x01);
}

3.2.5 读字节

uint8_t flash_read_byte(uint8_t addr_H, uint8_t addr_M, uint8_t addr_L){uint8_t readVal;FLASH_CS0 = 0;spi_write_byte(AT25F4096_READ);spi_write_byte(addr_H);spi_write_byte(addr_M);spi_write_byte(addr_L);readVal = spi_read_byte();FLASH_CS0 = 1;return readVal;
}

3.3 测试例程

3.3.1 Proteus面向软件编程的硬件模型

3.3.2 PC上生成一个有规律的大数组

3.3.2.1 电脑上生成测试数据的代码

#include <stdio.h>
int main(){for(int i = 0; i < 1000; i++){printf("0x%.2x,", i % 256);if((i + 1) % 16 == 0){printf("\r\n");}}return 0;
}

3.3.2.2 测试数据

uint8_t code arr[1000] = {// page 00x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
// page 10x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,0x90,0x91,0x92,0x93,0x94,0x95,0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32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x9f,0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,0xb0,0xb1,0xb2,0xb3,0xb4,0xb5,0xb6,0xb7,0xb8,0xb9,0xba,0xbb,0xbc,0xbd,0xbe,0xbf,0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,0xd0,0xd1,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda,0xdb,0xdc,0xdd,0xde,0xdf,0xe0,0xe1,0xe2,0xe3,0xe4,0xe5,0xe6,0xe7
};

3.3.3 Keil上编写测试代码

#include "at89c55.h"
#include "oled12864.h"
#include "at25f4096.h"sbit TEST_LED = P1^7;void delay_ms(uint16_t ms){uint16_t i, j;for(i = ms; i > 0; i--){for(j = 114; j > 0; j--);}
}int main(void){uint8_t buf[2] = {0};uint8_t readVal = 0x00;oled_init();delay_ms(500);// Display the ID of AT25F4096flash_get_id(&buf[0], &buf[1]);oled_show_hex_byte(1, 0, buf[0]);oled_show_hex_byte(2, 0, buf[1]);
//    flash_write_page(0x00, 0x00, 0xFF, arr, 1);flash_write_continuous(0x00, 0x00, 0xF0, arr, 1000);while(flash_isWriting()); // You must wait for flash to finish writing operation.readVal = flash_read_byte(0x00, 0x01, 0x01); // is 0x11oled_show_hex_byte(0, 0, readVal);readVal = flash_read_byte(0x00, 0x02, 0x01); // is 0x11oled_show_hex_byte(0, 5, readVal);readVal = flash_read_byte(0x00, 0x03, 0x01); // is 0x11oled_show_hex_byte(3, 0, readVal); readVal = flash_read_byte(0x00, 0x04, 0xD7); // is 0xE7oled_show_hex_byte(3, 5, readVal);while(1){}
//    return 0;
}

3.3.4 Proteus仿真现象与分析

3.3.4.1 现象

3.3.4.2 SPI数据传送分析

写入过程分析

等待写入完成

读出1字节过程

单片机作业1_为OLED制作汉字字库_第3部分相关推荐

  1. 单片机作业1_为OLED制作汉字字库_第4部分

    本部分2个工作: ① 向 AT25F4096 写入部分 HZK8x16 转化后的 "列行式" 数据 ② 解码 GB2312 字符,根据码值,去 AT25F4096 中寻找对应的点阵 ...

  2. stm32汉字字库显示实验与OLED的使用(开始于2021-09-01)

    stm32汉字字库显示实验与OLED的使用 1.字库的使用 GBK字库的简介: GBK库的由两部分组成,如下图: 高位从0x81开始是为了兼容ASII字符,因为未扩展的ASII字符是从0-128,即0 ...

  3. LittleVGL (LVGL)干货入门教程四之制作和使用中文汉字字库

    LittleVGL (LVGL)干货入门教程四之制作和使用中文汉字字库 前言: 阅读前,请确保你至少拥有以下条件: 已实现显示API(教程一已实现, 链接:LittleVGL (LVGL)入门教程一之 ...

  4. 单片机 怎调用显示屏字库_单片机巧用Windows矢量字库

    1 引 言本文引用地址:http://www.eepw.com.cn/article/172177.htm 单片机控制的LED.LCD显示屏均涉及到各种字体的汉字显示.建立单片机汉字字库的传统方法有使 ...

  5. 0.96吋 OLED 12864 汉字 显示 优化

    辅助舍友做毕业设计中的显示部分,优化了OLED的汉字显示,简化了函数的调用方式,略有小得,留做记录.程序在最后面. 未经授权,不得转载!_(:з)∠)_ 前言 中景园的给的例程中的汉字显示函数调用方式 ...

  6. LCD / OLED显示汉字,取模软件PCtoLCD2002完美版

    一.LCD显示汉字结果展示: 二.取模软件的使用(PCtoLCD2002完美版) 1. 打开软件,模式为(字符模式) 点击菜单栏[选项],打开字模选项 勾选[阴码点阵].逐列式取模.顺向(高位在前,低 ...

  7. 0.96寸OLED显示汉字,数字,英文,图片,GIF动画+取模软件使用+代码解析

    前言 本次我们学习一下STM32F103关于OLED显示汉字,数字,英文,图片,GIF动画,和介绍各种取模软件的使用,主要教会大家使用和修改OLED驱动的代码,对汉字大小,图片分辨率进行代码修改并显示 ...

  8. c语言oled p14x16str,OLED显示汉字

    OLED显示汉字 工具:OLED 芯片:K60,XS128等 取模软件:PCtoLCD2002完美版 显示汉字需要几个条件: 汉字索引表, const byte F14x16_Idx[] = { &q ...

  9. .net 数字转汉字_[原创工具] 小熊汉字笔顺学习软件,查笔顺、学拼音、制作汉字英文数字字贴...

    点击右上角"设为星标"每日精彩内容,第一时间送达! 前言 今天带来的是原创软件.家里有上一二年级的小朋友有福了!家里有打印机的可以把设置好的字帖打印出来,小朋友即可临摹.赶紧下载使 ...

最新文章

  1. 鼠标滚轮(mousewheel)和DOMMouseScroll事件 (转载)
  2. 指定开始_@高坪人,熏腊肉开始啦!指定地点仅限这9个地方,别走错啦
  3. 慕课堂计算机word,数字技能 – 办公工具(Microsoft Word、Excel、Power Point)
  4. Linux下社交平台,Linux 启动
  5. 前端学习(1708):前端系列javascript之问题解答
  6. 算法图解:如何判断括号是否有效?
  7. 在谈数据治理和数字化的时候,别忘了数据标准
  8. 信息学奥赛C++语言: 趣味整数5(勾股数)
  9. thinkphp自动验证分析
  10. FreeCAD源码分析:FEM模块
  11. pptx文件怎么打开(ppt兼容包下载)
  12. VMWare虚拟机Ubantu20.10添加中文智能拼音输入法
  13. windows下自动切换并连接wifi热点
  14. 清洗outliers
  15. 3种修正异常数据的方法
  16. 复利单利计算0318
  17. CSS文字自适应div宽度
  18. ieda永久破解!!!
  19. 中国战队Newbee夺DOTA2世界冠军
  20. html中创建学生对象,在考生文件夹下,存在一个数据库文件“sampl.mdb”。在数据库文件中已经建立了一个表对象“学生基本情...

热门文章

  1. matlab/simulink鼠标滚动设置成上下移动而不是缩放
  2. 英文网页批量翻译导出本地教程
  3. 脆弱性和安全风险分析
  4. 锦标赛选择算法及 matlab 实现
  5. 成为腾讯开发者——如何使用QQ开放平台和微信开放平台
  6. AlexNet网络结构详解与代码复现
  7. Latex编辑器Texstudio的注释快捷键。
  8. 2022经典生活感悟说说,句句值千金
  9. 2017年网易有数用户定位和产品能力
  10. 菜谱 延安特色美食小吃