Skip to content

Commit 0cb23e3

Browse files
authored
Merge pull request #2 from arduino-libraries/improvements
Clean up for release
2 parents 8811c6c + 81d89ad commit 0cb23e3

12 files changed

+173
-135
lines changed

Diff for: .github/workflows/check-arduino.yml renamed to .github/workflows/arduino-lint.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Check Arduino
1+
name: Arduino Linter
22

33
# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows
44
on:

Diff for: .github/workflows/compile-examples.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@ on:
2222

2323
env:
2424
UNIVERSAL_SKETCH_PATHS: |
25-
- examples/WakeFromGPIO
25+
- examples/WakeFromPin
2626
- examples/WakeFromRTC
27-
- examples/TurnPeripheralsOff
2827
SKETCHES_REPORTS_PATH: sketches-reports
2928
SKETCHES_REPORTS_ARTIFACT_NAME: sketches-reports
3029

Diff for: .github/workflows/render-documentation.yml

+9-8
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@ name: Render Documentation
22

33
on:
44
push:
5+
branches:
6+
- main
57
paths:
68
- ".github/workflows/render-documentation.ya?ml"
79
- "examples/**"
810
- "src/**"
911
pull_request:
12+
branches:
13+
- main
1014
paths:
1115
- ".github/workflows/render-documentation.ya?ml"
1216
- "examples/**"
@@ -15,13 +19,10 @@ on:
1519

1620
jobs:
1721
render-docs:
18-
runs-on: ubuntu-latest
1922
permissions:
2023
contents: write
21-
22-
steps:
23-
- uses: actions/checkout@v4
24-
- uses: sebromero/render-docs-github-action@main
25-
with:
26-
source-path: './src'
27-
target-path: './docs/api.md'
24+
uses: arduino/render-docs-github-action/.github/workflows/render-docs.yml@main
25+
with:
26+
source-path: './src'
27+
target-path: './docs/api.md'
28+
commit: ${{ github.event_name != 'pull_request' }} # Only commit changes if not a PR

Diff for: README.md

+22-23
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@
55
The Portenta C33 Low Power Library is a library designed to optimize power consumption for projects using the Portenta C33 boards, which are powered by the Renesas RA6M5 microcontroller. The library achieves this by providing access to various low power modes. These modes are essential for applications where power efficiency is crucial, such as in remote sensing, IoT devices, or battery-powered applications.
66

77
## Examples
8-
* [WakeFromGPIO](https://github.com/arduino-libraries/Arduino_LowPowerPortentaC33/blob/main/examples/WakeFromGPIO/WakeFromGPIO.ino) - This example demonstrates how you can use [the GPIO pins](https://github.com/arduino-libraries/Arduino_LowPowerPortentaC33/blob/main/docs/README.md#wakeup-pins) to wake your board from sleep.
9-
* [WakeFromRTC](https://github.com/arduino-libraries/Arduino_LowPowerPortentaC33/blob/main/examples/WakeFromRTC/WakeFromRTC.ino) - This example demonstrates how you can use the RTC to wake the board from sleep.
8+
* [WakeFromPin](./examples/WakeFromPin/WakeFromPin.ino) - This example demonstrates how you can use [the GPIO pins](#wake-up-pins) to wake your board from sleep.
9+
* [WakeFromRTC](./examples/WakeFromRTC/WakeFromRTC.ino) - This example demonstrates how you can use the RTC to wake the board from sleep.
1010

11-
## 😴 Sleep Modes
11+
## 💤 Sleep Modes
1212

13-
### Sleep
13+
### 🥱 Sleep
1414
* **Function**: Reduces the microcontroller's power usage to about half of its normal consumption.
1515
* **Effect**: Upon waking up from this mode, the execution of your program resumes exactly where it stopped. This is particularly useful for applications that require a quick resume with minimal power savings.
1616
* **Wake-Up Triggers**: The board can be configured to wake up either from an RTC alarm or an external interrupt pin.
1717

18-
### Deep Sleep
19-
* **Function**: Significantly reduces power usage to approximately 100uA (when all peripherals are off), making it ideal for long-term, battery-dependent operations.
20-
* **Effect**: Unlike Sleep Mode, waking up from Deep Sleep Mode restarts the board, triggering the void setup() function. This behavior is suitable for scenarios where a full reset is acceptable or desired upon waking up.
21-
* **Wake-Up Triggers**: The board can be configured to wake up either from an RTC alarm or an external interrupt pin.
18+
### 😴 Deep Sleep
19+
- **Function**: Significantly reduces power usage to approximately 100uA (when all peripherals are off), making it ideal for long-term, battery-dependent operations.
20+
- **Effect**: Unlike Sleep Mode, waking up from Deep Sleep Mode restarts the board, triggering the `setup()` function. This behavior is suitable for scenarios where a full reset is acceptable or desired upon waking up. The application state may need to be persisted before going to sleep.
21+
- **Wake-Up Triggers**: The board can be configured to wake up either from an RTC alarm or an external interrupt pin.
2222

2323

2424
## 📐 Measurements
@@ -32,16 +32,16 @@ Here's an overview of the reduction in power usage that you can expect from this
3232
| Deep Sleep | On | 11.57mA |
3333
| Deep Sleep | Off | **58.99uA** |
3434

35-
For more information about these measurements check out [this document](https://github.com/arduino-libraries/Arduino_LowPowerPortentaC33/blob/main/docs/README.md)
35+
For more information about these measurements check out [this page](./docs/)
3636

37-
## Usage
38-
### Selecting a wakeup source
39-
The wakeup source can be one of the deep-sleep enabled wakeup pins, and an RTC Alarm. You can select multiple pins and the RTC alarm to wake up the board.
37+
## 💻 Usage
38+
### Selecting a Wake-Up Source
39+
The wake-up source can be one of the deep-sleep enabled wake-up pins, and an RTC Alarm. You can select multiple pins and the RTC alarm to wake up the board.
4040

41-
#### Wakeup Pins
42-
This feature can be used when you want to wake up the board from external stimuli, such as sensors or user input. Some sensors have an interrupt pin that you can connect to one of the wakeup pins (eg: most motion sensors), while some output voltage on a pin, (eg: Passive Infrared Sensors or user buttons).
41+
#### 📍 Wake-Up Pins
42+
This feature can be used when you want to wake up the board from external stimuli, such as sensors or user input. Some sensors have an interrupt pin that you can connect to one of the wake-up pins (eg: most motion sensors), while others output a voltage on a pin when triggered (eg: Passive Infrared Sensors or user buttons).
4343

44-
To select a wakeup pin just call `lowPower.setWakeupPin(<pin_number>, <direction>)`. The direction can be either **RISING** if you want to wake up when voltage is applied to a pin, or **FALLING** if you want to wake when no voltage is applied anymore.
44+
To set up a wake-up pin call `lowPower.setWakeupPin(<pin_number>, <direction>)`. The direction can be either `RISING` if you want to wake up when voltage is applied to a pin, or `FALLING` if you want to wake when no voltage is applied anymore.
4545

4646
Here is a list of the usable interrupts:
4747

@@ -57,15 +57,14 @@ Here is a list of the usable interrupts:
5757
| D7 | P402 | IRQ4 |
5858

5959
> [!IMPORTANT]
60-
> Not all IRQs are created equal, the number of the IRQ represents it's priority. (IRQ0 being the highest priority and IRQ15 the lowest). Be careful when selecting your IRQ pin to make sure the board behaves as expected.
61-
62-
#### RTC Alarm
63-
This feature is particularly useful when you want to set the board to wake up at specific times. You can use this in conjunction with the [RTC library]().
64-
To make your board wake up on an RTC alarm you simply need to call `lowPower.setWakeupRTC()` and it will enable that functionality. Check out [this example]() for more details about setting up the RTC.
60+
> Not all IRQs are created equal. The number of the IRQ represents it's priority. (`IRQ0` being the highest priority and `IRQ15` the lowest). Be careful when selecting your IRQ pin to make sure the board behaves as expected.
6561
62+
#### ⏰ RTC Alarm
63+
This feature is particularly useful when you want to set the board to wake up at specific times. You can use this in conjunction with the [RTC library](https://github.com/arduino/ArduinoCore-renesas/tree/main/libraries/RTC).
64+
To make your board wake up on an RTC alarm you simply need to call `lowPower.setWakeUpAlarm(time)` or `lowPower.setWakeUpAlarm(hours, minutes, seconds)`. Check out this [example](./examples/WakeFromRTC/) for more details about setting up the RTC.
6665

67-
### Initiating sleep modes:
68-
Use lowPower.sleep() for Sleep Mode and lowPower.deepSleep() for Deep Sleep Mode. Upon calling these methods the board will sleep until one of the wakeup events mentioned earlier arises.
6966

67+
### 🛏️ Initiating sleep modes
68+
Use `lowPower.sleep()` to enter the Sleep Mode and `lowPower.deepSleep()` to enter the Deep Sleep Mode. Upon calling these methods the board will sleep until one of the wake-up events mentioned earlier arises.
7069

71-
For more information about this library check the [API Reference](https://github.com/arduino-libraries/Arduino_LowPowerPortentaC33/blob/main/docs/api.md)
70+
For more information on how to use this library check the [API Reference](./docs/api.md)

Diff for: docs/README.md

+5-6
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,20 @@
22

33
The screenshots below are taken from the nRF Power Profiler application using a Nordic PPK2 while running the blink sketch on the same board.
44

5-
65
#### Normal operating conditions
7-
![](https://raw.githubusercontent.com/arduino-libraries/Arduino_LowPowerPortentaC33/main/extras/results/normal_usage_blink.png)
6+
![](./assets/normal_usage_blink.png)
87

98
#### Deep Sleep
109
##### Peripherals off
11-
![](https://raw.githubusercontent.com/arduino-libraries/Arduino_LowPowerPortentaC33/main/extras/results/deep_sleep_no_peripherals.png)
10+
![](./assets/deep_sleep_no_peripherals.png)
1211

1312
##### Peripherals on
14-
![](https://raw.githubusercontent.com/arduino-libraries/Arduino_LowPowerPortentaC33/main/extras/results/deep_sleep_peripherals_on.png)
13+
![](./assets/deep_sleep_peripherals_on.png)
1514

1615
#### Sleep Mode
1716
##### Peripherals off
18-
![](https://raw.githubusercontent.com/arduino-libraries/Arduino_LowPowerPortentaC33/main/extras/results/sleep_no_peripherals.png)
17+
![](./assets/sleep_no_peripherals.png)
1918

2019
##### Peripherals on
21-
![](https://raw.githubusercontent.com/arduino-libraries/Arduino_LowPowerPortentaC33/main/extras/results/sleep_peripherals_on.png)
20+
![](./assets/sleep_peripherals_on.png)
2221

Diff for: docs/api.md

+12-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ This class allows the user to put the device into different low-power states and
1818
| [`sleep`](#class_low_power_1a351563f87f8d1f118e9d77201fd59a55) | Puts the device into a standard sleep mode. This sleep mode consumes less power than the active mode but more than the deep sleep mode. The device will resume execution from the point where it entered the sleep mode. |
1919
| [`deepSleep`](#class_low_power_1ada3410c10d04970e0898eb5f7f36ce55) | Puts the device into a deep sleep mode. The device consumes the least power in this mode but will reset when it wakes up effectively running the setup() function again. |
2020
| [`enableWakeupFromPin`](#class_low_power_1a9ee83fbc2b670ac9490cd179b2e08138) | Enables wake-up of the device from a specified pin (A0, A1, A2, A3, A4, A5, D4, D7 ) |
21-
| [`enableWakeupFromRTC`](#class_low_power_1a91d86cab239a56506bf15e9d2139c097) | Enables wake-up of the device based on the Real-Time Clock (RTC). |
21+
| [`setWakeUpAlarm`](#class_low_power_1ad9ccfd5502d837138fde0e60e5dc70e6) | |
22+
| [`setWakeUpAlarm`](#class_low_power_1aeaa63e5a37b37ccb0379e9d2ade99941) | |
2223

2324
## Members
2425

@@ -62,12 +63,19 @@ Enables wake-up of the device from a specified pin (A0, A1, A2, A3, A4, A5, D4,
6263
* `direction` The direction of the interrupt that will wake up the device. (RISING, FALLING, CHANGE)
6364
<hr />
6465
65-
### `enableWakeupFromRTC` <a id="class_low_power_1a91d86cab239a56506bf15e9d2139c097" class="anchor"></a>
66+
### `setWakeUpAlarm` <a id="class_low_power_1ad9ccfd5502d837138fde0e60e5dc70e6" class="anchor"></a>
6667
6768
```cpp
68-
void enableWakeupFromRTC()
69+
bool setWakeUpAlarm(RTCTime alarmTime)
70+
```
71+
72+
<hr />
73+
74+
### `setWakeUpAlarm` <a id="class_low_power_1aeaa63e5a37b37ccb0379e9d2ade99941" class="anchor"></a>
75+
76+
```cpp
77+
bool setWakeUpAlarm(uint8_t hours, uint8_t minutes, uint8_t seconds)
6978
```
7079
71-
Enables wake-up of the device based on the Real-Time Clock (RTC).
7280
<hr />
7381

Diff for: examples/WakeFromGPIO/WakeFromGPIO.ino renamed to examples/WakeFromPin/WakeFromPin.ino

+27-19
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,35 @@
11
/*
2-
********************************************************************************
3-
* WakeFromGPIO.ino
4-
*
52
* This example demonstrates how to wake up the Portenta C33 from deep sleep using a GPIO pin.
63
* The pin can be configured to wake up the device on a rising or falling edge, but not all pins are supported.
74
* Please check the README.md file for more information about the supported pins.
85
*
9-
* The example uses two buttons connected to pin 0 and A3:
10-
* * The device will go to sleep when the button connected to pin 0 is pressed.
6+
* The example uses two buttons connected to pin D0 and A3:
7+
* * The device will go to sleep when the button connected to pin D0 is pressed.
118
* * The device will wake up when the button connected to pin A3 is pressed.
129
*
1310
* The example also demonstrates how to use the PF1550 PMIC to turn off the peripherals
1411
* before going to sleep and turn them back on after waking up.
15-
* uncomment #define TURN_PERIPHERALS_OFF on line 28 to enable this feature.
12+
* uncomment #define TURN_PERIPHERALS_OFF to enable this feature.
1613
*
17-
* When the device is not sleeping it will blink the built-in LED every 100ms.
14+
* When the device is not sleeping it will blink the built-in LED.
1815
*
1916
* INSTRUCTIONS:
20-
* - Make sure you are running the latest version of the Renesas Core
17+
* - Make sure you are running the latest version of the Portenta C33 Core
2118
* - Select the Portenta C33 board from the Tools menu
22-
* - Select the Portenta C33 USB port from the Tools menu
19+
* - Select the Portenta C33's USB port from the Tools menu
2320
* - Upload the code to your Portenta C33
24-
* - Connect a button to pin 0 and with a pull-up resistor to 3.3V
25-
* - Connect a button to pin A3 and with a pull-up resistor to 3.3V
21+
* - Connect a button to pin D0 and ground (internal pull-up resistor is enabled)
22+
* - Connect a button to pin A3 and ground (internal pull-up resistor is enabled)
2623
* (If you need information about how to wire the buttons check this link: https://docs.arduino.cc/built-in-examples/digital/Button/)
2724
*
28-
* Original author: C. Dragomir (http://arduino.cc)
25+
* Initial author: C. Dragomir
2926
*/
3027

3128
#include "Arduino_LowPowerPortentaC33.h"
3229

33-
// #define TURN_PERIPHERALS_OFF
34-
#define SLEEP_PIN 0
35-
#define WAKE_PIN A3
30+
// #define TURN_PERIPHERALS_OFF // Uncomment this line to turn off the peripherals before going to sleep
31+
#define SLEEP_PIN D0 // Pin used to put the device to sleep
32+
#define WAKE_PIN A3 // Pin used to wake up the device
3633

3734
LowPower lowPower;
3835

@@ -59,14 +56,24 @@ LowPower lowPower;
5956
#endif
6057

6158
void goToSleep(){
62-
turnPeripheralsOff();
59+
#ifdef TURN_PERIPHERALS_OFF
60+
turnPeripheralsOff();
61+
#else
62+
// Turn off the built-in LED before going to sleep
63+
digitalWrite(LED_BUILTIN, HIGH);
64+
#endif
6365
lowPower.deepSleep();
6466
}
6567

6668
void setup(){
67-
lowPower = LowPower();
69+
// Register the sleep and wake-up pins as inputs with pull-up resistors
70+
pinMode(SLEEP_PIN, INPUT_PULLUP);
71+
pinMode(WAKE_PIN, INPUT_PULLUP);
72+
73+
// Register the callback function to put the device to sleep when the button is pressed
6874
attachInterrupt(digitalPinToInterrupt(SLEEP_PIN), goToSleep, RISING);
6975
lowPower.enableWakeupFromPin(WAKE_PIN, RISING);
76+
7077
pinMode(LED_BUILTIN, OUTPUT);
7178

7279
#ifdef TURN_PERIPHERALS_OFF
@@ -76,10 +83,11 @@ void setup(){
7683
}
7784

7885
void loop(){
86+
// Blink the built-in LED every 500ms when the device is not sleeping
7987
digitalWrite(LED_BUILTIN, HIGH);
80-
delay(100);
88+
delay(500);
8189
digitalWrite(LED_BUILTIN, LOW);
82-
delay(100);
90+
delay(500);
8391
}
8492

8593

0 commit comments

Comments
 (0)