From d22f427dcbf8d5a2bf6d6bce8e6a4faa4d6678c4 Mon Sep 17 00:00:00 2001 From: IllusionLee <1115451437@qq.com> Date: Fri, 4 Oct 2019 16:50:14 +0800 Subject: [PATCH 1/4] Fix warning about oledfont.h with 'missing braces around initializer'. --- .../BSP/Hardware/OLED/oledfont.h | 184 +++++++++--------- 1 file changed, 92 insertions(+), 92 deletions(-) diff --git a/board/TencentOS_tiny_EVB_MX/BSP/Hardware/OLED/oledfont.h b/board/TencentOS_tiny_EVB_MX/BSP/Hardware/OLED/oledfont.h index b2f658c4..7d6675cc 100644 --- a/board/TencentOS_tiny_EVB_MX/BSP/Hardware/OLED/oledfont.h +++ b/board/TencentOS_tiny_EVB_MX/BSP/Hardware/OLED/oledfont.h @@ -8,98 +8,98 @@ /************************************6*8的点阵************************************/ const unsigned char F6x8[][6] = { -0x00, 0x00, 0x00, 0x00, 0x00, 0x00,// sp -0x00, 0x00, 0x00, 0x2f, 0x00, 0x00,// ! -0x00, 0x00, 0x07, 0x00, 0x07, 0x00,// " -0x00, 0x14, 0x7f, 0x14, 0x7f, 0x14,// # -0x00, 0x24, 0x2a, 0x7f, 0x2a, 0x12,// $ -0x00, 0x62, 0x64, 0x08, 0x13, 0x23,// % -0x00, 0x36, 0x49, 0x55, 0x22, 0x50,// & -0x00, 0x00, 0x05, 0x03, 0x00, 0x00,// ' -0x00, 0x00, 0x1c, 0x22, 0x41, 0x00,// ( -0x00, 0x00, 0x41, 0x22, 0x1c, 0x00,// ) -0x00, 0x14, 0x08, 0x3E, 0x08, 0x14,// * -0x00, 0x08, 0x08, 0x3E, 0x08, 0x08,// + -0x00, 0x00, 0x00, 0xA0, 0x60, 0x00,// , -0x00, 0x08, 0x08, 0x08, 0x08, 0x08,// - -0x00, 0x00, 0x60, 0x60, 0x00, 0x00,// . -0x00, 0x20, 0x10, 0x08, 0x04, 0x02,// / -0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E,// 0 -0x00, 0x00, 0x42, 0x7F, 0x40, 0x00,// 1 -0x00, 0x42, 0x61, 0x51, 0x49, 0x46,// 2 -0x00, 0x21, 0x41, 0x45, 0x4B, 0x31,// 3 -0x00, 0x18, 0x14, 0x12, 0x7F, 0x10,// 4 -0x00, 0x27, 0x45, 0x45, 0x45, 0x39,// 5 -0x00, 0x3C, 0x4A, 0x49, 0x49, 0x30,// 6 -0x00, 0x01, 0x71, 0x09, 0x05, 0x03,// 7 -0x00, 0x36, 0x49, 0x49, 0x49, 0x36,// 8 -0x00, 0x06, 0x49, 0x49, 0x29, 0x1E,// 9 -0x00, 0x00, 0x36, 0x36, 0x00, 0x00,// : -0x00, 0x00, 0x56, 0x36, 0x00, 0x00,// ; -0x00, 0x08, 0x14, 0x22, 0x41, 0x00,// < -0x00, 0x14, 0x14, 0x14, 0x14, 0x14,// = -0x00, 0x00, 0x41, 0x22, 0x14, 0x08,// > -0x00, 0x02, 0x01, 0x51, 0x09, 0x06,// ? -0x00, 0x32, 0x49, 0x59, 0x51, 0x3E,// @ -0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C,// A -0x00, 0x7F, 0x49, 0x49, 0x49, 0x36,// B -0x00, 0x3E, 0x41, 0x41, 0x41, 0x22,// C -0x00, 0x7F, 0x41, 0x41, 0x22, 0x1C,// D -0x00, 0x7F, 0x49, 0x49, 0x49, 0x41,// E -0x00, 0x7F, 0x09, 0x09, 0x09, 0x01,// F -0x00, 0x3E, 0x41, 0x49, 0x49, 0x7A,// G -0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F,// H -0x00, 0x00, 0x41, 0x7F, 0x41, 0x00,// I -0x00, 0x20, 0x40, 0x41, 0x3F, 0x01,// J -0x00, 0x7F, 0x08, 0x14, 0x22, 0x41,// K -0x00, 0x7F, 0x40, 0x40, 0x40, 0x40,// L -0x00, 0x7F, 0x02, 0x0C, 0x02, 0x7F,// M -0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F,// N -0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E,// O -0x00, 0x7F, 0x09, 0x09, 0x09, 0x06,// P -0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E,// Q -0x00, 0x7F, 0x09, 0x19, 0x29, 0x46,// R -0x00, 0x46, 0x49, 0x49, 0x49, 0x31,// S -0x00, 0x01, 0x01, 0x7F, 0x01, 0x01,// T -0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F,// U -0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F,// V -0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F,// W -0x00, 0x63, 0x14, 0x08, 0x14, 0x63,// X -0x00, 0x07, 0x08, 0x70, 0x08, 0x07,// Y -0x00, 0x61, 0x51, 0x49, 0x45, 0x43,// Z -0x00, 0x00, 0x7F, 0x41, 0x41, 0x00,// [ -0x00, 0x55, 0x2A, 0x55, 0x2A, 0x55,// 55 -0x00, 0x00, 0x41, 0x41, 0x7F, 0x00,// ] -0x00, 0x04, 0x02, 0x01, 0x02, 0x04,// ^ -0x00, 0x40, 0x40, 0x40, 0x40, 0x40,// _ -0x00, 0x00, 0x01, 0x02, 0x04, 0x00,// ' -0x00, 0x20, 0x54, 0x54, 0x54, 0x78,// a -0x00, 0x7F, 0x48, 0x44, 0x44, 0x38,// b -0x00, 0x38, 0x44, 0x44, 0x44, 0x20,// c -0x00, 0x38, 0x44, 0x44, 0x48, 0x7F,// d -0x00, 0x38, 0x54, 0x54, 0x54, 0x18,// e -0x00, 0x08, 0x7E, 0x09, 0x01, 0x02,// f -0x00, 0x18, 0xA4, 0xA4, 0xA4, 0x7C,// g -0x00, 0x7F, 0x08, 0x04, 0x04, 0x78,// h -0x00, 0x00, 0x44, 0x7D, 0x40, 0x00,// i -0x00, 0x40, 0x80, 0x84, 0x7D, 0x00,// j -0x00, 0x7F, 0x10, 0x28, 0x44, 0x00,// k -0x00, 0x00, 0x41, 0x7F, 0x40, 0x00,// l -0x00, 0x7C, 0x04, 0x18, 0x04, 0x78,// m -0x00, 0x7C, 0x08, 0x04, 0x04, 0x78,// n -0x00, 0x38, 0x44, 0x44, 0x44, 0x38,// o -0x00, 0xFC, 0x24, 0x24, 0x24, 0x18,// p -0x00, 0x18, 0x24, 0x24, 0x18, 0xFC,// q -0x00, 0x7C, 0x08, 0x04, 0x04, 0x08,// r -0x00, 0x48, 0x54, 0x54, 0x54, 0x20,// s -0x00, 0x04, 0x3F, 0x44, 0x40, 0x20,// t -0x00, 0x3C, 0x40, 0x40, 0x20, 0x7C,// u -0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C,// v -0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C,// w -0x00, 0x44, 0x28, 0x10, 0x28, 0x44,// x -0x00, 0x1C, 0xA0, 0xA0, 0xA0, 0x7C,// y -0x00, 0x44, 0x64, 0x54, 0x4C, 0x44,// z -0x14, 0x14, 0x14, 0x14, 0x14, 0x14,// horiz lines +{0x00, 0x00, 0x00, 0x00, 0x00, 0x00},// sp +{0x00, 0x00, 0x00, 0x2f, 0x00, 0x00},// ! +{0x00, 0x00, 0x07, 0x00, 0x07, 0x00},// " +{0x00, 0x14, 0x7f, 0x14, 0x7f, 0x14},// # +{0x00, 0x24, 0x2a, 0x7f, 0x2a, 0x12},// $ +{0x00, 0x62, 0x64, 0x08, 0x13, 0x23},// % +{0x00, 0x36, 0x49, 0x55, 0x22, 0x50},// & +{0x00, 0x00, 0x05, 0x03, 0x00, 0x00},// ' +{0x00, 0x00, 0x1c, 0x22, 0x41, 0x00},// ( +{0x00, 0x00, 0x41, 0x22, 0x1c, 0x00},// ) +{0x00, 0x14, 0x08, 0x3E, 0x08, 0x14},// * +{0x00, 0x08, 0x08, 0x3E, 0x08, 0x08},// + +{0x00, 0x00, 0x00, 0xA0, 0x60, 0x00},// , +{0x00, 0x08, 0x08, 0x08, 0x08, 0x08},// - +{0x00, 0x00, 0x60, 0x60, 0x00, 0x00},// . +{0x00, 0x20, 0x10, 0x08, 0x04, 0x02},// / +{0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E},// 0 +{0x00, 0x00, 0x42, 0x7F, 0x40, 0x00},// 1 +{0x00, 0x42, 0x61, 0x51, 0x49, 0x46},// 2 +{0x00, 0x21, 0x41, 0x45, 0x4B, 0x31},// 3 +{0x00, 0x18, 0x14, 0x12, 0x7F, 0x10},// 4 +{0x00, 0x27, 0x45, 0x45, 0x45, 0x39},// 5 +{0x00, 0x3C, 0x4A, 0x49, 0x49, 0x30},// 6 +{0x00, 0x01, 0x71, 0x09, 0x05, 0x03},// 7 +{0x00, 0x36, 0x49, 0x49, 0x49, 0x36},// 8 +{0x00, 0x06, 0x49, 0x49, 0x29, 0x1E},// 9 +{0x00, 0x00, 0x36, 0x36, 0x00, 0x00},// : +{0x00, 0x00, 0x56, 0x36, 0x00, 0x00},// ; +{0x00, 0x08, 0x14, 0x22, 0x41, 0x00},// < +{0x00, 0x14, 0x14, 0x14, 0x14, 0x14},// = +{0x00, 0x00, 0x41, 0x22, 0x14, 0x08},// > +{0x00, 0x02, 0x01, 0x51, 0x09, 0x06},// ? +{0x00, 0x32, 0x49, 0x59, 0x51, 0x3E},// @ +{0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C},// A +{0x00, 0x7F, 0x49, 0x49, 0x49, 0x36},// B +{0x00, 0x3E, 0x41, 0x41, 0x41, 0x22},// C +{0x00, 0x7F, 0x41, 0x41, 0x22, 0x1C},// D +{0x00, 0x7F, 0x49, 0x49, 0x49, 0x41},// E +{0x00, 0x7F, 0x09, 0x09, 0x09, 0x01},// F +{0x00, 0x3E, 0x41, 0x49, 0x49, 0x7A},// G +{0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F},// H +{0x00, 0x00, 0x41, 0x7F, 0x41, 0x00},// I +{0x00, 0x20, 0x40, 0x41, 0x3F, 0x01},// J +{0x00, 0x7F, 0x08, 0x14, 0x22, 0x41},// K +{0x00, 0x7F, 0x40, 0x40, 0x40, 0x40},// L +{0x00, 0x7F, 0x02, 0x0C, 0x02, 0x7F},// M +{0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F},// N +{0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E},// O +{0x00, 0x7F, 0x09, 0x09, 0x09, 0x06},// P +{0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E},// Q +{0x00, 0x7F, 0x09, 0x19, 0x29, 0x46},// R +{0x00, 0x46, 0x49, 0x49, 0x49, 0x31},// S +{0x00, 0x01, 0x01, 0x7F, 0x01, 0x01},// T +{0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F},// U +{0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F},// V +{0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F},// W +{0x00, 0x63, 0x14, 0x08, 0x14, 0x63},// X +{0x00, 0x07, 0x08, 0x70, 0x08, 0x07},// Y +{0x00, 0x61, 0x51, 0x49, 0x45, 0x43},// Z +{0x00, 0x00, 0x7F, 0x41, 0x41, 0x00},// [ +{0x00, 0x55, 0x2A, 0x55, 0x2A, 0x55},// 55 +{0x00, 0x00, 0x41, 0x41, 0x7F, 0x00},// ] +{0x00, 0x04, 0x02, 0x01, 0x02, 0x04},// ^ +{0x00, 0x40, 0x40, 0x40, 0x40, 0x40},// _ +{0x00, 0x00, 0x01, 0x02, 0x04, 0x00},// ' +{0x00, 0x20, 0x54, 0x54, 0x54, 0x78},// a +{0x00, 0x7F, 0x48, 0x44, 0x44, 0x38},// b +{0x00, 0x38, 0x44, 0x44, 0x44, 0x20},// c +{0x00, 0x38, 0x44, 0x44, 0x48, 0x7F},// d +{0x00, 0x38, 0x54, 0x54, 0x54, 0x18},// e +{0x00, 0x08, 0x7E, 0x09, 0x01, 0x02},// f +{0x00, 0x18, 0xA4, 0xA4, 0xA4, 0x7C},// g +{0x00, 0x7F, 0x08, 0x04, 0x04, 0x78},// h +{0x00, 0x00, 0x44, 0x7D, 0x40, 0x00},// i +{0x00, 0x40, 0x80, 0x84, 0x7D, 0x00},// j +{0x00, 0x7F, 0x10, 0x28, 0x44, 0x00},// k +{0x00, 0x00, 0x41, 0x7F, 0x40, 0x00},// l +{0x00, 0x7C, 0x04, 0x18, 0x04, 0x78},// m +{0x00, 0x7C, 0x08, 0x04, 0x04, 0x78},// n +{0x00, 0x38, 0x44, 0x44, 0x44, 0x38},// o +{0x00, 0xFC, 0x24, 0x24, 0x24, 0x18},// p +{0x00, 0x18, 0x24, 0x24, 0x18, 0xFC},// q +{0x00, 0x7C, 0x08, 0x04, 0x04, 0x08},// r +{0x00, 0x48, 0x54, 0x54, 0x54, 0x20},// s +{0x00, 0x04, 0x3F, 0x44, 0x40, 0x20},// t +{0x00, 0x3C, 0x40, 0x40, 0x20, 0x7C},// u +{0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C},// v +{0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C},// w +{0x00, 0x44, 0x28, 0x10, 0x28, 0x44},// x +{0x00, 0x1C, 0xA0, 0xA0, 0xA0, 0x7C},// y +{0x00, 0x44, 0x64, 0x54, 0x4C, 0x44},// z +{0x14, 0x14, 0x14, 0x14, 0x14, 0x14},// horiz lines }; /****************************************8*16的点阵************************************/ const unsigned char F8X16[]= From 6dd262ac09e9ab6444aa9400ab5587b36d4899e3 Mon Sep 17 00:00:00 2001 From: IllusionLee <1115451437@qq.com> Date: Fri, 4 Oct 2019 16:55:16 +0800 Subject: [PATCH 2/4] Fix warning about E53_IA1.c with 'array subscript has type char'. --- board/TencentOS_tiny_EVB_MX/BSP/Hardware/E53_IA1/E53_IA1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/board/TencentOS_tiny_EVB_MX/BSP/Hardware/E53_IA1/E53_IA1.c b/board/TencentOS_tiny_EVB_MX/BSP/Hardware/E53_IA1/E53_IA1.c index 00415d6e..01882a75 100644 --- a/board/TencentOS_tiny_EVB_MX/BSP/Hardware/E53_IA1/E53_IA1.c +++ b/board/TencentOS_tiny_EVB_MX/BSP/Hardware/E53_IA1/E53_IA1.c @@ -91,7 +91,7 @@ uint8_t SHT3x_CheckCrc(char data[], char nbrOfBytes, char checksum) char crc = 0xFF; char bit = 0; - char byteCtr ; + unsigned char byteCtr; //calculates 8-Bit checksum with given polynomial for(byteCtr = 0; byteCtr < nbrOfBytes; ++byteCtr) From 3d5b7bd6a15e77cfd9c7667fc22a8f6420af8ec3 Mon Sep 17 00:00:00 2001 From: IllusionLee <1115451437@qq.com> Date: Fri, 4 Oct 2019 16:59:14 +0800 Subject: [PATCH 3/4] Fix warning about oled.c with 'this for clause does not guard'. --- board/TencentOS_tiny_EVB_MX/BSP/Hardware/OLED/oled.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/board/TencentOS_tiny_EVB_MX/BSP/Hardware/OLED/oled.c b/board/TencentOS_tiny_EVB_MX/BSP/Hardware/OLED/oled.c index 33c36183..3418797e 100644 --- a/board/TencentOS_tiny_EVB_MX/BSP/Hardware/OLED/oled.c +++ b/board/TencentOS_tiny_EVB_MX/BSP/Hardware/OLED/oled.c @@ -179,8 +179,10 @@ void OLED_ShowChar(uint8_t x,uint8_t y,uint8_t chr,uint8_t Char_Size) { OLED_Set_Pos(x,y); for(i=0;i<8;i++) + { OLED_WR_Byte(F8X16[c*16+i],OLED_DATA); - OLED_Set_Pos(x,y+1); + } + OLED_Set_Pos(x,y+1); for(i=0;i<8;i++) OLED_WR_Byte(F8X16[c*16+i+8],OLED_DATA); } From dba0bcf45247bfb21e8aef372f5d65a68d96ac22 Mon Sep 17 00:00:00 2001 From: IllusionLee <1115451437@qq.com> Date: Fri, 4 Oct 2019 17:23:41 +0800 Subject: [PATCH 4/4] Fix garbled code about bmp.h oled.c oled.h oledfont.h . --- .../BSP/Hardware/OLED/bmp.h | 6 +- .../BSP/Hardware/OLED/oled.c | 195 +++++++++--------- .../BSP/Hardware/OLED/oled.h | 34 ++- .../BSP/Hardware/OLED/oledfont.h | 46 ++--- 4 files changed, 138 insertions(+), 143 deletions(-) diff --git a/board/TencentOS_tiny_EVB_MX/BSP/Hardware/OLED/bmp.h b/board/TencentOS_tiny_EVB_MX/BSP/Hardware/OLED/bmp.h index 0775126f..9c852fa4 100644 --- a/board/TencentOS_tiny_EVB_MX/BSP/Hardware/OLED/bmp.h +++ b/board/TencentOS_tiny_EVB_MX/BSP/Hardware/OLED/bmp.h @@ -1,7 +1,7 @@ -////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////// // // -//存储图片数据,图片大小为64*32像素 +//瀛樺偍鍥剧墖鏁版嵁锛屽浘鐗囧ぇ灏忎负64*32鍍忕礌 // ///////////////////////////////////////////////////////////////////////////////// @@ -71,7 +71,7 @@ unsigned char BMP1[] = 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x20,0x40,0x40, -0x40,0x50,0x20,0x5F,0x80,0x00,0x1F,0x20,0x40,0x40,0x40,0x50,0x20,0x5F,0x80,0x00,/*"C:\Users\evk\Desktop\??2014.bmp",0*/ +0x40,0x50,0x20,0x5F,0x80,0x00,0x1F,0x20,0x40,0x40,0x40,0x50,0x20,0x5F,0x80,0x00, }; diff --git a/board/TencentOS_tiny_EVB_MX/BSP/Hardware/OLED/oled.c b/board/TencentOS_tiny_EVB_MX/BSP/Hardware/OLED/oled.c index 3418797e..44b67bae 100644 --- a/board/TencentOS_tiny_EVB_MX/BSP/Hardware/OLED/oled.c +++ b/board/TencentOS_tiny_EVB_MX/BSP/Hardware/OLED/oled.c @@ -1,15 +1,15 @@ #include "oled.h" #include "stdlib.h" -#include "oledfont.h" -//OLED的显存 -//存放格式如下. +#include "oledfont.h" +//OLED鐨勬樉瀛 +//瀛樻斁鏍煎紡濡備笅. //----------------------------------- -//|x→[0,127] | -//| OLED显示坐标 | -//|y 范围 | -//|↓ | +//|x鈫抂0,127] | +//| OLED鏄剧ず鍧愭爣 | +//|y 鑼冨洿 | +//|鈫 | //|[0,31] | -//----------------------------------- +//----------------------------------- /********************************************** //IIC Start **********************************************/ @@ -46,7 +46,7 @@ void Write_IIC_Byte(unsigned char IIC_Byte) unsigned char m,da; da=IIC_Byte; OLED_SCLK_Clr(); - for(i=0;i<8;i++) + for(i=0;i<8;i++) { m=da; m=m&0x80; @@ -54,7 +54,7 @@ void Write_IIC_Byte(unsigned char IIC_Byte) { OLED_SDIN_Set(); } - else + else OLED_SDIN_Clr(); da=da<<1; OLED_SCLK_Set(); @@ -68,11 +68,11 @@ void Write_IIC_Command(unsigned char IIC_Command) { IIC_Start(); Write_IIC_Byte(0x78); //Slave address,SA0=0 - IIC_Wait_Ack(); + IIC_Wait_Ack(); Write_IIC_Byte(0x00); //write command - IIC_Wait_Ack(); - Write_IIC_Byte(IIC_Command); - IIC_Wait_Ack(); + IIC_Wait_Ack(); + Write_IIC_Byte(IIC_Command); + IIC_Wait_Ack(); IIC_Stop(); } /********************************************** @@ -82,11 +82,11 @@ void Write_IIC_Data(unsigned char IIC_Data) { IIC_Start(); Write_IIC_Byte(0x78); //D/C#=0; R/W#=0 - IIC_Wait_Ack(); + IIC_Wait_Ack(); Write_IIC_Byte(0x40); //write data - IIC_Wait_Ack(); + IIC_Wait_Ack(); Write_IIC_Byte(IIC_Data); - IIC_Wait_Ack(); + IIC_Wait_Ack(); IIC_Stop(); } void OLED_WR_Byte(unsigned dat,unsigned cmd) @@ -95,9 +95,9 @@ void OLED_WR_Byte(unsigned dat,unsigned cmd) { Write_IIC_Data(dat); } - else + else { - Write_IIC_Command(dat); + Write_IIC_Command(dat); } } @@ -120,96 +120,97 @@ void fill_picture(unsigned char fill_Data) } } -//坐标设置 -void OLED_Set_Pos(unsigned char x, unsigned char y) -{ +//鍧愭爣璁剧疆 +void OLED_Set_Pos(unsigned char x, unsigned char y) +{ OLED_WR_Byte(0xb0+y,OLED_CMD); OLED_WR_Byte(((x&0xf0)>>4)|0x10,OLED_CMD); - OLED_WR_Byte((x&0x0f),OLED_CMD); -} -//开启OLED显示 + OLED_WR_Byte((x&0x0f),OLED_CMD); +} +//寮鍚疧LED鏄剧ず void OLED_Display_On(void) { - OLED_WR_Byte(0X8D,OLED_CMD); //SET DCDC命令 + OLED_WR_Byte(0X8D,OLED_CMD); //SET DCDC鍛戒护 OLED_WR_Byte(0X14,OLED_CMD); //DCDC ON OLED_WR_Byte(0XAF,OLED_CMD); //DISPLAY ON } -//关闭OLED显示 +//鍏抽棴OLED鏄剧ず void OLED_Display_Off(void) { - OLED_WR_Byte(0X8D,OLED_CMD); //SET DCDC命令 + OLED_WR_Byte(0X8D,OLED_CMD); //SET DCDC鍛戒护 OLED_WR_Byte(0X10,OLED_CMD); //DCDC OFF OLED_WR_Byte(0XAE,OLED_CMD); //DISPLAY OFF -} -//注意:清屏函数,清完屏,整个屏幕是黑色的!和没点亮一样!!! -void OLED_Clear(void) -{ - uint8_t i,n; - for(i=0;i<8;i++) - { - OLED_WR_Byte (0xb0+i,OLED_CMD); //设置页地址(0~7) - OLED_WR_Byte (0x00,OLED_CMD); //设置显示位置—列低地址 - OLED_WR_Byte (0x10,OLED_CMD); //设置显示位置—列高地址 +} +//娉ㄦ剰锛氭竻灞忓嚱鏁,娓呭畬灞,鏁翠釜灞忓箷鏄粦鑹茬殑!鍜屾病鐐逛寒涓鏍!!! +void OLED_Clear(void) +{ + uint8_t i,n; + for(i=0;i<8;i++) + { + OLED_WR_Byte (0xb0+i,OLED_CMD); //璁剧疆椤靛湴鍧锛0~7锛 + OLED_WR_Byte (0x00,OLED_CMD); //璁剧疆鏄剧ず浣嶇疆鈥斿垪浣庡湴鍧 + OLED_WR_Byte (0x10,OLED_CMD); //璁剧疆鏄剧ず浣嶇疆鈥斿垪楂樺湴鍧 for(n=0;n<128;n++) - OLED_WR_Byte(0,OLED_DATA); - } //更新显示 + OLED_WR_Byte(0,OLED_DATA); + } //鏇存柊鏄剧ず } -void OLED_On(void) -{ - uint8_t i,n; - for(i=0;i<8;i++) - { - OLED_WR_Byte (0xb0+i,OLED_CMD); //设置页地址(0~7) - OLED_WR_Byte (0x00,OLED_CMD); //设置显示位置—列低地址 - OLED_WR_Byte (0x10,OLED_CMD); //设置显示位置—列高地址 - for(n=0;n<128;n++)OLED_WR_Byte(1,OLED_DATA); - } //更新显示 +void OLED_On(void) +{ + uint8_t i,n; + for(i=0;i<8;i++) + { + OLED_WR_Byte (0xb0+i,OLED_CMD); //璁剧疆椤靛湴鍧锛0~7锛 + OLED_WR_Byte (0x00,OLED_CMD); //璁剧疆鏄剧ず浣嶇疆鈥斿垪浣庡湴鍧 + OLED_WR_Byte (0x10,OLED_CMD); //璁剧疆鏄剧ず浣嶇疆鈥斿垪楂樺湴鍧 + for(n=0;n<128;n++)OLED_WR_Byte(1,OLED_DATA); + } //鏇存柊鏄剧ず } -//在指定位置显示一个字符,包括部分字符 +//鍦ㄦ寚瀹氫綅缃樉绀轰竴涓瓧绗,鍖呮嫭閮ㄥ垎瀛楃 //x:0~127 //y:0~63 -// -//size:选择字体 16/12 +// +//size:閫夋嫨瀛椾綋 16/12 void OLED_ShowChar(uint8_t x,uint8_t y,uint8_t chr,uint8_t Char_Size) -{ - unsigned char c=0,i=0; - c=chr-' ';//得到偏移后的值 +{ + unsigned char c=0,i=0; + c=chr-' ';//寰楀埌鍋忕Щ鍚庣殑鍊 if(x>Max_Column-1){x=0;y=y+2;} if(Char_Size ==16) { - OLED_Set_Pos(x,y); + OLED_Set_Pos(x,y); for(i=0;i<8;i++) { OLED_WR_Byte(F8X16[c*16+i],OLED_DATA); } OLED_Set_Pos(x,y+1); - for(i=0;i<8;i++) + for(i=0;i<8;i++){ OLED_WR_Byte(F8X16[c*16+i+8],OLED_DATA); + } } - else - { + else + { OLED_Set_Pos(x,y); for(i=0;i<6;i++) OLED_WR_Byte(F6x8[c][i],OLED_DATA); } } -//m^n函数 +//m^n鍑芥暟 uint32_t oled_pow(uint8_t m,uint8_t n) { - uint32_t result=1; - while(n--)result*=m; + uint32_t result=1; + while(n--)result*=m; return result; -} -//显示2个数字 -//x,y :起点坐标 -//len :数字的位数 -//size:字体大小 +} +//鏄剧ず2涓暟瀛 +//x,y :璧风偣鍧愭爣 +//len :鏁板瓧鐨勪綅鏁 +//size:瀛椾綋澶у皬 // -//num:数值(0~4294967295); +//num:鏁板(0~4294967295); void OLED_ShowNum(uint8_t x,uint8_t y,uint32_t num,uint8_t len,uint8_t size2) -{ +{ uint8_t t,temp; - uint8_t enshow=0; + uint8_t enshow=0; for(t=0;t120) @@ -240,60 +241,60 @@ void OLED_ShowString(uint8_t x,uint8_t y,uint8_t *chr,uint8_t Char_Size) j++; } } -//显示汉字 +//鏄剧ず姹夊瓧 void OLED_ShowCHinese(uint8_t x,uint8_t y,uint8_t no) -{ +{ uint8_t t,adder=0; - OLED_Set_Pos(x,y); + OLED_Set_Pos(x,y); for(t=0;t<16;t++) { OLED_WR_Byte(Hzk[2*no][t],OLED_DATA); adder+=1; - } - OLED_Set_Pos(x,y+1); + } + OLED_Set_Pos(x,y+1); for(t=0;t<16;t++) - { + { OLED_WR_Byte(Hzk[2*no+1][t],OLED_DATA); adder+=1; - } + } } -/***********功能描述:显示显示BMP图片128×64起始点坐标(x,y),x的范围0~127,y为页的范围0~7*****************/ +/***********鍔熻兘鎻忚堪锛氭樉绀烘樉绀築MP鍥剧墖128脳64璧峰鐐瑰潗鏍(x,y),x鐨勮寖鍥0銆127锛寉涓洪〉鐨勮寖鍥0銆7*****************/ void OLED_DrawBMP(unsigned char x0, unsigned char y0,unsigned char x1, unsigned char y1,unsigned char BMP[]) -{ +{ unsigned int j=0; unsigned char x,y; - if(y1%8==0) y=y1/8; + if(y1%8==0) y=y1/8; else y=y1/8+1; for(y=y0;y