arduino:schlafphasenwecker:programmversion_0.7
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen RevisionVorhergehende ÜberarbeitungNächste Überarbeitung | Vorhergehende Überarbeitung | ||
arduino:schlafphasenwecker:programmversion_0.7 [11.02.2017 15:49] – Frickelpiet | arduino:schlafphasenwecker:programmversion_0.7 [18.05.2023 12:34] (aktuell) – Externe Bearbeitung 127.0.0.1 | ||
---|---|---|---|
Zeile 4: | Zeile 4: | ||
Weitere Änderungen: | Weitere Änderungen: | ||
- | * Die Uhrzeit wird nun auf dem NeoPixel-Ring angezeigt. | + | * Die Uhrzeit wird auf dem NeoPixel-Ring angezeigt. |
- | * Die Helligkeit des Ziffernblatts wird abhängig von der Umgebungsbeleuchtung | + | * Die Helligkeit des Ziffernblatts wird abhängig von der Umgebungsbeleuchtung |
* Die Lautstärke des akustischen Weckalarms kann eingestellt werden. | * Die Lautstärke des akustischen Weckalarms kann eingestellt werden. | ||
- | * Änderungen am Menü | + | * Im Snoozle-Modus nach Ablauf der vorausgewählten Zeit die Lautstärke langsam reduziert. |
- | * visueller Weckalarm | + | * Jeder Alarm kann abgebrochen oder in einen Schlummermodus überführt werden. Im Schlummermodus wird nach einer vorausgewählten Schlummerzeit der akustische Alarm aktiviert. |
+ | * Das Menü wurde an verschiedenen Stellen aufgehübst und erweitert. | ||
+ | * Es kann ein visueller Weckalarm | ||
* kleinere Optimierungen des Programmcodes | * kleinere Optimierungen des Programmcodes | ||
* Fehlerbeseitigungen | * Fehlerbeseitigungen | ||
Zeile 16: | Zeile 18: | ||
ToDos: | ToDos: | ||
- | * Die Schlummerfunktion im Lichtweckmodus funktioniert nicht. | + | * Die Helligkeit des Ziffernblatts muss in dunklen Lichtsituationen stärker reduziert werden. |
* Die Menüs müssen aufgehübscht werden. | * Die Menüs müssen aufgehübscht werden. | ||
- | * Im Snoozle-Modus sollte beim automatischen Abschalten die Lautstärke langsam reduziert werden. | ||
- | * Die Bassanhebung des AAB scheint nicht korrekt konfiguriert zu sein. | ||
* Die Funktion zum Einstellen der Alarmzeit berechnet unter bestimmten Bedingungen die Startzeit für den Vorlauf falsch. | * Die Funktion zum Einstellen der Alarmzeit berechnet unter bestimmten Bedingungen die Startzeit für den Vorlauf falsch. | ||
+ | * Der Verstärker macht bei den Dateien " | ||
+ | * DIE Datei " | ||
+ | * Die Farbtemperatur des Ziffernblatts sollte abhängig von Sonnenauf- und Untergangszeit sein. | ||
Zeile 28: | Zeile 31: | ||
< | < | ||
+ | // Schlafphasenwecker Version 0.7.3 | ||
+ | |||
+ | // Bibliotheken einbinden | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | |||
+ | // Fonts einbinden | ||
+ | #include " | ||
+ | #include " | ||
+ | #include " | ||
+ | #include " | ||
+ | #include " | ||
+ | #include " | ||
+ | #include " | ||
+ | |||
+ | // Definiert Adressen im EEPROM | ||
+ | int addrAlarmHour = 0; | ||
+ | int addrAlarmMinute = 1; | ||
+ | int addrAlarmMode = 2; | ||
+ | int addrDisplayedAlarmHour = 3; | ||
+ | int addrDisplayedAlarmMinute = 4; | ||
+ | int addrAlarmAdvancetime = 5; // Vorlauf für die Alarmfunktion | ||
+ | int addrAlarmFile = 6; // Musikdatei für die Alarmfunktion | ||
+ | int addrSnoozleFile = 7; // Musikdatei für die Einschalffunktion (Snoozle) | ||
+ | int addrSnoozleGain = 8; // Lautstärke der Einschlaffunkion (Snoozle) | ||
+ | int addrAlarmGain = 9; // Lautstärke der Alarmfunktion | ||
+ | |||
+ | // Definiert die Pins | ||
+ | #define DCF_PIN 2 // DCF77-Modul | ||
+ | #define DCF_INTERRUPT 2 // Interrupt number associated with pin | ||
+ | #define DHTPIN 3 | ||
+ | #define TFTbacklightPin 4 // PWM Backlight TFT | ||
+ | #define NEOPIXELPIN 33 // NeoPixel | ||
+ | |||
+ | // Definiert die DCF77-Bibliothek | ||
+ | DCF77 DCF = DCF77(DCF_PIN, | ||
+ | |||
+ | // The FT6206 uses hardware I2C (SCL/SDA) | ||
+ | Adafruit_FT6206 ctp = Adafruit_FT6206(); | ||
+ | |||
+ | // The display also uses hardware SPI | ||
+ | #define TFT_DC 20 | ||
+ | #define TFT_CS 21 | ||
+ | #define TFT_RST 255 // Set to 255 when reset is not used | ||
+ | #define TFT_MOSI 7 | ||
+ | #define TFT_SCLK 14 | ||
+ | #define TFT_MISO 12 | ||
+ | |||
+ | ILI9341_t3 tft = ILI9341_t3(TFT_CS, | ||
+ | |||
+ | // pass in a number for the sensor identifier (for your use later) | ||
+ | Adafruit_TSL2591 tsl = Adafruit_TSL2591(2591); | ||
+ | |||
+ | // Assign a unique ID to this sensor at the same time | ||
+ | Adafruit_LSM303_Accel_Unified accel(30301); | ||
+ | Adafruit_LSM303_Mag_Unified | ||
+ | |||
+ | // Create simple AHRS algorithm using the above sensors. | ||
+ | Adafruit_Simple_AHRS | ||
+ | |||
+ | // Parameter 1 = number of pixels in strip | ||
+ | // Parameter 2 = Arduino pin number (most are valid) | ||
+ | // Parameter 3 = pixel type flags, add together as needed: | ||
+ | // | ||
+ | // | ||
+ | // | ||
+ | // | ||
+ | // | ||
+ | Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, | ||
+ | |||
+ | // IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across | ||
+ | // pixel power leads, add 300 - 500 Ohm resistor on first pixel' | ||
+ | // and minimize distance between Arduino and first pixel. | ||
+ | // on a live circuit...if you must, connect GND first. | ||
+ | |||
+ | int numPixels = 60; // Anzahl der NeoPixel | ||
+ | |||
+ | // Konfiguriert die Audio-Funktionen | ||
+ | AudioPlaySdWav | ||
+ | AudioPlaySdWav | ||
+ | AudioMixer4 | ||
+ | AudioMixer4 | ||
+ | AudioOutputI2S | ||
+ | AudioConnection | ||
+ | AudioConnection | ||
+ | AudioConnection | ||
+ | AudioConnection | ||
+ | AudioConnection | ||
+ | AudioConnection | ||
+ | AudioControlSGTL5000 | ||
+ | |||
+ | // Stereo 2.8W Class D Audio Amplifier TPA2016 | ||
+ | Adafruit_TPA2016 audioamp = Adafruit_TPA2016(); | ||
+ | |||
+ | // Initialisiert den DHT22-Sensor | ||
+ | #define DHTTYPE DHT22 | ||
+ | DHT dht(DHTPIN, DHTTYPE); | ||
+ | |||
+ | // Definiert die Variablen | ||
+ | int flankUp = 0; | ||
+ | int flankDown = 0; | ||
+ | int PreviousflankUp; | ||
+ | bool Up = false; | ||
+ | |||
+ | boolean IMUconnected = false; | ||
+ | boolean DCFtimesignalFound = false; | ||
+ | |||
+ | time_t DCFtime = 0; // Das aktuelleste erfolgreich empfangene Zeitzeichen im Variablenformat time_t (Sekunden seit dem 1.1.1970) | ||
+ | time_t t = 0; // Die Zeit der Real Time Clock im Variablenformat time_t (Sekunden seit dem 1.1.1970) | ||
+ | time_t DefaultTime = 1477958400; | ||
+ | //time_t startTime; | ||
+ | unsigned long timesinceDCFsignal; | ||
+ | unsigned long noDCFsignal; | ||
+ | time_t timestampDCFsignal; | ||
+ | unsigned long receivedDCFsignals = 0; // Zählt die Anzahl der erfolgreich empfangenen DCF77-Zeitzeichen seit dem Systemstart. | ||
+ | float DCFsuccessRate = 0; // Wert für die Quote der erfolgreich empfangenen DCF77-Zeitzeichen seit dem Systemstart. | ||
+ | |||
+ | boolean clockfaceOn = true; // Kann auf falsch gesetzt werden, om das Ziffernblatt zugunsten anderer Effekte zu deaktivieren. | ||
+ | int8_t intensity = 1; // Wert für die Helligkeit des Ziffernblatts | ||
+ | |||
+ | float x = 4.712388980; | ||
+ | |||
+ | int i; // Zählwert für verschiedene Beleuchtungseffekte | ||
+ | int j; // Zählwert für verschiedene Beleuchtungseffekte | ||
+ | int k; // Zählwert für verschiedene Beleuchtungseffekte | ||
+ | int l; // Zählwert für verschiedene Beleuchtungseffekte | ||
+ | |||
+ | // Definiert die globalen RGBW-Werte für das NeoPixel-Ziffernblatt | ||
+ | byte r = 0; | ||
+ | byte g = 0; | ||
+ | byte b = 0; | ||
+ | byte w = 0; | ||
+ | |||
+ | |||
+ | |||
+ | int displayedAlarmHour = 6; // Stunde, die auf dem TFT als Alarmzeit angezeigt wird. Wird als Integer definiert, damit die Variable theoretisch negativ werden kann. (Das ist für den Rollover von 0 auf 23 nötig.) | ||
+ | int displayedAlarmMinute = 0; // Minute, die auf dem TFT als Alarmzeit angezeigt wird. Wird als Integer definiert, damit die Variable theoretisch negativ werden kann. (Das ist für den Rollover von 0 auf 45 nötig.) | ||
+ | int alarmHour = 5; // Stunde, zu der ein schlafphasensensibler Alarm frühestens ausgelöst werden soll. Wird als Integer definiert, damit die Variable theoretisch negativ werden kann. (Das ist für den Rollover von 0 auf 23 nötig.) | ||
+ | int alarmMinute = 30; // Minute, zu der ein schlafphasensensibler Alarm frühestens ausgelöst werden soll. Wird als Integer definiert, damit die Variable theoretisch negativ werden kann. (Das ist für den Rollover von 0 auf 45 nötig.) | ||
+ | int alarmAdvancetime = 30; // Größe des Zeitfensters in Minuten, in der der schlafphasensensible Alarm ausgelöst werden kann. | ||
+ | byte alarmMode = 0; // Alarmmodus (0 = Alarm aus) | ||
+ | byte alarmFile = 1; // Legt die WAV-Datei fest, die bei einem Alarm abgespielt wird | ||
+ | int16_t alarmGain = 30; // Lautstärke der Alarmfunktion (wird mit 0.004 multipliziert). Wird als Integer definiert, damit sie theoretisch negativ weden kann. | ||
+ | boolean alarmOn = false; | ||
+ | |||
+ | boolean snoozeOn = false; | ||
+ | int snoozeDelay = 600; // Schlummerzeit in Sekunden | ||
+ | int snoozeTime = 1477958400; | ||
+ | |||
+ | boolean snoozleOn = false; | ||
+ | byte snoozleFile = 1; // Legt die WAV-Datei fest, die zum Snoozlen abgespielt wird | ||
+ | time_t snoozleTime = 1477958400; | ||
+ | int16_t snoozleGain = 70; // Lautstärke der Einschlaffunktion (wird mit 0.004 multipliziert). Wird als Integer definiert, damit sie theoretisch negativ weden kann. | ||
+ | int16_t sg; // Variable für das Fade out der Snoozle-Musik | ||
+ | |||
+ | uint16_t ir; // Helligkeitswert für den Infrarotanteil des Lichts | ||
+ | uint16_t full; // Helligkeitswert für das Infrarotanteil und das sichtbare Licht | ||
+ | uint32_t lum; | ||
+ | uint16_t lux; | ||
+ | uint16_t filteredLux; | ||
+ | |||
+ | float accelX; | ||
+ | float accelY; | ||
+ | double accelZ, filteredAccelZ; | ||
+ | |||
+ | double roll, filteredRoll; | ||
+ | double pitch, filteredPitch; | ||
+ | float heading; | ||
+ | |||
+ | Kalman accelZFilter(0.25, | ||
+ | Kalman rollFilter(0.25, | ||
+ | Kalman pitchFilter(0.25, | ||
+ | Kalman luxFilter(0.25, | ||
+ | |||
+ | |||
+ | int eventAccelZ = 0; // Zählt Ereignisse auf der Beschleunigungsachse Z | ||
+ | int eventRoll = 0; // Zählt Ereignisse auf der Rollachse | ||
+ | int eventPitch = 0; // Zählt Ereignisse auf der Pitchachse | ||
+ | int eventTotal = 0; | ||
+ | |||
+ | float h; // Wert für die Luftfeuchtigkeit | ||
+ | float c; // Wert für Temperatur in Grad Celsius | ||
+ | float f; // Wert für Temperatur in Fahrenheit | ||
+ | float taupunkt; | ||
+ | |||
+ | boolean touch = false; | ||
+ | boolean prevtouch = false; | ||
+ | boolean touch2 = false; | ||
+ | boolean prevtouch2 = false; | ||
+ | |||
+ | boolean TFTbacklightOn = false; | ||
+ | byte TFTbrightness = 0; // Wert für die aktuelle Helligkeit des TFT Backlights | ||
+ | //byte TFTmaxbrightness = 255; // Wert für die maximale Helligkeit des TFT backlights | ||
+ | //byte TFTminbrightness = 0; // Wert für die minimale Helligkeit des TFT backlights | ||
+ | const unsigned long TFTbacklightDelay = 60000; // Zeit in Millisekunden, | ||
+ | unsigned long TFTbacklightTime = 0; | ||
+ | boolean TFTrefresh = false; | ||
+ | |||
+ | |||
+ | byte menuPage = 0; // Wert für das aktuell auf dem TFT angezeigten Menü. Gestartet wird mit Menü Nr. 0. | ||
+ | byte previousmenuPage = 1; // Wert für die Menüseite, die in dem vormaligen Durchlauf aktuell war. | ||
+ | int tx; // Auf dem Touchscreen gedrücktes Pixel auf der x-Achse. Pixelspalte Nr. 0 ist links. | ||
+ | int ty; // Auf dem Touchscreen gedrücktes Pixel auf der y-Achse. Pixelzeile Nr. 0 ist oben. | ||
+ | |||
+ | |||
+ | // Definiert die Tracking-Variablen für die IF-Abfragen | ||
+ | unsigned long previousMillisSetRTC = 0; // Real time Clock | ||
+ | unsigned long previousMillisAlarmClock = 0; // Alarm-Funktion | ||
+ | unsigned long previousMillisSnoozleTime = 0; // Einschlaf-Funktion | ||
+ | unsigned long previousMillisClockFace = 0; // Ziffernblatt | ||
+ | unsigned long previousMillisTFTScreen = 0; // TFT-Screen | ||
+ | unsigned long previousMillisTouchScreen = 0; // Touch-Sensor | ||
+ | unsigned long previousMillisSensorData = 0; // IMU und TSL2591 | ||
+ | unsigned long previousMillisDHTSensor = 0; // DHT22 | ||
+ | unsigned long previousMillisSerialPrint = 0; // Serielle Ausgabe | ||
+ | unsigned long previousMillisDCFPulseLength = 0; // Pulsweitenmessung | ||
+ | |||
+ | // Definiert die Intervalle für die IF-Abfragen in Millisekunden | ||
+ | const unsigned long intervalSetRTC = 1000; // konstanter Delay für Holen der Zeit | ||
+ | const unsigned long intervalAlarmClock = 1000; // konstanter Delay für die Weckfunktionen | ||
+ | const unsigned long intervalSnoozleTime = 1000; // konstanter Delay für die Snoozlefunktion | ||
+ | const unsigned long intervalClockFace = 20; // konstanter Delay für das Ziffernblatt | ||
+ | unsigned long intervalTFTScreen = 100; // variabler Delay für Anteuerung des TFT-Screens | ||
+ | const unsigned long intervalTouchScreen = 50; // konstanter Delay für Anteuerung des kapazitiven Touchsreens | ||
+ | const unsigned long intervalSensorData = 100; // konstanter Delay für Auslesen der Sensoren | ||
+ | const unsigned long intervalDHTSensor = 60000; | ||
+ | const unsigned long intervalSerialPrint = 100; // konstanter Delay für serielle Ausgabe | ||
+ | const unsigned long intervalDCFPulseLength = 1; // konstanter Delay für die Messung der Periode und Pulsweite des Zeitsignals | ||
+ | |||
+ | |||
+ | void setup() | ||
+ | // Initalisiert die Pins | ||
+ | pinMode(DCF_PIN, | ||
+ | pinMode(DHTPIN, | ||
+ | pinMode(TFTbacklightPin, | ||
+ | |||
+ | // Initialisiert die serielle Schnittstelle | ||
+ | Serial.begin(115200); | ||
+ | | ||
+ | // set the Time library to use Teensy 3.0's RTC to keep time | ||
+ | setSyncProvider(getTeensy3Time); | ||
+ | |||
+ | delay(2000); | ||
+ | if (timeStatus()!= timeSet) { | ||
+ | Serial.println(" | ||
+ | } else { | ||
+ | Serial.println(" | ||
+ | } | ||
+ | |||
+ | // | ||
+ | if (! ctp.begin(40)) { // Stellt u.a. die Sensitivität des Touchscreens ein | ||
+ | Serial.println(" | ||
+ | //while (1); | ||
+ | } else { | ||
+ | Serial.println(" | ||
+ | } | ||
+ | |||
+ | // | ||
+ | if(!accel.begin()) { | ||
+ | /* There was a problem detecting the ADXL345 ... check your connections */ | ||
+ | Serial.println(" | ||
+ | //while(1); | ||
+ | } else { | ||
+ | IMUconnected = true; | ||
+ | } | ||
+ | if(!mag.begin()) { | ||
+ | /* There was a problem detecting the ADXL345 ... check your connections */ | ||
+ | Serial.println(" | ||
+ | //while(1); | ||
+ | } | ||
+ | | ||
+ | // Initialisiert den TFT-Bildschirm | ||
+ | tft.begin(); | ||
+ | tft.setRotation(1); | ||
+ | tft.fillScreen(ILI9341_BLACK); | ||
+ | | ||
+ | // read diagnostics (optional but can help debug problems) | ||
+ | uint8_t x = tft.readcommand8(ILI9341_RDMODE); | ||
+ | Serial.print(" | ||
+ | x = tft.readcommand8(ILI9341_RDMADCTL); | ||
+ | Serial.print(" | ||
+ | x = tft.readcommand8(ILI9341_RDPIXFMT); | ||
+ | Serial.print(" | ||
+ | x = tft.readcommand8(ILI9341_RDIMGFMT); | ||
+ | Serial.print(" | ||
+ | x = tft.readcommand8(ILI9341_RDSELFDIAG); | ||
+ | Serial.print(" | ||
+ | |||
+ | // Konfiguration des TSL2591 | ||
+ | // You can change the gain on the fly, to adapt to brighter/ | ||
+ | tsl.setGain(TSL2591_GAIN_LOW); | ||
+ | // tsl.setGain(TSL2591_GAIN_MED); | ||
+ | // tsl.setGain(TSL2591_GAIN_HIGH); | ||
+ | | ||
+ | // Changing the integration time gives you a longer time over which to sense light | ||
+ | // longer timelines are slower, but are good in very low light situtations! | ||
+ | tsl.setTiming(TSL2591_INTEGRATIONTIME_100MS); | ||
+ | // tsl.setTiming(TSL2591_INTEGRATIONTIME_200MS); | ||
+ | // tsl.setTiming(TSL2591_INTEGRATIONTIME_300MS); | ||
+ | // tsl.setTiming(TSL2591_INTEGRATIONTIME_400MS); | ||
+ | // | ||
+ | // tsl.setTiming(TSL2591_INTEGRATIONTIME_600MS); | ||
+ | |||
+ | // Initialisiert den TSL2591 | ||
+ | tsl.begin(); | ||
+ | |||
+ | // Intitialisiert den DHT22 | ||
+ | dht.begin(); | ||
+ | |||
+ | // Displays some basic information on this sensor from the unified sensor API sensor_t type | ||
+ | sensor_t sensor; | ||
+ | tsl.getSensor(& | ||
+ | Serial.println(" | ||
+ | Serial.print | ||
+ | Serial.print | ||
+ | Serial.print | ||
+ | Serial.print | ||
+ | Serial.print | ||
+ | Serial.print | ||
+ | Serial.println(" | ||
+ | Serial.println("" | ||
+ | | ||
+ | // Startet die Abfrage des DCF77-Moduls | ||
+ | DCF.Start(); | ||
+ | Serial.println(" | ||
+ | Serial.println(" | ||
+ | | ||
+ | // Initialisiert das Audio Board und die SD-Karte | ||
+ | AudioMemory(12); | ||
+ | sgtl5000_1.enable(); | ||
+ | sgtl5000_1.muteHeadphone(); | ||
+ | sgtl5000_1.volume(0.8); | ||
+ | sgtl5000_1.audioPostProcessorEnable(); | ||
+ | sgtl5000_1.enhanceBassEnable(); | ||
+ | SPI.setMOSI(7); | ||
+ | SPI.setSCK(14); | ||
+ | if (!(SD.begin(10))) { | ||
+ | Serial.println(" | ||
+ | } | ||
+ | Serial.println(" | ||
+ | | ||
+ | // Initialisiert den Class D Amplifier | ||
+ | audioamp.begin(); | ||
+ | audioamp.setAGCCompression(TPA2016_AGC_OFF); | ||
+ | // audioamp.setAGCCompression(TPA2016_AGC_2); | ||
+ | audioamp.setLimitLevelOn(); | ||
+ | audioamp.setLimitLevel(10); | ||
+ | |||
+ | // Initialisiert den NeoPixel-Teststrip | ||
+ | strip.begin(); | ||
+ | strip.show(); | ||
+ | | ||
+ | // Lese die abgespeicherten Werte für die angezeigte Alarmzeit, die schlafphasenabhängige Alarmzeit und den Alarmmmodus | ||
+ | alarmHour = EEPROM.read(addrAlarmHour); | ||
+ | alarmMinute = EEPROM.read(addrAlarmMinute); | ||
+ | alarmMode = EEPROM.read(addrAlarmMode); | ||
+ | displayedAlarmMinute = EEPROM.read(addrDisplayedAlarmMinute); | ||
+ | displayedAlarmHour = EEPROM.read(addrDisplayedAlarmHour); | ||
+ | alarmAdvancetime = EEPROM.read(addrAlarmAdvancetime); | ||
+ | alarmFile = EEPROM.read(addrAlarmFile); | ||
+ | alarmGain = EEPROM.read(addrAlarmGain); | ||
+ | snoozleFile = EEPROM.read(addrSnoozleFile); | ||
+ | snoozleGain = EEPROM.read(addrSnoozleGain); | ||
+ | |||
+ | Serial.println(" | ||
+ | Serial.print(" | ||
+ | Serial.print(" | ||
+ | Serial.print(" | ||
+ | Serial.print(" | ||
+ | Serial.print(" | ||
+ | |||
+ | // Es wird einmalig die Funktion zur Berechnung des Sonnenauf- und untergangs aufgerufen. | ||
+ | sunrise(); | ||
+ | } | ||
+ | |||
+ | |||
+ | void loop() { | ||
+ | // Aktuelle Zeit abfragen | ||
+ | unsigned long currentMillis = millis(); | ||
+ | |||
+ | |||
+ | // Stelle die Real Time Clock (RTC) auf die aktuelle Zeit | ||
+ | if ((unsigned long)(currentMillis - previousMillisSetRTC) >= intervalSetRTC) { | ||
+ | |||
+ | DCFtime = DCF.getTime(); | ||
+ | |||
+ | // Wenn die serielle Schnittstelle verfügbar ist, setze die RTC auf diese Zeit | ||
+ | if (Serial.available()) { | ||
+ | t = processSyncMessage(); | ||
+ | if (t != 0) { | ||
+ | Teensy3Clock.set(t); | ||
+ | setTime(t); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | // Wenn ein Zeitsignal vom DCF77-Modul verfügbar ist, setze die RTC auf diese Zeit | ||
+ | if (DCFtime > DefaultTime) { | ||
+ | t = DCFtime; | ||
+ | Serial.println(" | ||
+ | Teensy3Clock.set(t); | ||
+ | setTime(t); | ||
+ | DCFtimesignalFound = true; // die Variable wird wahr | ||
+ | receivedDCFsignals = receivedDCFsignals + 1; | ||
+ | timestampDCFsignal = now(); | ||
+ | } | ||
+ | |||
+ | // Berechne die Zeit die seit dem Empfang des letzten vollständig empfangenen Zeitsignals vergangen ist | ||
+ | if (DCFtimesignalFound == false) { | ||
+ | noDCFsignal = currentMillis / 1000; // in Sekunden | ||
+ | } | ||
+ | else { | ||
+ | timesinceDCFsignal = now() - timestampDCFsignal; | ||
+ | } | ||
+ | |||
+ | // Berechnet die Quote erfolgreich empfangener DCF77-Signale seit dem letzten Systemstart | ||
+ | DCFsuccessRate = (float(receivedDCFsignals) / ((millis() / 60000))) * 100; | ||
+ | | ||
+ | //Speichere die aktuelle Zeit in die zughörige Variable | ||
+ | previousMillisSetRTC = currentMillis; | ||
+ | } | ||
+ | |||
+ | |||
+ | // Ziffernblatt | ||
+ | if ((unsigned long)(currentMillis - previousMillisClockFace) >= intervalClockFace) { | ||
+ | |||
+ | // Berechnung der Helligkeit des Ziffernblatts | ||
+ | /* | ||
+ | if (filteredLux <= 20) {intensity = 10;} | ||
+ | else if (filteredLux > 20 && filteredLux <= 100) {intensity = 5;} | ||
+ | else if (filteredLux > 100 && filteredLux <= 10000) {intensity = 4;} | ||
+ | else if (filteredLux > 10000 && filteredLux <= 20000) {intensity = 3;} | ||
+ | else if (filteredLux > 20000 && filteredLux <= 40000) {intensity = 2;} | ||
+ | else if (filteredLux > 40000) {intensity = 1;} | ||
+ | |||
+ | Serial.print(" | ||
+ | */ | ||
+ | intensity = round(10 - (log(filteredLux/ | ||
+ | Serial.print(" | ||
+ | if (intensity > 10) { | ||
+ | intensity = 10; | ||
+ | } | ||
+ | if (intensity < 0) { | ||
+ | intensity = 0; | ||
+ | } | ||
+ | |||
+ | |||
+ | // Anmerkung: | ||
+ | // Wenn bei 7 NeoPixelen eine Farbe mit einem Wert von 32 (1/8 der max. Intensität) angesteuert wird, ist das für einen dunklen Raum zu hell. | ||
+ | // Je mehr NeoPixel von einem Ziffernblatteffekt verwendet werden, desto besser muss die Anzahl der aktiven NeoPixel berücksichtigt werden. | ||
+ | | ||
+ | if (clockfaceOn == true) { // Das Ziffernblatt wird angezeit, wenn die Variable wahr ist | ||
+ | strip.clear(); | ||
+ | /* | ||
+ | // Stundenskaka | ||
+ | for (int i = 0; i < 60; i = i + 5) { | ||
+ | strip.setPixelColor(i, | ||
+ | } | ||
+ | */ | ||
+ | // Stundenanzeige | ||
+ | if (hour() < 12) { | ||
+ | for (int j = (hour() * 5); j < ((hour() * 5) + 6); j++) { | ||
+ | strip.setPixelColor(j, | ||
+ | } | ||
+ | } | ||
+ | else if (hour() >= 12) { | ||
+ | for (int j = ((hour() - 12) * 5); j < (((hour() - 12) * 5) + 6); j++) { | ||
+ | strip.setPixelColor(j, | ||
+ | } | ||
+ | } | ||
+ | // Minutenanzeige | ||
+ | k = minute(); | ||
+ | strip.setPixelColor(k, | ||
+ | |||
+ | // Sekundenanzeige | ||
+ | l = second(); | ||
+ | strip.setPixelColor(l, | ||
+ | |||
+ | strip.show(); | ||
+ | } | ||
+ | //Speichere die aktuelle Zeit in die zughörige Variable | ||
+ | previousMillisClockFace = currentMillis; | ||
+ | } | ||
+ | | ||
+ | |||
+ | // Snoozle-Funktion | ||
+ | if ((unsigned long)(currentMillis - previousMillisSnoozleTime) >= intervalSnoozleTime) { | ||
+ | |||
+ | /* | ||
+ | // Ausgabe an serielle Schnittstelle für Debugging | ||
+ | Serial.print(" | ||
+ | Serial.print(now()); | ||
+ | Serial.print("; | ||
+ | Serial.print(snoozleTime); | ||
+ | Serial.print("; | ||
+ | Serial.print(snoozleOn); | ||
+ | Serial.print("; | ||
+ | Serial.println(snoozleFile); | ||
+ | */ | ||
+ | | ||
+ | // Wenn die aktuelle Zeit kleiner ist als die eingestellte Snoozle-Zeit, | ||
+ | if (snoozleOn == true) { | ||
+ | | ||
+ | if (now() < snoozleTime) { | ||
+ | audioamp.enableChannel(true, | ||
+ | snoozleGain = EEPROM.read(addrSnoozleGain); | ||
+ | mixer1.gain(0, | ||
+ | mixer2.gain(0, | ||
+ | } | ||
+ | | ||
+ | if (playSdWav1.isPlaying() == false) { | ||
+ | Serial.println(" | ||
+ | if (snoozleFile == 1) { | ||
+ | playSdWav1.play(" | ||
+ | } | ||
+ | else if (snoozleFile == 2) { | ||
+ | playSdWav1.play(" | ||
+ | } | ||
+ | else if (snoozleFile == 3) { | ||
+ | playSdWav1.play(" | ||
+ | } | ||
+ | else if (snoozleFile == 4) { | ||
+ | playSdWav1.play(" | ||
+ | } | ||
+ | if (snoozleFile == 5) { | ||
+ | playSdWav1.play(" | ||
+ | } | ||
+ | else if (snoozleFile == 6) { | ||
+ | playSdWav1.play(" | ||
+ | } | ||
+ | else if (snoozleFile == 7) { | ||
+ | playSdWav1.play(" | ||
+ | } | ||
+ | else if (snoozleFile == 8) { | ||
+ | playSdWav1.play(" | ||
+ | } | ||
+ | } | ||
+ | | ||
+ | if (menuPage != 8) { // Das Menü " | ||
+ | menuPage = 8; | ||
+ | TFTrefresh = true; | ||
+ | } | ||
+ | } | ||
+ | if (now() >= snoozleTime && snoozleOn == true) { | ||
+ | | ||
+ | |||
+ | // Reduziere langsam die Lautstärke | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | // Wenn die Lautstärke null ist, wird die Wiedergabe gestoppt und in das Hauptmenü gewechselt | ||
+ | if (snoozleGain <= 0) { | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | if (menuPage == 8) { // Wenn Menü " | ||
+ | | ||
+ | | ||
+ | | ||
+ | } | ||
+ | } | ||
+ | |||
+ | //Speichere die aktuelle Zeit in die zughörige Variable | ||
+ | previousMillisSnoozleTime = currentMillis; | ||
+ | } | ||
+ | |||
+ | |||
+ | // Alarm-Funktionen (alarm und Snooze) | ||
+ | if ((unsigned long)(currentMillis - previousMillisAlarmClock) >= intervalAlarmClock) { | ||
+ | | ||
+ | // Die Schleife wird durchlaufen, | ||
+ | if (alarmMode != 0 && hour() == alarmHour && minute() == alarmMinute && second() == 0 || alarmOn == true) { | ||
+ | | ||
+ | // Die Eventzähler müssen zu beginn einer Alarmphase einmalig zurückgesetzt werden | ||
+ | if (alarmOn == false) { | ||
+ | eventAccelZ = 0; | ||
+ | eventRoll = 0; | ||
+ | eventPitch = 0; | ||
+ | eventTotal = 0; | ||
+ | } | ||
+ | |||
+ | // Wecken mit Licht | ||
+ | if (alarmMode == 1) { | ||
+ | Serial.println(" | ||
+ | if (eventTotal >= 10) { // Weil dieser Alarm sehr schonend ist, kann er früh gestartet werden | ||
+ | clockfaceOn = false; | ||
+ | Serial.print(" | ||
+ | |||
+ | // Ansteuerung der NeoPixel | ||
+ | if (r < 255) { | ||
+ | r = r + 1; // r wird in jeder Schleife etwas erhöht | ||
+ | } | ||
+ | if (r == 255 && g < 120) { | ||
+ | g = g + 1; | ||
+ | } | ||
+ | //if (g == 255 && b < 255) { | ||
+ | // b = b + 1; | ||
+ | //} | ||
+ | if (g == 120 && w < 255) { | ||
+ | w = w + 1; | ||
+ | } | ||
+ | |||
+ | |||
+ | Serial.print("; | ||
+ | Serial.print(r); | ||
+ | Serial.print("; | ||
+ | Serial.print(g); | ||
+ | Serial.print("; | ||
+ | Serial.print(b); | ||
+ | Serial.print("; | ||
+ | Serial.println(w); | ||
+ | | ||
+ | for (int i = 0; i < numPixels; i++) { | ||
+ | strip.setPixelColor(i, | ||
+ | } | ||
+ | strip.show(); | ||
+ | } | ||
+ | } | ||
+ | | ||
+ | // Wecken mit Musik | ||
+ | else if (alarmMode == 2) { | ||
+ | Serial.println(" | ||
+ | if (eventTotal >= 100) { | ||
+ | audioamp.enableChannel(true, | ||
+ | alarmGain = EEPROM.read(addrAlarmGain); | ||
+ | mixer1.gain(1, | ||
+ | mixer2.gain(1, | ||
+ | Serial.print(" | ||
+ | if (playSdWav2.isPlaying() == false) { | ||
+ | Serial.println(" | ||
+ | if (alarmFile == 1) { | ||
+ | playSdWav2.play(" | ||
+ | } | ||
+ | else if (alarmFile == 2) { | ||
+ | playSdWav2.play(" | ||
+ | } | ||
+ | else if (alarmFile == 3) { | ||
+ | playSdWav2.play(" | ||
+ | } | ||
+ | else if (alarmFile == 4) { | ||
+ | playSdWav2.play(" | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | | ||
+ | // Wecken mit Licht und Musik | ||
+ | else if (alarmMode == 3) { | ||
+ | Serial.println(" | ||
+ | if (eventTotal >= 100) { | ||
+ | audioamp.enableChannel(true, | ||
+ | alarmGain = EEPROM.read(addrAlarmGain); | ||
+ | mixer1.gain(1, | ||
+ | mixer2.gain(1, | ||
+ | Serial.print(" | ||
+ | } | ||
+ | } | ||
+ | | ||
+ | |||
+ | |||
+ | // Anzeige des Menüs " | ||
+ | TFTbrightness = 255; | ||
+ | analogWrite(TFTbacklightPin, | ||
+ | TFTbacklightOn = true; // Das Backlight bleibt eingeschaltet, | ||
+ | alarmOn = true; | ||
+ | | ||
+ | if (menuPage != 7) { // Das Menü "Alarm aus/ | ||
+ | menuPage = 7; | ||
+ | TFTrefresh = true; | ||
+ | } | ||
+ | } | ||
+ | | ||
+ | | ||
+ | // Schlummeralarm | ||
+ | if (snoozeOn == true && now() >= snoozeTime) { | ||
+ | Serial.println(" | ||
+ | if (playSdWav2.isPlaying() == false) { | ||
+ | audioamp.enableChannel(true, | ||
+ | alarmGain = EEPROM.read(addrAlarmGain); | ||
+ | mixer1.gain(1, | ||
+ | mixer2.gain(1, | ||
+ | Serial.println(" | ||
+ | if (alarmFile == 1) { | ||
+ | playSdWav2.play(" | ||
+ | } | ||
+ | else if (alarmFile == 2) { | ||
+ | playSdWav2.play(" | ||
+ | } | ||
+ | else if (alarmFile == 3) { | ||
+ | playSdWav2.play(" | ||
+ | } | ||
+ | else if (alarmFile == 4) { | ||
+ | playSdWav2.play(" | ||
+ | } | ||
+ | } | ||
+ | // Anzeige des Menüs " | ||
+ | TFTbrightness = 255; | ||
+ | analogWrite(TFTbacklightPin, | ||
+ | TFTbacklightOn = true; // Das Backlight bleibt eingeschaltet, | ||
+ | snoozeOn = true; | ||
+ | | ||
+ | if (menuPage != 7) { // Das Menü "Alarm aus/ | ||
+ | menuPage = 7; | ||
+ | TFTrefresh = true; | ||
+ | } | ||
+ | } | ||
+ | | ||
+ | //Speichere die aktuelle Zeit in die zughörige Variable | ||
+ | previousMillisAlarmClock = currentMillis; | ||
+ | } | ||
+ | |||
+ | |||
+ | // Abfrage verschiedener Sensoren | ||
+ | if ((unsigned long)(currentMillis - previousMillisSensorData) >= intervalSensorData) { | ||
+ | |||
+ | if (IMUconnected == true) { | ||
+ | // Auslesen des Beschleunigungs- / Lagesensors und Magnetometers LSM303 | ||
+ | sensors_event_t event; | ||
+ | accel.getEvent(& | ||
+ | sensors_vec_t | ||
+ | ahrs.getOrientation(& | ||
+ | |||
+ | accelX = event.acceleration.x; | ||
+ | accelY = event.acceleration.y; | ||
+ | accelZ = event.acceleration.z; | ||
+ | |||
+ | pitch = orientation.roll; | ||
+ | roll = orientation.pitch; | ||
+ | heading = orientation.heading; | ||
+ | } | ||
+ | | ||
+ | // Die Werte für accelZ, pitch und roll werden mit einem Kalman-Filter geglättet | ||
+ | filteredAccelZ = accelZFilter.getFilteredValue(accelZ); | ||
+ | filteredRoll = rollFilter.getFilteredValue(roll); | ||
+ | filteredPitch = pitchFilter.getFilteredValue(pitch); | ||
+ | |||
+ | // Relativ schnelle Änderungen der Sensordaten lösen Ereignisse aus | ||
+ | if (filteredAccelZ - accelZ > 1 || filteredAccelZ - accelZ < -1) { | ||
+ | eventAccelZ = eventAccelZ + 1; | ||
+ | logSDcard(); | ||
+ | } | ||
+ | if (filteredRoll - roll > 5 || filteredRoll - roll < -5) { | ||
+ | eventRoll = eventRoll + 1; | ||
+ | } | ||
+ | if (filteredPitch - pitch > 5 || filteredPitch - pitch < -5) { | ||
+ | eventPitch = eventPitch + 1; | ||
+ | } | ||
+ | |||
+ | // Berechne die Summe aller Ereignisse | ||
+ | eventTotal = eventAccelZ + eventRoll + eventPitch; | ||
+ | | ||
+ | //Auslesen des Helligkeitssensors TSL2591 | ||
+ | lum = tsl.getFullLuminosity(); | ||
+ | ir = lum >> 16; | ||
+ | full = lum & 0xFFFF; | ||
+ | lux = tsl.calculateLux(full, | ||
+ | |||
+ | // Der Wert für Lux wird geglättet, weil er bei schnellen Änderungen des Umgebungslichts über das Ziel hinausschießt | ||
+ | filteredLux = luxFilter.getFilteredValue(lux); | ||
+ | |||
+ | Serial.print(" | ||
+ | Serial.print(", | ||
+ | Serial.print(", | ||
+ | Serial.print(", | ||
+ | Serial.print(", | ||
+ | | ||
+ | /* | ||
+ | // Daten auf SD-Karte loggen | ||
+ | // open the file. note that only one file can be open at a time, | ||
+ | // so you have to close this one before opening another. | ||
+ | File dataFile = SD.open(" | ||
+ | |||
+ | // if the file is available, write to it: | ||
+ | if (dataFile) { | ||
+ | dataFile.print(currentMillis); | ||
+ | dataFile.print("," | ||
+ | dataFile.println(lux); | ||
+ | dataFile.close(); | ||
+ | // print to the serial port too: | ||
+ | Serial.print(currentMillis); | ||
+ | Serial.print("," | ||
+ | Serial.print(lux); | ||
+ | } | ||
+ | // if the file isn't open, pop up an error: | ||
+ | else { | ||
+ | Serial.println(" | ||
+ | } | ||
+ | */ | ||
+ | //Speichere die aktuelle Zeit in die zughörige Variable | ||
+ | previousMillisSensorData = currentMillis; | ||
+ | } | ||
+ | |||
+ | |||
+ | // Abfrage des Temperatur- und Luftfeuchtigkeitssensors DHT22 | ||
+ | if ((unsigned long)(currentMillis - previousMillisDHTSensor) >= intervalDHTSensor) { | ||
+ | |||
+ | // Auslesen des Temperatursensors DHT22 | ||
+ | // Reading temperature or humidity takes about 250 milliseconds! | ||
+ | // Sensor readings may also be up to 2 seconds ' | ||
+ | h = dht.readHumidity(); | ||
+ | // Read temperature as Celsius (the default) | ||
+ | c = dht.readTemperature(); | ||
+ | // Read temperature as Fahrenheit (isFahrenheit = true) | ||
+ | f = dht.readTemperature(true); | ||
+ | |||
+ | // Check if any reads failed and exit early (to try again). | ||
+ | if (isnan(h) || isnan(c) || isnan(f)) { | ||
+ | Serial.println(" | ||
+ | return; | ||
+ | } | ||
+ | |||
+ | // Compute heat index in Fahrenheit (the default) | ||
+ | float hif = dht.computeHeatIndex(f, | ||
+ | // Compute heat index in Celsius (isFahreheit = false) | ||
+ | float hic = dht.computeHeatIndex(c, | ||
+ | |||
+ | // Taupunkt berechnen | ||
+ | float a = 17.271; | ||
+ | float b = 237.7; | ||
+ | float taupunktTmp = (a * c) / (b + c) + log(h/ | ||
+ | taupunkt = (b * taupunktTmp) / (a - taupunktTmp); | ||
+ | | ||
+ | Serial.print(" | ||
+ | Serial.print(h); | ||
+ | Serial.print(" | ||
+ | Serial.print(" | ||
+ | Serial.print(c); | ||
+ | Serial.print(" | ||
+ | Serial.print(f); | ||
+ | Serial.print(" | ||
+ | Serial.print(" | ||
+ | Serial.print(hic); | ||
+ | Serial.print(" | ||
+ | Serial.print(hif); | ||
+ | Serial.print(" | ||
+ | Serial.print(" | ||
+ | Serial.print(taupunkt); | ||
+ | Serial.println(" | ||
+ | | ||
+ | //Speichere die aktuelle Zeit in die zughörige Variable | ||
+ | previousMillisDHTSensor = currentMillis; | ||
+ | } | ||
+ | |||
+ | |||
+ | // TFT- imd Touchscreen | ||
+ | if ((unsigned long)(currentMillis - previousMillisTouchScreen) >= intervalTouchScreen) { | ||
+ | |||
+ | // Auslesen des kapazitiven Touchsensors | ||
+ | if (ctp.touched()) { | ||
+ | // Retrieve a point | ||
+ | TS_Point p = ctp.getPoint(); | ||
+ | // Damit der Wert 0, 0 des Touchsensors mit dem Pixel 0, 0 des TFT-Screens übereinstimmt, | ||
+ | tx = map(p.y, 0, 320, 320, 0); | ||
+ | ty = p.x; | ||
+ | |||
+ | // Variablen für die Steuerung des Backlights | ||
+ | touch = true; // Wird wahr, so lange der Touchsensor berührt wird (d.h. wird am Ende der TouchScreen-Schleife false). | ||
+ | prevtouch = touch; | ||
+ | TFTbacklightTime = currentMillis; | ||
+ | |||
+ | // Variablen für die Steurung des Menüs | ||
+ | if (TFTbacklightOn == true) { | ||
+ | touch2 = true; | ||
+ | prevtouch2 = touch2; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | // Das Backlight wird eingeschaltet, | ||
+ | if (touch == false && prevtouch == true) { | ||
+ | TFTbrightness = 255; | ||
+ | analogWrite(TFTbacklightPin, | ||
+ | TFTbacklightOn = true; | ||
+ | TFTrefresh = true; // Wenn das Backlight eingeschaltet wird, muss einmal das alte Menü aufgebaut werden | ||
+ | prevtouch = false; | ||
+ | } | ||
+ | |||
+ | // Wenn das Backlight an ist, soll es nach einer bestimmten Zeit wieder ausgeschaltet werden. | ||
+ | // Allerdings nur dann, wenn a) keine Alarmfunktion, | ||
+ | if (alarmOn == false && snoozeOn == false && snoozleOn == false) { | ||
+ | if (TFTbacklightOn == true && (millis() > TFTbacklightTime + TFTbacklightDelay)) { | ||
+ | TFTbrightness = TFTbrightness - 1; | ||
+ | if (TFTbrightness == 0) { | ||
+ | TFTbacklightOn = false; | ||
+ | tft.fillScreen(ILI9341_BLACK); | ||
+ | } | ||
+ | analogWrite(TFTbacklightPin, | ||
+ | } | ||
+ | } | ||
+ | |||
+ | // Wenn das Backlight an ist, kann das Menü mit dem Touchsensor bedient werden | ||
+ | // Es folgen für jedes einzelne Menü die Definitionen der jeweils sensiblen Bereiche einschließlich der Befehle, die jeweils ausgelöst werden sollen. | ||
+ | if (menuPage == 0 && touch2 == false && prevtouch2 == true) { // Wenn der Touchscreen losgelassen wurd und Menüseite 0 ausgewählt ist ... | ||
+ | if ((tx >= 0) && (tx <= 120) && (ty >= 0) && (ty <= 59)) { // ... und der TouchScreen in dem angegebenen Bereich berührt wird ... | ||
+ | menuPage = 1; // ... dann rufe Menüseite 1 auf. | ||
+ | } | ||
+ | else if ((tx >= 0) && (tx <= 120) && (ty >= 60) && (ty <= 120)) { | ||
+ | menuPage = 2; | ||
+ | } | ||
+ | else if ((tx >= 0) && (tx <= 120) && (ty >= 121) && (ty <= 180)) { | ||
+ | menuPage = 3; | ||
+ | } | ||
+ | else if ((tx >= 0) && (tx <= 120) && (ty >= 181) && (ty <= 240)) { | ||
+ | menuPage = 4; | ||
+ | } | ||
+ | else if ((tx >= 121) && (tx <= 320) && (ty >= 1) && (ty <= 240)) { | ||
+ | menuPage = 5; | ||
+ | } | ||
+ | tft.fillScreen(ILI9341_BLACK); | ||
+ | TFTrefresh = true; // Aktualisiere den Inhalt des TFT-Screens | ||
+ | prevtouch2 = false; | ||
+ | } | ||
+ | |||
+ | // Menü Snoozle | ||
+ | if (menuPage == 1 && touch2 == false && prevtouch2 == true) { | ||
+ | // Zurück zum Hauptmenü | ||
+ | if ((tx >= 0) && (tx <= 49) && (ty >= 0) && (ty <= 240)) { | ||
+ | menuPage = 0; | ||
+ | } | ||
+ | // Snoozle 15 Minuten | ||
+ | else if ((tx >= 50) && (tx <= 268) && (ty >= 0) && (ty <= 59)) { | ||
+ | snoozleOn = true; | ||
+ | snoozleTime = now() + 900; | ||
+ | } | ||
+ | // Snoozle 30 Minuten | ||
+ | else if ((tx >= 50) && (tx <= 268) && (ty >= 60) && (ty <= 119)) { | ||
+ | snoozleOn = true; | ||
+ | snoozleTime = now() + 1800; | ||
+ | } | ||
+ | // Snoozle 45 Minuten | ||
+ | else if ((tx >= 50) && (tx <= 268) && (ty >= 120) && (ty <= 179)) { | ||
+ | snoozleOn = true; | ||
+ | snoozleTime = now() + 2700; | ||
+ | } | ||
+ | // Snoozle 60 Minuten | ||
+ | else if ((tx >= 50) && (tx <= 268) && (ty >= 180) && (ty <= 239)) { | ||
+ | snoozleOn = true; | ||
+ | snoozleTime = now() + 3600; | ||
+ | } | ||
+ | // Zum Unteruntermenü Snoozle-Musik auswählen | ||
+ | else if ((tx >= 269) && (tx <= 319) && (ty >= 0) && (ty <= 239)) { | ||
+ | menuPage = 11; | ||
+ | } | ||
+ | // Debugging | ||
+ | Serial.print(" | ||
+ | Serial.print(", | ||
+ | | ||
+ | tft.fillScreen(ILI9341_BLACK); | ||
+ | TFTrefresh = true; | ||
+ | prevtouch2 = false; | ||
+ | } | ||
+ | |||
+ | // Unteruntermenü Auswahl Snoozlemusik | ||
+ | if (menuPage == 11 && touch2 == false && prevtouch2 == true) { | ||
+ | // Zurück zum Untermenü Snoozle | ||
+ | if ((tx >= 0) && (tx <= 40) && (ty >= 0) && (ty <= 240)) { | ||
+ | menuPage = 1; | ||
+ | tft.fillScreen(ILI9341_BLACK); | ||
+ | } | ||
+ | // Auswahl Musik 1 | ||
+ | else if ((tx >= 51) && (tx <= 184) && (ty >= 0) && (ty <= 59)) { | ||
+ | snoozleFile = 1; | ||
+ | EEPROM.update(addrSnoozleFile, | ||
+ | } | ||
+ | // Auswahl Musik 2 | ||
+ | else if ((tx >= 51) && (tx <= 184) && (ty >= 60) && (ty <= 120)) { | ||
+ | snoozleFile = 2; | ||
+ | EEPROM.update(addrSnoozleFile, | ||
+ | } | ||
+ | // Auswahl Musik 3 | ||
+ | else if ((tx >= 51) && (tx <= 184) && (ty >= 121) && (ty <= 180)) { | ||
+ | snoozleFile = 3; | ||
+ | EEPROM.update(addrSnoozleFile, | ||
+ | } | ||
+ | // Auswahl Musik 4 | ||
+ | else if ((tx >= 51) && (tx <= 184) && (ty >= 181) && (ty <= 240)) { | ||
+ | snoozleFile = 4; | ||
+ | EEPROM.update(addrSnoozleFile, | ||
+ | } | ||
+ | // Auswahl Musik 5 | ||
+ | else if ((tx >= 186) && (tx <= 319) && (ty >= 0) && (ty <= 59)) { | ||
+ | snoozleFile = 5; | ||
+ | EEPROM.update(addrSnoozleFile, | ||
+ | } | ||
+ | // Auswahl Musik 6 | ||
+ | else if ((tx >= 186) && (tx <= 319) && (ty >= 60) && (ty <= 120)) { | ||
+ | snoozleFile = 6; | ||
+ | EEPROM.update(addrSnoozleFile, | ||
+ | } | ||
+ | // Auswahl Musik 7 | ||
+ | else if ((tx >= 186) && (tx <= 319) && (ty >= 121) && (ty <= 180)) { | ||
+ | snoozleFile = 7; | ||
+ | EEPROM.update(addrSnoozleFile, | ||
+ | } | ||
+ | // Auswahl Musik 8 | ||
+ | else if ((tx >= 186) && (tx <= 319) && (ty >= 181) && (ty <= 240)) { | ||
+ | snoozleFile = 8; | ||
+ | EEPROM.update(addrSnoozleFile, | ||
+ | } | ||
+ | | ||
+ | TFTrefresh = true; | ||
+ | prevtouch2 = false; | ||
+ | } | ||
+ | |||
+ | // Menü Ziffernblatt | ||
+ | if (menuPage == 2 && touch2 == false && prevtouch2 == true) { | ||
+ | // Zurück zum Hauptmenü | ||
+ | if ((tx >= 0) && (tx <= 40) && (ty >= 0) && (ty <= 240)) { | ||
+ | menuPage = 0; | ||
+ | } | ||
+ | else if ((tx >= 41) && (tx <= 320) && (ty >= 0) && (ty <= 240)) { | ||
+ | menuPage = 0; | ||
+ | } | ||
+ | TFTrefresh = true; | ||
+ | prevtouch2 = false; | ||
+ | } | ||
+ | |||
+ | // Menü Einstellungen | ||
+ | if (menuPage == 3 && touch2 == false && prevtouch2 == true) { | ||
+ | // Zurück zum Hauptmenü | ||
+ | if ((tx >= 0) && (tx <= 40) && (ty >= 0) && (ty <= 240)) { | ||
+ | menuPage = 0; | ||
+ | } | ||
+ | // Zum Untermenü Weckzeitvorlauf | ||
+ | else if ((tx >= 51) && (tx <= 184) && (ty >= 0) && (ty <= 59)) { | ||
+ | menuPage = 31; | ||
+ | } | ||
+ | // Zum Untermenü Weckmusik | ||
+ | else if ((tx >= 51) && (tx <= 184) && (ty >= 60) && (ty <= 120)) { | ||
+ | menuPage = 32; | ||
+ | } | ||
+ | // Zum Untermenü Wecklautstärke | ||
+ | else if ((tx >= 51) && (tx <= 184) && (ty >= 121) && (ty <= 180)) { | ||
+ | menuPage = 33; | ||
+ | } | ||
+ | /* | ||
+ | // Zum Untermenü " | ||
+ | else if ((tx >= 51) && (tx <= 184) && (ty >= 181) && (ty <= 240)) { | ||
+ | menuPage = 34; | ||
+ | } | ||
+ | // Zum Untermenü " | ||
+ | else if ((tx >= 186) && (tx <= 319) && (ty >= 0) && (ty <= 59)) { | ||
+ | menuPage = 35; | ||
+ | } | ||
+ | // Zum Untermenü " | ||
+ | else if ((tx >= 186) && (tx <= 319) && (ty >= 60) && (ty <= 120)) { | ||
+ | menuPage = 36; | ||
+ | } | ||
+ | // Zum Untermenü " | ||
+ | else if ((tx >= 186) && (tx <= 319) && (ty >= 121) && (ty <= 180)) { | ||
+ | menuPage = 37; | ||
+ | } | ||
+ | // Zum Untermenü " | ||
+ | else if ((tx >= 186) && (tx <= 319) && (ty >= 181) && (ty <= 240)) { | ||
+ | menuPage = 38; | ||
+ | } | ||
+ | */ | ||
+ | tft.fillScreen(ILI9341_BLACK); | ||
+ | TFTrefresh = true; | ||
+ | prevtouch2 = false; | ||
+ | } | ||
+ | |||
+ | // Untermenü Weckzeitvorlauf einstellen | ||
+ | if (menuPage == 31 && touch2 == false && prevtouch2 == true) { | ||
+ | // Zurück zum Untermenü Einstellungen | ||
+ | if ((tx >= 0) && (tx <= 49) && (ty >= 0) && (ty <= 240)) { | ||
+ | menuPage = 3; | ||
+ | } | ||
+ | else if ((tx >= 50) && (tx <= 320) && (ty >= 0) && (ty <= 79)) { | ||
+ | alarmAdvancetime = 15; | ||
+ | EEPROM.update(addrAlarmAdvancetime, | ||
+ | } | ||
+ | else if ((tx >= 50) && (tx <= 320) && (ty >= 80) && (ty <= 159)) { | ||
+ | alarmAdvancetime = 30; | ||
+ | EEPROM.update(addrAlarmAdvancetime, | ||
+ | } | ||
+ | else if ((tx >= 50) && (tx <= 320) && (ty >= 160) && (ty <= 239)) { | ||
+ | alarmAdvancetime = 45; | ||
+ | EEPROM.update(addrAlarmAdvancetime, | ||
+ | } | ||
+ | tft.fillScreen(ILI9341_BLACK); | ||
+ | TFTrefresh = true; | ||
+ | prevtouch2 = false; | ||
+ | } | ||
+ | |||
+ | // Untermenü Weckmusikauswahl | ||
+ | if (menuPage == 32 && touch2 == false && prevtouch2 == true) { | ||
+ | // Zurück zum Untermenü Einstellungen | ||
+ | if ((tx >= 0) && (tx <= 40) && (ty >= 0) && (ty <= 240)) { | ||
+ | menuPage = 3; | ||
+ | } | ||
+ | // Auswahl Musik 1 | ||
+ | else if ((tx >= 51) && (tx <= 184) && (ty >= 0) && (ty <= 59)) { | ||
+ | alarmFile = 1; | ||
+ | EEPROM.update(addrAlarmFile, | ||
+ | } | ||
+ | // Auswahl Musik 2 | ||
+ | else if ((tx >= 51) && (tx <= 184) && (ty >= 60) && (ty <= 120)) { | ||
+ | alarmFile = 2; | ||
+ | EEPROM.update(addrAlarmFile, | ||
+ | } | ||
+ | // Auswahl Musik 3 | ||
+ | else if ((tx >= 51) && (tx <= 184) && (ty >= 121) && (ty <= 180)) { | ||
+ | alarmFile = 3; | ||
+ | EEPROM.update(addrAlarmFile, | ||
+ | } | ||
+ | // Auswahl Musik 4 | ||
+ | else if ((tx >= 51) && (tx <= 184) && (ty >= 181) && (ty <= 240)) { | ||
+ | alarmFile = 4; | ||
+ | EEPROM.update(addrAlarmFile, | ||
+ | } | ||
+ | /* | ||
+ | // Auswahl Musik 5 | ||
+ | else if ((tx >= 186) && (tx <= 319) && (ty >= 0) && (ty <= 59)) { | ||
+ | alarmFile = 5; | ||
+ | EEPROM.update(addrAlarmFile, | ||
+ | } | ||
+ | // Auswahl Musik 6 | ||
+ | else if ((tx >= 186) && (tx <= 319) && (ty >= 60) && (ty <= 120)) { | ||
+ | alarmFile = 6; | ||
+ | EEPROM.update(addrAlarmFile, | ||
+ | } | ||
+ | // Auswahl Musik 7 | ||
+ | else if ((tx >= 186) && (tx <= 319) && (ty >= 121) && (ty <= 180)) { | ||
+ | alarmFile = 7; | ||
+ | EEPROM.update(addrAlarmFile, | ||
+ | } | ||
+ | // Auswahl Musik 8 | ||
+ | else if ((tx >= 186) && (tx <= 319) && (ty >= 181) && (ty <= 240)) { | ||
+ | alarmFile = 8; | ||
+ | EEPROM.update(addrAlarmFile, | ||
+ | } | ||
+ | */ | ||
+ | tft.fillScreen(ILI9341_BLACK); | ||
+ | TFTrefresh = true; | ||
+ | prevtouch2 = false; | ||
+ | } | ||
+ | | ||
+ | // Menü Informationen | ||
+ | if (menuPage == 4 && touch2 == false && prevtouch2 == true) { | ||
+ | // Zurück zum Hauptmenü | ||
+ | if ((tx >= 0) && (tx <= 40) && (ty >= 0) && (ty <= 240)) { | ||
+ | menuPage = 0; | ||
+ | } | ||
+ | // Zum Unteruntermenü DCF Zeitsignal | ||
+ | else if ((tx >= 51) && (tx <= 184) && (ty >= 0) && (ty <= 59)) { | ||
+ | menuPage = 41; | ||
+ | } | ||
+ | // Zum Unteruntermenü LSM303 | ||
+ | else if ((tx >= 51) && (tx <= 184) && (ty >= 60) && (ty <= 120)) { | ||
+ | menuPage = 42; | ||
+ | } | ||
+ | /* | ||
+ | // Zum Unteruntermenü " | ||
+ | else if ((tx >= 51) && (tx <= 184) && (ty >= 121) && (ty <= 180)) { | ||
+ | menuPage = 43; | ||
+ | } | ||
+ | // Zum Unteruntermenü " | ||
+ | else if ((tx >= 51) && (tx <= 184) && (ty >= 181) && (ty <= 240)) { | ||
+ | menuPage = 44; | ||
+ | } | ||
+ | */ | ||
+ | // Zum Unteruntermenü TSL2591-Sensor | ||
+ | else if ((tx >= 186) && (tx <= 319) && (ty >= 0) && (ty <= 59)) { | ||
+ | menuPage = 45; | ||
+ | } | ||
+ | // Zum Unteruntermenü DHT22 Sensor | ||
+ | else if ((tx >= 186) && (tx <= 319) && (ty >= 60) && (ty <= 120)) { | ||
+ | menuPage = 46; | ||
+ | } | ||
+ | /* | ||
+ | // Zum Unteruntermenü " | ||
+ | else if ((tx >= 186) && (tx <= 319) && (ty >= 121) && (ty <= 180)) { | ||
+ | menuPage = 47; | ||
+ | } | ||
+ | // Zum Unteruntermenü " | ||
+ | else if ((tx >= 186) && (tx <= 319) && (ty >= 181) && (ty <= 240)) { | ||
+ | menuPage = 48; | ||
+ | } | ||
+ | */ | ||
+ | tft.fillScreen(ILI9341_BLACK); | ||
+ | TFTrefresh = true; | ||
+ | prevtouch2 = false; | ||
+ | } | ||
+ | |||
+ | // Unteruntermenü DCF77 Zeitsignal | ||
+ | if (menuPage == 41 && touch2 == false && prevtouch2 == true) { | ||
+ | // Zurück zum Untermenü Informationen | ||
+ | if ((tx >= 0) && (tx <= 40) && (ty >= 0) && (ty <= 240)) { | ||
+ | menuPage = 4; | ||
+ | } | ||
+ | else if ((tx >= 41) && (tx <= 320) && (ty >= 0) && (ty <= 240)) { | ||
+ | menuPage = 4; | ||
+ | } | ||
+ | tft.fillScreen(ILI9341_BLACK); | ||
+ | TFTrefresh = true; | ||
+ | prevtouch2 = false; | ||
+ | } | ||
+ | | ||
+ | // Unteruntermenü TSL303 Sensor | ||
+ | if (menuPage == 42 && touch2 == false && prevtouch2 == true) { | ||
+ | // Zurück zum Untermenü Informationen | ||
+ | if ((tx >= 0) && (tx <= 40) && (ty >= 0) && (ty <= 240)) { | ||
+ | menuPage = 4; | ||
+ | } | ||
+ | else if ((tx >= 41) && (tx <= 320) && (ty >= 0) && (ty <= 240)) { | ||
+ | menuPage = 4; | ||
+ | } | ||
+ | tft.fillScreen(ILI9341_BLACK); | ||
+ | TFTrefresh = true; | ||
+ | prevtouch2 = false; | ||
+ | } | ||
+ | | ||
+ | // Unteruntermenü TSL2591 Sensor | ||
+ | if (menuPage == 45 && touch2 == false && prevtouch2 == true) { | ||
+ | // Zurück zum Untermenü Informationen | ||
+ | if ((tx >= 0) && (tx <= 40) && (ty >= 0) && (ty <= 240)) { | ||
+ | menuPage = 4; | ||
+ | } | ||
+ | else if ((tx >= 41) && (tx <= 320) && (ty >= 0) && (ty <= 240)) { | ||
+ | menuPage = 4; | ||
+ | } | ||
+ | tft.fillScreen(ILI9341_BLACK); | ||
+ | TFTrefresh = true; | ||
+ | prevtouch2 = false; | ||
+ | } | ||
+ | |||
+ | // Unteruntermenü DHT22 Sensor | ||
+ | if (menuPage == 46 && touch2 == false && prevtouch2 == true) { | ||
+ | // Zurück zum Untermenü Informationen | ||
+ | if ((tx >= 0) && (tx <= 40) && (ty >= 0) && (ty <= 240)) { | ||
+ | menuPage = 4; | ||
+ | } | ||
+ | else if ((tx >= 41) && (tx <= 320) && (ty >= 0) && (ty <= 240)) { | ||
+ | menuPage = 4; | ||
+ | } | ||
+ | tft.fillScreen(ILI9341_BLACK); | ||
+ | TFTrefresh = true; | ||
+ | prevtouch2 = false; | ||
+ | } | ||
+ | |||
+ | // Menü Alarmzeit stellen. Vor dem Speichern werden von der eingestellten Zeit 30 Minuten abgezogen. | ||
+ | if (menuPage == 5 && touch2 == false && prevtouch2 == true) { | ||
+ | // Zurück zum Hauptmenü | ||
+ | if ((tx >= 0) && (tx <= 49) && (ty >= 0) && (ty <= 239)) { | ||
+ | menuPage = 0; | ||
+ | tft.fillScreen(ILI9341_BLACK); | ||
+ | |||
+ | // Vor dem Speichern der Alarmzeit ins EEPROM wird die angezeigte Alarmzeit in die schlafphasensensible Alarmzeit umgerechnet | ||
+ | alarmMinute = displayedAlarmMinute; | ||
+ | alarmHour = displayedAlarmHour; | ||
+ | | ||
+ | if (alarmAdvancetime == 15) { | ||
+ | if (displayedAlarmMinute == 0) { | ||
+ | alarmMinute = displayedAlarmMinute - 15; | ||
+ | alarmHour = displayedAlarmHour - 1; | ||
+ | if (alarmHour < 0) { | ||
+ | alarmHour = 23; | ||
+ | } | ||
+ | } | ||
+ | else if (displayedAlarmMinute == 15) { | ||
+ | alarmMinute = displayedAlarmMinute - 15; | ||
+ | } | ||
+ | else if (displayedAlarmMinute == 30) { | ||
+ | alarmMinute = displayedAlarmMinute - 15; | ||
+ | } | ||
+ | else if (displayedAlarmMinute == 45) { | ||
+ | alarmMinute = displayedAlarmMinute - 15; | ||
+ | } | ||
+ | } | ||
+ | else if (alarmAdvancetime == 30) { | ||
+ | if (displayedAlarmMinute == 0) { | ||
+ | alarmMinute = 30; | ||
+ | alarmHour = displayedAlarmHour - 1; | ||
+ | if (alarmHour < 0) { | ||
+ | alarmHour = 23; | ||
+ | } | ||
+ | } | ||
+ | else if (displayedAlarmMinute == 15) { | ||
+ | alarmMinute = 45; | ||
+ | alarmHour = displayedAlarmHour - 1; | ||
+ | if (alarmHour < 0) { | ||
+ | alarmHour = 23; | ||
+ | } | ||
+ | } | ||
+ | else if (displayedAlarmMinute == 30) { | ||
+ | alarmMinute = 0; | ||
+ | } | ||
+ | else if (displayedAlarmMinute == 45) { | ||
+ | alarmMinute = 15; | ||
+ | } | ||
+ | } | ||
+ | else if (alarmAdvancetime == 45) { | ||
+ | if (displayedAlarmMinute == 0) { | ||
+ | alarmMinute = displayedAlarmMinute - 45; | ||
+ | alarmHour = displayedAlarmHour -1; | ||
+ | if (alarmHour < 0) { | ||
+ | alarmHour = 23; | ||
+ | } | ||
+ | } | ||
+ | else if (displayedAlarmMinute == 15) { | ||
+ | alarmMinute = displayedAlarmMinute - 45; | ||
+ | alarmHour = displayedAlarmHour -1; | ||
+ | if (alarmHour < 0) { | ||
+ | alarmHour = 23; | ||
+ | } | ||
+ | } | ||
+ | else if (displayedAlarmMinute == 30) { | ||
+ | alarmMinute = displayedAlarmMinute - 45; | ||
+ | alarmHour = displayedAlarmHour -1; | ||
+ | if (alarmHour < 0) { | ||
+ | alarmHour = 23; | ||
+ | } | ||
+ | } | ||
+ | else if (displayedAlarmMinute == 45) { | ||
+ | alarmMinute = displayedAlarmMinute - 45; | ||
+ | } | ||
+ | } | ||
+ | | ||
+ | // Um das EEPROM zu schonen, werden die Alarmzeit und der Alarmmodus erst gespeichert, | ||
+ | // Um Speicherplatz im EEPROM zu sparen, werden die Integervariablen alarmHour, alarmMinute etc. als Byte gespeichert. | ||
+ | EEPROM.update(addrDisplayedAlarmHour, | ||
+ | EEPROM.update(addrDisplayedAlarmMinute, | ||
+ | EEPROM.update(addrAlarmHour, | ||
+ | EEPROM.update(addrAlarmMinute, | ||
+ | EEPROM.update(addrAlarmMode, | ||
+ | |||
+ | // Ausgabe an die serielle Schnittstelle | ||
+ | Serial.print(" | ||
+ | Serial.print(":" | ||
+ | Serial.print(" | ||
+ | Serial.print(":" | ||
+ | } | ||
+ | // Stunden auf | ||
+ | else if ((tx >= 50) && (tx <= 159) && (ty >= 0) && (ty <= 119)) { | ||
+ | displayedAlarmHour = displayedAlarmHour + 1; | ||
+ | if (displayedAlarmHour >= 24) { | ||
+ | displayedAlarmHour = 0; | ||
+ | } | ||
+ | } | ||
+ | // Minuten auf | ||
+ | else if ((tx >= 160) && (tx <= 268) && (ty >= 0) && (ty <= 119)) { | ||
+ | displayedAlarmMinute = displayedAlarmMinute + 15; | ||
+ | if (displayedAlarmMinute >= 60) { | ||
+ | displayedAlarmMinute = 0; | ||
+ | displayedAlarmHour = displayedAlarmHour + 1; | ||
+ | } | ||
+ | } | ||
+ | // Stunden ab | ||
+ | else if ((tx >= 50) && (tx <= 159) && (ty >= 120) && (ty <= 239)) { | ||
+ | displayedAlarmHour = displayedAlarmHour - 1; | ||
+ | if (displayedAlarmHour < 0) { | ||
+ | displayedAlarmHour = 23; | ||
+ | } | ||
+ | } | ||
+ | // Minuten ab | ||
+ | else if ((tx >= 160) && (tx <= 268) && (ty >= 120) && (ty <= 239)) { | ||
+ | displayedAlarmMinute = displayedAlarmMinute - 15; | ||
+ | if (displayedAlarmMinute < 0) { | ||
+ | displayedAlarmMinute = 45; | ||
+ | displayedAlarmHour = displayedAlarmHour - 1; | ||
+ | } | ||
+ | } | ||
+ | // Zum Menü Weckmodus stellen | ||
+ | else if ((tx >= 269) && (tx <= 319) && (ty >= 0) && (ty <= 239)) { | ||
+ | menuPage = 51; | ||
+ | tft.fillScreen(ILI9341_BLACK); | ||
+ | } | ||
+ | TFTrefresh = true; | ||
+ | prevtouch2 = false; | ||
+ | } | ||
+ | |||
+ | // Untermenü Weckmodus stellen | ||
+ | if (menuPage == 51 && touch2 == false && prevtouch2 == true) { | ||
+ | // Zurück zum Untermenü Informationen | ||
+ | if ((tx >= 0) && (tx <= 49) && (ty >= 0) && (ty <= 240)) { | ||
+ | menuPage = 5; | ||
+ | tft.fillScreen(ILI9341_BLACK); | ||
+ | } | ||
+ | else if ((tx >= 50) && (tx <= 268) && (ty >= 0) && (ty <= 59)) { | ||
+ | alarmMode = 0; | ||
+ | } | ||
+ | else if ((tx >= 50) && (tx <= 268) && (ty >= 60) && (ty <= 119)) { | ||
+ | alarmMode = 1; | ||
+ | } | ||
+ | else if ((tx >= 50) && (tx <= 268) && (ty >= 120) && (ty <= 179)) { | ||
+ | alarmMode = 2; | ||
+ | } | ||
+ | else if ((tx >= 50) && (tx <= 268) && (ty >= 180) && (ty <= 239)) { | ||
+ | alarmMode = 3; | ||
+ | } | ||
+ | // Zum Menü Wecklautstärke stellen | ||
+ | else if ((tx >= 269) && (tx <= 319) && (ty >= 0) && (ty <= 239)) { | ||
+ | menuPage = 52; | ||
+ | tft.fillScreen(ILI9341_BLACK); | ||
+ | // Um die Wecklautstärke einstellen zu können, muss die in den EInstellungen ausgewählte Datei mit der eingestellten Lautstärke abgespielt werden | ||
+ | audioamp.enableChannel(true, | ||
+ | alarmGain = EEPROM.read(addrAlarmGain); | ||
+ | mixer1.gain(1, | ||
+ | mixer2.gain(1, | ||
+ | if (playSdWav2.isPlaying() == false) { | ||
+ | Serial.println(" | ||
+ | if (alarmFile == 1) { | ||
+ | playSdWav2.play(" | ||
+ | } | ||
+ | else if (alarmFile == 2) { | ||
+ | playSdWav2.play(" | ||
+ | } | ||
+ | else if (alarmFile == 3) { | ||
+ | playSdWav2.play(" | ||
+ | } | ||
+ | else if (alarmFile == 4) { | ||
+ | playSdWav2.play(" | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | TFTrefresh = true; | ||
+ | prevtouch2 = false; | ||
+ | } | ||
+ | |||
+ | // Untermenü Wecklautstärke stellen | ||
+ | if (menuPage == 52 && touch2 == false && prevtouch2 == true) { | ||
+ | |||
+ | // Zurück zum Untermenü Informationen | ||
+ | if ((tx >= 0) && (tx <= 49) && (ty >= 0) && (ty <= 240)) { | ||
+ | menuPage = 51; | ||
+ | tft.fillScreen(ILI9341_BLACK); | ||
+ | playSdWav2.stop(); | ||
+ | Serial.println(" | ||
+ | audioamp.enableChannel(false, | ||
+ | } | ||
+ | | ||
+ | // Lautstärke einstellen | ||
+ | else if ((tx >= 214) && (tx <= 319) && (ty >= 0) && (ty <= 119)) { | ||
+ | // Lautstärke erhöhen | ||
+ | alarmGain = alarmGain + 10; | ||
+ | if (alarmGain >= 200) { | ||
+ | alarmGain = 200; | ||
+ | } | ||
+ | EEPROM.update(addrAlarmGain, | ||
+ | mixer1.gain(1, | ||
+ | mixer2.gain(1, | ||
+ | } | ||
+ | else if ((tx >= 214) && (tx <= 319) && (ty >= 120) && (ty <= 239)) { | ||
+ | // Lautstärke verringern | ||
+ | alarmGain = alarmGain - 10; | ||
+ | if (alarmGain <= 0) { | ||
+ | alarmGain = 0; | ||
+ | } | ||
+ | EEPROM.update(addrAlarmGain, | ||
+ | mixer1.gain(1, | ||
+ | mixer2.gain(1, | ||
+ | } | ||
+ | | ||
+ | |||
+ | TFTrefresh = true; | ||
+ | prevtouch2 = false; | ||
+ | } | ||
+ | | ||
+ | // Untermenü " | ||
+ | if (menuPage == 7 && touch2 == false && prevtouch2 == true) { | ||
+ | // Wecker aus | ||
+ | if ((tx >= 0) && (tx <= 213) && (ty >= 0) && (ty <= 239)) { | ||
+ | menuPage = 0; // Das Hauptmenü wird aufgerufen. | ||
+ | alarmOn = false; | ||
+ | snoozeOn = false; | ||
+ | clockfaceOn = true; // Das Ziffernblatt wirg ggf. aktiviert. | ||
+ | playSdWav2.stop(); | ||
+ | Serial.println(" | ||
+ | audioamp.enableChannel(false, | ||
+ | r = 0; // setzt den globalen Farbwert zurück | ||
+ | g = 0; // setzt den globalen Farbwert zurück | ||
+ | b = 0; // setzt den globalen Farbwert zurück | ||
+ | w = 0; // setzt den globalen Farbwert zurück | ||
+ | for (int i = 0; i < numPixels; i++) { | ||
+ | strip.setPixelColor(i, | ||
+ | } | ||
+ | strip.show(); | ||
+ | } | ||
+ | // Schlummern | ||
+ | else if ((tx >= 214) && (tx <= 319) && (ty >= 0) && (ty <= 239)) { | ||
+ | alarmOn = false; | ||
+ | snoozeOn = true; // Der Schlummerlarm wird aktiviert. | ||
+ | clockfaceOn = true; // Das Ziffernblatt wirg ggf. aktiviert. | ||
+ | playSdWav2.stop(); | ||
+ | Serial.println(" | ||
+ | audioamp.enableChannel(false, | ||
+ | r = 0; // setzt den globalen Farbwert zurück | ||
+ | g = 0; // setzt den globalen Farbwert zurück | ||
+ | b = 0; // setzt den globalen Farbwert zurück | ||
+ | w = 0; // setzt den globalen Farbwert zurück | ||
+ | for (int i = 0; i < numPixels; i++) { | ||
+ | strip.setPixelColor(i, | ||
+ | } | ||
+ | strip.show(); | ||
+ | snoozeTime = now() + snoozeDelay; | ||
+ | |||
+ | // Debugging | ||
+ | Serial.print(" | ||
+ | Serial.print(", | ||
+ | } | ||
+ | TFTrefresh = true; | ||
+ | prevtouch2 = false; | ||
+ | } | ||
+ | | ||
+ | // Untermenü " | ||
+ | if (menuPage == 8 && touch2 == false && prevtouch2 == true) { | ||
+ | // Zurück zum Untermenü Informationen | ||
+ | if ((tx >= 0) && (tx <= 213) && (ty >= 0) && (ty <= 239)) { | ||
+ | menuPage = 0; | ||
+ | snoozleOn = false; | ||
+ | playSdWav1.stop(); | ||
+ | Serial.println(" | ||
+ | audioamp.enableChannel(false, | ||
+ | } | ||
+ | else if ((tx >= 214) && (tx <= 319) && (ty >= 0) && (ty <= 119)) { | ||
+ | // Lautstärke erhöhen | ||
+ | snoozleGain = snoozleGain + 10; | ||
+ | if (snoozleGain >= 200) { | ||
+ | snoozleGain = 200; | ||
+ | } | ||
+ | EEPROM.update(addrSnoozleGain, | ||
+ | mixer1.gain(0, | ||
+ | mixer2.gain(0, | ||
+ | } | ||
+ | else if ((tx >= 214) && (tx <= 319) && (ty >= 120) && (ty <= 239)) { | ||
+ | // Lautstärke verringern | ||
+ | snoozleGain = snoozleGain - 10; | ||
+ | if (snoozleGain <= 0) { | ||
+ | snoozleGain = 0; | ||
+ | } | ||
+ | EEPROM.update(addrSnoozleGain, | ||
+ | mixer1.gain(0, | ||
+ | mixer2.gain(0, | ||
+ | } | ||
+ | | ||
+ | TFTrefresh = true; | ||
+ | prevtouch2 = false; | ||
+ | } | ||
+ | |||
+ | |||
+ | // Der Inhalt des Bildschirms wird nur dann neu aufgebaut, wenn a) das Backlight an ist und b) ein Refresh angewiesen wurde. | ||
+ | if (TFTbacklightOn == true) { | ||
+ | // Die Nummerierung der Menüseiten erfolgt nach dem folgendendem Muster: | ||
+ | // Hauptmenü = 0; von dort Verzweigungen zu den Untermenüs 1 bis 5 | ||
+ | |||
+ | // Hauptmenü | ||
+ | if (menuPage == 0 && TFTrefresh == true) { | ||
+ | tft.fillScreen(ILI9341_BLACK); | ||
+ | | ||
+ | // Linke Spalte des Menüs | ||
+ | tft.drawRoundRect(1, | ||
+ | tft.drawRoundRect(1, | ||
+ | tft.drawRoundRect(1, | ||
+ | tft.drawRoundRect(1, | ||
+ | |||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.setFont(DroidSans_12_Bold); | ||
+ | tft.setCursor(15, | ||
+ | tft.print(" | ||
+ | tft.setCursor(15, | ||
+ | tft.print(" | ||
+ | tft.setCursor(15, | ||
+ | tft.print(" | ||
+ | tft.setCursor(15, | ||
+ | tft.print(" | ||
+ | |||
+ | // Anzeige Uhrzeit | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.setFont(DroidSans_13); | ||
+ | tft.setCursor(190, | ||
+ | tft.print(" | ||
+ | if (DCFtimesignalFound == true) { | ||
+ | tft.setCursor(300, | ||
+ | tft.setFont(AwesomeF180_10); | ||
+ | if (timesinceDCFsignal >= 86400) { // Die Farbe des Symbols hängt vom Alter des zuletzt erfolgreich empfangenen Zeitsignals ab | ||
+ | tft.setTextColor(ILI9341_BLACK); | ||
+ | } | ||
+ | else if (timesinceDCFsignal < 86400 && timesinceDCFsignal >= 43200) { | ||
+ | tft.setTextColor(ILI9341_DARKGREY); | ||
+ | } | ||
+ | else if (timesinceDCFsignal < 43200 && timesinceDCFsignal >= 3600) { | ||
+ | tft.setTextColor(ILI9341_LIGHTGREY); | ||
+ | } | ||
+ | else if (timesinceDCFsignal < 3600) { | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | } | ||
+ | tft.print((char)107); | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | } | ||
+ | |||
+ | /* | ||
+ | // Anzeige Sonnenaufgang und Sonnenuntergang | ||
+ | tft.setTextColor(ILI9341_YELLOW); | ||
+ | tft.setFont(AwesomeF180_13); | ||
+ | tft.setCursor(140, | ||
+ | tft.print((char)5); | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.setFont(DroidSans_13); | ||
+ | tft.print(AufgangStunden); | ||
+ | tft.print(":" | ||
+ | if (AufgangMinuten< | ||
+ | tft.print(AufgangMinuten); | ||
+ | | ||
+ | tft.setTextColor(ILI9341_BLUE); | ||
+ | tft.setFont(AwesomeF180_13); | ||
+ | tft.setCursor(140, | ||
+ | tft.print((char)6); | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.setFont(DroidSans_13); | ||
+ | tft.print(UntergangStunden); | ||
+ | tft.print(":" | ||
+ | if (UntergangMinuten< | ||
+ | tft.print(UntergangMinuten); | ||
+ | */ | ||
+ | // Die Uhrzeit wird unabhängig davon einmal pro Sekunde aktualisiert | ||
+ | | ||
+ | tft.fillRect(130, | ||
+ | | ||
+ | //Anzeige Alarmzeit | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | if (alarmMode == 0) { | ||
+ | tft.setFont(DroidSans_24); | ||
+ | tft.setCursor(140, | ||
+ | tft.print(" | ||
+ | } | ||
+ | else { | ||
+ | tft.setFont(DroidSans_13); | ||
+ | tft.setCursor(180, | ||
+ | tft.print(" | ||
+ | |||
+ | tft.setFont(DroidSans_24); | ||
+ | tft.setCursor(165, | ||
+ | if(alarmHour < 10) { | ||
+ | tft.print(' | ||
+ | } | ||
+ | tft.print(displayedAlarmHour); | ||
+ | tft.print(" | ||
+ | if(displayedAlarmMinute < 10) { | ||
+ | tft.print(' | ||
+ | } | ||
+ | tft.print(displayedAlarmMinute); | ||
+ | tft.setFont(DroidSans_13); | ||
+ | tft.setCursor(155, | ||
+ | tft.print(" | ||
+ | if (alarmMode == 1) { | ||
+ | tft.setFont(AwesomeF080_14); | ||
+ | tft.print((char)35); | ||
+ | } | ||
+ | else if (alarmMode == 2) { | ||
+ | tft.setFont(AwesomeF000_14); | ||
+ | tft.print((char)38); | ||
+ | } | ||
+ | else if (alarmMode == 3) { | ||
+ | tft.setFont(AwesomeF000_14); | ||
+ | tft.print((char)38); | ||
+ | tft.setFont(DroidSans_13); | ||
+ | tft.print(" | ||
+ | tft.setFont(AwesomeF080_14); | ||
+ | tft.print((char)35); | ||
+ | } | ||
+ | } | ||
+ | TFTrefresh = false; | ||
+ | } | ||
+ | |||
+ | if (menuPage == 0 && ((unsigned long)(currentMillis - previousMillisTFTScreen) >= intervalTFTScreen)) { | ||
+ | intervalTFTScreen = 1000; | ||
+ | |||
+ | tft.fillRect(140, | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.setCursor(150, | ||
+ | tft.setFont(DroidSans_24); | ||
+ | if(hour() < 10) { | ||
+ | tft.print(' | ||
+ | } | ||
+ | tft.print(hour()); | ||
+ | tftprintDigits(minute()); | ||
+ | tftprintDigits(second()); | ||
+ | tft.setFont(DroidSans_13); | ||
+ | tft.setCursor(180, | ||
+ | tft.print(day()); | ||
+ | tft.print(" | ||
+ | tft.print(month()); | ||
+ | tft.print(" | ||
+ | tft.print(year()); | ||
+ | |||
+ | previousMillisTFTScreen = currentMillis; | ||
+ | } | ||
+ | |||
+ | // Untermenü " | ||
+ | if (menuPage == 1 && TFTrefresh == true) { | ||
+ | // | ||
+ | | ||
+ | // Zurück zum Hauptmenü | ||
+ | tft.setFont(AwesomeF100_32); | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.setCursor(6, | ||
+ | tft.print((char)0); | ||
+ | | ||
+ | // Optionen | ||
+ | tft.drawRoundRect(69, | ||
+ | tft.drawRoundRect(69, | ||
+ | tft.drawRoundRect(69, | ||
+ | tft.drawRoundRect(69, | ||
+ | | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.setFont(DroidSans_12_Bold); | ||
+ | tft.setCursor(84, | ||
+ | tft.print(" | ||
+ | tft.setCursor(84, | ||
+ | tft.print(" | ||
+ | tft.setCursor(84, | ||
+ | tft.print(" | ||
+ | tft.setCursor(84, | ||
+ | tft.print(" | ||
+ | |||
+ | // Weiter zur Auswahl der WAV-Datei | ||
+ | tft.setFont(AwesomeF100_32); | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.setCursor(290, | ||
+ | tft.print((char)1); | ||
+ | | ||
+ | TFTrefresh = false; | ||
+ | } | ||
+ | |||
+ | // Unteruntermenü " | ||
+ | if (menuPage == 11 && TFTrefresh == true) { | ||
+ | // | ||
+ | | ||
+ | // Zurück zum Snoozlemenü | ||
+ | tft.setFont(AwesomeF100_32); | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.setCursor(6, | ||
+ | tft.print((char)0); | ||
+ | |||
+ | // Optionen | ||
+ | tft.setFont(DroidSans_9_Bold); | ||
+ | if (snoozleFile == 1) { | ||
+ | tft.fillRect(49, | ||
+ | tft.fillRoundRect(49, | ||
+ | tft.setTextColor(ILI9341_BLACK); | ||
+ | tft.setCursor(64, | ||
+ | tft.print(" | ||
+ | } | ||
+ | else { | ||
+ | tft.fillRect(49, | ||
+ | tft.drawRoundRect(49, | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.setCursor(64, | ||
+ | tft.print(" | ||
+ | } | ||
+ | | ||
+ | if (snoozleFile == 2) { | ||
+ | tft.fillRect(49, | ||
+ | tft.fillRoundRect(49, | ||
+ | tft.setTextColor(ILI9341_BLACK); | ||
+ | tft.setCursor(64, | ||
+ | tft.print(" | ||
+ | } | ||
+ | else { | ||
+ | tft.fillRect(49, | ||
+ | tft.drawRoundRect(49, | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.setCursor(64, | ||
+ | tft.print(" | ||
+ | } | ||
+ | | ||
+ | if (snoozleFile == 3) { | ||
+ | tft.fillRect(49, | ||
+ | tft.fillRoundRect(49, | ||
+ | tft.setTextColor(ILI9341_BLACK); | ||
+ | tft.setCursor(64, | ||
+ | tft.print(" | ||
+ | } | ||
+ | else { | ||
+ | tft.fillRect(49, | ||
+ | tft.drawRoundRect(49, | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.setCursor(64, | ||
+ | tft.print(" | ||
+ | } | ||
+ | |||
+ | if (snoozleFile == 4) { | ||
+ | tft.fillRect(49, | ||
+ | tft.fillRoundRect(49, | ||
+ | tft.setTextColor(ILI9341_BLACK); | ||
+ | tft.setCursor(64, | ||
+ | tft.print(" | ||
+ | } | ||
+ | else { | ||
+ | tft.fillRect(49, | ||
+ | tft.drawRoundRect(49, | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.setCursor(64, | ||
+ | tft.print(" | ||
+ | } | ||
+ | |||
+ | if (snoozleFile == 5) { | ||
+ | tft.fillRect(184, | ||
+ | tft.fillRoundRect(184, | ||
+ | tft.setTextColor(ILI9341_BLACK); | ||
+ | tft.setCursor(199, | ||
+ | tft.print(" | ||
+ | } | ||
+ | else { | ||
+ | tft.fillRect(184, | ||
+ | tft.drawRoundRect(184, | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.setCursor(199, | ||
+ | tft.print(" | ||
+ | } | ||
+ | | ||
+ | if (snoozleFile == 6) { | ||
+ | tft.fillRect(184, | ||
+ | tft.fillRoundRect(184, | ||
+ | tft.setTextColor(ILI9341_BLACK); | ||
+ | tft.setCursor(199, | ||
+ | tft.print(" | ||
+ | } | ||
+ | else { | ||
+ | tft.fillRect(184, | ||
+ | tft.drawRoundRect(184, | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.setCursor(199, | ||
+ | tft.print(" | ||
+ | } | ||
+ | | ||
+ | if (snoozleFile == 7) { | ||
+ | tft.fillRect(184, | ||
+ | tft.fillRoundRect(184, | ||
+ | tft.setTextColor(ILI9341_BLACK); | ||
+ | tft.setCursor(199, | ||
+ | tft.print(" | ||
+ | } | ||
+ | else { | ||
+ | tft.fillRect(184, | ||
+ | tft.drawRoundRect(184, | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.setCursor(199, | ||
+ | tft.print(" | ||
+ | } | ||
+ | |||
+ | if (snoozleFile == 8) { | ||
+ | tft.fillRect(184, | ||
+ | tft.fillRoundRect(184, | ||
+ | tft.setTextColor(ILI9341_BLACK); | ||
+ | tft.setCursor(199, | ||
+ | tft.print(" | ||
+ | } | ||
+ | else { | ||
+ | tft.fillRect(184, | ||
+ | tft.drawRoundRect(184, | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.setCursor(199, | ||
+ | tft.print(" | ||
+ | } | ||
+ | | ||
+ | TFTrefresh = false; | ||
+ | } | ||
+ | | ||
+ | // Untermenü " | ||
+ | if (menuPage == 2 && TFTrefresh == true) { | ||
+ | // | ||
+ | | ||
+ | // Zurück zum Hauptmenü | ||
+ | tft.setFont(AwesomeF100_32); | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.setCursor(6, | ||
+ | tft.print((char)0); | ||
+ | |||
+ | // Effekte einstellen | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.setFont(DroidSans_8); | ||
+ | tft.setCursor(50, | ||
+ | tft.print(" | ||
+ | |||
+ | TFTrefresh = false; | ||
+ | } | ||
+ | |||
+ | // Untermenü " | ||
+ | if (menuPage == 3 && TFTrefresh == true) { | ||
+ | // | ||
+ | | ||
+ | // Zurück zum Hauptmenü | ||
+ | tft.setFont(AwesomeF100_32); | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.setCursor(6, | ||
+ | tft.print((char)0); | ||
+ | |||
+ | // Optionen | ||
+ | tft.setFont(DroidSans_9_Bold); | ||
+ | // Linke Spalte | ||
+ | tft.drawRoundRect(49, | ||
+ | tft.drawRoundRect(49, | ||
+ | tft.drawRoundRect(49, | ||
+ | tft.drawRoundRect(49, | ||
+ | |||
+ | | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | | ||
+ | tft.setCursor(64, | ||
+ | tft.print(" | ||
+ | tft.setCursor(64, | ||
+ | tft.print(" | ||
+ | tft.setCursor(64, | ||
+ | tft.print(" | ||
+ | tft.setCursor(64, | ||
+ | tft.print(" | ||
+ | |||
+ | // Rechte Spalte | ||
+ | tft.drawRoundRect(184, | ||
+ | tft.drawRoundRect(184, | ||
+ | tft.drawRoundRect(184, | ||
+ | tft.drawRoundRect(184, | ||
+ | | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.setCursor(199, | ||
+ | tft.print(" | ||
+ | tft.setCursor(199, | ||
+ | tft.print(" | ||
+ | tft.setCursor(199, | ||
+ | tft.print(" | ||
+ | tft.setCursor(199, | ||
+ | tft.print(" | ||
+ | |||
+ | TFTrefresh = false; | ||
+ | } | ||
+ | |||
+ | // Unteruntermenü " | ||
+ | if (menuPage == 31 && TFTrefresh == true) { | ||
+ | // | ||
+ | | ||
+ | // Zurück zum " | ||
+ | tft.setFont(AwesomeF100_32); | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.setCursor(6, | ||
+ | tft.print((char)0); | ||
+ | | ||
+ | // Optionen | ||
+ | tft.setFont(DroidSans_12_Bold); | ||
+ | tft.setCursor(84, | ||
+ | if (alarmAdvancetime == 15) { | ||
+ | tft.fillCircle(89, | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | } | ||
+ | else { | ||
+ | tft.fillCircle(89, | ||
+ | tft.setTextColor(ILI9341_RED); | ||
+ | } | ||
+ | tft.print(" | ||
+ | | ||
+ | tft.setCursor(84, | ||
+ | if (alarmAdvancetime == 30) { | ||
+ | tft.fillCircle(89, | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | } | ||
+ | else { | ||
+ | tft.fillCircle(89, | ||
+ | tft.setTextColor(ILI9341_RED); | ||
+ | } | ||
+ | tft.print(" | ||
+ | | ||
+ | tft.setCursor(84, | ||
+ | if (alarmAdvancetime == 45) { | ||
+ | tft.fillCircle(89, | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | } | ||
+ | else { | ||
+ | tft.fillCircle(89, | ||
+ | tft.setTextColor(ILI9341_RED); | ||
+ | } | ||
+ | tft.print(" | ||
+ | |||
+ | TFTrefresh = false; | ||
+ | } | ||
+ | | ||
+ | // Unteruntermenü " | ||
+ | if (menuPage == 32 && TFTrefresh == true) { | ||
+ | // | ||
+ | | ||
+ | // Zurück zum Hauptmenü | ||
+ | tft.setFont(AwesomeF100_32); | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.setCursor(6, | ||
+ | tft.print((char)0); | ||
+ | |||
+ | // Linke Spalte | ||
+ | tft.fillCircle(69, | ||
+ | tft.fillCircle(69, | ||
+ | tft.fillCircle(69, | ||
+ | tft.fillCircle(69, | ||
+ | | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.setFont(DroidSans_12_Bold); | ||
+ | tft.setCursor(64, | ||
+ | tft.print(" | ||
+ | tft.setCursor(64, | ||
+ | tft.print(" | ||
+ | tft.setCursor(64, | ||
+ | tft.print(" | ||
+ | tft.setCursor(64, | ||
+ | tft.print(" | ||
+ | |||
+ | // Rechte Spalte | ||
+ | tft.fillCircle(199, | ||
+ | tft.fillCircle(199, | ||
+ | tft.fillCircle(199, | ||
+ | tft.fillCircle(199, | ||
+ | |||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.setFont(DroidSans_12_Bold); | ||
+ | tft.setCursor(194, | ||
+ | tft.print(" | ||
+ | tft.setCursor(194, | ||
+ | tft.print(" | ||
+ | tft.setCursor(194, | ||
+ | tft.print(" | ||
+ | tft.setCursor(194, | ||
+ | tft.print(" | ||
+ | |||
+ | TFTrefresh = false; | ||
+ | } | ||
+ | |||
+ | // Untermenü " | ||
+ | if (menuPage == 4 && TFTrefresh == true) { | ||
+ | // | ||
+ | | ||
+ | // Zurück zum Hauptmenü | ||
+ | tft.setFont(AwesomeF100_32); | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.setCursor(6, | ||
+ | tft.print((char)0); | ||
+ | |||
+ | // Linke Spalte | ||
+ | tft.drawRoundRect(49, | ||
+ | tft.drawRoundRect(49, | ||
+ | tft.drawRoundRect(49, | ||
+ | tft.drawRoundRect(49, | ||
+ | | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.setFont(DroidSans_12_Bold); | ||
+ | tft.setCursor(64, | ||
+ | tft.print(" | ||
+ | tft.setCursor(64, | ||
+ | tft.print(" | ||
+ | tft.setCursor(64, | ||
+ | tft.print(" | ||
+ | tft.setCursor(64, | ||
+ | tft.print(" | ||
+ | |||
+ | // Rechte Spalte | ||
+ | tft.drawRoundRect(184, | ||
+ | tft.drawRoundRect(184, | ||
+ | tft.drawRoundRect(184, | ||
+ | tft.drawRoundRect(184, | ||
+ | |||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.setFont(DroidSans_12_Bold); | ||
+ | tft.setCursor(194, | ||
+ | tft.print(" | ||
+ | tft.setCursor(194, | ||
+ | tft.print(" | ||
+ | tft.setCursor(194, | ||
+ | tft.print(" | ||
+ | tft.setCursor(194, | ||
+ | tft.print(" | ||
+ | |||
+ | TFTrefresh = false; | ||
+ | } | ||
+ | |||
+ | // Unteruntermenü " | ||
+ | if (menuPage == 41 && TFTrefresh == true) { | ||
+ | // | ||
+ | | ||
+ | // Zurück zum Untermenü Informationen | ||
+ | tft.setFont(AwesomeF100_32); | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.setCursor(6, | ||
+ | tft.print((char)0); | ||
+ | |||
+ | TFTrefresh = false; | ||
+ | } | ||
+ | | ||
+ | if (menuPage == 41 && ((unsigned long)(currentMillis - previousMillisTFTScreen) >= intervalTFTScreen)) { | ||
+ | intervalTFTScreen = 50; | ||
+ | | ||
+ | tft.setFontAdafruit(); | ||
+ | tft.setTextSize(1); | ||
+ | |||
+ | // Datenausgabe | ||
+ | tft.setFontAdafruit(); | ||
+ | tft.setTextSize(1); | ||
+ | | ||
+ | if (DCFtimesignalFound == false){ | ||
+ | tft.setCursor(60, | ||
+ | tft.setTextColor(ILI9341_WHITE, | ||
+ | tft.print(" | ||
+ | tft.setCursor(60, | ||
+ | tft.print(" | ||
+ | tft.setTextColor(ILI9341_RED, | ||
+ | |||
+ | int seconds = noDCFsignal % 60; | ||
+ | int minutes = (noDCFsignal | ||
+ | int hours = (noDCFsignal / 3600) % 24; | ||
+ | int days = (noDCFsignal / 86400) % 1; | ||
+ | |||
+ | tft.print(days); | ||
+ | tft.print(hours); | ||
+ | tft.print(minutes); | ||
+ | tft.print(seconds); | ||
+ | tft.setTextColor(ILI9341_WHITE, | ||
+ | tft.print(" | ||
+ | } | ||
+ | else { | ||
+ | tft.setCursor(60, | ||
+ | tft.setTextColor(ILI9341_WHITE, | ||
+ | tft.println(" | ||
+ | tft.setCursor(60, | ||
+ | tft.print(" | ||
+ | tft.setTextColor(ILI9341_RED, | ||
+ | |||
+ | int seconds = timesinceDCFsignal % 60; | ||
+ | int minutes = (timesinceDCFsignal | ||
+ | int hours = (timesinceDCFsignal / 3600) % 24; | ||
+ | int days = (timesinceDCFsignal / 86400) % 1; | ||
+ | | ||
+ | tft.print(days); | ||
+ | tft.print(hours); | ||
+ | tft.print(minutes); | ||
+ | tft.print(seconds); | ||
+ | tft.setTextColor(ILI9341_WHITE, | ||
+ | tft.print(" | ||
+ | } | ||
+ | |||
+ | tft.setCursor(60, | ||
+ | tft.setTextColor(ILI9341_WHITE, | ||
+ | tft.print(" | ||
+ | tft.setCursor(60, | ||
+ | tft.print(" | ||
+ | tft.setTextColor(ILI9341_RED, | ||
+ | tft.print(receivedDCFsignals); | ||
+ | tft.setTextColor(ILI9341_WHITE, | ||
+ | tft.print(" | ||
+ | |||
+ | tft.setCursor(60, | ||
+ | tft.setTextColor(ILI9341_WHITE, | ||
+ | tft.print(" | ||
+ | tft.setCursor(60, | ||
+ | tft.print(" | ||
+ | tft.setTextColor(ILI9341_RED, | ||
+ | tft.print(DCFsuccessRate); | ||
+ | tft.setTextColor(ILI9341_WHITE, | ||
+ | tft.print(" | ||
+ | |||
+ | tft.setCursor(60, | ||
+ | tft.setTextColor(ILI9341_WHITE, | ||
+ | tft.print(" | ||
+ | tft.setTextColor(ILI9341_RED, | ||
+ | tft.print(millis()/ | ||
+ | tft.setTextColor(ILI9341_WHITE, | ||
+ | tft.print(" | ||
+ | |||
+ | tft.fillRect(60, | ||
+ | tft.setCursor(60, | ||
+ | tft.setTextColor(ILI9341_WHITE, | ||
+ | tft.print(" | ||
+ | tft.setTextColor(ILI9341_RED, | ||
+ | tft.print(flankUp-PreviousflankUp); | ||
+ | tft.setTextColor(ILI9341_WHITE, | ||
+ | tft.print(" | ||
+ | tft.setTextColor(ILI9341_RED, | ||
+ | tft.print(flankDown - flankUp); | ||
+ | |||
+ | previousMillisTFTScreen = currentMillis; | ||
+ | } | ||
+ | |||
+ | // Unteruntermenü " | ||
+ | if (menuPage == 42 && TFTrefresh == true) { | ||
+ | // | ||
+ | | ||
+ | // Zurück zum Untermenü Informationen | ||
+ | tft.setFont(AwesomeF100_32); | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.setCursor(6, | ||
+ | tft.print((char)0); | ||
+ | |||
+ | TFTrefresh = false; | ||
+ | } | ||
+ | | ||
+ | if (menuPage == 42 && ((unsigned long)(currentMillis - previousMillisTFTScreen) >= intervalTFTScreen)) { | ||
+ | intervalTFTScreen = 50; | ||
+ | | ||
+ | // Datenausgabe | ||
+ | tft.setFontAdafruit(); | ||
+ | tft.setTextSize(1); | ||
+ | |||
+ | tft.setCursor(60, | ||
+ | tft.setTextColor(ILI9341_WHITE, | ||
+ | tft.print(" | ||
+ | tft.setCursor(60, | ||
+ | tft.print(" | ||
+ | tft.setTextColor(ILI9341_RED, | ||
+ | tft.print(accelX); | ||
+ | tft.setTextColor(ILI9341_WHITE, | ||
+ | tft.print(" | ||
+ | tft.setTextColor(ILI9341_RED, | ||
+ | tft.print(accelY); | ||
+ | tft.setTextColor(ILI9341_WHITE, | ||
+ | tft.print(" | ||
+ | tft.setTextColor(ILI9341_RED, | ||
+ | tft.print(accelZ); | ||
+ | |||
+ | tft.setCursor(60, | ||
+ | tft.setTextColor(ILI9341_WHITE, | ||
+ | tft.print(" | ||
+ | tft.setCursor(60, | ||
+ | tft.print(" | ||
+ | tft.setTextColor(ILI9341_RED, | ||
+ | tft.print(roll); | ||
+ | tft.setTextColor(ILI9341_WHITE, | ||
+ | tft.print(" | ||
+ | tft.setTextColor(ILI9341_RED, | ||
+ | tft.print(pitch); | ||
+ | tft.setTextColor(ILI9341_WHITE, | ||
+ | tft.print(" | ||
+ | tft.setTextColor(ILI9341_RED, | ||
+ | tft.print(heading); | ||
+ | |||
+ | previousMillisTFTScreen = currentMillis; | ||
+ | } | ||
+ | | ||
+ | // Unteruntermenü " | ||
+ | if (menuPage == 45 && TFTrefresh == true) { | ||
+ | // | ||
+ | | ||
+ | // Zurück zum Untermenü Informationen | ||
+ | tft.setFont(AwesomeF100_32); | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.setCursor(6, | ||
+ | tft.print((char)0); | ||
+ | | ||
+ | TFTrefresh = false; | ||
+ | } | ||
+ | | ||
+ | if (menuPage == 45 && ((unsigned long)(currentMillis - previousMillisTFTScreen) >= intervalTFTScreen)) { | ||
+ | intervalTFTScreen = 500; | ||
+ | | ||
+ | // Datenausgabe | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.setFont(DroidSans_9); | ||
+ | | ||
+ | tft.setCursor(60, | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.print(" | ||
+ | tft.setTextColor(ILI9341_RED); | ||
+ | tft.print(ir); | ||
+ | tft.setCursor(60, | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.print(" | ||
+ | tft.setTextColor(ILI9341_RED); | ||
+ | tft.print(full); | ||
+ | tft.setCursor(60, | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.print(" | ||
+ | tft.setTextColor(ILI9341_RED); | ||
+ | tft.print(full - ir); tft.print(" | ||
+ | tft.setCursor(60, | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.print(" | ||
+ | tft.setTextColor(ILI9341_RED); | ||
+ | tft.print(lux); | ||
+ | tft.setCursor(60, | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.print(" | ||
+ | tft.setTextColor(ILI9341_RED); | ||
+ | tft.print(filteredLux); | ||
+ | | ||
+ | previousMillisTFTScreen = currentMillis; | ||
+ | } | ||
+ | |||
+ | // Unteruntermenü " | ||
+ | if (menuPage == 46 && TFTrefresh == true) { | ||
+ | // | ||
+ | |||
+ | // Zurück zum Untermenü Informationen | ||
+ | tft.setFont(AwesomeF100_32); | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.setCursor(6, | ||
+ | tft.print((char)0); | ||
+ | | ||
+ | // Datenausgabe | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.setFont(DroidSans_9); | ||
+ | |||
+ | tft.setCursor(60, | ||
+ | tft.print(" | ||
+ | tft.setTextColor(ILI9341_RED); | ||
+ | tft.print(c); | ||
+ | tft.print(f); | ||
+ | tft.setCursor(60, | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.print(" | ||
+ | tft.setTextColor(ILI9341_RED); | ||
+ | tft.print(h); | ||
+ | tft.print(" | ||
+ | tft.setCursor(60, | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.print(" | ||
+ | tft.setTextColor(ILI9341_RED); | ||
+ | tft.print(taupunkt); | ||
+ | |||
+ | TFTrefresh = false; | ||
+ | } | ||
+ | |||
+ | // Unteruntermenü " | ||
+ | if (menuPage == 48 && TFTrefresh == true) { | ||
+ | // | ||
+ | | ||
+ | // Zurück zum Untermenü Informationen | ||
+ | tft.setFont(AwesomeF100_32); | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.setCursor(6, | ||
+ | tft.print((char)0); | ||
+ | |||
+ | // Obere Reihe des Menüs | ||
+ | tft.setTextSize(1); | ||
+ | tft.setTextColor(ILI9341_BLACK, | ||
+ | tft.setCursor(35, | ||
+ | tft.print(" | ||
+ | tft.setCursor(145, | ||
+ | tft.print(" | ||
+ | tft.setTextColor(ILI9341_WHITE, | ||
+ | tft.setCursor(255, | ||
+ | tft.print(" | ||
+ | tft.setCursor(245, | ||
+ | tft.print(" | ||
+ | |||
+ | // Bereich der Datenausgabe | ||
+ | tft.print(" | ||
+ | tft.print(millis() / 60000); | ||
+ | tft.print(" | ||
+ | |||
+ | TFTrefresh = false; | ||
+ | } | ||
+ | |||
+ | // Untermenü " | ||
+ | if (menuPage == 5 && TFTrefresh == true) { | ||
+ | // | ||
+ | | ||
+ | // Zurück zum Hauptmenü | ||
+ | tft.setFont(AwesomeF100_32); | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.setCursor(6, | ||
+ | tft.print((char)0); | ||
+ | |||
+ | |||
+ | // Wecker stellen | ||
+ | tft.setFont(DroidSans_13); | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.setCursor(75, | ||
+ | tft.print(" | ||
+ | |||
+ | // Stunden auf | ||
+ | tft.setFont(AwesomeF100_32); | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.setCursor(100, | ||
+ | tft.print((char)6); | ||
+ | |||
+ | // Stunde anzeigen | ||
+ | tft.fillRect(90, | ||
+ | tft.setFont(DroidSans_24); | ||
+ | tft.setCursor(95, | ||
+ | if(displayedAlarmHour < 10) { | ||
+ | tft.print(' | ||
+ | } | ||
+ | tft.print(displayedAlarmHour); | ||
+ | |||
+ | // Stunde ab | ||
+ | tft.setFont(AwesomeF100_32); | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.setCursor(100, | ||
+ | tft.print((char)7); | ||
+ | |||
+ | // Doppelpunkt | ||
+ | tft.setCursor(159, | ||
+ | tft.setFont(DroidSans_24); | ||
+ | tft.print(":" | ||
+ | |||
+ | // Minuten auf | ||
+ | tft.setFont(AwesomeF100_32); | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.setCursor(195, | ||
+ | tft.print((char)6); | ||
+ | |||
+ | // Minuten anzeigen | ||
+ | tft.fillRect(185, | ||
+ | tft.setFont(DroidSans_24); | ||
+ | tft.setCursor(192, | ||
+ | if(displayedAlarmMinute < 10) { | ||
+ | tft.print(' | ||
+ | } | ||
+ | tft.print(displayedAlarmMinute); | ||
+ | |||
+ | // Minuten ab | ||
+ | tft.setFont(AwesomeF100_32); | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.setCursor(195, | ||
+ | tft.print((char)7); | ||
+ | | ||
+ | // Alarmmodus anzeigen | ||
+ | tft.setFont(DroidSans_13); | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | if (alarmMode == 0) { | ||
+ | tft.setCursor(125, | ||
+ | tft.print(" | ||
+ | } | ||
+ | else if (alarmMode == 1) { | ||
+ | tft.setCursor(95, | ||
+ | tft.print(" | ||
+ | } | ||
+ | else if (alarmMode == 2) { | ||
+ | tft.setCursor(95, | ||
+ | tft.print(" | ||
+ | } | ||
+ | else if (alarmMode == 3) { | ||
+ | tft.setCursor(75, | ||
+ | tft.print(" | ||
+ | } | ||
+ | | ||
+ | // Weiter zur Auswahl des Programmmodus | ||
+ | tft.setFont(AwesomeF100_32); | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.setCursor(290, | ||
+ | tft.print((char)1); | ||
+ | | ||
+ | TFTrefresh = false; | ||
+ | } | ||
+ | |||
+ | // Unteruntermenü " | ||
+ | if (menuPage == 51 && TFTrefresh == true) { | ||
+ | | ||
+ | // Zurück zum " | ||
+ | tft.setFont(AwesomeF100_32); | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.setCursor(6, | ||
+ | tft.print((char)0); | ||
+ | | ||
+ | // Optionen | ||
+ | if (alarmMode == 0) { | ||
+ | tft.fillRect(60, | ||
+ | tft.setFont(AwesomeF000_24); | ||
+ | tft.setCursor(60, | ||
+ | tft.print((char)88); | ||
+ | } | ||
+ | else { | ||
+ | tft.fillRect(60, | ||
+ | tft.setFont(AwesomeF000_24); | ||
+ | tft.setCursor(60, | ||
+ | tft.print((char)87); | ||
+ | } | ||
+ | tft.setFont(DroidSans_13); | ||
+ | tft.setCursor(100, | ||
+ | tft.print(" | ||
+ | | ||
+ | if (alarmMode == 1) { | ||
+ | tft.fillRect(60, | ||
+ | tft.setFont(AwesomeF000_24); | ||
+ | tft.setCursor(60, | ||
+ | tft.print((char)88); | ||
+ | } | ||
+ | else { | ||
+ | tft.fillRect(60, | ||
+ | tft.setFont(AwesomeF000_24); | ||
+ | tft.setCursor(60, | ||
+ | tft.print((char)87); | ||
+ | } | ||
+ | tft.setFont(DroidSans_13); | ||
+ | tft.setCursor(100, | ||
+ | tft.print(" | ||
+ | | ||
+ | if (alarmMode == 2) { | ||
+ | tft.fillRect(60, | ||
+ | tft.setFont(AwesomeF000_24); | ||
+ | tft.setCursor(60, | ||
+ | tft.print((char)88); | ||
+ | } | ||
+ | else { | ||
+ | tft.fillRect(60, | ||
+ | tft.setFont(AwesomeF000_24); | ||
+ | tft.setCursor(60, | ||
+ | tft.print((char)87); | ||
+ | } | ||
+ | tft.setFont(DroidSans_13); | ||
+ | tft.setCursor(100, | ||
+ | tft.print(" | ||
+ | | ||
+ | if (alarmMode == 3) { | ||
+ | tft.fillRect(60, | ||
+ | tft.setFont(AwesomeF000_24); | ||
+ | tft.setCursor(60, | ||
+ | tft.print((char)88); | ||
+ | } | ||
+ | else { | ||
+ | tft.fillRect(60, | ||
+ | tft.setFont(AwesomeF000_24); | ||
+ | tft.setCursor(60, | ||
+ | tft.print((char)87); | ||
+ | } | ||
+ | tft.setFont(DroidSans_13); | ||
+ | tft.setCursor(100, | ||
+ | tft.print(" | ||
+ | |||
+ | // Weiter zur Auswahl der Wecklautstärke | ||
+ | tft.setFont(AwesomeF100_32); | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.setCursor(290, | ||
+ | tft.print((char)1); | ||
+ | | ||
+ | TFTrefresh = false; | ||
+ | } | ||
+ | |||
+ | |||
+ | // Untermenü " | ||
+ | if (menuPage == 52 && TFTrefresh == true) { | ||
+ | | ||
+ | // Zurück zu " | ||
+ | tft.setFont(AwesomeF100_32); | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.setCursor(6, | ||
+ | tft.print((char)0); | ||
+ | | ||
+ | // Lautstärke | ||
+ | tft.fillRect(213, | ||
+ | | ||
+ | tft.setFont(AwesomeF000_28); | ||
+ | tft.setCursor(250, | ||
+ | tft.print((char)40); | ||
+ | | ||
+ | tft.setFont(DroidSans_10); | ||
+ | tft.setCursor(225, | ||
+ | tft.print(" | ||
+ | | ||
+ | tft.setFont(AwesomeF000_28); | ||
+ | tft.setCursor(255, | ||
+ | tft.print((char)39); | ||
+ | |||
+ | TFTrefresh = false; | ||
+ | } | ||
+ | |||
+ | // Untermenü " | ||
+ | if (menuPage == 7 && TFTrefresh == true) { | ||
+ | tft.fillScreen(ILI9341_BLACK); | ||
+ | | ||
+ | // Wecker/ | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.setFont(DroidSans_18_Bold); | ||
+ | if (snoozeOn == false) { | ||
+ | tft.setCursor(60, | ||
+ | tft.print(" | ||
+ | } | ||
+ | else if (snoozeOn == true) { | ||
+ | tft.setCursor(30, | ||
+ | tft.print(" | ||
+ | } | ||
+ | tft.setCursor(85, | ||
+ | tft.print(" | ||
+ | |||
+ | tft.fillRect(213, | ||
+ | |||
+ | // Schlummern | ||
+ | tft.setFont(DroidSans_10); | ||
+ | tft.setCursor(225, | ||
+ | tft.print(" | ||
+ | |||
+ | TFTrefresh = false; | ||
+ | } | ||
+ | |||
+ | // Untermenü " | ||
+ | if (menuPage == 8 && TFTrefresh == true) { | ||
+ | tft.fillScreen(ILI9341_BLACK); | ||
+ | | ||
+ | // Snoozle aus | ||
+ | tft.setTextColor(ILI9341_WHITE); | ||
+ | tft.setFont(DroidSans_18_Bold); | ||
+ | tft.setCursor(60, | ||
+ | tft.print(" | ||
+ | tft.setCursor(85, | ||
+ | tft.print(" | ||
+ | | ||
+ | // Lautstärke | ||
+ | tft.fillRect(213, | ||
+ | | ||
+ | tft.setFont(AwesomeF000_28); | ||
+ | tft.setCursor(250, | ||
+ | tft.print((char)40); | ||
+ | | ||
+ | tft.setFont(DroidSans_10); | ||
+ | tft.setCursor(225, | ||
+ | tft.print(" | ||
+ | | ||
+ | tft.setFont(AwesomeF000_28); | ||
+ | tft.setCursor(255, | ||
+ | tft.print((char)39); | ||
+ | |||
+ | TFTrefresh = false; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | touch = false; | ||
+ | touch2 = false; | ||
+ | | ||
+ | //Speichere die aktuelle Zeit in die zughörige Variable | ||
+ | | ||
+ | } | ||
+ | |||
+ | // Ausgabe an die serielle Schnittstelle | ||
+ | if ((unsigned long)(currentMillis - previousMillisSerialPrint) >= intervalSerialPrint) { | ||
+ | /* | ||
+ | // Gibt die aktuelle Zeit aus | ||
+ | Serial.print(hour()); | ||
+ | printDigits(minute()); | ||
+ | printDigits(second()); | ||
+ | Serial.print(" | ||
+ | Serial.print(day()); | ||
+ | Serial.print(" | ||
+ | Serial.print(month()); | ||
+ | Serial.print(" | ||
+ | Serial.print(year()); | ||
+ | Serial.print(" | ||
+ | Serial.print(weekday()); | ||
+ | printDCFsyncTime(); | ||
+ | | ||
+ | Serial.print(" | ||
+ | Serial.print(menuPage); | ||
+ | Serial.print("; | ||
+ | Serial.print(TFTbrightness); | ||
+ | |||
+ | Serial.print("; | ||
+ | Serial.print(receivedDCFsignals); | ||
+ | */ | ||
+ | // Display the results (acceleration is measured in m/s^2) | ||
+ | /* | ||
+ | Serial.print("; | ||
+ | Serial.print(" | ||
+ | Serial.print(" | ||
+ | |||
+ | // ' | ||
+ | Serial.print(F("; | ||
+ | Serial.print(roll); | ||
+ | Serial.print(F(" | ||
+ | Serial.print(pitch); | ||
+ | Serial.print(F(" | ||
+ | Serial.print(heading); | ||
+ | Serial.print(F("" | ||
+ | |||
+ | Serial.print("; | ||
+ | Serial.print(filteredAccelZ); | ||
+ | Serial.print("; | ||
+ | Serial.print(filteredRoll); | ||
+ | Serial.print("; | ||
+ | Serial.print(filteredPitch); | ||
+ | | ||
+ | Serial.print("; | ||
+ | Serial.print(eventAccelZ); | ||
+ | | ||
+ | Serial.print(eventRoll); | ||
+ | Serial.print("; | ||
+ | Serial.print(eventPitch); | ||
+ | */ | ||
+ | Serial.println(); | ||
+ | //Speichere die aktuelle Zeit in die zughörige Variable | ||
+ | previousMillisSerialPrint = currentMillis; | ||
+ | } | ||
+ | |||
+ | // Misst die Periode und Pusweite des vom DCF77-Modul empfangenen Signals in Millisekunden | ||
+ | if ((unsigned long)(currentMillis - previousMillisDCFPulseLength) >= intervalDCFPulseLength) { | ||
+ | |||
+ | int sensorValue = !digitalRead(DCF_PIN); | ||
+ | if (sensorValue) { | ||
+ | if (!Up) { | ||
+ | flankUp=millis(); | ||
+ | Up = true; | ||
+ | } | ||
+ | } else { | ||
+ | if (Up) { | ||
+ | flankDown=millis(); | ||
+ | Serial.print(" | ||
+ | Serial.print(flankUp-PreviousflankUp); | ||
+ | Serial.print(" | ||
+ | Serial.println(flankDown - flankUp); | ||
+ | PreviousflankUp = flankUp; | ||
+ | Up = false; | ||
+ | } | ||
+ | } | ||
+ | | ||
+ | //Speichere die aktuelle Zeit in die zughörige Variable | ||
+ | previousMillisDCFPulseLength = currentMillis; | ||
+ | } | ||
+ | |||
+ | |||
+ | |||
+ | } | ||
+ | |||
+ | |||
+ | time_t getTeensy3Time() | ||
+ | { | ||
+ | return Teensy3Clock.get(); | ||
+ | } | ||
+ | |||
+ | |||
+ | /* code to process time sync messages from the serial port */ | ||
+ | #define TIME_HEADER | ||
+ | |||
+ | unsigned long processSyncMessage() { | ||
+ | time_t pctime = 0L; | ||
+ | //unsigned long pctime = 0L; | ||
+ | |||
+ | if(Serial.find(TIME_HEADER)) { | ||
+ | | ||
+ | | ||
+ | if( pctime < DefaultTime) { // check the value is a valid time (greater than Nov 1 2016) | ||
+ | | ||
+ | } | ||
+ | } | ||
+ | return pctime; | ||
+ | Serial.print(" | ||
+ | Serial.print(pctime); | ||
+ | } | ||
+ | |||
+ | |||
+ | void tftprintDigits(int digits) { | ||
+ | // utility function for digital clock display: prints preceding colon and leading 0 | ||
+ | tft.print(":" | ||
+ | if(digits < 10) | ||
+ | tft.print(' | ||
+ | tft.print(digits); | ||
+ | } | ||
+ | |||
+ | |||
+ | void printDigits(int digits) { | ||
+ | // utility function for digital clock display: prints preceding colon and leading 0 | ||
+ | Serial.print(":" | ||
+ | if(digits < 10) | ||
+ | Serial.print(' | ||
+ | Serial.print(digits); | ||
+ | } | ||
+ | |||
+ | |||
+ | void tftprintDCFsyncTime() { | ||
+ | if (DCFtimesignalFound == false){ | ||
+ | tft.println(" | ||
+ | tft.print(noDCFsignal); | ||
+ | tft.print(" | ||
+ | } | ||
+ | else { | ||
+ | tft.println(" | ||
+ | tft.print(timesinceDCFsignal); | ||
+ | tft.print(" | ||
+ | } | ||
+ | } | ||
+ | |||
+ | |||
+ | void printDCFsyncTime() { | ||
+ | if (DCFtimesignalFound == false){ | ||
+ | Serial.print(" | ||
+ | Serial.print(noDCFsignal); | ||
+ | Serial.print(" | ||
+ | } | ||
+ | else { | ||
+ | Serial.print(" | ||
+ | Serial.print(timesinceDCFsignal); | ||
+ | Serial.print(" | ||
+ | } | ||
+ | } | ||
+ | |||
+ | |||
+ | void tftprintDCFsyncCycle() { | ||
+ | if (DCFtimesignalFound == false){ | ||
+ | tft.println(" | ||
+ | tft.print(noDCFsignal / 60); | ||
+ | tft.print(" | ||
+ | } | ||
+ | else { | ||
+ | tft.println(" | ||
+ | tft.print(timesinceDCFsignal /60); | ||
+ | tft.print(" | ||
+ | } | ||
+ | } | ||
+ | |||
+ | |||
+ | void logSDcard() { | ||
+ | | ||
+ | // Daten auf SD-Karte loggen | ||
+ | // open the file. note that only one file can be open at a time, | ||
+ | // so you have to close this one before opening another. | ||
+ | File dataFile = SD.open(" | ||
+ | |||
+ | // if the file is available, write to it: | ||
+ | if (dataFile) { | ||
+ | dataFile.print(millis()); | ||
+ | dataFile.print("," | ||
+ | dataFile.println(accelZ); | ||
+ | dataFile.close(); | ||
+ | // print to the serial port too: | ||
+ | Serial.print(millis()); | ||
+ | Serial.print("," | ||
+ | Serial.println(lux); | ||
+ | } | ||
+ | // if the file isn't open, pop up an error: | ||
+ | else { | ||
+ | Serial.println(" | ||
+ | } | ||
+ | } | ||
</ | </ | ||
+ | Der Sketch verwendet 170.088 Bytes (16%) des Programmspeicherplatzes. Das Maximum sind 1.048.576 Bytes. | ||
+ | Globale Variablen verwenden 13.180 Bytes (5%) des dynamischen Speichers, 248.964 Bytes für lokale Variablen verbleiben. Das Maximum sind 262.144 Bytes. | ||
- | Tags: #Arduino | + | {{tag>Arduino Schlafphasenwecker |
arduino/schlafphasenwecker/programmversion_0.7.1486824555.txt.gz · Zuletzt geändert: 18.05.2023 12:16 (Externe Bearbeitung)