• Уважаемые посетители сайта esp8266.ru!
    Мы отказались от размещения рекламы на страницах форума для большего комфорта пользователей.
    Вы можете оказать посильную поддержку администрации форума. Данные средства пойдут на оплату услуг облачных провайдеров для сайта esp8266.ru
  • Система автоматизации с открытым исходным кодом на базе esp8266/esp32 микроконтроллеров и приложения IoT Manager. Наша группа в Telegram

tft 1.8 st7735

kolkpetkinsyn

New member
Помогите вывести информацию с датчика bmp280 на дисплей

библиотека adafruit/Adafruit-ST7735-Library

в попытке вывода одного блока информации на дисплей, сократил скетч из примера до:
Код:
#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library for ST7735
#include <Adafruit_ST7789.h> // Hardware-specific library for ST7789
#include <SPI.h>

#ifdef ADAFRUIT_HALLOWING
  #define TFT_CS        39 // Hallowing display control pins: chip select
  #define TFT_RST       37 // Display reset
  #define TFT_DC        38 // Display data/command select
  #define TFT_BACKLIGHT  7 // Display backlight pin
#else
  // For the breakout board, you can use any 2 or 3 pins.
  // These pins will also work for the 1.8" TFT shield.
  #define TFT_CS        10
  #define TFT_RST        9 // Or set to -1 and connect to Arduino RESET pin
  #define TFT_DC         8
#endif

// OPTION 1 (recommended) is to use the HARDWARE SPI pins, which are unique
// to each board and not reassignable. For Arduino Uno: MOSI = pin 11 and
// SCLK = pin 13. This is the fastest mode of operation and is required if
// using the breakout board's microSD card.

// For 1.44" and 1.8" TFT with ST7735 (including HalloWing) use:
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);

// For 1.54" TFT with ST7789:
//Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST);

// OPTION 2 lets you interface the display using ANY TWO or THREE PINS,
// tradeoff being that performance is not as fast as hardware SPI above.
//#define TFT_MOSI 11  // Data out
//#define TFT_SCLK 13  // Clock out
//Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);

float p = 3.1415926;

void setup(void) {
  Serial.begin(9600);
  Serial.print(F("Hello! ST77xx TFT Test"));

#ifdef ADAFRUIT_HALLOWING
  tft.initR(INITR_HALLOWING);        // Initialize HalloWing-oriented screen
  pinMode(TFT_BACKLIGHT, OUTPUT);
  digitalWrite(TFT_BACKLIGHT, HIGH); // Backlight on
#else
  tft.initR(INITR_BLACKTAB);      // Init ST7735S chip, black tab
#endif

  Serial.println(F("Initialized"));

  uint16_t time = millis();
  tft.fillScreen(ST77XX_BLACK);
  time = millis() - time;

  Serial.println(time, DEC);
  delay(500);


  Serial.println("done");
  delay(1000);
}

void loop() {
  tft.invertDisplay(true);
  delay(500);
  tft.invertDisplay(false);
  delay(500);
}

void tftPrintTest() {
  tft.setTextWrap(false);
  tft.fillScreen(ST77XX_BLACK);
  tft.setCursor(0, 30);
  tft.setTextColor(ST77XX_RED);
  tft.setTextSize(1);
  tft.println("Hello World!");
  tft.setTextColor(ST77XX_YELLOW);
  tft.setTextSize(2);
  tft.println("Hello World!");
  tft.setTextColor(ST77XX_GREEN);
  tft.setTextSize(3);
  tft.println("Hello World!");
  tft.setTextColor(ST77XX_BLUE);
  tft.setTextSize(4);
  tft.print(1234.567);
  delay(1500);
  tft.setCursor(0, 0);
  tft.fillScreen(ST77XX_BLACK);
  tft.setTextColor(ST77XX_WHITE);
  tft.setTextSize(0);
  tft.println("Hello World!");
  tft.setTextSize(1);
  tft.setTextColor(ST77XX_GREEN);
  tft.print(p, 6);
  tft.println(" Want pi?");
  tft.println(" ");
  tft.print(8675309, HEX); // print 8,675,309 out in HEX!
  tft.println(" Print HEX!");
  tft.println(" ");
  tft.setTextColor(ST77XX_WHITE);
  tft.println("Sketch has been");
  tft.println("running for: ");
  tft.setTextColor(ST77XX_MAGENTA);
  tft.print(millis() / 1000);
  tft.setTextColor(ST77XX_WHITE);
  tft.print(" seconds.");
}

но не работает, только белый экран(

Мне бы пример, вывода на экран одного слова, а дальше я бы сам.

Ну или вывод одного параметра из моего проекта:

Код:
#include <Adafruit_Sensor.h>

#include <Wire.h>

#include <CayenneMQTTESP8266.h>

#include <Adafruit_BMP280.h>

#include <SimpleTimer.h>

extern "C" {
#include "user_interface.h";
}
char ssid[] = "ASUS-CDC0" ;
char wifiPassword[] = "00000000" ;
SimpleTimer timer;
char username[] = "be69a3f0-5d168a516101" ;
char password[] = "3f6b82d32ed8fd523c5857b9" ;
char clientID[] = "ecff01c0-3ee3d2557533" ;
float in_216184383_1;
float in_216184383_2;
float Temperature_145241870_1;
float Pressure_145241870_1;
float Altitude_145241870_1;
#define SEALEVELPRESSURE_HPA_145241870_1 (1013.25)

Adafruit_BMP280 bmp_145241870_1; // I2C
float in_216184383_3;
int in_216184383_4;
int ESP8266_AnalogInputValue;
unsigned long ESP8266_AnalogInputValue_StR;
void setup()
{
ESP8266_AnalogInputValue_StR = millis() + 500 ;
Cayenne.begin(username, password, clientID, ssid, wifiPassword);
timer.setInterval(5000L, sendUptime_216184383_1);
timer.setInterval(30000L, sendUptime_216184383_2);
if (!bmp_145241870_1.begin()) {
   bmp_145241870_1.readTemperature();
    while (1);
}
timer.setInterval(300000L, sendUptime_216184383_3);
timer.setInterval(1500L, sendUptime_216184383_4);
}
void loop()
{if(_isTimer(ESP8266_AnalogInputValue_StR, 500))
{
ESP8266_AnalogInputValue_StR = millis();
ESP8266_AnalogInputValue = analogRead(A0);
}

//Плата:1
//Наименование:Esp
Cayenne.loop();
  timer.run();
{
Temperature_145241870_1 = bmp_145241870_1.readTemperature();
Pressure_145241870_1 = bmp_145241870_1.readPressure() / 100.0F * 0.7500;
Altitude_145241870_1 = bmp_145241870_1.readAltitude(1032.4);
}
in_216184383_3 = Altitude_145241870_1;

in_216184383_2 = Pressure_145241870_1;

in_216184383_1 = Temperature_145241870_1;

in_216184383_4 = ESP8266_AnalogInputValue;
}

bool _isTimer(unsigned long startTime, unsigned long period )
  {
  unsigned long currentTime;
currentTime = millis();
if (currentTime>= startTime) {return (currentTime>=(startTime + period));} else {return (currentTime >=(4294967295-startTime+period));}
  }
void sendUptime_216184383_1()
{
Cayenne.virtualWrite( 0 ,  in_216184383_1 );
}
void sendUptime_216184383_2()
{
Cayenne.virtualWrite( 1 ,  in_216184383_2 );
}
void sendUptime_216184383_3()
{
Cayenne.virtualWrite( 2 ,  in_216184383_3 );
}
void sendUptime_216184383_4()
{
Cayenne.virtualWrite( 3 ,  in_216184383_4 );
}
 
Последнее редактирование модератором:

Сергей_Ф

Moderator
Команда форума
@Юрий Ботов ну почему же? Теперь понятно, что пример для st7735 для AVR, а не для ESP.
@kolkpetkinsyn вы уверены что библиотека работоспособна с esp? Как минимум, надо поменять управляющие пины для экрана.
 
Сверху Снизу