2019-04-07 01:04:34 +02:00
|
|
|
/**
|
|
|
|
* Marlin 3D Printer Firmware
|
2019-06-28 06:57:50 +02:00
|
|
|
* Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
2019-04-07 01:04:34 +02:00
|
|
|
*
|
|
|
|
* Based on Sprinter and grbl.
|
2019-06-28 06:57:50 +02:00
|
|
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
2019-04-07 01:04:34 +02:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "../inc/MarlinConfigPre.h"
|
|
|
|
|
|
|
|
#if IS_CORE || EITHER(BABYSTEP_XY, I2C_POSITION_ENCODERS)
|
|
|
|
#define BS_TODO_AXIS(A) A
|
|
|
|
#else
|
|
|
|
#define BS_TODO_AXIS(A) 0
|
|
|
|
#endif
|
|
|
|
|
2019-09-28 23:58:48 +02:00
|
|
|
#if ENABLED(BABYSTEP_DISPLAY_TOTAL)
|
2019-04-07 01:04:34 +02:00
|
|
|
#if ENABLED(BABYSTEP_XY)
|
|
|
|
#define BS_TOTAL_AXIS(A) A
|
|
|
|
#else
|
|
|
|
#define BS_TOTAL_AXIS(A) 0
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
class Babystep {
|
|
|
|
public:
|
2019-09-16 22:01:46 +02:00
|
|
|
static volatile int16_t steps[BS_TODO_AXIS(Z_AXIS) + 1];
|
2019-09-28 23:58:48 +02:00
|
|
|
static int16_t accum; // Total babysteps in current edit
|
|
|
|
|
|
|
|
#if ENABLED(BABYSTEP_DISPLAY_TOTAL)
|
|
|
|
static int16_t axis_total[BS_TOTAL_AXIS(Z_AXIS) + 1]; // Total babysteps since G28
|
|
|
|
static inline void reset_total(const AxisEnum axis) {
|
|
|
|
if (true
|
|
|
|
#if ENABLED(BABYSTEP_XY)
|
|
|
|
&& axis == Z_AXIS
|
|
|
|
#endif
|
|
|
|
) axis_total[BS_TOTAL_AXIS(axis)] = 0;
|
|
|
|
}
|
2019-04-07 01:04:34 +02:00
|
|
|
#endif
|
2019-09-16 22:01:46 +02:00
|
|
|
|
2019-04-11 01:34:38 +02:00
|
|
|
static void add_steps(const AxisEnum axis, const int16_t distance);
|
2019-04-07 01:04:34 +02:00
|
|
|
static void add_mm(const AxisEnum axis, const float &mm);
|
|
|
|
static void task();
|
|
|
|
private:
|
|
|
|
static void step_axis(const AxisEnum axis);
|
|
|
|
};
|
|
|
|
|
|
|
|
extern Babystep babystep;
|