ソースを参照

Fix G26 circles (#9627)

Easier to configure. Catch an odd divisor.
Scott Lahteine 7年前
コミット
6a70a4fbb3
コミッターのメールアドレスに関連付けられたアカウントが存在しません
1個のファイルの変更10行の追加6行の削除
  1. 10
    6
      Marlin/src/gcode/bedlevel/G26.cpp

+ 10
- 6
Marlin/src/gcode/bedlevel/G26.cpp ファイルの表示

738
   /**
738
   /**
739
    * Pre-generate radius offset values at 30 degree intervals to reduce CPU load.
739
    * Pre-generate radius offset values at 30 degree intervals to reduce CPU load.
740
    */
740
    */
741
-
742
-  #define A_CNT ((360 / 30) / 2)  // must be a multiple of 2 for _COS() and _SIN() macro to work correctly!
743
-  #define NEGATION_of_COS_TABLE(A) (((A + A_CNT * 16) % (A_CNT * 2)) >= A_CNT ? -1 : 1) 
744
-  #define _COS(A) (trig_table[(A + A_CNT * 16) % A_CNT] * NEGATION_of_COS_TABLE(A))
745
-  #define _SIN(A) (-_COS((A + A_CNT / 2) % (A_CNT * 2)))
741
+  #define A_INT 30
742
+  #define _ANGS (360 / A_INT)
743
+  #define A_CNT (_ANGS / 2)
744
+  #define _IND(A) ((A + _ANGS * 8) % _ANGS)
745
+  #define _COS(A) (trig_table[_IND(A) % A_CNT] * (_IND(A) >= A_CNT ? -1 : 1))
746
+  #define _SIN(A) (-_COS((A + A_CNT / 2) % _ANGS))
747
+  #if A_CNT & 1
748
+    #error "A_CNT must be a positive value. Please change A_INT."
749
+  #endif
746
   float trig_table[A_CNT];
750
   float trig_table[A_CNT];
747
   for (uint8_t i = 0; i < A_CNT; i++)
751
   for (uint8_t i = 0; i < A_CNT; i++)
748
-    trig_table[i] = INTERSECTION_CIRCLE_RADIUS * cos(RADIANS(i * 30));
752
+    trig_table[i] = INTERSECTION_CIRCLE_RADIUS * cos(RADIANS(i * A_INT));
749
 
753
 
750
   mesh_index_pair location;
754
   mesh_index_pair location;
751
   do {
755
   do {

読み込み中…
キャンセル
保存