From de380df8d6cb04ce335e32b97af579ee259e2680 Mon Sep 17 00:00:00 2001 From: Ren Juan Date: Sat, 28 Aug 2021 22:36:13 +0000 Subject: [PATCH] * --- Ejectable/GT2.tsx | 11 +++++++++-- Ejectable/app.json | 1 + Ejectable/components/ScreenInfo.tsx | 4 ++-- Ejectable/screens/TripScreen.tsx | 6 +++--- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Ejectable/GT2.tsx b/Ejectable/GT2.tsx index 71adc095..98447739 100644 --- a/Ejectable/GT2.tsx +++ b/Ejectable/GT2.tsx @@ -4,6 +4,7 @@ import { Text, View } from './components/Themed'; import { StyleSheet } from 'react-native'; import * as geolib from 'geolib'; +export const ver:string = "2.06;" var debug:number = 0; var endIsNigh:boolean = false; var testCount = 0; @@ -153,6 +154,7 @@ export class GT2 { startPoint:Coordinate = new Coordinate(0.0,0.0); displayInterval:number = displayBeat * heartbeat; + arc:number = 0.0; public distance:number = 0.0; co2Rate:number = 250.0; sensitivity:number = 3; @@ -210,6 +212,7 @@ export class GT2 { this.trip.stop(); this.inProgress = false; + this.arc = this.startPoint.distanceTo(this.trip.loc); this.trip.CO2 = ( this.distance / 1000 ) * this.co2Rate; this.nTrips++; @@ -225,7 +228,7 @@ export class GT2 { this.co2Rate = last.co2Rate; this.units = last.units; this.sensitivity = last.sensitivity; - + this.arc = last.arc; } public setLocEnabled(value:boolean) { locEnabled = value} @@ -245,6 +248,7 @@ export class GT2 { public reset() { this.distance = 0.0; + this.arc = 0.0; this.endPoint = new Coordinate(0,0); this.startPoint = new Coordinate(0,0); this.v = 0; @@ -269,6 +273,8 @@ export class GT2 { var preferredUnits:number = ((this.units == 'km') ? (this.distance / 1000) : (this.distance / 1609.34)); + var preferredUnitsArc:number = ((this.units == 'km') ? (this.arc / 1000) + : (this.arc / 1609.34)); return ( 'Elapsed - ' + this.trip.elapsed + '\n' + @@ -278,7 +284,8 @@ export class GT2 { ' long: ' + this.trip.loc.mLongitude.toFixed(8) + '\n' + 'CO2: ' + this.trip.CO2.toFixed(1) + ' grams ' + this.CO2Effect + '\n\n' + 'CO2 Rate / Sensitivity: ' + this.co2Rate + " / " + this.sensitivity + '\n' + - 'Distance covered while consuming fuel: ' + preferredUnits.toFixed(2) + ' ' + this.units ); + 'Arc distance from origin to destination: ' + preferredUnitsArc.toFixed(2) + this.units + '\n' + + 'Path distance while consuming fuel: ' + preferredUnits.toFixed(2) + ' ' + this.units ); } diff --git a/Ejectable/app.json b/Ejectable/app.json index 7be7ac0b..93ddaeb8 100644 --- a/Ejectable/app.json +++ b/Ejectable/app.json @@ -21,6 +21,7 @@ ], "ios": { "supportsTablet": true, + "bundleIdentifier": "app.greentravel.gt2", "buildNumber": "2", "infoPlist": { "UIBackgroundModes": [ diff --git a/Ejectable/components/ScreenInfo.tsx b/Ejectable/components/ScreenInfo.tsx index b947a14e..d3d52023 100644 --- a/Ejectable/components/ScreenInfo.tsx +++ b/Ejectable/components/ScreenInfo.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { StyleSheet, TouchableOpacity } from 'react-native'; import { Text, View } from './Themed'; import * as Device from 'expo-device'; -import { withSafeAreaInsets } from 'react-native-safe-area-context'; +import { ver } from '../GT2'; export default function ScreenInfo() { return ( @@ -61,7 +61,7 @@ export function ScreenInfo3() { style={styles.titleText} lightColor="rgba(0,0,0,0.8)" darkColor="rgba(255,255,255,0.8)"> - Green Travel Calculator v. 2.0.6 + {'Green Travel Calculator v. ' + ver } ) title={sButtonText} onPress={() => { if (!getAdvised()) { - Alert.alert("Note: GT2 2.0.n doesn't while run in background."); + Alert.alert("Note: " + ver + " doesn't run while in background or sleeping."); setAdvised(); } if (!Trips.inProgress) {startTrip(); @@ -102,7 +102,7 @@ export default function TripScreen( { navigation }: RootTabScreenProps<'Trip'>) title={sButtonText} onPress={() => { if (!getAdvised()) { - Alert.alert("Note: GT2 2.0.n doesn't run while in background."); + Alert.alert("Note: GT2 2.0.6 doesn't run while in background or sleeping."); setAdvised(); } if (!Trips.inProgress) {startTrip();