Skip to content

Commit d1a3f00

Browse files
author
Maarten Pennings
committed
0.4.0
- Updated documentation. - `aoapps_swflag.cpp` switched to new driver `aomw_iox4b4l`; it also supports selector SAIDsense (next to the one on SAIDbasic). - Added module `aoapps_sensors` (to be used with the SAIDsense demo board) and example `aoapps_sensors.ino`. - Added link to examples.
1 parent dcde8b6 commit d1a3f00

8 files changed

Lines changed: 879 additions & 45 deletions

File tree

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
// saidbasic.ino - the demo application for the SAIDbasic board
2+
/*****************************************************************************
3+
* Copyright 2024,2025 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 <aocmd.h> // aocmd_cint_pollserial()
24+
#include <aoui32.h> // aoui32_oled_splash()
25+
#include <aomw.h> // aomw_init()
26+
#include <aoapps.h> // aoapps_mngr_start()
27+
28+
29+
/*
30+
DESCRIPTION
31+
This is a template for a sketch using multiple apps and the app manager.
32+
It contains two apps ("runled" and "sensors"). The "A" button switches to
33+
the next app. For simplicity the command interpreter has not been added.
34+
35+
HARDWARE
36+
The demo should run on the OSP32 board, connected to the SAIDsense board.
37+
In Arduino select board "ESP32S3 Dev Module".
38+
39+
BEHAVIOR
40+
The behavior depends on the app chosen and the buttons pressed.
41+
42+
OUTPUT
43+
Welcome to aoapps_sensors.ino
44+
45+
spi: init(MCU-B)
46+
osp: init
47+
mw: init
48+
apps: init
49+
ui32: init
50+
sensors: using temp sensor 48 on SAID 003
51+
sensors: using rotation sensor 36 on SAID 003
52+
sensors: using light sensor 26 on SAID 003
53+
sensors: using display 38 on SAID 003
54+
sensors: using selector 3F on SAID 003
55+
*/
56+
57+
58+
void setup() {
59+
// Identify over Serial
60+
Serial.begin(115200);
61+
do delay(250); while( ! Serial );
62+
Serial.printf("\n\nWelcome to aoapps_sensors.ino\n\n");
63+
64+
// Initialize all libraries
65+
aospi_init();
66+
aoosp_init();
67+
aomw_init();
68+
aoapps_init();
69+
aoui32_init();
70+
71+
// Splash screen
72+
aoui32_oled_splash("aoapps_sensors", "1.0");
73+
delay(1000);
74+
75+
// App registration
76+
aoapps_runled_register(); // First app registered
77+
aoapps_sensors_register(); // Second app registered
78+
aoapps_sensors_resethw(); // Switch off display on SAISsense
79+
80+
// Start
81+
aoapps_mngr_start();
82+
}
83+
84+
85+
void loop() {
86+
// Check physical buttons
87+
aoui32_but_scan();
88+
89+
// Switch to next app when A was pressed
90+
if( aoui32_but_wentdown(AOUI32_BUT_A) ) aoapps_mngr_switchnext();
91+
92+
// Animation step in current application
93+
aoapps_mngr_step();
94+
}
95+
96+
97+

extras/aoapps-modules.drawio.png

7.3 KB
Loading

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=OSP ReusableApps aoapps
2-
version=0.3.0
2+
version=0.4.0
33
author=ams-OSRAM
44
maintainer=ams-OSRAM
55
sentence=A library with reusable "apps" for OSP chains.

readme.md

Lines changed: 62 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ The landing page for the _aolibs_ is on
1111
## Introduction
1212

1313
Library _aoapps_ is a library with reusable "apps" for OSP chains.
14-
Multiple apps form one firmware image (or executable) for the ESP32
15-
as explained below.
14+
Multiple apps form one _firmware image_ or _executable_ for the ESP32
15+
as explained below.
1616

1717

1818
![aoapps in context](extras/aolibs-aoapps.drawio.png)
@@ -23,7 +23,7 @@ that exposes a `step()` function, which is constantly called from the
2323
main loop, and which manages the animation implemented by the app.
2424

2525
In addition to the apps, this library also contains an _app manager_.
26-
A top-level sketch includes the manager and registers one or more apps,
26+
A sketch includes the manager and registers one or more apps,
2727
either from this library or from elsewhere (self developed). Typically
2828
the "A" button on the OSP32 board is used to tell the app manager
2929
to switch from one app to the next.
@@ -70,22 +70,28 @@ void loop() {
7070

7171
This library comes with the following examples.
7272
You can find them in the Arduino IDE via
73-
File > Examples > OSP ReusableApps aoapps > ...
73+
[File > Examples > OSP ReusableApps aoapps > ...](examples):
7474

7575
- **aoapps_switch** ([source](examples/aoapps_switch))
76-
This demo implements an application with two (dummy) apps.
76+
This demo implements an executable with two (dummy) apps,
77+
App1 and App2, which are part of the example.
7778
By pressing but A, the user can switch between the apps.
7879
The name of the active app is shown on the OLED.
7980
The green and red signaling LED show heart beat and error.
8081
App1 shows how to process button presses.
8182
App2 goes into error after a while (to show that the green heart beat
8283
LED stops and the red error LED switches on).
8384

84-
- **aoapps_runled** ([source](examples/aoapps_runled))
85+
- **aoapps_runled** ([source](examples/aoapps_runled))
8586
This demo shows how to run an app.
8687
It uses the "runled" app, which has been made to expose its internals;
8788
the start, step and stop function.
8889

90+
- **aoapps_sensors** ([source](examples/aoapps_sensors))
91+
This is a template for a sketch using multiple apps and the app manager.
92+
It contains two apps ("runled" and "sensors"). The "A" button switches to
93+
the next app. For simplicity the command interpreter has not been added.
94+
8995

9096
## Module architecture
9197

@@ -114,12 +120,12 @@ This library contains several modules, see figure below (arrows indicate `#inclu
114120
- The goal is to show that various OSP nodes can be mixed and have color/brightness matched.
115121

116122
- **aoapps_swflag** (`aoapps_swflag.cpp` and `aoapps_swflag.h`) is one of the stock apps.
117-
- Shows one (static) flag at a time, eg the Dutch national flag red/white/blue spread over the OSP chain.
118-
- Tries to find a SAID with an I2C bridge with an I/O-expander (with four buttons and four indicator LEDs).
119-
- If there is no I/O-expander, shows four static flags switching on a time basis.
120-
- If there are multiple I/O-expanders the first one is taken.
121-
- When an I/O-expander is found the four buttons select which flag to show.
122-
- The indicator LEDs connected to the I/O-expander indicate which button/flag was selected.
123+
- Shows one (static) flag at a time, e.g. the Dutch national flag red/white/blue spread over the OSP chain.
124+
- Tries to find a SAID with an I2C bridge with a "selector", an I/O-expander with four buttons and four indicator LEDs.
125+
- If there is no selector, shows four static flags switching on a time basis.
126+
- If there are multiple selectors the first SAIDbasic one is taken, or the first SAIDsense when no SAIDbasic.
127+
- When a selector is found the four buttons select which flag to show.
128+
- The indicator LEDs indicate which button/flag was selected.
123129
- The X and Y buttons control the dim level (RGB brightness).
124130
- This app adds a command to configure which four flags will be shown.
125131
- The goal is to show a "sensor" (button) being accessible from the root MCU (the ESP).
@@ -146,6 +152,32 @@ This library contains several modules, see figure below (arrows indicate `#inclu
146152
- Note, the tool [eepromflasher](https://github.com/ams-OSRAM/OSP_aotop/tree/main/examples/eepromflasher)
147153
allows flashing EEPROMs with the various animation scripts.
148154

155+
- **aoapps_sensors** (`aoapps_sensors.cpp` and `aoapps_sensors.h`) is one of the stock apps.
156+
- Measures the temperature using an AS6212 temperature sensor.
157+
- Measures the angle of the knob using an AS5600 rotary sensor.
158+
- Measures the light intensity using an SFH5721 ambient light sensor.
159+
- Only one of the three sensors is active at one time.
160+
- To change the active sensor, either press the X button to cycle to next,
161+
or press one of the selector buttons TEMP, ROTARY, ALS (and EXT) on
162+
the SAIDsense board.
163+
- The indicator LED (paired with the selector button) of the active
164+
sensor switches on.
165+
- The quad 7-segment display shows the readout of the active sensor.
166+
- When the temperature sensor is active, the OSP chains shows a red part
167+
and a blue part that change with temperature.
168+
- When the angle sensor is active, the knob angle (0-360) determines how
169+
many triplets are yellow (0..num triplets).
170+
- When ambient light sensor is active, the higher the ambient light level,
171+
the greener the triplets.
172+
- This app is written for the SAIDsense board.
173+
- For backward compatibility with older board, this app supports a board
174+
without light sensor, rotary sensor, or selector.
175+
- The Y button scrolls the type number of the sensor.
176+
- The X button toggles between temperature, angle or light sensor being active.
177+
- Upon a press the display shows the units for a short moment.
178+
- Active sensor has its indicator LED on.
179+
- Goal is to show a sensor can be used in OSP (eg for climate control, light adaption).
180+
149181

150182
## API
151183

@@ -212,14 +244,15 @@ so desired). This handler allows the user manage apps.
212244

213245
- `aoapps_runled_start()`, `aoapps_runled_step()`, `aoapps_runled_stop()`
214246
are external, making it easier to demo this app without the manager.
247+
For the other apps these functions are kept private.
215248

216249

217250
### aoapps_swflag
218251

219252
- `aoapps_swflag_register()` registers the swflag app with the app manager.
220-
- `aoresult_t aoapps_swflag_resethw()` resets the I/O-expander, thereby
221-
switching off the indicator LEDs attached to it. This helps reset the PCB
222-
state when the MCU is reset.
253+
- `aoapps_swflag_resethw()` resets the selector, thereby
254+
switching off the indicator LEDs attached to it.
255+
This helps reset the PCB state when the MCU is reset.
223256

224257

225258
### aoapps_dither
@@ -232,6 +265,14 @@ so desired). This handler allows the user manage apps.
232265
- `aoapps_aniscript_register()` registers the aniscript app with the app manager.
233266

234267

268+
### aoapps_sensors
269+
270+
- `aoapps_sensors_register()` registers the sensors app with the app manager.
271+
- `aoapps_sensors_resethw()` resets the selector and the quad 7-segment display,
272+
thereby switching off the LEDs attached to them.
273+
This helps reset the PCB state when the MCU is reset.
274+
275+
235276
## Execution architecture
236277

237278
To keep execution architecture simple, top-level sketches employ a
@@ -342,7 +383,6 @@ the `boot.cmd` which is executed at startup, for example:
342383
`apps config sw set dutch mali europe italy`.
343384
344385
345-
346386
## The voidapp
347387
348388
The app manager has one app always registered, the "voidapp". This app
@@ -361,6 +401,12 @@ of the OSP chain, without app telegrams interfering.
361401
362402
## Version history _aoapps_
363403
404+
- **2025 September 17, 0.4.0**
405+
- Updated documentation.
406+
- `aoapps_swflag.cpp` switched to new driver `aomw_iox4b4l`; it also supports selector SAIDsense (next to the one on SAIDbasic).
407+
- Added module `aoapps_sensors` (to be used with the SAIDsense demo board) and example `aoapps_sensors.ino`.
408+
- Added link to examples.
409+
364410
- **2025 March 3, 0.3.0**
365411
- Added the feature that an app can be hidden; the `hide` commands toggles.
366412
- The voidapp no longer is hardwired hidden; it uses the new hidden feature.

src/aoapps.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// aoapps.h - apps for OSP chains (eg running LEDs)
22
/*****************************************************************************
3-
* Copyright 2024 by ams OSRAM AG *
3+
* Copyright 2024,2025 by ams OSRAM AG *
44
* All rights are reserved. *
55
* *
66
* IMPORTANT - PLEASE READ CAREFULLY BEFORE COPYING, INSTALLING OR USING *
@@ -23,7 +23,7 @@
2323

2424

2525
// Identifies lib version
26-
#define AOAPPS_VERSION "0.3.0"
26+
#define AOAPPS_VERSION "0.4.0"
2727

2828

2929
// Include the (headers of the) modules of this app
@@ -32,6 +32,7 @@
3232
#include <aoapps_swflag.h> // the app "swflag"
3333
#include <aoapps_dither.h> // the app "dither"
3434
#include <aoapps_aniscript.h> // the app "aniscript"
35+
#include <aoapps_sensors.h> // the app "sensors"
3536

3637

3738
// Initializes the aoapps library (the mngr)

0 commit comments

Comments
 (0)