pifcamp-2021/osc32h/osc32h/osc32h.ino

71 lines
1.4 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

// ESP32 Dev Module
#include "Wire.h"
#include "MPU6050.h"
#include <OSCBoards.h>
#include <OSCMessage.h>
/*
Make an OSC message and send it over serial
*/
#ifdef BOARD_HAS_USB_SERIAL
#include <SLIPEncodedUSBSerial.h>
SLIPEncodedUSBSerial SLIPSerial( thisBoardsSerialUSB );
#else
#include <SLIPEncodedSerial.h>
SLIPEncodedSerial SLIPSerial(Serial); // Change to Serial1 or Serial2 etc. for boards with multiple serial ports that dont have Serial
#endif
/*
#include <BluetoothSerial.h>
#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
#endif
BluetoothSerial SerialBT;
*/
MPU6050 mpu;
// Sem dobimo vrednosti
int16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ;
void setup() {
Wire.begin();
SLIPSerial.begin(115200); // set this as high as you can reliably run on your platform
mpu.initialize();
// setFullScaleGyroRange(MPU6050_GYRO_FS_250);
// setFullScaleAccelRange(MPU6050_ACCEL_FS_2);
/*
SerialBT.begin("MotionGlove");
*/
}
void loop() {
mpu.getMotion6(&AcX, &AcY, &AcZ, &GyX, &GyY, &GyZ);
OSCMessage msg("/accel/");
msg.add(AcX);
msg.add(AcY);
msg.add(AcZ);
SLIPSerial.beginPacket();
msg.send(SLIPSerial);
SLIPSerial.endPacket();
msg.empty();
OSCMessage gmsg("/gyro/");
gmsg.add(GyX);
gmsg.add(GyY);
gmsg.add(GyZ);
SLIPSerial.beginPacket();
gmsg.send(SLIPSerial);
SLIPSerial.endPacket();
gmsg.empty();
}