Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
arduino-block-course
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Stefan Gehr
arduino-block-course
Commits
97bee4ff
Commit
97bee4ff
authored
2 years ago
by
Stefan Gehr
Browse files
Options
Downloads
Patches
Plain Diff
using queue for error sound; setting LONG_TIME_ERROR time to 10 seconds for testing and showing
parent
4595e086
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
solarpump/mp3.h
+1
-0
1 addition, 0 deletions
solarpump/mp3.h
solarpump/mp3.ino
+13
-4
13 additions, 4 deletions
solarpump/mp3.ino
solarpump/solarpump.ino
+4
-1
4 additions, 1 deletion
solarpump/solarpump.ino
solarpump/temperature.ino
+1
-1
1 addition, 1 deletion
solarpump/temperature.ino
with
19 additions
and
6 deletions
solarpump/mp3.h
+
1
−
0
View file @
97bee4ff
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
#define MP3_H
#define MP3_H
void
mp3Setup
(
void
);
void
mp3Setup
(
void
);
uint8_t
queueLength
(
void
);
void
playFile
(
uint8_t
fileNumber
,
bool
respectBusyPin
);
void
playFile
(
uint8_t
fileNumber
,
bool
respectBusyPin
);
void
mp3Loop
(
void
);
void
mp3Loop
(
void
);
void
playFileQueue
(
uint8_t
fileNumber
);
void
playFileQueue
(
uint8_t
fileNumber
);
...
...
This diff is collapsed.
Click to expand it.
solarpump/mp3.ino
+
13
−
4
View file @
97bee4ff
...
@@ -7,6 +7,10 @@ static SoftwareSerial mp3(MP3RX, MP3TX);
...
@@ -7,6 +7,10 @@ static SoftwareSerial mp3(MP3RX, MP3TX);
// the queue for playing sounds
// the queue for playing sounds
#define QUEUESIZE 64
#define QUEUESIZE 64
static
uint8_t
fileQueue
[
QUEUESIZE
];
static
uint8_t
fileQueue
[
QUEUESIZE
];
// next playing position in the queue
static
uint8_t
currentPlayPos
=
0
;
// position of end of queue
static
uint8_t
currentQueueEnd
=
0
;
// needs to be run once at the start
// needs to be run once at the start
void
mp3Setup
(
void
)
{
void
mp3Setup
(
void
)
{
...
@@ -15,6 +19,15 @@ void mp3Setup(void) {
...
@@ -15,6 +19,15 @@ void mp3Setup(void) {
//mp3.sendCommand(CMD_SEL_DEV, 0, 2); //select sd-card
//mp3.sendCommand(CMD_SEL_DEV, 0, 2); //select sd-card
}
}
// return the number of files waiting in the queue
uint8_t
queueLength
(
void
)
{
// in case of wrapround in the queue
if
(
currentQueueEnd
<
currentPlayPos
)
{
return
currentQueueEnd
+
QUEUESIZE
-
currentPlayPos
;
}
return
currentPlayPos
-
currentQueueEnd
;
}
// immediately play a file
// immediately play a file
void
playFile
(
uint8_t
fileNumber
,
bool
respectBusyPin
)
{
void
playFile
(
uint8_t
fileNumber
,
bool
respectBusyPin
)
{
// do nothing if we want to wait for the BUSY pin
// do nothing if we want to wait for the BUSY pin
...
@@ -34,8 +47,6 @@ void mp3Loop(void) {
...
@@ -34,8 +47,6 @@ void mp3Loop(void) {
* now we can wait for the flank from LOW to HIGH => then the playing is done
* now we can wait for the flank from LOW to HIGH => then the playing is done
*/
*/
static
bool
waitForBusy
=
false
;
static
bool
waitForBusy
=
false
;
// next playing position in the queue
static
uint8_t
currentPlayPos
=
0
;
// check if we are busy
// check if we are busy
if
(
digitalRead
(
MP3BUSY
)
==
LOW
)
{
if
(
digitalRead
(
MP3BUSY
)
==
LOW
)
{
...
@@ -72,8 +83,6 @@ void mp3Loop(void) {
...
@@ -72,8 +83,6 @@ void mp3Loop(void) {
// add a file to the queue and start playing the queue
// add a file to the queue and start playing the queue
void
playFileQueue
(
uint8_t
fileNumber
)
{
void
playFileQueue
(
uint8_t
fileNumber
)
{
// position of end of queue
static
uint8_t
currentQueueEnd
=
0
;
// save file to queue
// save file to queue
fileQueue
[
currentQueueEnd
]
=
fileNumber
;
fileQueue
[
currentQueueEnd
]
=
fileNumber
;
...
...
This diff is collapsed.
Click to expand it.
solarpump/solarpump.ino
+
4
−
1
View file @
97bee4ff
...
@@ -246,7 +246,10 @@ void loop(void) {
...
@@ -246,7 +246,10 @@ void loop(void) {
if
(
t1upState
==
LONG_TIME_ERROR
||
t1downState
==
LONG_TIME_ERROR
||
t2upState
==
LONG_TIME_ERROR
||
t2downState
==
LONG_TIME_ERROR
)
{
if
(
t1upState
==
LONG_TIME_ERROR
||
t1downState
==
LONG_TIME_ERROR
||
t2upState
==
LONG_TIME_ERROR
||
t2downState
==
LONG_TIME_ERROR
)
{
// continuously say that there is an error
// continuously say that there is an error
playFile
(
SOUND_FEHLER
,
true
);
if
(
queueLength
()
==
0
)
{
playFileQueue
(
SOUND_FEHLER
);
playFileQueue
(
SOUND_STILLE
);
}
}
}
// control pump of system 1
// control pump of system 1
...
...
This diff is collapsed.
Click to expand it.
solarpump/temperature.ino
+
1
−
1
View file @
97bee4ff
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
/* No new valid temperature for < 60 seconds? I sleep.
/* No new valid temperature for < 60 seconds? I sleep.
* No new valid temperature for > 60 seconds? REAL PROBLEM! */
* No new valid temperature for > 60 seconds? REAL PROBLEM! */
const
uint32_t
ERRORTIME
=
6
0000
;
const
uint32_t
ERRORTIME
=
1
0000
;
// Update the temperature only every second
// Update the temperature only every second
const
uint32_t
TEMPUPDATETIME
=
1000
;
const
uint32_t
TEMPUPDATETIME
=
1000
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment