From b9cf29f09d96a64df00eb3dd7e5d4a31c6ca0219 Mon Sep 17 00:00:00 2001 From: Nathaniel van Diepen Date: Sun, 24 Dec 2023 20:53:14 -0700 Subject: [PATCH] Add simulate --- .gitignore | 8 +++++++ Makefile | 53 ++++++++++++++++++++++++++++++++++++++++++++ README.md | 11 +++++++++ myapp/__init__.py | 17 +++++++++++++- requirements-dev.txt | 3 +++ 5 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 Makefile create mode 100644 requirements-dev.txt diff --git a/.gitignore b/.gitignore index 68bc17f..936bf04 100644 --- a/.gitignore +++ b/.gitignore @@ -158,3 +158,11 @@ cython_debug/ # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. #.idea/ + +.rmkit/ +fb.pnm +fb.raw +event0 +event1 +event2 +.resim.sh diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..0911e89 --- /dev/null +++ b/Makefile @@ -0,0 +1,53 @@ +define USAGE +Development: + + simulator Run application with simulator + clean +endef +export USAGE + +help: + @echo "$$USAGE" + +.NOTPARALLEL: + +.rmkit: + git clone \ + --depth=1 \ + https://github.com/rmkit-dev/rmkit.git \ + .rmkit + +.venv/bin/activate: + @echo "Setting up development virtual env in .venv" + python -m venv .venv; \ + . .venv/bin/activate; \ + python -m pip install -r requirements-dev.txt + +.rmkit/src/build/simple: .rmkit .venv/bin/activate + . .venv/bin/activate; \ + cd .rmkit; \ + TARGET=dev make simple + +define SCRIPT +#!/bin/sh +. .venv/bin/activate +exec python myapp.py --simple-executable=.rmkit/src/build/simple +endef +export SCRIPT + +.resim.sh: .rmkit/src/build/simple + echo "$$SCRIPT" >> .resim.sh + chmod +x .resim.sh + +simulate: .venv/bin/activate .resim.sh + . .venv/bin/activate; \ + resim ./.resim.sh + +clean: + git clean --force -dX + rm -rf .rmkit + +.PHONY: \ + all \ + simulator \ + clean diff --git a/README.md b/README.md index d99f715..8b02a1c 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,17 @@ reMarkable Template Python Carta Application Testing ======= +Simulate +======== + +You can use [rmkit-sim](https://pypi.org/project/rmkit-sim/) to test your application on your local machine. +```bash +make simulate +``` + +On Device +========= + First you will need to install the following dependencies on the device: ```bash opkg update diff --git a/myapp/__init__.py b/myapp/__init__.py index 5e8e607..73ccfb8 100644 --- a/myapp/__init__.py +++ b/myapp/__init__.py @@ -1,8 +1,23 @@ +import argparse + from carta import ReMarkable, Widget def main(): - rm = ReMarkable() + parser = argparse.ArgumentParser( + prog="myapp", + description="Example carta application", + ) + parser.add_argument( + "--simple-executable", + help="Path to the simple application", + action="store", + default=None, + dest="simple", + ) + args = parser.parse_args() + + rm = ReMarkable(simple=args.simple) if args.simple is not None else ReMarkable() button = Widget( id="but1", diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..d5020d8 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,3 @@ +-r requirements.txt +rmkit-sim==0.0.2 +okp==0.0.54