Skip to content

Commit 5299b05

Browse files
committed
Merge branch 'main' into release-1.0
2 parents f1d346d + 3b0658f commit 5299b05

File tree

7 files changed

+108
-6
lines changed

7 files changed

+108
-6
lines changed

containers/ei-models-runner/Dockerfile

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,18 @@ RUN set -ex; \
1010
groupadd -g 29 audio || true; \
1111
groupadd -g 991 render || true; \
1212
groupadd -g 1000 arduino || true; \
13-
useradd -u 1000 -g arduino -G audio,video,render -ms /bin/bash arduino;
13+
useradd -u 1000 -g arduino -G audio,video,render -ms /bin/bash arduino
1414

1515
# Add all EI OOTB models to the container with specific ownership
1616
COPY --chown=arduino:arduino ./models/ei-ootb-models/arm64/* /models/ootb/ei/
17+
COPY --chown=arduino:arduino ./src/start-runner.sh /home/arduino/start-runner.sh
1718

18-
USER arduino
19-
20-
WORKDIR /app
19+
RUN chmod +x /home/arduino/start-runner.sh
2120

21+
WORKDIR /home/arduino
2222
ENV HOME=/home/arduino
23+
24+
USER arduino
2325
ENV USER=arduino
2426

25-
ENTRYPOINT ["node", "/app/linux/node/build/cli/linux/runner.js"]
27+
ENTRYPOINT ["/home/arduino/start-runner.sh"]
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
# SPDX-FileCopyrightText: Copyright (C) ARDUINO SRL (http://www.arduino.cc)
4+
#
5+
# SPDX-License-Identifier: MPL-2.0
6+
7+
NODE_COMMAND=("node" "/app/linux/node/build/cli/linux/runner.js" "$@")
8+
9+
trap_signal() {
10+
echo "Caught signal $1. Exiting wrapper immediately..."
11+
exit 0
12+
}
13+
14+
trap 'trap_signal TERM' TERM
15+
trap 'trap_signal INT' INT
16+
17+
while true; do
18+
echo "🚀 Starting EI inference runner..."
19+
20+
"${NODE_COMMAND[@]}"
21+
22+
EXIT_CODE=$?
23+
24+
# Check the exit code
25+
if [ $EXIT_CODE -eq 0 ]; then
26+
echo "✅ Application exited successfully (Exit Code: 0). Stopping restart loop."
27+
break
28+
else
29+
echo "⚠️ Application exited with error (Exit Code: $EXIT_CODE). Restarting in 1 seconds..."
30+
sleep 1
31+
fi
32+
done

src/arduino/app_bricks/streamlit_ui/addons.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def arduino_header(title: str):
3131
3232
Additionally, custom components like `st.arduino_header()` are provided to streamline Arduino integration.
3333
"""
34-
svg_path = os.path.join(os.path.dirname(__file__), "assets", "RGB-Arduino-Logo_Color Inline Loop.svg")
34+
svg_path = os.path.join(os.path.dirname(__file__), "assets", "RGB-Arduino-Logo-Color-Inline-Loop.svg")
3535
svg_path = os.path.abspath(svg_path)
3636
try:
3737
with open(svg_path, "r", encoding="utf-8") as f:

src/arduino/app_bricks/streamlit_ui/assets/RGB-Arduino-Logo_Color Inline Loop.svg renamed to src/arduino/app_bricks/streamlit_ui/assets/RGB-Arduino-Logo-Color-Inline-Loop.svg

File renamed without changes.

src/arduino/app_bricks/streamlit_ui/assets/RGB-Arduino-Logo_Color Inline Loop.svg.license renamed to src/arduino/app_bricks/streamlit_ui/assets/RGB-Arduino-Logo-Color-Inline-Loop.svg.license

File renamed without changes.

src/arduino/app_utils/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from .ledmatrix import *
1515
from .slidingwindowbuffer import *
1616
from .userinput import *
17+
from .leds import *
1718

1819
__all__ = [
1920
"App",
@@ -34,4 +35,5 @@
3435
"SineGenerator",
3536
"SlidingWindowBuffer",
3637
"UserTextInput",
38+
"Leds",
3739
]

src/arduino/app_utils/leds.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# SPDX-FileCopyrightText: Copyright (C) 2025 ARDUINO SA <http://www.arduino.cc>
2+
# SPDX-FileCopyrightText: Copyright (C) ARDUINO SRL (http://www.arduino.cc)
3+
#
4+
# SPDX-License-Identifier: MPL-2.0
5+
6+
from arduino.app_utils import Logger
7+
8+
logger = Logger(__name__)
9+
10+
11+
class Leds:
12+
"""
13+
A utility class for controlling LED colors on Arduino hardware.
14+
15+
This class provides static methods to control two RGB LEDs by writing to system
16+
brightness files. LED1 and LED2 can be controlled directly by the MPU, while
17+
LED3 and LED4 require MCU control via Bridge.
18+
19+
Attributes:
20+
_led_ids (list): List of supported LED IDs [1, 2].
21+
_led1_brightness_files (list): System file paths for LED1 RGB channels
22+
(red:user, green:user, blue:user).
23+
_led2_brightness_files (list): System file paths for LED2 RGB channels
24+
(red:panic, green:wlan, blue:bt).
25+
26+
Methods:
27+
set_led1_color(r, g, b): Set the RGB color state for LED1.
28+
set_led2_color(r, g, b): Set the RGB color state for LED2.
29+
30+
Example:
31+
>>> Leds.set_led1_color(True, False, True) # LED1 shows magenta
32+
>>> Leds.set_led2_color(False, True, False) # LED2 shows green
33+
"""
34+
35+
_led_ids = [1, 2] # Supported LED IDs (Led 3 and 4 can't be controlled directly by MPU but only by MCU via Bridge)
36+
37+
_led1_brightness_files = [
38+
"/sys/class/leds/red:user/brightness",
39+
"/sys/class/leds/green:user/brightness",
40+
"/sys/class/leds/blue:user/brightness",
41+
]
42+
_led2_brightness_files = [
43+
"/sys/class/leds/red:panic/brightness",
44+
"/sys/class/leds/green:wlan/brightness",
45+
"/sys/class/leds/blue:bt/brightness",
46+
]
47+
48+
@staticmethod
49+
def _write_led_file(led_file, value: bool):
50+
try:
51+
with open(led_file, "w") as f:
52+
f.write(f"{int(value)}\n")
53+
except Exception as e:
54+
print(f"Error writing to {led_file}: {e}")
55+
56+
@staticmethod
57+
def set_led1_color(r: bool, g: bool, b: bool):
58+
Leds._write_led_file(Leds._led1_brightness_files[0], r)
59+
Leds._write_led_file(Leds._led1_brightness_files[1], g)
60+
Leds._write_led_file(Leds._led1_brightness_files[2], b)
61+
62+
@staticmethod
63+
def set_led2_color(r: bool, g: bool, b: bool):
64+
Leds._write_led_file(Leds._led2_brightness_files[0], r)
65+
Leds._write_led_file(Leds._led2_brightness_files[1], g)
66+
Leds._write_led_file(Leds._led2_brightness_files[2], b)

0 commit comments

Comments
 (0)