Browse Source

For FTDI800 compatibility, remove VERTEX_FORMAT dependency (#18982)

Marcio T 3 years ago
parent
commit
f62578efec
No account linked to committer's email address

+ 14
- 3
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_screen.cpp View File

88
 
88
 
89
   const float scale_z = ((val_max == val_min) ? 1 : 1/(val_max - val_min)) * autoscale_max;
89
   const float scale_z = ((val_max == val_min) ? 1 : 1/(val_max - val_min)) * autoscale_max;
90
 
90
 
91
-  // These equations determine the appearance of the grid on the screen.
91
+  /**
92
+   * The 3D points go through a 3D graphics pipeline to determine the final 2D point on the screen.
93
+   * This is written out as a stack of macros that each apply an affine transformation to the point.
94
+   * At compile time, the compiler should be able to reduce these expressions.
95
+   *
96
+   * The last transformation in the chain (TRANSFORM_5) is initially set to a no-op so we can measure
97
+   * the dimensions of the grid, but is later replaced with a scaling transform that scales the grid
98
+   * to fit.
99
+   */
92
 
100
 
93
   #define TRANSFORM_5(X,Y,Z)  (X), (Y)                                                                   // No transform
101
   #define TRANSFORM_5(X,Y,Z)  (X), (Y)                                                                   // No transform
94
   #define TRANSFORM_4(X,Y,Z)  TRANSFORM_5((X)/(Z),(Y)/-(Z), 0)                                           // Perspective
102
   #define TRANSFORM_4(X,Y,Z)  TRANSFORM_5((X)/(Z),(Y)/-(Z), 0)                                           // Perspective
119
   const float center_x         = x + w/2;
127
   const float center_x         = x + w/2;
120
   const float center_y         = y + h/2;
128
   const float center_y         = y + h/2;
121
 
129
 
130
+  // Now replace the last transformation in the chain with a scaling operation.
131
+
122
   #undef  TRANSFORM_5
132
   #undef  TRANSFORM_5
123
-  #define TRANSFORM_5(X,Y,Z)  center_x + (X - grid_cx) * scale_x, center_y + (Y - grid_cy) * scale_y      // Fit to bounds
133
+  #define TRANSFORM_6(X,Y,Z)  (X)*16, (Y)*16                                                  // Scale to 1/16 pixel units
134
+  #define TRANSFORM_5(X,Y,Z)  TRANSFORM_6( center_x + ((X) - grid_cx) * scale_x, \
135
+                                           center_y + ((Y) - grid_cy) * scale_y, 0)           // Scale to bounds
124
 
136
 
125
   // Draw the grid
137
   // Draw the grid
126
 
138
 
128
 
140
 
129
   CommandProcessor cmd;
141
   CommandProcessor cmd;
130
   cmd.cmd(SAVE_CONTEXT())
142
   cmd.cmd(SAVE_CONTEXT())
131
-     .cmd(VERTEX_FORMAT(0))
132
      .cmd(TAG_MASK(false))
143
      .cmd(TAG_MASK(false))
133
      .cmd(SAVE_CONTEXT());
144
      .cmd(SAVE_CONTEXT());
134
 
145
 

Loading…
Cancel
Save