forked from adafruit/Adafruit_Learning_System_Guides
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:adafruit/Adafruit_Learning_System_G…
…uides
- Loading branch information
Showing
446 changed files
with
102,744 additions
and
685 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
65 changes: 65 additions & 0 deletions
65
ADG72x_Examples/Arduino_ADG728_Plotter/Arduino_ADG728_Plotter.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
66
ADG72x_Examples/Arduino_ADG729_Plotter/Arduino_ADG729_Plotter.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.