终版
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
/* ... 请确保您文件里这部分内容是完整的 ... */
|
||||
|
||||
/*引脚初始化*/
|
||||
/* 函数作用:初始化 OLED 软件 I2C 使用的 SCL 和 SDA GPIO。 */
|
||||
void OLED_I2C_Init(void)
|
||||
{
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
|
||||
@@ -28,6 +29,7 @@ void OLED_I2C_Init(void)
|
||||
OLED_W_SDA(1);
|
||||
}
|
||||
|
||||
/* 函数作用:产生 OLED 软件 I2C 起始信号。 */
|
||||
void OLED_I2C_Start(void)
|
||||
{
|
||||
OLED_W_SDA(1);
|
||||
@@ -36,6 +38,7 @@ void OLED_I2C_Start(void)
|
||||
OLED_W_SCL(0);
|
||||
}
|
||||
|
||||
/* 函数作用:产生 OLED 软件 I2C 停止信号。 */
|
||||
void OLED_I2C_Stop(void)
|
||||
{
|
||||
OLED_W_SDA(0);
|
||||
@@ -43,6 +46,7 @@ void OLED_I2C_Stop(void)
|
||||
OLED_W_SDA(1);
|
||||
}
|
||||
|
||||
/* 函数作用:通过软件 I2C 向 OLED 发送一个字节。 */
|
||||
void OLED_I2C_SendByte(uint8_t Byte)
|
||||
{
|
||||
uint8_t i;
|
||||
@@ -56,6 +60,7 @@ void OLED_I2C_SendByte(uint8_t Byte)
|
||||
OLED_W_SCL(0);
|
||||
}
|
||||
|
||||
/* 函数作用:向 OLED 写入一条控制命令。 */
|
||||
void OLED_WriteCommand(uint8_t Command)
|
||||
{
|
||||
OLED_I2C_Start();
|
||||
@@ -65,6 +70,7 @@ void OLED_WriteCommand(uint8_t Command)
|
||||
OLED_I2C_Stop();
|
||||
}
|
||||
|
||||
/* 函数作用:向 OLED 写入一个显示数据字节。 */
|
||||
void OLED_WriteData(uint8_t Data)
|
||||
{
|
||||
OLED_I2C_Start();
|
||||
@@ -74,6 +80,7 @@ void OLED_WriteData(uint8_t Data)
|
||||
OLED_I2C_Stop();
|
||||
}
|
||||
|
||||
/* 函数作用:设置 OLED 显存写入光标位置。 */
|
||||
void OLED_SetCursor(uint8_t Y, uint8_t X)
|
||||
{
|
||||
OLED_WriteCommand(0xB0 | Y);
|
||||
@@ -81,6 +88,7 @@ void OLED_SetCursor(uint8_t Y, uint8_t X)
|
||||
OLED_WriteCommand(0x00 | (X & 0x0F));
|
||||
}
|
||||
|
||||
/* 函数作用:清空 OLED 屏幕显示内容。 */
|
||||
void OLED_Clear(void)
|
||||
{
|
||||
uint8_t i, j;
|
||||
@@ -94,6 +102,7 @@ void OLED_Clear(void)
|
||||
}
|
||||
}
|
||||
|
||||
/* 函数作用:在指定行列显示一个 ASCII 字符。 */
|
||||
void OLED_ShowChar(uint8_t Line, uint8_t Column, char Char)
|
||||
{
|
||||
uint8_t i;
|
||||
@@ -109,6 +118,7 @@ void OLED_ShowChar(uint8_t Line, uint8_t Column, char Char)
|
||||
}
|
||||
}
|
||||
|
||||
/* 函数作用:从指定行列开始显示字符串。 */
|
||||
void OLED_ShowString(uint8_t Line, uint8_t Column, char *String)
|
||||
{
|
||||
uint8_t i;
|
||||
@@ -118,6 +128,7 @@ void OLED_ShowString(uint8_t Line, uint8_t Column, char *String)
|
||||
}
|
||||
}
|
||||
|
||||
/* 函数作用:计算整数 X 的 Y 次方,用于数字拆位显示。 */
|
||||
uint32_t OLED_Pow(uint32_t X, uint32_t Y)
|
||||
{
|
||||
uint32_t Result = 1;
|
||||
@@ -128,6 +139,7 @@ uint32_t OLED_Pow(uint32_t X, uint32_t Y)
|
||||
return Result;
|
||||
}
|
||||
|
||||
/* 函数作用:在 OLED 上显示指定长度的无符号十进制数字。 */
|
||||
void OLED_ShowNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length)
|
||||
{
|
||||
uint8_t i;
|
||||
@@ -137,6 +149,7 @@ void OLED_ShowNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length)
|
||||
}
|
||||
}
|
||||
|
||||
/* 函数作用:在 OLED 上显示带正负号的十进制数字。 */
|
||||
void OLED_ShowSignedNum(uint8_t Line, uint8_t Column, int32_t Number, uint8_t Length)
|
||||
{
|
||||
uint8_t i;
|
||||
@@ -157,6 +170,7 @@ void OLED_ShowSignedNum(uint8_t Line, uint8_t Column, int32_t Number, uint8_t Le
|
||||
}
|
||||
}
|
||||
|
||||
/* 函数作用:在 OLED 上显示指定长度的十六进制数字。 */
|
||||
void OLED_ShowHexNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length)
|
||||
{
|
||||
uint8_t i, SingleNumber;
|
||||
@@ -174,6 +188,7 @@ void OLED_ShowHexNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Leng
|
||||
}
|
||||
}
|
||||
|
||||
/* 函数作用:在 OLED 上显示指定长度的二进制数字。 */
|
||||
void OLED_ShowBinNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length)
|
||||
{
|
||||
uint8_t i;
|
||||
@@ -191,6 +206,7 @@ void OLED_ShowBinNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Leng
|
||||
* @param num 要显示的汉字在OLED_F16x16_CN字模数组中的索引
|
||||
* @retval 无
|
||||
*/
|
||||
/* 函数作用:按照字模索引在 OLED 上显示一个 16x16 汉字。 */
|
||||
void OLED_ShowChinese(uint8_t Line, uint8_t Column, uint8_t num)
|
||||
{
|
||||
uint8_t i;
|
||||
@@ -219,6 +235,7 @@ void OLED_ShowChinese(uint8_t Line, uint8_t Column, uint8_t num)
|
||||
|
||||
|
||||
/* ... OLED_Init() 函数保持不变 ... */
|
||||
/* 函数作用:初始化 OLED 控制器参数并清屏。 */
|
||||
void OLED_Init(void)
|
||||
{
|
||||
uint32_t i, j;
|
||||
|
||||
Reference in New Issue
Block a user