Untitled
unknown
c_cpp
a year ago
68 kB
27
Indexable
//////////////////////////////////////////////////////////////////////////////////////////////////////// Bibliotheken #include <Adafruit_SSD1327.h> #include <Adafruit_GFX.h> #include <FlashStorage.h> #include <Adafruit_SharpMem.h> #include <Wire.h> #include <Adafruit_Sensor.h> #include <Adafruit_MPU6050.h> #include <Adafruit_BMP280.h> //////////////////////////////////////////////////////////////////////////////////////////////////////// Definitionen #define SEALEVELPRESSURE_HPA (pressure) #define SHARP_SCK 8 #define SHARP_MOSI 10 #define SHARP_SS 7 #define BLACK 0 #define WHITE 1 Adafruit_BMP280 bmp; Adafruit_SharpMem display(SHARP_SCK, SHARP_MOSI, SHARP_SS, 144, 168); Adafruit_MPU6050 mpu; //////////////////////////////////////////////////////////////////////////////////////////////////////// Schriftarten #include <Fonts\FreeMono9pt7b.h> #include <Fonts\FreeMono12pt7b.h> #include <Fonts\FreeMono18pt7b.h> #include <Fonts\FreeMono24pt7b.h> #include <Fonts\FreeMonoBold9pt7b.h> #include <Fonts\FreeMonoBold12pt7b.h> #include <Fonts\FreeMonoBold18pt7b.h> #include <Fonts\FreeMonoBold24pt7b.h> //////////////////////////////////////////////////////////////////////////////////////////////////////// Variablen //Display int dh = 144; //resolution graph vertical int dw = 168; //resolution graph horizontal int dx = 50; //offset display horizontal float poti = 0.00; float poti1 = 0.00; //Sensor float pressure = 1013; //pressure for altimeter float temp1 = 0.00; //Sensor temperature float hum = 0.00; //Sensor humidity float alt = 2000; // Sensor altitude //Einstellungen int Hmax; //upper limit altitude graph int Hmin; //lower limit altitude graph float resalt; //Resolution altitude m/px float resaltgap = 1; float Tmax; //upper limit temperature graph float Tmin; //lower limit temperature graph float restemp; //resolution temperature °C/px //Menü int page = 1; // 1 = Temp sinken, 2 = Temp steigen, 3 = Temp sinken/steigen, 4 = G-Force, 5 = Thermal int menupos = 1; int valuepos = 6; // position menu int settingspos = 0; //settings menu bool modeflag = 0; // 1 = Normal, 2 = Demo bool settingsflag = 0; bool menuflag = 0; bool valueflag = 0; //Graph float winkel; int x; //graph X-coordinate int y; //graph Y-coordinate int yi; //y inverted int xw; //delta-x angle int xt; //delta-x temp int yp; int yip; int xp; int xwp; int xtp; //Höhenlinie int x01; int x02; int y01; int y02; int x03; int x04; int y03; int y04; int x01old; int x02old; int y01old; int y02old; int x03old; int x04old; int y03old; int y04old; //Timer unsigned long currentMillis; unsigned long seconds; unsigned long minutes; unsigned long hours; unsigned long starttime; unsigned long ontime; unsigned long savetimer = 3000; unsigned long saveinterval = 300000; float codetime; float codetime1; float codetime2; //Speicher FlashStorage(flash1, int); //Hmin FlashStorage(flash2, float); //resalt FlashStorage(flash3, int); //Tmax FlashStorage(flash4, float); //resTeamp FlashStorage(flash5, float); //pressure FlashStorage(flash6, unsigned long); //Ontime FlashStorage(flash7, float); //GLimit FlashStorage(flash8, unsigned long); //GForcetimerStartpage FlashStorage(flash9, bool); //GForceDisplayMode //FlashStorage(flash10, unsigned long); FlashStorage(flash11, float); //thermaltimerStartpage FlashStorage(flash12, float); //varioLimit FlashStorage(flash14, unsigned long); //climbmodeinterval FlashStorage(flash15, int); //saveinterval FlashStorage(flash16, bool); //GForceAutoswitch FlashStorage(flash17, bool); //thermalAutoswitch FlashStorage(flash18, unsigned long); //GForceInitDuration FlashStorage(flash19, unsigned long); //thermalInitDuration //Demomodus float alttest; float temptest; int altinc = 0; float tempinc = 0; float tempdemo; //Climbmode unsigned long climbmodetimer = 0; unsigned long climbmodeinterval; float altold; int climbmode = 0; float climbmodealt; //Variometer unsigned long variotimer = 1; unsigned long variotimerinterval = 1000; float AltVario = 0.00; //Array int drawlinecounter; int tempsave1[1000]; int tempsave2[1000]; int altsave; int altload; float tempsave11; float tempsave10; float tempsave22; float tempsave20; //GForcepage float GForce = 1.0; float GLimit = 2.0; float currentGForce; float lastGForce = 1.0; float lastGForcePrint = 1.0; float maxGForce = 1.0; bool GForceAutoswitch = HIGH; String GForceAutoswitchValue = "ON"; bool GForceDisplayMode = HIGH; String GForceDisplayModeValue; signed long GForceInitDuration = 2000; signed long GforcetimerStartpage = 5000; bool GForcemodeinit = 0; bool GForceStatus = 0; signed long GForceTimeStartInit; signed long GForceTimeStart; signed long GForceTimeEndInit; signed long GForceTimeEnd; signed long GForceTime = 1; int GForceAltStartInit; int GForceAltStart; int GForceAltEndInit; int GForceAltEnd; int GForceAlt; float divespeed; float divespeedmax; //Thermalpage float vario = 0.00; //Vario float varioLimit = 0.00; //Variolimit for Thermalmode float varioAlt; float maxVario; float avVario; bool thermalAutoswitch; String thermalAutoswitchValue; signed long thermalInitDuration = 2000; //time for thermalmode start with >variolimit signed long thermalTimerStartpage = 5000; bool thermalmodeinit = 0; bool thermalStatus; signed long thermalTimeStartInit; signed long thermalTimeStart; signed long thermalTimeEndInit; signed long thermalTimeEnd; signed long thermalTime = 1; signed long thermalSeconds; signed long thermalMinutes; float thermalAltStartInit; float thermalAltStart; float thermalAltEndInit; float thermalAltEnd; float thermalAlt; //pages int thermalpagedown = 1; int thermalpageup = 2; int thermalpageupdown = 3; int GForcepage = 4; int thermalpage = 5; int oldpage = 1; //Buttons int buttonpin1 = 1; int buttonpin2 = 2; int buttonpin3 = 3; const unsigned char logo1[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0xFF, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xE0, 0x00, 0x07, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x1F, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xF8, 0x1F, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xF8, 0x0F, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x01, 0xC0, 0x00, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xF0, 0x07, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xE0, 0x00, 0x1F, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x07, 0xFF, 0xF8, 0x00, 0x03, 0x01, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0x80, 0xC0, 0x01, 0xFC, 0x0F, 0xFF, 0xE0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x07, 0xFF, 0xE0, 0x3F, 0x80, 0x00, 0xFF, 0xE0, 0x3F, 0xFE, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x7F, 0xFC, 0x07, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x01, 0xFF, 0xF0, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x0F, 0xFF, 0x80, 0xFF, 0xFF, 0x00, 0x00, 0x7F, 0xFF, 0xF8, 0x1F, 0xFF, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0xFF, 0xF8, 0x1F, 0xFF, 0xFE, 0x00, 0x00, 0x07, 0xFF, 0xFF, 0xC0, 0x7F, 0xF0, 0x00, 0x30, 0x00, 0x00, 0x00, 0x02, 0x00, 0x0F, 0xFE, 0x03, 0xFF, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFE, 0x03, 0xFF, 0x00, 0x18, 0x00, 0x00, 0x00, 0x04, 0x00, 0xFF, 0xC0, 0x7F, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xF8, 0x1F, 0xF0, 0x0C, 0x00, 0x00, 0x00, 0x08, 0x1F, 0xF8, 0x1F, 0xFF, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x00, 0x1F, 0xFF, 0xC0, 0x7F, 0x86, 0x00, 0x00, 0x00, 0x11, 0xFE, 0x03, 0xFF, 0xF8, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xF0, 0x00, 0x7F, 0xFC, 0x07, 0x83, 0x00, 0x00, 0x00, 0x21, 0xE0, 0x3F, 0xFE, 0x00, 0x0F, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xF0, 0x00, 0xFF, 0xF1, 0xC1, 0x80, 0x00, 0x00, 0x43, 0x8F, 0xFF, 0x00, 0x0F, 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xFF, 0xE0, 0x00, 0xFC, 0xC0, 0xC0, 0x00, 0x00, 0x83, 0x1F, 0x00, 0x07, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x03, 0xFF, 0xE0, 0x1C, 0xE0, 0x60, 0x00, 0x01, 0x07, 0x38, 0x07, 0xFF, 0xC0, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xE0, 0x01, 0xFF, 0xCE, 0x60, 0x20, 0x00, 0x02, 0x06, 0x73, 0xFF, 0x80, 0x07, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xF8, 0x00, 0x27, 0x30, 0x10, 0x00, 0x06, 0x0C, 0xE4, 0x00, 0x1F, 0xFF, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xFF, 0xFF, 0xFF, 0x01, 0x90, 0x08, 0x00, 0x0C, 0x09, 0x80, 0xFF, 0xFF, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xFC, 0xC8, 0x04, 0x0C, 0x18, 0x13, 0x3F, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x64, 0x02, 0x1E, 0x10, 0x26, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0xF0, 0x10, 0x01, 0x3E, 0x20, 0x08, 0x0F, 0xFF, 0xFF, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9E, 0x40, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x4C, 0x80, 0x03, 0xFF, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFC, 0xC1, 0x06, 0x0C, 0x31, 0x07, 0x06, 0x18, 0x03, 0xC3, 0xF0, 0x03, 0x80, 0xF0, 0x0C, 0x30, 0x78, 0x60, 0xC7, 0xF0, 0x01, 0xFC, 0x81, 0x08, 0x08, 0x21, 0x1F, 0x84, 0x10, 0x0F, 0xC3, 0xF8, 0x0F, 0xC3, 0xF0, 0x08, 0x21, 0xF8, 0x60, 0xC7, 0xF0, 0x01, 0x00, 0x81, 0x18, 0x08, 0x23, 0x10, 0xC4, 0x10, 0x08, 0x62, 0x18, 0x08, 0x62, 0x18, 0x08, 0x21, 0x0C, 0x61, 0xC4, 0x00, 0x02, 0x01, 0x01, 0x90, 0x10, 0x62, 0x20, 0x08, 0x30, 0x10, 0x44, 0x10, 0x10, 0x04, 0x10, 0x10, 0x62, 0x08, 0xE2, 0x88, 0x00, 0x02, 0x01, 0x01, 0xA0, 0x10, 0x42, 0x20, 0x08, 0x20, 0x10, 0x44, 0x10, 0x10, 0x04, 0x10, 0x10, 0x42, 0x08, 0xA2, 0x88, 0x00, 0x03, 0xE1, 0x00, 0xC0, 0x1F, 0xC6, 0x63, 0x8F, 0xE0, 0x30, 0xC7, 0xE0, 0x31, 0xCC, 0x30, 0x1F, 0xC6, 0x18, 0xA4, 0x8F, 0x80, 0x07, 0xE2, 0x00, 0x80, 0x3F, 0xC4, 0x47, 0x1F, 0xE0, 0x20, 0x8F, 0xC0, 0x23, 0x88, 0x20, 0x3F, 0xC4, 0x11, 0x29, 0x1F, 0x80, 0x04, 0x02, 0x00, 0x80, 0x20, 0x84, 0x41, 0x10, 0x40, 0x20, 0x88, 0x80, 0x20, 0x88, 0x20, 0x20, 0x84, 0x11, 0x39, 0x10, 0x00, 0x04, 0x02, 0x01, 0x80, 0x20, 0x8C, 0x43, 0x10, 0x40, 0x21, 0x08, 0xC0, 0x21, 0x88, 0x40, 0x20, 0x84, 0x21, 0x31, 0x10, 0x00, 0x08, 0x07, 0xF1, 0x00, 0x41, 0x88, 0x7E, 0x20, 0xC0, 0x3F, 0x10, 0xC0, 0x3F, 0x0F, 0xC0, 0x41, 0x87, 0xE2, 0x22, 0x3F, 0x80, 0x08, 0x07, 0xF1, 0x00, 0x41, 0x08, 0x38, 0x20, 0x80, 0x1C, 0x10, 0x40, 0x1C, 0x07, 0x00, 0x41, 0x03, 0x82, 0x02, 0x3F, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; void setup() { InitHW(); Drawlogo(); LoadSettings(); } void loop() { saveSettings(); OnTimeCounter(); Climbmode(); Displaymode(); saveTempArray(); AutoAltArea(); Vario(); GForceValues(); triggerGForcemodeStart(); triggerGForcemodeEnd(); triggerStartpageGForce(); Spiraldata(); triggerThermalmodeStart(); triggerThermalmodeEnd(); triggerStartpageThermal(); thermalValues(); varioAlt = vario; Codetime(); pages(); display.refresh(); delay(1); // Pause TestValues(); } void InitHW() { Serial.begin(9600); //Beschleunigungssensor if (!mpu.begin()) { Serial.println("Failed to find MPU6050 chip"); while (1) { delay(10); } } //Display display.begin(); display.clearDisplay(); display.setRotation(1); display.setTextSize(1); display.setTextColor(BLACK); //Drucksensor bmp.begin(0x76); //Beschleunigungssensor mpu.setAccelerometerRange(MPU6050_RANGE_16_G); mpu.setGyroRange(MPU6050_RANGE_250_DEG); mpu.setFilterBandwidth(MPU6050_BAND_21_HZ); Serial.println(""); delay(100); //Pins pinMode(0, INPUT); pinMode(1, INPUT); pinMode(2, INPUT); pinMode(3, INPUT); } void Drawlogo() { display.drawBitmap(0, 0, logo1, 168, 144, 0); display.refresh(); delay(4000); display.clearDisplay(); } void LoadSettings() { Hmin = flash1.read(); if (Hmin == 0) { Hmin = 200; } resalt = flash2.read(); if (resalt == 0) { resalt = 10; } Tmax = flash3.read(); if (Tmax == 0) { Tmax = 31; } restemp = flash4.read(); if (restemp == 0) { restemp = 0.1; } pressure = flash5.read(); if (pressure == 0) { pressure = 1020; } starttime = flash6.read(); GLimit = flash7.read(); if (GLimit == 0) { GLimit = 2; } GforcetimerStartpage = flash8.read(); if (GforcetimerStartpage == 0) { GforcetimerStartpage = 5000; } GForceDisplayMode = flash9.read(); if (GForceDisplayMode == 0) { GForceDisplayMode = 1; } thermalTimerStartpage = flash11.read(); if (thermalTimerStartpage == 0) { thermalTimerStartpage = 5000; } varioLimit = flash12.read(); if (varioLimit == 0) { varioLimit = 0.5; } climbmodeinterval = flash14.read(); if (climbmodeinterval == 0) { climbmodeinterval = 5000; } saveinterval = flash15.read(); if (saveinterval == 0) { saveinterval = 300000; } GForceAutoswitch = flash16.read(); thermalAutoswitch = flash17.read(); GForceInitDuration = flash18.read(); if (GForceInitDuration == 0) { GForceInitDuration = 5000; } thermalInitDuration = flash19.read(); if (thermalInitDuration == 0) { thermalInitDuration = 5000; } } void pages() { buttons(); if (page > 5) { page = 1; ClearSensorArea(); ClearPlotArea(); } if (settingspos > 11) { settingspos = 0; settingsflag = LOW; ClearSensorArea(); ClearPlotArea(); } if (menupos > 8) { menuflag = LOW; ClearSensorArea(); ClearPlotArea(); menupos = 0; } if (valuepos > 6) { valuepos = 1; } if (page == thermalpagedown || page == thermalpageup || page == thermalpageupdown) { DrawAltLine(); ClearSensorArea(); DisplaySensorData(); DrawTempLine(); DrawLines(); PlotPosMarker(); } if (page == thermalpagedown) { DrawDown(); } if (page == thermalpageup) { DrawUp(); } if (page == thermalpageupdown) { DrawUpDown(); } if (page == GForcepage) { ClearSensorArea(); ClearPlotArea(); display.setFont(&FreeMono9pt7b); display.setCursor(1, 12); display.setTextSize(1); display.setTextColor(BLACK); display.print("Time"); display.setFont(&FreeMonoBold18pt7b); display.setCursor(1, 38); display.setTextSize(1); display.setTextColor(BLACK); display.print(GForceTime); display.setFont(&FreeMono9pt7b); display.setCursor(102, 12); display.setTextSize(1); display.setTextColor(BLACK); display.print("Alt."); display.setFont(&FreeMonoBold18pt7b); display.setCursor(102, 38); display.setTextSize(1); display.setTextColor(BLACK); display.print(GForceAlt); display.setFont(&FreeMono9pt7b); display.setCursor(53, 12); display.setTextSize(1); display.setTextColor(BLACK); display.print("m/s"); display.setFont(&FreeMonoBold12pt7b); display.setCursor(53, 38); display.setTextSize(1); display.setTextColor(BLACK); display.print(divespeedmax, 1); display.setFont(&FreeMonoBold18pt7b); display.setCursor(21, 93); display.setTextSize(2); display.setTextColor(BLACK); display.print(GForce, 1); display.setFont(&FreeMono9pt7b); display.setCursor(11, 112); display.setTextSize(1); display.setTextColor(BLACK); display.print("MAX G:"); display.setFont(&FreeMonoBold18pt7b); display.setCursor(5, 138); display.setTextSize(1); display.setTextColor(BLACK); display.print(maxGForce, 1); display.setFont(&FreeMono9pt7b); display.setCursor(89, 112); display.setTextSize(1); display.setTextColor(BLACK); display.print("LAST G:"); display.setFont(&FreeMonoBold18pt7b); display.setCursor(95, 138); display.setTextSize(1); display.setTextColor(BLACK); display.print(lastGForcePrint, 1); display.drawLine(49, 0, 49, 44, BLACK); // vertical display.drawLine(100, 0, 100, 44, BLACK); // vertical display.drawLine(84, 100, 84, dh, BLACK); // vertical display.drawLine(0, 100, dw, 100, BLACK); // horizontal display.drawLine(0, 44, dw, 44, BLACK); // horizontal display.setTextSize(1); display.setFont(); } if (page == thermalpage) { ClearSensorArea(); ClearPlotArea(); display.setFont(&FreeMono9pt7b); display.setCursor(11, 12); display.setTextSize(1); display.setTextColor(BLACK); display.print("max."); display.setFont(&FreeMonoBold18pt7b); display.setCursor(11, 38); display.setTextSize(1); display.setTextColor(BLACK); if (thermalmodeinit == 0) { display.print("0.0"); } else { display.print(maxVario, 1); } display.setFont(&FreeMono9pt7b); display.setCursor(95, 12); display.setTextSize(1); display.setTextColor(BLACK); display.print("avrg."); display.setFont(&FreeMonoBold18pt7b); display.setCursor(95, 38); display.setTextSize(1); display.setTextColor(BLACK); if (thermalmodeinit == 0) { display.print("0.0"); } else { display.print(avVario, 1); } if (vario < 0) { display.setCursor(-21, 93); } else { display.setCursor(21, 93); } display.setFont(&FreeMonoBold18pt7b); display.setTextSize(2); display.setTextColor(BLACK); display.print(vario, 1); display.setFont(&FreeMono9pt7b); display.setCursor(11, 112); display.setTextSize(1); display.setTextColor(BLACK); display.print("Climb:"); display.setFont(&FreeMonoBold18pt7b); display.setCursor(-1, 138); display.setTextSize(1); display.setTextColor(BLACK); if (thermalmodeinit == 0) { display.print("0"); } else { display.print(thermalAlt, 0); } display.setFont(&FreeMono9pt7b); display.setCursor(95, 112); display.setTextSize(1); display.setTextColor(BLACK); display.print("Time:"); display.setFont(&FreeMonoBold18pt7b); display.setCursor(83, 138); display.setTextSize(1); display.setTextColor(BLACK); if (thermalmodeinit == 0) { display.print("0"); } else { display.printf("%02d", thermalMinutes); display.setCursor(116, 138); display.print(":"); display.setCursor(127, 138); display.printf("%02d", thermalSeconds); } display.drawLine(84, 0, 84, 44, BLACK); // vertical display.drawLine(84, 100, 84, dh, BLACK); // vertical display.drawLine(0, 100, dw, 100, BLACK); // horizontal display.drawLine(0, 44, dw, 44, BLACK); // horizontal display.setTextSize(1); display.setFont(); } if (menuflag == 1) { ClearSensorArea(); ClearPlotArea(); display.setTextSize(2); display.setTextColor(BLACK); display.setCursor(1, 10); if (menupos == 1) { display.setTextColor(WHITE, BLACK); } else { display.setTextColor(BLACK); } display.print("Reset GForce"); display.setCursor(1, 26); if (menupos == 2) { display.setTextColor(WHITE, BLACK); } else { display.setTextColor(BLACK); } display.print("Reset ON-Time"); display.setCursor(1, 42); if (menupos == 3) { display.setTextColor(WHITE, BLACK); } else { display.setTextColor(BLACK); } display.print("Edit Values"); display.setCursor(1, 58); if (menupos == 4) { display.setTextColor(WHITE, BLACK); } else { display.setTextColor(BLACK); } display.print("Del.Graph DN"); display.setCursor(1, 74); if (menupos == 5) { display.setTextColor(WHITE, BLACK); } else { display.setTextColor(BLACK); } display.print("Del.Graph UP"); display.setCursor(1, 90); if (menupos == 6) { display.setTextColor(WHITE, BLACK); } else { display.setTextColor(BLACK); } display.print("Del.Graph"); display.setCursor(1, 106); if (menupos == 7) { display.setTextColor(WHITE, BLACK); } else { display.setTextColor(BLACK); } display.print("Settings"); display.setCursor(1, 122); if (menupos == 8) { display.setTextColor(WHITE, BLACK); } else { display.setTextColor(BLACK); } display.print("Demomode"); display.setFont(); display.setTextSize(1); } if (settingsflag == 1) { ClearSensorArea(); ClearPlotArea(); display.setCursor(2, 1); display.setTextColor(BLACK); display.println("G-Force Limit:"); display.setCursor(140, 1); if (settingspos == 1) { display.setTextColor(WHITE, BLACK); } else { display.setTextColor(BLACK); } display.print(GLimit, 1); display.setCursor(2, 13); display.setTextColor(BLACK); display.println("Init Duration G-Force:"); display.setCursor(140, 13); if (settingspos == 2) { display.setTextColor(WHITE, BLACK); } else { display.setTextColor(BLACK); } display.print(GForceInitDuration / 1000); display.setCursor(2, 25); display.setTextColor(BLACK); display.println("G-Force Display:"); display.setCursor(140, 25); if (settingspos == 3) { display.setTextColor(WHITE, BLACK); } else { display.setTextColor(BLACK); } display.print(GForceDisplayModeValue); display.setCursor(2, 37); display.setTextColor(BLACK); display.println("Autoswitch G-Forcepage:"); display.setCursor(140, 37); if (settingspos == 4) { display.setTextColor(WHITE, BLACK); } else { display.setTextColor(BLACK); } display.print(GForceAutoswitchValue); display.setCursor(2, 49); display.setTextColor(BLACK); display.println("Startpagetimer G-Force:"); display.setCursor(140, 49); if (settingspos == 5) { display.setTextColor(WHITE, BLACK); } else { display.setTextColor(BLACK); } display.print(GforcetimerStartpage / 1000); display.setCursor(2, 66); display.setTextColor(BLACK); display.println("Variolimit:"); display.setCursor(140, 66); if (settingspos == 6) { display.setTextColor(WHITE, BLACK); } else { display.setTextColor(BLACK); } display.print(varioLimit, 1); display.setCursor(2, 78); display.setTextColor(BLACK); display.println("Init Duration Thermal:"); display.setCursor(140, 78); if (settingspos == 7) { display.setTextColor(WHITE, BLACK); } else { display.setTextColor(BLACK); } display.print(thermalInitDuration / 1000); display.setCursor(2, 90); display.setTextColor(BLACK); display.println("Autoswitch Thermalpage:"); display.setCursor(140, 90); if (settingspos == 8) { display.setTextColor(WHITE, BLACK); } else { display.setTextColor(BLACK); } display.print(thermalAutoswitchValue); display.setCursor(2, 102); display.setTextColor(BLACK); display.println("Startpagetimer Thermal:"); display.setCursor(140, 102); if (settingspos == 9) { display.setTextColor(WHITE, BLACK); } else { display.setTextColor(BLACK); } display.print(thermalTimerStartpage / 1000); display.setCursor(2, 119); display.setTextColor(BLACK); display.println("Climbmodeinterval:"); display.setCursor(140, 119); if (settingspos == 10) { display.setTextColor(WHITE, BLACK); } else { display.setTextColor(BLACK); } display.print(climbmodeinterval / 1000); display.setCursor(2, 131); display.setTextColor(BLACK); display.println("Saveinterval Ontime:"); display.setCursor(140, 131); if (settingspos == 11) { display.setTextColor(WHITE, BLACK); } else { display.setTextColor(BLACK); } display.print(saveinterval / 1000); if (GForceAutoswitch == LOW) { GForceAutoswitchValue = "OFF"; } if (GForceAutoswitch == HIGH) { GForceAutoswitchValue = "ON"; } if (thermalAutoswitch == 0) { thermalAutoswitchValue = "OFF"; } if (thermalAutoswitch == 1) { thermalAutoswitchValue = "ON"; } } } void Climbmode() { if (climbmodeinterval < (millis() - climbmodetimer)) { climbmodealt = alt - altold; altold = alt; climbmodetimer = millis(); } if (climbmodealt < 0) { climbmode = 0; } if (climbmodealt > 0) { climbmode = 1; } } void AutoAltArea() { if (alt > Hmax) { resalt = resalt + 1; } if (alt < Hmin) { Hmin = Hmin - 100; } } void saveSettings() { if (flash1.read() != Hmin) { flash1.write(Hmin); } if (flash2.read() != resalt) { flash2.write(resalt); } if (flash3.read() != Tmax) { flash3.write(Tmax); } if (flash4.read() != restemp) { flash4.write(restemp); } if (flash5.read() != pressure) { flash5.write(pressure); } if (saveinterval < (millis() - savetimer)) { flash6.write(ontime); savetimer = millis(); } if (flash7.read() != GLimit) { flash7.write(GLimit); } if (flash8.read() != GforcetimerStartpage) { flash8.write(GforcetimerStartpage); } if (flash9.read() != GForceDisplayMode) { flash9.write(GForceDisplayMode); } if (flash11.read() != thermalTimerStartpage) { flash11.write(thermalTimerStartpage); } if (flash12.read() != varioLimit) { flash12.write(varioLimit); } if (flash14.read() != climbmodeinterval) { flash14.write(climbmodeinterval); } if (flash15.read() != saveinterval) { flash15.write(saveinterval); } if (flash16.read() != GForceAutoswitch) { flash16.write(GForceAutoswitch); } if (flash17.read() != thermalAutoswitch) { flash17.write(thermalAutoswitch); } if (flash18.read() != GForceInitDuration) { flash18.write(GForceInitDuration); } if (flash19.read() != thermalInitDuration) { flash19.write(thermalInitDuration); } } void saveTempArray() { if (modeflag == LOW && climbmode == 0 && millis() > 10000) { if (temp1 != tempsave1[altsave]) { tempsave1[altsave] = temp1 * 100; } } if (modeflag == LOW && climbmode == 1 && millis() > 10000) { if (temp1 != tempsave2[altsave]) { tempsave2[altsave] = temp1 * 100; } } } void clearArray1() { for (int altsave = 0; altsave < 1000; altsave++) { tempsave1[altsave] = 0; } display.setCursor(80, 134); display.setTextColor(BLACK); display.println("E R A S E"); } void clearArray2() { for (int altsave = 0; altsave < 1000; altsave++) { tempsave2[altsave] = 0; } display.setCursor(80, 134); display.setTextColor(BLACK); display.println("E R A S E"); } void clearArray3() { for (int altsave = 0; altsave < 1000; altsave++) { tempsave1[altsave] = 0; } for (int altsave = 0; altsave < 1000; altsave++) { tempsave2[altsave] = 0; } display.setCursor(60, 134); display.setTextColor(BLACK); display.println("E R A S E A L L"); } void ClearSensorArea() { display.fillRect(0, 0, dx, dh, WHITE); } void ClearPlotArea() { display.fillRect(dx, 0, dw, dh, WHITE); } void Displaymode() { altsave = (alt / 10); Tmin = Tmax - ((dw - dx) * restemp); Hmax = Hmin + (dh * resalt); winkel = (atan((restemp * 125) / resalt) * 180 / PI); if (modeflag == LOW) { temp1 = bmp.readTemperature(); alt = 0.9 * alt + 0.1 * bmp.readAltitude(SEALEVELPRESSURE_HPA); sensors_event_t a, g, temp; mpu.getEvent(&a, &g, &temp); GForce = ((sqrt(sq(a.acceleration.x) + sq(a.acceleration.y) + sq(a.acceleration.z))) / 9.81); climbmodeinterval = flash14.read(); //alt = alt + vario / (1000 / codetime); //alt = alt - 1; //poti = analogRead(0); //poti1 = map(poti, 0, 1023, 10, 50); //GForce = poti1 / 10; } if (modeflag == HIGH) { temp1 = temptest; alt = alttest; climbmodeinterval = 1; alttest = alttest - altinc; temptest = temptest + tempinc; tempdemo = tempinc * 10; } } void DisplaySensorData() { display.setCursor(2, 1); display.setTextColor(BLACK); display.println("A"); display.setCursor(2, 11); display.setTextColor(BLACK); display.println("T"); display.setCursor(2, 21); display.setTextColor(BLACK); display.println("vs"); display.setCursor(12, 1); if (valuepos == 1 && valueflag == HIGH) { display.setTextColor(WHITE, BLACK); } else { display.setTextColor(BLACK); } display.print(String(alt, 1)); display.setCursor(17, 11); display.setTextColor(BLACK); display.println(String(temp1)); if (vario >= 0) { display.setCursor(23, 21); } else { display.setCursor(17, 21); } display.setTextColor(BLACK); display.print(vario, 1); display.setCursor(2, 36); display.setTextColor(BLACK); display.print("A"); display.setCursor(2, 46); display.setTextColor(BLACK); display.print("L"); display.setCursor(2, 56); display.setTextColor(BLACK); display.print("T"); display.setCursor(17, 36); display.setTextColor(BLACK); display.print(Hmax); display.setCursor(17, 46); if (valuepos == 3 && valueflag == HIGH) { display.setTextColor(WHITE, BLACK); } else { display.setTextColor(BLACK); } if (resalt >= 1) { display.print(resalt, 0); } else display.print(resalt, 1); display.setCursor(17, 56); if (valuepos == 2 && valueflag == HIGH) { display.setTextColor(WHITE, BLACK); } else { display.setTextColor(BLACK); } display.print(Hmin); display.setCursor(2, 71); display.setTextColor(BLACK); display.print("T"); display.setCursor(2, 81); display.setTextColor(BLACK); display.print("M"); display.setCursor(2, 91); display.setTextColor(BLACK); display.print("P"); display.setCursor(17, 71); if (valuepos == 4 && valueflag == HIGH) { display.setTextColor(WHITE, BLACK); } else { display.setTextColor(BLACK); } display.print(Tmax); display.setCursor(23, 81); if (valuepos == 5 && valueflag == HIGH) { display.setTextColor(WHITE, BLACK); } else { display.setTextColor(BLACK); } display.print(restemp); display.setCursor(17, 91); display.setTextColor(BLACK); display.print(Tmin); display.setCursor(3, 136); display.setTextColor(BLACK); display.printf("%02d", hours); display.setCursor(14, 136); display.setTextColor(BLACK); display.print(":"); display.setCursor(19, 136); display.setTextColor(BLACK); display.printf("%02d", minutes); display.setCursor(30, 136); display.setTextColor(BLACK); display.print(":"); display.setCursor(35, 136); display.setTextColor(BLACK); display.printf("%02d", seconds); display.setCursor(27, 108); display.setTextColor(BLACK); display.print("G"); display.setCursor(7, 108); display.setTextSize(1); display.setTextColor(BLACK); if (GForceDisplayMode == HIGH) { display.print(maxGForce, 1); } if (GForceDisplayMode == HIGH) { GForceDisplayModeValue = "max."; } if (GForceDisplayMode == LOW) { display.print(lastGForcePrint, 1); } if (GForceDisplayMode == LOW) { GForceDisplayModeValue = "last"; } display.setCursor(7, 120); display.setTextColor(BLACK); display.print(GForce, 1); display.setCursor(27, 120); display.setTextColor(BLACK); display.print("G"); display.fillRect(dx + 5, 0, 22, 8, WHITE); display.setCursor(dx + 5, 0); display.setTextColor(BLACK); display.print(codetime, 0); } void Vario() { if (millis() > (variotimerinterval + variotimer)) { //poti = analogRead(0); //poti1 = map(poti, 0, 1023, -10, 30); //vario = poti1 / 10; vario = alt - AltVario; AltVario = alt; variotimer = millis(); } } void OnTimeCounter() { //Ontime seconds = ontime / 1000; minutes = seconds / 60; hours = minutes / 60; seconds %= 60; minutes %= 60; ontime = starttime + millis() - currentMillis; } void GForceValues() { if (millis() > 15000) { // max GForce schreiben if (GForce > maxGForce) { maxGForce = GForce; } // divespeed schreiben divespeed = vario; if (divespeed > divespeedmax) { divespeedmax = divespeed; } // lastGForcePrint schreiben if (GForce > lastGForcePrint) { lastGForcePrint = GForce; } } } void triggerGForcemodeStart() { if (GForce > GLimit && lastGForce < GLimit && millis() > 15000 && modeflag == LOW && valuepos == 6 && GForceStatus == LOW) { //Trigger GForce-Seite GForceTimeStartInit = millis(); GForceAltStartInit = alt; if (page != GForcepage) { oldpage = page; } } if (GForce > GLimit && (millis() - GForceInitDuration) > GForceTimeStartInit && GForceStatus == LOW) { GForceStatus = HIGH; GForceTimeStart = GForceTimeStartInit; GForceAltStart = GForceAltStartInit; lastGForcePrint = 1.0; divespeedmax = 0; GForcemodeinit = 1; } if (GForceStatus == HIGH && GForceAutoswitch == HIGH) { page = GForcepage; } } void triggerGForcemodeEnd() { if (GForce < GLimit && lastGForce > GLimit && GForceStatus == HIGH && millis() > 13000) { //Trigger spiral end GForceTimeEndInit = millis(); GForceAltEndInit = alt; } if (GForce < GLimit && (millis() - GForceInitDuration) > GForceTimeEndInit && GForceStatus == HIGH) { GForceTimeEnd = GForceTimeEndInit; GForceAltEnd = GForceAltEndInit; GForceStatus = LOW; } } void triggerStartpageGForce() { if (millis() < GForceTimeEnd + GforcetimerStartpage && GForceTimeEnd > GForceTimeStart && GForceAutoswitch == 1) { //Trigger Startpage page = oldpage; ClearPlotArea(); } } void Spiraldata() { if (GForceStatus == HIGH) { GForceTime = (millis() - GForceTimeStart) / 1000; GForceAlt = GForceAltStartInit - alt; } if (GForceStatus == LOW) { GForceTime = (GForceTimeEnd - GForceTimeStart) / 1000; GForceAlt = GForceAltStartInit - GForceAltEnd; } if (GForceTime < 0) { GForceTime = 0; } lastGForce = GForce; } void thermalValues() { if (vario > maxVario) { maxVario = vario; } if (thermalStatus == HIGH) { thermalAlt = alt - thermalAltStartInit; if (thermalAlt < 0) { thermalAlt = 1; } thermalTime = (millis() - thermalTimeStart); thermalSeconds = thermalTime / 1000; thermalMinutes = thermalSeconds / 60; thermalSeconds %= 60; } if (thermalStatus == LOW) { thermalAlt = thermalAltEndInit - thermalAltStartInit; if (thermalAlt < 0) { thermalAlt = 0; } thermalTime = (thermalTimeEnd - thermalTimeStart); thermalSeconds = thermalTime / 1000; thermalMinutes = thermalSeconds / 60; thermalSeconds %= 60; } avVario = thermalAlt / thermalSeconds; if (avVario < 0) { avVario = 0; } if (thermalTime < 0) { thermalTime = 0; } if (thermalSeconds < 0) { thermalSeconds = 0; } if (thermalMinutes < 0) { thermalMinutes = 0; } } void triggerThermalmodeStart() { if (vario * 10 > varioLimit * 10 && varioAlt * 10 < varioLimit * 10 && millis() > 15000 && modeflag == LOW && valuepos == 6 && thermalStatus == LOW) { thermalTimeStartInit = millis(); thermalAltStartInit = alt; if (page != thermalpage) { oldpage = page; } } if (vario * 10 > varioLimit * 10 && (millis() - thermalInitDuration) > thermalTimeStartInit && thermalStatus == LOW && millis() > 15000) { thermalStatus = HIGH; thermalTimeStart = thermalTimeStartInit; thermalAltStart = thermalAltStartInit; maxVario = 0; avVario = 0; thermalAlt = 0; thermalmodeinit = 1; } if (thermalStatus == HIGH && thermalAutoswitch == HIGH) { page = thermalpage; } } void triggerThermalmodeEnd() { if (vario * 10 < varioLimit * 10 && varioAlt * 10 > varioLimit * 10 && thermalStatus == HIGH && millis() > 13000) { thermalTimeEndInit = millis(); thermalAltEndInit = alt; } if (vario * 10 < varioLimit * 10 && (millis() - thermalInitDuration) > thermalTimeEndInit && thermalStatus == HIGH) { thermalTimeEnd = thermalTimeEndInit; thermalAltEnd = thermalAltEndInit; thermalStatus = LOW; } } void triggerStartpageThermal() { if (millis() > thermalTimeEnd + thermalInitDuration + thermalTimerStartpage && thermalTimeEnd > thermalTimeStart && thermalAutoswitch == 1) { page = oldpage; ClearPlotArea(); } } void DrawLines() { display.drawLine(dx, 0, dx, dw, BLACK); //1. vertikal display.drawLine(dw - 1, 0, dw - 1, dh, BLACK); //2. vertikal display.drawLine(0, 31, dx, 31, BLACK); //1. horizontal display.drawLine(0, 66, dx, 66, BLACK); //2. horizontal display.drawLine(0, 101, dx, 101, BLACK); //3. horizontal display.drawLine(0, 131, dx, 131, BLACK); //4. horizontal } void DrawTempLine() { display.drawLine(dx, dh, (dx + (dh * tan(((90 - winkel) / 180 * PI)))), 0, BLACK); } void DrawAltLine() { y = ((Hmax - alt) / resalt); yi = dh - y; xw = yi * tan((90 - winkel) / 180 * PI); xt = ((temp1 - Tmin) / (restemp)); x = dx + xw + xt; if (modeflag == LOW && (page == thermalpagedown || page == thermalpageup || page == thermalpageupdown)) { x01 = dx; y01 = y + 1; x02 = x - 10; y02 = y + 1; x03 = x + 10; y03 = y + 1; x04 = dx + dw; y04 = y + 1; display.drawLine(x01old, y01old, x02old, y02old, WHITE); display.drawLine(x01, y01, x02, y02, BLACK); x01old = x01; y01old = y01; x02old = x02; y02old = y02; display.drawLine(x03old, y03old, x04old, y04old, WHITE); display.drawLine(x03, y03, x04, y04, BLACK); x03old = x03; y03old = y03; x04old = x04; y04old = y04; PlotGraph(); } if (modeflag == HIGH && (page == thermalpagedown || page == thermalpageup || page == thermalpageupdown)) { display.fillRect(dx + 65, 126, dw, 17, WHITE); display.setTextSize(1); display.setFont(&FreeMonoBold9pt7b); display.setCursor(dx + 15, 139); display.setTextColor(BLACK); display.print("Temp:"); display.setCursor(dx + 75, 139); display.setTextColor(BLACK); display.print(tempdemo, 1); display.setTextSize(1); display.setFont(); if (alttest <= 0) { alttest = 0; } display.drawLine(x01old, y01old, x02old, y02old, WHITE); display.drawLine(x01, y01, x02, y02, BLACK); display.drawLine(x03old, y03old, x04old, y04old, WHITE); display.drawLine(x03, y03, x04, y04, BLACK); display.drawLine(dx + 1, y, dx + dw - 7, y, WHITE); display.drawPixel(x, y, BLACK); display.drawPixel(x + 1, y, BLACK); display.drawPixel(x - 1, y, BLACK); display.drawPixel(x + 2, y, BLACK); display.drawPixel(x - 2, y, BLACK); } } void PlotGraph() { altload = (Hmax - (drawlinecounter * resalt)) / 10; yp = drawlinecounter - 1; yip = dh - yp; xwp = yip * tan((90 - winkel) / 180 * PI); if (modeflag == LOW && page == thermalpagedown) { tempsave10 = tempsave1[altload]; tempsave11 = tempsave10 / 100; if (tempsave1[altload] == 0) { xtp = 300; } xtp = (tempsave11 - Tmin) / restemp; xp = dx + xwp + xtp; display.drawLine(dx + 1, yp, dx + dw - 7, yp, WHITE); display.drawPixel(xp, yp, BLACK); display.drawPixel(xp + 1, yp, BLACK); display.drawPixel(xp - 1, yp, BLACK); display.drawPixel(xp + 2, yp, BLACK); display.drawPixel(xp - 2, yp, BLACK); drawlinecounter++; drawlinecounter %= dh; } if (modeflag == LOW && page == thermalpageup) { tempsave20 = tempsave2[altload]; tempsave22 = tempsave20 / 100; if (tempsave2[altload] == 0) { xtp = 300; } xtp = (tempsave22 - Tmin) / restemp; xp = dx + xwp + xtp; display.drawLine(dx + 1, yp, dx + dw - 7, yp, WHITE); display.drawPixel(xp, yp, BLACK); display.drawPixel(xp + 1, yp, BLACK); display.drawPixel(xp - 1, yp, BLACK); display.drawPixel(xp + 2, yp, BLACK); display.drawPixel(xp - 2, yp, BLACK); drawlinecounter++; drawlinecounter %= dh; } if (modeflag == LOW && page == thermalpageupdown) { tempsave10 = tempsave1[altload]; tempsave11 = tempsave10 / 100; if (tempsave1[altload] == 0) { xtp = 300; } xtp = (tempsave11 - Tmin) / restemp; xp = dx + xwp + xtp; display.drawLine(dx + 1, yp, dx + dw - 7, yp, WHITE); display.drawPixel(xp, yp, BLACK); display.drawPixel(xp + 1, yp, BLACK); display.drawPixel(xp - 1, yp, BLACK); display.drawPixel(xp + 2, yp, BLACK); display.drawPixel(xp - 2, yp, BLACK); tempsave20 = tempsave2[altload]; tempsave22 = tempsave20 / 100; if (tempsave2[altload] == 0) { xtp = 300; } xtp = (tempsave22 - Tmin) / restemp; xp = dx + xwp + xtp; display.drawPixel(xp, yp, BLACK); display.drawPixel(xp + 1, yp, BLACK); display.drawPixel(xp - 1, yp, BLACK); display.drawPixel(xp + 2, yp, BLACK); display.drawPixel(xp - 2, yp, BLACK); drawlinecounter++; drawlinecounter %= dh; } } void PlotPosMarker() { display.drawRect(dx + 1, yp - 11, 4, 10, WHITE); display.drawLine(dx + 1, yp, dx + 4, yp, BLACK); display.drawRect(dx + 1, yp - 1, 4, 10, WHITE); } void buttons() { buttonpress1(); buttonpress2(); buttonpress3(); } void buttonpress1() { if (digitalRead(buttonpin1)) { if (menuflag == LOW && settingsflag == LOW && valueflag == LOW && modeflag == LOW) { page++; ClearSensorArea(); ClearPlotArea(); } if (valueflag == HIGH && valuepos == 1) { pressure = pressure - 1; ClearPlotArea(); } if (valueflag == HIGH && valuepos == 2) { Hmin = Hmin - 100; winkel = (atan((restemp * 125) / resalt) * 180 / PI); ClearPlotArea(); } if (resalt <= 1) { resaltgap = 0.1; } else resaltgap = 1; if (valueflag == HIGH && valuepos == 3) { resalt = resalt - resaltgap; winkel = (atan((restemp * 125) / resalt) * 180 / PI); ClearPlotArea(); } if (valueflag == HIGH && valuepos == 4) { Tmax = Tmax - 1; winkel = (atan((restemp * 125) / resalt) * 180 / PI); ClearPlotArea(); } if (valueflag == HIGH && valuepos == 5) { restemp = restemp - 0.05; winkel = (atan((restemp * 125) / resalt) * 180 / PI); ClearPlotArea(); } if (settingsflag == HIGH && settingspos == 1) { GLimit = GLimit - 0.1; } if (settingsflag == HIGH && settingspos == 2) { GForceInitDuration = GForceInitDuration - 1000; } if (settingsflag == HIGH && settingspos == 3) { GForceDisplayMode = !GForceDisplayMode; } if (settingsflag == HIGH && settingspos == 4) { GForceAutoswitch = !GForceAutoswitch; display.fillRect(120, 0, 48, dh, SSD1327_WHITE); } if (settingsflag == HIGH && settingspos == 5) { GforcetimerStartpage = GforcetimerStartpage - 1000; } if (settingsflag == HIGH && settingspos == 6) { varioLimit = varioLimit - 0.1; } if (settingsflag == HIGH && settingspos == 7) { thermalInitDuration = thermalInitDuration - 1000; } if (settingsflag == HIGH && settingspos == 8) { thermalAutoswitch = !thermalAutoswitch; display.fillRect(120, 0, 48, dh, SSD1327_WHITE); } if (settingsflag == HIGH && settingspos == 9) { thermalTimerStartpage = thermalTimerStartpage - 1000; } if (settingsflag == HIGH && settingspos == 10) { climbmodeinterval = climbmodeinterval - 1000; } if (settingsflag == HIGH && settingspos == 11) { saveinterval = saveinterval - 30000; } if (modeflag == HIGH) { tempinc = tempinc - 0.01; } if (menuflag == HIGH) { menuflag = LOW; ClearSensorArea(); ClearPlotArea(); } while (digitalRead(buttonpin1)) ; } } void buttonpress2() { if (digitalRead(buttonpin2)) { if (modeflag == HIGH && menuflag == LOW) { modeflag = LOW; ClearSensorArea(); ClearPlotArea(); } if (modeflag == LOW && valuepos == 6 && page != thermalpage) { Tmax = temp1 + (((dw - dx) / 2) * restemp) + ((yi * tan((90 - winkel) / 180 * PI)) * restemp); ClearSensorArea(); ClearPlotArea(); } if (menuflag == HIGH && menupos == 1) { maxGForce = 1; menuflag = LOW; } if (menuflag == HIGH && menupos == 2) { starttime = 100; flash6.write(starttime); currentMillis = millis(); menuflag = LOW; } if (menuflag == HIGH && menupos == 3) { valueflag = HIGH; valuepos = 0; menuflag = LOW; } if (menuflag == HIGH && menupos == 4) { menuflag = LOW; clearArray1(); } if (menuflag == HIGH && menupos == 5) { menuflag = LOW; clearArray2(); } if (menuflag == HIGH && menupos == 6) { menuflag = LOW; clearArray3(); } if (menuflag == HIGH && menupos == 7) { settingsflag = HIGH; settingspos = 0; menuflag = LOW; } if (menuflag == HIGH && menupos == 8) { altinc = 10; tempinc = 0.08; alttest = Hmax; temptest = Tmin + ((Tmax - Tmin) / 2) - (dh * tan((90 - winkel) / 180 * PI) * restemp); modeflag = HIGH; menuflag = LOW; } if (page == GForcepage) { maxGForce = 1.0; } if (valueflag == HIGH) { valuepos++; } if (valuepos == 6) { valueflag = LOW; } if (settingsflag == HIGH) { settingspos++; } menupos = 0; while (digitalRead(buttonpin2)) ; } } void buttonpress3() { if (digitalRead(buttonpin3)) { if (menuflag == LOW && settingsflag == LOW && valueflag == LOW && modeflag == LOW) { menuflag = HIGH; menupos = 0; } if (menuflag == HIGH && settingsflag == LOW) { menupos++; } if (valueflag == HIGH && valuepos == 1) { pressure = pressure + 1; ClearPlotArea(); } if (valueflag == HIGH && valuepos == 2) { Hmin = Hmin + 100; winkel = (atan((restemp * 125) / resalt) * 180 / PI); ClearPlotArea(); } if (resalt < 1) { resaltgap = 0.1; } else resaltgap = 1; if (valueflag == HIGH && valuepos == 3) { resalt = resalt + resaltgap; winkel = (atan((restemp * 125) / resalt) * 180 / PI); ClearPlotArea(); } if (valueflag == HIGH && valuepos == 4) { Tmax = Tmax + 1; winkel = (atan((restemp * 125) / resalt) * 180 / PI); ClearPlotArea(); } if (valueflag == HIGH && valuepos == 5) { restemp = restemp + 0.05; winkel = (atan((restemp * 125) / resalt) * 180 / PI); ClearPlotArea(); } if (settingsflag == HIGH && settingspos == 1) { GLimit = GLimit + 0.1; } if (settingsflag == HIGH && settingspos == 2) { GForceInitDuration = GForceInitDuration + 1000; } if (settingsflag == HIGH && settingspos == 3) { GForceDisplayMode = !GForceDisplayMode; } if (settingsflag == HIGH && settingspos == 4) { GForceAutoswitch = !GForceAutoswitch; display.fillRect(120, 0, 48, dh, SSD1327_WHITE); } if (settingsflag == HIGH && settingspos == 5) { GforcetimerStartpage = GforcetimerStartpage + 1000; } if (settingsflag == HIGH && settingspos == 6) { varioLimit = varioLimit + 0.1; } if (settingsflag == HIGH && settingspos == 7) { thermalInitDuration = thermalInitDuration + 1000; } if (settingsflag == HIGH && settingspos == 8) { thermalAutoswitch = !thermalAutoswitch; display.fillRect(120, 0, 48, dh, SSD1327_WHITE); } if (settingsflag == HIGH && settingspos == 9) { thermalTimerStartpage = thermalTimerStartpage + 1000; } if (settingsflag == HIGH && settingspos == 10) { climbmodeinterval = climbmodeinterval + 1000; } if (settingsflag == HIGH && settingspos == 11) { saveinterval = saveinterval + 30000; } if (modeflag == HIGH) { tempinc = tempinc + 0.01; } } while (digitalRead(buttonpin3)) ; } void DrawDown() { display.drawTriangle(35, 108, 45, 108, 40, 123, BLACK); } void DrawUp() { display.drawTriangle(35, 123, 45, 123, 40, 108, BLACK); } void DrawUpDown() { display.drawTriangle(37, 113, 43, 113, 40, 108, BLACK); display.drawTriangle(37, 117, 43, 117, 40, 123, BLACK); } void Codetime() { codetime2 = millis(); codetime = codetime2 - codetime1; codetime1 = codetime2; } void TestValues() { Serial.println(alt); Serial.println(y); Serial.println("==========================================="); } /* //Mode Serial.print("Pos: \t\t\t");Serial.print("page: \t\t\t"); Serial.println(page); Serial.println(pos); Serial.print("page: \t\t\t"); Serial.println(page); Serial.print("thermalflag: \t\t"); Serial.println(thermalflag); Serial.print("thermalAutoswitch: \t\t"); Serial.println(thermalAutoswitch); //Sensors Serial.print("Sensor Temp: \t\t"); Serial.println(bme.readTemperature()); Serial.print("Sensor Hum: \t\t"); Serial.println(bme.readHumidity()); Serial.print("Sensor alt: \t\t"); Serial.println( bme.readAltitude(SEALEVELPRESSURE_HPA)); Serial.print("alt: \t\t\t"); Serial.println(alt); Serial.print("temp1: \t\t\t"); Serial.println(temp1); Serial.print("Hum: \t\t"); Serial.println(hum); Serial.println(" "); //XY Serial.print("x: \t"); Serial.println(x); Serial.print("xw: \t"); Serial.println(xw); Serial.print("xt: \t"); Serial.println(xt); Serial.print ("y: \t"); Serial.println(y); Serial.print("yi: \t"); Serial.println(yi); Serial.println(" "); //Drawline Serial.print("altsave: \t"); Serial.println(altsave); Serial.print("Altload: \t"); Serial.println(altload); Serial.print("tempsave[altsave]: \t"); Serial.println(tempsave[altsave]); Serial.print("tempsave[altload]: \t"); Serial.println(tempsave[altload]); Serial.print("Drawlinecounter: \t"); Serial.println(drawlinecounter); Serial.println(" "); //XpYp Serial.print("xp: \t"); Serial.println(xp); Serial.print("xwp: \t"); Serial.println(xwp); Serial.print("xtp: \t"); Serial.println(xtp); Serial.print("yp: \t"); Serial.println(yp); Serial.print("yip: \t"); Serial.println(yip); Serial.println(" "); //GForcepage Serial.print("G-Force: \t\t"); Serial.println(GForce); Serial.print("GLimit: \t\t"); Serial.println(GLimit); Serial.print("currentGForce: \t\t"); Serial.println(currentGForce); Serial.print("lastGForce: \t\t"); Serial.println(lastGForce); Serial.print("lastGForcePrint: \t"); Serial.println(lastGForcePrint); Serial.print("maxGForce: \t\t"); Serial.println(maxGForce); Serial.print("GForceDisplayMode: \t"); Serial.println(GForceDisplayMode); Serial.print("GForceDisplayModeValue:"); Serial.println(GForceDisplayModeValue); Serial.print("GForceAutoswitch: \t"); Serial.println(GForceAutoswitch); Serial.print("GForceAutoswitchValue: \t"); Serial.println(GForceAutoswitchValue); Serial.print("GForceInitDuration: \t"); Serial.println(GForceInitDuration); Serial.print("GforcetimerStartpage: \t"); Serial.println(GforcetimerStartpage); Serial.print("GForcemodeinit: \t"); Serial.println(GForcemodeinit); Serial.print("GForceStatus: \t\t"); Serial.println(GForceStatus); Serial.print("GForceTimeStartInit: \t"); Serial.println(GForceTimeStartInit); Serial.print("GForceTimeStart: \t"); Serial.println(GForceTimeStart); Serial.print("GForceTimeEndInit: \t"); Serial.println(GForceTimeEndInit); Serial.print("GForceTimeEnd: \t\t"); Serial.println(GForceTimeEnd); Serial.print("GForceTime: \t\t"); Serial.println(GForceTime); Serial.print("GForceAltStartInit: \t"); Serial.println(GForceAltStartInit); Serial.print("GForceAltStart: \t"); Serial.println(GForceAltStart); Serial.print("GForceAltEndInit: \t"); Serial.println(GForceAltEndInit); Serial.print("GForceAltEnd: \t\t"); Serial.println(GForceAltEnd); Serial.print("Spiral Altitude: \t"); Serial.println(GForceAlt); Serial.print("divespeedmax: \t\t"); Serial.println(divespeedmax); Serial.print("page: \t\t"); Serial.println(page); Serial.print("oldpage: \t\t"); Serial.println(oldpage); //Thermalpage Serial.print("Vario: \t\t"); Serial.println(vario); Serial.print("varioAlt: \t\t"); Serial.println(varioAlt); Serial.print("varioLimit: \t\t"); Serial.println(varioLimit); Serial.print("maxVario: \t\t"); Serial.println(maxVario); Serial.print("avVario: \t\t"); Serial.println(avVario); Serial.print("thermalAutoswitch: \t"); Serial.println(thermalAutoswitch); Serial.print("thermalAutoswitchValue:\t"); Serial.println(thermalAutoswitchValue); Serial.print("thermalInitDuration: \t"); Serial.println(thermalInitDuration); Serial.print("thermalTimerStartpage: \t"); Serial.println(thermalTimerStartpage); Serial.print("thermalmodeinit: \t"); Serial.println(thermalmodeinit); Serial.print("thermalStatus: \t\t"); Serial.println(thermalStatus); Serial.print("thermalTimeStartInit: \t"); Serial.println(thermalTimeStartInit); Serial.print("thermalTimeStart: \t"); Serial.println(thermalTimeStart); Serial.print("thermalTimeEndInit: \t"); Serial.println(thermalTimeEndInit); Serial.print("thermalTimeEnd: \t"); Serial.println(thermalTimeEnd); Serial.print("thermalTime: \t\t"); Serial.println(thermalTime); Serial.print("thermalSeconds: \t"); Serial.println(thermalSeconds); Serial.print("thermalMinutes: \t"); Serial.println(thermalMinutes); Serial.print("thermalAltStartInit: \t"); Serial.println(thermalAltStartInit); Serial.print("thermalAltStart: \t"); Serial.println(thermalAltStart); Serial.print("thermalAltEndInit: \t"); Serial.println(thermalAltEndInit); Serial.print("thermalAltEnd: \t\t"); Serial.println(thermalAltEnd); Serial.print("thermalAlt Altitude: \t"); Serial.println(thermalAlt); Serial.print("page: \t\t"); Serial.println(page); Serial.print("oldpage: \t\t"); Serial.println(oldpage); //Climbmode Serial.print("Climbmode: \t"); Serial.println(climbmode); Serial.print("Climbmodetimer: \t"); Serial.println(climbmodetimer); Serial.print("Climbmodealt: \t"); Serial.println(climbmodealt); //Vario Serial.print("Vario: \t\t"); Serial.println(vario); Serial.print("Alt Vario: \t"); Serial.println(AltVario); Serial.print("Vario Timer: \t"); Serial.println(variotimer); //Buttons Serial.print("Down: \t"); Serial.println(digitalRead(1)); Serial.print("Up: \t"); Serial.println(digitalRead(3)); Serial.print("Set: \t"); Serial.println(digitalRead(2)); //Codetime Serial.print("Code Time: \t"); Serial.println(codetime); Serial.println("==========================================="); */
Editor is loading...
Leave a Comment