Skip to content

Commit f1cf3ce

Browse files
committed
Merge branch 'refs/heads/main' into displayio_api_9x
2 parents 93d32ea + 109eebc commit f1cf3ce

File tree

870 files changed

+152449
-817
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

870 files changed

+152449
-817
lines changed

.github/workflows/arduino_cron.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ jobs:
3939
[[ $changedfile == *.cpp ]] ||
4040
[[ $changedfile == *.h ]] ||
4141
[[ $changedfile == *.hpp ]] ||
42-
[[ $changedfile == *.ino ]]; then
42+
[[ $changedfile == *.ino ]] ||
43+
[[ $changedfile == *.yml ]]; then
4344
ischanged=true
4445
break
4546
fi
@@ -60,14 +61,19 @@ jobs:
6061
strategy:
6162
fail-fast: false
6263
matrix:
63-
arduino-platform: ["cpb", "cpc", "cpx_ada", "esp32", "esp8266", "feather32u4", "feather_m0_express", "feather_m4_express", "feather_rp2040", "flora", "funhouse", "gemma", "gemma_m0", "hallowing_m0", "hallowing_m4_tinyusb", "magtag", "metro_m0", "metro_m0_tinyusb", "metro_m4", "metro_m4_tinyusb", "monster_m4sk", "monster_m4sk_tinyusb", "neokeytrinkey_m0", "neotrellis_m4", "nrf52832", "nrf52840", "pycamera_s3", "protrinket_5v", "proxlighttrinkey_m0", "pybadge", "pygamer", "pyportal", "qualia_s3_rgb666", "qt2040_trinkey", "qtpy_m0", "qtpy_esp32s2", "rotarytrinkey_m0", "slidetrinkey_m0", "trinket_m0", "uno", "trinket_5v", "ledglasses_nrf52840" ]
64+
arduino-platform: ["cpb", "cpc", "cpx_ada", "esp32", "esp8266", "feather32u4", "feather_esp32c6", "feather_m0_express", "feather_m4_express", "feather_rp2040", "feather_rp2040_adalogger", "flora", "funhouse", "gemma", "gemma_m0", "hallowing_m0", "hallowing_m4_tinyusb", "ledglasses_nrf52840", "magtag", "metro_m0", "metro_m0_tinyusb", "metro_m4", "metro_m4_tinyusb", "monster_m4sk", "monster_m4sk_tinyusb", "neokeytrinkey_m0", "neotrellis_m4", "nrf52832", "nrf52840", "pixeltrinkey_m0", "protrinket_5v", "proxlighttrinkey_m0", "pybadge", "pycamera_s3", "pygamer", "pyportal", "qualia_s3_rgb666", "qt2040_trinkey", "qtpy_m0", "qtpy_esp32s2", "rotarytrinkey_m0", "sht4xtrinkey_m0", "slidetrinkey_m0", "trinket_5v", "trinket_m0", "uno"]
6465
runs-on: ubuntu-latest
6566
if: needs.check-if-needed.outputs.answer == 'true'
6667
needs: check-if-needed
6768
steps:
6869
- uses: actions/setup-python@v5
6970
with:
7071
python-version: "3.x"
72+
73+
# Checkout the learn repo itself
74+
- uses: actions/checkout@v4
75+
76+
# Checkout the CI scripts
7177
- uses: actions/checkout@v4
7278
with:
7379
repository: adafruit/ci-arduino
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// SPDX-FileCopyrightText: 2024 Liz Clark for Adafruit Industries
2+
//
3+
// SPDX-License-Identifier: MIT
4+
5+
const int DIR = 5;
6+
const int STEP = 6;
7+
const int microMode = 16; // microstep mode, default is 1/16 so 16; ex: 1/4 would be 4
8+
// full rotation * microstep divider
9+
const int steps = 200 * microMode;
10+
11+
void setup()
12+
{
13+
// setup step and dir pins as outputs
14+
pinMode(STEP, OUTPUT);
15+
pinMode(DIR, OUTPUT);
16+
}
17+
18+
void loop()
19+
{
20+
// change direction every loop
21+
digitalWrite(DIR, !digitalRead(DIR));
22+
// toggle STEP to move
23+
for(int x = 0; x < steps; x++)
24+
{
25+
digitalWrite(STEP, HIGH);
26+
delay(2);
27+
digitalWrite(STEP, LOW);
28+
delay(2);
29+
}
30+
delay(1000); // 1 second delay
31+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# SPDX-FileCopyrightText: 2024 Liz Clark for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
import time
6+
import board
7+
from digitalio import DigitalInOut, Direction
8+
9+
# direction and step pins as outputs
10+
DIR = DigitalInOut(board.D5)
11+
DIR.direction = Direction.OUTPUT
12+
STEP = DigitalInOut(board.D6)
13+
STEP.direction = Direction.OUTPUT
14+
15+
# microstep mode, default is 1/16 so 16
16+
# another ex: 1/4 microstep would be 4
17+
microMode = 16
18+
# full rotation multiplied by the microstep divider
19+
steps = 200 * microMode
20+
21+
while True:
22+
# change direction every loop
23+
DIR.value = not DIR.value
24+
# toggle STEP pin to move the motor
25+
for i in range(steps):
26+
STEP.value = True
27+
time.sleep(0.001)
28+
STEP.value = False
29+
time.sleep(0.001)
30+
print("rotated! now reverse")
31+
# 1 second delay before starting again
32+
time.sleep(1)
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// SPDX-FileCopyrightText: 2024 Liz Clark for Adafruit Industries
2+
//
3+
// SPDX-License-Identifier: MIT
4+
5+
#include <Adafruit_ADG72x.h>
6+
7+
Adafruit_ADG72x adg72x;
8+
9+
bool isADG728 = false; // which chip are we connected to?
10+
11+
int analogIn = A0;
12+
int analogValue = 0;
13+
unsigned long switchTimer = 1000; // 1000 ms = 1 second for channel switch
14+
unsigned long readTimer = 10; // 10 ms for analog read
15+
unsigned long lastSwitchTime = 0; // Last time the channels were switched
16+
unsigned long lastReadTime = 0; // Last time the analog was read
17+
uint8_t currentChannel = 0; // Current channel being selected
18+
19+
void setup() {
20+
Serial.begin(115200);
21+
22+
// Wait for serial port to open
23+
while (!Serial) {
24+
delay(1);
25+
}
26+
27+
// Try with the ADG728 default address first...
28+
if (adg72x.begin(ADG728_DEFAULT_ADDR, &Wire)) {
29+
Serial.println("ADG728 found!");
30+
isADG728 = true;
31+
}
32+
// Maybe they have an ADG729?
33+
else if (adg72x.begin(ADG729_DEFAULT_ADDR, &Wire)) {
34+
Serial.println("ADG729 found!");
35+
isADG728 = false;
36+
}
37+
else {
38+
Serial.println("No ADG device found? Check wiring!");
39+
while (1); // Stop here if no device was found
40+
}
41+
}
42+
43+
void loop() {
44+
unsigned long currentTime = millis();
45+
46+
// read and print analog value every 10ms
47+
if ((currentTime - lastReadTime) >= readTimer) {
48+
analogValue = analogRead(analogIn);
49+
Serial.println(analogValue);
50+
lastReadTime = currentTime;
51+
}
52+
53+
// switch channels every 1 second
54+
if ((currentTime - lastSwitchTime) >= switchTimer) {
55+
uint8_t bits = 1 << currentChannel; // Shift a '1' from LSB to MSB
56+
if (!adg72x.selectChannels(bits)) {
57+
Serial.println("Failed to set channels...");
58+
}
59+
/*Serial.print((currentChannel % 4) + 1);
60+
if (currentChannel < 4) Serial.println("A");
61+
else Serial.println("B");*/
62+
currentChannel = (currentChannel + 1) % 8; // Move to the next channel, wrap around at 8
63+
lastSwitchTime = currentTime;
64+
}
65+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// SPDX-FileCopyrightText: 2024 Liz Clark for Adafruit Industries
2+
//
3+
// SPDX-License-Identifier: MIT
4+
5+
#include <Adafruit_ADG72x.h>
6+
7+
Adafruit_ADG72x adg72x;
8+
9+
int analogInA0 = A0;
10+
int analogInA1 = A1;
11+
int analogValueDA = 0;
12+
int analogValueDB = 0;
13+
unsigned long switchTimer = 1000; // 1000 ms = 1 second for channel switch
14+
unsigned long readTimer = 10; // 10 ms for analog read
15+
unsigned long lastSwitchTime = 0; // Last time the channels were switched
16+
unsigned long lastReadTime = 0; // Last time the analog was read
17+
uint8_t currentChannel = 0; // Current channel being selected
18+
19+
void setup() {
20+
Serial.begin(115200);
21+
22+
// Wait for serial port to open
23+
while (!Serial) {
24+
delay(1);
25+
}
26+
27+
// Try with the ADG728 default address first...
28+
if (adg72x.begin(ADG728_DEFAULT_ADDR, &Wire)) {
29+
//Serial.println("ADG728 found!");
30+
}
31+
// Maybe they have an ADG729?
32+
else if (adg72x.begin(ADG729_DEFAULT_ADDR, &Wire)) {
33+
//Serial.println("ADG729 found!");
34+
}
35+
else {
36+
Serial.println("No ADG72x device found? Check wiring!");
37+
while (1); // Stop here if no device was found
38+
}
39+
}
40+
41+
void loop() {
42+
unsigned long currentTime = millis();
43+
44+
// read and print analog value every 10ms
45+
if ((currentTime - lastReadTime) >= readTimer) {
46+
analogValueDA = analogRead(analogInA0);
47+
analogValueDB = analogRead(analogInA1);
48+
Serial.print(analogValueDA);
49+
Serial.print(",");
50+
Serial.println(analogValueDB);
51+
lastReadTime = currentTime;
52+
}
53+
54+
// switch channels every 1 second
55+
if ((currentTime - lastSwitchTime) >= switchTimer) {
56+
uint8_t bits = 1 << currentChannel; // Shift a '1' from LSB to MSB
57+
if (!adg72x.selectChannels(bits)) {
58+
Serial.println("Failed to set channels...");
59+
}
60+
/*Serial.print((currentChannel % 4) + 1);
61+
if (currentChannel < 4) Serial.println("A");
62+
else Serial.println("B");*/
63+
currentChannel = (currentChannel + 1) % 8; // Move to the next channel, wrap around at 8
64+
lastSwitchTime = currentTime;
65+
}
66+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2024 Liz Clark for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
import time
6+
import board
7+
import adafruit_adg72x
8+
from analogio import AnalogIn
9+
10+
analog_in = AnalogIn(board.A0)
11+
12+
i2c = board.I2C()
13+
switch = adafruit_adg72x.ADG72x(i2c)
14+
15+
c = 0
16+
switch_time = 2
17+
channels = [0, 4]
18+
clock = time.monotonic()
19+
while True:
20+
if (time.monotonic() - clock) > switch_time:
21+
print(f"Selecting channel {channels[c] + 1}")
22+
switch.channel = channels[c]
23+
c = (c + 1) % 2
24+
clock = time.monotonic()
25+
print((analog_in.value,))
26+
time.sleep(0.1)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2024 Liz Clark for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
import time
6+
import board
7+
import adafruit_adg72x
8+
from analogio import AnalogIn
9+
10+
analog_in_DA = AnalogIn(board.A0)
11+
analog_in_DB = AnalogIn(board.A1)
12+
13+
i2c = board.I2C()
14+
switch = adafruit_adg72x.ADG72x(i2c, 0x44)
15+
16+
c = 0
17+
switch_time = 3
18+
clock = time.monotonic()
19+
20+
while True:
21+
if (time.monotonic() - clock) > switch_time:
22+
if c < 4:
23+
channels = "A"
24+
else:
25+
channels = "B"
26+
print(f"Selecting channel {(c % 4) + 1}{channels}")
27+
switch.channel = c
28+
c = (c + 1) % 8
29+
clock = time.monotonic()
30+
print((analog_in_DA.value, analog_in_DB.value,))
31+
time.sleep(0.1)

Adafruit_ESP32_Arduino_Demos/ESP32_sleeptest/ESP32_sleeptest.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ void disableInternalPower() {
9393
#endif
9494

9595
#if defined(ARDUINO_ADAFRUIT_FEATHER_ESP32S2)
96-
// turn on the I2C power by setting pin to rest state (off)
96+
// turn off the I2C power by setting pin to rest state (off)
9797
pinMode(PIN_I2C_POWER, INPUT);
9898
pinMode(NEOPIXEL_POWER, OUTPUT);
9999
digitalWrite(NEOPIXEL_POWER, LOW);

Adafruit_IO_Power_Relay/code.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#
33
# SPDX-License-Identifier: MIT
44

5+
import os
56
import time
67
import board
78
import busio
@@ -15,12 +16,10 @@
1516

1617
### WiFi ###
1718

18-
# Get wifi details and more from a secrets.py file
19-
try:
20-
from secrets import secrets
21-
except ImportError:
22-
print("WiFi secrets are kept in secrets.py, please add them there!")
23-
raise
19+
secrets = {
20+
"ssid" : os.getenv("CIRCUITPY_WIFI_SSID"),
21+
"password" : os.getenv("CIRCUITPY_WIFI_PASSWORD"),
22+
}
2423

2524
# If you are using a board with pre-defined ESP32 Pins:
2625
esp32_cs = DigitalInOut(board.ESP_CS)
@@ -55,7 +54,7 @@
5554

5655
### Feeds ###
5756
# Set up a feed named Relay for subscribing to the relay feed on Adafruit IO
58-
feed_relay = secrets["aio_username"] + "/feeds/relay"
57+
feed_relay = os.getenv("AIO_USERNAME") + "/feeds/relay"
5958

6059
### Code ###
6160

@@ -107,8 +106,8 @@ def on_relay_msg(client, topic, value):
107106
# Set up a MiniMQTT Client
108107
client = MQTT.MQTT(
109108
broker="io.adafruit.com",
110-
username=secrets["aio_username"],
111-
password=secrets["aio_key"],
109+
username=os.getenv("AIO_USERNAME"),
110+
password=os.getenv("AIO_KEY"),
112111
socket_pool=pool,
113112
ssl_context=ssl_context,
114113
)

Arduino_Nano_RP2040_Connect/arduino_nano_rp2040_connect_wifi/code.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
print("MAC addr:", [hex(i) for i in esp.MAC_address])
4747

4848
for ap in esp.scan_networks():
49-
print("\t%s\t\tRSSI: %d" % (str(ap['ssid'], 'utf-8'), ap['rssi']))
49+
print("\t%s\t\tRSSI: %d" % (str(ap.ssid, 'utf-8'), ap.rssi))
5050

5151
print("Connecting to AP...")
5252
while not esp.is_connected:
@@ -55,7 +55,7 @@
5555
except RuntimeError as e:
5656
print("could not connect to AP, retrying: ", e)
5757
continue
58-
print("Connected to", str(esp.ssid, "utf-8"), "\tRSSI:", esp.rssi)
58+
print("Connected to", str(esp.ap_info.ssid, "utf-8"), "\tRSSI:", esp.ap_info.rssi)
5959
print("My IP address is", esp.pretty_ip(esp.ip_address))
6060

6161
print(

0 commit comments

Comments
 (0)