前言
随着智能化的发展,“智慧”一词常映入我们的眼帘,目前我们的生活中很多会运用嵌入式技术,将实现功能的程序写入单片机中,因环境的改变通过单片机控制做出相应的动作,在本项目中主要实现智慧农业的实现,主要使用STM32进行开发。
提示:以下是本篇文章正文内容,下面案例可供参考
一、项目介绍
智慧农业实现的功能是首先进入开机界面,界面展现的是一个取模后的开机动画,及欢迎文字,经过一定的时间后,变成主界面,再通过按键中断控制切换成数据采集界面,采集对应的农业环境的光照、温度、湿度的数据,当采集的数值超过阈值后会进行蜂鸣器的响应等,在查看完数据后可通过按键中断进入关机的程序,跳入关机界面。
二、项目技术
OLED屏显、IIC协议、USART协议、中断、取模、DHT11温湿度采集、ADC光照采集、stm32f407vet6开发板等
三、项目代码及实现结果
1.项目代码
oled.c (oled数据文字显示,及取模软件取模后的调用)#include "oled.h" //oled操作函数文件
#include "iic_at24c02.h"
u8 OLED_GRAM[144][8];
//char humi = 0;
//char temp = 0;
//======================================================
// 128X64I液晶底层驱动[8X16]字体库
// 设计者: powerint
// 描 述: [8X16]西文字符的字模数据 (纵向取模,字节倒序)
// !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
//======================================================
int hour;
int min;
int sec;
char secstr[4];
char minstr[4];
char hourstr[4];
unsigned char **[]=
{
0x00,0x00,0x00,0x00,0x20,0x40,0x80,0xB8,0xF8,0xB8,0x80,0x40,0x20,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x40,0x20,0x10,0x0F,0x10,0x20,0x40,0x00,0x00,0x00,0x00
};
unsigned char **1[]=
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,
0x80,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,0x02,0x04,0x08,0x8B,0x7F,
0x8B,0x08,0x04,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x01,0x00,0x00,
0x01,0x02,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,0x00,0x00};
unsigned char **2[]=
{0xFE,0xF8,0x00,0x06,0x3E,0xFC,0xFC,0x38,0x30,0x60,0xE0,0xC0,0xC0,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x40,0x60,0x30,0x38,0xFC,0xFC,0x7C,
0xDF,0x9F,0xBC,0xFC,0xFE,0xFE,0x11,0x1F,0x40,0xE0,0xF1,0xE3,0x43,0x03,0x03,0x03,
0x06,0x86,0xCE,0xCC,0x8C,0x06,0xE7,0xF3,0x31,0x18,0x0C,0x06,0x03,0x01,0x00,0x00,
0x0F,0x1F,0x1C,0x38,0xF0,0xE3,0x40,0x46,0x86,0x80,0x01,0x38,0xF8,0x78,0x39,0x13,
0x00,0x01,0x33,0x7B,0xB1,0xC0,0xCE,0xC7,0xC4,0x6C,0x3C,0x1C,0x0C,0x04,0x00,0x00,
0x00,0x00,0x40,0x78,0x7F,0x3F,0x1E,0x18,0x38,0x30,0x30,0x20,0x60,0x60,0x60,0x21,
0x31,0x71,0xF9,0xFD,0xEF,0xC3,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
unsigned char **3[]=
{0x00,0x00,0x00,0x00,0x00,0xC0,0xF0,0x38,0x1C,0x8C,0xE6,0xFE,0x9F,0x4F,0xDF,0xF9,
0xFB,0xCF,0x8F,0xDF,0xFE,0xC6,0xCC,0xBC,0x78,0xE0,0x80,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x80,0xBF,0xFB,0xFE,0xEF,0x81,0x20,0x61,0xE1,0xC1,0xC7,0xFF,
0xFF,0xC3,0xC1,0xE1,0x60,0x20,0x83,0xFF,0xFE,0xF3,0x3F,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x0E,0x1F,0x19,0x3B,0x3F,0x67,0xEF,0xFF,0xFB,0xEA,0xCA,0xCA,0xDE,0xDE,
0xDE,0xDE,0xCE,0xCF,0xEF,0xFF,0xFF,0xEF,0x7F,0x3F,0x19,0x1B,0x1F,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0xFF,0xFF,0xF3,0xF7,0xEF,0xEF,0xFE,0xFE,
0xFC,0xFE,0xEF,0xEF,0xE7,0xF1,0xFF,0xFF,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
unsigned char **4[]=
{0x00,0x00,0x00,0x00,0x00,0xC0,0xF0,0x38,0x1C,0x8C,0xE6,0xFE,0x9F,0x4F,0xDF,0xF9,
0xFB,0xCF,0x8F,0xDF,0xFE,0xC6,0xCC,0xBC,0x78,0xE0,0x80,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x80,0xBF,0xFB,0xFE,0xEF,0x81,0x20,0x61,0xE1,0xC1,0xC7,0xFF,
0xFF,0xC3,0xC1,0xE1,0x60,0x20,0x83,0xFF,0xFE,0xF3,0x3F,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x0E,0x1F,0x19,0x3B,0x3F,0x67,0xEF,0xFF,0xFB,0xEA,0xCA,0xCA,0xDE,0xDE,
0xDE,0xDE,0xCE,0xCF,0xEF,0xFF,0xFF,0xEF,0x7F,0x3F,0x19,0x1B,0x1F,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0xFF,0xFF,0xF3,0xF7,0xEF,0xEF,0xFE,0xFE,
0xFC,0xFE,0xEF,0xEF,0xE7,0xF1,0xFF,0xFF,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
const unsigned char F8X16[]=
{
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0
0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x30,0x00,0x00,0x00,//!1
0x00,0x10,0x0C,0x06,0x10,0x0C,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//"2
0x40,0xC0,0x78,0x40,0xC0,0x78,0x40,0x00,0x04,0x3F,0x04,0x04,0x3F,0x04,0x04,0x00,//#3
0x00,0x70,0x88,0xFC,0x08,0x30,0x00,0x00,0x00,0x18,0x20,0xFF,0x21,0x1E,0x00,0x00,//$4
0xF0,0x08,0xF0,0x00,0xE0,0x18,0x00,0x00,0x00,0x21,0x1C,0x03,0x1E,0x21,0x1E,0x00,//%5
0x00,0xF0,0x08,0x88,0x70,0x00,0x00,0x00,0x1E,0x21,0x23,0x24,0x19,0x27,0x21,0x10,//&6
0x10,0x16,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//'7
0x00,0x00,0x00,0xE0,0x18,0x04,0x02,0x00,0x00,0x00,0x00,0x07,0x18,0x20,0x40,0x00,//(8
0x00,0x02,0x04,0x18,0xE0,0x00,0x00,0x00,0x00,0x40,0x20,0x18,0x07,0x00,0x00,0x00,//)9
0x40,0x40,0x80,0xF0,0x80,0x40,0x40,0x00,0x02,0x02,0x01,0x0F,0x01,0x02,0x02,0x00,//*10
0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x1F,0x01,0x01,0x01,0x00,//+11
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xB0,0x70,0x00,0x00,0x00,0x00,0x00,//,12
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,//-13
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00,//.14
0x00,0x00,0x00,0x00,0x80,0x60,0x18,0x04,0x00,0x60,0x18,0x06,0x01,0x00,0x00,0x00,///15
0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,//016
0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//117
0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,//218
0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00,//319
0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,//420
0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00,//521
0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00,//622
0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,//723
0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,//824
0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00,//925
0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,//:26
0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x60,0x00,0x00,0x00,0x00,//;27
0x00,0x00,0x80,0x40,0x20,0x10,0x08,0x00,0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x00,//<28
0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00,//=29
0x00,0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x00,0x20,0x10,0x08,0x04,0x02,0x01,0x00,//>30
0x00,0x70,0x48,0x08,0x08,0x08,0xF0,0x00,0x00,0x00,0x00,0x30,0x36,0x01,0x00,0x00,//?31
0xC0,0x30,0xC8,0x28,0xE8,0x10,0xE0,0x00,0x07,0x18,0x27,0x24,0x23,0x14,0x0B,0x00,//@32
0x00,0x00,0xC0,0x38,0xE0,0x00,0x00,0x00,0x20,0x3C,0x23,0x02,0x02,0x27,0x38,0x20,//A33
0x08,0xF8,0x88,0x88,0x88,0x70,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x11,0x0E,0x00,//B34
0xC0,0x30,0x08,0x08,0x08,0x08,0x38,0x00,0x07,0x18,0x20,0x20,0x20,0x10,0x08,0x00,//C35
0x08,0xF8,0x08,0x08,0x08,0x10,0xE0,0x00,0x20,0x3F,0x20,0x20,0x20,0x10,0x0F,0x00,//D36
0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x20,0x23,0x20,0x18,0x00,//E37
0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x00,0x03,0x00,0x00,0x00,//F38
0xC0,0x30,0x08,0x08,0x08,0x38,0x00,0x00,0x07,0x18,0x20,0x20,0x22,0x1E,0x02,0x00,//G39
0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x20,0x3F,0x21,0x01,0x01,0x21,0x3F,0x20,//H40
0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//I41
0x00,0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,0x00,//J42
0x08,0xF8,0x88,0xC0,0x28,0x18,0x08,0x00,0x20,0x3F,0x20,0x01,0x26,0x38,0x20,0x00,//K43
0x08,0xF8,0x08,0x00,0x00,0x00,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x20,0x30,0x00,//L44
0x08,0xF8,0xF8,0x00,0xF8,0xF8,0x08,0x00,0x20,0x3F,0x00,0x3F,0x00,0x3F,0x20,0x00,//M45
0x08,0xF8,0x30,0xC0,0x00,0x08,0xF8,0x08,0x20,0x3F,0x20,0x00,0x07,0x18,0x3F,0x00,//N46
0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x10,0x20,0x20,0x20,0x10,0x0F,0x00,//O47
0x08,0xF8,0x08,0x08,0x08,0x08,0xF0,0x00,0x20,0x3F,0x21,0x01,0x01,0x01,0x00,0x00,//P48
0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x18,0x24,0x24,0x38,0x50,0x4F,0x00,//Q49
0x08,0xF8,0x88,0x88,0x88,0x88,0x70,0x00,0x20,0x3F,0x20,0x00,0x03,0x0C,0x30,0x20,//R50
0x00,0x70,0x88,0x08,0x08,0x08,0x38,0x00,0x00,0x38,0x20,0x21,0x21,0x22,0x1C,0x00,//S51
0x18,0x08,0x08,0xF8,0x08,0x08,0x18,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,//T52
0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,//U53
0x08,0x78,0x88,0x00,0x00,0xC8,0x38,0x08,0x00,0x00,0x07,0x38,0x0E,0x01,0x00,0x00,//V54
0xF8,0x08,0x00,0xF8,0x00,0x08,0xF8,0x00,0x03,0x3C,0x07,0x00,0x07,0x3C,0x03,0x00,//W55
0x08,0x18,0x68,0x80,0x80,0x68,0x18,0x08,0x20,0x30,0x2C,0x03,0x03,0x2C,0x30,0x20,//X56
0x08,0x38,0xC8,0x00,0xC8,0x38,0x08,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,//Y57
0x10,0x08,0x08,0x08,0xC8,0x38,0x08,0x00,0x20,0x38,0x26,0x21,0x20,0x20,0x18,0x00,//Z58
0x00,0x00,0x00,0xFE,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x7F,0x40,0x40,0x40,0x00,//[59
0x00,0x0C,0x30,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x06,0x38,0xC0,0x00,//\60
0x00,0x02,0x02,0x02,0xFE,0x00,0x00,0x00,0x00,0x40,0x40,0x40,0x7F,0x00,0x00,0x00,//]61
0x00,0x00,0x04,0x02,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//^62
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,//_63
0x00,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//`64
0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x19,0x24,0x22,0x22,0x22,0x3F,0x20,//a65
0x08,0xF8,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x3F,0x11,0x20,0x20,0x11,0x0E,0x00,//b66
0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x0E,0x11,0x20,0x20,0x20,0x11,0x00,//c67
0x00,0x00,0x00,0x80,0x80,0x88,0xF8,0x00,0x00,0x0E,0x11,0x20,0x20,0x10,0x3F,0x20,//d68
0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x22,0x22,0x22,0x22,0x13,0x00,//e69
0x00,0x80,0x80,0xF0,0x88,0x88,0x88,0x18,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//f70
0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x6B,0x94,0x94,0x94,0x93,0x60,0x00,//g71
0x08,0xF8,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,//h72
0x00,0x80,0x98,0x98,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//i73
0x00,0x00,0x00,0x80,0x98,0x98,0x00,0x00,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,//j74
0x08,0xF8,0x00,0x00,0x80,0x80,0x80,0x00,0x20,0x3F,0x24,0x02,0x2D,0x30,0x20,0x00,//k75
0x00,0x08,0x08,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//l76
0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x20,0x3F,0x20,0x00,0x3F,0x20,0x00,0x3F,//m77
0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,//n78
0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,//o79
0x80,0x80,0x00,0x80,0x80,0x00,0x00,0x00,0x80,0xFF,0xA1,0x20,0x20,0x11,0x0E,0x00,//p80
0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x0E,0x11,0x20,0x20,0xA0,0xFF,0x80,//q81
0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x20,0x20,0x3F,0x21,0x20,0x00,0x01,0x00,//r82
0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x33,0x24,0x24,0x24,0x24,0x19,0x00,//s83
0x00,0x80,0x80,0xE0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x1F,0x20,0x20,0x00,0x00,//t84
0x80,0x80,0x00,0x00,0x00,0x80,0x80,0x00,0x00,0x1F,0x20,0x20,0x20,0x10,0x3F,0x20,//u85
0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x00,0x01,0x0E,0x30,0x08,0x06,0x01,0x00,//v86
0x80,0x80,0x00,0x80,0x00,0x80,0x80,0x80,0x0F,0x30,0x0C,0x03,0x0C,0x30,0x0F,0x00,//w87
0x00,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x31,0x2E,0x0E,0x31,0x20,0x00,//x88
0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x80,0x81,0x8E,0x70,0x18,0x06,0x01,0x00,//y89
0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x21,0x30,0x2C,0x22,0x21,0x30,0x00,//z90
0x00,0x00,0x00,0x00,0x80,0x7C,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x3F,0x40,0x40,//{91
0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,//|92
0x00,0x02,0x02,0x7C,0x80,0x00,0x00,0x00,0x00,0x40,0x40,0x3F,0x00,0x00,0x00,0x00,//}93
0x00,0x06,0x01,0x01,0x02,0x02,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//~94
};
//汉字字模数据 字库字符数组
uint8_t F16X16[]=
{
0x10,0x60,0x02,0x8C,0x00,0x00,0xFE,0x92,0x92,0x92,0x92,0x92,0xFE,0x00,0x00,0x00,//温0
0x04,0x04,0x7E,0x01,0x40,0x7E,0x42,0x42,0x7E,0x42,0x7E,0x42,0x42,0x7E,0x40,0x00,
0x00,0x00,0xFC,0x24,0x24,0x24,0xFC,0x25,0x26,0x24,0xFC,0x24,0x24,0x24,0x04,0x00,//度1
0x40,0x30,0x8F,0x80,0x84,0x4C,0x55,0x25,0x25,0x25,0x55,0x4C,0x80,0x80,0x80,0x00,
0x10,0x60,0x02,0x8C,0x00,0xFE,0x92,0x92,0x92,0x92,0x92,0x92,0xFE,0x00,0x00,0x00,//湿2
0x04,0x04,0x7E,0x01,0x44,0x48,0x50,0x7F,0x40,0x40,0x7F,0x50,0x48,0x44,0x40,0x00,
0x00,0x3E,0x22,0xE2,0x22,0x3E,0x00,0xFE,0x22,0x22,0x22,0x22,0x22,0xE2,0x02,0x00,//距3
0x20,0x3F,0x20,0x1F,0x11,0x11,0x00,0x7F,0x44,0x44,0x44,0x44,0x44,0x47,0x40,0x00,
0x04,0x04,0x04,0xF4,0x84,0xD4,0xA5,0xA6,0xA4,0xD4,0x84,0xF4,0x04,0x04,0x04,0x00,//离4
0x00,0xFE,0x02,0x02,0x12,0x3A,0x16,0x13,0x12,0x1A,0x32,0x42,0x82,0x7E,0x00,0x00,
0x40,0x40,0x42,0x44,0x58,0xC0,0x40,0x7F,0x40,0xC0,0x50,0x48,0x46,0x40,0x40,0x00,//光5
0x80,0x80,0x40,0x20,0x18,0x07,0x00,0x00,0x00,0x3F,0x40,0x40,0x40,0x40,0x78,0x00,
0x00,0xFE,0x42,0x42,0x42,0xFE,0x00,0x42,0xA2,0x9E,0x82,0xA2,0xC2,0xBE,0x00,0x00,//照6
0x80,0x6F,0x08,0x08,0x28,0xCF,0x00,0x00,0x2F,0xC8,0x08,0x08,0x28,0xCF,0x00,0x00,
0x20,0xC2,0x0C,0x80,0x02,0xF2,0x12,0x12,0xFE,0x12,0xFE,0x12,0x12,0xF2,0x02,0x00,//酒7
0x04,0x04,0x7E,0x01,0x00,0xFF,0x4A,0x49,0x48,0x48,0x48,0x49,0x49,0xFF,0x00,0x00,
0x44,0x58,0xC0,0xFF,0x50,0x4C,0x00,0x44,0x54,0x54,0x7F,0x54,0x54,0x54,0x44,0x00,//精8
0x08,0x06,0x01,0xFF,0x01,0x06,0x00,0x00,0xFF,0x15,0x15,0x55,0x95,0x7F,0x00,0x00,
0x10,0x60,0x02,0x8C,0x20,0x18,0x08,0xC8,0x38,0xCF,0x08,0x08,0x28,0x98,0x00,0x00,//浓9
0x04,0x04,0x7E,0x01,0x04,0x02,0x01,0xFF,0x40,0x21,0x06,0x0A,0x11,0x20,0x40,0x00,
0x10,0x10,0x14,0xD4,0x54,0x54,0x54,0xFC,0x52,0x52,0x52,0xD3,0x12,0x10,0x10,0x00,//重10
0x40,0x40,0x50,0x57,0x55,0x55,0x55,0x7F,0x55,0x55,0x55,0x57,0x50,0x40,0x40,0x00,
0x20,0x20,0x20,0xBE,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xBE,0x20,0x20,0x20,0x00,//量11
0x00,0x80,0x80,0xAF,0xAA,0xAA,0xAA,0xFF,0xAA,0xAA,0xAA,0xAF,0x80,0x80,0x00,0x00,
0x00,0x00,0x04,0x04,0x04,0x04,0x04,0xFC,0x04,0x04,0x04,0x04,0x04,0x04,0x00,0x00,//王12
0x00,0x80,0x81,0x81,0x81,0x81,0x81,0xFF,0x81,0x81,0x81,0x81,0x81,0x81,0x80,0x00,
0x10,0x94,0x53,0x32,0x1E,0x32,0x52,0x10,0x00,0x7E,0x42,0x42,0x42,0x7E,0x00,0x00,
0x00,0x00,0x00,0xFF,0x49,0x49,0x49,0x49,0x49,0x49,0x49,0xFF,0x00,0x00,0x00,0x00,/*"智",13*/
0x22,0x2A,0xAA,0xFF,0xAA,0xAA,0xA2,0x80,0xA2,0xAA,0xAA,0xFF,0xAA,0x2A,0x22,0x00,
0x80,0x60,0x08,0x0A,0x6A,0x8A,0x8A,0x9A,0xAA,0x8A,0x8A,0xCA,0x0F,0x20,0xC0,0x00,/*"慧",14*/
0x20,0x18,0x08,0x08,0x08,0xC8,0x38,0xCF,0x08,0x08,0x08,0x08,0xA8,0x18,0x00,0x00,
0x10,0x08,0x04,0x02,0xFF,0x40,0x20,0x00,0x03,0x04,0x0A,0x11,0x20,0x40,0x40,0x00,/*"农",15*/
0x00,0x10,0x60,0x80,0x00,0xFF,0x00,0x00,0x00,0xFF,0x00,0x00,0xC0,0x30,0x00,0x00,
0x40,0x40,0x40,0x43,0x40,0x7F,0x40,0x40,0x40,0x7F,0x42,0x41,0x40,0x40,0x40,0x00,/*"业",16*/
0x04,0x24,0x44,0x84,0x64,0x9C,0x40,0x30,0x0F,0xC8,0x08,0x08,0x28,0x18,0x00,0x00,
0x10,0x08,0x06,0x01,0x82,0x4C,0x20,0x18,0x06,0x01,0x06,0x18,0x20,0x40,0x80,0x00,/*"欢",17*/
0x40,0x40,0x42,0xCC,0x00,0x00,0xFC,0x04,0x02,0x00,0xFC,0x04,0x04,0xFC,0x00,0x00,
0x00,0x40,0x20,0x1F,0x20,0x40,0x4F,0x44,0x42,0x40,0x7F,0x42,0x44,0x43,0x40,0x00,/*"迎",18*/
0x20,0x10,0x08,0xFC,0x23,0x10,0x88,0x67,0x04,0xF4,0x04,0x24,0x54,0x8C,0x00,0x00,
0x40,0x30,0x00,0x77,0x80,0x81,0x88,0xB2,0x84,0x83,0x80,0xE0,0x00,0x11,0x60,0x00,/*"您",19*/
0x00,0xFC,0x84,0x84,0x84,0xFC,0x00,0x10,0x10,0x10,0x10,0x10,0xFF,0x10,0x10,0x00,
0x00,0x3F,0x10,0x10,0x10,0x3F,0x00,0x00,0x01,0x06,0x40,0x80,0x7F,0x00,0x00,0x00,/*"时",20*/
0x00,0xF8,0x01,0x06,0x00,0xF0,0x12,0x12,0x12,0xF2,0x02,0x02,0x02,0xFE,0x00,0x00,
0x00,0xFF,0x00,0x00,0x00,0x1F,0x11,0x11,0x11,0x1F,0x00,0x40,0x80,0x7F,0x00,0x00,/*"间",21*/
0x06,0x09,0x09,0xE6,0xF8,0x0C,0x04,0x02,0x02,0x02,0x02,0x02,0x04,0x1E,0x00,0x00,
0x00,0x00,0x00,0x07,0x1F,0x30,0x20,0x40,0x40,0x40,0x40,0x40,0x20,0x10,0x00,0x00,/*"℃",22*/
0x90,0x52,0x34,0x10,0xFF,0x10,0x34,0x52,0x80,0x70,0x8F,0x08,0x08,0xF8,0x08,0x00,
0x82,0x9A,0x56,0x63,0x22,0x52,0x8E,0x00,0x80,0x40,0x33,0x0C,0x33,0x40,0x80,0x00,/*"数",23*/
0x10,0x10,0xFF,0x10,0x90,0x00,0xFE,0x92,0x92,0x92,0xF2,0x92,0x92,0x9E,0x80,0x00,
0x42,0x82,0x7F,0x01,0x80,0x60,0x1F,0x00,0xFC,0x44,0x47,0x44,0x44,0xFC,0x00,0x00,/*"据",24*/
0x00,0x00,0x04,0x14,0x64,0x04,0x0C,0xB4,0x02,0x02,0x42,0x33,0x02,0x00,0x00,0x00,
0x40,0x41,0x21,0x11,0x09,0x05,0x03,0xFF,0x03,0x05,0x09,0x11,0x21,0x41,0x40,0x00,/*"采",25*/
0x20,0x10,0x08,0xFC,0x57,0x54,0x54,0x55,0xFE,0x54,0x54,0x54,0x54,0x04,0x00,0x00,
0x44,0x44,0x24,0x27,0x15,0x0D,0x05,0xFF,0x05,0x0D,0x15,0x25,0x25,0x45,0x44,0x00,/*"集",26*/
0x40,0x40,0x42,0x44,0x58,0xC0,0x40,0x7F,0x40,0xC0,0x50,0x48,0x46,0x40,0x40,0x00,
0x80,0x80,0x40,0x20,0x18,0x07,0x00,0x00,0x00,0x3F,0x40,0x40,0x40,0x40,0x78,0x00,/*"光",27*/
0x00,0xF8,0x00,0x00,0xFF,0x40,0x20,0x18,0x0F,0x18,0x68,0x08,0x08,0x08,0x08,0x00,
0x00,0x1F,0x00,0x00,0xFF,0x00,0x00,0x7F,0x21,0x21,0x3F,0x21,0x21,0x7F,0x00,0x00,/*"临",28*/
0x02,0x02,0x02,0x02,0x02,0x02,0xFE,0x02,0x02,0x42,0x82,0x02,0x02,0x02,0x02,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x01,0x06,0x00,0x00,0x00,/*"下",29*/
0x00,0x02,0x0C,0x80,0x60,0x80,0x40,0x30,0x0F,0xC8,0x08,0x08,0x28,0x18,0x00,0x00,
0x02,0x02,0x7E,0x01,0x80,0x40,0x20,0x18,0x06,0x01,0x06,0x18,0x20,0x40,0x80,0x00,/*"次",30*/
0x02,0x02,0xF2,0x92,0x92,0x92,0x92,0xFE,0x92,0x92,0x92,0x92,0xF2,0x02,0x02,0x00,
0x04,0x04,0xFF,0x04,0x04,0x04,0x04,0x07,0x04,0x04,0x44,0x84,0x7F,0x04,0x04,0x00,/*"再",31*/
0x00,0x00,0x00,0xFE,0x02,0x02,0x02,0xF2,0x02,0x02,0x02,0xFE,0x00,0x00,0x00,0x00,
0x80,0x80,0x40,0x47,0x20,0x18,0x06,0x01,0x7E,0x80,0x80,0x87,0x80,0x80,0xE0,0x00,/*"见",32*/
};
//显示温度 和湿度函数
void OLed_ShowTemp(void)
{
//第1行显示温度
OLed_ShowChina1(16,2,0);
OLed_ShowChina1(32,2,1);
OLed_ShowChina1(82,2,22);
//第2行显示湿度
OLed_ShowChina1(16,4,2);
OLed_ShowChina1(32,4,1);
OLed_ShowASCII(82,4,"%");
}
//显示距离汉字
void OLed_ShowDist(void)
{
//第2行显示距离
OLed_ShowChina1(16,2,3);
OLed_ShowChina1(32,2,4);
}
//显示光照汉字
void OLed_ShowLight(void)
{
//第2行显示光照
OLed_ShowChina1(16,6,5);
OLed_ShowChina1(32,6,6);
}
//显示酒精浓度汉字
void OLed_ShowAlcol(void)
{
//第2行显示酒精浓度
OLed_ShowChina1(0,2,7);
OLed_ShowChina1(16,2,8);
OLed_ShowChina1(32,2,9);
OLed_ShowChina1(48,2,1);
}
//显示重量汉字
void OLed_ShowWeight(void)
{
//第2行显示重量
OLed_ShowChina1(16,2,10);
OLed_ShowChina1(32,2,11);
}
//显示智慧农业
void OLed_Start(void)
{
OLed_ShowChina1(0,0,13);//智
OLed_ShowChina1(16,0,14);//慧
OLed_ShowChina1(32,0,15);//农
OLed_ShowChina1(48,0,16);//业
OLed_ShowChina1(64,0,17);//欢
OLed_ShowChina1(80,0,18);//迎
OLed_ShowChina1(96,0,19);//您
OLed_ShowASCII(112,0,"!");
OLed_ShowASCII(128,0,"");
}
//显示数据采集
void OLed_Showcj(void)
{
OLed_ShowChina1(24,0,23);
OLed_ShowChina1(40,0,24);
OLed_ShowChina1(56,0,25);
OLed_ShowChina1(72,0,26);
}
void OLed_Time(void)
{
OLed_ShowASCII(32,6,"12:00:00");
OLed_ShowASCII(24,4,"2023/02/27");
delay_ms(1000);
}
/*
写OLED命令寄存器的函数
*/
//这里就是根据写函数发送的各种指令而已。
//iic写自己函数
void WriteOLedCmd(uint8_t cmd)
{
uint8_t CtrWord = 0x00;
IIC_Start();
IIC_Send_Byte(OLED_SLAVE_ADDR_WR); //发送从设备地址
IIC_Wait_Ack();
IIC_Send_Byte(CtrWord); //发送命令控制字
IIC_Wait_Ack();
IIC_Send_Byte(cmd);
IIC_Wait_Ack();
IIC_Stop();
}
/*
写OLED数据的函数
*/
//iic写数据函数
void WriteOLedData(uint8_t data)
{
uint8_t CtrWord = 0x00;
CtrWord |= (0x1<<6); //表示发送的是数据
IIC_Start();
IIC_Send_Byte(OLED_SLAVE_ADDR_WR); //发送从设备地址
IIC_Wait_Ack();
IIC_Send_Byte(CtrWord); //发送命令控制字
IIC_Wait_Ack();
IIC_Send_Byte(data);
IIC_Wait_Ack();
IIC_Stop();
}
/*
设置显示位置
y--> page address页地址 ,相当于 行 (0 ~ 7) 1 100
x --> 列地址 (0 ~ 127)
*/
void OLed_SetPos(unsigned char x, unsigned char y)
{
WriteOLedCmd((0xb0+y)); //设置行地址,设置页号
WriteOLedCmd(((x&0xf0)>>4)|0x10); //设置列地址高位
WriteOLedCmd((x&0x0f)|0x00); //设置列地址的低位
}
#define X_WIDTH 128
/*
填充显示数据缓冲区
*/
void OLed_Fill(unsigned char bmp_data)
{
unsigned char y,x;
for(y=0;y<8;y++)
{
//设置PAGE地址
WriteOLedCmd(0xb0+y);
//设置列地址
WriteOLedCmd(0x00);
WriteOLedCmd(0x10);
for(x=0;x<X_WIDTH;x++)
{
WriteOLedData(bmp_data);
}
}
}
//-----------------------------------------------------//
//1 打开oled函数
void InitOLed(void)
{
//oled屏幕里面有一块oled芯片。芯片需要指令来控制。
//让所有知识点内容统一起来。
//全部的内容就是通过iic协议向oled芯片输入各种指令,控制oled芯片:SSD1306;
//通过输入命令,可以控制oled屏幕。
//给OLED发送命令 初始化OLED
//对oled设备进行相关设定
//查询指令表得出的结论
//根据芯片手册SSD1306:向芯片发送指令,驱动芯片做事。
//关闭显示 //1010 1110
WriteOLedCmd(0xAE);//--turn off oled panel//查表。
//设定行地址
WriteOLedCmd(0x00);//---set low column address //行底地址
//设定列地址
WriteOLedCmd(0x10);//---set high column address //行高地址
//设定起始行地址
WriteOLedCmd(0x40);//--set start line address Set Mapping RAM Display Start Line (0x00~0x3F)
//设定对比度控制寄存器。
WriteOLedCmd(0x81);//--set contrast control register
WriteOLedCmd(0xCF); // Set SEG Output Current Brightness
//设定段映射
WriteOLedCmd(0xA1);//--Set SEG/Column Mapping 0xa0???? 0xa1??
//设定扫描方向行扫描 // 1100 1000
WriteOLedCmd(0xC8);//Set COM/Row Scan Direction 0xc0???? 0xc8??
//正常显示 高电平驱动
WriteOLedCmd(0xA6);//--set normal display
//复用率
WriteOLedCmd(0xA8);//--set multiplex ratio(1 to 64)
WriteOLedCmd(0x3f);//--1/64 duty
//偏移量设定
WriteOLedCmd(0xD3);//-set display offset Shift Mapping RAM Counter (0x00~0x3F)
WriteOLedCmd(0x00);//-not offset
//时钟频率
WriteOLedCmd(0xd5);//--set display clock divide ratio/oscillator frequency
WriteOLedCmd(0x80);//--set divide ratio, Set Clock as 100 Frames/Sec
//充电周期
WriteOLedCmd(0xD9);//--set pre-charge period
WriteOLedCmd(0xF1);//Set Pre-Charge as 15 Clocks & Discharge as 1 Clock
//引脚硬件配置 //iic协议的发送数据函数
WriteOLedCmd(0xDA);//--set com pins hardware configuration
WriteOLedCmd(0x12);
//电压输出
WriteOLedCmd(0xDB);//--set vcomh
//选择线
WriteOLedCmd(0x40);//Set VCOM Deselect Level
//设定页地址
WriteOLedCmd(0x02);//-Set Page Addressing Mode (0x00/0x01/0x02)
//WriteOLedCmd(0x02);//
//充电使能 //对oled驱动芯片的设定
WriteOLedCmd(0x8D);//--set Charge Pump enable/disable
WriteOLedCmd(0x14);//--set(0x10) disable
//全部显示、翻转显示 --- 这就是 oled控制芯片与指令的关系。
WriteOLedCmd(0xA4);// Disable Entire Display On (0xa4/0xa5)
WriteOLedCmd(0xA6);// Disable Inverse Display On (0xa6/a7)
//打开显示器
WriteOLedCmd(0xAF);//--turn on oled panel
//打开显示器
WriteOLedCmd(0xAF); /*display ON*/
OLed_Fill(0x00);//描点;
//WriteOLedCmd(0xAE);
}
//2oled关闭函数
void offInitOLed(void)
{
//给OLED发送命令 初始化OLED
WriteOLedCmd(0xAE);//--turn off oled panel
WriteOLedCmd(0x00);//---set low column address
WriteOLedCmd(0x10);//---set high column address
WriteOLedCmd(0x40);//--set start line address Set Mapping RAM Display Start Line (0x00~0x3F)
WriteOLedCmd(0x81);//--set contrast control register
WriteOLedCmd(0xCF); // Set SEG Output Current Brightness
WriteOLedCmd(0xA1);//--Set SEG/Column Mapping 0xa0???? 0xa1??
WriteOLedCmd(0xC8);//Set COM/Row Scan Direction 0xc0???? 0xc8??
WriteOLedCmd(0xA6);//--set normal display
WriteOLedCmd(0xA8);//--set multiplex ratio(1 to 64)
WriteOLedCmd(0x3f);//--1/64 duty
WriteOLedCmd(0xD3);//-set display offset Shift Mapping RAM Counter (0x00~0x3F)
WriteOLedCmd(0x00);//-not offset
WriteOLedCmd(0xd5);//--set display clock divide ratio/oscillator frequency
WriteOLedCmd(0x80);//--set divide ratio, Set Clock as 100 Frames/Sec
WriteOLedCmd(0xD9);//--set pre-charge period
WriteOLedCmd(0xF1);//Set Pre-Charge as 15 Clocks & Discharge as 1 Clock
WriteOLedCmd(0xDA);//--set com pins hardware configuration
WriteOLedCmd(0x12);
WriteOLedCmd(0xDB);//--set vcomh
WriteOLedCmd(0x40);//Set VCOM Deselect Level
WriteOLedCmd(0x20);//-Set Page Addressing Mode (0x00/0x01/0x02)
WriteOLedCmd(0x02);//
WriteOLedCmd(0x8D);//--set Charge Pump enable/disable
WriteOLedCmd(0x14);//--set(0x10) disable
WriteOLedCmd(0xA4);// Disable Entire Display On (0xa4/0xa5)
WriteOLedCmd(0xA6);// Disable Inverse Display On (0xa6/a7)
WriteOLedCmd(0xAF);//--turn on oled panel
}
//发送一个字节
//mode:数据/命令标志 0,表示命令;1,表示数据;
void OLED_WR_Byte(u8 dat,u8 mode)
{
IIC_Start();
IIC_Send_Byte(0x78);
IIC_Wait_Ack();
if(mode){IIC_Send_Byte(0x40);}
else{IIC_Send_Byte(0x00);}
IIC_Wait_Ack();
IIC_Send_Byte(dat);
IIC_Wait_Ack();
IIC_Stop();
}
//更新显存到OLED
void OLED_Refresh(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); //设置高列起始地址
IIC_Start();
IIC_Send_Byte(0x78);
IIC_Wait_Ack();
IIC_Send_Byte(0x40);
IIC_Wait_Ack();
for(n=0;n<128;n++)
{
IIC_Send_Byte(OLED_GRAM[n][i]);
IIC_Wait_Ack();
}
IIC_Stop();
}
}
//清屏函数
void OLED_Clear(void)
{
u8 i,n;
for(i=0;i<8;i++)
{
for(n=0;n<128;n++)
{
OLED_GRAM[n][i]=0;//清除所有数据
}
}
OLED_Refresh();//更新显示
}
/***********************************显示3个函数*************************************************/
uint8_t fbuf1[]={0x00,0x00,0xF0,0x10,0x10,0x10,0x10,0xFF,0x10,0x10,0x10,0x10,0xF0,0x00,0x00,0x00};
uint8_t fbuf2[]={0x00,0x00,0x0F,0x04,0x04,0x04,0x04,0xFF,0x04,0x04,0x04,0x04,0x0F,0x00,0x00,0x00};/*中*/
uint8_t fbuf3[]={0x00,0xFE,0x02,0x12,0x92,0x92,0x92,0xF2,0x92,0x92,0x92,0x12,0x02,0xFE,0x00,0x00};
uint8_t fbuf4[]={0x00,0xFF,0x40,0x48,0x48,0x48,0x48,0x4F,0x48,0x4A,0x4C,0x48,0x40,0xFF,0x00,0x00};/*国*/
/*
功能:在指定位置显示指定ASCII码对应字符串
@x: 显示的行号(页号0~7)
@y:显示的列号(列号0~127)
@str: 要显示的ascii的字符串
*/
//3.显示字母函数
void OLed_ShowASCII(uint8_t x, uint8_t y,char *str)
{
uint8_t i = 0;
char *pstr = str;
while(*pstr)
{
OLed_SetPos(x,y);
for(i=0;i<8;i++)
{
WriteOLedData(F8X16[((*pstr)-32)*16+i]);
}
OLed_SetPos(x,y+1);
for(i=0;i<8;i++)
{
WriteOLedData(F8X16[((*pstr)-32)*16+8+i]);
}
pstr++;
x +=8;
}
}
/*
功能: 在指定位置显示一个汉字, 显示下一个汉字时,X每次递增16
Y递增 2 字模数据 buf
*/
//4.显示汉字函数
void OLed_ShowChina(uint8_t x,uint8_t y,uint8_t *buf)
{
uint8_t i = 0;
OLed_SetPos(x,y); //设置显示位置
for(i=0;i<16;i++)
{
WriteOLedData(buf[i]);
}
OLed_SetPos(x,(y+1));
for(i=0;i<16;i++)
{
WriteOLedData(buf[i+16]);
}
}
//显示图片
//x0:横坐标;y0:纵坐标;x1:图片起点;y1:所占页数;BMP[]:选用的结构体名称
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_SetPos(x0,y);
for(x=x0;x<x1;x++)
{
WriteOLedData(BMP[j++]);
}
}
}
//num 显示汉字的个数
//space 每一遍显示的间隔
//mode:0,反色显示;1,正常显示
void OLED_ScrollDisplay(u8 num,u8 space)//,u8 mode
{
u8 i,n,t=0,m=0,r;
while(1)
{
if(m==0)
{
OPEN_show();
t++;
}
if(t==num)
{
for(r=0;r<16*space;r++) //显示间隔
{
for(i=1;i<144;i++)
{
for(n=0;n<8;n++)
{
OLED_GRAM[i-1][n]=OLED_GRAM[i][n];
}
}
OLED_Refresh();
}
t=0;
}
m++;
if(m==16){m=0;}
for(i=1;i<144;i++) //实现左移
{
for(n=0;n<8;n++)
{
OLED_GRAM[i-1][n]=OLED_GRAM[i][n];
}
}
OLED_Refresh();
break;
}
}
//显示开机动画
void OPEN_show(void)
{
int x= 0;
while(x<48)
{
OLED_Clear();
OLED_DrawBMP(x-48+48,2,x-48+80,6,**3);//显示图片移动从最左边到中间
delay_ms(100);
x++;
OLED_Clear();
if(x==48)
{
OLED_Clear();
break;
}
}
OLed_ShowChina1(32,2,17);
OLED_DrawBMP(48,2,80,6,**3);//显示图片
OLed_ShowChina1(80,2,18);
OLed_ShowChina1(32,4,27);
OLed_ShowChina1(80,4,28);
delay_ms(6000);
OLED_Clear();
}
//显示关机动画
void CLOSE_show(void)
{
int x= 0;
while(x<80)
{
OLED_Clear();
OLED_DrawBMP(x+48,2,x+80,6,**3);//显示图片移动从最左边到中间到移除
delay_ms(100);
x++;
OLED_Clear();
if(x==80)
{
OLED_Clear();
break;
}
}
OLed_ShowChina1(32,2,31);
OLED_DrawBMP(48,2,80,6,**3);
OLed_ShowChina1(80,2,32);
OLed_ShowChina1(32,4,33);
OLed_ShowChina1(80,4,34);
delay_ms(6000);
OLED_Clear();
offInitOLed();
}
/*
在 x,y 位置显示 中国
*/
void OLed_ShowTest(unsigned char x,unsigned char y)
{
uint8_t i = 0;
OLed_SetPos(x,y);
for(i=0;i<16;i++)
{
WriteOLedData(fbuf1[i]);
}
OLed_SetPos(x,(y+1));
for(i=0;i<16;i++)
{
WriteOLedData(fbuf2[i]);
}
OLed_SetPos((x+16),y);
for(i=0;i<16;i++)
{
WriteOLedData(fbuf3[i]);
}
OLed_SetPos((x+16),(y+1));
for(i=0;i<16;i++)
{
WriteOLedData(fbuf4[i]);
}
}
//取汉字字库输出
void OLed_ShowChina1(uint8_t x,uint8_t y,unsigned char bufstr)
{
unsigned char wm=0;
unsigned int adder=32*bufstr;
OLed_SetPos(x,y);
for(wm = 0;wm < 16;wm++)
{
WriteOLedData(F16X16[adder]);
adder += 1;
}
OLed_SetPos(x,y + 1);
for(wm = 0;wm < 16;wm++)
{
WriteOLedData(F16X16[adder]);
adder += 1;
}
}
//起始页0
void OLed_page0(void)
{
//显示智慧农业
OLed_Start();
OLed_Time();
}
//页1
void OLed_page1(void)
{ OLed_Showcj();
WS_Run();
GM_Av();
}
|
|