implement gpsblinker

This commit is contained in:
Daniel afx 2020-10-14 19:41:26 +03:00
parent 1802d14d8e
commit 32d59cbd87
5 changed files with 40 additions and 7 deletions

View file

@ -1,5 +1,6 @@
#:import MapView kivy_garden.mapview.MapView
#:import GpsBlinker gpsblinker.GpsBlinker
#:include gpsblinker.kv
<ForestMapView>:
lat: 42.131331

View file

@ -24,14 +24,14 @@ class ForestMapView(MapView):
# Get reference to main app and the db cursor
app = App.get_running_app()
# Gebug gps position
#print(self.get_bbox())
print("] Current map position: " + str(self.get_bbox()))
min_lat, min_lon, max_lat, max_lon = self.get_bbox()
sql_statement = "SELECT * FROM locations WHERE x > %s AND x < %s AND y > %s AND y < %s" % (min_lat, max_lat, min_lon, max_lon) #sql_statement = "SELECT * FROM locations"
app.cursor.execute(sql_statement)
trees = app.cursor.fetchall()
for tree in trees:
name = tree[0]
print("] Fountain detected: " + str(tree))
#print("] Fountain detected: " + str(tree))
if name in self.tree_names:
continue
else:
@ -49,4 +49,4 @@ class ForestMapView(MapView):
# Keep track of the TreeMarker's name
self.tree_names.append(name)
self.tree_names.append(name)

View file

@ -1 +1,22 @@
<GpsBlinker>:
<GpsBlinker>:
default_blink_size: 25
blink_size: 25
source: 'kivymd/images/transparent.png'
outer_opacity: 1
canvas.before:
# Outer circle
Color:
rgba: app.theme_cls.primary_color[:3] + [root.outer_opacity]
RoundedRectangle:
radius: [root.blink_size/2.0, ]
size: [root.blink_size, root.blink_size]
pos: root.pos[0] + root.size[0]/2.0 - root.blink_size/2.0, root.pos[1] + root.size[1]/2.0 - root.blink_size/2.0
# Inner Circle
Color:
rgba: app.theme_cls.primary_color
RoundedRectangle:
radius: [root.default_blink_size/2.0, ]
size: [root.default_blink_size, root.default_blink_size]
pos: [root.pos[0] + root.size[0]/2.0 - root.default_blink_size/2.0, root.pos[1] + root.size[1]/2.0 - root.default_blink_size/2.0]

View file

@ -1,7 +1,15 @@
from kivy_garden.mapview import MapMarker
from kivy.animation import Animation
class GpsBlinker(MapMarker):
def blink(self):
# Animantion that changes the blink size and opacity
# Animation that changes the blink size and opacity
anim = Animation(outer_opacity=0, blink_size=50)
# When the animation completes, reset the animation, then repeat
pass
anim.bind(on_complete=self.reset)
anim.start(self)
def reset(self, *args):
self.outer_opacity = 1
self.blink_size = self.default_blink_size
self.blink()

View file

@ -5,7 +5,10 @@ class TreePopupMenu(ListMDDialog):
super().__init__()
# Set all of the fields of tree data
headers = "Name,Lat,Lon,Description"
#headers = "Name,Lat,Lon,Description"
#headers = headers.split(',')
# Set all of the fields of market data
headers = "FMID,MarketName,Website,Facebook,Twitter,Youtube,OtherMedia,street,city,County,State,zip,Season1Date,Season1Time,Season2Date,Season2Time,Season3Date,Season3Time,Season4Date,Season4Time,x,y,Location,Credit,WIC,WICcash,SFMNP,SNAP,Organic,Bakedgoods,Cheese,Crafts,Flowers,Eggs,Seafood,Herbs,Vegetables,Honey,Jams,Maple,Meat,Nursery,Nuts,Plants,Poultry,Prepared,Soap,Trees,Wine,Coffee,Beans,Fruits,Grains,Juices,Mushrooms,PetFood,Tofu,WildHarvested,updateTime"
headers = headers.split(',')
for i in range(len(headers)):