Skip to content

Commit

Permalink
Add simulate
Browse files Browse the repository at this point in the history
  • Loading branch information
Eeems committed Dec 25, 2023
1 parent f9b1c70 commit b9cf29f
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
53 changes: 53 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 16 additions & 1 deletion myapp/__init__.py
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
3 changes: 3 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-r requirements.txt
rmkit-sim==0.0.2
okp==0.0.54

0 comments on commit b9cf29f

Please sign in to comment.