From c0495a64af01a3482230fb68b238ea36f923ff45 Mon Sep 17 00:00:00 2001 From: EmaMaker Date: Tue, 17 Dec 2019 09:31:36 +0100 Subject: [PATCH] position --- .vscode/extensions.json | 12 ++++++------ include/ds_ctrl_lines.h | 6 +++--- include/ds_ctrl_position.h | 10 ++++++++++ include/sensors.h | 4 ++-- src/ds_ctrl_lines.cpp | 16 ++++++++-------- src/ds_ctrl_position.cpp | 0 src/sensors.cpp | 2 +- 7 files changed, 30 insertions(+), 20 deletions(-) create mode 100644 include/ds_ctrl_position.h create mode 100644 src/ds_ctrl_position.cpp diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 272828b..8281e64 100755 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,7 +1,7 @@ -{ - // See http://go.microsoft.com/fwlink/?LinkId=827846 - // for the documentation about the extensions.json format - "recommendations": [ - "platformio.platformio-ide" - ] +{ + // See http://go.microsoft.com/fwlink/?LinkId=827846 + // for the documentation about the extensions.json format + "recommendations": [ + "platformio.platformio-ide" + ] } \ No newline at end of file diff --git a/include/ds_ctrl_lines.h b/include/ds_ctrl_lines.h index fa330fd..2967f15 100755 --- a/include/ds_ctrl_lines.h +++ b/include/ds_ctrl_lines.h @@ -16,11 +16,11 @@ #define LINE_THRESH 90 #define EXTIME 100 -class DataSourceCtrlLines : public DataSourceCtrl { +class DSCtrlLines : public DataSourceCtrl { public: - DataSourceCtrlLines(); - DataSourceCtrlLines(vector in_, vector out); + DSCtrlLines(); + DSCtrlLines(vector in_, vector out); void read() override; void postProcess() override; diff --git a/include/ds_ctrl_position.h b/include/ds_ctrl_position.h new file mode 100644 index 0000000..2bcad65 --- /dev/null +++ b/include/ds_ctrl_position.h @@ -0,0 +1,10 @@ +#include "vars.h" +#include "ds_ctrl.h" +#include "ds_ctrl_lines.h" + +class DSCtrlPosition : public DataSourceController { + + public: + DSCtrlPosition(); + +}; \ No newline at end of file diff --git a/include/sensors.h b/include/sensors.h index b50067b..9907900 100755 --- a/include/sensors.h +++ b/include/sensors.h @@ -25,8 +25,8 @@ s_extr vector lIn; s_extr vector lOut; s_extr vector dUs; -s_extr DataSourceCtrl* usCtrl; -s_extr DataSourceCtrlLines* linesCtrl; +s_extr DSCtrlLines* usCtrl; +s_extr DSCtrlLines* linesCtrl; s_extr DataSourceBNO055* compass; s_extr DataSourceBall* ball; diff --git a/src/ds_ctrl_lines.cpp b/src/ds_ctrl_lines.cpp index f973b5c..61cbad4 100755 --- a/src/ds_ctrl_lines.cpp +++ b/src/ds_ctrl_lines.cpp @@ -2,8 +2,8 @@ #include "sensors.h" using namespace std; -DataSourceCtrlLines::DataSourceCtrlLines() {} -DataSourceCtrlLines::DataSourceCtrlLines(vector in_, vector out_){ +DSCtrlLines::DSCtrlLines() {} +DSCtrlLines::DSCtrlLines(vector in_, vector out_){ this->in = in_; this->out = out_; @@ -24,7 +24,7 @@ DataSourceCtrlLines::DataSourceCtrlLines(vector in_, vectorreadSensor(); @@ -49,7 +49,7 @@ void DataSourceCtrlLines::read(){ inV = inV | outV; } -void DataSourceCtrlLines::postProcess(){ +void DSCtrlLines::postProcess(){ if ((inV > 0) || (outV > 0)) { fboundsOX = true; fboundsOY = true; @@ -63,12 +63,12 @@ void DataSourceCtrlLines::postProcess(){ outOfBounds(); } -void DataSourceCtrlLines::outOfBounds(){ +void DSCtrlLines::outOfBounds(){ handleExtern(); handleIntern(); } -void DataSourceCtrlLines::handleIntern(){ +void DSCtrlLines::handleIntern(){ if(fboundsX == true) { if(inV & 0x02) inVOldX = 2; @@ -162,14 +162,14 @@ void DataSourceCtrlLines::handleIntern(){ else slow = false; } -void DataSourceCtrlLines::handleExtern(){ +void DSCtrlLines::handleExtern(){ if((outV & 0b00000001) == 1) drive->vyp = 1; // esclusione if((outV & 0b00000100) == 4) drive->vyn = 1; if((outV & 0b00000010) == 2) drive->vxp = 1; if((outV & 0b00001000) == 8) drive->vxn = 1; } -void DataSourceCtrlLines::test(){ +void DSCtrlLines::test(){ update(); DEBUG.print("In: "); for(DataSource* d : in){ diff --git a/src/ds_ctrl_position.cpp b/src/ds_ctrl_position.cpp new file mode 100644 index 0000000..e69de29 diff --git a/src/sensors.cpp b/src/sensors.cpp index 6fb504f..3597fe6 100755 --- a/src/sensors.cpp +++ b/src/sensors.cpp @@ -16,7 +16,7 @@ void initSensors(){ ball = new DataSourceBall(&Serial4, 57600); camera = new DataSourceCamera(&Serial2, 19200); usCtrl = new DataSourceCtrl(dUs); - linesCtrl = new DataSourceCtrlLines(lIn, lOut); + linesCtrl = new DSCtrlLines(lIn, lOut); bt = new DataSourceBT(&Serial3, 115200); /*game = new Game();