Closed manroop5 closed 3 years ago
Hi!
Thanks for using the code I provided! Unfortunately as I don't have the hardware you use and cannot reproduce the problems you describe, I cannot support in this case.
The hardware specified by your code is the same ILI9431 chipset which is basis for Adafruit tft feather
Hello I have been trying to compile your code for use in sps30 and bme280 sensor. The code compiles but the screen remains blank. Please suggests changes
It is mainly unchanegd from your code however i specified spi connections in the code in place of settings. Also the display example which is working for me has same pin connections only few lines different Adafruit_ILI9341 instead of ILI9341_SPI. If i change it to adafruit_ILI9341 then Minigrafx gets messed up.
/* The MIT License (MIT) based on the esp8266-weather-station by 2018 by Daniel Eichhorn Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. See more at https://blog.squix.org /
/***** Important: see settings.h to configure your settings!!!
include
include
include
include
include
include
include
include
include
include
include
include
include
include "settings.h"
include "settings_private.h"
include "ArialRounded.h"
include "weathericons.h"
include "OpenWeatherMapCurrent.h"
include "OpenWeatherMapForecast.h"
define TFT_DC 2 // Data Command control pin
define TFT_CS 15 // Chip select control pin
define TFT_MOSI 23
define TFT_CLK 18
define TFT_RST 4 // Reset pin (could connect to RST pin)
define TFT_MISO 19
define TFT_LED 22
// Touch SPI
define HAVE_TOUCHPAD
define TOUCH_CS 33 // Chip select pin (T_CS) of touch screen
define TOUCH_IRQ 35
//#define _sclk 25 //#define _mosi 32 //#define _miso 39
define MINI_BLACK 0
define MINI_WHITE 1
define MINI_YELLOW 2
define MINI_BLUE 3
define MINI_BLACK 0
define MINI_WHITE 1
define MINI_YELLOW 2
define MINI_BLUE 3
define BACKLIGHT_PWM_FRQ 5000
define BACKLIGHT_PWM_RES 8
define BACKLIGHT_PWM_CHN 0
// defines the colors usable in the paletted 16 color frame buffer uint16_t palette[] = {ILI9341_BLACK, // 0 ILI9341_WHITE, // 1 ILI9341_YELLOW, // 2 0x7E3C }; //3
// Limited to 4 colors due to memory constraints int BITS_PER_PIXEL = 2; // 2^2 = 4 colors
ILI9341_SPI tft = ILI9341_SPI(TFT_CS, TFT_DC); MiniGrafx gfx = MiniGrafx(&tft, BITS_PER_PIXEL, palette);
OpenWeatherMapCurrentData currentWeather; OpenWeatherMapForecastData forecasts[MAX_FORECASTS]; simpleDSTadjust dstAdjusted(StartRule, EndRule); Adafruit_BME280 bme280;
void updateWeatherData(); void updateSensorData(); void drawProgress(uint8_t percentage, String text); void drawTime(); void drawWifiQuality(); void drawCurrentWeather(); void drawForecast(int16_t x, int16_t y); void drawForecastDetail(uint16_t x, uint16_t y, uint8_t dayIndex); void drawSensorValues();
const char getMeteoconIconFromProgmem(String iconText); const char getMiniMeteoconIconFromProgmem(String iconText);
time_t dstOffset = 0; float temp = 0; float humidity = 0; float pressure = 0; int spsState = 0; struct sps30_measurement sps30Data;
void connectWifi() {
}
void setup() { int16_t result;
}
void loop() { Serial.println(F("Benchmark Time (microseconds)")); delay(10); Serial.print(F("Screen fill ")); delay(500);
}
void sendDataToOpenSenseMap() {
}
// Update the sensor data void updateSensorData() {
}
// Update the internet based information and update screen void updateWeatherData() {
}
// Progress bar helper void drawProgress(uint8_t percentage, String text) { gfx.fillBuffer(MINI_BLACK); gfx.setColor(MINI_YELLOW);
}
// Draw the clock void drawTime() {
}
// draws current weather information void drawCurrentWeather() { gfx.setTransparentColor(MINI_BLACK); gfx.drawPalettedBitmapFromPgm(0, 55, getMeteoconIconFromProgmem(currentWeather.icon)); // Weather Text
}
void drawForecast(int16_t x, int16_t y) { drawForecastDetail(x + 10, y + 165, 0); drawForecastDetail(x + 95, y + 165, 1); drawForecastDetail(x + 180, y + 165, 2); }
// helper for the forecast columns void drawForecastDetail(uint16_t x, uint16_t y, uint8_t dayIndex) { gfx.setColor(MINI_YELLOW); gfx.setFont(ArialRoundedMTBold_14); gfx.setTextAlignment(TEXT_ALIGN_CENTER); time_t time = forecasts[dayIndex].observationTime + dstOffset; struct tm * timeinfo = localtime (&time); gfx.drawString(x + 25, y - 15, WDAY_NAMES[timeinfo->tm_wday] + " " + String(timeinfo->tm_hour) + ":00");
}
void drawSensorValues() { gfx.setTextAlignment(TEXT_ALIGN_LEFT); gfx.setColor(MINI_YELLOW); gfx.drawString(10, 250, "Temp:"); gfx.drawString(10, 265, "Druck:"); gfx.drawString(10, 280, "rel. LF:"); gfx.drawString(10, 295, "SPS30:"); gfx.drawString(150, 250, "PM 1.0:"); gfx.drawString(150, 265, "PM 2.5:"); gfx.drawString(150, 280, "PM 4.0:"); gfx.drawString(150, 295, "PM 10.0:");
}
// converts the dBm to a range between 0 and 100% int8_t getWifiQuality() { int32_t dbm = WiFi.RSSI(); if (dbm <= -100) { return 0; } else if (dbm >= -50) { return 100; } else { return 2 * (dbm + 100); } }
void drawWifiQuality() { int8_t quality = getWifiQuality(); gfx.setColor(MINI_WHITE); gfx.setTextAlignment(TEXT_ALIGN_RIGHT); gfx.drawString(228, 9, String(quality) + "%"); for (int8_t i = 0; i < 4; i++) { for (int8_t j = 0; j < 2 (i + 1); j++) { if (quality > i 25 || j == 0) { gfx.setPixel(230 + 2 * i, 18 - j); } } } }