From ee77c323fa483352dd1d235d4dc361782db1e868 Mon Sep 17 00:00:00 2001 From: Hendrik Schutter Date: Tue, 15 Nov 2016 23:24:08 +0100 Subject: [PATCH] Add files via upload --- TrackFPV.ini | 19 ++++++++++++++ TrackFPV.ino | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 TrackFPV.ini create mode 100644 TrackFPV.ino diff --git a/TrackFPV.ini b/TrackFPV.ini new file mode 100644 index 0000000..651e0d2 --- /dev/null +++ b/TrackFPV.ini @@ -0,0 +1,19 @@ +[migrations] +last-migration-at=20160917_00~ + +[modules] +filter-dll=Kalman +tracker-dll=Joystick input + +[opentrack-ui] +pitch-invert-sign=true +yaw-invert-sign=true + +[tracker-joystick] +axis-map-1=0 +axis-map-2=0 +axis-map-3=0 +axis-map-4=2 +axis-map-5=3 +axis-map-6=0 +joy-guid={D964FB90-A458-11E6-8001-444553540000} diff --git a/TrackFPV.ino b/TrackFPV.ino new file mode 100644 index 0000000..99b760b --- /dev/null +++ b/TrackFPV.ino @@ -0,0 +1,72 @@ +// File: TrackFPV.ino +// Date: 15.11.2016 +// Author: Hendrik Schutter +// Version: a0.1 + +#include +#include + +int yawRaw; +int pitchRaw; +int min = -500; +int max = 500; + +void cppm_cycle(void){ + if (CPPM.synchronized()){ + yawRaw = CPPM.read_us(CPPM_GEAR) - 1500; + pitchRaw = CPPM.read_us(CPPM_AUX1) - 1500; + } + else + { + Serial.println("Nix"); + } +} + +int getYAW() { + yawRaw = yawRaw - 22; + yawRaw = max_min(yawRaw); + float f = yawRaw/5; + return f; +} + +int getPITCH() { + pitchRaw = pitchRaw - 22; + pitchRaw = max_min(pitchRaw); + float f = pitchRaw/5; + return f; +} + +int max_min(int zahl) { + if (zahl > max) { + zahl = max; + } + if (zahl < min) { + zahl = min; + } + return zahl; +} + + +void setup(){ + Serial.begin(9600); + CPPM.begin(); + Joystick.begin(true); +} + +void loop(){ + cppm_cycle(); + Serial.print("Pitchraw: "); + Serial.println(pitchRaw-22); + Serial.print("YAWraw: "); + Serial.println(yawRaw-22); + + Serial.print("Pitch: "); + Serial.println(getPITCH()); + Serial.print("YAW: "); + Serial.println(getYAW()); + + Joystick.setYAxis(getPITCH()); + Joystick.setXAxis(getYAW()); + + delay(100); +}