- fchao-Sinus-Wechselrichter AliExpress         
Ergebnis 1 bis 6 von 6

Thema: Temperatur auf Display ausgeben läuft - fast

Baum-Darstellung

Vorheriger Beitrag Vorheriger Beitrag   Nächster Beitrag Nächster Beitrag
  1. #1
    Neuer Benutzer Öfters hier
    Registriert seit
    05.03.2011
    Ort
    Neuburg a.d. Donau
    Alter
    63
    Beiträge
    7

    Idee Temperatur auf Display ausgeben läuft - fast

    Hallo Leute,
    Ich benutze ein HX8357C 3" Display am Arduino Mega 2560, das mir 2 Temperaturen über Dallas 18B20 anzeigen soll.

    Als absoluter Noob in C, hab ich zum laufen gebracht:

    1); aus beiden 18B20 Temperatur auslesen funktioniert

    2); die Anzeige zu formatieren funktioniert auch. Aller Code dazu steht im void setup (//runs once!) , so das eine saubere Anzeige da ist.
    im void loop (// runs forever!) schreibe ich die zwei Temperaturen ins Display. - funktioniert ; Temperaturänderungen werden übernommen.

    3); my flaw in the plan: Jede neue Messung überschreibt die alte Anzeige, aber ohne sie zu löschen. Bei 5 Messungen liegen 5 Werte übereinander.
    Wie lösche ich den alten Wert aus dem Display, wenn der neue geschrieben wird?

    Code:
    
    /*
      Test the tft.print() viz the libraries embedded write() function
    
      Make sure all the required fonts are loaded by editting the
      User_Setup.h file in the TFT_ILI9341 library folder.
    
      #########################################################################
      ###### DON'T FORGET TO UPDATE THE User_Setup.h FILE IN THE LIBRARY ######
      #########################################################################
      changed by dh4mbm 2016.11.06 uses Dallas DS18B20 temperature sensor
       * partial Working Sketch * 480 x 320 Display is working * refreshes Temp, overides Temp in display, without deleting previous drawn digits*
    */
    
    #include <OneWire.h>
    #include <DallasTemperature.h>
    
    #define ONE_WIRE_BUS_1 2
    #define ONE_WIRE_BUS_2 4
    
    OneWire oneWire_in(ONE_WIRE_BUS_1); 
    OneWire oneWire_out(ONE_WIRE_BUS_2);
    
    DallasTemperature sensor_inhouse(&oneWire_in);
    DallasTemperature sensor_outhouse(&oneWire_out);
    
    #include <TFT_HX8357.h> // Hardware-specific library
    byte fontSize4 = 4; //  26 px, FontSize 4, 6, 7, 8  
    byte fontSize6 = 6; // 48 px
    
    TFT_HX8357 tft = TFT_HX8357();       // Invoke custom library
    
    int timer1 = (3000);
    
    void setup(void) {
      tft.init();
      tft.setRotation(1);
      sensor_inhouse.begin();  
      sensor_outhouse.begin(); 
      // delay(timer1);
    
      /* Fill screen with colour so we can see the effect of printing with and without
        code color
      */
      tft.fillScreen(TFT_YELLOW); // TFT_YELLOW = Blue - TFT_BLUE = YELLOW
    
      tft.setTextColor(TFT_BLUE); // TFT_WHITE = Black - TFT_BLUE = White  << Das muß raus, dann gehts! 
    
      tft.setCursor(40, 48, fontSize4); //shift Cursor in Pixel (Collum, Row, Fontsize)
      tft.setTextFont(fontSize4);
      tft.println("Dallas TwoPin_DS18B20");
      
      // Set "cursor" at top left corner of display (0,0) and select font 4
      // (cursor will move to next line automatically during printing with 'tft.println'
      //  or stay on the line is there is room for the text with tft.print)
    
      tft.setCursor(40, 172, fontSize4); //shift Cursor in Pixel (Collum, Row, Fontsize)
      tft.print("Inhouse: ");
      tft.setCursor(380, 172, fontSize4); //shift Cursor in Pixel (Collum, Row, Fontsize)
      tft.print("Degree ");
      
      tft.setCursor(40, 248, fontSize4);
      tft.print("Outhouse: ");
      tft.setCursor(380, 248, fontSize4); //shift Cursor in Pixel (Collum, Row, Fontsize)
      tft.print("Degree ");
    }
    
    void loop() {   
    
    tft.setCursor(40, 98, fontSize4); // Spalte, Zeile, Font
      tft.println("Requesting temperatures...");
      sensor_inhouse.requestTemperatures();
      sensor_outhouse.requestTemperatures();
      
      tft.setCursor(190, 172, fontSize6); //shift Cursor in Pixel (Collum, Row, Fontsize)
      tft.print(sensor_inhouse.getTempCByIndex(0)); //writes temperature from pin 2
    
       tft.setCursor(190, 248, fontSize6);
      tft.print(sensor_outhouse.getTempCByIndex(0)); //writes temperature from pin 4
     
    }
    Geändert von DH4MBM (09.11.2016 um 21:34 Uhr)

Ähnliche Themen

  1. Nibobee (fast) nichts läuft - Anfänger
    Von BeeAnfaenger im Forum Sonstige Roboter- und artverwandte Modelle
    Antworten: 24
    Letzter Beitrag: 31.01.2013, 18:30
  2. [ERLEDIGT] LM75 Auswerten und Temperatur über terminal ausgeben?
    Von Ferdinand im Forum C - Programmierung (GCC u.a.)
    Antworten: 13
    Letzter Beitrag: 03.06.2012, 20:25
  3. Lego Cybermaster läuft fast wieder
    Von schrauber 93 im Forum Elektronik
    Antworten: 0
    Letzter Beitrag: 19.01.2010, 17:34
  4. Temperatur auf drei 7-Segment-Anzeigen ausgeben
    Von TomEdl im Forum Basic-Programmierung (Bascom-Compiler)
    Antworten: 1
    Letzter Beitrag: 15.09.2009, 19:18
  5. Variablen auf Display ausgeben
    Von palermo im Forum C - Programmierung (GCC u.a.)
    Antworten: 20
    Letzter Beitrag: 22.12.2006, 09:55

Stichworte

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •  

12V Akku bauen