Skip to content

Commit 8f14b20

Browse files
Bob-the-KuhnTracy Spiva
authored and
Tracy Spiva
committed
✨ AnyCubic Vyper / Vyper LCD (MarlinFirmware#25405)
1 parent ee8e595 commit 8f14b20

39 files changed

+4951
-53
lines changed

Marlin/Configuration.h

+12-4
Original file line numberDiff line numberDiff line change
@@ -3150,15 +3150,23 @@
31503150
//#define TOUCH_UI_FTDI_EVE
31513151

31523152
//
3153-
// Touch-screen LCD for Anycubic printers
3153+
// Touch-screen LCD for Anycubic Chiron
31543154
//
3155-
//#define ANYCUBIC_LCD_I3MEGA
31563155
//#define ANYCUBIC_LCD_CHIRON
3157-
#if EITHER(ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON)
3158-
//#define ANYCUBIC_LCD_DEBUG
3156+
3157+
//
3158+
// Touch-screen LCD for Anycubic i3 Mega
3159+
//
3160+
//#define ANYCUBIC_LCD_I3MEGA
3161+
#if ENABLED(ANYCUBIC_LCD_I3MEGA)
31593162
//#define ANYCUBIC_LCD_GCODE_EXT // Add ".gcode" to menu entries for DGUS clone compatibility
31603163
#endif
31613164

3165+
//
3166+
// Touch-screen LCD for Anycubic Vyper
3167+
//
3168+
//#define ANYCUBIC_LCD_VYPER
3169+
31623170
//
31633171
// 320x240 Nextion 2.8" serial TFT Resistive Touch Screen NX3224T028
31643172
//

Marlin/Configuration_adv.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1976,7 +1976,7 @@
19761976
//
19771977
// Specify additional languages for the UI. Default specified by LCD_LANGUAGE.
19781978
//
1979-
#if ANY(DOGLCD, TFT_COLOR_UI, TOUCH_UI_FTDI_EVE, IS_DWIN_MARLINUI)
1979+
#if ANY(DOGLCD, TFT_COLOR_UI, TOUCH_UI_FTDI_EVE, IS_DWIN_MARLINUI, ANYCUBIC_LCD_VYPER)
19801980
//#define LCD_LANGUAGE_2 fr
19811981
//#define LCD_LANGUAGE_3 de
19821982
//#define LCD_LANGUAGE_4 es

Marlin/src/HAL/LPC1768/HAL.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,9 @@ class MarlinHAL {
249249
static bool adc_ready() { return LPC176x::adc_hardware.done(LPC176x::pin_get_adc_channel(adc_pin)); }
250250

251251
// The current value of the ADC register
252-
static uint16_t adc_value() {
252+
static uint16_t adc_value() {
253253
adc_result = FilteredADC::read(adc_pin) >> (16 - HAL_ADC_RESOLUTION); // returns 16bit value, reduce to required bits
254-
return uint16_t(adc_result);
254+
return uint16_t(adc_result);
255255
}
256256

257257
/**

Marlin/src/core/boards.h

+1
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@
382382
#define BOARD_ERYONE_ERY32_MINI 5065 // Eryone Ery32 mini (STM32F103VE)
383383
#define BOARD_PANDA_PI_V29 5066 // Panda Pi V2.9 - Standalone (STM32F103RC)
384384
#define BOARD_SOVOL_V131 5067 // Sovol V1.3.1 (GD32F103RET6)
385+
#define BOARD_TRIGORILLA_V006 5068 // Trigorilla V0.0.6 (GD32F103RE)
385386

386387
//
387388
// ARM Cortex-M4F

Marlin/src/feature/bedlevel/abl/bbl.cpp

+14-19
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,13 @@ void LevelingBilinear::print_leveling_grid(const bed_mesh_t* _z_values/*=nullptr
175175
xy_float_t LevelingBilinear::grid_factor_virt;
176176

177177
#define LINEAR_EXTRAPOLATION(E, I) ((E) * 2 - (I))
178-
float LevelingBilinear::bed_level_virt_coord(const uint8_t x, const uint8_t y) {
178+
float LevelingBilinear::virt_coord(const uint8_t x, const uint8_t y) {
179179
uint8_t ep = 0, ip = 1;
180180
if (x > (GRID_MAX_POINTS_X) + 1 || y > (GRID_MAX_POINTS_Y) + 1) {
181181
// The requested point requires extrapolating two points beyond the mesh.
182182
// These values are only requested for the edges of the mesh, which are always an actual mesh point,
183183
// and do not require interpolation. When interpolation is not needed, this "Mesh + 2" point is
184-
// cancelled out in bed_level_virt_cmr and does not impact the result. Return 0.0 rather than
184+
// cancelled out in virt_cmr and does not impact the result. Return 0.0 rather than
185185
// making this function more complex by extrapolating two points.
186186
return 0.0;
187187
}
@@ -197,8 +197,8 @@ void LevelingBilinear::print_leveling_grid(const bed_mesh_t* _z_values/*=nullptr
197197
);
198198
else
199199
return LINEAR_EXTRAPOLATION(
200-
bed_level_virt_coord(ep + 1, y),
201-
bed_level_virt_coord(ip + 1, y)
200+
virt_coord(ep + 1, y),
201+
virt_coord(ip + 1, y)
202202
);
203203
}
204204
if (!y || y == ABL_TEMP_POINTS_Y - 1) {
@@ -213,14 +213,14 @@ void LevelingBilinear::print_leveling_grid(const bed_mesh_t* _z_values/*=nullptr
213213
);
214214
else
215215
return LINEAR_EXTRAPOLATION(
216-
bed_level_virt_coord(x, ep + 1),
217-
bed_level_virt_coord(x, ip + 1)
216+
virt_coord(x, ep + 1),
217+
virt_coord(x, ip + 1)
218218
);
219219
}
220220
return z_values[x - 1][y - 1];
221221
}
222222

223-
float LevelingBilinear::bed_level_virt_cmr(const float p[4], const uint8_t i, const float t) {
223+
float LevelingBilinear::virt_cmr(const float p[4], const uint8_t i, const float t) {
224224
return (
225225
p[i-1] * -t * sq(1 - t)
226226
+ p[i] * (2 - 5 * sq(t) + 3 * t * sq(t))
@@ -229,18 +229,18 @@ void LevelingBilinear::print_leveling_grid(const bed_mesh_t* _z_values/*=nullptr
229229
) * 0.5f;
230230
}
231231

232-
float LevelingBilinear::bed_level_virt_2cmr(const uint8_t x, const uint8_t y, const_float_t tx, const_float_t ty) {
232+
float LevelingBilinear::virt_2cmr(const uint8_t x, const uint8_t y, const_float_t tx, const_float_t ty) {
233233
float row[4], column[4];
234234
LOOP_L_N(i, 4) {
235235
LOOP_L_N(j, 4) {
236-
column[j] = bed_level_virt_coord(i + x - 1, j + y - 1);
236+
column[j] = virt_coord(i + x - 1, j + y - 1);
237237
}
238-
row[i] = bed_level_virt_cmr(column, 1, ty);
238+
row[i] = virt_cmr(column, 1, ty);
239239
}
240-
return bed_level_virt_cmr(row, 1, tx);
240+
return virt_cmr(row, 1, tx);
241241
}
242242

243-
void LevelingBilinear::bed_level_virt_interpolate() {
243+
void LevelingBilinear::subdivide_mesh() {
244244
grid_spacing_virt = grid_spacing / (BILINEAR_SUBDIVISIONS);
245245
grid_factor_virt = grid_spacing_virt.reciprocal();
246246
LOOP_L_N(y, GRID_MAX_POINTS_Y)
@@ -250,20 +250,15 @@ void LevelingBilinear::print_leveling_grid(const bed_mesh_t* _z_values/*=nullptr
250250
if ((ty && y == (GRID_MAX_POINTS_Y) - 1) || (tx && x == (GRID_MAX_POINTS_X) - 1))
251251
continue;
252252
z_values_virt[x * (BILINEAR_SUBDIVISIONS) + tx][y * (BILINEAR_SUBDIVISIONS) + ty] =
253-
bed_level_virt_2cmr(
254-
x + 1,
255-
y + 1,
256-
(float)tx / (BILINEAR_SUBDIVISIONS),
257-
(float)ty / (BILINEAR_SUBDIVISIONS)
258-
);
253+
virt_2cmr(x + 1, y + 1, (float)tx / (BILINEAR_SUBDIVISIONS), (float)ty / (BILINEAR_SUBDIVISIONS));
259254
}
260255
}
261256

262257
#endif // ABL_BILINEAR_SUBDIVISION
263258

264259
// Refresh after other values have been updated
265260
void LevelingBilinear::refresh_bed_level() {
266-
TERN_(ABL_BILINEAR_SUBDIVISION, bed_level_virt_interpolate());
261+
TERN_(ABL_BILINEAR_SUBDIVISION, subdivide_mesh());
267262
cached_rel.x = cached_rel.y = -999.999;
268263
cached_g.x = cached_g.y = -99;
269264
}

Marlin/src/feature/bedlevel/abl/bbl.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ class LevelingBilinear {
4343
static xy_pos_t grid_spacing_virt;
4444
static xy_float_t grid_factor_virt;
4545

46-
static float bed_level_virt_coord(const uint8_t x, const uint8_t y);
47-
static float bed_level_virt_cmr(const float p[4], const uint8_t i, const float t);
48-
static float bed_level_virt_2cmr(const uint8_t x, const uint8_t y, const_float_t tx, const_float_t ty);
49-
static void bed_level_virt_interpolate();
46+
static float virt_coord(const uint8_t x, const uint8_t y);
47+
static float virt_cmr(const float p[4], const uint8_t i, const float t);
48+
static float virt_2cmr(const uint8_t x, const uint8_t y, const_float_t tx, const_float_t ty);
49+
static void subdivide_mesh();
5050
#endif
5151

5252
public:

Marlin/src/feature/powerloss.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ void PrintJobRecovery::changed() {
113113
purge();
114114
else if (IS_SD_PRINTING())
115115
save(true);
116-
TERN_(EXTENSIBLE_UI, ExtUI::onSetPowerLoss(onoff));
116+
TERN_(EXTENSIBLE_UI, ExtUI::onSetPowerLoss(enabled));
117117
}
118118

119119
/**

Marlin/src/gcode/queue.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,24 @@ static bool serial_data_available(serial_index_t index) {
303303

304304
inline int read_serial(const serial_index_t index) { return SERIAL_IMPL.read(index); }
305305

306+
#if (defined(ARDUINO_ARCH_STM32F4) || defined(ARDUINO_ARCH_STM32)) && defined(USBCON)
307+
308+
/**
309+
* arduinoststm32's USB receive buffer is not well behaved when the buffer overflows
310+
*
311+
* This can happen when the host programs (such as Pronterface) automatically
312+
* send M105 temperature requests.
313+
*/
314+
void GCodeQueue::flush_rx() {
315+
// Flush receive buffer
316+
LOOP_L_N(p, NUM_SERIAL) {
317+
if (!serial_data_available(p)) continue; // No data for this port? Skip.
318+
while (SERIAL_IMPL.available(p)) (void)read_serial(p);
319+
}
320+
}
321+
322+
#endif // (ARDUINO_ARCH_STM32F4 || ARDUINO_ARCH_STM32) && USBCON
323+
306324
void GCodeQueue::gcode_line_error(FSTR_P const ferr, const serial_index_t serial_ind) {
307325
PORT_REDIRECT(SERIAL_PORTMASK(serial_ind)); // Reply to the serial port that sent the command
308326
SERIAL_ERROR_START();

Marlin/src/gcode/queue.h

+6
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,12 @@ class GCodeQueue {
201201
*/
202202
static void flush_and_request_resend(const serial_index_t serial_ind);
203203

204+
#if (defined(ARDUINO_ARCH_STM32F4) || defined(ARDUINO_ARCH_STM32)) && defined(USBCON)
205+
static void flush_rx();
206+
#else
207+
static void flush_rx() {}
208+
#endif
209+
204210
/**
205211
* (Re)Set the current line number for the last received command
206212
*/

Marlin/src/gcode/temp/M303.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#if HAS_PID_HEATING
2626

2727
#include "../gcode.h"
28+
#include "../queue.h" // for flush_tx
2829
#include "../../lcd/marlinui.h"
2930
#include "../../module/temperature.h"
3031

@@ -85,6 +86,8 @@ void GcodeSuite::M303() {
8586
LCD_MESSAGE(MSG_PID_AUTOTUNE);
8687
thermalManager.PID_autotune(temp, hid, c, u);
8788
ui.reset_status();
89+
90+
queue.flush_rx();
8891
}
8992

9093
#endif // HAS_PID_HEATING

Marlin/src/inc/Conditionals_LCD.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -477,15 +477,15 @@
477477
#endif
478478

479479
// Aliases for LCD features
480-
#if !DGUS_UI_IS(NONE)
480+
#if !DGUS_UI_IS(NONE) || ENABLED(ANYCUBIC_LCD_VYPER)
481481
#define HAS_DGUS_LCD 1
482482
#if DGUS_UI_IS(ORIGIN, FYSETC, HIPRECY, MKS)
483483
#define HAS_DGUS_LCD_CLASSIC 1
484484
#endif
485485
#endif
486486

487487
// Extensible UI serial touch screens. (See src/lcd/extui)
488-
#if ANY(HAS_DGUS_LCD, MALYAN_LCD, TOUCH_UI_FTDI_EVE, ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON, NEXTION_TFT)
488+
#if ANY(HAS_DGUS_LCD, MALYAN_LCD, TOUCH_UI_FTDI_EVE, ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON, ANYCUBIC_LCD_VYPER, NEXTION_TFT)
489489
#define IS_EXTUI 1
490490
#define EXTENSIBLE_UI
491491
#endif

Marlin/src/inc/SanityCheck.h

+7-3
Original file line numberDiff line numberDiff line change
@@ -3140,7 +3140,7 @@ static_assert(X_MAX_LENGTH >= X_BED_SIZE, "Movement bounds (X_MIN_POS, X_MAX_POS
31403140
+ (ENABLED(EXTENSIBLE_UI) && DISABLED(IS_EXTUI)) \
31413141
+ (DISABLED(IS_LEGACY_TFT) && ENABLED(TFT_GENERIC)) \
31423142
+ (ENABLED(IS_LEGACY_TFT) && COUNT_ENABLED(TFT_320x240, TFT_320x240_SPI, TFT_480x320, TFT_480x320_SPI)) \
3143-
+ COUNT_ENABLED(ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON, ANYCUBIC_TFT35) \
3143+
+ COUNT_ENABLED(ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON, ANYCUBIC_TFT35, ANYCUBIC_LCD_VYPER) \
31443144
+ DGUS_UI_IS(ORIGIN) + DGUS_UI_IS(FYSETC) + DGUS_UI_IS(HIPRECY) + DGUS_UI_IS(MKS) + DGUS_UI_IS(RELOADED) + DGUS_UI_IS(IA_CREALITY) \
31453145
+ COUNT_ENABLED(ENDER2_STOCKDISPLAY, CR10_STOCKDISPLAY) \
31463146
+ COUNT_ENABLED(DWIN_CREALITY_LCD, DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI, DWIN_MARLINUI_PORTRAIT, DWIN_MARLINUI_LANDSCAPE) \
@@ -3254,6 +3254,10 @@ static_assert(X_MAX_LENGTH >= X_BED_SIZE, "Movement bounds (X_MIN_POS, X_MAX_POS
32543254
#endif
32553255
#endif
32563256

3257+
#if ENABLED(ANYCUBIC_LCD_VYPER)
3258+
static_assert(strcmp(STRINGIFY(LCD_LANGUAGE_2), "zh_CN") == 0, "LCD_LANGUAGE_2 must be set to zh_CN for ANYCUBIC_LCD_VYPER.");
3259+
#endif
3260+
32573261
#if EITHER(MKS_TS35_V2_0, BTT_TFT35_SPI_V1_0) && SD_CONNECTION_IS(LCD)
32583262
#error "SDCARD_CONNECTION cannot be set to LCD for the enabled TFT. No available SD card reader."
32593263
#endif
@@ -3353,8 +3357,8 @@ static_assert(X_MAX_LENGTH >= X_BED_SIZE, "Movement bounds (X_MIN_POS, X_MAX_POS
33533357
#else
33543358
#if HAS_DGUS_LCD
33553359
#error "The DGUS LCD requires LCD_SERIAL_PORT to be defined."
3356-
#elif EITHER(ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON)
3357-
#error "The ANYCUBIC LCD requires LCD_SERIAL_PORT to be defined."
3360+
#elif ANY(ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON, ANYCUBIC_LCD_VYPER)
3361+
#error "ANYCUBIC_LCD_* requires LCD_SERIAL_PORT to be defined."
33583362
#elif ENABLED(MALYAN_LCD)
33593363
#error "MALYAN_LCD requires LCD_SERIAL_PORT to be defined."
33603364
#elif ENABLED(NEXTION_LCD)

Marlin/src/inc/Warnings.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -780,8 +780,8 @@
780780
/**
781781
* GD32 is not exactly like STM32
782782
*/
783-
#if MB(SOVOL_V131)
784-
#warning "GD32 based controllers may not be fully compatible with Maple Generic STM32F103RE. Please report any issues."
783+
#if MB(SOVOL_V131, TRIGORILLA_V006)
784+
#warning "GD32 based controllers may not be fully compatible with STM32 platforms. Please report any issues."
785785
#endif
786786

787787
/**

Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp

-8
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,6 @@ void ChironTFT::Startup() {
7272
live_Zoffset = 0.0;
7373
file_menu = AC_menu_file;
7474

75-
// Setup pins for powerloss detection
76-
// Two IO pins are connected on the Trigorilla Board
77-
// On a power interruption the OUTAGECON_PIN goes low.
78-
79-
#if ENABLED(POWER_LOSS_RECOVERY)
80-
OUT_WRITE(OUTAGECON_PIN, HIGH);
81-
#endif
82-
8375
// Filament runout is handled by Marlin settings in Configuration.h
8476
// opt_set FIL_RUNOUT_STATE HIGH // Pin state indicating that filament is NOT present.
8577
// opt_enable FIL_RUNOUT_PULLUP

Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.h

-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ class ChironTFT {
7676
static void CheckHeaters();
7777
static void SendFileList(int8_t);
7878
static void SelectFile();
79-
static void InjectCommandandWait(PGM_P);
8079
static void ProcessPanelRequest();
8180
static void PanelInfo(uint8_t);
8281
static void PanelAction(uint8_t);

Marlin/src/lcd/extui/anycubic_i3mega/anycubic_i3mega_lcd.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
#if ENABLED(ANYCUBIC_LCD_I3MEGA)
2525

26+
//#define ANYCUBIC_LCD_DEBUG
27+
2628
#include "anycubic_i3mega_lcd.h"
2729
#include "../ui_api.h"
2830

0 commit comments

Comments
 (0)