Commit 68237c98 authored by Geithner, Thomas's avatar Geithner, Thomas
Browse files

Merge branch 'master' of gitlab.dai-labor.de:30223/desk-control

parents d0853790 5a9fc7a0
......@@ -16,7 +16,7 @@ using namespace desk;
using namespace usb2lin06;
#define MIN_HEIGHT 0
#define MAX_HEIGHT 52
#define MAX_HEIGHT 68
#define STOP_DELAY 2
#define SMALL_STEP_TIME 220
......@@ -63,6 +63,8 @@ Controller::setOffset(int offset)
f_out << m_offset;
f_out.close();
}
m_maxHeight = m_offset + MAX_HEIGHT;
m_minHeight = m_offset + MIN_HEIGHT;
}
int
......@@ -162,11 +164,12 @@ LinakDesk::setHeight(int height)
{
cout << __func__ << ": " << height << endl;
unique_lock<mutex> lck(m_cmdMutex);
height -= m_offset;
m_targetHeight = height > MAX_HEIGHT? MAX_HEIGHT : height;
m_targetHeight = height < MIN_HEIGHT? MIN_HEIGHT : height;
m_targetHeight = m_targetHeight < MIN_HEIGHT? MIN_HEIGHT : m_targetHeight;
lck.unlock();
cout << __func__ << "set height: " << m_targetHeight << endl;
m_queue.addMessage(height);
cout << __func__ << " set height: " << m_targetHeight << endl;
m_queue.addMessage(m_targetHeight);
}
int
......@@ -243,6 +246,7 @@ LinakDesk::doDeskControl(void)
m_currentHeight = getInternalHeight();
lck.unlock();
cout << "currentHeight=" << m_currentHeight << endl;
cout << "target_height=" << target_height << endl;
if (target_height >= (m_currentHeight - STOP_DELAY) && target_height <= (m_currentHeight + STOP_DELAY) && !m_smallStep)
{
......@@ -272,7 +276,6 @@ LinakDesk::doDeskControl(void)
}
}
} while (m_finished == true);
target_height -= m_offset;
uint delta = abs(m_currentHeight - target_height);
m_smallStep = (delta <= STOP_DELAY) ? true : false;
}
......@@ -302,11 +305,13 @@ LinakDesk::doDeskControl(void)
}
else if (m_currentHeight < target_height)
{
cout << "up" << endl;
bool state = move(Command::up);
usleep(10000);
}
else
{
cout << "down" << endl;
bool state = move(Command::down);
usleep(10000);
}
......
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