Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
ESP32-audioI2S
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
ESP32-audioI2S
Commits
79aa6269
Unverified
Commit
79aa6269
authored
Dec 13, 2021
by
Wolle
Committed by
GitHub
Dec 13, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add files via upload
parent
7fee4ea7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
68 additions
and
0 deletions
+68
-0
examples/Talking_Clock/TalkingClock.ino
examples/Talking_Clock/TalkingClock.ino
+68
-0
No files found.
examples/Talking_Clock/TalkingClock.ino
0 → 100644
View file @
79aa6269
#include "Arduino.h"
#include "Audio.h"
#include "SD.h"
#include "SPI.h"
#include "FS.h"
#include "Ticker.h"
// Digital I/O used
#define SD_CS 5
#define SPI_MOSI 23
#define SPI_MISO 19
#define SPI_SCK 18
#define I2S_DOUT 25
#define I2S_BCLK 27
#define I2S_LRC 26
Audio
audio
;
Ticker
ticker
;
struct
tm
timeinfo
;
time_t
now
;
uint8_t
hour
=
6
;
uint8_t
minute
=
59
;
uint8_t
sec
=
45
;
bool
f_time
=
false
;
int8_t
timefile
=
-
1
;
char
chbuf
[
100
];
void
tckr1s
(){
sec
++
;
if
(
sec
>
59
)
{
sec
=
0
;
minute
++
;}
if
(
minute
>
59
){
minute
=
0
;
hour
++
;}
if
(
hour
>
24
)
{
hour
=
0
;}
if
(
minute
==
59
&&
sec
==
50
)
f_time
=
true
;
// flag will be set 10s before full hour
Serial
.
printf
(
"%02d:%02d:%02d
\n
"
,
hour
,
minute
,
sec
);
}
void
setup
()
{
Serial
.
begin
(
115200
);
SPI
.
begin
(
SPI_SCK
,
SPI_MISO
,
SPI_MOSI
);
SD
.
begin
(
SD_CS
);
audio
.
setPinout
(
I2S_BCLK
,
I2S_LRC
,
I2S_DOUT
);
audio
.
setVolume
(
10
);
// 0...21
ticker
.
attach
(
1
,
tckr1s
);
}
void
loop
(){
audio
.
loop
();
if
(
f_time
==
true
){
f_time
=
false
;
timefile
=
3
;
uint8_t
next_hour
=
hour
+
1
;
if
(
next_hour
==
25
)
next_hour
=
1
;
sprintf
(
chbuf
,
"/voice_time/%03d.mp3"
,
next_hour
);
audio
.
connecttoFS
(
SD
,
chbuf
);
}
}
void
audio_eof_mp3
(
const
char
*
info
){
//end of file
//Serial.printf("file :%s\n", info);
if
(
timefile
>
0
){
if
(
timefile
==
1
){
audio
.
connecttoFS
(
SD
,
"/voice_time/080.mp3"
);
timefile
--
;}
// stroke
if
(
timefile
==
2
){
audio
.
connecttoFS
(
SD
,
"/voice_time/200.mp3"
);
timefile
--
;}
// precisely
if
(
timefile
==
3
){
audio
.
connecttoFS
(
SD
,
"/voice_time/O'clock.mp3"
);
timefile
--
;}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment