/*
  Simple "Hello World" for ILI9341 LCD

  https://wokwi.com/arduino/projects/308024602434470466
*/

#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"

#define TFT_DC 9
#define TFT_CS 10
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);

void setup() {
  tft.begin();

  
  // pipe - top
  tft.fillRect(180, 40, 40, 10, ILI9341_RED);

  // pipe - bottom
  tft.fillRect(180, 290, 40, 10, ILI9341_BLUE);

  // container
  tft.fillRect(80, 20, 100, 300, ILI9341_WHITE);

  // lines, from bottom to top
  tft.drawLine(10, 290, 80, 290, ILI9341_WHITE);
  tft.drawLine(10, 230, 80, 230, ILI9341_WHITE);
  tft.drawLine(10, 170, 80, 170, ILI9341_WHITE);
  tft.drawLine(10, 110, 80, 110, ILI9341_WHITE);
  tft.drawLine(10, 50, 80, 50, ILI9341_WHITE);

  // set text mode
  tft.setTextColor(ILI9341_WHITE);
  tft.setTextSize(2);

  // texts, from bottom to top
  tft.setCursor(5, 265);
  tft.println("15 st.");

  tft.setCursor(5, 205);
  tft.println("30 st.");




  // Meme reference: https://english.stackexchange.com/questions/20356/origin-of-i-can-haz
}

void loop() {
  // rendom temperature as percentage
  float temp = random(0, 100);

  // set text mode
  tft.setTextColor(ILI9341_BLACK);
  tft.setTextSize(2);

  // print temperature
  tft.setCursor(90, 100);
  tft.print(temp);
  tft.print(" %");

  delay(2500);

  // clear print position
  tft.fillRect(80, 100, 100, 15, ILI9341_WHITE);

 }
#include <OneWire.h>
#include <DallasTemperature.h>
// Data wire is plugged into port 2 on the Arduino
#define ONE_WIRE_BUS 2

// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
// Addresses of 3 DS18B20s
uint8_t dallas[8] = { 0x28, 0x61, 0x64, 0x11, 0x83, 0xC0, 0x7F, 0xD8 };
void setup(void)
{
Serial.begin(9600);
sensors.begin();
}
void loop(void)
{
sensors.requestTemperatures();
printTemperature(dallas);
Serial.println();
delay(1000);
}
void printTemperature(DeviceAddress deviceAddress)
{
float dallas1 = sensors.getTempC(dallas);
if(dallas1 == -127){
Serial.println("chyba");
Serial.println(dallas1);
}
if(dallas1 != -127){
Serial.println("ok");
}}