Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
boitarire
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Flax
boitarire
Commits
3f68084b
Commit
3f68084b
authored
Feb 01, 2022
by
Flax
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added playlist function.
parent
75c57e19
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
767 additions
and
13 deletions
+767
-13
sw/boitarire_sw/boitarire_sw.ino
sw/boitarire_sw/boitarire_sw.ino
+41
-13
sw/boitarire_sw/boitarire_sw.ino.eightanaloginputs.hex
sw/boitarire_sw/boitarire_sw.ino.eightanaloginputs.hex
+346
-0
sw/boitarire_sw/boitarire_sw.ino.with_bootloader.eightanaloginputs.hex
...sw/boitarire_sw.ino.with_bootloader.eightanaloginputs.hex
+380
-0
No files found.
sw/boitarire_sw/boitarire_sw.ino
View file @
3f68084b
...
...
@@ -43,7 +43,7 @@
#define ACCEL_THRES_GYX 1000 // Detection threshold for X axis acceleration
#define ACCEL_THRES_GYY 1000 // Detection threshold for Y axis acceleration
#define ACCEL_THRES_GYZ 1000 // Detection threshold for Z axis acceleration
#define
NUMBER_SONGS 2 // Number of different songs to be played
#define
PLAYLIST_LENGTH 4 // Number of songs in the playlist
// Typedefs
// Main state machine : start actions
...
...
@@ -71,8 +71,28 @@ typedef enum
STM_DEBOUNCE_DEBOUNCE_1
,
}
tStateMachineDebounce
;
typedef
struct
{
uint8_t
song_index_u8
;
// Index of the song in the device /!\ counts from 0
uint8_t
cycles_number_u8
;
// Number of times the song must be played before switching to the next
}
tSongItem
;
// Constant variables
/* Indifference table for songs cycles
* Contains the indexes of the songs to be played and the number of times each one must be played.
* Contains couples {index of the song in the MP3 device memory, number of times the song must be played},
* Playlist cycles from first element to last and loops.
* Don't forget to update PLAYLIST_LENGTH define.
*/
const
tSongItem
cPlaylistIndif_TA
[
PLAYLIST_LENGTH
]
=
{
{
0
,
2
},
{
2
,
3
},
{
1
,
1
},
{
3
,
2
},
};
// Local variables
String
inputString
=
""
;
// a String to hold incoming data
bool
stringComplete
=
false
;
// whether the string is complete
...
...
@@ -86,6 +106,9 @@ const int MPU=0x68;
int16_t
AcX
,
AcY
,
AcZ
,
Tmp
,
GyX
,
GyY
,
GyZ
;
bool
accel_detect
;
uint8_t
song_cycles_cnt_u8
;
// Counts the number of times the current song has been played
uint8_t
song_playing_current_u8
;
// Holds the index of the playlist song actually being played
// State machines states
tStateMachine
stmState
;
tStateMachineDebounce
stmDebounceState
;
...
...
@@ -118,7 +141,7 @@ void setup() {
// MP3 module ground switch command - See hardware constants for pin definition - Output push-pull
pinMode
(
PIN_GROUND_SWITCH
,
OUTPUT
);
//In
tianlise variable
, do not define constants value here
//In
itialise variables
, do not define constants value here
play_blank_delay
=
0
;
mp3_reset_delay
=
0
;
stmState
=
STM_INIT
;
...
...
@@ -127,6 +150,8 @@ void setup() {
input_position_sensor
=
LOW
;
input_touch_sensor1
=
LOW
;
input_touch_sensor2
=
LOW
;
song_cycles_cnt_u8
=
0
;
song_playing_current_u8
=
0
;
#ifdef SENSOR_ACCELEROMETER
// Accelerometer setup
...
...
@@ -315,8 +340,20 @@ void loop() {
break
;
case
STM_PLAY
:
//WritePlay();
WritePlaySong
(
1
);
WritePlaySong
(
cPlaylistIndif_TA
[
song_playing_current_u8
].
song_index_u8
+
1U
);
// Play the current song
song_cycles_cnt_u8
++
;
// Increment cycles counter
if
(
song_cycles_cnt_u8
>=
cPlaylistIndif_TA
[
song_playing_current_u8
].
cycles_number_u8
)
{
// Check cycles counter overflow
song_cycles_cnt_u8
=
0
;
// Reset the cycles counter
song_playing_current_u8
++
;
// Increment the playlist counter
}
if
(
song_playing_current_u8
>=
PLAYLIST_LENGTH
)
{
// Check playlist song counter overflow
song_playing_current_u8
=
0
;
}
play_blank_delay
=
millis
();
stmState
=
STM_BLANK
;
break
;
...
...
@@ -426,15 +463,6 @@ void WritePlaySong (uint16_t index)
Serial
.
write
((
int
)
buffer_u8A
[
3
]);
// Song number high byte
Serial
.
write
((
int
)
buffer_u8A
[
4
]);
// Song number low byte
Serial
.
write
((
int
)
crc_u8
);
// CRC
/*
Serial.write(170); // 0xAA
Serial.write(7); // 0x07
Serial.write(2); // 0x02
Serial.write(0); // Song number high byte
Serial.write(1); // Song number low byte
Serial.write(180); // CRC
*/
}
uint8_t
CrcCalculate
(
uint8_t
*
buff
,
uint8_t
size
)
...
...
sw/boitarire_sw/boitarire_sw.ino.eightanaloginputs.hex
0 → 100644
View file @
3f68084b
This diff is collapsed.
Click to expand it.
sw/boitarire_sw/boitarire_sw.ino.with_bootloader.eightanaloginputs.hex
0 → 100644
View file @
3f68084b
This diff is collapsed.
Click to expand it.
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