终于可以显示了,虽然还有些问题
#include <Arduino.h>
#include <Wire.h>
#include <SoftwareSerial.h>
#define uchar unsigned char
#define uint unsigned int
#include <SimpleDHT.h>
int pinDHT11 = D5;
SimpleDHT11 dht11(pinDHT11);
int i=0;
int RST =D2;
int sck = D1;
int sda = D0;
int CS = D4;
int CD = D3;
// width: 144, height: 142
unsigned char col[]={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,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,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,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,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0f,0xff,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0xff,0xf0,0x00,0x00,0x3f,0xff,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0xff,0xf8,0x00,0x00,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0xff,0xfc,0x00,0x1f,0xf0,0x00,0x07,0xfc,0x00,0x00,0x1e,0x00,0x00,0x01,0xff,0xff,0xfe,0x07,0xff,0x00,0x00,0x00,0x1f,0x80,0x01,0xff,0xc0,0x00,0x01,0xff,0xff,0xff,0x1f,0xf8,0x00,0x00,0x00,0x07,0xc0,0x07,0xff,0xf0,0x00,0x03,0xff,0xff,0xff,0xf8,0x00,0x00,0x00,0x00,0x00,0x78,0x1f,0xff,0xfe,0x00,0x03,0xff,0xff,0xff,0xf0,0x00,0x00,0x00,0x00,0x00,0x3e,0x3f,0xff,0xff,0x00,0x07,0xff,0xff,0xff,0xe0,0x00,0x00,0x00,0x00,0x00,0x0f,0x3f,0xff,0xff,0x80,0x0f,0xff,0xff,0xff,0x80,0x00,0x00,0x00,0x00,0x00,0x03,0xff,0xff,0xff,0xc0,0x0f,0xff,0xff,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xc0,0x0f,0xff,0xff,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0xff,0xff,0xc0,0x0f,0xff,0xff,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0xff,0xff,0xe0,0x0f,0xff,0xff,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0xff,0xff,0xf0,0x0f,0xff,0xff,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0f,0xff,0xff,0xf0,0x0f,0xff,0xff,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xff,0xff,0xf8,0x0f,0xff,0xff,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xff,0xff,0xf8,0x0f,0xff,0xff,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xff,0xff,0xf8,0x0f,0xff,0xff,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xff,0xff,0xf8,0x0f,0xff,0xff,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xf8,0x0f,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xf8,0x0f,0xff,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xf8,0x0f,0xff,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0xff,0xf8,0x0f,0xff,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0xff,0xf8,0x07,0xff,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0xff,0xf8,0x03,0xff,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0xff,0xf8,0x03,0xff,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0xff,0xf8,0x01,0xff,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0xff,0xf0,0x01,0xff,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0f,0xff,0xf0,0x01,0xff,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0f,0xff,0xf0,0x00,0x7f,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xf0,0x07,0xff,0xe0,0x00,0x3f,0xc0,0x00,0x00,0x00,0x1f,0xe0,0x00,0x00,0x7b,0xf0,0x07,0xff,0xc0,0x00,0x1f,0xc0,0x00,0x00,0x00,0x3f,0xfe,0x00,0x00,0x7f,0xf0,0x03,0xff,0x80,0x00,0x07,0x80,0x00,0x00,0x00,0xdf,0xff,0x86,0x01,0xff,0xe0,0x03,0xff,0x00,0x00,0x01,0x80,0x00,0x00,0x07,0xc0,0xff,0xc7,0x13,0xff,0x80,0x01,0xfe,0x00,0x00,0x01,0x80,0x00,0x00,0x01,0x01,0xff,0xff,0x1f,0xff,0xe0,0x01,0xfc,0x00,0x00,0x01,0x00,0x00,0x00,0x38,0x0f,0xff,0xff,0x1f,0xff,0xe0,0x00,0xc0,0x00,0x00,0x03,0x00,0x00,0x00,0x30,0xff,0xff,0xff,0x9f,0xfb,0xf0,0x00,0xc0,0x00,0x00,0x03,0x00,0x00,0x00,0x0f,0xff,0x9f,0xfc,0x3f,0xf1,0xf0,0x00,0xc0,0x00,0x00,0x06,0x00,0x00,0x00,0x0f,0xfe,0x0f,0xf8,0x3f,0xe0,0xe0,0x00,0xc0,0x00,0x00,0x06,0x00,0x00,0x00,0x0f,0xfe,0x07,0xc0,0x1f,0xc0,0xc0,0x00,0xc0,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x7c,0x0f,0x80,0x0f,0xe6,0x00,0x00,0x60,0x00,0x00,0x0c,0x00,0x00,0x00,0x00,0x01,0xff,0x80,0x0f,0xfe,0x00,0x00,0x60,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x03,0xff,0x00,0x07,0xfe,0x00,0x00,0x60,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x03,0xf8,0x00,0x02,0x3e,0x00,0x00,0x60,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x30,0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x30,0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x01,0xe0,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x01,0xe0,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x03,0xc0,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x07,0xc0,0x00,0x00,0x00,0x00,0x07,0x80,0x00,0x00,0x00,0x00,0x00,0x1c,0x00,0x0f,0xc0,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x1e,0x00,0x1f,0xc0,0x00,0x00,0x00,0x00,0xfe,0x01,0xfc,0x1f,0xfc,0x00,0x00,0x1e,0x00,0x3f,0xc0,0x00,0x00,0x00,0x00,0xfe,0x01,0xff,0xff,0x9f,0x00,0x00,0x1f,0x80,0x7f,0xc0,0x00,0x00,0x00,0x03,0xfc,0x00,0xff,0xff,0x1f,0x00,0x00,0x1f,0x80,0x7f,0xc0,0x00,0x00,0x00,0x00,0xf0,0x00,0x3f,0xfe,0x06,0x00,0x00,0x1f,0x80,0xff,0xc0,0x00,0x00,0x00,0x00,0xe0,0x00,0x07,0xf8,0x02,0x00,0x00,0x1f,0xc0,0xff,0xc0,0x00,0x00,0x00,0x00,0xc0,0x00,0x03,0xf0,0x00,0x00,0x00,0x1f,0xc0,0xff,0xe0,0x00,0x00,0x00,0x00,0x40,0x00,0x06,0x00,0x00,0x00,0x00,0x1f,0xe0,0xff,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x1f,0xf0,0xff,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0xf0,0xff,0xf0,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0xf8,0xff,0xf8,0x00,0x00,0x00,0x00,0x0f,0xf1,0x60,0x00,0x00,0x00,0x00,0x3f,0xf8,0xff,0xf8,0x00,0x00,0x00,0x00,0x07,0xff,0xfc,0x7f,0x80,0x00,0x00,0x3f,0xfc,0xff,0xf8,0x00,0x00,0x00,0x00,0x03,0xff,0xff,0xff,0xe0,0x00,0x00,0x7f,0xfe,0xff,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xff,0x80,0x00,0x00,0x7f,0xfe,0xff,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x7f,0xfe,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xff,0xff,0xff,0xff,0xe0,0x00,0x00,0x00,0x00,0x0e,0x00,0x00,0x00,0x00,0x03,0xff,0xff,0xff,0xff,0xf0,0x00,0x00,0x00,0x00,0x03,0x80,0x00,0x00,0x00,0x07,0xff,0xff,0xff,0xff,0xf8,0x00,0x00,0x00,0x00,0x01,0xd0,0x03,0x00,0x00,0x0f,0xff,0xff,0xff,0xff,0xfc,0x00,0x00,0x00,0x00,0x00,0x7f,0xff,0x00,0x00,0x1f,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x3f,0xff,0x00,0x00,0x3f,0xff,0xff,0xff,0xff,0xff,0xc0,0x00,0x00,0x00,0x00,0x1f,0xff,0x00,0x00,0x7f,0xff,0xff,0xff,0xff,0xff,0xe0,0x00,0x00,0x00,0x00,0x0f,0xfc,0x00,0x01,0xff,0xff,0xff,0xff,0xff,0xff,0xf8,0x00,0x00,0x00,0x00,0x07,0xf8,0x00,0x07,0xff,0xff,0xff,0xff,0xff,0xff,0xf8,0x00,0x00,0x00,0x00,0x03,0xf0,0x00,0x1f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0x00,0x00,0x00,0x00,0x00,0x07,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0x00,0x00,0x00,0x00,0x00,0x3f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x80,0x00,0x00,0x00,0x07,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe0,0x00,0x00,0x00,0x1f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfc,0x00,0x00,0x0f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff };
char shi1[] = {
0x00,0x00,0x00,0x00,0x7F,
0x49,0x49,0x49,0x49,0x49,
0x7F,0x00,0x00,0x80,0x00,
0x00,0x01,0x81,0x41,0x21,
0x1D,0x21,0x41,0x7F,0x89,
0x89,0x8D,0x89,0x81,0xC1,
0x41,0x00
};
char qiu[] = {
/*-- 文字: 秋 --*/
/*-- 宋体18; 此字体下对应的点阵为:宽x高=24x24 --*/
0x00,0x00,0x00,0x20,0x10,0x10,0x18,0xFC,
0x06,0x86,0x00,0x80,0x00,0x00,0xD3,0xFF,
0x02,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,
0x00,0x00,0x02,0x82,0x63,0x31,0x1F,0xFF,
0x0D,0x39,0x31,0x03,0x1E,0x80,0xFF,0x3F,
0xC8,0x06,0x03,0x00,0x00,0x00,0x00,0x00,
0x00,0x06,0x03,0x00,0x00,0x00,0xF7,0xFF,
0x00,0xC0,0x60,0x30,0x0C,0x07,0x00,0x00,
0x01,0x0E,0x38,0x70,0x60,0x40,0x40,0x00};
char one[] =
{
0x00,0x10,0x10,0x18,0x18, // -1-
0xFC,0xFC,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0xFF,0xFF,0x00,
0x00,0x00,0x00,0x00,0x00,
0x00,0x20,0x20,0x20,0x3F,
0x3F,0x20,0x20,0x20,0x00,
0x00 };
char wen[]={ 0x00,0x00,0x00,0xC0,0x80,0x82,0x06,0x1C, 0x80,0x00,0x00,0xFF,0x26,0x26,0x22,0x32, 0x32,0xC2,0xFF,0x03,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x01,0x03,0xE0,0x3E, 0x01,0x70,0xE0,0x27,0x66,0xF2,0x33,0x13, 0xF1,0x11,0x11,0xF8,0x18,0x00,0x00,0x00, 0x00,0x00,0x00,0x0C,0x18,0x1F,0x03,0x00, 0x00,0x00,0x1F,0x10,0x10,0x1F,0x10,0x1C, 0x1F,0x10,0x1E,0x1F,0x10,0x18,0x10,0x00};
char du[]={0x00,0x00,0x00,0x00,0x00,0xF8,0x60,0x20, 0x20,0x60,0xF0,0x33,0x16,0x16,0x10,0xF0, 0x10,0x18,0x98,0x98,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x80,0xFF,0x02,0x02, 0x82,0x82,0xBF,0x93,0xD3,0xD1,0x5D,0xDF, 0xE1,0x41,0x01,0x01,0x01,0x00,0x00,0x00, 0x00,0x80,0x60,0x38,0x0F,0x01,0x00,0x80, 0xC0,0x42,0x22,0x34,0x1C,0x1C,0x33,0x61, 0xC0,0xC0,0x80,0x80,0x80,0x80,0x80,0x00};
char shi[]={0x00,0x00,0x00,0x00,0x02,0x04,0x1C,0x08, 0x80,0x00,0xFE,0x44,0x44,0x44,0x64,0x64, 0x24,0xE6,0x7E,0x06,0x00,0x00,0x00,0x00, 0x00,0x00,0x01,0x03,0x06,0x06,0xF0,0x1F, 0x00,0xC0,0x87,0x06,0xF6,0x22,0x02,0xFA, 0x12,0x03,0xC2,0x60,0x00,0x00,0x00,0x00, 0x00,0x00,0x08,0x18,0x38,0x3F,0x01,0x20, 0x20,0x20,0x23,0x20,0x3F,0x20,0x20,0x3F, 0x36,0x33,0x30,0x30,0x30,0x20,0x00,0x00};
char abc[]={ 0x00,0x00,0x00,0x00,0x80,0xC0,0xC0,0x80, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x81,0xC3,0xC3,0x81,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x01,0x03,0x03,0x01, 0x00,0x00,0x00,0x00};
char C[]={ 0xC0,0xF0,0x38,0x0C,0x04,0x04,0x04,0x0C, 0x18,0x38,0x7C,0x00,0xFF,0xFF,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x03,0x0F,0x1C,0x30,0x20,0x20,0x20,0x30, 0x18,0x0E,0x06,0x00};
char H[]={0x04,0xFC,0xFC,0x04,0x00,0x00,0x00,0x04, 0xFC,0xFC,0x04,0x00,0x00,0xFF,0xFF,0x08, 0x08,0x08,0x08,0x08,0xFF,0xFF,0x00,0x00, 0x20,0x3F,0x3F,0x20,0x00,0x00,0x00,0x20, 0x3F,0x3F,0x20,0x00};
char O[]={0xC0,0xE0,0x20,0x20,0x20, 0xE0,0xC0,0x00,0x07,0x0F, 0x08,0x08,0x08,0x0F,0x07, 0x00};
char num_24_12[][36]=
{
// -0-
{0x00,0xC0,0xF0,0x38,0x0C, 0x04,0x0C,0x38,0xF0,0xC0, 0x00,0x00,0xFF,0xFF,0x00, 0x00,0x00,0x00,0x00,0x00, 0x00,0xFF,0xFF,0x00,0x00, 0x03,0x0F,0x1C,0x30,0x20, 0x30,0x1C,0x0F,0x03,0x00,0x00},
// -1-
{0x00,0x10,0x10,0x18,0x18, 0xFC,0xFC,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0xFF,0xFF,0x00, 0x00,0x00,0x00,0x00,0x00, 0x00,0x20,0x20,0x20,0x3F, 0x3F,0x20,0x20,0x20,0x00, 0x00},
// -2-
{0x60,0xF0,0xF8,0x0C,0x04, 0x04,0x04,0x0C,0x18,0xF0, 0xE0,0x00,0x00,0x00,0x00, 0x80,0xC0,0x60,0x30,0x18, 0x0E,0x07,0x01,0x00,0x38, 0x3E,0x3F,0x33,0x30,0x30, 0x30,0x30,0x30,0x30,0x3C, 0x00},
// -3-
{0x00,0x30,0x78,0x78,0x0C, 0x04,0x04,0x0C,0x18,0xF8, 0xF0,0x00,0x00,0x00,0x00, 0x00,0x08,0x08,0x1C,0x16, 0x33,0xE1,0xC0,0x00,0x0C, 0x1E,0x3E,0x30,0x20,0x20, 0x20,0x30,0x18,0x1F,0x0F, 0x00},
// -4-
{0x00,0x00,0x00,0x00,0x80, 0xE0,0x38,0xFC,0xFC,0x00, 0x00,0x00,0x80,0xE0,0x38, 0x0E,0x03,0x00,0x00,0xFF, 0xFF,0x00,0x00,0x00,0x01, 0x01,0x01,0x01,0x01,0x21, 0x21,0x3F,0x3F,0x21,0x21, 0x01},
// -5-
{0x00,0xFC,0xFC,0x0C,0x0C, 0x0C,0x0C,0x0C,0x0C,0x0C, 0x00,0x00,0x00,0x1F,0x0F, 0x08,0x04,0x02,0x02,0x06, 0x1C,0xF8,0xE0,0x00,0x0C, 0x1E,0x3E,0x30,0x20,0x20, 0x20,0x30,0x1C,0x0F,0x03, 0x00},
// -6-
{0xC0,0xF0,0x38,0x0C,0x04, 0x04,0x0C,0x7C,0x78,0x30, 0x00,0x00,0xFF,0xFF,0x08, 0x04,0x02,0x02,0x02,0x06, 0x1C,0xF8,0xE0,0x00,0x03, 0x0F,0x1C,0x30,0x20,0x20, 0x20,0x30,0x1C,0x0F,0x03, 0x00},
// -7-
{0x78,0x1C,0x0C,0x0C,0x0C, 0x0C,0x0C,0x0C,0xCC,0x7C, 0x1C,0x00,0x00,0x00,0x00, 0x00,0x80,0xF0,0x7C,0x0F, 0x01,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x3F,0x3F, 0x00,0x00,0x00,0x00,0x00, 0x00},
// -8-
{0x00,0xF0,0xF8,0x0C,0x04, 0x04,0x04,0x0C,0xF8,0xF0, 0x00,0x00,0xC0,0xE0,0x31, 0x1B,0x0E,0x0C,0x0E,0x1B, 0x31,0xE0,0xC0,0x00,0x07, 0x0F,0x18,0x30,0x20,0x20, 0x20,0x30,0x18,0x0F,0x07, 0x00},
// -9-
{0xC0,0xF0,0x38,0x0C,0x04, 0x04,0x04,0x0C,0x38,0xF0, 0xC0,0x00,0x07,0x1F,0x38, 0x60,0x40,0x40,0x40,0x20, 0x10,0xFF,0xFF,0x00,0x00, 0x0C,0x1E,0x3E,0x30,0x20, 0x20,0x30,0x1C,0x0F,0x03, 0x00},
};
char num_16_8[][16]=
{
// -0-
{0xF8,0xFC,0x04,0xC4,0x24, 0xFC,0xF8,0x00,0x07,0x0F, 0x09,0x08,0x08,0x0F,0x07, 0x00},
// -1-
{0x00,0x10,0x18,0xFC,0xFC, 0x00,0x00,0x00,0x00,0x08, 0x08,0x0F,0x0F,0x08,0x08, 0x00},
// -2-
{0x08,0x0C,0x84,0xC4,0x64, 0x3C,0x18,0x00,0x0E,0x0F, 0x09,0x08,0x08,0x0C,0x0C, 0x00},
// -3-
{0x08,0x0C,0x44,0x44,0x44, 0xFC,0xB8,0x00,0x04,0x0C, 0x08,0x08,0x08,0x0F,0x07, 0x00},
// -4-
{0xC0,0xE0,0xB0,0x98,0xFC, 0xFC,0x80,0x00,0x00,0x00, 0x00,0x08,0x0F,0x0F,0x08, 0x00},
// -5-
{0x7C,0x7C,0x44,0x44,0xC4, 0xC4,0x84,0x00,0x04,0x0C, 0x08,0x08,0x08,0x0F,0x07, 0x00},
// -6-
{0xF0,0xF8,0x4C,0x44,0x44, 0xC0,0x80,0x00,0x07,0x0F, 0x08,0x08,0x08,0x0F,0x07, 0x00},
// -7-
{0x0C,0x0C,0x04,0x84,0xC4, 0x7C,0x3C,0x00,0x00,0x00, 0x0F,0x0F,0x00,0x00,0x00, 0x00},
// -8-
{0xB8,0xFC,0x44,0x44,0x44, 0xFC,0xB8,0x00,0x07,0x0F, 0x08,0x08,0x08,0x0F,0x07, 0x00},
// -9-
{0x38,0x7C,0x44,0x44,0x44, 0xFC,0xF8,0x00,0x00,0x08, 0x08,0x08,0x0C,0x07,0x03, 0x00},
};
void num_str_2412(char x,char y,int data)
{
int ge=data%10;
int shi=data/10;
words_2424(x, y, 1, num_24_12[shi]);
words_2424(x+4, y, 1, num_24_12[ge]);
}
void write_160160(bool flag, uchar dat)
{
uchar i;
digitalWrite(CD, flag);//flag=0,write command;flag=1,write data
digitalWrite(CS, 0);
for(i = 0; i < 8; i++)
{
if(dat&0x80)
{
digitalWrite(sda, 1);
}
else
{
digitalWrite(sda, 0);
}
dat<<=1;
digitalWrite(sck, 1);
digitalWrite(sck, 0);
}
digitalWrite(CS,1);
}
void LCD_SetAddress(int x, int y)
{
x = 0x25 + x / 3; //计算出该点所在的列地址,注意该液晶每3个点共有一个地址
write_160160(0, 0x60 | (y & 0x0f)); //写行地址低位
write_160160(0, 0x70 | (y >> 4)); //写行地址高位
write_160160(0, x & 0x0f); //写列地址低位
write_160160(0, 0x10 | (x >> 4)); //写列地址高位
}
void init160160(void)
{
digitalWrite(CS, 0);
/*************************reset*************************/
digitalWrite(RST, 0);
delay(2); //power on reset
digitalWrite(RST, 1);
delay(800);
write_160160(0, 0xe2); //reset by command
delay(2);
/**********************power control*********************/
write_160160(0, 0xe9); //Bias Ratio:1/10 bias LCD 偏压比 偏压比设置为1/10
write_160160(0, 0x2b); //Bias Ratio:1/10 bias LCD 偏压比 偏压比设置为1/10
write_160160(0, 0x24); //set temperate compensation as 0% 温度补偿 设置驱动偏压(VBIAS)的温度补偿系TC
write_160160(0, 0x81); //electronic potentionmeter 设置对比度调节值 取值范围为0 ~255
write_160160(0, 198); //0xc6不起作用
/**********************display control*******************/
write_160160(0, 0xa4); //0xa4 关闭所有像素 0xa5 启动全显示功能
write_160160(0, 0xa6); //关闭像素反显 决定屏幕反显 a6为正性显示;a7为负性显示
//write_160160(0, 0xa8);//..显示使能 开关灰度
/*************************lcd control********************/
write_160160(0,0xc0); //partial display and MX disable,MY enable设置显示RAM 驱动数据的输出与驱动行COM 端和驱动列SEG 端的对应关系
// write(0,0xc7);//
//write_160160(0, 0xe2); //系统初始化,启用此选项屏变淡
write_160160(0, 0xa3); //line rate 15.2klps 设置帧频率
write_160160(0, 0xd1); //rgb-rgb 显示数据格式
write_160160(0, 0xd5); //4k color mode 12-bit/RGB
write_160160(0, 0x84); //partial display control disable 局部显示控制
/********************n-line inversion********************/
write_160160(0, 0xc8); //set n-line inversion
write_160160(0,0x10); //enable NIV
/********************com scan fuction********************/
write_160160(0, 0xd8); //enable FRC,PWM,LRM sequence设置COM 扫描模式
/***********************window***区域操作指令*************************
*column and row set fix the display district,for example
*when AC[0]=1,AC[1]=0;(automatic wraparound,column first)
*column auto_icrement will restart after the end address
*显示窗口大小设置
*********************************************************/
write_160160(0, 0xf4); //wpc0:column 操作窗口的左边界列地址
write_160160(0, 0x25); //start from 130
write_160160(0, 0xf6); //wpc1 ending column address 操作窗口右边界(结束列地址)设置
write_160160(0, 0x5A); //end:272 90
//因为列开始到结尾共90-37=53个数所以 一个数代表160/53=3个像素
write_160160(0, 0xf5); //wpp0:row starting row address 操作窗口上边界(起始行地址)设置
write_160160(0, 0x00); //start from 0
write_160160(0, 0xf7); //wpp1 ending row address 操作窗口下边界(结束行地址)设置
write_160160(0, 0x9F); //end 160 0x9F=159
//行开始到结束共160个数所以一个数代表160/160=1个像素
write_160160(0, 0xf8); //inside mode 窗口操作的使能 0xf9:使能无效
write_160160(0, 0x89); //RAM control 地址自动加一 AC1=0 列先增加 AC2=0 控制行增加+1还是-1 AC0=1
write_160160(0, 0x8b); //是0x89的90°翻转显示 AC1=1 行先增加 AC0=1
write_160160(0,0x8d); // AC1=0 AC2=1 控制行增加+1还是-1 AC0=1
write_160160(0,0x8a); //这四行控制一次性写入时地址增加方向 直接向地址中写数据时不管用....
write_160160(0, 0xad); //display on,select on/off mode.Green Enhance mode disable 显示使能设置 关灰度,增强模式无效 背景深黑雪花
/***************卷动指令*********scroll line**********滚动行***********/
write_160160(0, 0x40); //低4位卷动行号
write_160160(0, 0x50); //高4位卷动行号
write_160160(0, 0xc4); //19,enable FLT and FLB set lcd Mapping control
write_160160(0, 0x90); //14:FLT,FLB set 局部卷动功能而分解卷动区域和固定区域,FLT,FLB 为固定区域
write_160160(0, 0x00);
/**********************partial display*******区域操作指令***********/
write_160160(0, 0x84); //12,set partial display controlff 控制局部显示功能 0x84: 局部显示无效;0x85:局部显示使能
write_160160(0, 0xf1); //com end COM 扫描结束行设置
write_160160(0, 0x9f); //160 取值范围0~9F。复位后默认为9FH。
write_160160(0, 0xf2); //display start 局部显示起始行设置
write_160160(0, 0); //0
write_160160(0, 0xf3); //display end 局部显示结束行设置
write_160160(0, 159); //160
}
void cleadlCD()
{
uint i;
write_160160(0,0xf4); write_160160(0,0x25); //设置操作窗口左边界 0--53
write_160160(0,0xf5); write_160160(0,0x00); //设置操作窗口上边界
write_160160(0,0xf6); write_160160(0,0x5a); //设置操作窗口右边界
write_160160(0,0xf7); write_160160(0,0x9f); //设置操作窗口下边界
write_160160(0,0xf8); //设置窗口操作使能
write_160160(0,0x05);write_160160(0,0x12); //设置起始列地址
write_160160(0,0x60); write_160160(0,0x70); //设置起始行地址
for (i=0;i<160*28;i++) //循环总的数据量(列块x 行数)
{
write_160160(1,0x00); //写入数据pixel1,pixel2
write_160160(1,0x00); //写入数据pixel3,pixel4
write_160160(1,0x00); //写入数据pixel5,pixel6
}
}
void cleadlCD1()
{
uint i;
write_160160(0,0xf4); write_160160(0,0x25); //设置操作窗口左边界 0--53
write_160160(0,0xf5); write_160160(0,0x00); //设置操作窗口上边界
write_160160(0,0xf6); write_160160(0,0x5a); //设置操作窗口右边界
write_160160(0,0xf7); write_160160(0,0x9f); //设置操作窗口下边界
write_160160(0,0xf8); //设置窗口操作使能
write_160160(0,0x05);write_160160(0,0x12); //设置起始列地址
write_160160(0,0x60); write_160160(0,0x70); //设置起始行地址
for (i=0;i<160*28;i++) //循环总的数据量(列块x 行数)
{
write_160160(1,0xff); //写入数据pixel1,pixel2
write_160160(1,0xff); //写入数据pixel3,pixel4
write_160160(1,0xff); //写入数据pixel5,pixel6
}
}
void lcdscan(uchar dat1,uchar dat2)
{
uchar i,j;
write_160160(0,0x60); write_160160(0,0x25); //设置操作窗口左边界 0--53
write_160160(0,0x70); write_160160(0,0x00); //设置操作窗口上边界
write_160160(0,0x05); write_160160(0,0x5a); //设置操作窗口右边界
write_160160(0,0x12); write_160160(0,0x9f); //设置操作窗口下边界
write_160160(0,0xf8);//设置窗口操作使能
write_160160(0,0x05);write_160160(0,0x12); //设置起始列地址
write_160160(0,0x60); write_160160(0,0x70); //设置起始行地址
for(j=0;j<160;j++)
{
for(i=0;i<27;i++)
{
if(j%2==0)
{
write_160160(1,dat1);
write_160160(1,dat1);
write_160160(1,dat1);
}
else
{
write_160160(1,dat2);
write_160160(1,dat2);
write_160160(1,dat2);
}
}
}
}
void words_1616(char x, char y, char type, char *p) //type=1,ascii;type=2,Chinese character 显示16*16像素 汉字 小四
{ //x控制列显示地址 y控制行显示地址
//汉字取模方式 16*16 从左到右从上到下 纵向8点下高位
char i, k, j, m, n, l, x0, dat0, dat1, dat2, dat3, dat6;
x = 37 + x; //控制LCD RAM地址用
x0 = 0x00 | (x & 0x0f);
x = 0x10 | ((x & 0xf0) >> 4);
for (i = 0; i < 2; i++) //横向 2个字节 因为是纵向取模 所以横向 共2*8=16个像素点 i的上限为字符宽度/8 eg:16/8=2
{ //i的值控制着字符宽度若显示48*24则for(i=0;i<6;i++)
n = i * 8 * type; //纵向 type==2时为汉字 因为是16*16尺寸的汉字所以纵向每次需要16个bit
//n的值控制着字符高度像素若显示24*48则n=i*24*type (type==2时显示汉字)
for (j = 0; j < 8; j++) //j的8次循环负责将取模字节中的数据还原成8bit像素数据
{
m = i * 8 + j; //控制LCD RAM的地址
write_160160(0, 0x89); //地址自动加一
write_160160(0, x0); // write display address area
write_160160(0, x); // write display address area
write_160160(0, 0x60 | ((y + m) & 0x0f)); // write display address area
write_160160(0, 0x70 | (((y + m) & 0xf0) >> 4)); // write display address area
for (k = 0; k < 2 * type; k++) //此循环显示汉字的时候执行4*4=16个字节(for循环中用dat0-dat4计算字模中的4个字节)
{
l = k * 4 + n; //l和n联合控制汉字高度因为是24*24所以每次执行4*4=16个循环 其中(4表示k的数据范围 4表示k的公倍数)
dat6 = 0x01 << j; //通过上一层j的for循环来取出没个字节中的8bit数据
dat0 = (*(p + l))&dat6;
dat0 = dat0 >> j;
dat0 <<= 7; //取出字模数组中第p+l个字节的第j位并移到第8位上
dat1 = (*(p + l + 1))&dat6;
dat1 = dat1 >> j;
dat1 <<= 3; //取出字模数组中第p+l+1个字节的第j位并移到第4位上
dat2 = *(p + 2 + l)&dat6;
dat2 = dat2 >> j;
dat2 <<= 7; //取出字模数组中第p+l+2个字节的第j位并移到第8位上
dat3 = (*(p + 3 + l))&dat6;
dat3 = dat3 >> j;
dat3 <<= 3; //取出字模数组中第p+l+3个字节的第j位并移到第8位上
write_160160(1, dat0 | dat1); //写入的数据是16进制包含2个字节数据 将dat0放到高4位 dat1放到第4位
write_160160(1, dat2 | dat3);
}
write_160160(0, 0x88);
}
}
write_160160(0, 0x89);
}
void words_2424(char x, char y, char type, char *p)
{ //x控制列显示地址 y控制行显示地址 type=1,ascii;type=2,Chinese character 显示24*24像素 宋体 小二
//汉字取模方式 24*24 纵向取模 从上往下一次八个点,从左往右 每个ascii加4
char i, k, j, m, n, l, x0, dat0, dat1, dat2, dat3, dat4, dat5, dat6;
x = 37 + x;
x0 = 0x00 | (x & 0x0f);
x = 0x10 | ((x & 0xf0) >> 4);
for (i = 0; i < 3; i++) //横向 3个字节 因为是纵向取模 所以横向 共3*8=24个像素点 i的上限为字符宽度/8 eg:24/8=3
{ //i的值控制着字符宽度若显示48*24则for(i=0;i<6;i++)
n = i * 12 * type; //纵向 type==2时为汉字 因为是24*24尺寸的汉字所以纵向每次需要24个bit
//n的值控制着字符高度像素若显示24*48则n=i*24*type (type==2时显示汉字)
for (j = 0; j < 8; j++) //j的8次循环负责将取模字节中的数据还原成8bit像素数据
{
m = i * 8 + j; //控制LCD RAM的地址
write_160160(0, 0x89); //地址自动加一
write_160160(0, x0); // write display address area
write_160160(0, x); // write display address area
write_160160(0, 0x60 | ((y + m) & 0x0f)); // write display address area
write_160160(0, 0x70 | (((y + m) & 0xf0) >> 4)); // write display address area
for (k = 0; k < 2 * type; k++) //此循环显示汉字的时候执行4*6=24个字节(for循环中用dat0-dat6计算字模中的6个字节)
{
l = k * 6 + n; //l和n联合控制汉字高度因为是24*24所以每次执行4*6=24个循环 其中(4表示k的数据范围 6表示k的公倍数)
dat6 = 0x01 << j; //通过上一层j的for循环来取出没个字节中的8bit数据
dat0 = (*(p + l))&dat6;
dat0 = dat0 >> j;
dat0 <<= 7; //取出字模数组中第p+l个字节的第j位并移到第8位上
dat1 = (*(p + l + 1))&dat6;
dat1 = dat1 >> j;
dat1 <<= 3; //取出字模数组中第p+l+1个字节的第j位并移到第4位上
dat2 = *(p + 2 + l)&dat6;
dat2 = dat2 >> j;
dat2 <<= 7; //取出字模数组中第p+2个字节的第j位并移到第8位上
dat3 = (*(p + 3 + l))&dat6;
dat3 = dat3 >> j;
dat3 <<= 3; //取出字模数组中第p+l+3个字节的第j位并移到第4位上
dat4 = (*(p + 4 + l))&dat6;
dat4 = dat4 >> j;
dat4 <<= 7; //取出字模数组中第p+l+4个字节的第j位并移到第8位上
dat5 = (*(p + 5 + l))&dat6;
dat5 = dat5 >> j;
dat5 <<= 3; //取出字模数组中第p+l+5个字节的第j位并移到第4位上
write_160160(1, dat0 | dat1); //写入的数据是16进制包含2个字节数据 将dat0放到高4位 dat1放到第4位
write_160160(1, dat2 | dat3);
write_160160(1, dat4 | dat5);
}
write_160160(0, 0x88); //
}
}
write_160160(0, 0x89);
}
//--图形写入函数-------------------
// 图形格式要求:水平方向宽度要以3 和8 的倍数出现
// 8 的倍数是数据以字节形式出现
// 3 的倍数是因为DDRAM 列地址以列块形式计算的,即3 点像素数据为一个列块
void ShowBMP(uchar x,uchar y,uchar width,uchar high,uchar bmp[])
{
// 坐标X 为像素列块0-79 列块,3 像素点数据/列块
// 坐标Y 为像素点行数0-159
// 图形宽度width 为水平方向点列数,要求该值为3 和8 的倍数
// 图形高度high 为垂直方向点行数,取值为0-159
// 图形数组bmp[]为所要写入的图形数据,以1bpp(8dots/byte)、水平排列格式表示
uint p;
uchar i,j,k,m,Ddata;
write_160160(0,0xf4); write_160160(0,0x25+x); // 设置操作窗口左边界
write_160160(0,0xf5); write_160160(0,y); // 设置操作窗口上边界
write_160160(0,0xf6); write_160160(0,0x25+x+width/3-1); // 设置操作窗口右边界
write_160160(0,0xf7); write_160160(0,high-1+y); // 设置操作窗口下边界
write_160160(0,0xf8); // 设置窗口操作使能
x=x+0x25;
write_160160(0,x&0x0f); write_160160(0,0x10|(x>>4)); // 设置起始列地址
write_160160(0,0x60+(y&0x0f)); write_160160(0,0x70+(y>>4)); // 设置起始行地址
p=0; // 数组指针初始化
for(i=0;i<high;i++) // 循环行数数据量
{
for ( j=0;j<width/8;j++) // 循环字节数/行
{
k=bmp[p++]; // 取图形数据
for (m=0;m<4;m++) // 1 字节转换成4 字节数据写入
{
switch (k&0xc0) // 根据数据位值设置显示数据
{
case 0x00 : Ddata=0x00;break;
case 0x40 : Ddata=0x0f;break;
case 0x80 : Ddata=0xf0;break;
case 0xc0 : Ddata=0xff;break;
}
write_160160(1,Ddata); // 写入数据
k=k<<2;
}
}
switch (width%3)
{
case 0 : break;
case 1 : write_160160(1,0x00);break; //补充余数据为0
case 2 : write_160160(1,0x00); write_160160(1,0x00);break;// 补充余数据为0
}
}
}
void setup()
{
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(RST, OUTPUT);
pinMode(sda, OUTPUT);
pinMode(sck, OUTPUT);
pinMode(CS, OUTPUT);
pinMode(CD, OUTPUT);
pinMode(pinDHT11, OUTPUT);
Serial.begin(115200);
init160160();
words_1616(8,24,2,shi);
cleadlCD();
Serial.println("初始化完成");
}
void loop() {
words_2424(10, 1, 2, wen);
words_2424(18, 1, 2, du);
words_2424(26, 1, 1, abc);
words_2424(10, 25, 2, shi);
words_2424(18, 25, 2, du);
words_2424(26, 25, 1, abc);
Serial.println("=================================");
Serial.println("Sample DHT11...");
byte temperature = 0;
byte humidity = 0;
int err = SimpleDHTErrSuccess;
if ((err = dht11.read(&temperature, &humidity, NULL)) != SimpleDHTErrSuccess) {
Serial.print("Read DHT11 failed, err="); Serial.println(err);delay(1000);
return;
}
Serial.print("Sample OK: ");
Serial.print((int)temperature); Serial.print(" *C, ");
Serial.print((int)humidity); Serial.println(" H");
delay(1500);
num_str_2412(30,1,(int)temperature);
words_1616(39, 0, 1, O);
words_2424(42, 1, 1, C);
num_str_2412(30,25,(int)humidity);
words_2424(39, 25, 1, H);
num_str_2412(0,0,i);
i++;
if(i>30) i=0;
ShowBMP(10,50,120,110,col);
delay(1000);
Serial.println("start");
}
|