-
Notifications
You must be signed in to change notification settings - Fork 0
Clap
Interact with and control MiP using claps.
- enableClapEvents()
- disableClapEvents()
- areClapEventsEnabled()
- writeClapDelay()
- readClapDelay()
- availableClapEvents()
- readClapEvent()
void enableClapEvents()
Enable MiP to detect user claps. Once this is enabled, your code can call availableClapEvents() and readClapEvent() to determine when clap events have been detected by MiP.
None
Nothing
- MiP defaults to having the clap detection feature disabled after the MPU: D1 mini attaches.
Serial1.println(F(" Calling enableClapEvents()"));
mip.enableClapEvents();
isEnabled = mip.areClapEventsEnabled();
Serial1.print(F(" areClapEventsEnabled() returns "));
if (isEnabled) {
Serial1.println(F("true - pass"));
} else {
Serial1.println(F("false - fail"));
}void disableClapEvents()
Disables MiP's ability to detect user claps.
None
Nothing
- MiP defaults to having the clap detection feature disabled after the ESP8266 attaches.
Serial.println(F("Calling disableClapEvents()"));
mip.disableClapEvents();
bool isEnabled = mip.areClapEventsEnabled();
Serial.print(F("areClapEventsEnabled() returns "));
if (isEnabled) {
Serial.println(F("true - fail"));
} else {
Serial.println(F("false - pass"));
}bool areClapEventsEnabled()
Returns whether MiP's clap detection feature is currently enabled.
None
- true if MiP was successfully placed in clap detection mode with a previous call to enableClapEvents().
- false if it is not in clap detection mode.
Serial.println(F("Calling enableClapEvents()"));
mip.enableClapEvents();
isEnabled = mip.areClapEventsEnabled();
Serial.print(F("areClapEventsEnabled() returns "));
if (isEnabled) {
Serial.println(F("true - pass"));
} else {
Serial.println(F("false - fail"));
}void writeClapDelay(uint16_t delay)
Sets the expected delay between user claps.
- delay is the new delay to be used for clap detection.
Nothing
- I don't know what the units are for this setting. Maybe milliseconds?
- MiP defaults to having the clap delay set to 500 after the application first connects.
Serial.println(F("Calling writeClapDelay(501)"));
mip.writeClapDelay(501);
uint16_t delay = mip.readClapDelay();
Serial.print(F("readClapDelay() returns "));
Serial.println(delay);uint16_t readClapDelay()
Read MiP’s current clap delay.
None
The current setting of the delay expected between claps. It defaults to 500.
Serial.println(F("Calling writeClapDelay(501)"));
mip.writeClapDelay(501);
uint16_t delay = mip.readClapDelay();
Serial.print(F("readClapDelay() returns "));
Serial.println(delay);uint8_t availableClapEvents()
Returns the number of clap detection events that the library currently has sitting in its queue, ready to be read by calling readClapEvent(). MiP must have already been placed in clap detection mode via a call to enableClapEvents() for new clap detection events to be added to this queue.
None
- 0 if there are currently no clap detection events ready for reading. Calling readClapEvent() now would retun 0.
- Non-zero value indicates the number of readClapEvent() calls that can be made and successfully return a valid clap detection event.
- The maximum number of clap detection events that can be queued up between calls to readClapEvent() is 8. If this count is exceeded, the oldest events will be overwritten.
void loop() {
while (mip.availableClapEvents() > 0) {
uint8_t clapCount = mip.readClapEvent();
Serial.print(F("Detected "));
Serial.print(clapCount);
Serial.println(F(" claps"));
}
}uint8_t readClapEvent()
Returns a clap detection event from the library's queue. They will be returned in the order that MiP detected them. MiP must have already been placed in clap detection mode via a call to enableClapEvents() for new clap detection events to be added to this queue.
None
- 0 if the clap detection event queue is empty. availableClapEvents() would return 0 in this scenario.
- The number of claps detected in this event (ie. 2 for a double clap).
- The maximum number of clap detection events that can be queued up between calls to readClapEvent() is 8. If this count is exceeded, the oldest events will be overwritten.
void loop() {
while (mip.availableClapEvents() > 0) {
uint8_t clapCount = mip.readClapEvent();
Serial1.print(F(" Detected "));
Serial1.print(clapCount);
Serial1.println(F(" claps"));
}
}🔗 Quick Links: Main Repository • Report an Issue • Wiki Home
An open-source API for the WowWee MiP Robot. Licensed under Apache-2.0.
- MiP
- MiPChestLED
- MiPClapSettings
- MiPDebug
- MiPHardwareInfo
- MiPHeadLEDs
- MiPIRDongleCode
- MiPSoftwareVersion
- MiPStatus
- MiP_Battery
- MiP_ChestLED
- MiP_Clap
- MiP_EEPROM
- MiP_Gesture
- MiP_HeadLEDs
- MiP_Infrared
- MiP_Mode
- MiP_Motion
- MiP_Odometer
- MiP_Position
- MiP_Radar
- MiP_Serial
- MiP_Shake
- MiP_Sound
- MiP_Version
- MiP_Weight
- MiP_WiFi