绘图函数

Signed-off-by: kevin <kevin@lmve.net>
This commit is contained in:
2022-04-16 21:54:47 +08:00
parent 368f32622f
commit 0cd9f67310
16 changed files with 421 additions and 317 deletions
+14 -11
View File
@@ -10,15 +10,16 @@
const char testbmp[]=
{
0x00,0x00,0x00,0x00,0x16,0x1D,0x10,0x18,0x08,0x0C,0x06,0x07,0x02,0x03,0x02,0x02,
0x06,0x05,0x05,0x0D,0x79,0x51,0xC1,0x73,0x1D,0x07,0x03,0x03,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x93,0xFF,0x2C,0x19,0x11,0x33,0x22,0x26,
0x64,0x44,0x4C,0xC8,0xC8,0x58,0x90,0x11,0x90,0xB0,0x30,0x20,0x30,0x20,0x60,0xC0,
0xE6,0x3F,0x1F,0x03,0x01,0x00,0x00,0x00,0x00,0x01,0x1F,0x7E,0xFF,0xC0,0x80,0x80,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0xE0,0x00,0x00,0x00,
0x00,0x20,0x30,0x70,0x51,0x7D,0x57,0xF1,0xE1,0x7B,0x0F,0x07,0x7B,0xE3,0x07,0xBF,
0xFF,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
0x03,0x03,0x63,0x43,0xC3,0xC3,0x8B,0x9F,0xBB,0x23,0xB3,0x23,0x63,0x43,0xC3,0x03
0x00,0x00,0x02,0x00,0x0F,0x00,0x00,0x0F,0x00,0x0F,0x00,0x00,0x09,0x00,0x0F,0x0F,
0x00,0x0D,0x80,0x0F,0x05,0xC0,0x18,0x80,0x0F,0x0C,0x70,0xF0,0xC0,0x0F,0x08,0x3F,
0x81,0x70,0x0F,0x04,0x14,0x7F,0xF0,0x0F,0x0C,0x01,0xAC,0x18,0x0F,0x04,0x0F,0xC0,
0x38,0x0F,0x06,0x78,0x07,0xEC,0x0F,0x0D,0xC0,0x7E,0x86,0x0F,0x07,0x03,0xC0,0x06,
0x0F,0x06,0x1E,0x00,0x0E,0x0F,0x0C,0x70,0x00,0x0F,0x0F,0x0D,0xC0,0x10,0x07,0x8F,
0x0F,0x00,0x18,0x01,0x8F,0x1C,0x00,0x18,0x1F,0xCF,0x18,0x00,0x18,0x75,0xCF,0x38,
0x00,0x00,0x3F,0x4F,0x38,0x00,0x00,0x04,0x6F,0x38,0x00,0x00,0x06,0x3F,0x38,0x00,
0x00,0x02,0x7F,0x68,0x00,0x00,0x0F,0xFF,0x58,0x00,0x00,0xFA,0x2F,0xC8,0x00,0x03,
0xC0,0xEF,0xD8,0x00,0x02,0x0F,0x8F,0x98,0x00,0x00,0x1A,0x0F,0x98,0x00,0x00,0x38,
0x0F,0x38,0x00,0x00,0x10,0x0F
};
@@ -29,12 +30,14 @@ uint32_t run_tick=0;
OLED_Init();
OLED_Pix(0,0,36,32,testbmp);
OLED_Pix(0,0,36,30,testbmp,1);
OLED_Pix(50,0,36,30,testbmp,2);
OLED_Pix(0,30,36,30,testbmp,4);
while(1)
{
//OLED_Cache_to_hardware();
OLED_Cache_to_hardware();
if(HAL_GetTick()>run_tick)
{
run_tick+=500;
+68 -8
View File
@@ -249,16 +249,18 @@ void OLED_set_dot(unsigned char x,unsigned char y,unsigned char dot_type)
return ;
}
uint8_t y1=y/8;
uint8_t y2=y%8;
uint8_t y3=(0x80>>y2);
switch(dot_type)
{
case 0:
OLED_buff[y1][x] &= ~(1<<(y%8));
OLED_buff[y1][x] &= ~y3;
break;
case 1:
OLED_buff[y1][x] |= (1<<(y%8));
OLED_buff[y1][x] |= y3;
break;
case 2:
OLED_buff[y1][x] ^= (1<<(y%8));
OLED_buff[y1][x] ^= y3;
break;
case 3:break;
}
@@ -266,15 +268,73 @@ void OLED_set_dot(unsigned char x,unsigned char y,unsigned char dot_type)
}
/*
绘图函数
数据格式 从左到右,从上到下,横向8点右高位
type=0 清空区域
=1 区域图层
=2 正片叠底
=3 正片清空
=4 负片
*/
void OLED_Pix(unsigned char x,unsigned char y,unsigned char w,unsigned char h,const char *p)
void OLED_Pix(unsigned char x,unsigned char y,unsigned char w,unsigned char h,const char *p,unsigned char type)
{
OLED_Set_Pos(0,0);
for(int a=0;a<36;a++)
unsigned char b=0;
unsigned int c=0;
for(uint8_t h1=0;h1<h;h1++)
{
OLED_WrDat(p[a]);
for(uint8_t w1=0;w1<w;w1++)
{
if(p[c]&0x80>>b)
{
switch(type)
{
case 0:
OLED_set_dot(w1+x,h1+y,0);
break;
case 1:
OLED_set_dot(w1+x,h1+y,1);
break;
case 2:
OLED_set_dot(w1+x,h1+y,1);
break;
case 3:
OLED_set_dot(w1+x,h1+y,0);
break;
case 4:
OLED_set_dot(w1+x,h1+y,0);
break;
}
}else
{
switch(type)
{
case 0:
OLED_set_dot(w1+x,h1+y,0);
break;
case 1:
OLED_set_dot(w1+x,h1+y,0);
break;
case 2:
break;
case 4:
OLED_set_dot(w1+x,h1+y,1);
break;
}
}
b++;
if(b==8)
{
b=0;c++;
}
}
b=0;c++;
}
}
void OLED_ShowChar(unsigned char x,unsigned char y,unsigned char chr)
{
+1 -1
View File
@@ -22,7 +22,7 @@ void OLED_Init(void);
void OLED_Cache_to_hardware();
void OLED_set_dot(unsigned char x,unsigned char y,unsigned char dot_type);
void OLED_Pix(unsigned char x,unsigned char y,unsigned char w,unsigned char h,const char *p);
void OLED_Pix(unsigned char x,unsigned char y,unsigned char w,unsigned char h,const char *p,unsigned char type);
void OLED_ShowStr(unsigned char x,unsigned char y,char *str);