mirror of
https://github.com/EFeru/hoverboard-sideboard-hack-STM.git
synced 2026-06-27 21:46:36 +00:00
Initial commit
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 68 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 65 KiB |
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 2.8 MiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.0 MiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.5 MiB |
Binary file not shown.
|
After Width: | Height: | Size: 26 KiB |
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
hoverboard-sidebboard-hack MPU6050 IMU - 3D Visualization Example
|
||||
Copyright (C) 2020-2021 Emanuel FERU
|
||||
*/
|
||||
import processing.serial.*;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.io.IOException;
|
||||
|
||||
Serial myPort;
|
||||
float roll, pitch,yaw;
|
||||
int idx = 0;
|
||||
int inBytePrev;
|
||||
short bufWord;
|
||||
|
||||
void setup() {
|
||||
size (1400, 800, P3D);
|
||||
printArray(Serial.list()); // List all the available serial ports
|
||||
myPort = new Serial(this, "COM5", 38400); // starts the serial communication
|
||||
|
||||
}
|
||||
|
||||
void draw() {
|
||||
|
||||
while (myPort.available() > 0) {
|
||||
int inByte = myPort.read();
|
||||
bufWord = (short)(inBytePrev | (inByte << 8));
|
||||
idx++;
|
||||
if(bufWord == -21846) { // check START_FRAME = 0xAAAA
|
||||
idx = 0;
|
||||
}
|
||||
if (idx == 2) {
|
||||
roll = float(bufWord) / 100;
|
||||
}
|
||||
if (idx == 4) {
|
||||
pitch = float(bufWord) / 100;
|
||||
}
|
||||
if (idx == 6) {
|
||||
yaw = float(bufWord) / 100;
|
||||
}
|
||||
inBytePrev = inByte;
|
||||
}
|
||||
|
||||
// println(bufWord); //<>//
|
||||
|
||||
translate(width/2, height/2, 0);
|
||||
background(51);
|
||||
textSize(22);
|
||||
text("Roll: " + roll + " Pitch: " + pitch + " Yaw: " + yaw, -200, 300);
|
||||
|
||||
// Rotate the object
|
||||
rotateX(radians(roll));
|
||||
rotateZ(radians(-pitch));
|
||||
rotateY(radians(yaw));
|
||||
|
||||
// 3D 0bject
|
||||
|
||||
// Draw box with text
|
||||
fill(0, 76, 153);; // Make board BLUE
|
||||
box (426, 30, 220);
|
||||
textSize(25);
|
||||
fill(255, 255, 255);
|
||||
text("MPU-6050 DMP DEMO", -150, 10, 111);
|
||||
|
||||
// Add other boxes
|
||||
translate(-70, -18, -30);
|
||||
fill(100, 100, 100);
|
||||
box (20, 5, 20); // MPU-6050
|
||||
|
||||
translate(70, 0, 0);
|
||||
box (40, 5, 40); // GD32
|
||||
|
||||
translate(0, 0, -70);
|
||||
fill(255, 255, 255);
|
||||
box (50, 40, 15); // USART Main
|
||||
|
||||
translate(0, 0, 200);
|
||||
box (50, 40, 15); // Color Led connector
|
||||
|
||||
translate(-60, 0, 0);
|
||||
box (40, 40, 15); // Blue Led connector
|
||||
|
||||
}
|
||||
Binary file not shown.
Reference in New Issue
Block a user