static int writeTrackChannels(SampleRecord *sampleRecord, size_t currentTicks, TrackConfig *config){ int rate = SAMPLE_DISABLED; { size_t sr = config->lapCountCfg.sampleRate; if (sr != SAMPLE_DISABLED){ if ((currentTicks % sr) == 0){ rate = HIGHER_SAMPLE_RATE(sr, rate); sampleRecord->Track_LapCountSample.intValue = getLapCount(); } } } { size_t sr = config->splitTimeCfg.sampleRate; if (sr != SAMPLE_DISABLED){ if ((currentTicks % sr) == 0){ rate = HIGHER_SAMPLE_RATE(sr, rate); sampleRecord->Track_SplitTimeSample.floatValue = getLastSectorTime(); // getLastSplitTime()->getLastSectorTime() ?-jrwiebe } } } { size_t sr = config->lapTimeCfg.sampleRate; if (sr != SAMPLE_DISABLED){ if ((currentTicks % sr) == 0){ rate = HIGHER_SAMPLE_RATE(sr, rate); sampleRecord->Track_LapTimeSample.floatValue = getLastLapTime(); } } } { size_t sr = config->distanceCfg.sampleRate; if (sr != SAMPLE_DISABLED){ if ((currentTicks % sr) == 0){ rate = HIGHER_SAMPLE_RATE(sr, rate); sampleRecord->Track_DistanceSample.floatValue = getGpsDistance() * 0.621371192; //convert to miles } } } { size_t sr = config->predTimeCfg.sampleRate; if (sr != SAMPLE_DISABLED){ if ((currentTicks % sr) == 0){ rate = HIGHER_SAMPLE_RATE(sr, rate); sampleRecord->Track_PredTimeSample.floatValue = get_predicted_time(getGPSSpeed()); } } } return rate; }
//============================================================================== void menuProcNMEA2(uint8_t event) { static int8_t set_home; passes +=1; switch(event) { // Menu navigation case EVT_KEY_BREAK(KEY_LEFT): chainMenu(menuProcNMEA1); break; case EVT_KEY_BREAK(KEY_RIGHT): chainMenu(menuProcNMEA3); break; //Beep setting case EVT_KEY_BREAK(KEY_UP): killEvents(event); beep_on = beep_on ^ 1; // toggle Beep ON/OFF audioDefevent(AU_MENUS); // short blip break; case EVT_KEY_LONG(KEY_UP): NMEA_DisableRXD(); chainMenu(menuProcStatistic); break; //Voice setting case EVT_KEY_BREAK(KEY_DOWN): // Switch Voice on/off killEvents(event); beep_on = beep_on ^ 2; // toggle Voice ON/OFF audioDefevent(AU_MENUS); // short blip v_prev_alt=0; prev_dist=0; break; case EVT_KEY_LONG(KEY_DOWN): NMEA_DisableRXD(); #if defined(OPEN9X) chainMenu(menuMainView); #else chainMenu(menuProc0); #endif /* break; //Beep setting case EVT_KEY_FIRST(KEY_UP): killEvents(event); beep_on = beep_on ^ 1; // toggle Beep ON/OFF audioDefevent(AU_MENUS); // short blip break; //Voice setting case EVT_KEY_FIRST(KEY_DOWN): // Switch Voice on/off killEvents(event); beep_on = beep_on ^ 2; // toggle Voice ON/OFF audioDefevent(AU_MENUS); // short blip v_prev_alt=0; prev_dist=0; break; */ /* Altitude setting: Set a home position for altitude. Normally used before starting the model when GPS has got a fix. MENU[short] --> alternating relative and absolute altitudes MENU[long] --> set home altitude to current altitude EXIT[long] --> reset max altitude to 0 Switch ON / OFF short beep with positive lift DOWN[short] --> Toggle Positive lift Beep on/off Switch ON / OFF voice for altitude and distance UP[short] --> Toggle voice message of altitude and distance on/off */ case EVT_KEY_BREAK(KEY_MENU): // Menu short if (!home_alt) // umschalten zwischen absoluter und relativer Höhe home_alt = save_alt; else home_alt=0; if (save_alt==0) // wenn noch keine Home Höhe gesetzt war, wird sie es jetzt, weil sonst // das Umschalten keine Wirkung zeigt save_alt = home_alt = abs_alt; // absolute altitude audioDefevent(AU_MENUS); // short blip for non negative lift break; case EVT_KEY_LONG(KEY_MENU): // Menu long, set home position killEvents(event); set_home=1; save_alt = home_alt =abs_alt ; // Home altitude auf aktuelle absolute Höhe setzen max_alt=0; // es ist irritierend, wenn max_alt bestehen bliebe d_pass = max_pass>>1; audioDefevent(AU_MENUS); // short blip break; case EVT_KEY_BREAK(KEY_EXIT): // Exit short resets max_alt and MaxDistance MaxDistance = max_alt = 0; audioDefevent(AU_MENUS); // short blip break; case EVT_KEY_LONG(KEY_EXIT): // Exit long resets all distance and altitude values killEvents(event); pilotLatitude=pilotLongitude=LastDistance=MaxDistance=save_alt = home_alt = abs_alt=max_alt=increasing=decreasing=0; audioDefevent(AU_MENUS); // short blip break; } title ('2'); my_lcd_puts ( 1*FW, 1*FH, PSTR("Altitude Sat Max")); my_lcd_puts ( 16*FW, 3*FH, PSTR("Home")); my_lcd_puts ( 1*FW, 4*FH, PSTR("Lift") ); lcd_putsAtt (16*FW, 5*FH, PSTR("Beep"), ((beep_on==1)|(beep_on==3))); lcd_putsAtt (16*FW, 6*FH, PSTR("Voice"), (beep_on >=2)); /* lcd_putcAtt( 16*FW, 5*FH, 'B', ((beep_on==1)|(beep_on==3))); //first letter inverted if active my_lcd_puts( 17*FW, 5*FH, PSTR("eep") ); lcd_putcAtt( 16*FW, 6*FH, 'V', (beep_on>=2)) ; //first letter inverted if active my_lcd_puts( 17*FW, 6*FH, PSTR("oice") ); */ lcd_outdezNAtt( 20*FW, 4*FH, home_alt, PREC1, 6); // display home_alt, small characters rmcreceived=0; // RMC Pack not used //---------------------------------------- if (ggareceived) // at least one second has elapsed { ggareceived = 0; passes=0; if (count < MaxCount) count +=1; initval (LONG_BUF(0), PACK_GGA, ALT); // -> rbuf[0] initval (LONG_BUF(1), PACK_GGA, GEO); // -> rbuf[1] initval (SHORT_BUF(0), PACK_GGA, MTR); // -> sbuf[0] initval (SHORT_BUF(1), PACK_GGA, FIX); // -> sbuf[1] initval (SHORT_BUF(2), PACK_GGA, SAT); // -> sbuf[2] fixed=(sbuf[1]>0x30) ? ATTRIB : 0 ; satellites=sbuf[2]; /* ALT and GEO have one single digit following the decimal point e.g. ALT=359.7 GEO=47.7 The altitude over mean sea level is to be calculated as: altitude minus geoidal separation */ abs_alt = binary(rbuf[0]) - binary(rbuf[1]); // alt - geo that is absolute altitude if (abs_alt> max_alt) max_alt=abs_alt; // hold max altitude relative to 0 m rel_alt=abs_alt - home_alt; // alt - geo - home altitude relative to home initval (LONG_BUF(2), PACK_GGA, LAT); // -> rbuf[2] gpsLatitude_bp=split((rbuf[2]),DP); // Latitude before decimal point gpsLatitude_ap=split((rbuf[2]),EOS); // Latitude after decimal point initval (LONG_BUF(3), PACK_GGA, LON); // -> rbuf[3] gpsLongitude_bp=split((rbuf[3]),DP); // Longitude before decimal point gpsLongitude_ap=split((rbuf[3]),EOS); // Longitude after decimal point if ((a_pass >= max_pass) | ((a_pass + d_pass) > max2_pass)) { // Höhe ändert sich uint16_t alt_diff = (rel_alt > v_prev_alt) ? rel_alt - v_prev_alt: v_prev_alt - rel_alt ; if ((fixed) && (beep_on & 0x2) && (alt_diff >= 100)) // diff of 10 m { v_prev_alt = rel_alt; // kann auch negativ sein if (rel_alt > 0) // nur positive Werte ansagen. voice kann nicht negative { a_pass = 0; putVoiceQueue(V_ALTITUDE) ; //!!!!!!!!!!!!!!!! voice_numeric(rel_alt/10, 0,V_METRES); //!!!!!!!!!!!!!!!! } } } lift_alt = rel_alt - prev_alt; prev_alt = rel_alt; //!!!!!!!!!!!!!! if ((lift_alt >= 0) && (fixed) && (beep_on & 0x1)) // GGA record must have Fix> 0 audioDefevent(AU_MENUS); // short blip for non negative lift //!!!!!!!!!!!!!!!!! } //---------------------------------------- // Shown value depends on home_alt. // For home_alt=0 this is altitude relativeto sea level // For home_alt > 0 this is altitude relative to home level lcd_outdezNAtt( 20*FW, 2*FH, (max_alt-home_alt), PREC1, 6); // max_altitude rel 0 or home //---------------------------------------- if (pilotLatitude | (set_home)) // show distance only, when home position has been set { my_lcd_puts ( 11*FW, 4*FH, PSTR("Dist") ); GpsDistance=getGpsDistance(); if ((d_pass >= max_pass) | ((a_pass + d_pass) > max2_pass)) { uint16_t dist_diff = (GpsDistance > prev_dist) ? GpsDistance - prev_dist: prev_dist - GpsDistance ; if ( (fixed) && (beep_on & 0x2) && (dist_diff >= 500) ) // diff of 50 m { prev_dist=GpsDistance ; putVoiceQueue(V_DISTANCE) ; voice_numeric(GpsDistance/10, 0, V_METRES) ; d_pass = 0; } } // GetGpsDistance intermittently returns a wrong, much to high value (e.g.3284.2 instead of 15.3) // Try to catch it and avoid MaxDistance to go incorrectly high // MaxDistance is only set, if two consecutive values are greater than MaxDistance if (count==MaxCount) { if (set_home) { LastDistance=MaxDistance=increasing=decreasing=0; getGpsPilotPosition(); pilotAltitude = abs_alt; set_home=0; } if (GpsDistance > MaxDistance) { if (increasing) { MaxDistance=LastDistance; increasing=0; } else { increasing=1; } } else increasing=0; LastDistance=GpsDistance; lcd_outdezNAtt( 15*FW, 5*FH, MaxDistance, PREC1, 6); // Distance lcd_outdezNAtt( 15*FW, 6*FH, GpsDistance, PREC1, 6); // Distance } // on a communication loss, after a delay of some seconds, the last values are displayed else if (passes > 300) { lcd_outdezNAtt( 15*FW, 5*FH, MaxDistance, PREC1, 6); // show last MaxDistance lcd_outdezNAtt( 15*FW, 6*FH, LastDistance, PREC1, 6); // show LastDistance lcd_putsAtt ( 12*FW, 2*FH, val_unknown, 22); // large blinking Questionmark above Dist. } } //--------for Test only -------------------------------- /* initval (LONG_BUF(4), PACK_GGA, SAT); // -> rbuf[4] ER9X open9x lcd_putsnAtt ( 12*FW, 2*FH, &rbuf[4][0], 2, 16); // small normal lcd_putsnAtt ( 12*FW, 3*FH, &rbuf[4][0], 2, 17); // invers BLINK lcd_putsnAtt ( 12*FW, 4*FH, &rbuf[4][0], 2, 18); // blink INVERS lcd_putsnAtt ( 12*FW, 5*FH, &rbuf[4][0], 2, 20); // big normal */ //---------------------------------------- #if defined(HUB) initval (LONG_BUF(5), PACK_LCL, RSSI); // -> rbuf[4] lcd_putsnAtt ( 12*FW, 3*FH, &rbuf[5][0], 3, 16); // small normal my_lcd_puts ( 14*FW, 3*FH, PSTR("%") ); #endif if (rbuf[0][0]) { initval (LONG_BUF(4), PACK_GGA, SAT); // -> rbuf[4] lcd_putsnAtt (13*FW, 1*FH, &rbuf[4][0], 2, 16+fixed); // satellites in view, //invers if Fixed if (sbuf[1]>0x30) { // & GGA has FIX > "0" lcd_outdezNAtt( 10*FW, 2*FH, rel_alt, DBLSIZE|PREC1, 7); // actual altitude lcd_putcAtt ( 10*FW, 3*FH, sbuf[0]+0x20, 0); // dimension [m] as lower case lcd_outdezNAtt( 8*FW, 5*FH, lift_alt, DBLSIZE|PREC1, 6); // lift my_lcd_puts ( 5*FW, 4*FH, PSTR("[ /s]") ); lcd_putcAtt ( 6*FW, 4*FH, sbuf[0]+0x20, 0); // dimension [m/s] as lower case } } //---------------------------------------- // in case we do not receive GGA packages(due to poor receiption) the passes count will increase accordingly. question(12,2); // large blinking Questionmark in case of timeout }