Commit da0434a6 authored by Mall, Anon's avatar Mall, Anon
Browse files

fixed max min height and stepping problem

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