当前位置:网站首页>Arduino UNO驱动合宙1.8‘TFT SPI屏幕示例演示(含资料包)
Arduino UNO驱动合宙1.8‘TFT SPI屏幕示例演示(含资料包)
2022-07-28 21:39:00 【perseverance52】
Arduino UNO驱动合宙1.8"TFT SPI屏幕示例演示
- 效果展示


驱动参考资料包
- 来源于:http://www.lcdwiki.com/zh/1.8inch_Arduino_SPI_Module_ST7735S_SKU:MAR1801
- 资料包中2种驱动方式:模拟SPI和硬件SPI驱动方式
1.8inch Arduino SPI Module ST7735S都是一样的驱动芯片,直接利用该资料中的代码轻松点亮合宙1.8"tff屏幕
http://www.lcdwiki.com/res/Program/Arduino_SPI/1.8inch/Arduino_SPI_ST7735S_MAR1801_V1.0/1.8inch_Arduino_SPI_Module_ST7735S_MAR1801_V1.0.zip

接线说明
/ CS DC RST SDA CLK VCC GND
//Arduino Mega2560&Uno A5 A3 A4 A2 A1 3.3V GND
驱动显示演示代码
模拟SPI驱动
Demo不需要包含库直接编译。
#define CS A5
#define RS A3
#define RESET A4
#define SDA A2
#define SCK A1
//LED 不用接
#define LED A0 //if you don't need to control the LED pin,you should set it to -1 and set it to 3.3V
void Lcd_Writ_Bus(unsigned char d)
{
uint8_t val = 0x80;
while(val)
{
if(d&val)
{
digitalWrite(SDA,HIGH);
}
else
{
digitalWrite(SDA,LOW);
}
digitalWrite(SCK,LOW);
digitalWrite(SCK,HIGH);
val >>= 1;
}
}
void Lcd_Write_Com(unsigned char VH)
{
*(portOutputRegister(digitalPinToPort(RS))) &= ~digitalPinToBitMask(RS);//LCD_RS=0;
Lcd_Writ_Bus(VH);
}
void Lcd_Write_Data(unsigned char VH)
{
*(portOutputRegister(digitalPinToPort(RS)))|= digitalPinToBitMask(RS);//LCD_RS=1;
Lcd_Writ_Bus(VH);
}
void Lcd_Write_Com_Data(unsigned char com,unsigned char dat)
{
Lcd_Write_Com(com);
Lcd_Write_Data(dat);
}
void Address_set(unsigned int x1,unsigned int y1,unsigned int x2,unsigned int y2)
{
Lcd_Write_Com(0x2a);
Lcd_Write_Data(x1>>8);
Lcd_Write_Data(x1);
Lcd_Write_Data(x2>>8);
Lcd_Write_Data(x2);
Lcd_Write_Com(0x2b);
Lcd_Write_Data(y1>>8);
Lcd_Write_Data(y1);
Lcd_Write_Data(y2>>8);
Lcd_Write_Data(y2);
Lcd_Write_Com(0x2c);
}
void Lcd_Init(void)
{
digitalWrite(RESET,HIGH);
delay(5);
digitalWrite(RESET,LOW);
delay(15);
digitalWrite(RESET,HIGH);
delay(15);
digitalWrite(CS,LOW); //CS
Lcd_Write_Com(0x11);
delay(120);
Lcd_Write_Com(0xB1);
Lcd_Write_Data(0x05);
Lcd_Write_Data(0x3C);
Lcd_Write_Data(0x3C);
Lcd_Write_Com(0xB2);
Lcd_Write_Data(0x05);
Lcd_Write_Data(0X3C);
Lcd_Write_Data(0X3C);
Lcd_Write_Com(0xB3);
Lcd_Write_Data(0x05);
Lcd_Write_Data(0x3C);
Lcd_Write_Data(0x3C);
Lcd_Write_Data(0x05);
Lcd_Write_Data(0x3C);
Lcd_Write_Data(0x3C);
Lcd_Write_Com(0xB4);
Lcd_Write_Data(0x03);
Lcd_Write_Com(0xC0);
Lcd_Write_Data(0x28);
Lcd_Write_Data(0x08);
Lcd_Write_Data(0x04);
Lcd_Write_Com(0xC1);
Lcd_Write_Data(0xC0);
Lcd_Write_Com(0xC2);
Lcd_Write_Data(0x0D);
Lcd_Write_Data(0X00);
Lcd_Write_Com(0xC3);
Lcd_Write_Data(0x8D);
Lcd_Write_Data(0x2A);
Lcd_Write_Com(0xC4);
Lcd_Write_Data(0x8D);
Lcd_Write_Data(0xEE);
Lcd_Write_Com(0xC5);
Lcd_Write_Data(0x1A);
Lcd_Write_Com(0x17);
Lcd_Write_Data(0x05);
Lcd_Write_Com(0x36);
Lcd_Write_Data(0xD8);
Lcd_Write_Com(0xE0);
Lcd_Write_Data(0x03);
Lcd_Write_Data(0x22);
Lcd_Write_Data(0x07);
Lcd_Write_Data(0x0A);
Lcd_Write_Data(0x2E);
Lcd_Write_Data(0x30);
Lcd_Write_Data(0x25);
Lcd_Write_Data(0x2A);
Lcd_Write_Data(0x28);
Lcd_Write_Data(0x26);
Lcd_Write_Data(0x2E);
Lcd_Write_Data(0x3A);
Lcd_Write_Data(0x00);
Lcd_Write_Data(0x01);
Lcd_Write_Data(0x03);
Lcd_Write_Data(0x13);
Lcd_Write_Com(0xE1);
Lcd_Write_Data(0x04);
Lcd_Write_Data(0x16);
Lcd_Write_Data(0x06);
Lcd_Write_Data(0x0D);
Lcd_Write_Data(0x2D);
Lcd_Write_Data(0x26);
Lcd_Write_Data(0x23);
Lcd_Write_Data(0x27);
Lcd_Write_Data(0x27);
Lcd_Write_Data(0x25);
Lcd_Write_Data(0x2D);
Lcd_Write_Data(0x3B);
Lcd_Write_Data(0x00);
Lcd_Write_Data(0x01);
Lcd_Write_Data(0x04);
Lcd_Write_Data(0x13);
Lcd_Write_Com(0x3A);
Lcd_Write_Data(0x05);
Lcd_Write_Com(0x29);
digitalWrite(CS,HIGH);
}
void H_line(unsigned int x, unsigned int y, unsigned int l, unsigned int c)
{
unsigned int i,j;
digitalWrite(CS,LOW);
Lcd_Write_Com(0x02c); //write_memory_start
//digitalWrite(RS,HIGH);
l=l+x;
Address_set(x,y,l,y);
j=l*2;
for(i=1;i<=j;i++)
{
Lcd_Write_Data(c>>8);
Lcd_Write_Data(c);
}
digitalWrite(CS,HIGH);
}
void V_line(unsigned int x, unsigned int y, unsigned int l, unsigned int c)
{
unsigned int i,j;
digitalWrite(CS,LOW);
Lcd_Write_Com(0x02c); //write_memory_start
//digitalWrite(RS,HIGH);
l=l+y;
Address_set(x,y,x,l);
j=l*2;
for(i=1;i<=j;i++)
{
Lcd_Write_Data(c>>8);
Lcd_Write_Data(c);
}
digitalWrite(CS,HIGH);
}
void Rect(unsigned int x,unsigned int y,unsigned int w,unsigned int h,unsigned int c)
{
H_line(x , y , w, c);
H_line(x , y+h, w, c);
V_line(x , y , h, c);
V_line(x+w, y , h, c);
}
void Rectf(unsigned int x,unsigned int y,unsigned int w,unsigned int h,unsigned int c)
{
unsigned int i;
for(i=0;i<h;i++)
{
H_line(x , y , w, c);
H_line(x , y+i, w, c);
}
}
int RGB(int r,int g,int b)
{
return r << 16 | g << 8 | b;
}
void LCD_Clear(unsigned int j)
{
unsigned int i,m;
digitalWrite(CS,LOW);
Address_set(0,0,127,159);
for(i=0;i<128;i++)
for(m=0;m<160;m++)
{
Lcd_Write_Data(j>>8);
Lcd_Write_Data(j);
}
digitalWrite(CS,HIGH);
}
void setup()
{
pinMode(A0,OUTPUT);
pinMode(A3,OUTPUT);
pinMode(A4,OUTPUT);
pinMode(A5,OUTPUT);
pinMode(A1,OUTPUT);
pinMode(A2,OUTPUT);
digitalWrite(A0, HIGH);
digitalWrite(A3, HIGH);
digitalWrite(A4, HIGH);
digitalWrite(A5, HIGH);
digitalWrite(A1, HIGH);
digitalWrite(A2, HIGH);
Lcd_Init();
}
void loop()
{
LCD_Clear(0xf800);
LCD_Clear(0x07E0);
LCD_Clear(0x001F);
LCD_Clear(0x0);
for(int i=0;i<300;i++)
{
Rect(random(127),random(159),random(127),random(159),random(65535)); // rectangle at x, y, with, hight, color
}
// LCD_Clear(0xf800);
}
边栏推荐
- No code development platform management background tutorial
- Typescript防止基类被实例化
- Will Qualcomm and MediaTek chips soon be sold, and will they surpass Huawei to become the first in China?
- ValueError: Using a target size (torch.Size([64])) that is different to the input size (torch.Size([
- 安全狗入选《云安全全景图2.0》多个细项
- MySQL常用的日期时间函数
- The US FCC provided us $1.6 billion to support domestic operators to remove Huawei and ZTE equipment
- Sdwebimage source code comb 4 # introduce several usages of existing code
- CGLIb 创建代理
- Sqlilabs-2 (breakthrough record)
猜你喜欢

【物理应用】水下浮动风力涡轮机的尾流诱导动态模拟风场附matlab代码

《MySQL数据库进阶实战》读后感(SQL 小虚竹)

业界首创云原生安全检测双模型!安全狗重磅报告亮相数字中国建设峰会

Basic concept of MySQL database and deployment of MySQL version 8.0 (I)
![[physical application] Wake induced dynamic simulation of underwater floating wind turbine wind field with matlab code](/img/31/e4cd4c261a7fc5cfa731976314530b.png)
[physical application] Wake induced dynamic simulation of underwater floating wind turbine wind field with matlab code
![[physical application] atmospheric absorption loss with matlab code](/img/72/e6ac23012a59ac48a37bcbb068890b.png)
[physical application] atmospheric absorption loss with matlab code

Thesis reading (3) - googlenet of classification

No code development platform management background tutorial

Rouyi cloud platform - how to realize the launch and login functions of the project and how to create new modules

Sdwebimage source code combs 5 author motivation, modifies directory, and changes inheritance relationship
随机推荐
Runloop, auto release pool, thread, GCD
Target detection notes -yolo
Failure [INSTALL_FAILED_TEST_ONLY: installPackageLI]
Text is hidden beyond and ellipsis is displayed
Cnpm installation steps
[physical application] Wake induced dynamic simulation of underwater floating wind turbine wind field with matlab code
Solve the exception that all control files are damaged
All aspect visual monitoring of istio microservice governance grid (microservice architecture display, resource monitoring, traffic monitoring, link monitoring)
DirectX repair tool download (where is exagear simulator package)
Introduction to original code, inverse code and complement code
xshell7,xftp7个人免费版官方下载,无需破解,免激活,下载即可使用
Hands on Teaching of servlet use (1)
Advanced C language: pointer (3)
Binary search tree
WebView whitelist
[mongodb] basic use of mongodb database, special cases, and the installation and creation process of mongoose (including the installation of mongoose fixed version)
Invest 50billion yuan! SMIC capital was officially registered!
Leetcode 199. right view of binary tree
Performance optimized APK slimming
In 2020, the top ten domestic IC design enterprises will be exposed! These five industrial challenges still need to be overcome!