-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
81 lines (60 loc) · 1.72 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# Define the list of Python source files
PY_SOURCES := $(wildcard *.py)
# Define the corresponding compiled files
MPY_OBJECTS := $(PY_SOURCES:.py=.mpy)
# Define the target device
DEVICE := :
# Define the mpy-cross command
MPY_CROSS := mpy-cross
# Define the mpremote command
MPREMOTE := mpremote
# File to track updated files
UPDATED_FILES := .updated_files
# Connect to the device with repl
repl:
@$(MPREMOTE) repl
.phony: rm_updated
rm_updated:
rm -f $(UPDATED_FILES);
# Rule to compile .py files to .mpy files
%.mpy: %.py
$(MPY_CROSS) $<
-echo $@ >> $(UPDATED_FILES)
# Rule to determine if a .mpy file needs to be updated
.PRECIOUS: %.mpy
.SECONDARY: $(MPY_OBJECTS)
# Rule to compile only
compile: rm_updated $(MPY_OBJECTS)
# Rule to transfer compiled .mpy files to the device
transfer:
@if [ -f $(UPDATED_FILES) ]; then \
for mpy in $$(cat $(UPDATED_FILES)); do \
$(MPREMOTE) cp $$mpy $(DEVICE); \
done; \
rm -f $(UPDATED_FILES); \
fi
# @$(MPREMOTE) repl
# Rule to compile and transfer
all: compile transfer
reset:
$(MPREMOTE) reset ; \
$(MPREMOTE) sleep 2
run: compile transfer reset repl
# Clean up compiled files
clean:
rm -f $(MPY_OBJECTS) $(UPDATED_FILES)
## Install on fresh new micropython device. Run as $> make PORT=/dev/cu.usbmodemXXX install
install: compile
mpremote connect $(PORT) mip install aioble \
mpremote mip install "github:peterhinch/micropython-async/v3/primitives" \
mpremote cp ble.mpy : \
mpremote cp tft_config.mpy : \
mpremote cp tft_buttons.mpy : \
mpremote cp wheeldata.mpy : \
mpremote cp Noto*.mpy : \
mpremote cp tft_display.mpy : \
mpremote cp main.py : \
mpremote cp app.mpy : \
mpremote cp alarms.mpy : \
mpremote cp heap_mon.mpy : \
mpremote cp board.mpy :