From 3578bb228485b1ed715ded35668c47b5378d0416 Mon Sep 17 00:00:00 2001 From: lukasfriedrichsen <lukas.friedrichsen@hs-bochum.de> Date: Thu, 9 Feb 2017 11:19:53 +0100 Subject: [PATCH] tidiing up... --- .../LeonardoMixerIO/src/LeonardoMixer.cpp | 16 +++-- Systemtechnik/LeonardoMixerIO/src/Mixer.cpp | 9 ++- Systemtechnik/LeonardoMixerIO/src/Mixer.h | 7 ++- .../LeonardoMixerIO/src/MultiWiiSerial.cpp | 7 ++- .../src/MultiWiiSerial.cpp.lukas | 59 ------------------- .../LeonardoMixerIO/src/MultiWiiSerial.h | 8 +-- .../src/MultiWiiSerial.h.lukas | 43 -------------- Systemtechnik/LeonardoMixerIO/src/RC.h | 8 +-- .../LeonardoMixerIO/src/RawSerial.cpp | 11 ++-- Systemtechnik/LeonardoMixerIO/src/RawSerial.h | 10 ++-- .../LeonardoMixerIO/src/Scheduler.cpp | 9 ++- Systemtechnik/LeonardoMixerIO/src/Scheduler.h | 6 +- .../LeonardoMixerIO/src/Spektrum.cpp | 5 +- Systemtechnik/LeonardoMixerIO/src/Spektrum.h | 11 ++-- 14 files changed, 59 insertions(+), 150 deletions(-) delete mode 100644 Systemtechnik/LeonardoMixerIO/src/MultiWiiSerial.cpp.lukas delete mode 100644 Systemtechnik/LeonardoMixerIO/src/MultiWiiSerial.h.lukas diff --git a/Systemtechnik/LeonardoMixerIO/src/LeonardoMixer.cpp b/Systemtechnik/LeonardoMixerIO/src/LeonardoMixer.cpp index 940b34e..c5ebd12 100644 --- a/Systemtechnik/LeonardoMixerIO/src/LeonardoMixer.cpp +++ b/Systemtechnik/LeonardoMixerIO/src/LeonardoMixer.cpp @@ -1,7 +1,11 @@ // LeonardoMixer.cpp -// TODO License -// Lukas Friedrichsen, Philipp Stenkamp, 2017-1-6 +// Copyright 2016, 2017 Lukas Friedrichsen, Philipp Stenkamp +// License: Modified BSD-License // +// Realtime RC mixer for Arduino-devices +// +// 2017-01-06 + #include <Arduino.h> #include "RC.h" @@ -32,20 +36,17 @@ nRtTask *nRtTasks[] = { &readRawSerial, &readSpektrum, &mix, NULL }; void mix_Function (void) { - //Serial.println("MIX"); mixer.mix(); } void readSpektrum_Function (void) { - //Serial.println("SPEKTRUM"); spektrum.dataReceive(); spektrum.getData(); } void readRawSerial_Function (void) { - //Serial.println("RAW_SERIAL"); serial.dataReceive(); serial.getData(); } @@ -75,9 +76,6 @@ void printLCD_Function () void send_Function (void) { - - //Serial.println("SEND"); - //printDebug(); msp.SerialEncode(); } @@ -117,7 +115,7 @@ void setup() lcd.begin(2, 8); while(Serial1.available()){ - Serial1.read(); //gibt es eine bessere möglichkeit () + Serial1.read(); } } diff --git a/Systemtechnik/LeonardoMixerIO/src/Mixer.cpp b/Systemtechnik/LeonardoMixerIO/src/Mixer.cpp index 3e4c063..f2a7f81 100644 --- a/Systemtechnik/LeonardoMixerIO/src/Mixer.cpp +++ b/Systemtechnik/LeonardoMixerIO/src/Mixer.cpp @@ -1,9 +1,12 @@ - // Mixer.cpp -// TODO License -// Philipp Stenkamp, 2016-11-7 +// Mixer.cpp +// Copyright 2016, 2017 Lukas Friedrichsen, Philipp Stenkamp +// License: Modified BSD-License // // Very basic implementation of an RC mixer. // Mixing can be activated remotely via one of the input channels +// +// 2016-11-07 + #include "Mixer.h" #include "Arduino.h" diff --git a/Systemtechnik/LeonardoMixerIO/src/Mixer.h b/Systemtechnik/LeonardoMixerIO/src/Mixer.h index 3f27e1e..da570d7 100644 --- a/Systemtechnik/LeonardoMixerIO/src/Mixer.h +++ b/Systemtechnik/LeonardoMixerIO/src/Mixer.h @@ -1,6 +1,9 @@ // Mixer.h -// TODO License -// Philipp Stenkamp, 2016-11-7 +// Copyright 2016, 2017 Lukas Friedrichsen, Philipp Stenkamp +// License: Modified BSD-License +// +// 2016-11-07 + #ifndef Mixer_h #define Mixer_h diff --git a/Systemtechnik/LeonardoMixerIO/src/MultiWiiSerial.cpp b/Systemtechnik/LeonardoMixerIO/src/MultiWiiSerial.cpp index 05ec230..4cb6ebb 100755 --- a/Systemtechnik/LeonardoMixerIO/src/MultiWiiSerial.cpp +++ b/Systemtechnik/LeonardoMixerIO/src/MultiWiiSerial.cpp @@ -1,9 +1,12 @@ // MultiWiiSerial.cpp -// TODO License -// Philipp Stenkamp, 2016-11-7 +// Copyright 2016, 2017 Lukas Friedrichsen, Philipp Stenkamp +// License: Modified BSD-License // // Implementation of the MultiWii Serial Protocol for Arduino // http://www.multiwii.com/wiki/index.php?title=Multiwii_Serial_Protocol +// +// 2016-11-07 + #include "MultiWiiSerial.h" #include "Arduino.h" diff --git a/Systemtechnik/LeonardoMixerIO/src/MultiWiiSerial.cpp.lukas b/Systemtechnik/LeonardoMixerIO/src/MultiWiiSerial.cpp.lukas deleted file mode 100644 index 7fd6631..0000000 --- a/Systemtechnik/LeonardoMixerIO/src/MultiWiiSerial.cpp.lukas +++ /dev/null @@ -1,59 +0,0 @@ -#include "MultiWiiSerial.h" -#include "Arduino.h" -#include "RC.h" - -/* - * The general format of an MSP message is: - * <preamble>,<direction>,<size>,<command>,<data>,<crc> - * preamble = the ASCII characters '$M' - * direction = the ASCII character '<' if to the MWC or '>' if from the MWC - * size = number of data bytes, binary. Can be zero as in the case of a data request to the MWC - * command = message_id as per the table below - * data = as per the table below. UINT16 values are LSB first. - * crc = XOR of <size>, <command> and each data byte into a zero'ed sum - */ - -MultiWiiSerial::MultiWiiSerial(rcSource *source) { - _source = source; -} -/* Needed if a reference to an HardwareSerial object is given, needs some logic to decide which type of Serial Object needs to be initialized - -void MultiWiiSerial::init(Serial_ *msp_Serial){ - _Serial = msp_Serial; - _Serial->begin(115200); -} -*/ -void MultiWiiSerial::init(HardwareSerial *msp_Serial){ - _Serial = msp_Serial; - _Serial->begin(115200); -} - -void MultiWiiSerial::SerialEncode() -{ - uint8_t header[] = {'$', 'M', '<', MSP_FRAME_SIZE, 200}; //Fixed header for sending raw RC Data - uint8_t crc = 0; - crc ^= MSP_FRAME_SIZE; - crc ^= 200; - //crc = makeCRC(crc, header + 3, 2); // checksum starts from len field - _Serial->write(header, 5); - for(uint8_t i = 0; i < MSP_FRAME_SIZE/2; i++){ - crc = crc ^ uint8_t(_source->data[i]%256); - _Serial->write(uint8_t(_source->data[i]%256)); - crc = crc ^ uint8_t(_source->data[i]/256); - _Serial->write(uint8_t(_source->data[i]/256)); - } - _Serial->write(crc); -} - - -void MultiWiiSerial::dataReceive(){ - while (_Serial->available() >= MSP_FRAME_SIZE) //DANGEROUS, runtime dependent on serial input, NO REALTIME AT ALL!! - { - _Serial->readBytes(frame, MSP_FRAME_SIZE); - } -} - -uint16_t MultiWiiSerial::readRawRC(uint8_t chan){ - return frame[chan]; - -} diff --git a/Systemtechnik/LeonardoMixerIO/src/MultiWiiSerial.h b/Systemtechnik/LeonardoMixerIO/src/MultiWiiSerial.h index 07230b2..43eeecb 100755 --- a/Systemtechnik/LeonardoMixerIO/src/MultiWiiSerial.h +++ b/Systemtechnik/LeonardoMixerIO/src/MultiWiiSerial.h @@ -1,9 +1,9 @@ // MultiWiiSerial.h -// TODO License -// Philipp Stenkamp, 2016-11-7 +// Copyright 2016, 2017 Lukas Friedrichsen, Philipp Stenkamp +// License: Modified BSD-License // -// Implementation of the MultiWii Serial Protocol for Arduino -// http://www.multiwii.com/wiki/index.php?title=Multiwii_Serial_Protocol +// 2016-11-07 + #ifndef MultiWiiSerial_h #define MultiWiiSerial_h diff --git a/Systemtechnik/LeonardoMixerIO/src/MultiWiiSerial.h.lukas b/Systemtechnik/LeonardoMixerIO/src/MultiWiiSerial.h.lukas deleted file mode 100644 index 261e9d0..0000000 --- a/Systemtechnik/LeonardoMixerIO/src/MultiWiiSerial.h.lukas +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Implementation of the MultiWii Serial Protocol - * http://www.multiwii.com/wiki/index.php?title=Multiwii_Serial_Protocol - * - * - * - * Philipp Stenkamp - 7-11-2016 - */ - -#ifndef MultiWiiSerial_h -#define MultiWiiSerial_h - -#include <stdbool.h> -#include <stdint.h> -#include <stdlib.h> -#include "Arduino.h" -#include "RC.h" - -#define MSP_MAX_SUPPORTED_CHANNEL_COUNT 8 -#define MSP_FRAME_SIZE 8*2 - -class MultiWiiSerial { - public: - MultiWiiSerial(rcSource *source); - //void init(Serial_ *msp_Serial); - void init(HardwareSerial *msp_Serial); - void dataReceive(); - uint16_t readRawRC(uint8_t chan); - - void SerialEncode(); - - private: - HardwareSerial *_Serial; - rcSource *_source; - uint8_t channelCount; - uint16_t rxRefreshRate; - - uint8_t frame[MSP_FRAME_SIZE]; - - uint16_t channelData[MSP_MAX_SUPPORTED_CHANNEL_COUNT]; // shouldn't be channelCount to prevent going out of bounds in case of misconfiguration -}; - -#endif diff --git a/Systemtechnik/LeonardoMixerIO/src/RC.h b/Systemtechnik/LeonardoMixerIO/src/RC.h index 9365377..6e89c06 100644 --- a/Systemtechnik/LeonardoMixerIO/src/RC.h +++ b/Systemtechnik/LeonardoMixerIO/src/RC.h @@ -1,9 +1,9 @@ // RC.h -// TODO License -// Philipp Stenkamp, 2016-11-7 +// Copyright 2016, 2017 Lukas Friedrichsen, Philipp Stenkamp +// License: Modified BSD-License // -// Provides an array of channel data for a given number of channels. -// Can be signed with a timestamp to indicate timeliness of the data. +// 2016-11-07 + #ifndef RC_h #define RC_h diff --git a/Systemtechnik/LeonardoMixerIO/src/RawSerial.cpp b/Systemtechnik/LeonardoMixerIO/src/RawSerial.cpp index 3bc85c6..9e9a032 100755 --- a/Systemtechnik/LeonardoMixerIO/src/RawSerial.cpp +++ b/Systemtechnik/LeonardoMixerIO/src/RawSerial.cpp @@ -1,11 +1,14 @@ // RawSerial.h -// TODO License -// Philipp Stenkamp, 2016-11-7 +// Copyright 2016, 2017 Lukas Friedrichsen, Philipp Stenkamp +// License: Modified BSD-License // // Implementation of a simple serial data protocol. // Primarily meant for use with our OpenCV Android Circle Tracking App -// TODO Project Name -// TODO url +// Visual Based Landing System +// https://gitlab.cvh-server.de/lf.ps/vbls/Visual-Based-Landing-System/ +// +// 2016-11-07 + #include "RawSerial.h" #include "Arduino.h" diff --git a/Systemtechnik/LeonardoMixerIO/src/RawSerial.h b/Systemtechnik/LeonardoMixerIO/src/RawSerial.h index 5f7f48b..923fb4f 100755 --- a/Systemtechnik/LeonardoMixerIO/src/RawSerial.h +++ b/Systemtechnik/LeonardoMixerIO/src/RawSerial.h @@ -1,11 +1,9 @@ // RawSerial.h -// TODO License -// Philipp Stenkamp, 2016-11-7 +// Copyright 2016, 2017 Lukas Friedrichsen, Philipp Stenkamp +// License: Modified BSD-License // -// Implementation of a simple serial RC data protocol. -// Primarily meant for use with our OpenCV Android Circle Tracking App -// TODO Project Name -// TODO url +// 2016-11-07 + #ifndef RawSerial_h #define RawSerial_h diff --git a/Systemtechnik/LeonardoMixerIO/src/Scheduler.cpp b/Systemtechnik/LeonardoMixerIO/src/Scheduler.cpp index b54b214..5bdb1ab 100755 --- a/Systemtechnik/LeonardoMixerIO/src/Scheduler.cpp +++ b/Systemtechnik/LeonardoMixerIO/src/Scheduler.cpp @@ -1,7 +1,11 @@ // Scheduler.cpp -// TODO License -// Lukas Friedrichsen, 2016-12- +// Copyright 2016, 2017 Lukas Friedrichsen, Philipp Stenkamp +// License: Modified BSD-License // +// Implementation of a cooperative multitasking based scheduler for Arduino-devices +// +// 2017-02-10 + #include "Scheduler.h" @@ -244,7 +248,6 @@ void Scheduler::schedule (void) { if (rtTasks) { unsigned long timerDiff = getTaskTimerDiff(rtTasks->listElement); unsigned long cycleTime = getTaskCycleTime((rtTask *) rtTasks->listElement); - //debugger->println("cycle-time: "+(String)cycleTime+" timer-diff: "+(String)timerDiff+" micros: "+(String)micros()); if (timerDiff >= cycleTime) { if (((timerDiff-cycleTime)*100/cycleTime) > OVERLOAD_THRESHOLD_PERCENT) { overloadCounter++; diff --git a/Systemtechnik/LeonardoMixerIO/src/Scheduler.h b/Systemtechnik/LeonardoMixerIO/src/Scheduler.h index 324e773..5f3290b 100755 --- a/Systemtechnik/LeonardoMixerIO/src/Scheduler.h +++ b/Systemtechnik/LeonardoMixerIO/src/Scheduler.h @@ -1,7 +1,9 @@ // Scheduler.h -// TODO License -// Lukas Friedrichsen, 2016-12- +// Copyright 2016, 2017 Lukas Friedrichsen, Philipp Stenkamp +// License: Modified BSD-License // +// 2017-02-10 + #ifndef Scheduler_h #define Scheduler_h diff --git a/Systemtechnik/LeonardoMixerIO/src/Spektrum.cpp b/Systemtechnik/LeonardoMixerIO/src/Spektrum.cpp index 675bfb4..403318b 100755 --- a/Systemtechnik/LeonardoMixerIO/src/Spektrum.cpp +++ b/Systemtechnik/LeonardoMixerIO/src/Spektrum.cpp @@ -1,6 +1,6 @@ // Spektrum.cpp -// TODO License -// Philipp Stenkamp, 2016-11-7 +// Copyright 2016, 2017 Lukas Friedrichsen, Philipp Stenkamp +// License: Modified BSD-License // // Implementation of the Spektrum Satellite Serial Protocol for Arduino // based on the Spektrum Remote Receiver Interfacing Specification @@ -8,6 +8,7 @@ // // In the style of Cleanflight // https://github.com/cleanflight/cleanflight/tree/master/src/main/rx +// 2016-11-07 #include "Spektrum.h" diff --git a/Systemtechnik/LeonardoMixerIO/src/Spektrum.h b/Systemtechnik/LeonardoMixerIO/src/Spektrum.h index 2a58c46..9955dcf 100755 --- a/Systemtechnik/LeonardoMixerIO/src/Spektrum.h +++ b/Systemtechnik/LeonardoMixerIO/src/Spektrum.h @@ -1,12 +1,9 @@ // Spektrum.h -// TODO License -// Philipp Stenkamp, 2016-11-7 +// Copyright 2016, 2017 Lukas Friedrichsen, Philipp Stenkamp +// License: Modified BSD-License // -// Implementation of the Spektrum Remote Receiver Interfacing Specification -// https://www.spektrumrc.com/ProdInfo/Files/Remote%20Receiver%20Interfacing%20Rev%20A.pdf -// -// Partly based on and heavily influenced by Cleanflight -// https://github.com/cleanflight/cleanflight/tree/master/src/main/rx +// 2016-11-07 + #ifndef Spektrum_h #define Spektrum_h -- GitLab