mirror of
https://github.com/Klipper3d/klipper.git
synced 2026-10-21 02:59:56 -05:00
trigger_analog: Fix TT_ABS_GE handling on AVR mcu
The abs() function on AVR only handles 16-bit integers. Implement it manually. Reported by @kmatzen. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
1 parent
9c1ae230ea
commit
cab2f00408
1 file changed
+2
-2
@@ -5,7 +5,6 @@
|
||||
//
|
||||
// This file may be distributed under the terms of the GNU GPLv3 license.
|
||||
|
||||
#include <stdlib.h> // abs
|
||||
#include "basecmd.h" // oid_alloc
|
||||
#include "board/io.h" // writeb
|
||||
#include "board/misc.h" // timer_read_time
|
||||
@@ -90,7 +89,8 @@ check_trigger(struct trigger_analog *ta, uint32_t time, int32_t value)
|
||||
{
|
||||
switch (ta->trigger_type) {
|
||||
case TT_ABS_GE:
|
||||
return abs(value) >= ta->trigger_value;
|
||||
uint32_t abs_value = value < 0 ? -value : value;
|
||||
return abs_value >= ta->trigger_value;
|
||||
case TT_GT:
|
||||
return value > ta->trigger_value;
|
||||
case TT_DIFF_PEAK_GT:
|
||||
|
||||
Reference in new issue
Block a user