esp82661.44寸tft屏幕显示刷新问题-Arduino中文社区 - Powered by Discuz!

Arduino中文社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 1432|回复: 0

esp82661.44寸tft屏幕显示刷新问题

[复制链接]
发表于 2021-10-12 16:17 | 显示全部楼层 |阅读模式
本帖最后由 wo116114 于 2021-10-12 16:23 编辑

以下是代码
  1. <font _mstmutation="1">#include <Adafruit_GFX.h>    // Core graphics library
  2. #include <Adafruit_ST7735.h>
  3. #include <SPI.h>
  4. #include <DHT.h>
  5. #define DHTPIN     12
  6. #define TFT_CS     D1
  7. #define TFT_RST    D2
  8. #define TFT_DC     D3
  9. #define DHTTYPE DHT22
  10. DHT dht(DHTPIN, DHTTYPE);

  11. Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS,  TFT_DC, TFT_RST);
  12. #define TFT_SCLK 13   // set these to be whatever pins you like!
  13. #define TFT_MOSI 11
  14. unsigned char quan[] = {0x00,0x00,0x00,0x44,0xA4,0xA8,0xA8,0xB0,0x54,0x1A,0x2A,0x2A,0x4A,0x44,0x00,0x00};
  15. unsigned char zhou[] = {0x10,0x04,0x10,0x84,0x10,0x84,0x10,0x84,0x10,0x84,0x54,0xA4,0x52,0x94,0x52,0x94,0x90,0x84,0x10,0x84,0x10,0x84,0x10,0x84,0x20,0x84,0x20,0x84,0x40,0x04,0x80,0x04};
  16. unsigned char wen[] = {0x00,0x00,0x23,0xF8,0x12,0x08,0x12,0x08,0x83,0xF8,0x42,0x08,0x42,0x08,0x13,0xF8,0x10,0x00,0x27,0xFC,0xE4,0xA4,0x24,0xA4,0x24,0xA4,0x24,0xA4,0x2F,0xFE,0x00,0x00};
  17. unsigned char du[] = {0x01,0x00,0x00,0x80,0x3F,0xFE,0x22,0x20,0x22,0x20,0x3F,0xFC,0x22,0x20,0x22,0x20,0x23,0xE0,0x20,0x00,0x2F,0xF0,0x24,0x10,0x42,0x20,0x41,0xC0,0x86,0x30,0x38,0x0E};
  18. unsigned char shi[] = {0x00,0x00,0x27,0xF8,0x14,0x08,0x14,0x08,0x87,0xF8,0x44,0x08,0x44,0x08,0x17,0xF8,0x11,0x20,0x21,0x20,0xE9,0x24,0x25,0x28,0x23,0x30,0x21,0x20,0x2F,0xFE,0x00,0x00};
  19. unsigned char wendu[] = {0x60,0x00,0x91,0xF4,0x96,0x0C,0x6C,0x04,0x08,0x04,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x08,0x00,0x0C,0x04,0x06,0x08,0x01,0xF0,0x00,0x00};
  20. unsigned char re[] = {0x10,0x40,0x10,0x40,0x10,0x40,0xFD,0xF8,0x10,0x48,0x10,0x48,0x1C,0xC8,0x30,0x48,0xD0,0xAA,0x10,0xAA,0x51,0x06,0x22,0x02,0x00,0x00,0x48,0x88,0x44,0x44,0x84,0x44};
  21. unsigned char zhi[] = {0x11,0x00,0x11,0x04,0x11,0x38,0x11,0xC0,0xFD,0x02,0x11,0x02,0x10,0xFE,0x14,0x00,0x19,0xFC,0x31,0x04,0xD1,0x04,0x11,0xFC,0x11,0x04,0x11,0x04,0x51,0xFC,0x21,0x04};
  22. unsigned char shu[] = {0x08,0x20,0x49,0x20,0x2A,0x20,0x08,0x3E,0xFF,0x44,0x2A,0x44,0x49,0x44,0x88,0xA4,0x10,0x28,0xFE,0x28,0x22,0x10,0x42,0x10,0x64,0x28,0x18,0x28,0x34,0x44,0xC2,0x82};
  23. void setup() {
  24.   // put your setup code here, to run once:
  25. tft.initR(INITR_144GREENTAB);
  26. //tft.fillScreen(ST7735_BLACK);
  27. Serial.println("init");
  28. Serial.begin(9600);
  29. Serial.println(F("DHTxx test!"));
  30. dht.begin();
  31. }
  32. void printChinese(uint x,uint y,unsigned char *Hz_code)
  33. {
  34. int tbl_size=sizeof(Hz_code)/sizeof(char);

  35. short int temp_code=0;
  36. int i,j,k;

  37. for(i=0;i<16;i++)
  38. for(j=0;j<2;j++)
  39. for(k=0;k<8;k++)

  40. if(((Hz_code[i*2+j]>>(7-k))&0x1)!=NULL)
  41. //}
  42. tft.drawPixel(x+8*j+k,y+i, ST7735_RED);
  43. }

  44. void loop() {
  45. delay(2000);
  46. /*tft.setCursor(39,20);
  47.   tft.setTextPadding();
  48.   tft.setCursor(39,0);
  49.   tft.setTextPadding();
  50.   tft.setCursor(55,40);
  51.   tft.setTextPadding();*/
  52. //  tft.setTextWrap(true);
  53.   tft.fillScreen(ST7735_BLACK);
  54.   // Reading temperature or humidity takes about 250 milliseconds!
  55.   // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  56.   float h = dht.readHumidity();
  57.   // Read temperature as Celsius (the default)
  58.   float t = dht.readTemperature();
  59.   // Read temperature as Fahrenheit (isFahrenheit = true)
  60.   float f = dht.readTemperature(true);

  61.   // Check if any reads failed and exit early (to try again).
  62.   if (isnan(h) || isnan(t) || isnan(f)) {
  63.     Serial.println(F("Failed to read from DHT sensor!"));
  64.     return;
  65.   }
  66.   float hif = dht.computeHeatIndex(f, h);
  67.   // Compute heat index in Celsius (isFahreheit = false)
  68.   float hic = dht.computeHeatIndex(t, h, false);
  69. tft.setTextColor(ST7735_GREEN);
  70. tft.setTextSize(2);
  71.   Serial.print(F("Humidity: "));
  72.   Serial.print(h);
  73.   Serial.print(F("%  Temperature: "));
  74.   Serial.print(t);
  75.   Serial.print(F("°C "));
  76.   Serial.print(f);
  77.   Serial.print(F("°F  Heat index: "));
  78.   Serial.print(hic);
  79.   Serial.print(F("°C "));
  80.   Serial.print(hif);
  81.   Serial.println(F("°F"));
  82.   tft.setCursor(39,20);
  83.   tft.print(h);
  84.   tft.setCursor(39,0);
  85.   tft.print(t);
  86.   tft.setCursor(101,20);
  87.   tft.print("%");
  88.   tft.setCursor(55,40);
  89.   tft.print(hic);
  90. // Serial.println(tft.getRotation(), DEC);


  91. //tft.WindowMax(0,30,16,46);
  92. tft.setCursor(0, 0);

  93. printChinese(4,0,wen);
  94. printChinese(20,0,du);
  95. printChinese(4,20,shi);
  96. printChinese(20,20,du);
  97. printChinese(100,0,wendu);
  98. printChinese(4,40,re);
  99. printChinese(20,40,zhi);
  100. printChinese(36,40,shu);
  101. printChinese(114,40,wendu);</font>
  102. }
复制代码
目前无法解决屏幕数字重影只能用黑色背景覆盖求解决另外dht22温湿度传感器无法显示负温度会溢出
大神们是怎么写的




您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|Archiver|手机版|Arduino中文社区

GMT+8, 2024-11-28 09:45 , Processed in 0.247781 second(s), 15 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表