Skip to content

Commit f4f180b

Browse files
committed
Migrate to new AP. Add multi-version support
1 parent 776823b commit f4f180b

13 files changed

Lines changed: 1617 additions & 1401 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,4 @@ Mkfile.old
5252
dkms.conf
5353

5454
.bin
55+
CLAUDE.md

build-uno-r4.sh

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
#!/bin/bash
2+
#########################################################################################
3+
#
4+
# Build script for the ProtoCentral Pulse Express library — Arduino Uno R4
5+
#
6+
# Compiles every sketch under examples/ against the Uno R4 Minima target by
7+
# default, or the Uno R4 WiFi target with --wifi. Installs the Renesas core
8+
# on first run if it is not already present.
9+
#
10+
# Copyright (c) 2025 ProtoCentral Electronics
11+
#
12+
# This software is licensed under the MIT License (http://opensource.org/licenses/MIT).
13+
#
14+
#########################################################################################
15+
16+
set -euo pipefail
17+
18+
LIBRARY_PATH="$(cd "$(dirname "$0")" && pwd)"
19+
EXAMPLES_DIR="$LIBRARY_PATH/examples"
20+
BOARD_FQBN="arduino:renesas_uno:minima"
21+
CORE_ID="arduino:renesas_uno"
22+
23+
RED='\033[0;31m'
24+
GREEN='\033[0;32m'
25+
YELLOW='\033[1;33m'
26+
BLUE='\033[0;34m'
27+
NC='\033[0m'
28+
29+
print_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
30+
print_success() { echo -e "${GREEN}[OK]${NC} $1"; }
31+
print_warning() { echo -e "${YELLOW}[WARN]${NC} $1"; }
32+
print_error() { echo -e "${RED}[ERROR]${NC} $1"; }
33+
34+
show_help() {
35+
cat <<EOF
36+
Pulse Express build script — Arduino Uno R4
37+
38+
Usage: $0 [OPTIONS]
39+
40+
Options:
41+
--wifi Build for Uno R4 WiFi (arduino:renesas_uno:unor4wifi)
42+
instead of the default Minima target.
43+
--fqbn FQBN Override the board FQBN entirely.
44+
-h, --help Show this help.
45+
46+
The script compiles every directory found in examples/ that contains a .ino
47+
file with a matching name. Exit code is non-zero if any sketch fails to build.
48+
EOF
49+
}
50+
51+
while [[ $# -gt 0 ]]; do
52+
case "$1" in
53+
--wifi)
54+
BOARD_FQBN="arduino:renesas_uno:unor4wifi"
55+
shift
56+
;;
57+
--fqbn)
58+
BOARD_FQBN="$2"
59+
shift 2
60+
;;
61+
-h|--help)
62+
show_help
63+
exit 0
64+
;;
65+
*)
66+
print_error "Unknown option: $1"
67+
show_help
68+
exit 1
69+
;;
70+
esac
71+
done
72+
73+
if ! command -v arduino-cli &> /dev/null; then
74+
print_error "arduino-cli not found"
75+
echo "Install from: https://arduino.github.io/arduino-cli/"
76+
exit 1
77+
fi
78+
79+
if ! arduino-cli core list 2>/dev/null | awk 'NR>1 {print $1}' | grep -qx "$CORE_ID"; then
80+
print_info "Installing $CORE_ID core..."
81+
arduino-cli core update-index
82+
arduino-cli core install "$CORE_ID"
83+
fi
84+
85+
if [[ ! -d "$EXAMPLES_DIR" ]]; then
86+
print_error "examples/ directory not found at $EXAMPLES_DIR"
87+
exit 1
88+
fi
89+
90+
print_info "Target FQBN: $BOARD_FQBN"
91+
print_info "Library: $LIBRARY_PATH"
92+
echo
93+
94+
declare -a SKETCHES=()
95+
while IFS= read -r dir; do
96+
name=$(basename "$dir")
97+
if [[ -f "$dir/$name.ino" ]]; then
98+
SKETCHES+=("$dir")
99+
else
100+
print_warning "Skipping $name (no $name.ino inside)"
101+
fi
102+
done < <(find "$EXAMPLES_DIR" -mindepth 1 -maxdepth 1 -type d | sort)
103+
104+
if [[ ${#SKETCHES[@]} -eq 0 ]]; then
105+
print_error "No example sketches found under $EXAMPLES_DIR"
106+
exit 1
107+
fi
108+
109+
PASS=0
110+
FAIL=0
111+
FAILED_NAMES=()
112+
113+
for sketch in "${SKETCHES[@]}"; do
114+
name=$(basename "$sketch")
115+
print_info "Compiling $name ..."
116+
if arduino-cli compile \
117+
--fqbn "$BOARD_FQBN" \
118+
--library "$LIBRARY_PATH" \
119+
--warnings default \
120+
"$sketch" > /tmp/pulse-express-build.log 2>&1; then
121+
SIZE_LINE=$(grep -E "^Sketch uses" /tmp/pulse-express-build.log || true)
122+
print_success "$name ${SIZE_LINE#Sketch uses }"
123+
PASS=$((PASS + 1))
124+
else
125+
print_error "$name failed:"
126+
sed 's/^/ /' /tmp/pulse-express-build.log
127+
FAIL=$((FAIL + 1))
128+
FAILED_NAMES+=("$name")
129+
fi
130+
done
131+
132+
echo
133+
echo "================================================================"
134+
print_info "$PASS passed, $FAIL failed (out of ${#SKETCHES[@]} sketches)"
135+
if [[ $FAIL -gt 0 ]]; then
136+
for n in "${FAILED_NAMES[@]}"; do
137+
echo " - $n"
138+
done
139+
exit 1
140+
fi
141+
echo "================================================================"
416 KB
Binary file not shown.
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
//////////////////////////////////////////////////////////////////////////////////////////
2+
//
3+
// Pulse Express — Raw PPG stream for the Arduino Serial Plotter
4+
//
5+
// Streams the IR PPG counter from the MAX30101 (via the MAX32664D sensor hub)
6+
// one sample per line. Place a finger on the sensor and open Tools → Serial
7+
// Plotter at 57600 baud to view the waveform.
8+
//
9+
// Hardware connections (default):
10+
// | MAX32664 pin | Arduino pin | Function |
11+
// |--------------|-------------|----------------|
12+
// | SDA | A4 | I2C data |
13+
// | SCL | A5 | I2C clock |
14+
// | Vin | 5V | Power |
15+
// | GND | GND | |
16+
// | MFIO | D2 | Data-ready int |
17+
// | RESET | D4 | Hub reset |
18+
//
19+
// Original 2020 example: Joice Tm, Copyright (c) 2020 ProtoCentral
20+
// Modernised: Copyright (c) 2025 ProtoCentral Electronics
21+
//
22+
// This software is licensed under the MIT License (http://opensource.org/licenses/MIT).
23+
//
24+
/////////////////////////////////////////////////////////////////////////////////////////
25+
26+
#include <Wire.h>
27+
#include "max32664.h"
28+
29+
#define RESET_PIN 4
30+
#define MFIO_PIN 2
31+
#define SAMPLE_CAP 32 // max samples to drain per loop iteration
32+
33+
Max32664 hub(RESET_PIN, MFIO_PIN);
34+
35+
void setup()
36+
{
37+
Serial.begin(57600);
38+
Wire.begin();
39+
40+
hub.setDebug(&Serial);
41+
42+
Max32664Status s = hub.begin();
43+
if (s != Max32664Status::Ok)
44+
{
45+
Serial.print("hub.begin() failed: 0x");
46+
Serial.println(uint8_t(s), HEX);
47+
while (true) delay(5000);
48+
}
49+
Serial.print("Hub firmware ");
50+
Serial.print(hub.version().major); Serial.print('.');
51+
Serial.print(hub.version().minor); Serial.print('.');
52+
Serial.println(hub.version().patch);
53+
54+
s = hub.startRaw();
55+
if (s != Max32664Status::Ok)
56+
{
57+
Serial.print("startRaw() failed: 0x");
58+
Serial.println(uint8_t(s), HEX);
59+
while (true) delay(5000);
60+
}
61+
delay(2000);
62+
}
63+
64+
void loop()
65+
{
66+
Max32664RawSample buf[SAMPLE_CAP];
67+
size_t n = 0;
68+
Max32664Status s = hub.readRaw(buf, SAMPLE_CAP, &n, /*wantRed=*/false);
69+
if (s != Max32664Status::Ok) return;
70+
71+
for (size_t i = 0; i < n; ++i)
72+
{
73+
Serial.println(buf[i].ir);
74+
delay(3);
75+
}
76+
}

0 commit comments

Comments
 (0)