STM32F103核心板I2C驱动oled代码(纯小白拿来就可用)

先来看效果图吧
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
我是从零开始学习stm32单片机的,写这篇记录学习过程,也希望可以帮助正在学习的小伙伴们。

淘宝买的stm32核心板,0.96寸I2C通信的oled屏幕,下载程序是用的st-link,这个比串口下载好用。

存放字符串,图片16进制的头文件

codetab.h

#ifndef __CODETAB_H
#define __CODETAB_H
/1616µÄµãÕó×ÖÌåÈ¡Ä£·½Ê½£º¹²Òõ¡ª¡ªÁÐÐÐʽ¡ª¡ªÄæÏòÊä³ö/
//unsigned char F16x16[] =//{ 0x00,0xFE,0x92,0x92,0xFE,0x92,0x92,0xFE,0x00,0x42,0x4A,0xD2,0x6A,0x46,0xC0,0x00,
// 0x40,0xC4,0x44,0x44,0x3F,0x24,0x24,0x24,0x00,0x40,0x80,0x7F,0x00,0x01,0x00,0x00,/
“Ò°”,0
/// 0x00,0x00,0xC0,0x38,0x00,0x00,0x00,0xFF,0x00,0x00,0x40,0x20,0x18,0x00,0x00,0x00,
// 0x80,0x81,0x40,0x20,0x10,0x0C,0x03,0x00,0x03,0x0C,0x10,0x20,0x40,0x80,0x80,0x00,/
"»ð",1
/// 0x24,0x24,0xA4,0xFE,0xA3,0x22,0x00,0x22,0xCC,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,
// 0x08,0x06,0x01,0xFF,0x00,0x01,0x04,0x04,0x04,0x04,0x04,0xFF,0x02,0x02,0x02,0x00,/
"¿Æ",2
/// 0x10,0x10,0x10,0xFF,0x10,0x90,0x08,0x88,0x88,0x88,0xFF,0x88,0x88,0x88,0x08,0x00,
// 0x04,0x44,0x82,0x7F,0x01,0x80,0x80,0x40,0x43,0x2C,0x10,0x28,0x46,0x81,0x80,0x00/
“¼¼”,3
/
//};
unsigned char F16x16[] =
{0x00,0x00,0x00,0x00,0xFC,0x00,0x00,0x00,0x00,0xC0,0xFE,0x00,0x00,0x00,0x00,0x00,
0x00,0x60,0x30,0x0C,0x03,0x43,0x4E,0x34,0x1C,0x07,0x01,0x0E,0x18,0x70,0x40,0x00,/
“´Ó”,0
/0x00,0x00,0x00,0x00,0x00,0x06,0x8C,0xF8,0x70,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x60,0x60,0x30,0x1C,0x06,0x03,0x00,0x00,0x01,0x07,0x1C,0x38,0x30,0x20,0x00,/
“Èë”,1
/0x00,0x00,0xF0,0x06,0x0C,0x00,0x00,0x04,0x04,0x04,0x04,0x04,0x04,0xFC,0x00,0x00,
0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x40,0x7F,0x00,0x00,/
“ÃÅ”,2
/0x00,0xC4,0xC4,0xB4,0x9C,0xC4,0x44,0x74,0xC4,0x80,0xF8,0x00,0x00,0xFE,0xFE,0x00,
0x00,0x64,0x64,0x24,0x3F,0x3F,0x24,0x24,0x24,0x00,0x0F,0x40,0xC0,0x7F,0x3F,0x00,/
“µ½”,3
/0x00,0x10,0x10,0xF6,0x9C,0x90,0x90,0x90,0xC0,0xF8,0x16,0x10,0xF0,0x70,0x10,0x00,
0x00,0x60,0x38,0x0F,0x40,0x40,0x7F,0x40,0x40,0x61,0x3E,0x18,0x27,0x40,0xC0,0x00,/
"·Å",4*/0x00,0x08,0x08,0xC8,0x48,0x68,0x58,0x4E,0x4E,0x48,0x78,0x68,0xC8,0x08,0x08,0x00,
0x00,0x04,0x44,0x44,0x24,0x1F,0x05,0x04,0x04,0x04,0x7F,0x04,0x04,0x04,0x04,0x00,/“Æú”,5/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x30,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/",",6/

0x00,0x04,0x04,0xE4,0x24,0x24,0x24,0xFC,0xFC,0x24,0x24,0x24,0xE4,0x04,0x00,0x00,
0x00,0x08,0x08,0xFF,0x09,0x09,0x09,0x0F,0x0F,0x09,0x49,0xC9,0x7F,0x08,0x08,0x08,/“ÔÙ”,7/0x00,0xC4,0xC4,0xB4,0x9C,0xC4,0x44,0x74,0xC4,0x80,0xF8,0x00,0x00,0xFE,0xFE,0x00,
0x00,0x64,0x64,0x24,0x3F,0x3F,0x24,0x24,0x24,0x00,0x0F,0x40,0xC0,0x7F,0x3F,0x00,/“µ½”,8/0x00,0x00,0x00,0x00,0x00,0x06,0x8C,0xF8,0x70,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x60,0x60,0x30,0x1C,0x06,0x03,0x00,0x00,0x01,0x07,0x1C,0x38,0x30,0x20,0x00,/“Èë”,9/0x00,0x00,0x40,0x40,0x40,0x40,0x40,0xFE,0xFE,0x40,0x40,0x40,0x40,0x40,0x00,0x00,
0x00,0x60,0x60,0x60,0x60,0x60,0x60,0x7F,0x7F,0x60,0x60,0x60,0x60,0x60,0x60,0x00,/“ÍÁ”,10/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x38,0x28,0x28,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/".",11/
};/68µÄµãÕó*/
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,

评论 16
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值