Skip to content

Commit 299f6e2

Browse files
per1234dido18
andauthored
feat: Do not exit from default Python script (#106)
When a new App is created, it is populated with a simple Python script and "bare minimum" Arduino sketch. For initial explorations of a new system, or when troubleshooting, it is common to create very simple programs (AKA "Hello, world!"). Although a complex App will typically consist of a Python script and Arduino sketch program working in coordination, for users with prior experience with Arduino the natural approach to creating a minimal App will be to simply write some familiar Arduino sketch code, leaving the default Python script code as-is. The App is considered to be in a "stopped" state as soon as the Python script exits. This is the correct approach, but may be confusing to users due to the fact that, except perhaps under exceptional conditions, the Arduino sketch program runs perpetually. The author of a minimal sketch-based "Hello, world!" App will find it unintuitive if their App goes into a "stopped" state immediately after starting. The previous default Python script produced exactly that result. The default Python script is hereby changed to the more intuitive behavior of running perpetually. Co-authored-by: Davide <davideneri18@gmail.com>
1 parent 12a78db commit 299f6e2

File tree

3 files changed

+39
-12
lines changed
  • internal/orchestrator/app/generator

3 files changed

+39
-12
lines changed
Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
1-
def main():
2-
print("Hello World!")
1+
import time
32

3+
from arduino.app_utils import App
44

5-
if __name__ == "__main__":
6-
main()
5+
print("Hello world!")
6+
7+
8+
def loop():
9+
"""This function is called repeatedly by the App framework."""
10+
# You can replace this with any code you want your App to run repeatedly.
11+
time.sleep(10)
12+
13+
14+
# See: https://docs.arduino.cc/software/app-lab/tutorials/getting-started/#app-run
15+
App.run(user_loop=loop)
Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
1-
def main():
2-
print("Hello World!")
1+
import time
32

3+
from arduino.app_utils import App
44

5-
if __name__ == "__main__":
6-
main()
5+
print("Hello world!")
6+
7+
8+
def loop():
9+
"""This function is called repeatedly by the App framework."""
10+
# You can replace this with any code you want your App to run repeatedly.
11+
time.sleep(10)
12+
13+
14+
# See: https://docs.arduino.cc/software/app-lab/tutorials/getting-started/#app-run
15+
App.run(user_loop=loop)
Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
1-
def main():
2-
print("Hello World!")
1+
import time
32

3+
from arduino.app_utils import App
44

5-
if __name__ == "__main__":
6-
main()
5+
print("Hello world!")
6+
7+
8+
def loop():
9+
"""This function is called repeatedly by the App framework."""
10+
# You can replace this with any code you want your App to run repeatedly.
11+
time.sleep(10)
12+
13+
14+
# See: https://docs.arduino.cc/software/app-lab/tutorials/getting-started/#app-run
15+
App.run(user_loop=loop)

0 commit comments

Comments
 (0)