Skip to content

Commit 5346e81

Browse files
committed
moved to bool status return for example 8
1 parent d82df4c commit 5346e81

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

examples/Example_08_Sound_Effects/Example_08_Sound_Effects.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ QwiicBuzzer buzzer;
7878

7979
#define BUZZER_VOLUME 4 // loudest!!
8080
//#define BUZZER_VOLUME 3 // pretty good volume for most things
81-
sfeTkError_t err; // used for checking for errors
81+
bool err; // used for checking for errors
8282

8383
void setup() {
8484
Serial.begin(115200);
@@ -100,7 +100,7 @@ void setup() {
100100
err = buzzer.playSoundEffect(i, BUZZER_VOLUME);
101101

102102
// Check whether the playSoundEffect() was successful
103-
if (err != kSTkErrOk)
103+
if (err == false)
104104
{
105105
Serial.println("error!");
106106
break;

src/sfeQwiicBuzzer.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ uint8_t sfeQwiicBuzzer::address()
144144
return _theBus->address();
145145
}
146146

147-
sfeTkError_t sfeQwiicBuzzer::playSoundEffect(const uint8_t soundEffectNumber, const uint8_t volume)
147+
bool sfeQwiicBuzzer::playSoundEffect(const uint8_t soundEffectNumber, const uint8_t volume)
148148
{
149149
sfeTkError_t err;
150150

@@ -184,7 +184,10 @@ sfeTkError_t sfeQwiicBuzzer::playSoundEffect(const uint8_t soundEffectNumber, co
184184
err = kSTkErrFail;
185185
}
186186

187-
return err;
187+
if (err == kSTkErrOk)
188+
return true;
189+
else
190+
return false;
188191
}
189192

190193
sfeTkError_t sfeQwiicBuzzer::soundEffect0(const uint8_t volume)

src/sfeQwiicBuzzer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ class sfeQwiicBuzzer
108108
/// @brief Plays one of the sound effects included in this library
109109
/// @param soundEffectNumber The sound effect you with to play
110110
/// @param volume Volume (4 settings; 0=off, 1=quiet... 4=loudest)
111-
/// @return 0 for succuss, negative for errors, positive for warnings
112-
sfeTkError_t playSoundEffect(const uint8_t soundEffectNumber, const uint8_t volume);
111+
/// @return 1 for succuss, 0 error
112+
bool playSoundEffect(const uint8_t soundEffectNumber, const uint8_t volume);
113113

114114
private:
115115
/// @brief Plays sound effect 0 (aka "Siren")

0 commit comments

Comments
 (0)