Hallo,
ich habe mir einen Gassensor gekauft und eine Schaltung mit einem
Arduino Nano gebaut, an die der Gastester mittels I²C angeschlossen ist.
Die Gasmessung funktioniert einwandfrei, alles klappt soweit bis auf ein
triviales Problem (was der Funktion letztlich keinen Abbruch tut), mich
aber wurmt, warum es nicht das macht, was ich möchte.
Folgendes Problem:
Sobald ich den "Gastester" (Arduino + Sensor) bestrome/einschalte, soll
als aller Erstes ein "Splashscreen" für 3 Sekunden erscheinen
(printSplashscreen(); ), anschließend soll das Display "clearen" und
Title und Warmingprozess anzeigen (printTitle(); und printWarming(); ).
printTitle() und printWarming() zeigt er genauso an wie er soll.
Nur wird nach dem Einschalten des Arduinos nie der Splashscreen
angezeigt, d.h. er überspringt "printSplashscreen()" und geht direkt zu
printTitle() und printWarming().
Was mache ich falsch?
Hier ein Auszug aus dem Code (der wiegesagt funktioniert, bis eben auf
diesen blöden Splashscreen):
1 | #include <SPI.h>
|
2 | #include <Wire.h>
|
3 | #include <Adafruit_GFX.h>
|
4 | #include <Adafruit_SSD1306.h>
|
5 |
|
6 | #define OLED_RESET 4
|
7 | int TIME_UNTIL_WARMUP = 15;
|
8 | unsigned long time;
|
9 |
|
10 |
|
11 | int analogPin = 0;
|
12 | int val = 0;
|
13 | Adafruit_SSD1306 display(OLED_RESET);
|
14 |
|
15 |
|
16 | void setup()
|
17 | {
|
18 | display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
|
19 | display.clearDisplay();
|
20 | delay(2000); // Startphase
|
21 | }
|
22 |
|
23 |
|
24 | void loop()
|
25 | {
|
26 | val = readGas();
|
27 | delay(100);
|
28 |
|
29 | printSplashScreen(); // !!! WIRD NIE ANGEZEIGT! Warum?
|
30 |
|
31 | printTitle(); // Wird ohne Probleme angezeigt
|
32 | printWarming(); // Wird auch ohne Probleme angezeigt
|
33 |
|
34 | time = millis()/1000;
|
35 |
|
36 | if(time<=TIME_UNTIL_WARMUP)
|
37 | {
|
38 | time = map(time, 0, TIME_UNTIL_WARMUP, 0, 100);
|
39 | display.drawRect(10, 20, 110, 10, WHITE);
|
40 | display.fillRect(10, 20, time,10,WHITE);
|
41 | }
|
42 | else
|
43 | {
|
44 | printTitle(); // Wird auch ohne Probleme angezeigt
|
45 | printGas(val); // Wird auch ohne Probleme angezeigt
|
46 | }
|
47 | display.display();
|
48 |
|
49 | }
|
50 |
|
51 | void printSplashscreen()
|
52 | {
|
53 | display.clearDisplay();
|
54 | display.setTextSize(1);
|
55 | display.setTextColor(WHITE);
|
56 | display.setCursor(22,0);
|
57 | display.println("Willkommen!");
|
58 | delay(3000);
|
59 | }
|
60 |
|
61 |
|
62 | void printTitle()
|
63 | {
|
64 | display.clearDisplay();
|
65 | display.setTextSize(1);
|
66 | display.setTextColor(WHITE);
|
67 | display.setCursor(22,0);
|
68 | display.println("Gas-Messer");
|
69 | }
|
70 |
|
71 |
|
72 |
|
73 |
|
74 | void printWarming()
|
75 | {
|
76 | display.setTextSize(1);
|
77 | display.setTextColor(WHITE);
|
78 | display.setCursor(22,10);
|
79 | display.println("Aufwaermen...");
|
80 | }
|
81 |
|
82 | void printGas(int value)
|
83 | {
|
84 | display.setTextSize(2);
|
85 | display.setTextColor(WHITE);
|
86 | display.setCursor(45,15);
|
87 | display.println(val);
|
88 | }
|
Ich hoffe ihr könnt mir helfen, ich verzweifle gerade.
Gruß und Danke.