Skip to content

Conversation

@per1234
Copy link
Contributor

@per1234 per1234 commented Nov 25, 2025

Motivation

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.

Change description

The default Python script is hereby changed to the more intuitive behavior of running perpetually.

Additional Notes

Arduino App Lab 0.2.0 treated the App as being in a running state until the user explicitly stopped it. So even though Arduino App CLI considered the App with the previous Python code to have stopped, App Lab provided the users with the expected behavior where they would continue to be able to see the output from the sketch program in the App Lab Serial Monitor.

This behavior changed in Arduino App Lab 0.2.4. It now considers the App to be stopped when Arduino App CLI considers it stopped. I believe the new behavior of Arduino App Lab is correct, but the users who are accustomed to their Apps having the previous behavior are interpreting this as a bug:

Reviewer checklist

  • PR addresses a single concern.
  • PR title and description are properly filled.
  • Changes will be merged in main.
  • Changes are covered by tests.
  • Logging is meaningful in case of troubleshooting.

@per1234 per1234 requested review from dido18 and lucarin91 November 25, 2025 15:59
@per1234 per1234 added the enhancement New feature or request label Nov 25, 2025
@per1234 per1234 force-pushed the default-python-loop branch 2 times, most recently from 26ae187 to c845aad Compare November 25, 2025 23:26
@robgee86
Copy link

I like the proposal, I'm adding an observation: in the examples we sponsor using the App.run() approach that achieves the same objective.
For consistency, we could use that instead, and the default Python script would become:

from arduino.app_utils import App

print("Hello world!")

App.run()

@lucarin91
Copy link
Contributor

@robgee86 @per1234, maybe we should add a comment on what App.run() is

@Xayton
Copy link
Contributor

Xayton commented Nov 26, 2025

After an internal discussion, it was confirmed that Arduino Apps should have a default Python code that includes the App.run() code. This is because the Python code is not generic, but is in the specific context of an Arduino App.

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>
@per1234 per1234 force-pushed the default-python-loop branch from c845aad to 407d30d Compare November 27, 2025 07:37
@per1234 per1234 requested a review from dido18 November 27, 2025 07:51
@per1234 per1234 self-assigned this Nov 27, 2025
@per1234 per1234 merged commit 299f6e2 into arduino:main Nov 27, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants