Skip to content

Commit a4f2126

Browse files
0.2.9
- Fixed parsing problems Doxygen. - Prefixed `modules.drawio.png` with library short name. - Added example `aoapps_runled.ino`. - Moved domain from `github.com/ams-OSRAM-Group` to `github.com/ams-OSRAM`. - Term cleanup ("indicator LEDs" and "I/O-expander"). - Cleanup of `readme.md`. - Added BEHAVIOR to `aoapps_switch.ino`. - `aoapps_mngr` now uses `"apps"` in error messages, no longer `"mngr"`. - More uniform error messages in command `swflags`. - Now prints flags in `apps list` (with help, fixed bug). - Added feature `AOAPPS_MNGR_FLAGS_NEXTONERR` in app manager (next app on error). - Added links in `readme.md` for all example sketches. - Fixed typos in `aoapps_xxx_register()` documentation. - Corrected link to GitHub from `aotop` to `OSP_aotop`. - Remove "oalib" from `sentence=` in `library.properties`. - Arduino name changed from `OSP Reusable apps - aoapps` to `OSP ReusableApps aoapps`. - Renamed dir `extra` to `extras`. - `license.txt` line endings changed from LF to CR+LF.
0 parents  commit a4f2126

19 files changed

Lines changed: 2532 additions & 0 deletions
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// aoapps_runled.ino - - illustrates how to run a single app
2+
/*****************************************************************************
3+
* Copyright 2024 by ams OSRAM AG *
4+
* All rights are reserved. *
5+
* *
6+
* IMPORTANT - PLEASE READ CAREFULLY BEFORE COPYING, INSTALLING OR USING *
7+
* THE SOFTWARE. *
8+
* *
9+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
10+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
11+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
12+
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT *
13+
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
14+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
15+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
16+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
17+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
18+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
19+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
20+
*****************************************************************************/
21+
#include <aospi.h> // aospi_init()
22+
#include <aoosp.h> // aoosp_init()
23+
#include <aomw.h> // aomw_init()
24+
#include <aoapps_runled.h> // aoapps_runled_step()
25+
26+
/*
27+
DESCRIPTION
28+
This demo shows how to run an app.
29+
It uses the runled app, which has been made to expose its internals;
30+
the start, step and stop function.
31+
32+
HARDWARE
33+
The demo runs on the OSP32 board, with the SAIDbasic board connected.
34+
In Arduino select board "ESP32S3 Dev Module".
35+
36+
BEHAVIOR
37+
See aoapps_runled.cpp for how the running led behaves; but informally
38+
it a a color bar going left to righ and back in changing colors.
39+
40+
OUTPUT
41+
Welcome to aoapps_runled.ino
42+
43+
spi: init
44+
osp: init
45+
mw: init
46+
topo ok
47+
*/
48+
49+
50+
void setup() {
51+
Serial.begin(115200);
52+
do delay(250); while( ! Serial );
53+
Serial.printf("\n\nWelcome to aoapps_runled.ino\n\n");
54+
55+
// Initialize all libraries
56+
aospi_init();
57+
aoosp_init();
58+
aomw_init();
59+
aoresult_t result = aomw_topo_build(); // runled uses topo
60+
Serial.printf("topo %s\n", aoresult_to_str(result) );
61+
62+
// Start the app
63+
aoapps_runled_start();
64+
}
65+
66+
67+
void loop() {
68+
// Animate the app
69+
aoapps_runled_step();
70+
}
71+
Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
// aoapps_switch.ino - illustrates how to switch between registered apps
2+
/*****************************************************************************
3+
* Copyright 2024 by ams OSRAM AG *
4+
* All rights are reserved. *
5+
* *
6+
* IMPORTANT - PLEASE READ CAREFULLY BEFORE COPYING, INSTALLING OR USING *
7+
* THE SOFTWARE. *
8+
* *
9+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
10+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
11+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
12+
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT *
13+
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
14+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
15+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
16+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
17+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
18+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
19+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
20+
*****************************************************************************/
21+
#include <aoui32.h> // aoui32_oled_splash()
22+
#include <aoapps.h> // aoapps_mngr_start()
23+
24+
25+
/*
26+
DESCRIPTION
27+
This demo implements an application with two (dummy) apps.
28+
By pressing but A, the user can switch between the apps.
29+
The name of the active app is shown on the OLED.
30+
The green and red signaling LED show heart beat and error.
31+
App1 shows how to process button presses.
32+
App2 goes into error after a while (to show that the green heart beat
33+
LED stops and the red error LED switches on).
34+
35+
HARDWARE
36+
The demo runs on the OSP32 board (uses the A, X, and Y buttons).
37+
In Arduino select board "ESP32S3 Dev Module".
38+
39+
BEHAVIOR
40+
When demo starts, OLED shows that "Application 1" is running and that
41+
X and Y cause a print. When pressing X or Y, we see that on Serial.
42+
While running, the green/ok LED blinks ("heartbeat").
43+
We switch to the next app by pressing A. The OLED shows "Application 2".
44+
The X and Y have no function. Green/ok led blinks heartbeat. After a
45+
while Application 2 goes into error. Heartbeat stops, red led is on
46+
permanently, and the OLED shows an error message (from aoresult_other).
47+
If the flag AOAPPS_MNGR_FLAGS_NEXTONERR is passed to application 2,
48+
the app manager will switch automatically to the next app (Application 1)
49+
when the error occurs (and some wait).
50+
51+
OUTPUT
52+
Welcome to aoapps_switch
53+
ui32: init
54+
apps: init
55+
56+
app1: start
57+
app1: step
58+
app1: step
59+
app1: step
60+
app1: step
61+
app1: step
62+
app1: but X
63+
app1: step
64+
app1: but Y
65+
app1: step
66+
app1: step
67+
app1: step
68+
app1: stop
69+
70+
app2: start
71+
app2: step
72+
app2: step
73+
app2: step
74+
app2: step
75+
app2: step
76+
app2: step
77+
app2: step (pretend error)
78+
apps: ERROR in app 'app2': other
79+
app2: stop
80+
81+
app1: start
82+
app1: step
83+
app1: step
84+
app1: step
85+
*/
86+
87+
88+
// === dummy app1 ===========================================================
89+
90+
91+
static uint32_t last;
92+
93+
static aoresult_t app1_start() {
94+
Serial.printf("app1: start\n");
95+
last= millis();
96+
return aoresult_ok;
97+
}
98+
99+
static aoresult_t app1_step() {
100+
if( aoui32_but_wentdown(AOUI32_BUT_X) ) Serial.printf("app1: but X\n");
101+
if( aoui32_but_wentdown(AOUI32_BUT_Y) ) Serial.printf("app1: but Y\n");
102+
if( millis()-last>2000 ) { Serial.printf("app1: step\n"); last=millis(); }
103+
return aoresult_ok;
104+
}
105+
106+
static void app1_stop() {
107+
Serial.printf("app1: stop\n\n");
108+
}
109+
110+
void app1_register() {
111+
aoapps_mngr_register("app1", "Application 1", "print X", "print Y", AOAPPS_MNGR_FLAGS_NONE, app1_start, app1_step, app1_stop, 0, 0);
112+
}
113+
114+
115+
// === dummy app2 ===========================================================
116+
117+
118+
static int count;
119+
120+
static aoresult_t app2_start() {
121+
Serial.printf("app2: start\n");
122+
last= millis();
123+
count=0;
124+
return aoresult_ok;
125+
}
126+
127+
static aoresult_t app2_step() {
128+
if( count>5 ) { Serial.printf("app2: step (pretend error)\n"); return aoresult_other; }
129+
if( millis()-last>2000 ) { Serial.printf("app2: step\n"); last=millis(); count++; }
130+
return aoresult_ok;
131+
}
132+
133+
static void app2_stop() {
134+
Serial.printf("app2: stop\n\n");
135+
}
136+
137+
void app2_register() {
138+
// Option: add flag AOAPPS_MNGR_FLAGS_NEXTONERR
139+
aoapps_mngr_register("app2", "Application 2", "--", "--", AOAPPS_MNGR_FLAGS_NONE , app2_start, app2_step, app2_stop, 0, 0);
140+
}
141+
142+
143+
// === application ==========================================================
144+
145+
146+
// Pick apps that we want in this application (either from the aoapps library, or the local ones)
147+
void apps_register() {
148+
app1_register();
149+
app2_register();
150+
}
151+
152+
153+
void setup() {
154+
// Identify over Serial
155+
Serial.begin(115200);
156+
do delay(250); while( ! Serial );
157+
Serial.printf("\n\n\nWelcome to aoapps_switch\n");
158+
159+
// Initialize all libraries
160+
aoui32_init();
161+
aoapps_init();
162+
apps_register();
163+
Serial.printf("\n");
164+
165+
// Start the first app
166+
aoapps_mngr_start();
167+
}
168+
169+
170+
void loop() {
171+
// Check physical buttons
172+
aoui32_but_scan();
173+
174+
// Switch to next app when A was pressed
175+
if( aoui32_but_wentdown(AOUI32_BUT_A) ) aoapps_mngr_switchnext();
176+
177+
// Let current app progress
178+
aoapps_mngr_step();
179+
}
180+
181+
182+

extras/aoapps-modules.drawio.png

19.7 KB
Loading

extras/aolibs-aoapps.drawio.png

30.6 KB
Loading

library.properties

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name=OSP ReusableApps aoapps
2+
version=0.2.9
3+
author=ams-OSRAM
4+
maintainer=ams-OSRAM
5+
sentence=A library with reusable "apps" for OSP chains.
6+
paragraph=Multiple "apps" form one firmware image (executable). Example apps are running LEDs or scripted animation.
7+
category=Device Control
8+
url=https://github.com/ams-OSRAM/OSP_aoapps
9+
architectures=esp32
10+
depends=OSP ResultCodes aoresult,OSP 2wireSPI aospi,OSP Telegrams aoosp,OSP CommandInterpreter aocmd,OSP Middleware aomw,OSP UIDriversOSP32 aoui32
11+
includes=aoapps.h

license.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*****************************************************************************
2+
* Copyright 2024 by ams OSRAM AG *
3+
* All rights are reserved. *
4+
* *
5+
* IMPORTANT - PLEASE READ CAREFULLY BEFORE COPYING, INSTALLING OR USING *
6+
* THE SOFTWARE. *
7+
* *
8+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
9+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
10+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
11+
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT *
12+
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
13+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
14+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
15+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
16+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
17+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
18+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
19+
*****************************************************************************/

0 commit comments

Comments
 (0)