Skip to content

Commit

Permalink
Merge branch 'main' of github.com:adafruit/Adafruit_Learning_System_G…
Browse files Browse the repository at this point in the history
…uides
  • Loading branch information
ladyada committed Sep 23, 2024
2 parents 71abe83 + 24406bf commit 91839ea
Show file tree
Hide file tree
Showing 446 changed files with 102,744 additions and 685 deletions.
19 changes: 12 additions & 7 deletions .github/workflows/arduino_cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
outputs:
answer: ${{ steps.is-needed.outputs.answer }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Check if run by adabot
Expand All @@ -39,7 +39,8 @@ jobs:
[[ $changedfile == *.cpp ]] ||
[[ $changedfile == *.h ]] ||
[[ $changedfile == *.hpp ]] ||
[[ $changedfile == *.ino ]]; then
[[ $changedfile == *.ino ]] ||
[[ $changedfile == *.yml ]]; then
ischanged=true
break
fi
Expand All @@ -60,16 +61,20 @@ jobs:
strategy:
fail-fast: false
matrix:
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" ]
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"]
runs-on: ubuntu-latest
if: needs.check-if-needed.outputs.answer == 'true'
needs: check-if-needed
steps:
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: "3.x"
- uses: actions/checkout@v3
- uses: actions/checkout@v3

# Checkout the learn repo itself
- uses: actions/checkout@v4

# Checkout the CI scripts
- uses: actions/checkout@v4
with:
repository: adafruit/ci-arduino
path: ci
Expand Down Expand Up @@ -98,7 +103,7 @@ jobs:


- name: Upload build artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ github.event.repository.name }}.${{ github.sha }}
path: |
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/githubci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ jobs:
spdx:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Checkout Current Repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: check SPDX licensing
run: python ./SPDX.py
Expand All @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Set up Python 3.10
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Versions
Expand All @@ -29,7 +29,7 @@ jobs:
run: |
pip install --force-reinstall pylint==2.7.1
- name: Checkout Current Repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: lint
run: ./pylint_check.sh
4 changes: 2 additions & 2 deletions .github/workflows/images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ jobs:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"

- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Python 3.x
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.x"

Expand Down
File renamed without changes.
File renamed without changes.
65 changes: 65 additions & 0 deletions ADG72x_Examples/Arduino_ADG728_Plotter/Arduino_ADG728_Plotter.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// SPDX-FileCopyrightText: 2024 Liz Clark for Adafruit Industries
//
// SPDX-License-Identifier: MIT

#include <Adafruit_ADG72x.h>

Adafruit_ADG72x adg72x;

bool isADG728 = false; // which chip are we connected to?

int analogIn = A0;
int analogValue = 0;
unsigned long switchTimer = 1000; // 1000 ms = 1 second for channel switch
unsigned long readTimer = 10; // 10 ms for analog read
unsigned long lastSwitchTime = 0; // Last time the channels were switched
unsigned long lastReadTime = 0; // Last time the analog was read
uint8_t currentChannel = 0; // Current channel being selected

void setup() {
Serial.begin(115200);

// Wait for serial port to open
while (!Serial) {
delay(1);
}

// Try with the ADG728 default address first...
if (adg72x.begin(ADG728_DEFAULT_ADDR, &Wire)) {
Serial.println("ADG728 found!");
isADG728 = true;
}
// Maybe they have an ADG729?
else if (adg72x.begin(ADG729_DEFAULT_ADDR, &Wire)) {
Serial.println("ADG729 found!");
isADG728 = false;
}
else {
Serial.println("No ADG device found? Check wiring!");
while (1); // Stop here if no device was found
}
}

void loop() {
unsigned long currentTime = millis();

// read and print analog value every 10ms
if ((currentTime - lastReadTime) >= readTimer) {
analogValue = analogRead(analogIn);
Serial.println(analogValue);
lastReadTime = currentTime;
}

// switch channels every 1 second
if ((currentTime - lastSwitchTime) >= switchTimer) {
uint8_t bits = 1 << currentChannel; // Shift a '1' from LSB to MSB
if (!adg72x.selectChannels(bits)) {
Serial.println("Failed to set channels...");
}
/*Serial.print((currentChannel % 4) + 1);
if (currentChannel < 4) Serial.println("A");
else Serial.println("B");*/
currentChannel = (currentChannel + 1) % 8; // Move to the next channel, wrap around at 8
lastSwitchTime = currentTime;
}
}
File renamed without changes.
66 changes: 66 additions & 0 deletions ADG72x_Examples/Arduino_ADG729_Plotter/Arduino_ADG729_Plotter.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// SPDX-FileCopyrightText: 2024 Liz Clark for Adafruit Industries
//
// SPDX-License-Identifier: MIT

#include <Adafruit_ADG72x.h>

Adafruit_ADG72x adg72x;

int analogInA0 = A0;
int analogInA1 = A1;
int analogValueDA = 0;
int analogValueDB = 0;
unsigned long switchTimer = 1000; // 1000 ms = 1 second for channel switch
unsigned long readTimer = 10; // 10 ms for analog read
unsigned long lastSwitchTime = 0; // Last time the channels were switched
unsigned long lastReadTime = 0; // Last time the analog was read
uint8_t currentChannel = 0; // Current channel being selected

void setup() {
Serial.begin(115200);

// Wait for serial port to open
while (!Serial) {
delay(1);
}

// Try with the ADG728 default address first...
if (adg72x.begin(ADG728_DEFAULT_ADDR, &Wire)) {
//Serial.println("ADG728 found!");
}
// Maybe they have an ADG729?
else if (adg72x.begin(ADG729_DEFAULT_ADDR, &Wire)) {
//Serial.println("ADG729 found!");
}
else {
Serial.println("No ADG72x device found? Check wiring!");
while (1); // Stop here if no device was found
}
}

void loop() {
unsigned long currentTime = millis();

// read and print analog value every 10ms
if ((currentTime - lastReadTime) >= readTimer) {
analogValueDA = analogRead(analogInA0);
analogValueDB = analogRead(analogInA1);
Serial.print(analogValueDA);
Serial.print(",");
Serial.println(analogValueDB);
lastReadTime = currentTime;
}

// switch channels every 1 second
if ((currentTime - lastSwitchTime) >= switchTimer) {
uint8_t bits = 1 << currentChannel; // Shift a '1' from LSB to MSB
if (!adg72x.selectChannels(bits)) {
Serial.println("Failed to set channels...");
}
/*Serial.print((currentChannel % 4) + 1);
if (currentChannel < 4) Serial.println("A");
else Serial.println("B");*/
currentChannel = (currentChannel + 1) % 8; // Move to the next channel, wrap around at 8
lastSwitchTime = currentTime;
}
}
26 changes: 26 additions & 0 deletions ADG72x_Examples/CircuitPython_ADG728/code.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# SPDX-FileCopyrightText: Copyright (c) 2024 Liz Clark for Adafruit Industries
#
# SPDX-License-Identifier: MIT

import time
import board
import adafruit_adg72x
from analogio import AnalogIn

analog_in = AnalogIn(board.A0)

i2c = board.I2C()
switch = adafruit_adg72x.ADG72x(i2c)

c = 0
switch_time = 2
channels = [0, 4]
clock = time.monotonic()
while True:
if (time.monotonic() - clock) > switch_time:
print(f"Selecting channel {channels[c] + 1}")
switch.channel = channels[c]
c = (c + 1) % 2
clock = time.monotonic()
print((analog_in.value,))
time.sleep(0.1)
31 changes: 31 additions & 0 deletions ADG72x_Examples/CircuitPython_ADG729/code.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# SPDX-FileCopyrightText: Copyright (c) 2024 Liz Clark for Adafruit Industries
#
# SPDX-License-Identifier: MIT

import time
import board
import adafruit_adg72x
from analogio import AnalogIn

analog_in_DA = AnalogIn(board.A0)
analog_in_DB = AnalogIn(board.A1)

i2c = board.I2C()
switch = adafruit_adg72x.ADG72x(i2c, 0x44)

c = 0
switch_time = 3
clock = time.monotonic()

while True:
if (time.monotonic() - clock) > switch_time:
if c < 4:
channels = "A"
else:
channels = "B"
print(f"Selecting channel {(c % 4) + 1}{channels}")
switch.channel = c
c = (c + 1) % 8
clock = time.monotonic()
print((analog_in_DA.value, analog_in_DB.value,))
time.sleep(0.1)
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
//#define ADAFRUIT_FEATHER_ESP32_V2

// then these pins will be defined for us
#if defined(ADAFRUIT_FEATHER_ESP32_V2)
#if defined(ADAFRUIT_FEATHER_ESP32_V2) or defined(ARDUINO_ADAFRUIT_ITSYBITSY_ESP32)
#define PIN_NEOPIXEL 0
#define NEOPIXEL_I2C_POWER 2
#endif
Expand Down
57 changes: 57 additions & 0 deletions Adafruit_Feather_ESP32-S2_Reverse_TFT/display/code.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT

"""
This test will initialize the display using displayio and draw a solid green
background, a smaller purple rectangle, and some yellow text.
"""
import board
import terminalio
import displayio
from adafruit_display_text import label

# First set some parameters used for shapes and text
BORDER = 20
FONTSCALE = 2
BACKGROUND_COLOR = 0x00FF00 # Bright Green
FOREGROUND_COLOR = 0xAA0088 # Purple
TEXT_COLOR = 0xFFFF00

display = board.DISPLAY

# Make the display context
splash = displayio.Group()
display.root_group = splash

color_bitmap = displayio.Bitmap(display.width, display.height, 1)
color_palette = displayio.Palette(1)
color_palette[0] = BACKGROUND_COLOR

bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0)
splash.append(bg_sprite)

# Draw a smaller inner rectangle
inner_bitmap = displayio.Bitmap(
display.width - BORDER * 2, display.height - BORDER * 2, 1
)
inner_palette = displayio.Palette(1)
inner_palette[0] = FOREGROUND_COLOR
inner_sprite = displayio.TileGrid(
inner_bitmap, pixel_shader=inner_palette, x=BORDER, y=BORDER
)
splash.append(inner_sprite)

# Draw a label
text = "Hello World!"
text_area = label.Label(terminalio.FONT, text=text, color=TEXT_COLOR)
text_width = text_area.bounding_box[2] * FONTSCALE
text_group = displayio.Group(
scale=FONTSCALE,
x=display.width // 2 - text_width // 2,
y=display.height // 2,
)
text_group.append(text_area) # Subgroup for text scaling
splash.append(text_group)

while True:
pass
Loading

0 comments on commit 91839ea

Please sign in to comment.