Luca SevàMichele ValentiniMassimiliano
Published © GPL3+

Presentation Controller for PowerPoint with the T-Skin

We made this project to show an example of how you can integrate the T-Skin into everyday tasks making them more interesting and intuitive.

IntermediateFull instructions provided3 hours575

Things used in this project

Hardware components

The Tactigon Skin (T-SKIN)
The Tactigon Skin (T-SKIN)
×1
Adafruit Bluefruit LE UART Friend - Bluetooth Low Energy (BLE)
×1

Software apps and online services

Arduino IDE
Arduino IDE
Processing
The Processing Foundation Processing

Story

Read more

Code

Tskin_PPT.ino

Arduino
Arduino code that will be flashed to the T-skin.
#include <tactigon_led.h>
#include <tactigon_IMU.h>
#include <tactigon_BLE.h>
#include <tactigon_IO.h>

#define CENTRAL_MODE

#define TSKIN_ULTIMATE

T_Led rLed, bLed, gLed;
T_ACC accMeter;
T_AccData accData;
T_GYRO gyro;

T_QUAT qMeter;
T_QData qData;

T_BLE bleManager;

#ifdef CENTRAL_MODE
UUID targetUUID;
#endif

//GPIO
T_GPP gpp1;
T_GPP gpp2;
T_GPP gpp3;
T_GPP gpp4;

#ifdef CENTRAL_MODE
const uint8_t BUFF_SIZE = 20;
char buffData[BUFF_SIZE];
#endif

float roll;
float pitch;
float yaw;

float rollZero = 0;
float pitchZero = 0;
float yawZero = 0;

boolean offsets = false;

float thresholdRoll = 10;
float thresholdPitch = 10;
float thresholdYaw = 10;

boolean transmission = false;
int debounceTime = 300;
int lastTransmissionSwitch = 0;

int ticksProc;

//Used for LEDs cycle
int  ticksLed, stp;

#ifdef CENTRAL_MODE
//MAC of the bluetooth module
uint8_t targetMAC[6] = {0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF}; //ex: 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF
#endif

void setup() {
  ticksProc = 0;
  ticksLed = 0;
  rLed.init(T_Led::RED);
  gLed.init(T_Led::GREEN);
  bLed.init(T_Led::BLUE);

  rLed.off();
  gLed.off();
  bLed.off();

#ifdef CENTRAL_MODE
  bleManager.InitRole(TACTIGON_BLE_CENTRAL);
  targetUUID.set("Place_UUID_Here"); //UUID of the bluetooth module
  bleManager.setTarget(targetMAC, targetUUID);
#endif

  qMeter.enable();
  qMeter.useMag(0);

#ifdef TSKIN_ULTIMATE
  gpp1.init(T_GPP::GPP1, T_GPP::GPP_IN);
  gpp2.init(T_GPP::GPP2, T_GPP::GPP_IN);
  gpp3.init(T_GPP::GPP3, T_GPP::GPP_IN);
  gpp4.init(T_GPP::GPP4, T_GPP::GPP_IN);
#endif
}

void flash() {
  rLed.on();
  gLed.on();
  bLed.on();
}

float radToDegree(float rad) {
  return rad * 360 / 6.28;
}

void generateOffsets() {
  qData = qMeter.getQs();
  rollZero = qData.roll;
  pitchZero = qData.pitch;
  yawZero = qData.yaw;
}

void loop() {
  offsets = true;

  //buttons and sensor processing handling
  if (GetCurrentMilli() >= (ticksProc + (1000 / 30))) {

    ticksProc = GetCurrentMilli();

    if (!offsets) {
      generateOffsets();
      offsets = true;
    }

    //get acc data.
    qData = qMeter.getQs();
    roll = radToDegree(qData.roll - rollZero);
    pitch = radToDegree(qData.pitch - pitchZero);
    yaw = radToDegree(qData.yaw - yawZero);


    //debounce on GPP4 (activate /deactivate transmission)
    if (!gpp4.read()) {
      if (GetCurrentMilli() >= lastTransmissionSwitch + debounceTime) {
        transmission = !transmission;
        lastTransmissionSwitch = GetCurrentMilli();
      }
    }

    //trasmission
    if (transmission) {
      float rollTmp, pitchTmp;

      memset(buffData, 0, BUFF_SIZE);

#ifdef CENTRAL_MODE
#ifdef TSKIN_ULTIMATE
      pitchTmp = pitch + 180;
      rollTmp = roll + 180;
#endif
      //data buffer creation and fill up process
      snprintf (buffData, BUFF_SIZE, "%04d %04d %04d %01d%01d%01d\n", (int)(rollTmp * 10), (int)(pitchTmp * 10), (int)((yaw + 180) * 10), gpp1.read(), gpp2.read(), gpp3.read());
      Serial.println(buffData);
      bleManager.writeToPeripheral((unsigned char *)buffData, BUFF_SIZE);
#endif
    }
  }

  // led handling
  if (GetCurrentMilli() >= (ticksLed + (1000 / 2))) {
    ticksLed = GetCurrentMilli();
    int connStatus = bleManager.getStatus();
    switch (connStatus) {
      case 0:
        if (stp == 0) {
          rLed.on();
          gLed.off();
          bLed.off();
        }
        else if (stp == 1) {
          rLed.off();
          gLed.off();
          bLed.on();
        }
        else if (stp == 2) {
          rLed.off();
          gLed.on();
          bLed.off();
        }
        stp = (stp + 1) % 3;
        break;
      case 1:           //seraching for target
        rLed.on();
        gLed.off();
        bLed.off();
        break;
      case 2:           //target found, searching for characteristic
        rLed.off();
        gLed.off();
        bLed.on();
        break;
      case 3:           //ready for characteristic operations
        rLed.off();
        gLed.on();
        if (transmission)
          bLed.on();
        else
          bLed.off();
        break;
    }
  }
}

PPT-Controller

Processing application which provide an interface for the T-skin to be used as a PPT remote.

Credits

Luca Sevà

Luca Sevà

8 projects • 8 followers
Michele Valentini

Michele Valentini

20 projects • 51 followers
From Pepper growing to CNC milling, i don't like to waste time sleeping
Massimiliano

Massimiliano

28 projects • 102 followers
I'm an engineer and I like robotics, embedded systems and linux. I spent a lot of time in automation and firmware development.

Comments