-
Notifications
You must be signed in to change notification settings - Fork 789
Added FunHouse Arduino Demos #1512
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3ad72e4
Added FunHouse Arduino Demos
makermelissa c402a3f
Add missing dependencies
makermelissa e3c8266
Add a test.only file to FunHouse demos
makermelissa 47f9c74
Remove tester
makermelissa d196342
Remove analogread
makermelissa 18ac0ae
Merge branch 'master' of https://github.com/adafruit/Adafruit_Learnin…
makermelissa e753d36
Add MagTag and FunHouse boards to testing matrix so they actually get…
makermelissa b21e22e
Fix failing tests
makermelissa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Empty file.
This file contains hidden or 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,12 @@ | ||
void setup() { | ||
Serial.begin(115200); | ||
} | ||
void loop() { | ||
// put your main code here, to run repeatedly: | ||
uint32_t vol; | ||
vol = ((analogRead(17) * 30 ) / 8191); | ||
Serial.printf("17 : %d\n", vol); | ||
vol = ((analogRead(1) * 30 ) / 8191); | ||
Serial.printf("1 : %d\n", vol); | ||
delay(1000); | ||
} |
Empty file.
This file contains hidden or 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,51 @@ | ||
#include <Adafruit_DotStar.h> | ||
|
||
// LEDs! | ||
Adafruit_DotStar pixels(NUM_DOTSTAR, PIN_DOTSTAR_DATA, PIN_DOTSTAR_CLOCK, DOTSTAR_BRG); | ||
|
||
uint16_t firstPixelHue = 0; | ||
uint8_t LED_dutycycle = 0; | ||
|
||
void setup() { | ||
Serial.begin(115200); | ||
|
||
pinMode(LED_BUILTIN, OUTPUT); | ||
|
||
ledcSetup(0, 5000, 8); | ||
ledcAttachPin(LED_BUILTIN, 0); | ||
|
||
pixels.begin(); // Initialize pins for output | ||
pixels.show(); // Turn all LEDs off ASAP | ||
pixels.setBrightness(20); | ||
} | ||
|
||
|
||
|
||
void loop() { | ||
Serial.println("Hello!"); | ||
|
||
// pulse red LED | ||
ledcWrite(0, LED_dutycycle++); | ||
|
||
// rainbow dotstars | ||
for (int i=0; i<pixels.numPixels(); i++) { // For each pixel in strip... | ||
int pixelHue = firstPixelHue + (i * 65536L / pixels.numPixels()); | ||
pixels.setPixelColor(i, pixels.gamma32(pixels.ColorHSV(pixelHue))); | ||
} | ||
pixels.show(); // Update strip with new contents | ||
firstPixelHue += 256; | ||
|
||
delay(15); | ||
} | ||
|
||
|
||
void rainbow(int wait) { | ||
for(long firstPixelHue = 0; firstPixelHue < 5*65536; firstPixelHue += 256) { | ||
for(int i=0; i<pixels.numPixels(); i++) { // For each pixel in strip... | ||
int pixelHue = firstPixelHue + (i * 65536L / pixels.numPixels()); | ||
pixels.setPixelColor(i, pixels.gamma32(pixels.ColorHSV(pixelHue))); | ||
} | ||
pixels.show(); // Update strip with new contents | ||
delay(wait); // Pause for a moment | ||
} | ||
} |
Empty file.
This file contains hidden or 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,272 @@ | ||
#include <Adafruit_DotStar.h> | ||
#include <Adafruit_GFX.h> // Core graphics library | ||
#include <Adafruit_ST7789.h> // Hardware-specific library for ST7789 | ||
#include <Adafruit_DPS310.h> | ||
#include <Adafruit_AHTX0.h> | ||
|
||
#define BG_COLOR ST77XX_BLACK | ||
|
||
// display! | ||
Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RESET); | ||
// LEDs! | ||
Adafruit_DotStar pixels(NUM_DOTSTAR, PIN_DOTSTAR_DATA, PIN_DOTSTAR_CLOCK, DOTSTAR_BRG); | ||
// sensors! | ||
Adafruit_DPS310 dps; | ||
Adafruit_AHTX0 aht; | ||
|
||
uint8_t LED_dutycycle = 0; | ||
uint16_t firstPixelHue = 0; | ||
|
||
void setup() { | ||
Serial.begin(115200); | ||
delay(100); | ||
|
||
pixels.begin(); // Initialize pins for output | ||
pixels.show(); // Turn all LEDs off ASAP | ||
pixels.setBrightness(20); | ||
|
||
pinMode(BUTTON_DOWN, INPUT_PULLDOWN); | ||
pinMode(BUTTON_SELECT, INPUT_PULLDOWN); | ||
pinMode(BUTTON_UP, INPUT_PULLDOWN); | ||
|
||
//analogReadResolution(13); | ||
|
||
tft.init(240, 240); // Initialize ST7789 screen | ||
pinMode(TFT_BACKLIGHT, OUTPUT); | ||
digitalWrite(TFT_BACKLIGHT, HIGH); // Backlight on | ||
|
||
tft.fillScreen(BG_COLOR); | ||
tft.setTextSize(2); | ||
tft.setTextColor(ST77XX_YELLOW); | ||
tft.setTextWrap(false); | ||
|
||
// check DPS! | ||
tft.setCursor(0, 0); | ||
tft.setTextColor(ST77XX_YELLOW); | ||
tft.print("DP310? "); | ||
|
||
|
||
if (! dps.begin_I2C()) { | ||
tft.setTextColor(ST77XX_RED); | ||
tft.println("FAIL!"); | ||
while (1) delay(100); | ||
} | ||
tft.setTextColor(ST77XX_GREEN); | ||
tft.println("OK!"); | ||
dps.configurePressure(DPS310_64HZ, DPS310_64SAMPLES); | ||
dps.configureTemperature(DPS310_64HZ, DPS310_64SAMPLES); | ||
|
||
// check AHT! | ||
tft.setCursor(0, 20); | ||
tft.setTextColor(ST77XX_YELLOW); | ||
tft.print("AHT20? "); | ||
|
||
if (! aht.begin()) { | ||
tft.setTextColor(ST77XX_RED); | ||
tft.println("FAIL!"); | ||
while (1) delay(100); | ||
} | ||
tft.setTextColor(ST77XX_GREEN); | ||
tft.println("OK!"); | ||
|
||
pinMode(LED_BUILTIN, OUTPUT); | ||
pinMode(SPEAKER, OUTPUT); | ||
|
||
ledcSetup(0, 2000 * 80, 8); | ||
ledcAttachPin(LED_BUILTIN, 0); | ||
|
||
ledcSetup(1, 2000 * 80, 8); | ||
ledcAttachPin(SPEAKER, 1); | ||
ledcWrite(1, 0); | ||
} | ||
|
||
|
||
|
||
void loop() { | ||
|
||
|
||
/********************* sensors */ | ||
sensors_event_t humidity, temp, pressure; | ||
|
||
tft.setCursor(0, 0); | ||
tft.setTextColor(ST77XX_YELLOW, BG_COLOR); | ||
dps.getEvents(&temp, &pressure); | ||
|
||
tft.print("DP310: "); | ||
tft.print(temp.temperature, 0); | ||
tft.print(" C "); | ||
tft.print(pressure.pressure, 0); | ||
tft.print(" hPa"); | ||
tft.println(" "); | ||
Serial.printf("DPS310: %0.1f *C %0.2f hPa\n", temp.temperature, pressure.pressure); | ||
|
||
|
||
tft.setCursor(0, 20); | ||
tft.setTextColor(ST77XX_YELLOW, BG_COLOR); | ||
aht.getEvent(&humidity, &temp); | ||
|
||
tft.print("AHT20: "); | ||
tft.print(temp.temperature, 0); | ||
tft.print(" C "); | ||
tft.print(humidity.relative_humidity, 0); | ||
tft.print(" %"); | ||
tft.println(" "); | ||
Serial.printf("AHT20: %0.1f *C %0.2f rH\n", temp.temperature, humidity.relative_humidity); | ||
|
||
|
||
/****************** BUTTONS */ | ||
tft.setCursor(0, 40); | ||
tft.setTextColor(ST77XX_YELLOW); | ||
tft.print("Buttons: "); | ||
if (! digitalRead(BUTTON_DOWN)) { | ||
tft.setTextColor(0x808080); | ||
} else { | ||
Serial.println("DOWN pressed"); | ||
tft.setTextColor(ST77XX_WHITE); | ||
} | ||
tft.print("DOWN "); | ||
|
||
if (! digitalRead(BUTTON_SELECT)) { | ||
tft.setTextColor(0x808080); | ||
} else { | ||
Serial.println("SELECT pressed"); | ||
tft.setTextColor(ST77XX_WHITE); | ||
} | ||
tft.print("SEL "); | ||
|
||
if (! digitalRead(BUTTON_UP)) { | ||
tft.setTextColor(0x808080); | ||
} else { | ||
Serial.println("UP pressed"); | ||
tft.setTextColor(ST77XX_WHITE); | ||
} | ||
tft.println("UP"); | ||
|
||
/************************** CAPACITIVE */ | ||
uint16_t touchread; | ||
|
||
tft.setCursor(0, 60); | ||
tft.setTextColor(ST77XX_YELLOW, BG_COLOR); | ||
tft.print("Captouch 6: "); | ||
touchread = touchRead(6); | ||
if (touchread < 10000 ) { | ||
tft.setTextColor(0x808080, BG_COLOR); | ||
} else { | ||
tft.setTextColor(ST77XX_WHITE, BG_COLOR); | ||
} | ||
tft.print(touchread); | ||
tft.println(" "); | ||
Serial.printf("Captouch #6 reading: %d\n", touchread); | ||
|
||
tft.setCursor(0, 80); | ||
tft.setTextColor(ST77XX_YELLOW, BG_COLOR); | ||
tft.print("Captouch 7: "); | ||
touchread = touchRead(7); | ||
if (touchread < 20000 ) { | ||
tft.setTextColor(0x808080, BG_COLOR); | ||
} else { | ||
tft.setTextColor(ST77XX_WHITE, BG_COLOR); | ||
} | ||
tft.print(touchread); | ||
tft.println(" "); | ||
Serial.printf("Captouch #7 reading: %d\n", touchread); | ||
|
||
|
||
tft.setCursor(0, 100); | ||
tft.setTextColor(ST77XX_YELLOW, BG_COLOR); | ||
tft.print("Captouch 8: "); | ||
touchread = touchRead(8); | ||
if (touchread < 20000 ) { | ||
tft.setTextColor(0x808080, BG_COLOR); | ||
} else { | ||
tft.setTextColor(ST77XX_WHITE, BG_COLOR); | ||
} | ||
tft.print(touchread); | ||
tft.println(" "); | ||
Serial.printf("Captouch #8 reading: %d\n", touchread); | ||
|
||
|
||
/************************** ANALOG READ */ | ||
uint16_t analogread; | ||
|
||
tft.setCursor(0, 120); | ||
tft.setTextColor(ST77XX_YELLOW, BG_COLOR); | ||
tft.print("Analog 0: "); | ||
analogread = analogRead(A0); | ||
if (analogread < 8000 ) { | ||
tft.setTextColor(ST77XX_WHITE, BG_COLOR); | ||
} else { | ||
tft.setTextColor(ST77XX_RED, BG_COLOR); | ||
} | ||
tft.print(analogread); | ||
tft.println(" "); | ||
Serial.printf("Analog A0 reading: %d\n", analogread); | ||
|
||
|
||
tft.setCursor(0, 140); | ||
tft.setTextColor(ST77XX_YELLOW, BG_COLOR); | ||
tft.print("Analog 1: "); | ||
analogread = analogRead(A1); | ||
if (analogread < 8000 ) { | ||
tft.setTextColor(ST77XX_WHITE, BG_COLOR); | ||
} else { | ||
tft.setTextColor(ST77XX_RED, BG_COLOR); | ||
} | ||
tft.print(analogread); | ||
tft.println(" "); | ||
Serial.printf("Analog A1 reading: %d\n", analogread); | ||
|
||
|
||
tft.setCursor(0, 160); | ||
tft.setTextColor(ST77XX_YELLOW, BG_COLOR); | ||
tft.print("Analog 2: "); | ||
analogread = analogRead(A2); | ||
if (analogread < 8000 ) { | ||
tft.setTextColor(ST77XX_WHITE, BG_COLOR); | ||
} else { | ||
tft.setTextColor(ST77XX_RED, BG_COLOR); | ||
} | ||
tft.print(analogread); | ||
tft.println(" "); | ||
Serial.printf("Analog A2 reading: %d\n", analogread); | ||
|
||
tft.setCursor(0, 180); | ||
tft.setTextColor(ST77XX_YELLOW, BG_COLOR); | ||
tft.print("Light: "); | ||
analogread = analogRead(A3); | ||
tft.setTextColor(ST77XX_WHITE, BG_COLOR); | ||
tft.print(analogread); | ||
tft.println(" "); | ||
Serial.printf("Light sensor reading: %d\n", analogread); | ||
|
||
/************************** Beep! */ | ||
if (digitalRead(BUTTON_SELECT)) { | ||
Serial.println("** Beep! ***"); | ||
tone(SPEAKER, 988, 100); // tone1 - B5 | ||
tone(SPEAKER, 1319, 200); // tone2 - E6 | ||
delay(100); | ||
//tone(SPEAKER, 2000, 100); | ||
} | ||
|
||
/************************** LEDs */ | ||
// pulse red LED | ||
ledcWrite(0, LED_dutycycle); | ||
LED_dutycycle += 32; | ||
|
||
// rainbow dotstars | ||
for (int i=0; i<pixels.numPixels(); i++) { // For each pixel in strip... | ||
int pixelHue = firstPixelHue + (i * 65536L / pixels.numPixels()); | ||
pixels.setPixelColor(i, pixels.gamma32(pixels.ColorHSV(pixelHue))); | ||
} | ||
pixels.show(); // Update strip with new contents | ||
firstPixelHue += 256; | ||
} | ||
|
||
|
||
void tone(uint8_t pin, float frequecy, float duration) { | ||
ledcSetup(1, frequecy * 80, 8); | ||
ledcAttachPin(pin, 1); | ||
ledcWrite(1, 128); | ||
delay(duration); | ||
ledcWrite(1, 0); | ||
} |
Empty file.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is 'vol'?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure. I think volume? Maybe I should remove this one since it doesn't seem quite as useful as the others.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok remove