Skip to content

Commit 8f6e6f1

Browse files
authored
Merge pull request #11 from nomakewan/docupdate
Documentation, function updates
2 parents aa261fc + 7f21682 commit 8f6e6f1

File tree

5 files changed

+33
-12
lines changed

5 files changed

+33
-12
lines changed

README.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,22 @@ Example code to demonstrate some of the GPStar Audio's features can be found in
6464

6565
**GPStarAudio.resumeAllInSync()** - This will resume all tracks which are currently paused at the exact same time.
6666

67-
**GPStarAudio.samplerateOffset(uint16_t offset)** - This sets the sample-rate offset of the main output mix. The range for the offset is `-32767` to `32676`, giving a speed range of 1/2x to 2x or a pitch range of down one octave to up one octave. If audio is playing you will hear the result immediately. If audio is not playing, the new sample-rate offset will be used the next time a track is started.
67+
**GPStarAudio.samplerateOffset(int16_t offset)** - This sets the sample-rate offset of the main output mix. The range for the offset is `-32767` to `32676`, giving a speed range of 1/2x to 2x or a pitch range of down one octave to up one octave. If audio is playing you will hear the result immediately. If audio is not playing, the new sample-rate offset will be used the next time a track is started.
6868

6969
**GPStarAudio.setLED(bool status)** - You can turn off the LED status indicator by setting `status` to `false`. Passing `true` enables the LED again. By default the LED on GPStar Audio flashes and blinks to provide various status updates.
7070

7171
**GPStarAudio.gpstarShortTrackOverload(bool status)** - Enabled by default. GPStar Audio will detect mulitple versions of the same sound playing in succession and prevent it from overloading and taking too many audio channels, instead replaying the file to save system resources.
7272

7373
**GPStarAudio.gpstarTrackForce(bool status)** - Disabled by default. When enabled, GPStar Audio will forcibly take a audio channel when requested to play a new track even if all channels in use and locked.
7474

75-
**GPStarAudio.trackPlayingStatus(uint16_t trk)** - This will ask GPStar Audio if the provided track number is playing. After calling this method, call the `GPStarAudio.currentTrackStatus(uint16_t trk)` method to find out if the track is playing or not.
75+
**GPStarAudio.trackPlayingStatus(uint16_t trk)** - This will ask GPStar Audio if the provided track number is playing. After calling this method, call the `GPStarAudio.currentTrackStatus(uint16_t trk)` method to find out if the track is playing or not. If the provided track number is not currently playing, this function will also set the internal track counter flag to `false` (see `isTrackCounterReset()`).
7676

7777
**GPStarAudio.currentTrackStatus(uint16_t trk)** - This will retrieve the status of a the provided track number if it is playing. You will want to use the `GPStarAudio.trackPlayingStatus(uint16_t trk)` method first to ask if the provided track is playing, then call this method soon after to retrieve the response.
7878

79+
**GPStarAudio.resetTrackCounter()** - Call this function to reset the state of the internal track counter flag. This is useful, for example, when you want to identify when a specific track has finished playing (such as for music playback). It is recommended to call this right before you start playing the track you intend to have the GPStar Audio follow the status of.
80+
81+
**GPStarAudio.isTrackCounterReset()** - Call this function to see if the internal track counter flag has been reset. This will return `true` if the internal track counter flag has been reset by `resetTrackCounter()`. It will return `false` if `resetTrackCounter()` has never been called or if `trackPlayingStatus(trk)` was called on a track that is not currently playing.
82+
7983
**GPStarAudio.setReporting(bool enable)** - Provided for backwards compatibility with existing polyphonic audio boards, but has no effect on GPStar Audio (which always has track reporting enabled).
8084

8185
**GPStarAudio.setAmpPwr(bool enable)** - Provided for backwards compatibility with existing polyphonic audio boards, but has no effect on GPStar Audio (which uses a headphone sense circuit to dynamically switch between the headphone and speaker amplifiers).

examples/example.ino

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* 1. Download and install AltSoftSerial library.
2121
* 2. Copy the wav files from the example folder to a Micro SD Card.
2222
* 3. Connect 4 wires from the UNO or Nano to the GPStar UART connector / pins:
23-
23+
2424
* UNO / Nano GPStar Audio
2525
* ---------- ------------
2626
* GND <-----> GND
@@ -81,7 +81,7 @@ void loop() {
8181
// Play track 2 at 100% volume. The track will stop playing after it has ended.
8282
gpstar.trackGain(2, 0);
8383
gpstar.trackPlay(2);
84-
84+
8585
delay(5000);
8686

8787
// Fade in track 3 over 4 seconds to 100% volume, and let it loop

library.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version=1.0.0
33
author=Michael Rajotte
44
maintainer=Michael Rajotte <[email protected]>
55
sentence=Control your GPStar Audio boards with serial communication commands.
6-
paragraph=A serial communication control library for the GPStar Audio and GPStar Audio XL series of audio boards from GPStar Technologies.
6+
paragraph=A serial communication control library for the GPStar Audio and GPStar Audio XL series of audio boards from GPStar Technologies.
77
category=Audio
88
architectures=*
99
url=https://github.com/gpstar81/GPStarAudio-Serial-Library

src/GPStarAudio.cpp

+20-5
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,14 @@ void gpstarAudio::update(void) {
115115

116116
// 0 = not playing. 1 = playing.
117117
if(rxMessage[3] == 0) {
118-
b_currentTrackStatus = false;
118+
bCurrentTrackStatus = false;
119119
}
120120
else {
121-
b_currentTrackStatus = true;
121+
bCurrentTrackStatus = true;
122122
}
123123

124-
resetTrackCounter(false);
124+
// Set trackCounter to false to reset it.
125+
trackCounter = false;
125126
break;
126127

127128
case RSP_TRACK_REPORT:
@@ -174,20 +175,34 @@ void gpstarAudio::update(void) {
174175

175176
bool gpstarAudio::currentTrackStatus(uint16_t trk) {
176177
if(trk == currentTrack) {
177-
if(b_currentTrackStatus) {
178+
if(bCurrentTrackStatus) {
178179
return true;
179180
}
180181
}
181182

182183
return false;
183184
}
184185

186+
__attribute__((deprecated("trackCounterReset() is deprecated. Please use isTrackCounterReset() instead.")))
185187
bool gpstarAudio::trackCounterReset() {
188+
return isTrackCounterReset();
189+
}
190+
191+
bool gpstarAudio::isTrackCounterReset() {
192+
// trackCounter is reset if it is true.
186193
return trackCounter;
187194
}
188195

196+
__attribute__((deprecated("resetTrackCounter(bool) is deprecated and will always reset to true. Please use resetTrackCounter() without passing a parameter instead.")))
189197
void gpstarAudio::resetTrackCounter(bool bReset) {
190-
trackCounter = bReset;
198+
// Ignore the passed parameter and reset trackCounter.
199+
(void)bReset;
200+
resetTrackCounter();
201+
}
202+
203+
void gpstarAudio::resetTrackCounter() {
204+
// Resetting the variable means to set it to true.
205+
trackCounter = true;
191206
}
192207

193208
void gpstarAudio::trackPlayingStatus(uint16_t trk) {

src/GPStarAudio.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,9 @@ class gpstarAudio
102102
void trackPlayingStatus(uint16_t trk);
103103
bool currentTrackStatus(uint16_t trk);
104104
bool trackCounterReset(void);
105-
void resetTrackCounter(bool bReset);
105+
void resetTrackCounter(bool bReset);
106+
bool isTrackCounterReset(void);
107+
void resetTrackCounter(void);
106108
void serialFlush(void);
107109
void requestVersionString(void);
108110
void requestSystemInfo(void);
@@ -131,6 +133,6 @@ class gpstarAudio
131133
bool sysInfoRcvd;
132134
bool gpsInfoRcvd;
133135
uint16_t currentTrack;
134-
bool b_currentTrackStatus;
136+
bool bCurrentTrackStatus;
135137
bool trackCounter;
136138
};

0 commit comments

Comments
 (0)