05:OLED模块【MSP430F5529】

这篇具有很好参考价值的文章主要介绍了05:OLED模块【MSP430F5529】。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

目录

实物图

字模取字

        字模软件

        取模步骤

        1.设置软件

        2.取模

        3.输出数据

 代码

type.h

oledfont.h

oled.h

oled.c

main.c


实物图

下面图片中,可以看到OLED模块的四个接口:GND,VCC,SCL,SDA

GND VCC SCL SDA
接地 接电源3.3V/5V 接P3.5 接P3.6

msp430f5529怎么接oled,MSP430f5529,c语言,单片机,嵌入式msp430f5529怎么接oled,MSP430f5529,c语言,单片机,嵌入式

字模取字

        字模软件

        PCtoLCD2002,直接百度搜索软件进行下载。

        或者链接:【免费】PCtoLCD2002.zip(免费下载)资源-CSDN文库

        取模步骤

        1.设置软件

        点“设置

msp430f5529怎么接oled,MSP430f5529,c语言,单片机,嵌入式

                 点阵格式:阴码(根据高电平或者低电平有效判断)

                取模方式:列行式

                每行显示数:16、16

                取模走向:逆向

                输出数制:十六位进制数

                自定义格式:C51

                像素大小:10

                可参考下列图片进行设置

msp430f5529怎么接oled,MSP430f5529,c语言,单片机,嵌入式

        2.取模

        点击“文件”,再点击“新建”,设置新建图像尺寸16*16,再点“确定”,然后会出现一个第二张图片的这个东西,再到上面画你想显示的字符或者图案了(只有一个字的大小的图案)。点鼠标左键为放置(这个点位亮起来),右键为取消。

msp430f5529怎么接oled,MSP430f5529,c语言,单片机,嵌入式msp430f5529怎么接oled,MSP430f5529,c语言,单片机,嵌入式msp430f5529怎么接oled,MSP430f5529,c语言,单片机,嵌入式

        3.输出数据

        绘制结束后,点击“生成字模”,然后复制粘贴到数组 LHR[][32] 中去就可以了

msp430f5529怎么接oled,MSP430f5529,c语言,单片机,嵌入式

 代码

type.h

        首先是定义u8,u16,u32,方便后面代码的书写

#ifndef TYPE_H_
#define TYPE_H_
#define u32 unsigned int
#define u16 unsigned short
#define u8 unsigned char

#endif

oledfont.h

#ifndef OLEDFONT_H_
#define OLEDFONT_H_


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
};

//8*16 dot matrix
const unsigned char F8X16[]=
{
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//
    0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x30,0x00,0x00,0x00,//!
    0x00,0x10,0x0C,0x06,0x10,0x0C,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//"
    0x40,0xC0,0x78,0x40,0xC0,0x78,0x40,0x00,0x04,0x3F,0x04,0x04,0x3F,0x04,0x04,0x00,//#
    0x00,0x70,0x88,0xFC,0x08,0x30,0x00,0x00,0x00,0x18,0x20,0xFF,0x21,0x1E,0x00,0x00,//$
    0xF0,0x08,0xF0,0x00,0xE0,0x18,0x00,0x00,0x00,0x21,0x1C,0x03,0x1E,0x21,0x1E,0x00,//%
    0x00,0xF0,0x08,0x88,0x70,0x00,0x00,0x00,0x1E,0x21,0x23,0x24,0x19,0x27,0x21,0x10,//&
    0x10,0x16,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//'
    0x00,0x00,0x00,0xE0,0x18,0x04,0x02,0x00,0x00,0x00,0x00,0x07,0x18,0x20,0x40,0x00,//(
    0x00,0x02,0x04,0x18,0xE0,0x00,0x00,0x00,0x00,0x40,0x20,0x18,0x07,0x00,0x00,0x00,//)
    0x40,0x40,0x80,0xF0,0x80,0x40,0x40,0x00,0x02,0x02,0x01,0x0F,0x01,0x02,0x02,0x00,//*
    0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x1F,0x01,0x01,0x01,0x00,//+
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xB0,0x70,0x00,0x00,0x00,0x00,0x00,//,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,//-
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00,//.
    0x00,0x00,0x00,0x00,0x80,0x60,0x18,0x04,0x00,0x60,0x18,0x06,0x01,0x00,0x00,0x00,/// 
    0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,//0 
    0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//1 
    0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,//2 
    0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00,//3
    0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,//4 
    0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00,//5 
    0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00,//6
    0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,//7 
    0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,//8 
    0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00,//9 
    0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,//: 
    0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x60,0x00,0x00,0x00,0x00,//; 
    0x00,0x00,0x80,0x40,0x20,0x10,0x08,0x00,0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x00,//< 
    0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00,//= 
    0x00,0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x00,0x20,0x10,0x08,0x04,0x02,0x01,0x00,//> 
    0x00,0x70,0x48,0x08,0x08,0x08,0xF0,0x00,0x00,0x00,0x00,0x30,0x36,0x01,0x00,0x00,//? 
    0xC0,0x30,0xC8,0x28,0xE8,0x10,0xE0,0x00,0x07,0x18,0x27,0x24,0x23,0x14,0x0B,0x00,//@ 
    0x00,0x00,0xC0,0x38,0xE0,0x00,0x00,0x00,0x20,0x3C,0x23,0x02,0x02,0x27,0x38,0x20,//A 
    0x08,0xF8,0x88,0x88,0x88,0x70,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x11,0x0E,0x00,//B 
    0xC0,0x30,0x08,0x08,0x08,0x08,0x38,0x00,0x07,0x18,0x20,0x20,0x20,0x10,0x08,0x00,//C 
    0x08,0xF8,0x08,0x08,0x08,0x10,0xE0,0x00,0x20,0x3F,0x20,0x20,0x20,0x10,0x0F,0x00,//D 
    0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x20,0x23,0x20,0x18,0x00,//E 
    0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x00,0x03,0x00,0x00,0x00,//F 
    0xC0,0x30,0x08,0x08,0x08,0x38,0x00,0x00,0x07,0x18,0x20,0x20,0x22,0x1E,0x02,0x00,//G 
    0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x20,0x3F,0x21,0x01,0x01,0x21,0x3F,0x20,//H 
    0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//I 
    0x00,0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,0x00,//J 
    0x08,0xF8,0x88,0xC0,0x28,0x18,0x08,0x00,0x20,0x3F,0x20,0x01,0x26,0x38,0x20,0x00,//K 
    0x08,0xF8,0x08,0x00,0x00,0x00,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x20,0x30,0x00,//L 
    0x08,0xF8,0xF8,0x00,0xF8,0xF8,0x08,0x00,0x20,0x3F,0x00,0x3F,0x00,0x3F,0x20,0x00,//M 
    0x08,0xF8,0x30,0xC0,0x00,0x08,0xF8,0x08,0x20,0x3F,0x20,0x00,0x07,0x18,0x3F,0x00,//N 
    0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x10,0x20,0x20,0x20,0x10,0x0F,0x00,//O 
    0x08,0xF8,0x08,0x08,0x08,0x08,0xF0,0x00,0x20,0x3F,0x21,0x01,0x01,0x01,0x00,0x00,//P 
    0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x18,0x24,0x24,0x38,0x50,0x4F,0x00,//Q 
    0x08,0xF8,0x88,0x88,0x88,0x88,0x70,0x00,0x20,0x3F,0x20,0x00,0x03,0x0C,0x30,0x20,//R 
    0x00,0x70,0x88,0x08,0x08,0x08,0x38,0x00,0x00,0x38,0x20,0x21,0x21,0x22,0x1C,0x00,//S
    0x18,0x08,0x08,0xF8,0x08,0x08,0x18,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,//T 
    0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,//U 
    0x08,0x78,0x88,0x00,0x00,0xC8,0x38,0x08,0x00,0x00,0x07,0x38,0x0E,0x01,0x00,0x00,//V 
    0xF8,0x08,0x00,0xF8,0x00,0x08,0xF8,0x00,0x03,0x3C,0x07,0x00,0x07,0x3C,0x03,0x00,//W 
    0x08,0x18,0x68,0x80,0x80,0x68,0x18,0x08,0x20,0x30,0x2C,0x03,0x03,0x2C,0x30,0x20,//X 
    0x08,0x38,0xC8,0x00,0xC8,0x38,0x08,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,//Y 
    0x10,0x08,0x08,0x08,0xC8,0x38,0x08,0x00,0x20,0x38,0x26,0x21,0x20,0x20,0x18,0x00,//Z 
    0x00,0x00,0x00,0xFE,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x7F,0x40,0x40,0x40,0x00,//[ 
    0x00,0x0C,0x30,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x06,0x38,0xC0,0x00,//\ 
    0x00,0x02,0x02,0x02,0xFE,0x00,0x00,0x00,0x00,0x40,0x40,0x40,0x7F,0x00,0x00,0x00,//] 
    0x00,0x00,0x04,0x02,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//^ 
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,//_ 
    0x00,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//` 
    0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x19,0x24,0x22,0x22,0x22,0x3F,0x20,//a 
    0x08,0xF8,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x3F,0x11,0x20,0x20,0x11,0x0E,0x00,//b 
    0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x0E,0x11,0x20,0x20,0x20,0x11,0x00,//c 
    0x00,0x00,0x00,0x80,0x80,0x88,0xF8,0x00,0x00,0x0E,0x11,0x20,0x20,0x10,0x3F,0x20,//d 
    0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x22,0x22,0x22,0x22,0x13,0x00,//e 
    0x00,0x80,0x80,0xF0,0x88,0x88,0x88,0x18,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//f 
    0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x6B,0x94,0x94,0x94,0x93,0x60,0x00,//g 
    0x08,0xF8,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,//h 
    0x00,0x80,0x98,0x98,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//i 
    0x00,0x00,0x00,0x80,0x98,0x98,0x00,0x00,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,//j 
    0x08,0xF8,0x00,0x00,0x80,0x80,0x80,0x00,0x20,0x3F,0x24,0x02,0x2D,0x30,0x20,0x00,//k 
    0x00,0x08,0x08,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//l 
    0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x20,0x3F,0x20,0x00,0x3F,0x20,0x00,0x3F,//m 
    0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,//n 
    0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,//o 
    0x80,0x80,0x00,0x80,0x80,0x00,0x00,0x00,0x80,0xFF,0xA1,0x20,0x20,0x11,0x0E,0x00,//p 
    0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x0E,0x11,0x20,0x20,0xA0,0xFF,0x80,//q 
    0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x20,0x20,0x3F,0x21,0x20,0x00,0x01,0x00,//r 
    0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x33,0x24,0x24,0x24,0x24,0x19,0x00,//s 
    0x00,0x80,0x80,0xE0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x1F,0x20,0x20,0x00,0x00,//t 
    0x80,0x80,0x00,0x00,0x00,0x80,0x80,0x00,0x00,0x1F,0x20,0x20,0x20,0x10,0x3F,0x20,//u 
    0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x00,0x01,0x0E,0x30,0x08,0x06,0x01,0x00,//v 
    0x80,0x80,0x00,0x80,0x00,0x80,0x80,0x80,0x0F,0x30,0x0C,0x03,0x0C,0x30,0x0F,0x00,//w 
    0x00,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x31,0x2E,0x0E,0x31,0x20,0x00,//x 
    0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x80,0x81,0x8E,0x70,0x18,0x06,0x01,0x00,//y 
    0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x21,0x30,0x2C,0x22,0x21,0x30,0x00,//z 
    0x00,0x00,0x00,0x00,0x80,0x7C,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x3F,0x40,0x40,//{ 
    0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,//| 
    0x00,0x02,0x02,0x7C,0x80,0x00,0x00,0x00,0x00,0x40,0x40,0x3F,0x00,0x00,0x00,0x00,//} 
    0x00,0x06,0x01,0x01,0x02,0x02,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//~ 
};

/*中文字符*/
char LHR[][32]=
{
     //电
    {0x00,0x00,0xF0,0x90,0x90,0x90,0xFE,0x90,0x90,0x90,0xF0,0x00,0x00,0x00,0x00,0x00},
    {0x00,0x00,0x07,0x04,0x04,0x04,0x3F,0x44,0x44,0x44,0x47,0x40,0x38,0x00,0x00,0x00},

    //子
    {0x00,0x00,0x00,0x40,0x44,0x44,0x44,0x44,0xE4,0x54,0x4C,0x40,0x40,0x00,0x00,0x00},
    {0x00,0x00,0x00,0x00,0x00,0x18,0x30,0x20,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00},

    //创
    {0x00,0x20,0xD0,0x48,0x44,0x42,0x44,0xC8,0x10,0x20,0x00,0xF0,0x00,0xFE,0x00,0x00},
    {0x00,0x00,0x3F,0x20,0x26,0x24,0x24,0x27,0x20,0x3C,0x00,0x13,0x20,0x3F,0x00,0x00},

    //新
    {0x00,0x00,0x88,0x98,0xA8,0xCC,0xA8,0x98,0x88,0x00,0xF8,0x48,0x48,0xC8,0x48,0x00},
    {0x00,0x00,0x12,0x2A,0x46,0x7F,0x06,0x0A,0x12,0x00,0x3F,0x00,0x00,0x7F,0x00,0x00},

    //协
    {0x00,0x20,0x20,0xFC,0x20,0x20,0x80,0x20,0xE0,0x3C,0x20,0xE0,0x00,0x80,0x00,0x00},
    {0x00,0x00,0x00,0x3F,0x00,0x03,0x00,0x3E,0x03,0x10,0x20,0x3F,0x00,0x03,0x00,0x00},

    //会
    {0x00,0x00,0x80,0x40,0x20,0x90,0x88,0x84,0x86,0x88,0x90,0x20,0x40,0x80,0x00,0x00},
    {0x00,0x00,0x04,0x24,0x34,0x2C,0x24,0x24,0x24,0x24,0x34,0x24,0x44,0x00,0x00,0x00},
};
#endif

oled.h

#ifndef __OLED_H
#define __OLED_H

#include <msp430.h>
#include "type.h"

#define OLED_MODE 0
#define SIZE 8
#define XLevelL     0x00
#define XLevelH     0x10
#define Max_Column  128
#define Max_Row     64
#define Brightness  0xFF
#define X_WIDTH     128
#define Y_WIDTH     64

#define OLED_SCLK_Clr() P3OUT &= ~BIT5  //CLK
#define OLED_SCLK_Set() P3OUT |= BIT5

#define OLED_SDIN_Clr() P3OUT &= ~BIT6  //DIN
#define OLED_SDIN_Set() P3OUT |= BIT6

#define OLED_CMD  0
#define OLED_DATA 1

void OLED_WR_Byte(unsigned dat,unsigned cmd);
void OLED_Display_On(void);
void OLED_Display_Off(void);
void OLED_Init(void);
void OLED_Clear(void);
void OLED_DrawPoint(u8 x,u8 y,u8 t);
void OLED_Fill(u8 x1,u8 y1,u8 x2,u8 y2,u8 dot);
void OLED_ShowCHinese(u8 x,u8 y,u8 no);
void OLED_DrawBMP(unsigned char x0, unsigned char y0,unsigned char x1, unsigned char y1,unsigned char BMP[]);
void OLED_ShowChar(u8 x,u8 y,u8 chr,u8 Char_Size);
void OLED_ShowNum(u8 x,u8 y,u32 num,u8 len,u8 size);
void OLED_ShowVI(u8 x,u8 y,u32 num,u8 size);
void OLED_ShowString(u8 x,u8 y, u8 *p,u8 Char_Size);
void OLED_Set_Pos(unsigned char x, unsigned char y);
void Delay_1ms(unsigned int Del_1ms);
void fill_picture(unsigned char fill_Data);
void Picture();
void IIC_Start();
void IIC_Stop();
void Write_IIC_Command(unsigned char IIC_Command);
void Write_IIC_Data(unsigned char IIC_Data);
void Write_IIC_Byte(unsigned char IIC_Byte);
void IIC_Wait_Ack();

#endif

oled.c

#include "oled.h"
#include "oledfont.h"
#include "type.h"

//IIC启动
void IIC_Start()
{

    OLED_SCLK_Set();
    OLED_SDIN_Set();
    OLED_SDIN_Clr();
    OLED_SCLK_Clr();
}

//IIC停止
void IIC_Stop()
{
    OLED_SCLK_Set() ;
//  OLED_SCLK_Clr();
    OLED_SDIN_Clr();
    OLED_SDIN_Set();

}

void IIC_Wait_Ack()
{
    OLED_SCLK_Set() ;   //P3OUT|=BIT5
    OLED_SCLK_Clr();    //P3OUT&=~BIT5
}

// IIC Write byte
//IIC写入字节
void Write_IIC_Byte(unsigned char IIC_Byte)
{
    unsigned char i;
    unsigned char m,da;

    da=IIC_Byte;
    OLED_SCLK_Clr();    //P3OUT &= ~BIT5

    for(i=0;i<8;i++)
    {
        m=da;
        //  OLED_SCLK_Clr();
        m=m&0x80;
        if(m==0x80)
        {
            OLED_SDIN_Set();    //P3OUT |= BIT6
        }
        else OLED_SDIN_Clr();   //P3OUT &= ~BIT6
            da=da<<1;

        OLED_SCLK_Set();    //P3OUT |= BIT5
        OLED_SCLK_Clr();    P3OUT &= ~BIT5
    }
}

// IIC Write Command
void Write_IIC_Command(unsigned char IIC_Command)
{
   IIC_Start();
   Write_IIC_Byte(0x78);            //Slave address,SA0=0
    IIC_Wait_Ack();
   Write_IIC_Byte(0x00);            //write command
    IIC_Wait_Ack();
   Write_IIC_Byte(IIC_Command);
    IIC_Wait_Ack();
   IIC_Stop();
}

// IIC Write Data
void Write_IIC_Data(unsigned char IIC_Data)
{
    IIC_Start();
    Write_IIC_Byte(0x78);            //D/C#=0; R/W#=0
    IIC_Wait_Ack();
    Write_IIC_Byte(0x40);            //write data
    IIC_Wait_Ack();
    Write_IIC_Byte(IIC_Data);
    IIC_Wait_Ack();
    IIC_Stop();
}

//OLED写入字节
void OLED_WR_Byte(unsigned dat,unsigned cmd)
{
    if(cmd)
        Write_IIC_Data(dat);        //IIC,  数据
    else
        Write_IIC_Command(dat);     //IIC,命令
}

//填充图片
void fill_picture(unsigned char fill_Data)
{
    unsigned char m,n;
    for(m=0;m<8;m++)
    {
        OLED_WR_Byte(0xb0+m,0);     //page0-page1
        OLED_WR_Byte(0x00,0);       //low column start address,低八位
        OLED_WR_Byte(0x10,0);       //high column start address,高八位

        for(n=0;n<128;n++)
            OLED_WR_Byte(fill_Data,1);
    }
}

// 延时,单位:ms
void Delay_1ms(unsigned int Del_1ms)
{
    unsigned char j;
    while(Del_1ms--)
    {
        for(j=0;j<123;j++);
    }
}

//OLED设置位置
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显示开启
void OLED_Display_On(void)
{
    OLED_WR_Byte(0X8D,OLED_CMD);
    OLED_WR_Byte(0X14,OLED_CMD);  //DCDC ON
    OLED_WR_Byte(0XAF,OLED_CMD);  //DISPLAY ON
}

// OLED显示关闭
void OLED_Display_Off(void)
{
    OLED_WR_Byte(0X8D,OLED_CMD);
    OLED_WR_Byte(0X10,OLED_CMD);  //DCDC OFF
    OLED_WR_Byte(0XAE,OLED_CMD);  //DISPLAY OFF
}

// OLED清屏
void OLED_Clear(void)
{
    u8 i,n;
    for(i=0;i<8;i++)    //y = 8 清屏y轴的8行
    {
        OLED_WR_Byte (0xb0+i,OLED_CMD); //0111 0000 + i ,选中清屏的行
        OLED_WR_Byte (0x00,OLED_CMD);
        OLED_WR_Byte (0x10,OLED_CMD);   //0001 0000
        for(n=0;n<128;n++)              //x = 128 清屏x轴的128列
            OLED_WR_Byte(0,OLED_DATA);
    }
}

//OLED开启
void OLED_On(void)
{
    u8 i,n;
    for(i=0;i<8;i++)
    {
        OLED_WR_Byte (0xb0+i,OLED_CMD);
        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
显示字符
OLED_ShowChar(0,0,'D',20);//只能显示单个字符
*/
void OLED_ShowChar(u8 x,u8 y,u8 chr,u8 Char_Size)
{
    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);
        for(i = 0; i < 8; i++)
        OLED_WR_Byte( F8X16[c*16+i], OLED_DATA);
        OLED_Set_Pos(x,y+1);
        OLED_WR_Byte( F8X16[c*16+i+8], OLED_DATA);
    }

    else
    {
        OLED_Set_Pos(x,y);
        for(i = 0; i < 6; i++)
            OLED_WR_Byte(F6x8[c][i], OLED_DATA);
    }
}

/*
 * 求m的n次方
 * result = m * m * m * m....
 */
u32 oled_pow(u8 m,u8 n)
{
    u32 result = 1;
    while(n--) result *= m;
    return result;
}

/*
显示数字
x:行    y:列    num:要显示的数字    len:数字位数    size2:每一个数字的间隔
OLED_ShowNum(0,1,1234,4,8);
num的数字可以定义为变量,例:OLED_ShowNum(0,1,date,4,8);
*/
void OLED_ShowNum(u8 x,u8 y,u32 num,u8 len,u8 size2)
{
    u8 t,temp;
    u8 enshow = 0;
    for(t = 0; t < len; t++)
    {
        temp=(num/oled_pow(10,len-t-1))%10;
        if(enshow==0&&t<(len-1))
        {
            if(temp==0)
            {
                OLED_ShowChar(x+size2*t,y,' ',size2);
                continue;
            }
            else
                enshow=1;
        }
        OLED_ShowChar(x+size2*t,y,temp+'0',size2);
    }
}

//根据具体使用情况修改
void OLED_ShowVI(u8 x,u8 y,u32 num,u8 size2)
{
    OLED_ShowNum( x+size2*4-1, y, num%10, 1, size2);
    OLED_ShowNum( x+size2*3-1, y, num/10%10, 1, size2);
    OLED_ShowNum( x+size2*2-1, y, num/100%10, 1, size2);
    OLED_ShowString( x+size2*1-1, y, ".", size2);
    OLED_ShowNum( x-1,y, num/1000, 1, size2);
}

//显示字符串
//OLED_ShowString(0,4,"DZCXXH",8);
void OLED_ShowString(u8 x,u8 y,u8 *chr,u8 Char_Size)
{
    unsigned char j=0;
    while (chr[j]!='\0')
    {
        OLED_ShowChar(x,y,chr[j],Char_Size);
        x+=8;
        if(x>120)
        {
            x=0;
            y+=2;
        }
        j++;
    }
}

//显示汉字
//使用:OLED_ShowCHinese(0,4,0);    //"电"
//x:行    y:列    no:数组中第几个汉字
void OLED_ShowCHinese(u8 x,u8 y,u8 no)
{
    u8 t,adder=0;
    OLED_Set_Pos(x,y);
    for(t=0;t<16;t++)
    {
        OLED_WR_Byte(LHR[2*no][t],OLED_DATA);
        adder+=1;
    }
    OLED_Set_Pos(x,y+1);
    for(t=0;t<16;t++)
    {
        OLED_WR_Byte(LHR[2*no+1][t],OLED_DATA);
        adder+=1;
      }
}

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;
    else
        y=y1%8+1;

    for(y=y0;y<y1;y++)
    {
        OLED_Set_Pos(x0,y);
        for(x=x0;x<x1;x++)
        {
            OLED_WR_Byte(BMP[j++],OLED_DATA);
        }
    }
}

//OLED初始化模块
void OLED_Init(void)
{
    //若使用其他端口,这里要修改为对应端口
    P3DIR |= BIT5+BIT6;             //设置为输出

    OLED_WR_Byte(0xAE,OLED_CMD);    //显示关闭
    OLED_WR_Byte(0x00,OLED_CMD);    //设置低列地址
    OLED_WR_Byte(0x10,OLED_CMD);    //设置高位列地址
    OLED_WR_Byte(0x40,OLED_CMD);    //设置起始行地址
    OLED_WR_Byte(0xB0,OLED_CMD);    //设置页面地址
    OLED_WR_Byte(0x81,OLED_CMD);    //联合控制
    OLED_WR_Byte(0xFF,OLED_CMD);    //128
    OLED_WR_Byte(0xA1,OLED_CMD);    //设置段重映射
    OLED_WR_Byte(0xA6,OLED_CMD);    //--normal / reverse
    OLED_WR_Byte(0xA8,OLED_CMD);    //--set multiplex ratio(1 to 64)
    OLED_WR_Byte(0x3F,OLED_CMD);    //--1/32 duty
    OLED_WR_Byte(0xC8,OLED_CMD);    //Com scan direction
    OLED_WR_Byte(0xD3,OLED_CMD);    //-set display offset
    OLED_WR_Byte(0x00,OLED_CMD);    

    OLED_WR_Byte(0xD5,OLED_CMD);    //set osc division
    OLED_WR_Byte(0x80,OLED_CMD);

    OLED_WR_Byte(0xD8,OLED_CMD);    //set area color mode off
    OLED_WR_Byte(0x05,OLED_CMD);

    OLED_WR_Byte(0xD9,OLED_CMD);    //Set Pre-Charge Period
    OLED_WR_Byte(0xF1,OLED_CMD);

    OLED_WR_Byte(0xDA,OLED_CMD);    //set com pin configuartion
    OLED_WR_Byte(0x12,OLED_CMD);

    OLED_WR_Byte(0xDB,OLED_CMD);    //set Vcomh
    OLED_WR_Byte(0x30,OLED_CMD);

    OLED_WR_Byte(0x8D,OLED_CMD);    //set charge pump enable
    OLED_WR_Byte(0x14,OLED_CMD);

    OLED_WR_Byte(0xAF,OLED_CMD);    //打开oled面板
}


SCL对应CLK,SDA对应DIN

若想将SCL连接到板子的P4.1,只要将下面代码中的 P3OUT &= ~BIT5 改为 P4OUT &= ~BIT1 的答复,P3OUT |= BIT5 改为 P4OUT |= BIT1 便可。SDA同上。

msp430f5529怎么接oled,MSP430f5529,c语言,单片机,嵌入式

oled.c里面的这个也要修改

msp430f5529怎么接oled,MSP430f5529,c语言,单片机,嵌入式

main.c

/*
 * MSP430f5529REV  OLED
 * VCC ——> 5V
 * SDA ——> P3.6
 * SCL ——> P3.5
 */
#include <msp430.h>
#include "oled.h"
#include "type.h"

void main(void)
{
    WDTCTL = WDTPW + WDTHOLD;

    OLED_Init();
    OLED_Clear();

    int inputModel = 0;

    while(1)
    {
        OLED_ShowChar(0,0,'X',40);
        OLED_ShowString(20,1,"ABC456",8);

        OLED_ShowNum(40,2,1234,4,8);

        OLED_ShowNum(60,3,inputModel,4,8);
        inputModel++;

        OLED_ShowCHinese(0,6,0);        //电
        OLED_ShowCHinese(20,6,1);       //子
        OLED_ShowCHinese(40,6,2);       //创
        OLED_ShowCHinese(60,6,3);       //新
        OLED_ShowCHinese(80,6,4);       //协
        OLED_ShowCHinese(100,6,5);      //会
    }
}

现象如图:

msp430f5529怎么接oled,MSP430f5529,c语言,单片机,嵌入式

OLED_ShowChar(0,0,'X',40);//对应参数(第一个字符起始位子,行数,显示的字符串,。。。)

源代码参考修改来自于:

msp430f5529——OLED屏显示文字与图片_lhooer的博客-CSDN博客文章来源地址https://www.toymoban.com/news/detail-595910.html

到了这里,关于05:OLED模块【MSP430F5529】的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • MSP430F5529学习笔记

    该MCU是由德州仪器TI生产的16位低功耗单片机 主要分以下型号: 专注低功耗的 1xx 通用型,配备1KB-60KB FLASH、512B-10KB RAM,工作时耗电仅达200uA/MIPS,RAM保持模式耗电0.1uA,RTC模式耗电0.7uA;可在6us之内快速唤醒。搭载10/12位斜率SAR ADC,集成模拟比较器、DMA、硬件乘法器、BOR、SV

    2024年02月15日
    浏览(118)
  • MSP430F5529——中断理解

    认识低功耗模式; MSP430的中断,需要两个部分,一部分是打开中断,另外一部分是编写中断服务函数 首先我们得知道__bis_SR_register和_BIS_SR是一个玩意。查看宏定义可知  _BIS_SR()可传入的参数 然后我们查看x的值,发现里面有八个可以传入的值 我们这里只需要关系GIE就可以

    2024年02月16日
    浏览(54)
  • MSP430F5529库函数学习——串口

    波特率计算网站;导入MSP430Ware,查看例程;原理图和中文开发手册获取 目录 GPIO_setAsPeripheralModuleFunctionInputPin()和GPIO_setAsPeripheralModuleFunctionOutputPin 函数声明  作用 参数 selectedPort selectedPins 使用 USCI_A_UART_init() 函数声明  作用 参数 baseAddress param  USCI_A_UART_enable() 函数

    2024年02月16日
    浏览(68)
  • msp430f5529学习笔记(2)时钟系统

    写在前~本章将会详细的讲解msp430f5529单片机的时钟系统及其使用方法。如有不妥的地方欢迎各位大佬斧正!!! 目录 什么是时钟系统和时钟源 MSP430f5529时钟源和时钟系统介绍 产生时钟信号的时钟源: 时钟配置        在单片机中,单片机每开始一个周期的工作就需要一个节

    2024年02月17日
    浏览(46)
  • MSP430F5529库函数GPIO学习

    导入MSP430Ware,查看例程;数据手册以及原理图获取 建议不是很了解寄存器的看完我的MSP430F5529学习笔记  目录 GPIO_setAsOutputPin() 函数声明 作用 参数 selectedPort selectedPins 修改的寄存器 使用 与GPIO_setAsOutputPin()参数一致的函数  GPIO_setOutputHighOnPin() GPIO_setOutputLowOnPin()

    2024年02月15日
    浏览(67)
  • 06:PWM与电机驱动【MSP430F5529】

    电机型号: 工作方式: 原理图以及接线: 根据官方例程,主要代码为drive.c drive.h main.c (后面好像使用的时候会有什么冲突导致1或者2通道无法正常运行,不太记得了,可以到实物上实验一下子) 下面是智能送药小车使用PWM驱动电机相关代码与注释(在实物中,均能正常运行)

    2024年02月15日
    浏览(49)
  • MSP430F5529学习笔记(五)——串口|UART

            我们在使用MSP430的时候大家会发现插上usb线后电脑上有两个端口标识,那么在进行串口通信时选择哪个呢。其实如图所示,上面的端口是用来进行串口通信的,下面的则是用来进行程序的下载,大家在使用的时候多加分辨即可。          当然熟悉单片机操作的

    2024年02月16日
    浏览(47)
  • MSP430F5529学习笔记(6)——导入MSP430Ware,查看例程

    MSP430WARE下载; 目录 在线版本 下载MSP430Ware 查看例程 导入例程  离线版本 下载MSP430Ware  查看例程 导入例程 MSP430Ware里面有很多例程和库函数使用手册,我们可以查看学习。非常重要 (1) 打开CCS——view——Resource Explorer  之后我们会进入如下界面 (2)  点击MSP430——Embe

    2024年02月13日
    浏览(54)
  • 【2023电赛备赛】msp430f5529学习笔记(一)

    【写在前】 本人目前是大二在读生,第一次参加电赛,准备不充分,结果熬了四天,最后成绩却不如人意。有51和32的基础,然后想立一个flag系统的学习一下主打超低功耗的msp430f5529单片机为比赛做准备(毕竟电赛限制TI的板子)。另一方面也是给电协的后继者留下一些参考的

    2024年02月11日
    浏览(47)
  • MSP430F5529单片机入门学习笔记1

    本笔记整理自B站教程 MSP430F5529单片机学习视频汇总 右边部分写错了,看的时候注意 注意#include“driverlib.h”头文件时要注意: 添加MSP430F5xx_6xx文件夹到当前工程下 MSP430F5xx_6xx文件夹是在导入的msp430ware_3_80_13_03包中找 把上述MSP430F5xx_6xx文件夹的路径包含进来 有三个系统时钟可

    2024年02月06日
    浏览(47)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包