To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit 01674847 authored by remartin's avatar remartin
Browse files

Minor tinkering.

parent 6fe7ae58
......@@ -53,27 +53,11 @@
//SERIAL COMMUNICATION PARAMETERS
#define MAX_SERIAL_BUFFER_SIZE 180
#define SERIAL_LIGHT_BAUD_RATE B9600
#define SERIAL_BYTE_SIZE 8
#define SERIAL_STOP_BITS 0
#define SERIAL_PARITY 0
#define SERIAL_COMMAND_END '\n'
#define SERIAL_READY_FLAG "-7\n"
#define SERIAL_FLAG_TIMEOUT 1000
#define K_WARNING "\x1B[33m"
#define K_ERROR "\x1B[31m"
#define K_SUCCESS "\x1B[32m"
#define K_NORMAL "\x1B[0m"
#define KBLU "\x1B[34m"
#define KMAG "\x1B[35m"
#define KCYN "\x1B[36m"
#define KWHT "\x1B[37m"
class SerialLight{
public:
SerialLight();
......@@ -87,8 +71,6 @@ public:
// send something through the port.
bool writeSerialLight(const char* buffer);
// redundant
std::string readSerialLight();
private:
int startConnection(const char* port);
......@@ -96,11 +78,6 @@ private:
int tty_fd;
struct termios tio;
std::vector<std::string> _commands;
std::string _cur_command;
std::clock_t timer;
std::string _port;
bool _ready;
bool _isConnected;
};
\ No newline at end of file
......@@ -45,6 +45,7 @@
#include <stdio.h>
#include <cmath>
#include <sstream>
#include <ctime>
#include <iostream>
#include <termios.h> //For serial communication
......@@ -87,6 +88,10 @@ public:
// changes actual coordinates.
void testPTupdater();
// saves applied pan values in a file, along with a timestamp
void lineWithLogging(int panWidth, int brightness, int zoom , double speed);
private:
int posPT; // Where the four PT values start.
......
......@@ -45,9 +45,12 @@ int main(){
spotlightManager slM;
slM.setPTmanually(false);
slM.fullSearchPattern(3, 10, 0);
//slM.setPTmanually(false);
//slM.fullSearchPattern(3, 10, 0);
slM.lineWithLogging(40, 255, 200, 4);
//slM.testPTupdater();
......
......@@ -36,10 +36,8 @@
SerialLight::SerialLight(){
_isConnected = false;
_port = "";
_ready = true;
_cur_command = "";
_isConnected = false;
}
void SerialLight::init(){
......@@ -129,7 +127,6 @@ int SerialLight::startConnection(const char* port){
printf("Set baud rate and stuff. \n");
_port = port;
_ready = true;
_isConnected = true;
//printf("%sConnected\n", K_WARNING);
......@@ -147,15 +144,6 @@ bool SerialLight::isConnected(){
return _isConnected;
}
std::string SerialLight::readSerialLight(){
if (_commands.empty())
return "";
std::string ret = _commands.front();
_commands.erase(_commands.begin());
return ret;
}
bool SerialLight::writeSerialLight(const char* buffer){
if(!_isConnected){
......
......@@ -504,3 +504,45 @@ void spotlightManager::testPTupdater(){
}
}
// saves applied pan values in a file, along with a timestamp
void spotlightManager::lineWithLogging(int panWidth, int brightness, int zoom, double speed){
ofstream panLog;
panLog.open("loggedPanValues.txt", ofstream::out | ofstream::trunc);
panLog << "Dataset with " << brightness << " brightness, " << zoom << " zoom, " << speed << " speed. \n";
panLog.flush();
setPTmanually(false);
double panStep = panWidth/(speed*updateFrequency); // need Precision here.
double delayUs = 1000000/updateFrequency;
double steps = panWidth/panStep;
dmxValues[1] = brightness;
dmxValues[2] = zoom;
sL.writeSerialLight((buildMessage()).c_str());
usleep(1000000); // Wait a second. Looks cooler.
bool bumerang = true;
double precisePan = dmxValues[3] + dmxValues[4]/255.0;
int coarse;
while(true){
// one pass
for(int mm = 0; mm < steps; mm++){
if(bumerang){precisePan+=panStep;}else{precisePan-=panStep;}
// logging
panLog << time(0) << "\t" << precisePan << "\n";
panLog.flush();
// sending
coarse = floor(precisePan);
dmxValues[3] = coarse;
dmxValues[4] = round((precisePan-coarse)*255);
sL.writeSerialLight((buildPT()).c_str());
usleep(delayUs);
}
bumerang = !bumerang;
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment