From 3dc030641ca278f43bba7c27390ea9e42cfea361 Mon Sep 17 00:00:00 2001 From: Thomas Pietrzak Date: Tue, 26 Apr 2022 12:34:25 +0200 Subject: [PATCH] Updated serial port, pragma once --- .vscode/launch.json | 1 + README.md | 3 +- TactonDebug/AngleTester/angletester.cpp | 3 +- TactonDebug/AngleTester/angletester.h | 5 +--- TactonDebug/MagicCircle/magiccircle.cpp | 37 ++++++++++--------------- TactonDebug/MagicCircle/magiccircle.h | 5 +--- TactonDebug/TactonDebug/tactondebug.cpp | 3 +- TactonDebug/TactonDebug/tactondebug.h | 5 +--- TactonPlayer/ArduinoSerial | 2 +- TactonPlayer/Tacton.hpp | 5 +--- TactonPlayer/TactonPlayer.hpp | 5 +--- 11 files changed, 28 insertions(+), 46 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index e0ff6cd..9b0c8c7 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -13,6 +13,7 @@ "environment": [], "cwd": "${workspaceFolder}/TactonDebug/AngleTester/", "externalConsole": false, + "stopAtEntry": false, "logging": { "moduleLoad": false, "trace": true diff --git a/README.md b/README.md index bbe6396..3bbb02f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ # TactonLibrary + Arduino library + host PC library + GUI for debugging -# Compiling +## Compiling On VSCode, please use the C/C++ Extension pack. Compiling uses CMake, tested on Mac so far. diff --git a/TactonDebug/AngleTester/angletester.cpp b/TactonDebug/AngleTester/angletester.cpp index 1d75ba7..afa7f2d 100644 --- a/TactonDebug/AngleTester/angletester.cpp +++ b/TactonDebug/AngleTester/angletester.cpp @@ -7,7 +7,8 @@ AngleTester::AngleTester(QWidget *parent, Qt::WindowFlags flags) { try { - _tactonPlayer = new TactonPlayer("COM4"); + //_tactonPlayer = new TactonPlayer("COM4"); + _tactonPlayer = new TactonPlayer("/dev/tty.usbserial-FTFRHUAO"); // Mac USB serial cable } catch(...) { diff --git a/TactonDebug/AngleTester/angletester.h b/TactonDebug/AngleTester/angletester.h index 99f6e44..c0ba714 100644 --- a/TactonDebug/AngleTester/angletester.h +++ b/TactonDebug/AngleTester/angletester.h @@ -1,5 +1,4 @@ -#ifndef ANGLETESTER_H -#define ANGLETESTER_H +#pragma once #include #include "ui_angletester.h" @@ -23,5 +22,3 @@ class AngleTester : public QMainWindow, Ui::AngleTesterClass private: TactonPlayer *_tactonPlayer; }; - -#endif // ANGLETESTER_H diff --git a/TactonDebug/MagicCircle/magiccircle.cpp b/TactonDebug/MagicCircle/magiccircle.cpp index 8887246..07773c8 100644 --- a/TactonDebug/MagicCircle/magiccircle.cpp +++ b/TactonDebug/MagicCircle/magiccircle.cpp @@ -2,18 +2,28 @@ #include +#include +using namespace std; + MagicCircle::MagicCircle(QWidget *parent, Qt::WindowFlags flags) : QMainWindow(parent, flags), _timer(this), _angle(0), _clockwise(true) { try { - _tactonPlayer = new TactonPlayer("COM8"); +// _tactonPlayer = new TactonPlayer("COM8"); + _tactonPlayer = new TactonPlayer("/dev/tty.usbserial-FTFRHUAO"); // Mac USB serial cable } - catch(...) + catch (const char* message) { + cerr << message << endl; _tactonPlayer = NULL; } - + catch (...) + { + cerr << "Error" << endl; + _tactonPlayer = NULL; + } + setupUi(this); layout()->setSizeConstraint(QLayout::SetFixedSize); @@ -27,7 +37,7 @@ MagicCircle::MagicCircle(QWidget *parent, Qt::WindowFlags flags) connect(_play, SIGNAL(clicked(bool)), this, SLOT(play(bool))); connect(_stop, SIGNAL(clicked(bool)), this, SLOT(stop(bool))); - connect(_direction, SIGNAL(currentIndexChanged (const QString &)), this, SLOT(setDirection(const QString &))); + connect(_direction, SIGNAL(currentTextChanged (const QString &)), this, SLOT(setDirection(const QString &))); connect(_speed, SIGNAL(valueChanged(int)), this, SLOT(setSpeed(int))); connect(_resolution, SIGNAL(valueChanged(int)), this, SLOT(setResolution(int))); connect(_frequency, SIGNAL(valueChanged(int)), this, SLOT(setFrequency(int))); @@ -93,25 +103,8 @@ void MagicCircle::setFrequency(int frequency) void MagicCircle::tactileFeedback(float angle) { - _tactonPlayer->playAngle(angle);// * M_PI / 180); + _tactonPlayer->playAngle(angle); return; - - unsigned char amplitudes[4]; - memset(amplitudes, 0, 4); - - //vertical - if (angle < 180) - amplitudes[1] = 255 * sin(angle * M_PI / 180); - else - amplitudes[3] = - 255 * sin(angle * M_PI / 180); - - //horizontal - if (angle < 90 ||angle > 270) - amplitudes[0] = 255 * cos(angle * M_PI / 180); - else - amplitudes[2] = - 255 * cos(angle * M_PI / 180); - - _tactonPlayer->setAmplitudes(4, amplitudes); } void MagicCircle::visualFeedback(float) diff --git a/TactonDebug/MagicCircle/magiccircle.h b/TactonDebug/MagicCircle/magiccircle.h index f23bb4f..b176108 100644 --- a/TactonDebug/MagicCircle/magiccircle.h +++ b/TactonDebug/MagicCircle/magiccircle.h @@ -1,5 +1,4 @@ -#ifndef MAGICCIRCLE_H -#define MAGICCIRCLE_H +#pragma once #include #include "ui_magiccircle.h" @@ -39,5 +38,3 @@ class MagicCircle : public QMainWindow, Ui::MagicCircleClass TactonPlayer *_tactonPlayer; QTimer _timer; }; - -#endif // MAGICCIRCLE_H diff --git a/TactonDebug/TactonDebug/tactondebug.cpp b/TactonDebug/TactonDebug/tactondebug.cpp index 4ebdec3..be6fa45 100644 --- a/TactonDebug/TactonDebug/tactondebug.cpp +++ b/TactonDebug/TactonDebug/tactondebug.cpp @@ -10,7 +10,8 @@ TactonDebug::TactonDebug(QWidget *parent, Qt::WindowFlags flags) { try { - _tactonPlayer = new TactonPlayer("COM4"); + //_tactonPlayer = new TactonPlayer("COM4"); + _tactonPlayer = new TactonPlayer("/dev/tty.usbserial-FTFRHUAO"); // Mac USB serial cable } catch(...) { diff --git a/TactonDebug/TactonDebug/tactondebug.h b/TactonDebug/TactonDebug/tactondebug.h index c385d47..7008b26 100644 --- a/TactonDebug/TactonDebug/tactondebug.h +++ b/TactonDebug/TactonDebug/tactondebug.h @@ -1,5 +1,4 @@ -#ifndef TACTONDEBUG_H -#define TACTONDEBUG_H +#pragma once #include #include "ui_tactondebug.h" @@ -31,5 +30,3 @@ class TactonDebug : public QMainWindow, Ui::TactonDebugClass TactonPlayer *_tactonPlayer; }; - -#endif // TACTONDEBUG_H diff --git a/TactonPlayer/ArduinoSerial b/TactonPlayer/ArduinoSerial index 629e40c..9eb831e 160000 --- a/TactonPlayer/ArduinoSerial +++ b/TactonPlayer/ArduinoSerial @@ -1 +1 @@ -Subproject commit 629e40c4944430c75ef4378a8614471febf44e43 +Subproject commit 9eb831e643bfa4472bdfe757bbbc45ba25cd036b diff --git a/TactonPlayer/Tacton.hpp b/TactonPlayer/Tacton.hpp index 3f7dbc1..47aa994 100644 --- a/TactonPlayer/Tacton.hpp +++ b/TactonPlayer/Tacton.hpp @@ -1,5 +1,4 @@ -#ifndef _TACTON_ -#define _TACTON_ +#pragma once #define POS1_UP_FORWARD 0x01 #define POS1_UP_BACKWARD 0x02 @@ -82,5 +81,3 @@ class EXPORTED Tacton unsigned int *_frequencies; unsigned char *_amplitudes; }; - -#endif diff --git a/TactonPlayer/TactonPlayer.hpp b/TactonPlayer/TactonPlayer.hpp index cd326a5..7f38996 100644 --- a/TactonPlayer/TactonPlayer.hpp +++ b/TactonPlayer/TactonPlayer.hpp @@ -1,5 +1,4 @@ -#ifndef _TACTONPLAYER_ -#define _TACTONPLAYER_ +#pragma once #include "Tacton.hpp" @@ -57,5 +56,3 @@ class EXPORTED TactonPlayer private: Serial *_comport; }; - -#endif -- 2.30.2