Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Geithner, Thomas
desk-control
Commits
5a9fc7a0
Commit
5a9fc7a0
authored
Oct 11, 2017
by
Mall, Anon
Browse files
fixed max min height and stepping problem
parent
0d735a37
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/desk-controller.cpp
View file @
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
=
h
eight
<
MIN_HEIGHT
?
MIN_HEIGHT
:
h
eight
;
m_targetHeight
=
m_targetH
eight
<
MIN_HEIGHT
?
MIN_HEIGHT
:
m_targetH
eight
;
lck
.
unlock
();
cout
<<
__func__
<<
"set height: "
<<
m_targetHeight
<<
endl
;
m_queue
.
addMessage
(
h
eight
);
cout
<<
__func__
<<
"
set height: "
<<
m_targetHeight
<<
endl
;
m_queue
.
addMessage
(
m_targetH
eight
);
}
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
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment