Skip to content

Commit 1472d63

Browse files
Added gifs and sketch
1 parent 8f2fc85 commit 1472d63

File tree

4 files changed

+90
-1
lines changed

4 files changed

+90
-1
lines changed

content/hardware/10.mega/shields/giga-display-shield/tutorials/06.image-orientation/content.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ void loop() {
162162
}
163163
```
164164

165+
![Orientation sketch running on the GIGA Display Shield](assets/image-orientation.gif)
166+
165167
### Using Another Image
166168

167169
Any image could be used in the sketch. This tutorial and the example uses an image of the Arduino logo. Alternatively, any raw RGB565 image can be used. If you have an image you want to use, you can use this [online image converter](https://lvgl.io/tools/imageconverter), or any other software that lets you convert an image to a raw RGB565 image. This website will output in the Binary RGB565 format. For further instructions on how to display your own image, have a look at our [Text and Image tutorial](text-and-image).

content/hardware/10.mega/shields/giga-display-shield/tutorials/07.microphone-tutorial/content.md

Lines changed: 88 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,94 @@ void onPDMdata() {
9292
This sketch uses the [Arduino_Graphics library](https://www.arduino.cc/reference/en/libraries/arduinographics/) to change the color of the background when a loud noise is detected, such as a clap.
9393

9494
```arduino
95+
#include "Arduino_H7_Video.h"
96+
#include "ArduinoGraphics.h"
97+
#include <PDM.h>
98+
99+
Arduino_H7_Video Display(800, 480, GigaDisplayShield);
100+
101+
// default number of output channels
102+
static const char channels = 1;
103+
104+
// default PCM output frequency
105+
static const int frequency = 16000;
106+
107+
// Buffer to read samples into, each sample is 16-bits
108+
short sampleBuffer[512];
109+
110+
// Number of audio samples read
111+
volatile int samplesRead;
112+
113+
void setup() {
114+
Display.begin();
115+
Display.beginDraw();
116+
Display.background(255, 255, 255);
117+
Display.clear();
118+
119+
PDM.onReceive(onPDMdata);
120+
121+
if (!PDM.begin(channels, frequency)) {
122+
Serial.println("Failed to start PDM!");
123+
while (1);
124+
}
125+
Display.endDraw();
126+
}
127+
128+
int count = 1;
95129
130+
void loop(){
131+
int micValue;
132+
133+
if (samplesRead) {
134+
// Print samples to the serial monitor or plotter
135+
for (int i = 0; i < samplesRead; i++) {
136+
micValue = sampleBuffer[i];
137+
if(micValue > 10000){
138+
clap_switch();
139+
}
140+
}
141+
// Clear the read count
142+
samplesRead = 0;
143+
}
144+
}
145+
146+
void clap_switch(){
147+
Display.beginDraw();
148+
switch(count){
149+
case 1:
150+
Display.clear();
151+
Display.background(0, 0, 204);
152+
break;
153+
154+
case 2:
155+
Display.clear();
156+
Display.background(255, 128, 0);
157+
break;
158+
159+
case 3:
160+
Display.clear();
161+
Display.background(255, 255, 0);
162+
break;
163+
}
164+
if(count == 3)
165+
{
166+
count = 0;
167+
}
168+
count++;
169+
Display.endDraw();
170+
delay(1000);
171+
}
172+
173+
void onPDMdata() {
174+
// Query the number of available bytes
175+
int bytesAvailable = PDM.available();
176+
177+
// Read into the sample buffer
178+
PDM.read(sampleBuffer, bytesAvailable);
179+
180+
// 16-bit, 2 bytes per sample
181+
samplesRead = bytesAvailable / 2;
182+
}
96183
```
97184

98185
### Volume Indication Sketch
@@ -193,7 +280,7 @@ void onPDMdata() {
193280
```
194281

195282

196-
[GIF of sketch running]()
283+
[GIF of sketch running](assets/P1066383.gif)
197284

198285
## Conclusion
199286

0 commit comments

Comments
 (0)