From e2854ca19b73bbd93b680d15b26ff0bb5fb5f6e3 Mon Sep 17 00:00:00 2001 From: Dankao <116425012+Reikimen@users.noreply.github.com> Date: Sat, 15 Jul 2023 23:25:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A30.2.1=E7=9A=84LCD=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修正0.2.1的LCD显示问题 --- .../GreenBox.0.2.1-beta.ino | 2 -- .../GreenBox.0.2.1-beta/GreenBox_Define.h | 2 +- .../GreenBox.0.2.1-beta/GreenBox_Function.h | 27 +++++++++++++------ 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/ESP8266_GreenBox/GreenBox.0.2.1-beta/GreenBox.0.2.1-beta.ino b/ESP8266_GreenBox/GreenBox.0.2.1-beta/GreenBox.0.2.1-beta.ino index 17be14e..988a075 100644 --- a/ESP8266_GreenBox/GreenBox.0.2.1-beta/GreenBox.0.2.1-beta.ino +++ b/ESP8266_GreenBox/GreenBox.0.2.1-beta/GreenBox.0.2.1-beta.ino @@ -2,9 +2,7 @@ #include "GreenBox_Function.h" void setup() { setup_function(); - delay(2000); // the time used to setup } void loop() { loop_function(); - delay(500); // 500 milliseconds as a unit of time measurement } \ No newline at end of file diff --git a/ESP8266_GreenBox/GreenBox.0.2.1-beta/GreenBox_Define.h b/ESP8266_GreenBox/GreenBox.0.2.1-beta/GreenBox_Define.h index 7d508c7..0105e50 100644 --- a/ESP8266_GreenBox/GreenBox.0.2.1-beta/GreenBox_Define.h +++ b/ESP8266_GreenBox/GreenBox.0.2.1-beta/GreenBox_Define.h @@ -115,6 +115,6 @@ int count_water = 0; // 5000ms 监测一次 int count_light = 0; // 1000ms 监测一次 int count_CO2 = 0; // 1000ms 监测一次 int count_wattmeter = 0; // 1000ms 监测一次 -int count_wind = 0; // 60000ms = 1min 更改一次 +int count_wind = 0; // 6000ms 更改一次 int count_led = 0; // 5000ms 更改一次 int count_lcd = 0; // 根据显示的需求可以调整 diff --git a/ESP8266_GreenBox/GreenBox.0.2.1-beta/GreenBox_Function.h b/ESP8266_GreenBox/GreenBox.0.2.1-beta/GreenBox_Function.h index fe191de..714f52f 100644 --- a/ESP8266_GreenBox/GreenBox.0.2.1-beta/GreenBox_Function.h +++ b/ESP8266_GreenBox/GreenBox.0.2.1-beta/GreenBox_Function.h @@ -22,7 +22,7 @@ void measure_sht30(){ Wire.write(0x2C); Wire.write(0x06); Wire.endTransmission(); - //delay(100); + delay(100); //停止IIC,并且等待sht30的读数 //请求获取6字节的数据,然后会存到8266的内存里 @@ -250,6 +250,7 @@ void lcd_display_Temp_Humidity(){ LCD1602.print(sht30_humidity); LCD1602.setCursor(11, 1);//光标移动到第1行的第12个字符开始显示 LCD1602.print(" RH%"); + } void lcd_display_CO2_Light(){ @@ -268,6 +269,7 @@ void lcd_display_CO2_Light(){ LCD1602.print(VEML7700_light); LCD1602.setCursor(11, 1);//光标移动到第1行的第12个字符开始显示 LCD1602.print(" lx"); + } void lcd_display_water(){ // water depth @@ -278,6 +280,7 @@ void lcd_display_water(){ LCD1602.print(water_depth); LCD1602.setCursor(11, 0);//光标移动到第1行的第12个字符开始显示 LCD1602.print(" cm"); + } ////////////////////////////////////////////////// Control Logic ////////////////////////////////////////////////// @@ -295,15 +298,20 @@ void setup_function(){ WiFi_connection(); // Hardware initialization lcd_init(); // hello Liang delay 2000 - VEML7700.begin(); // Light - SG90_WIND.attach(PIN_SG90_WIND); LED_RGB.begin(); LED_RGB.setBrightness(255); LED_RGB.setPixelColor(0,LED_RGB.Color(255, 255, 255)); //最高亮度白色,只亮第一个LED LED_RGB.show(); //刷新显示 + VEML7700.begin(); // Light + SG90_WIND.attach(PIN_SG90_WIND); wattmeter_initialization(); pinMode(CO2_SENSOR_DATA_PIN, INPUT); attachInterrupt(INTERRUPT_NUMBER, CO2_InterruptFunc, CHANGE); + + delay(2000); // the time used to setup + + control_led_rgb(); + delay(2000); } ////////////////////////////////////////////////// Loop Function ////////////////////////////////////////////////// void loop_function(){ @@ -339,7 +347,7 @@ void loop_function(){ count_wattmeter = 0; measure_wattmeter(); } - if (count_wind >= 120){ // 60000ms = 1min 更改一次 + if (count_wind >= 12){ // 6000ms = 10s 更改一次 count_wind = 0; control_wind(); } @@ -347,14 +355,17 @@ void loop_function(){ count_led = 0; control_led_rgb(); } - if (count_lcd = 5){ // 根据显示的需求可以调整 + + if (count_lcd == 5){ // 根据显示的需求可以调整 lcd_display_Temp_Humidity(); } - else if (count_lcd = 10){ + if (count_lcd == 10){ lcd_display_CO2_Light(); } - else if (count_lcd >= 13){ + if (count_lcd >= 15){ count_lcd = 0; - lcd_display_water(); + lcd_display_water(); } + + delay(500); // 500 milliseconds as a unit of time measurement } \ No newline at end of file