Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
63a97c364d | ||
|
|
1ed4b45fe1 | ||
|
|
eb5b91d83b |
@ -28,7 +28,8 @@ source.include_exts = py,png,jpg,kv,atlas
|
||||
#source.exclude_patterns = license,images/*/*.jpg
|
||||
|
||||
# (str) Application versioning (method 1)
|
||||
version = 1.0
|
||||
version = 0.7
|
||||
|
||||
|
||||
# (str) Application versioning (method 2)
|
||||
# version.regex = __version__ = ['"](.*)['"]
|
||||
@ -36,7 +37,7 @@ version = 1.0
|
||||
|
||||
# (list) Application requirements
|
||||
# comma separated e.g. requirements = sqlite3,kivy
|
||||
requirements = hostpython3, python3, kivy, plyer, android, mapview, requests, urllib3, chardet, idna, geopy, geographiclib, python-dateutil
|
||||
requirements = hostpython3, python3, kivy, https://github.com/HyTurtle/plyer/archive/master.zip, android, mapview, requests, urllib3, chardet, idna, geopy, geographiclib, python-dateutil
|
||||
|
||||
# (str) Custom source folders for requirements
|
||||
# Sets custom source for any requirements with recipes
|
||||
@ -88,7 +89,7 @@ fullscreen = 0
|
||||
android.permissions = INTERNET,ACCESS_FINE_LOCATION,ACCESS_COARSE_LOCATION,WAKE_LOCK,READ_EXTERNAL_STORAGE,WRITE_EXTERNAL_STORAGE
|
||||
|
||||
# (int) Target Android API, should be as high as possible.
|
||||
#android.api = 27
|
||||
android.api = 30
|
||||
|
||||
# (int) Minimum API your APK will support.
|
||||
#android.minapi = 21
|
||||
|
||||
@ -157,7 +157,7 @@
|
||||
TextInput:
|
||||
id: flock_server
|
||||
font_size: '15sp'
|
||||
text: 'http://132.247.90.102'
|
||||
text: 'http://flocker.mooo.com'
|
||||
multiline: False
|
||||
BackgroundLabel:
|
||||
text: "Dark theme"
|
||||
|
||||
30
main.py
30
main.py
@ -79,16 +79,19 @@ class FlockompassApp(App):
|
||||
if path.isfile(pickle_path):
|
||||
with open(pickle_path, 'rb') as f:
|
||||
settings = pickle.load(f)
|
||||
Logger.info('Loaded settings')
|
||||
else:
|
||||
settings = {'settings_smoothing': 0.88,
|
||||
'settings_compass_update': 0.88,
|
||||
'settings_theme': "dark",
|
||||
'settings_flock_server': 'http://132.247.90.102'
|
||||
'settings_flock_server': 'http://flocker.mooo.com'
|
||||
}
|
||||
|
||||
with open(pickle_path, 'wb') as f:
|
||||
pickle.dump(settings, f)
|
||||
|
||||
Logger.info('Wrote default settings')
|
||||
|
||||
self.session_data.update(settings)
|
||||
|
||||
if self.session_data['settings_theme'] == "dark":
|
||||
@ -134,8 +137,7 @@ class FlockompassApp(App):
|
||||
self.compass_enable()
|
||||
self.session_data['dest_lat'] = self.ms.ids.centermark.lat
|
||||
self.session_data['dest_lon'] = self.ms.ids.centermark.lon
|
||||
self.ms.ids.mapview.center_on(self.session_data['dest_lat'],
|
||||
self.session_data['dest_lon'])
|
||||
Clock.schedule_once(self.center_map_on_session, 0)
|
||||
self.flock_server_register()
|
||||
Clock.schedule_interval(self.flock,
|
||||
self.session_data.get('settings_update_freq', 10.0))
|
||||
@ -187,8 +189,10 @@ class FlockompassApp(App):
|
||||
self.session_data['dest_lat'] = self.gps_data['lat']
|
||||
self.session_data['dest_lon'] = self.gps_data['lon']
|
||||
|
||||
self.ms.ids.mapview.center_on(self.session_data['dest_lat'],
|
||||
self.session_data['dest_lon'])
|
||||
Clock.schedule_once(self.center_map_on_session, 0)
|
||||
|
||||
# self.ms.ids.mapview.center_on(self.session_data['dest_lat'],
|
||||
# self.session_data['dest_lon'])
|
||||
else:
|
||||
dest_distance = geodesic(
|
||||
(self.gps_data['lat'], self.gps_data['lon']),
|
||||
@ -231,6 +235,11 @@ class FlockompassApp(App):
|
||||
self.gps_data['lon'])
|
||||
|
||||
|
||||
def center_map_on_session(self, *args):
|
||||
self.ms.ids.mapview.center_on(self.session_data['dest_lat'],
|
||||
self.session_data['dest_lon'])
|
||||
|
||||
|
||||
def get_field(self, dt):
|
||||
"""
|
||||
get magnetic field for compass
|
||||
@ -335,11 +344,13 @@ class FlockompassApp(App):
|
||||
'dest_lat': self.session_data['dest_lat'],
|
||||
'client_id': client_id},
|
||||
timeout=0.5)
|
||||
# TODO: check for response code, only proceed if 200
|
||||
self.session_data['bike_id'] = r.json()['bike_id']
|
||||
self.session_data['client_id'] = client_id
|
||||
Logger.info('registered! got bike_id: %s' % self.session_data['bike_id'])
|
||||
self.flock_server_update()
|
||||
except requests.exceptions.HTTPError as e:
|
||||
status_code = e.response.status_code
|
||||
Logger.info('http error', status_code)
|
||||
except requests.exceptions.Timeout:
|
||||
Logger.info('comm timeout while registering with flock server')
|
||||
except requests.exceptions.ConnectionError:
|
||||
@ -364,7 +375,12 @@ class FlockompassApp(App):
|
||||
if resp:
|
||||
self.session_data['last_update'] = isoparse(resp.pop('last_update'))
|
||||
|
||||
if 'flock_size' not in resp:
|
||||
if 'flock_size' in resp:
|
||||
self.session_data['flock_lat'] = resp.pop('flock_lat')
|
||||
self.session_data['flock_lon'] = resp.pop('flock_lon')
|
||||
self.session_data['flock_size'] = resp.pop('flock_size')
|
||||
self.session_data['flock_avg_speed'] = resp.pop('flock_avg_speed')
|
||||
else:
|
||||
self.session_data.pop('flock_avg_speed', None)
|
||||
self.session_data.pop('flock_lat', None)
|
||||
self.session_data.pop('flock_lon', None)
|
||||
|
||||
@ -32,7 +32,7 @@ pep517==0.6.0
|
||||
pexpect==4.8.0
|
||||
pickleshare==0.7.5
|
||||
platformdirs==2.4.0
|
||||
plyer==2.0.0
|
||||
plyer
|
||||
prompt-toolkit==3.0.21
|
||||
ptyprocess==0.7.0
|
||||
Pygments==2.10.0
|
||||
|
||||
Loading…
Reference in New Issue
Block a user