Skip to content

Game modes

Tiogaplanet edited this page Oct 9, 2018 · 2 revisions

These functions allow access to MiP's built-in game modes.


enableAppMode()

void enableAppMode()

Description

Place MiP in app mode. The chest LED will turn green. App mode allows MiP to interface with applications running on either the UART port or via Bluetooth.

Parameters

None

Returns

Nothing

Example

#include <mip_esp8266.h>

MiP mip;

// Use short delays for bench testing with serial monitor
// or long delays to see it in action.
int delayPeriod = 10000;

void setup() {
  // First need to initialize the serial connection with MiP.
  bool connectResult = mip.begin();
  if (!connectResult) {
    Serial.println(F("Failed connecting to MiP!"));
    return;
  }

  Serial.println(F("EnableGameMode.ino - Cycles through each mode available."));

  delay(500);
}

void loop() {
  mip.enableCageMode();
  if (mip.isCageModeEnabled()) {
    Serial.println(F("Cage mode enabled."));
  }
  delay(delayPeriod);

  mip.enableDanceMode();
  if (mip.isDanceModeEnabled()) {
    Serial.println(F("Dance mode enabled."));
  }
  delay(delayPeriod);

  mip.enableStackMode();
  if (mip.isStackModeEnabled()) {
    Serial.println(F("Stack mode enabled."));
  }
  delay(delayPeriod);

  mip.enableTrickMode();
  if (mip.isTrickModeEnabled()) {
    Serial.println(F("Trick mode enabled."));
  }
  delay(delayPeriod);

  mip.enableRoamMode();
  if (mip.isRoamModeEnabled()) {
    Serial.println(F("Roam mode enabled."));
  }
  delay(delayPeriod);

  mip.enableAppMode();
  if (mip.isAppModeEnabled()) {
    Serial.println(F("App mode enabled."));
  }
  delay(delayPeriod);
}

enableCageMode()

void enableCageMode()

Description

Place MiP in cage mode. The chest LED will turn white and the MiP will try to escape from you. Place your hand in front of MiP's eyes to block its path. MiP moves faster as the game progesses and makes victory sounds if it escapes from you. To restart the game, clap twice.

Parameters

None

Returns

Nothing

Example

#include <mip_esp8266.h>

MiP mip;

// Use short delays for bench testing with serial monitor
// or long delays to see it in action.
int delayPeriod = 10000;

void setup() {
  // First need to initialize the serial connection with MiP.
  bool connectResult = mip.begin();
  if (!connectResult) {
    Serial.println(F("Failed connecting to MiP!"));
    return;
  }

  Serial.println(F("EnableGameMode.ino - Cycles through each mode available."));

  delay(500);
}

void loop() {
  mip.enableCageMode();
  if (mip.isCageModeEnabled()) {
    Serial.println(F("Cage mode enabled."));
  }
  delay(delayPeriod);

  mip.enableDanceMode();
  if (mip.isDanceModeEnabled()) {
    Serial.println(F("Dance mode enabled."));
  }
  delay(delayPeriod);

  mip.enableStackMode();
  if (mip.isStackModeEnabled()) {
    Serial.println(F("Stack mode enabled."));
  }
  delay(delayPeriod);

  mip.enableTrickMode();
  if (mip.isTrickModeEnabled()) {
    Serial.println(F("Trick mode enabled."));
  }
  delay(delayPeriod);

  mip.enableRoamMode();
  if (mip.isRoamModeEnabled()) {
    Serial.println(F("Roam mode enabled."));
  }
  delay(delayPeriod);

  mip.enableAppMode();
  if (mip.isAppModeEnabled()) {
    Serial.println(F("App mode enabled."));
  }
  delay(delayPeriod);
}

enableDanceMode()

void enableDanceMode()

Description

Place MiP in dance mode. The chest LED will turn turquoise and MiP will dance around and play music.

Parameters

None

Returns

Nothing

Example

#include <mip_esp8266.h>

MiP mip;

// Use short delays for bench testing with serial monitor
// or long delays to see it in action.
int delayPeriod = 10000;

void setup() {
  // First need to initialize the serial connection with MiP.
  bool connectResult = mip.begin();
  if (!connectResult) {
    Serial.println(F("Failed connecting to MiP!"));
    return;
  }

  Serial.println(F("EnableGameMode.ino - Cycles through each mode available."));

  delay(500);
}

void loop() {
  mip.enableCageMode();
  if (mip.isCageModeEnabled()) {
    Serial.println(F("Cage mode enabled."));
  }
  delay(delayPeriod);

  mip.enableDanceMode();
  if (mip.isDanceModeEnabled()) {
    Serial.println(F("Dance mode enabled."));
  }
  delay(delayPeriod);

  mip.enableStackMode();
  if (mip.isStackModeEnabled()) {
    Serial.println(F("Stack mode enabled."));
  }
  delay(delayPeriod);

  mip.enableTrickMode();
  if (mip.isTrickModeEnabled()) {
    Serial.println(F("Trick mode enabled."));
  }
  delay(delayPeriod);

  mip.enableRoamMode();
  if (mip.isRoamModeEnabled()) {
    Serial.println(F("Roam mode enabled."));
  }
  delay(delayPeriod);

  mip.enableAppMode();
  if (mip.isAppModeEnabled()) {
    Serial.println(F("App mode enabled."));
  }
  delay(delayPeriod);
}

enableStackMode()

void enableStackMode()

Description

Place MiP in stack mode. The chest LED will turn pink and MiP will play the stack game with you. You will have only a few seconds to stack a heavy object or many light objects on top of the tray. If it can balance correctly, MiP will add additional time for you to stack. If you fail to reset the timer and the clock runs out, MiP spins around, tossing all the stacked items off the tray.

Parameters

None

Returns

Nothing

Example

#include <mip_esp8266.h>

MiP mip;

// Use short delays for bench testing with serial monitor
// or long delays to see it in action.
int delayPeriod = 10000;

void setup() {
  // First need to initialize the serial connection with MiP.
  bool connectResult = mip.begin();
  if (!connectResult) {
    Serial.println(F("Failed connecting to MiP!"));
    return;
  }

  Serial.println(F("EnableGameMode.ino - Cycles through each mode available."));

  delay(500);
}

void loop() {
  mip.enableCageMode();
  if (mip.isCageModeEnabled()) {
    Serial.println(F("Cage mode enabled."));
  }
  delay(delayPeriod);

  mip.enableDanceMode();
  if (mip.isDanceModeEnabled()) {
    Serial.println(F("Dance mode enabled."));
  }
  delay(delayPeriod);

  mip.enableStackMode();
  if (mip.isStackModeEnabled()) {
    Serial.println(F("Stack mode enabled."));
  }
  delay(delayPeriod);

  mip.enableTrickMode();
  if (mip.isTrickModeEnabled()) {
    Serial.println(F("Trick mode enabled."));
  }
  delay(delayPeriod);

  mip.enableRoamMode();
  if (mip.isRoamModeEnabled()) {
    Serial.println(F("Roam mode enabled."));
  }
  delay(delayPeriod);

  mip.enableAppMode();
  if (mip.isAppModeEnabled()) {
    Serial.println(F("App mode enabled."));
  }
  delay(delayPeriod);
}

enableTrickMode()

void enableTrickMode()

Description

Place MiP in trick mode. The chest LED will flash red. While the chest LED is flashing MiP will record your hand gestures. MiP will signal each successful gesture by saying "OK" and lighting up its eyes. You can record up to 50 gestures. When complete, clap twice and MiP will replay the movements given by your gestures.

Parameters

None

Returns

Nothing

Example

#include <mip_esp8266.h>

MiP mip;

// Use short delays for bench testing with serial monitor
// or long delays to see it in action.
int delayPeriod = 10000;

void setup() {
  // First need to initialize the serial connection with MiP.
  bool connectResult = mip.begin();
  if (!connectResult) {
    Serial.println(F("Failed connecting to MiP!"));
    return;
  }

  Serial.println(F("EnableGameMode.ino - Cycles through each mode available."));

  delay(500);
}

void loop() {
  mip.enableCageMode();
  if (mip.isCageModeEnabled()) {
    Serial.println(F("Cage mode enabled."));
  }
  delay(delayPeriod);

  mip.enableDanceMode();
  if (mip.isDanceModeEnabled()) {
    Serial.println(F("Dance mode enabled."));
  }
  delay(delayPeriod);

  mip.enableStackMode();
  if (mip.isStackModeEnabled()) {
    Serial.println(F("Stack mode enabled."));
  }
  delay(delayPeriod);

  mip.enableTrickMode();
  if (mip.isTrickModeEnabled()) {
    Serial.println(F("Trick mode enabled."));
  }
  delay(delayPeriod);

  mip.enableRoamMode();
  if (mip.isRoamModeEnabled()) {
    Serial.println(F("Roam mode enabled."));
  }
  delay(delayPeriod);

  mip.enableAppMode();
  if (mip.isAppModeEnabled()) {
    Serial.println(F("App mode enabled."));
  }
  delay(delayPeriod);
}

enableRoamMode()

void enableRoamMode()

Description

Place MiP in roam mode. The chest LED will turn yellow and roam freely, avoiding obstacles detected by the IR sensors.

Parameters

None

Returns

Nothing

Example

#include <mip_esp8266.h>

MiP mip;

// Use short delays for bench testing with serial monitor
// or long delays to see it in action.
int delayPeriod = 10000;

void setup() {
  // First need to initialize the serial connection with the MiP.
  bool connectResult = mip.begin();
  if (!connectResult) {
    Serial.println(F("Failed connecting to MiP!"));
    return;
  }

  Serial.println(F("EnableGameMode.ino - Cycles through each mode available."));

  delay(500);
}

void loop() {
  mip.enableCageMode();
  if (mip.isCageModeEnabled()) {
    Serial.println(F("Cage mode enabled."));
  }
  delay(delayPeriod);

  mip.enableDanceMode();
  if (mip.isDanceModeEnabled()) {
    Serial.println(F("Dance mode enabled."));
  }
  delay(delayPeriod);

  mip.enableStackMode();
  if (mip.isStackModeEnabled()) {
    Serial.println(F("Stack mode enabled."));
  }
  delay(delayPeriod);

  mip.enableTrickMode();
  if (mip.isTrickModeEnabled()) {
    Serial.println(F("Trick mode enabled."));
  }
  delay(delayPeriod);

  mip.enableRoamMode();
  if (mip.isRoamModeEnabled()) {
    Serial.println(F("Roam mode enabled."));
  }
  delay(delayPeriod);

  mip.enableAppMode();
  if (mip.isAppModeEnabled()) {
    Serial.println(F("App mode enabled."));
  }
  delay(delayPeriod);
}

isAppModeEnabled()

bool isAppModeEnabled()

Description

Returns whether MiP is in app mode.

Parameters

None

Returns

  • true if MiP was successfully placed in app mode with a previous call to enableAppMode().
  • false if MiP is not in app mode.

Example

#include <mip_esp8266.h>

MiP mip;

// Use short delays for bench testing with serial monitor
// or long delays to see it in action.
int delayPeriod = 10000;

void setup() {
  // First need to initialize the serial connection with MiP.
  bool connectResult = mip.begin();
  if (!connectResult) {
    Serial.println(F("Failed connecting to MiP!"));
    return;
  }

  Serial.println(F("EnableGameMode.ino - Cycles through each mode available."));

  delay(500);
}

void loop() {
  mip.enableCageMode();
  if (mip.isCageModeEnabled()) {
    Serial.println(F("Cage mode enabled."));
  }
  delay(delayPeriod);

  mip.enableDanceMode();
  if (mip.isDanceModeEnabled()) {
    Serial.println(F("Dance mode enabled."));
  }
  delay(delayPeriod);

  mip.enableStackMode();
  if (mip.isStackModeEnabled()) {
    Serial.println(F("Stack mode enabled."));
  }
  delay(delayPeriod);

  mip.enableTrickMode();
  if (mip.isTrickModeEnabled()) {
    Serial.println(F("Trick mode enabled."));
  }
  delay(delayPeriod);

  mip.enableRoamMode();
  if (mip.isRoamModeEnabled()) {
    Serial.println(F("Roam mode enabled."));
  }
  delay(delayPeriod);

  mip.enableAppMode();
  if (mip.isAppModeEnabled()) {
    Serial.println(F("App mode enabled."));
  }
  delay(delayPeriod);
}

isCageModeEnabled()

bool isCageModeEnabled()

Description

Returns whether MiP is in cage mode.

Parameters

None

Returns

  • true if MiP was successfully placed in cage mode with a previous call to enableCageMode().
  • false if MiP is not in cage mode.

Example

#include <mip_esp8266.h>

MiP mip;

// Use short delays for bench testing with serial monitor
// or long delays to see it in action.
int delayPeriod = 10000;

void setup() {
  // First need to initialize the serial connection with MiP.
  bool connectResult = mip.begin();
  if (!connectResult) {
    Serial.println(F("Failed connecting to MiP!"));
    return;
  }

  Serial.println(F("EnableGameMode.ino - Cycles through each mode available."));

  delay(500);
}

void loop() {
  mip.enableCageMode();
  if (mip.isCageModeEnabled()) {
    Serial.println(F("Cage mode enabled."));
  }
  delay(delayPeriod);

  mip.enableDanceMode();
  if (mip.isDanceModeEnabled()) {
    Serial.println(F("Dance mode enabled."));
  }
  delay(delayPeriod);

  mip.enableStackMode();
  if (mip.isStackModeEnabled()) {
    Serial.println(F("Stack mode enabled."));
  }
  delay(delayPeriod);

  mip.enableTrickMode();
  if (mip.isTrickModeEnabled()) {
    Serial.println(F("Trick mode enabled."));
  }
  delay(delayPeriod);

  mip.enableRoamMode();
  if (mip.isRoamModeEnabled()) {
    Serial.println(F("Roam mode enabled."));
  }
  delay(delayPeriod);

  mip.enableAppMode();
  if (mip.isAppModeEnabled()) {
    Serial.println(F("App mode enabled."));
  }
  delay(delayPeriod);
}

isDanceModeEnabled()

bool isDanceModeEnabled()

Description

Returns whether the MiP is in dance mode.

Parameters

None

Returns

  • true if MiP was successfully placed in dance mode with a previous call to enableDanceMode().
  • false if MiP is not in dance mode.

Example

#include <mip_esp8266.h>

MiP mip;

// Use short delays for bench testing with serial monitor
// or long delays to see it in action.
int delayPeriod = 10000;

void setup() {
  // First need to initialize the serial connection with MiP.
  bool connectResult = mip.begin();
  if (!connectResult) {
    Serial.println(F("Failed connecting to MiP!"));
    return;
  }

  Serial.println(F("EnableGameMode.ino - Cycles through each mode available."));

  delay(500);
}

void loop() {
  mip.enableCageMode();
  if (mip.isCageModeEnabled()) {
    Serial.println(F("Cage mode enabled."));
  }
  delay(delayPeriod);

  mip.enableDanceMode();
  if (mip.isDanceModeEnabled()) {
    Serial.println(F("Dance mode enabled."));
  }
  delay(delayPeriod);

  mip.enableStackMode();
  if (mip.isStackModeEnabled()) {
    Serial.println(F("Stack mode enabled."));
  }
  delay(delayPeriod);

  mip.enableTrickMode();
  if (mip.isTrickModeEnabled()) {
    Serial.println(F("Trick mode enabled."));
  }
  delay(delayPeriod);

  mip.enableRoamMode();
  if (mip.isRoamModeEnabled()) {
    Serial.println(F("Roam mode enabled."));
  }
  delay(delayPeriod);

  mip.enableAppMode();
  if (mip.isAppModeEnabled()) {
    Serial.println(F("App mode enabled."));
  }
  delay(delayPeriod);
}

isStackModeEnabled()

bool isStackModeEnabled()

Description

Returns whether MiP is in stack mode.

Parameters

None

Returns

  • true if MiP was successfully placed in stack mode with a previous call to enableStackMode().
  • false if MiP is not in stack mode.

Example

#include <mip_esp8266.h>

MiP mip;

// Use short delays for bench testing with serial monitor
// or long delays to see it in action.
int delayPeriod = 10000;

void setup() {
  // First need to initialize the serial connection with MiP.
  bool connectResult = mip.begin();
  if (!connectResult) {
    Serial.println(F("Failed connecting to MiP!"));
    return;
  }

  Serial.println(F("EnableGameMode.ino - Cycles through each mode available."));

  delay(500);
}

void loop() {
  mip.enableCageMode();
  if (mip.isCageModeEnabled()) {
    Serial.println(F("Cage mode enabled."));
  }
  delay(delayPeriod);

  mip.enableDanceMode();
  if (mip.isDanceModeEnabled()) {
    Serial.println(F("Dance mode enabled."));
  }
  delay(delayPeriod);

  mip.enableStackMode();
  if (mip.isStackModeEnabled()) {
    Serial.println(F("Stack mode enabled."));
  }
  delay(delayPeriod);

  mip.enableTrickMode();
  if (mip.isTrickModeEnabled()) {
    Serial.println(F("Trick mode enabled."));
  }
  delay(delayPeriod);

  mip.enableRoamMode();
  if (mip.isRoamModeEnabled()) {
    Serial.println(F("Roam mode enabled."));
  }
  delay(delayPeriod);

  mip.enableAppMode();
  if (mip.isAppModeEnabled()) {
    Serial.println(F("App mode enabled."));
  }
  delay(delayPeriod);
}

isTrickModeEnabled()

bool isTrickModeEnabled()

Description

Returns whether MiP is in trick mode.

Parameters

None

Returns

  • true if MiP was successfully placed in trick mode with a previous call to enableTrickMode().
  • false if MiP is not in trick mode.

Example

#include <mip_esp8266.h>

MiP mip;

// Use short delays for bench testing with serial monitor
// or long delays to see it in action.
int delayPeriod = 10000;

void setup() {
  // First need to initialize the serial connection with MiP.
  bool connectResult = mip.begin();
  if (!connectResult) {
    Serial.println(F("Failed connecting to MiP!"));
    return;
  }

  Serial.println(F("EnableGameMode.ino - Cycles through each mode available."));

  delay(500);
}

void loop() {
  mip.enableCageMode();
  if (mip.isCageModeEnabled()) {
    Serial.println(F("Cage mode enabled."));
  }
  delay(delayPeriod);

  mip.enableDanceMode();
  if (mip.isDanceModeEnabled()) {
    Serial.println(F("Dance mode enabled."));
  }
  delay(delayPeriod);

  mip.enableStackMode();
  if (mip.isStackModeEnabled()) {
    Serial.println(F("Stack mode enabled."));
  }
  delay(delayPeriod);

  mip.enableTrickMode();
  if (mip.isTrickModeEnabled()) {
    Serial.println(F("Trick mode enabled."));
  }
  delay(delayPeriod);

  mip.enableRoamMode();
  if (mip.isRoamModeEnabled()) {
    Serial.println(F("Roam mode enabled."));
  }
  delay(delayPeriod);

  mip.enableAppMode();
  if (mip.isAppModeEnabled()) {
    Serial.println(F("App mode enabled."));
  }
  delay(delayPeriod);
}

isRoamModeEnabled()

bool isRoamModeEnabled()

Description

Returns whether MiP is in roam mode.

Parameters

None

Returns

  • true if MiP was successfully placed in roam mode with a previous call to enableRoamMode().
  • false if MiP is not in roam mode.

Example

#include <mip_esp8266.h>

MiP mip;

// Use short delays for bench testing with serial monitor
// or long delays to see it in action.
int delayPeriod = 10000;

void setup() {
  // First need to initialize the serial connection with MiP.
  bool connectResult = mip.begin();
  if (!connectResult) {
    Serial.println(F("Failed connecting to MiP!"));
    return;
  }

  Serial.println(F("EnableGameMode.ino - Cycles through each mode available."));

  delay(500);
}

void loop() {
  mip.enableCageMode();
  if (mip.isCageModeEnabled()) {
    Serial.println(F("Cage mode enabled."));
  }
  delay(delayPeriod);

  mip.enableDanceMode();
  if (mip.isDanceModeEnabled()) {
    Serial.println(F("Dance mode enabled."));
  }
  delay(delayPeriod);

  mip.enableStackMode();
  if (mip.isStackModeEnabled()) {
    Serial.println(F("Stack mode enabled."));
  }
  delay(delayPeriod);

  mip.enableTrickMode();
  if (mip.isTrickModeEnabled()) {
    Serial.println(F("Trick mode enabled."));
  }
  delay(delayPeriod);

  mip.enableRoamMode();
  if (mip.isRoamModeEnabled()) {
    Serial.println(F("Roam mode enabled."));
  }
  delay(delayPeriod);

  mip.enableAppMode();
  if (mip.isAppModeEnabled()) {
    Serial.println(F("App mode enabled."));
  }
  delay(delayPeriod);
}