Welcome to mirror list, hosted at ThFree Co, Russian Federation.

marlin_1.h « ArcWelderInverseProcessor - github.com/FormerLurker/ArcWelderLib.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0fc11c48be14f3a97713533f7acbe06db57bc8dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Arc Welder: Marlin 1 arc interpolation simulator.  Please see the copyright notices in the function definitions
// starting with plan_arc_ for the original license.
//
// Converts G2/G3(arc) commands back to G0/G1 commands.  Intended to test firmware changes to improve arc support.
// This reduces file size and the number of gcodes per second.
//
// Built using the 'Arc Welder: Anti Stutter' library
//
// Copyright(C) 2021 - Brad Hochgesang
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// This program is free software : you can redistribute it and/or modify
// it under the terms of the GNU Affero 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 Affero General Public License for more details.
//
//
// You can contact the author at the following email address: 
// FormerLurker@pm.me
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#pragma once
#include "firmware.h"

#define NUM_MARLIN_1_FIRMWARE_VERSIONS 1


#define MARLIN_XYZE 5

class marlin_1 :
  public firmware
{
public:
  enum class marlin_1_firmware_versions { V1_1_9_1 = 0 };
  /// <summary>
  /// Types and enums taken from https://github.com/MarlinFirmware/Marlin/blob/1314b31d97bba8cd74c6625c47176d4692f57790/Marlin/enum.h
  /// Note that HANGPRINTER has been disabled to reduce impementation complexity
  /// </summary>
  enum AxisEnum : unsigned char {
    X_AXIS = 0,
    A_AXIS = 0,
    Y_AXIS = 1,
    B_AXIS = 1,
    Z_AXIS = 2,
    C_AXIS = 2,
    E_CART = 3,
//#if ENABLED(HANGPRINTER) // Hangprinter order: A_AXIS, B_AXIS, C_AXIS, D_AXIS, E_AXIS
//    D_AXIS = 3,
//    E_AXIS = 4,
//#else
    E_AXIS = 3,
//#endif
    X_HEAD, Y_HEAD, Z_HEAD,
    ALL_AXES = 0xFE,
    NO_AXIS = 0xFF
  };
  
  marlin_1(firmware_arguments args);
  virtual ~marlin_1();
  virtual std::string interpolate_arc(firmware_position& target, double i, double j, double r, bool is_clockwise) override;
  virtual firmware_arguments get_default_arguments_for_current_version() const override;
  virtual void apply_arguments() override;
private:
  marlin_1_firmware_versions marlin_1_version_;
  std::string gcodes_;
  float* current_position;
  float feedrate_mm_s;
  
  /// <summary>
  /// A struct representing the prusa configuration store.  Note:  I didn't add the trailing underscore so this variable name will match the original source algorithm name.
  /// </summary>
  typedef void(marlin_1::* plan_arc_func)(const float(&cart)[MARLIN_XYZE], // Destination position
    const float(&offset)[2], // Center of rotation relative to current_position
    const bool clockwise      // Clockwise?
  );
  
  void plan_arc_1_1_9_1(const float(&cart)[MARLIN_XYZE], // Destination position
    const float(&offset)[2], // Center of rotation relative to current_position
    const bool clockwise      // Clockwise?
  );
  
  plan_arc_func plan_arc_;
  // Marlin Function Defs
  void NOLESS(uint16_t& x, uint16_t y);
  float MMS_SCALED(float x);
  void COPY(float target[MARLIN_XYZE], const float (&source)[MARLIN_XYZE]);
  bool buffer_line_kinematic(const float (&cart)[MARLIN_XYZE], double fr_mm_s, int active_extruder);
  void clamp_to_software_endstops(const float (&raw)[MARLIN_XYZE]);
};