Skip to content

Commit

Permalink
improve
Browse files Browse the repository at this point in the history
  • Loading branch information
hishizuka committed Dec 15, 2023
1 parent d09cb19 commit 5d478b5
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/log/
/screenshots/
/maptile/*
/modules/test_code/
/courses/.current
/courses/ridewithgps/*
/courses/*html*
Expand All @@ -28,4 +29,4 @@ nohup.out
!.gitkeep
screenlog.*
gmon.out

.DS_Store
2 changes: 1 addition & 1 deletion modules/pyqt/pyqt_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def update_value(self, value):
self.value.setText(value)
elif np.isnan(value):
self.value.setText("-")
elif "Speed" in self.name:
elif self.name.startswith("Speed"):
self.value.setText(self.itemformat.format(value * 3.6)) # m/s to km/h
elif "SPD" in self.name:
self.value.setText(self.itemformat.format(value * 3.6)) # m/s to km/h
Expand Down
2 changes: 1 addition & 1 deletion modules/sensor/ant/ant_device_ctrl.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def add_struct_pattern(self):
def on_data(self, data):
(self.values["ctrl_cmd"],) = self.structPattern[self.name].unpack(data[0:8])
if self.values["ctrl_cmd"] in self.ctrl_cmd.keys():
self.config.press_button(
self.config.button_config.press_button(
"Edge_Remote", *(self.ctrl_cmd[self.values["ctrl_cmd"]])
)
else:
Expand Down
5 changes: 4 additions & 1 deletion modules/sensor/gps/dummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import numpy as np

from modules.utils.geo import calc_azimuth
from modules.utils.geo import calc_azimuth, get_track_str
from .base import AbstractSensorGPS


Expand All @@ -25,6 +25,7 @@ def set_position_from_log(self, current_position):
self.values["lon"] = np.nan
if self.values["track"] is None:
self.values["track"] = self.values["pre_track"]
self.values["track_str"] = get_track_str(self.values["track"])

def set_position_from_course(self, course, idx):
lat = course.latitude
Expand All @@ -49,6 +50,8 @@ def set_position_from_course(self, course, idx):
)
)[0]
)
if not np.isnan(self.values["track"]):
self.values["track_str"] = get_track_str(self.values["track"])

async def update(self):
if self.config.G_DUMMY_OUTPUT:
Expand Down
2 changes: 1 addition & 1 deletion modules/sensor/i2c/button_shim.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def __init__(self, config):
_FUNC["E_LONG"] = self.press_E_LONG

def press_button(self, button, index):
self.config.press_button("Button_Shim", button, index)
self.config.button_config.press_button("Button_Shim", button, index)

def press_A(self):
self.press_button("A", 0)
Expand Down
4 changes: 2 additions & 2 deletions modules/sensor/sensor_gpio.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ def my_callback(self, channel):
sw_counter
>= self.config.button_config.G_BUTTON_LONG_PRESS * self.interval_inv
):
self.config.press_button(
self.config.button_config.press_button(
self.config.G_DISPLAY, channel, 1
) # long press
break
else:
self.config.press_button(self.config.G_DISPLAY, channel, 0)
self.config.button_config.press_button(self.config.G_DISPLAY, channel, 0)
break
time.sleep(self.interval)

Expand Down
2 changes: 2 additions & 0 deletions modules/utils/geo.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ def get_mod_lat_np(lat):


def get_track_str(drc):
if np.isnan(drc):
return None
track_int = int((drc + 22.5) / 45.0)
return TRACK_STR[track_int]

Expand Down
7 changes: 5 additions & 2 deletions modules/utils/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
import shutil


def get_maptile_filename(map_name, z, x, y):
return f"maptile/{map_name}/{z}/{x}/{y}.png"
def get_maptile_filename(map_name, z, x, y, basetime=None, validtime=None):
if basetime and validtime:
return f"maptile/{map_name}/{basetime}/{validtime}/{z}/{x}/{y}.png"
else:
return f"maptile/{map_name}/{z}/{x}/{y}.png"


def get_lon_lat_from_tile_xy(z, x, y):
Expand Down

0 comments on commit 5d478b5

Please sign in to comment.