《6(100%开源)蓝牙心率防水运动手环_OLED屏幕显示.docx》由会员分享,可在线阅读,更多相关《6(100%开源)蓝牙心率防水运动手环_OLED屏幕显示.docx(8页珍藏版)》请在第一文库网上搜索。
1、蓝牙心率防水运动手环OLED屏幕显示疯壳-智能穿戴开发系列配套资料:https:/www.fengke.club/GeekMart/su_fkZyGYgrp.jsp配套视频:https:/www.fengke.club/GeekMart/su_fTSgUL3y3.jspLed屏幕显示1相关简介本次Led屏幕显示是采用SSD1306o SSD1306是一个单片CMOS OLED/PLED驱动芯片可以驱动有机/聚合发光二级管点阵图形显示系统。有128segments和64commons组成。该芯片专为共阴极OLED面板设计。SSD1306中嵌入了对比度控制器、显示RAM和晶振,并因此减少了外部器件
2、和功耗。有256级亮度控制。数据/命令的发送有三种接口可选择:6800/8000串口,I2C接口或SPI接口。我们本次就是使用软件模拟12c接口控制LCD屏幕。2 硬件设计下图是我们的LCD屏幕的接口,这里使用12c通信,SCL, SDA分别接在P25、P26o图13软件设计关于软件,首先就是要把模拟12c的两个引脚配置成普通输出10 口,GPIO_ConfigurePin(LCD_l2C_PORT, SCL, OUTPUT, PID_GPIO, false);GPIO_ConfigurePin(LCD_l2C_PORT, SDA, OUTPUT, PID_GPIO, false);首先模拟起
3、始信号:当SCL为高电平期间,SDA由高电平跳变到低电平。void IIC_Start()(GPI0_SetActive(LCDJ2C_P0RT,SCL);/SCL = high;/Delay_us(l);GPI0_SetActive(LCD_l2C_P0RT, SDA);/SDA = high;/Delay_us(l);GPI0_Setlnactive(LCDJ2C_P0RL SDA);/SDA = low;/ Delay_us(l);GPI0_Setlnactive(LCD2C_P0RT, SCL);/SCL = low;/ Delay_us(l);然后是停止信号:当SCL为高电平期间,S
4、DA由低电平跳变到高电平。void IIC_Stop()GPI0_Setlnactive(LCD_l2C_P0RT, SCL);/SCL = low;/Delay_us(l);GPIO_Setlnactive(LCD_l2C_PORT, SDA);/SDA = low;/Delay_us(l);GPIO_SetActive(LCD_l2C_PORT, SCL);/SCL = high;/Delay_us(l);GPIO_SetActive(LCD_l2C_PORTz SDA);/SDA = high;/Delay_us(l);)最后就是数据的传送:I2C总线进行数据传送时,时钟信号为高电平期间
5、,数据线上的数据必须保持稳定,只有在时钟线上的信号为低电平期间,数据线上的高电平或低电平状态才允许变化。void Write_IIC_Byte(unsigned charllC_Byte)(unsigned char i;for(i=0;iR广| 11 I职Control byte图2void i2c_eeprom_write_byte_dgh(unsigned char IIC_Control,unsigned char IIC_Command)IIC_Start();上图中的 Slave AddressWrite_IIC_Byte(0x78);Write_IIC_Byte(IIC_Cont
6、rol);D/C#位置0表示写指令,1表示写数据Write_IIC_Byte(IIC_Command); 要写的指令或数据IIC_Stop();)void oledjnit(void)对于LCD,首先是初始化LCDo初始化流程以及指令数据可以数据手册。(int i;i2c_eeprom_write_byte_dgh(0X00, OxAE); /display offi2c_eeprom_write_byte_dgh(0X00, 0x20); /Set Memory Addressing Modei2c_eeprom_write_byte_dgh(0X00, 0x10); /00,Horizon
7、tal Addressing Mode;01,VerticalAddressing Mode;10,Page Addressing Mode (RESET);11,Invalidi2c_eeprom_write_byte_dgh(0X00, OxbO); /Set Page Start Address for Page AddressingMode,0-7i2c_eeprom_write_byte_dgh(0X00, OxcO); /Set COM Output Scan Direction C0/C8i2c_eeprom_write_byte_dgh(0X00, 0x00);i2c_eepr
8、om_write_byte_dgh(0X00, 0xl2);/12i2c_eeprom_write_byte_dgh(0X00, 0x40);i2c_eeprom_write_byte_dgh(0X00, 0x81);i2c_eeprom_write_byte_dgh(0X00, 0x7f);i2c_eeprom_write_byte_dgh(0X00, 0xa0);/ali2c_eeprom_write_byte_dgh(0X00, 0xa6);/a6i2c_eeprom_write_byte_dgh(0X00, 0xa8);i2c_eeprom_write_byte_dgh(0X00, O
9、x3F);/lFi2c_eeprom_write_byte_dgh(0X00, 0xa4);/a4i2c_eeprom_write_byte_dgh(0X00, Oxd3);i2c_eeprom_write_byte_dgh(0X00, 0x00);i2c_eeprom_write_byte_dgh(0X00, 0xd5);i2c_eeprom_write_byte_dgh(0X00, OxfO);i2c_eeprom_write_byte_dgh(0X00, 0xd9);i2c_eeprom_write_byte_dgh(0X00, 0x22);i2c_eeprom_write_byte_d
10、gh(0X00, Oxda);i2c_eeprom_write_byte_dgh(0X00, 0xl2);/02i2c_eeprom_write_byte_dgh(0X00, Oxdb);i2c_eeprom_write_byte_dgh(0X00, 0x20);i2c_eeprom_write_byte_dgh(0X00, 0x8d);i2c_eeprom_write_byte_dgh(0X00, 0x14);i2c_eeprom_write_byte_dgh(0X00, Oxaf);for(i=0;ia99 i- m i: n r ft M9lH440t39M n t: 8 11dl 3t 9a二=三三三三三三三三一t . , | * ww * *0 一. *. w* .!:wc ltl-3-:e5S9 :VIM “ XC K 3 - VAliN. STES2, *W fMB :$ S ):9:CMHW0W$*iWMU eMS firwtev ee VW li?IWQOiMiWI W: MBMey t,2vwcevMfWlr*j:ro .“, CM刈 Ml” MrY,o rEG -m” c