Skip to content

Commit

Permalink
✨ AnyCubic Vyper / Vyper LCD (MarlinFirmware#25405)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bob-the-Kuhn authored Mar 26, 2023
1 parent ea5d7e2 commit 0021a58
Show file tree
Hide file tree
Showing 39 changed files with 4,951 additions and 53 deletions.
16 changes: 12 additions & 4 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -3132,15 +3132,23 @@
//#define TOUCH_UI_FTDI_EVE

//
// Touch-screen LCD for Anycubic printers
// Touch-screen LCD for Anycubic Chiron
//
//#define ANYCUBIC_LCD_I3MEGA
//#define ANYCUBIC_LCD_CHIRON
#if EITHER(ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON)
//#define ANYCUBIC_LCD_DEBUG

//
// Touch-screen LCD for Anycubic i3 Mega
//
//#define ANYCUBIC_LCD_I3MEGA
#if ENABLED(ANYCUBIC_LCD_I3MEGA)
//#define ANYCUBIC_LCD_GCODE_EXT // Add ".gcode" to menu entries for DGUS clone compatibility
#endif

//
// Touch-screen LCD for Anycubic Vyper
//
//#define ANYCUBIC_LCD_VYPER

//
// 320x240 Nextion 2.8" serial TFT Resistive Touch Screen NX3224T028
//
Expand Down
2 changes: 1 addition & 1 deletion Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1957,7 +1957,7 @@
//
// Specify additional languages for the UI. Default specified by LCD_LANGUAGE.
//
#if ANY(DOGLCD, TFT_COLOR_UI, TOUCH_UI_FTDI_EVE, IS_DWIN_MARLINUI)
#if ANY(DOGLCD, TFT_COLOR_UI, TOUCH_UI_FTDI_EVE, IS_DWIN_MARLINUI, ANYCUBIC_LCD_VYPER)
//#define LCD_LANGUAGE_2 fr
//#define LCD_LANGUAGE_3 de
//#define LCD_LANGUAGE_4 es
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/HAL/LPC1768/HAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,9 @@ class MarlinHAL {
static bool adc_ready() { return LPC176x::adc_hardware.done(LPC176x::pin_get_adc_channel(adc_pin)); }

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

/**
Expand Down
1 change: 1 addition & 0 deletions Marlin/src/core/boards.h
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@
#define BOARD_ERYONE_ERY32_MINI 5065 // Eryone Ery32 mini (STM32F103VE)
#define BOARD_PANDA_PI_V29 5066 // Panda Pi V2.9 - Standalone (STM32F103RC)
#define BOARD_SOVOL_V131 5067 // Sovol V1.3.1 (GD32F103RET6)
#define BOARD_TRIGORILLA_V006 5068 // Trigorilla V0.0.6 (GD32F103RE)

//
// ARM Cortex-M4F
Expand Down
33 changes: 14 additions & 19 deletions Marlin/src/feature/bedlevel/abl/bbl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,13 @@ void LevelingBilinear::print_leveling_grid(const bed_mesh_t* _z_values/*=nullptr
xy_float_t LevelingBilinear::grid_factor_virt;

#define LINEAR_EXTRAPOLATION(E, I) ((E) * 2 - (I))
float LevelingBilinear::bed_level_virt_coord(const uint8_t x, const uint8_t y) {
float LevelingBilinear::virt_coord(const uint8_t x, const uint8_t y) {
uint8_t ep = 0, ip = 1;
if (x > (GRID_MAX_POINTS_X) + 1 || y > (GRID_MAX_POINTS_Y) + 1) {
// The requested point requires extrapolating two points beyond the mesh.
// These values are only requested for the edges of the mesh, which are always an actual mesh point,
// and do not require interpolation. When interpolation is not needed, this "Mesh + 2" point is
// cancelled out in bed_level_virt_cmr and does not impact the result. Return 0.0 rather than
// cancelled out in virt_cmr and does not impact the result. Return 0.0 rather than
// making this function more complex by extrapolating two points.
return 0.0;
}
Expand All @@ -197,8 +197,8 @@ void LevelingBilinear::print_leveling_grid(const bed_mesh_t* _z_values/*=nullptr
);
else
return LINEAR_EXTRAPOLATION(
bed_level_virt_coord(ep + 1, y),
bed_level_virt_coord(ip + 1, y)
virt_coord(ep + 1, y),
virt_coord(ip + 1, y)
);
}
if (!y || y == ABL_TEMP_POINTS_Y - 1) {
Expand All @@ -213,14 +213,14 @@ void LevelingBilinear::print_leveling_grid(const bed_mesh_t* _z_values/*=nullptr
);
else
return LINEAR_EXTRAPOLATION(
bed_level_virt_coord(x, ep + 1),
bed_level_virt_coord(x, ip + 1)
virt_coord(x, ep + 1),
virt_coord(x, ip + 1)
);
}
return z_values[x - 1][y - 1];
}

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

float LevelingBilinear::bed_level_virt_2cmr(const uint8_t x, const uint8_t y, const_float_t tx, const_float_t ty) {
float LevelingBilinear::virt_2cmr(const uint8_t x, const uint8_t y, const_float_t tx, const_float_t ty) {
float row[4], column[4];
LOOP_L_N(i, 4) {
LOOP_L_N(j, 4) {
column[j] = bed_level_virt_coord(i + x - 1, j + y - 1);
column[j] = virt_coord(i + x - 1, j + y - 1);
}
row[i] = bed_level_virt_cmr(column, 1, ty);
row[i] = virt_cmr(column, 1, ty);
}
return bed_level_virt_cmr(row, 1, tx);
return virt_cmr(row, 1, tx);
}

void LevelingBilinear::bed_level_virt_interpolate() {
void LevelingBilinear::subdivide_mesh() {
grid_spacing_virt = grid_spacing / (BILINEAR_SUBDIVISIONS);
grid_factor_virt = grid_spacing_virt.reciprocal();
LOOP_L_N(y, GRID_MAX_POINTS_Y)
Expand All @@ -250,20 +250,15 @@ void LevelingBilinear::print_leveling_grid(const bed_mesh_t* _z_values/*=nullptr
if ((ty && y == (GRID_MAX_POINTS_Y) - 1) || (tx && x == (GRID_MAX_POINTS_X) - 1))
continue;
z_values_virt[x * (BILINEAR_SUBDIVISIONS) + tx][y * (BILINEAR_SUBDIVISIONS) + ty] =
bed_level_virt_2cmr(
x + 1,
y + 1,
(float)tx / (BILINEAR_SUBDIVISIONS),
(float)ty / (BILINEAR_SUBDIVISIONS)
);
virt_2cmr(x + 1, y + 1, (float)tx / (BILINEAR_SUBDIVISIONS), (float)ty / (BILINEAR_SUBDIVISIONS));
}
}

#endif // ABL_BILINEAR_SUBDIVISION

// Refresh after other values have been updated
void LevelingBilinear::refresh_bed_level() {
TERN_(ABL_BILINEAR_SUBDIVISION, bed_level_virt_interpolate());
TERN_(ABL_BILINEAR_SUBDIVISION, subdivide_mesh());
cached_rel.x = cached_rel.y = -999.999;
cached_g.x = cached_g.y = -99;
}
Expand Down
8 changes: 4 additions & 4 deletions Marlin/src/feature/bedlevel/abl/bbl.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ class LevelingBilinear {
static xy_pos_t grid_spacing_virt;
static xy_float_t grid_factor_virt;

static float bed_level_virt_coord(const uint8_t x, const uint8_t y);
static float bed_level_virt_cmr(const float p[4], const uint8_t i, const float t);
static float bed_level_virt_2cmr(const uint8_t x, const uint8_t y, const_float_t tx, const_float_t ty);
static void bed_level_virt_interpolate();
static float virt_coord(const uint8_t x, const uint8_t y);
static float virt_cmr(const float p[4], const uint8_t i, const float t);
static float virt_2cmr(const uint8_t x, const uint8_t y, const_float_t tx, const_float_t ty);
static void subdivide_mesh();
#endif

public:
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/feature/powerloss.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void PrintJobRecovery::changed() {
purge();
else if (IS_SD_PRINTING())
save(true);
TERN_(EXTENSIBLE_UI, ExtUI::onSetPowerLoss(onoff));
TERN_(EXTENSIBLE_UI, ExtUI::onSetPowerLoss(enabled));
}

/**
Expand Down
18 changes: 18 additions & 0 deletions Marlin/src/gcode/queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,24 @@ static bool serial_data_available(serial_index_t index) {

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

#if (defined(ARDUINO_ARCH_STM32F4) || defined(ARDUINO_ARCH_STM32)) && defined(USBCON)

/**
* arduinoststm32's USB receive buffer is not well behaved when the buffer overflows
*
* This can happen when the host programs (such as Pronterface) automatically
* send M105 temperature requests.
*/
void GCodeQueue::flush_rx() {
// Flush receive buffer
LOOP_L_N(p, NUM_SERIAL) {
if (!serial_data_available(p)) continue; // No data for this port? Skip.
while (SERIAL_IMPL.available(p)) (void)read_serial(p);
}
}

#endif // (ARDUINO_ARCH_STM32F4 || ARDUINO_ARCH_STM32) && USBCON

void GCodeQueue::gcode_line_error(FSTR_P const ferr, const serial_index_t serial_ind) {
PORT_REDIRECT(SERIAL_PORTMASK(serial_ind)); // Reply to the serial port that sent the command
SERIAL_ERROR_START();
Expand Down
6 changes: 6 additions & 0 deletions Marlin/src/gcode/queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,12 @@ class GCodeQueue {
*/
static void flush_and_request_resend(const serial_index_t serial_ind);

#if (defined(ARDUINO_ARCH_STM32F4) || defined(ARDUINO_ARCH_STM32)) && defined(USBCON)
static void flush_rx();
#else
static void flush_rx() {}
#endif

/**
* (Re)Set the current line number for the last received command
*/
Expand Down
3 changes: 3 additions & 0 deletions Marlin/src/gcode/temp/M303.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#if HAS_PID_HEATING

#include "../gcode.h"
#include "../queue.h" // for flush_tx
#include "../../lcd/marlinui.h"
#include "../../module/temperature.h"

Expand Down Expand Up @@ -85,6 +86,8 @@ void GcodeSuite::M303() {
LCD_MESSAGE(MSG_PID_AUTOTUNE);
thermalManager.PID_autotune(temp, hid, c, u);
ui.reset_status();

queue.flush_rx();
}

#endif // HAS_PID_HEATING
4 changes: 2 additions & 2 deletions Marlin/src/inc/Conditionals_LCD.h
Original file line number Diff line number Diff line change
Expand Up @@ -477,15 +477,15 @@
#endif

// Aliases for LCD features
#if !DGUS_UI_IS(NONE)
#if !DGUS_UI_IS(NONE) || ENABLED(ANYCUBIC_LCD_VYPER)
#define HAS_DGUS_LCD 1
#if DGUS_UI_IS(ORIGIN, FYSETC, HIPRECY, MKS)
#define HAS_DGUS_LCD_CLASSIC 1
#endif
#endif

// Extensible UI serial touch screens. (See src/lcd/extui)
#if ANY(HAS_DGUS_LCD, MALYAN_LCD, TOUCH_UI_FTDI_EVE, ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON, NEXTION_TFT)
#if ANY(HAS_DGUS_LCD, MALYAN_LCD, TOUCH_UI_FTDI_EVE, ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON, ANYCUBIC_LCD_VYPER, NEXTION_TFT)
#define IS_EXTUI 1
#define EXTENSIBLE_UI
#endif
Expand Down
10 changes: 7 additions & 3 deletions Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -3140,7 +3140,7 @@ static_assert(X_MAX_LENGTH >= X_BED_SIZE, "Movement bounds (X_MIN_POS, X_MAX_POS
+ (ENABLED(EXTENSIBLE_UI) && DISABLED(IS_EXTUI)) \
+ (DISABLED(IS_LEGACY_TFT) && ENABLED(TFT_GENERIC)) \
+ (ENABLED(IS_LEGACY_TFT) && COUNT_ENABLED(TFT_320x240, TFT_320x240_SPI, TFT_480x320, TFT_480x320_SPI)) \
+ COUNT_ENABLED(ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON, ANYCUBIC_TFT35) \
+ COUNT_ENABLED(ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON, ANYCUBIC_TFT35, ANYCUBIC_LCD_VYPER) \
+ 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) \
+ COUNT_ENABLED(ENDER2_STOCKDISPLAY, CR10_STOCKDISPLAY) \
+ COUNT_ENABLED(DWIN_CREALITY_LCD, DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI, DWIN_MARLINUI_PORTRAIT, DWIN_MARLINUI_LANDSCAPE) \
Expand Down Expand Up @@ -3254,6 +3254,10 @@ static_assert(X_MAX_LENGTH >= X_BED_SIZE, "Movement bounds (X_MIN_POS, X_MAX_POS
#endif
#endif

#if ENABLED(ANYCUBIC_LCD_VYPER)
static_assert(strcmp(STRINGIFY(LCD_LANGUAGE_2), "zh_CN") == 0, "LCD_LANGUAGE_2 must be set to zh_CN for ANYCUBIC_LCD_VYPER.");
#endif

#if EITHER(MKS_TS35_V2_0, BTT_TFT35_SPI_V1_0) && SD_CONNECTION_IS(LCD)
#error "SDCARD_CONNECTION cannot be set to LCD for the enabled TFT. No available SD card reader."
#endif
Expand Down Expand Up @@ -3353,8 +3357,8 @@ static_assert(X_MAX_LENGTH >= X_BED_SIZE, "Movement bounds (X_MIN_POS, X_MAX_POS
#else
#if HAS_DGUS_LCD
#error "The DGUS LCD requires LCD_SERIAL_PORT to be defined."
#elif EITHER(ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON)
#error "The ANYCUBIC LCD requires LCD_SERIAL_PORT to be defined."
#elif ANY(ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON, ANYCUBIC_LCD_VYPER)
#error "ANYCUBIC_LCD_* requires LCD_SERIAL_PORT to be defined."
#elif ENABLED(MALYAN_LCD)
#error "MALYAN_LCD requires LCD_SERIAL_PORT to be defined."
#elif ENABLED(NEXTION_LCD)
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/inc/Warnings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -780,8 +780,8 @@
/**
* GD32 is not exactly like STM32
*/
#if MB(SOVOL_V131)
#warning "GD32 based controllers may not be fully compatible with Maple Generic STM32F103RE. Please report any issues."
#if MB(SOVOL_V131, TRIGORILLA_V006)
#warning "GD32 based controllers may not be fully compatible with STM32 platforms. Please report any issues."
#endif

/**
Expand Down
8 changes: 0 additions & 8 deletions Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,6 @@ void ChironTFT::Startup() {
live_Zoffset = 0.0;
file_menu = AC_menu_file;

// Setup pins for powerloss detection
// Two IO pins are connected on the Trigorilla Board
// On a power interruption the OUTAGECON_PIN goes low.

#if ENABLED(POWER_LOSS_RECOVERY)
OUT_WRITE(OUTAGECON_PIN, HIGH);
#endif

// Filament runout is handled by Marlin settings in Configuration.h
// opt_set FIL_RUNOUT_STATE HIGH // Pin state indicating that filament is NOT present.
// opt_enable FIL_RUNOUT_PULLUP
Expand Down
1 change: 0 additions & 1 deletion Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ class ChironTFT {
static void CheckHeaters();
static void SendFileList(int8_t);
static void SelectFile();
static void InjectCommandandWait(PGM_P);
static void ProcessPanelRequest();
static void PanelInfo(uint8_t);
static void PanelAction(uint8_t);
Expand Down
2 changes: 2 additions & 0 deletions Marlin/src/lcd/extui/anycubic_i3mega/anycubic_i3mega_lcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

#if ENABLED(ANYCUBIC_LCD_I3MEGA)

//#define ANYCUBIC_LCD_DEBUG

#include "anycubic_i3mega_lcd.h"
#include "../ui_api.h"

Expand Down
Loading

0 comments on commit 0021a58

Please sign in to comment.