点阵测试程序,如果在windowsTermal中需要打开头文件下的宏定义(WT下面方块占两个位置):
#include "stdio.h"
#include <stdlib.h>
typedef unsigned char uint8;
#define WIDTH 64
#define HEIGHT 64
#define PAGE 4
#define _OLED_Reverse 0
uint8 _buf[WIDTH*PAGE];
void OLED_DrawHLine(uint8 x, uint8 y, uint8 w)
{
uint8 *pBuf;
uint8 mask;
if (x + w > WIDTH)
w = WIDTH - x;
if (y > HEIGHT - 1)
y = HEIGHT - 1;
pBuf = &_buf[(y >> 3) * WIDTH + x];
mask = 1 << (y & 7);
while (w--)
{
if (_OLED_Reverse)
{
*pBuf++ &= ~mask;
}
else
{
*pBuf++ |= mask;
}
}
}
void show(void)
{
uint8 i, j, k;
uint8 x = 0, y = 0;
printf(" ");
for(i = 0; i < WIDTH; i ++)
{
if(y%8 == 0)
printf("%-2d",y);
else
printf(" ");
y ++;
}
y = 0;
printf("\n");
printf(" ");
for(i = 0; i < WIDTH; i ++)
{
printf("%-2d",(y++)&0x07);
}
printf("\n");
for(i = 0; i < PAGE; i++)
{
for(j = 0; j < 8; j++)
{
printf("%2d: ",x++);
for(k = 0; k < WIDTH; k ++)
{
if(_buf[i*WIDTH+k]&(0x01<<j))
printf(" ");
else
#ifdef windowTerminal
printf("■ ");
#endif
#ifndef windowTerminal
printf("■");
#endif
}
printf("\n");
}
}
}
int main(void)
{
uint8 i = 0, j = 0;
for(i=0; i< 20; i++)
{
system("clear");
OLED_DrawHLine(i+2,j+2,8);
show();
j++;
}
getchar();
return 0;
}
|