Skip to content

Commit

Permalink
Build joystick.kv in VirtualJoystickWidget (#4)
Browse files Browse the repository at this point in the history
* Simpler - just keep joystick in res/

* remove unused import

* Build joystick.kv in VirtualJoystickWidget

* rm comment

* Allow forwarding command line args from terminal
  • Loading branch information
Hackerman342 committed Feb 7, 2023
1 parent 24f13e2 commit a05a17d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion entry.sh
Expand Up @@ -3,6 +3,6 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

$DIR/bootstrap.sh $DIR $DIR/venv

$DIR/venv/bin/python $DIR/src/main.py --camera-port 50051 --canbus-port 50060
$DIR/venv/bin/python $DIR/src/main.py $@ --camera-port 50051 --canbus-port 50060

exit 0
5 changes: 5 additions & 0 deletions libs/virtual_joystick/joystick.py
Expand Up @@ -22,6 +22,7 @@

from kivy.clock import Clock # noqa: E402
from kivy.input.providers.mouse import MouseMotionEvent # noqa: E402
from kivy.lang.builder import Builder # noqa: E402
from kivy.uix.widget import Widget # noqa: E402


Expand All @@ -34,6 +35,10 @@ def __init__(self, **kwargs) -> None:
# Schedule the drawing of the joystick at 30 hz
Clock.schedule_interval(self.draw_joystick, 1 / 30)

# Build the .kv file for this VirtualJoystickWidget
# This is so it is included when your app imports the VirtualJoystickWidget
Builder.load_file(os.path.join(os.path.dirname(__file__), "res/joystick.kv"))

def on_touch_down(self, touch: MouseMotionEvent) -> None:
"""Overwrite kivy method that handles initial press with mouse click or touchscreen.
Expand Down
File renamed without changes.
4 changes: 0 additions & 4 deletions src/main.py
Expand Up @@ -18,7 +18,6 @@
from typing import Optional

import grpc
import virtual_joystick
from farm_ng.canbus import canbus_pb2
from farm_ng.canbus.canbus_client import CanbusClient
from farm_ng.canbus.packet import AmigaControlState
Expand Down Expand Up @@ -77,9 +76,6 @@ def __init__(
self.async_tasks: List[asyncio.Task] = []

def build(self):
# Build the imported ``VirtualJoystickWidget`` .kv file first
Builder.load_file(os.path.dirname(virtual_joystick.__file__) + "/joystick.kv")
# Then build the App's .kv file (which references the VirtualJoystickWidget)
return Builder.load_file("res/main.kv")

def on_exit_btn(self) -> None:
Expand Down

0 comments on commit a05a17d

Please sign in to comment.