BTT SKR-SE-BX (STM32H743IIT6 ARM Cortex M7) and BIQU_BX_TFT70 (#21536)
This commit is contained in:
@ -2496,6 +2496,11 @@
|
||||
//
|
||||
//#define ANET_ET5_TFT35
|
||||
|
||||
//
|
||||
// 1024x600, 7", RGB Stock Display from BIQU-BX
|
||||
//
|
||||
//#define BIQU_BX_TFT70
|
||||
|
||||
//
|
||||
// Generic TFT with detailed options
|
||||
//
|
||||
|
@ -19,7 +19,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC)
|
||||
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(STM32H7xx)
|
||||
|
||||
#include "MarlinSPI.h"
|
||||
|
||||
|
@ -52,6 +52,6 @@
|
||||
#error "SERIAL_STATS_DROPPED_RX is not supported on STM32."
|
||||
#endif
|
||||
|
||||
#if ANY(TFT_COLOR_UI, TFT_LVGL_UI, TFT_CLASSIC_UI) && NOT_TARGET(STM32F4xx, STM32F1xx)
|
||||
#error "TFT_COLOR_UI, TFT_LVGL_UI and TFT_CLASSIC_UI are currently only supported on STM32F4 and STM32F1 hardware."
|
||||
#if ANY(TFT_COLOR_UI, TFT_LVGL_UI, TFT_CLASSIC_UI) && NOT_TARGET(STM32H7xx, STM32F4xx, STM32F1xx)
|
||||
#error "TFT_COLOR_UI, TFT_LVGL_UI and TFT_CLASSIC_UI are currently only supported on STM32H7, STM32F4 and STM32F1 hardware."
|
||||
#endif
|
||||
|
390
Marlin/src/HAL/STM32/tft/tft_ltdc.cpp
Normal file
390
Marlin/src/HAL/STM32/tft/tft_ltdc.cpp
Normal file
@ -0,0 +1,390 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC)
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
#if HAS_LTDC_TFT
|
||||
|
||||
#include "tft_ltdc.h"
|
||||
#include "pinconfig.h"
|
||||
|
||||
#define FRAME_BUFFER_ADDRESS 0XC0000000 // SDRAM address
|
||||
|
||||
#define SDRAM_TIMEOUT ((uint32_t)0xFFFF)
|
||||
#define REFRESH_COUNT ((uint32_t)0x02A5) // SDRAM refresh counter
|
||||
|
||||
#define SDRAM_MODEREG_BURST_LENGTH_1 ((uint16_t)0x0000)
|
||||
#define SDRAM_MODEREG_BURST_LENGTH_2 ((uint16_t)0x0001)
|
||||
#define SDRAM_MODEREG_BURST_LENGTH_4 ((uint16_t)0x0002)
|
||||
#define SDRAM_MODEREG_BURST_LENGTH_8 ((uint16_t)0x0004)
|
||||
#define SDRAM_MODEREG_BURST_TYPE_SEQUENTIAL ((uint16_t)0x0000)
|
||||
#define SDRAM_MODEREG_BURST_TYPE_INTERLEAVED ((uint16_t)0x0008)
|
||||
#define SDRAM_MODEREG_CAS_LATENCY_2 ((uint16_t)0x0020)
|
||||
#define SDRAM_MODEREG_CAS_LATENCY_3 ((uint16_t)0x0030)
|
||||
#define SDRAM_MODEREG_OPERATING_MODE_STANDARD ((uint16_t)0x0000)
|
||||
#define SDRAM_MODEREG_WRITEBURST_MODE_PROGRAMMED ((uint16_t)0x0000)
|
||||
#define SDRAM_MODEREG_WRITEBURST_MODE_SINGLE ((uint16_t)0x0200)
|
||||
|
||||
|
||||
void SDRAM_Initialization_Sequence(SDRAM_HandleTypeDef *hsdram, FMC_SDRAM_CommandTypeDef *Command) {
|
||||
|
||||
__IO uint32_t tmpmrd =0;
|
||||
/* Step 1: Configure a clock configuration enable command */
|
||||
Command->CommandMode = FMC_SDRAM_CMD_CLK_ENABLE;
|
||||
Command->CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1;
|
||||
Command->AutoRefreshNumber = 1;
|
||||
Command->ModeRegisterDefinition = 0;
|
||||
/* Send the command */
|
||||
HAL_SDRAM_SendCommand(hsdram, Command, SDRAM_TIMEOUT);
|
||||
|
||||
/* Step 2: Insert 100 us minimum delay */
|
||||
/* Inserted delay is equal to 1 ms due to systick time base unit (ms) */
|
||||
HAL_Delay(1);
|
||||
|
||||
/* Step 3: Configure a PALL (precharge all) command */
|
||||
Command->CommandMode = FMC_SDRAM_CMD_PALL;
|
||||
Command->CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1;
|
||||
Command->AutoRefreshNumber = 1;
|
||||
Command->ModeRegisterDefinition = 0;
|
||||
/* Send the command */
|
||||
HAL_SDRAM_SendCommand(hsdram, Command, SDRAM_TIMEOUT);
|
||||
|
||||
/* Step 4 : Configure a Auto-Refresh command */
|
||||
Command->CommandMode = FMC_SDRAM_CMD_AUTOREFRESH_MODE;
|
||||
Command->CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1;
|
||||
Command->AutoRefreshNumber = 8;
|
||||
Command->ModeRegisterDefinition = 0;
|
||||
/* Send the command */
|
||||
HAL_SDRAM_SendCommand(hsdram, Command, SDRAM_TIMEOUT);
|
||||
|
||||
/* Step 5: Program the external memory mode register */
|
||||
tmpmrd = (uint32_t)(SDRAM_MODEREG_BURST_LENGTH_1 |
|
||||
SDRAM_MODEREG_BURST_TYPE_SEQUENTIAL |
|
||||
SDRAM_MODEREG_CAS_LATENCY_2 |
|
||||
SDRAM_MODEREG_OPERATING_MODE_STANDARD |
|
||||
SDRAM_MODEREG_WRITEBURST_MODE_SINGLE);
|
||||
|
||||
Command->CommandMode = FMC_SDRAM_CMD_LOAD_MODE;
|
||||
Command->CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1;
|
||||
Command->AutoRefreshNumber = 1;
|
||||
Command->ModeRegisterDefinition = tmpmrd;
|
||||
/* Send the command */
|
||||
HAL_SDRAM_SendCommand(hsdram, Command, SDRAM_TIMEOUT);
|
||||
|
||||
/* Step 6: Set the refresh rate counter */
|
||||
/* Set the device refresh rate */
|
||||
HAL_SDRAM_ProgramRefreshRate(hsdram, REFRESH_COUNT);
|
||||
}
|
||||
|
||||
void SDRAM_Config() {
|
||||
|
||||
__HAL_RCC_SYSCFG_CLK_ENABLE();
|
||||
__HAL_RCC_FMC_CLK_ENABLE();
|
||||
|
||||
SDRAM_HandleTypeDef hsdram;
|
||||
FMC_SDRAM_TimingTypeDef SDRAM_Timing;
|
||||
FMC_SDRAM_CommandTypeDef command;
|
||||
|
||||
/* Configure the SDRAM device */
|
||||
hsdram.Instance = FMC_SDRAM_DEVICE;
|
||||
hsdram.Init.SDBank = FMC_SDRAM_BANK1;
|
||||
hsdram.Init.ColumnBitsNumber = FMC_SDRAM_COLUMN_BITS_NUM_9;
|
||||
hsdram.Init.RowBitsNumber = FMC_SDRAM_ROW_BITS_NUM_13;
|
||||
hsdram.Init.MemoryDataWidth = FMC_SDRAM_MEM_BUS_WIDTH_16;
|
||||
hsdram.Init.InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_4;
|
||||
hsdram.Init.CASLatency = FMC_SDRAM_CAS_LATENCY_2;
|
||||
hsdram.Init.WriteProtection = FMC_SDRAM_WRITE_PROTECTION_DISABLE;
|
||||
hsdram.Init.SDClockPeriod = FMC_SDRAM_CLOCK_PERIOD_2;
|
||||
hsdram.Init.ReadBurst = FMC_SDRAM_RBURST_ENABLE;
|
||||
hsdram.Init.ReadPipeDelay = FMC_SDRAM_RPIPE_DELAY_0;
|
||||
|
||||
/* Timing configuration for 100Mhz as SDRAM clock frequency (System clock is up to 200Mhz) */
|
||||
SDRAM_Timing.LoadToActiveDelay = 2;
|
||||
SDRAM_Timing.ExitSelfRefreshDelay = 8;
|
||||
SDRAM_Timing.SelfRefreshTime = 6;
|
||||
SDRAM_Timing.RowCycleDelay = 6;
|
||||
SDRAM_Timing.WriteRecoveryTime = 2;
|
||||
SDRAM_Timing.RPDelay = 2;
|
||||
SDRAM_Timing.RCDDelay = 2;
|
||||
|
||||
/* Initialize the SDRAM controller */
|
||||
if (HAL_SDRAM_Init(&hsdram, &SDRAM_Timing) != HAL_OK)
|
||||
{
|
||||
/* Initialization Error */
|
||||
}
|
||||
|
||||
/* Program the SDRAM external device */
|
||||
SDRAM_Initialization_Sequence(&hsdram, &command);
|
||||
}
|
||||
|
||||
void LTDC_Config() {
|
||||
|
||||
__HAL_RCC_LTDC_CLK_ENABLE();
|
||||
__HAL_RCC_DMA2D_CLK_ENABLE();
|
||||
|
||||
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;
|
||||
|
||||
/* The PLL3R is configured to provide the LTDC PCLK clock */
|
||||
/* PLL3_VCO Input = HSE_VALUE / PLL3M = 25Mhz / 5 = 5 Mhz */
|
||||
/* PLL3_VCO Output = PLL3_VCO Input * PLL3N = 5Mhz * 160 = 800 Mhz */
|
||||
/* PLLLCDCLK = PLL3_VCO Output/PLL3R = 800Mhz / 16 = 50Mhz */
|
||||
/* LTDC clock frequency = PLLLCDCLK = 50 Mhz */
|
||||
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC;
|
||||
PeriphClkInitStruct.PLL3.PLL3M = 5;
|
||||
PeriphClkInitStruct.PLL3.PLL3N = 160;
|
||||
PeriphClkInitStruct.PLL3.PLL3FRACN = 0;
|
||||
PeriphClkInitStruct.PLL3.PLL3P = 2;
|
||||
PeriphClkInitStruct.PLL3.PLL3Q = 2;
|
||||
PeriphClkInitStruct.PLL3.PLL3R = (800 / LTDC_LCD_CLK);
|
||||
PeriphClkInitStruct.PLL3.PLL3VCOSEL = RCC_PLL3VCOWIDE;
|
||||
PeriphClkInitStruct.PLL3.PLL3RGE = RCC_PLL3VCIRANGE_2;
|
||||
HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);
|
||||
|
||||
LTDC_HandleTypeDef hltdc_F;
|
||||
LTDC_LayerCfgTypeDef pLayerCfg;
|
||||
|
||||
/* LTDC Initialization -------------------------------------------------------*/
|
||||
|
||||
/* Polarity configuration */
|
||||
/* Initialize the horizontal synchronization polarity as active low */
|
||||
hltdc_F.Init.HSPolarity = LTDC_HSPOLARITY_AL;
|
||||
/* Initialize the vertical synchronization polarity as active low */
|
||||
hltdc_F.Init.VSPolarity = LTDC_VSPOLARITY_AL;
|
||||
/* Initialize the data enable polarity as active low */
|
||||
hltdc_F.Init.DEPolarity = LTDC_DEPOLARITY_AL;
|
||||
/* Initialize the pixel clock polarity as input pixel clock */
|
||||
hltdc_F.Init.PCPolarity = LTDC_PCPOLARITY_IPC;
|
||||
|
||||
/* Timing configuration */
|
||||
hltdc_F.Init.HorizontalSync = (LTDC_LCD_HSYNC - 1);
|
||||
hltdc_F.Init.VerticalSync = (LTDC_LCD_VSYNC - 1);
|
||||
hltdc_F.Init.AccumulatedHBP = (LTDC_LCD_HSYNC + LTDC_LCD_HBP - 1);
|
||||
hltdc_F.Init.AccumulatedVBP = (LTDC_LCD_VSYNC + LTDC_LCD_VBP - 1);
|
||||
hltdc_F.Init.AccumulatedActiveH = (TFT_HEIGHT + LTDC_LCD_VSYNC + LTDC_LCD_VBP - 1);
|
||||
hltdc_F.Init.AccumulatedActiveW = (TFT_WIDTH + LTDC_LCD_HSYNC + LTDC_LCD_HBP - 1);
|
||||
hltdc_F.Init.TotalHeigh = (TFT_HEIGHT + LTDC_LCD_VSYNC + LTDC_LCD_VBP + LTDC_LCD_VFP - 1);
|
||||
hltdc_F.Init.TotalWidth = (TFT_WIDTH + LTDC_LCD_HSYNC + LTDC_LCD_HBP + LTDC_LCD_HFP - 1);
|
||||
|
||||
/* Configure R,G,B component values for LCD background color : all black background */
|
||||
hltdc_F.Init.Backcolor.Blue = 0;
|
||||
hltdc_F.Init.Backcolor.Green = 0;
|
||||
hltdc_F.Init.Backcolor.Red = 0;
|
||||
|
||||
hltdc_F.Instance = LTDC;
|
||||
|
||||
/* Layer0 Configuration ------------------------------------------------------*/
|
||||
|
||||
/* Windowing configuration */
|
||||
pLayerCfg.WindowX0 = 0;
|
||||
pLayerCfg.WindowX1 = TFT_WIDTH;
|
||||
pLayerCfg.WindowY0 = 0;
|
||||
pLayerCfg.WindowY1 = TFT_HEIGHT;
|
||||
|
||||
/* Pixel Format configuration*/
|
||||
pLayerCfg.PixelFormat = LTDC_PIXEL_FORMAT_RGB565;
|
||||
|
||||
/* Start Address configuration : frame buffer is located at SDRAM memory */
|
||||
pLayerCfg.FBStartAdress = (uint32_t)(FRAME_BUFFER_ADDRESS);
|
||||
|
||||
/* Alpha constant (255 == totally opaque) */
|
||||
pLayerCfg.Alpha = 255;
|
||||
|
||||
/* Default Color configuration (configure A,R,G,B component values) : no background color */
|
||||
pLayerCfg.Alpha0 = 0; /* fully transparent */
|
||||
pLayerCfg.Backcolor.Blue = 0;
|
||||
pLayerCfg.Backcolor.Green = 0;
|
||||
pLayerCfg.Backcolor.Red = 0;
|
||||
|
||||
/* Configure blending factors */
|
||||
pLayerCfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_CA;
|
||||
pLayerCfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_CA;
|
||||
|
||||
/* Configure the number of lines and number of pixels per line */
|
||||
pLayerCfg.ImageWidth = TFT_WIDTH;
|
||||
pLayerCfg.ImageHeight = TFT_HEIGHT;
|
||||
|
||||
/* Configure the LTDC */
|
||||
if (HAL_LTDC_Init(&hltdc_F) != HAL_OK)
|
||||
{
|
||||
/* Initialization Error */
|
||||
}
|
||||
|
||||
/* Configure the Layer*/
|
||||
if (HAL_LTDC_ConfigLayer(&hltdc_F, &pLayerCfg, 0) != HAL_OK)
|
||||
{
|
||||
/* Initialization Error */
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t TFT_LTDC::x_min = 0;
|
||||
uint16_t TFT_LTDC::x_max = 0;
|
||||
uint16_t TFT_LTDC::y_min = 0;
|
||||
uint16_t TFT_LTDC::y_max = 0;
|
||||
uint16_t TFT_LTDC::x_cur = 0;
|
||||
uint16_t TFT_LTDC::y_cur = 0;
|
||||
uint8_t TFT_LTDC::reg = 0;
|
||||
volatile uint16_t* TFT_LTDC::framebuffer = (volatile uint16_t* )FRAME_BUFFER_ADDRESS;
|
||||
|
||||
void TFT_LTDC::Init() {
|
||||
|
||||
// SDRAM pins init
|
||||
for (uint16_t i = 0; PinMap_SDRAM[i].pin != NC; i++)
|
||||
pinmap_pinout(PinMap_SDRAM[i].pin, PinMap_SDRAM);
|
||||
|
||||
// SDRAM peripheral config
|
||||
SDRAM_Config();
|
||||
|
||||
// LTDC pins init
|
||||
for (uint16_t i = 0; PinMap_LTDC[i].pin != NC; i++)
|
||||
pinmap_pinout(PinMap_LTDC[i].pin, PinMap_LTDC);
|
||||
|
||||
// LTDC peripheral config
|
||||
LTDC_Config();
|
||||
}
|
||||
|
||||
uint32_t TFT_LTDC::GetID() {
|
||||
return 0xABAB;
|
||||
}
|
||||
|
||||
uint32_t TFT_LTDC::ReadID(tft_data_t Reg) {
|
||||
return 0xABAB;
|
||||
}
|
||||
|
||||
bool TFT_LTDC::isBusy() {
|
||||
return false;
|
||||
}
|
||||
|
||||
uint16_t TFT_LTDC::ReadPoint(uint16_t x, uint16_t y) {
|
||||
return framebuffer[(TFT_WIDTH * y) + x];
|
||||
}
|
||||
|
||||
void TFT_LTDC::DrawPoint(uint16_t x, uint16_t y, uint16_t color) {
|
||||
framebuffer[(TFT_WIDTH * y) + x] = color;
|
||||
}
|
||||
|
||||
void TFT_LTDC::DrawRect(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey, uint16_t color) {
|
||||
|
||||
if (sx == ex || sy == ey) return;
|
||||
|
||||
uint16_t offline = TFT_WIDTH - (ex - sx);
|
||||
uint32_t addr = (uint32_t)&framebuffer[(TFT_WIDTH * sy) + sx];
|
||||
|
||||
DMA2D->CR &= ~(1 << 0);
|
||||
DMA2D->CR = 3 << 16;
|
||||
DMA2D->OPFCCR = 0X02;
|
||||
DMA2D->OOR = offline;
|
||||
DMA2D->OMAR = addr;
|
||||
DMA2D->NLR = (ey - sy) | ((ex - sx) << 16);
|
||||
DMA2D->OCOLR = color;
|
||||
DMA2D->CR |= 1<<0;
|
||||
|
||||
uint32_t timeout = 0;
|
||||
while((DMA2D->ISR & (1<<1)) == 0)
|
||||
{
|
||||
timeout++;
|
||||
if(timeout>0X1FFFFF)break;
|
||||
}
|
||||
DMA2D->IFCR |= 1<<1;
|
||||
}
|
||||
|
||||
void TFT_LTDC::DrawImage(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey, uint16_t *colors) {
|
||||
|
||||
if (sx == ex || sy == ey) return;
|
||||
|
||||
uint16_t offline = TFT_WIDTH - (ex - sx);
|
||||
uint32_t addr = (uint32_t)&framebuffer[(TFT_WIDTH * sy) + sx];
|
||||
|
||||
DMA2D->CR &= ~(1 << 0);
|
||||
DMA2D->CR = 0 << 16;
|
||||
DMA2D->FGPFCCR = 0X02;
|
||||
DMA2D->FGOR = 0;
|
||||
DMA2D->OOR = offline;
|
||||
DMA2D->FGMAR = (uint32_t)colors;
|
||||
DMA2D->OMAR = addr;
|
||||
DMA2D->NLR = (ey - sy) | ((ex - sx) << 16);
|
||||
DMA2D->CR |= 1<<0;
|
||||
|
||||
uint32_t timeout = 0;
|
||||
while((DMA2D->ISR & (1<<1)) == 0)
|
||||
{
|
||||
timeout++;
|
||||
if(timeout>0X1FFFFF)break;
|
||||
}
|
||||
DMA2D->IFCR |= 1<<1;
|
||||
}
|
||||
|
||||
void TFT_LTDC::WriteData(uint16_t data) {
|
||||
switch (reg) {
|
||||
case 0x01: x_cur = x_min = data; return;
|
||||
case 0x02: x_max = data; return;
|
||||
case 0x03: y_cur = y_min = data; return;
|
||||
case 0x04: y_max = data; return;
|
||||
}
|
||||
Transmit(data);
|
||||
}
|
||||
|
||||
void TFT_LTDC::Transmit(tft_data_t Data) {
|
||||
DrawPoint(x_cur, y_cur, Data);
|
||||
x_cur++;
|
||||
if (x_cur > x_max) {
|
||||
x_cur = x_min;
|
||||
y_cur++;
|
||||
if (y_cur > y_max) y_cur = y_min;
|
||||
}
|
||||
}
|
||||
|
||||
void TFT_LTDC::WriteReg(uint16_t Reg) {
|
||||
reg = Reg;
|
||||
}
|
||||
|
||||
void TFT_LTDC::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) {
|
||||
|
||||
while (x_cur != x_min && Count) {
|
||||
Transmit(*Data);
|
||||
if (MemoryIncrease == DMA_PINC_ENABLE) Data++;
|
||||
Count--;
|
||||
}
|
||||
|
||||
uint16_t width = x_max - x_min + 1;
|
||||
uint16_t height = Count / width;
|
||||
uint16_t x_end_cnt = Count - (width * height);
|
||||
|
||||
if (height) {
|
||||
if (MemoryIncrease == DMA_PINC_ENABLE) {
|
||||
DrawImage(x_min, y_cur, x_min + width, y_cur + height, Data);
|
||||
Data += width * height;
|
||||
} else {
|
||||
DrawRect(x_min, y_cur, x_min + width, y_cur + height, *Data);
|
||||
}
|
||||
y_cur += height;
|
||||
}
|
||||
|
||||
while (x_end_cnt) {
|
||||
Transmit(*Data);
|
||||
if (MemoryIncrease == DMA_PINC_ENABLE) Data++;
|
||||
x_end_cnt--;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // HAS_LTDC_TFT
|
||||
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC
|
155
Marlin/src/HAL/STM32/tft/tft_ltdc.h
Normal file
155
Marlin/src/HAL/STM32/tft/tft_ltdc.h
Normal file
@ -0,0 +1,155 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
#ifdef STM32H7xx
|
||||
#include "stm32h7xx_hal.h"
|
||||
#else
|
||||
#error "LTDC TFT is currently only supported on STM32H7 hardware."
|
||||
#endif
|
||||
|
||||
#define DATASIZE_8BIT SPI_DATASIZE_8BIT
|
||||
#define DATASIZE_16BIT SPI_DATASIZE_16BIT
|
||||
#define TFT_IO_DRIVER TFT_LTDC
|
||||
|
||||
#define TFT_DATASIZE DATASIZE_16BIT
|
||||
typedef uint16_t tft_data_t;
|
||||
|
||||
class TFT_LTDC {
|
||||
private:
|
||||
static volatile uint16_t *framebuffer;
|
||||
static uint16_t x_min, x_max, y_min, y_max, x_cur, y_cur;
|
||||
static uint8_t reg;
|
||||
|
||||
static uint32_t ReadID(tft_data_t Reg);
|
||||
|
||||
static uint16_t ReadPoint(uint16_t x, uint16_t y);
|
||||
static void DrawPoint(uint16_t x, uint16_t y, uint16_t color);
|
||||
static void DrawRect(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey, uint16_t color);
|
||||
static void DrawImage(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey, uint16_t *colors);
|
||||
static void Transmit(tft_data_t Data);
|
||||
static void TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count);
|
||||
|
||||
public:
|
||||
static void Init();
|
||||
static uint32_t GetID();
|
||||
static bool isBusy();
|
||||
static void Abort() { /*__HAL_DMA_DISABLE(&DMAtx);*/ }
|
||||
|
||||
static void DataTransferBegin(uint16_t DataWidth = TFT_DATASIZE) {}
|
||||
static void DataTransferEnd() {};
|
||||
|
||||
static void WriteData(uint16_t Data);
|
||||
static void WriteReg(uint16_t Reg);
|
||||
|
||||
static void WriteSequence(uint16_t *Data, uint16_t Count) { TransmitDMA(DMA_PINC_ENABLE, Data, Count); }
|
||||
static void WriteMultiple(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_PINC_DISABLE, &Data, Count); }
|
||||
static void WriteMultiple(uint16_t Color, uint32_t Count) {
|
||||
static uint16_t Data; Data = Color;
|
||||
while (Count > 0) {
|
||||
TransmitDMA(DMA_MINC_DISABLE, &Data, Count > 0xFFFF ? 0xFFFF : Count);
|
||||
Count = Count > 0xFFFF ? Count - 0xFFFF : 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const PinMap PinMap_LTDC[] = {
|
||||
{PF_10, LTDC, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_LTDC)}, // LCD_DE
|
||||
{PG_7, LTDC, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_LTDC)}, // LCD_CLK
|
||||
{PI_9, LTDC, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_LTDC)}, // LCD_VSYNC
|
||||
{PI_10, LTDC, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_LTDC)}, // LCD_HSYNC
|
||||
|
||||
{PG_6, LTDC, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_LTDC)}, // LCD_R7
|
||||
{PH_12, LTDC, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_LTDC)}, // LCD_R6
|
||||
{PH_11, LTDC, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_LTDC)}, // LCD_R5
|
||||
{PH_10, LTDC, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_LTDC)}, // LCD_R4
|
||||
{PH_9, LTDC, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_LTDC)}, // LCD_R3
|
||||
|
||||
{PI_2, LTDC, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_LTDC)}, // LCD_G7
|
||||
{PI_1, LTDC, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_LTDC)}, // LCD_G6
|
||||
{PI_0, LTDC, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_LTDC)}, // LCD_G5
|
||||
{PH_15, LTDC, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_LTDC)}, // LCD_G4
|
||||
{PH_14, LTDC, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_LTDC)}, // LCD_G3
|
||||
{PH_13, LTDC, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_LTDC)}, // LCD_G2
|
||||
|
||||
{PI_7, LTDC, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_LTDC)}, // LCD_B7
|
||||
{PI_6, LTDC, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_LTDC)}, // LCD_B6
|
||||
{PI_5, LTDC, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_LTDC)}, // LCD_B5
|
||||
{PI_4, LTDC, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_LTDC)}, // LCD_B4
|
||||
{PG_11, LTDC, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_LTDC)}, // LCD_B3
|
||||
{NC, NP, 0}
|
||||
};
|
||||
|
||||
const PinMap PinMap_SDRAM[] = {
|
||||
{PC_0, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_SDNWE
|
||||
{PC_2, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_SDNE0
|
||||
{PC_3, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_SDCKE0
|
||||
{PE_0, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_NBL0
|
||||
{PE_1, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_NBL1
|
||||
{PF_11, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_SDNRAS
|
||||
{PG_8, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_SDCLK
|
||||
{PG_15, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_SDNCAS
|
||||
{PG_4, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_BA0
|
||||
{PG_5, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_BA1
|
||||
{PD_14, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_D0
|
||||
{PD_15, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_D1
|
||||
{PD_0, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_D2
|
||||
{PD_1, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_D3
|
||||
{PE_7, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_D4
|
||||
{PE_8, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_D5
|
||||
{PE_9, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_D6
|
||||
{PE_10, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_D7
|
||||
{PE_11, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_D8
|
||||
{PE_12, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_D9
|
||||
{PE_13, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_D10
|
||||
{PE_14, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_D11
|
||||
{PE_15, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_D12
|
||||
{PD_8, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_D13
|
||||
{PD_9, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_D14
|
||||
{PD_10, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_D15
|
||||
{PF_0, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_A0
|
||||
{PF_1, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_A1
|
||||
{PF_2, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_A2
|
||||
{PF_3, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_A3
|
||||
{PF_4, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_A4
|
||||
{PF_5, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_A5
|
||||
{PF_12, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_A6
|
||||
{PF_13, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_A7
|
||||
{PF_14, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_A8
|
||||
{PF_15, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_A9
|
||||
{PG_0, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_A10
|
||||
{PG_1, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_A11
|
||||
{PG_2, FMC_Bank1_R, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_FMC)}, // FMC_A12
|
||||
{NC, NP, 0}
|
||||
};
|
||||
|
||||
const PinMap PinMap_QUADSPI[] = {
|
||||
{PB_2, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QUADSPI)}, // QUADSPI_CLK
|
||||
{PB_10, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QUADSPI)}, // QUADSPI_BK1_NCS
|
||||
{PF_6, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QUADSPI)}, // QUADSPI_BK1_IO3
|
||||
{PF_7, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QUADSPI)}, // QUADSPI_BK1_IO2
|
||||
{PF_8, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)}, // QUADSPI_BK1_IO0
|
||||
{PF_9, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)}, // QUADSPI_BK1_IO1
|
||||
{NC, NP, 0}
|
||||
};
|
@ -74,7 +74,7 @@
|
||||
#elif defined(STM32F401xC) || defined(STM32F401xE)
|
||||
#define MCU_STEP_TIMER 9
|
||||
#define MCU_TEMP_TIMER 10
|
||||
#elif defined(STM32F4xx) || defined(STM32F7xx)
|
||||
#elif defined(STM32F4xx) || defined(STM32F7xx) || defined(STM32H7xx)
|
||||
#define MCU_STEP_TIMER 6 // STM32F401 has no TIM6, TIM7, or TIM8
|
||||
#define MCU_TEMP_TIMER 14 // TIM7 is consumed by Software Serial if used.
|
||||
#endif
|
||||
|
@ -390,6 +390,7 @@
|
||||
#define BOARD_TEENSY41 5001 // Teensy 4.1
|
||||
#define BOARD_T41U5XBB 5002 // T41U5XBB Teensy 4.1 breakout board
|
||||
#define BOARD_NUCLEO_F767ZI 5003 // ST NUCLEO-F767ZI Dev Board
|
||||
#define BOARD_BTT_SKR_SE_BX 5004 // BigTreeTech SKR SE BX (STM32H743II)
|
||||
|
||||
//
|
||||
// Espressif ESP32 WiFi
|
||||
|
@ -1119,6 +1119,10 @@
|
||||
#define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY)
|
||||
#define TFT_RES_480x320
|
||||
#define TFT_INTERFACE_FSMC
|
||||
#elif ENABLED(BIQU_BX_TFT70) // RGB
|
||||
#define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY)
|
||||
#define TFT_RES_1024x600
|
||||
#define TFT_INTERFACE_LTDC
|
||||
#elif ENABLED(TFT_GENERIC)
|
||||
#define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_X | TFT_INVERT_Y)
|
||||
#if NONE(TFT_RES_320x240, TFT_RES_480x272, TFT_RES_480x320)
|
||||
@ -1141,9 +1145,13 @@
|
||||
#define TFT_WIDTH 480
|
||||
#define TFT_HEIGHT 320
|
||||
#define GRAPHICAL_TFT_UPSCALE 3
|
||||
#elif ENABLED(TFT_RES_1024x600)
|
||||
#define TFT_WIDTH 1024
|
||||
#define TFT_HEIGHT 600
|
||||
#define GRAPHICAL_TFT_UPSCALE 4
|
||||
#endif
|
||||
|
||||
// FSMC/SPI TFT Panels using standard HAL/tft/tft_(fsmc|spi).h
|
||||
// FSMC/SPI TFT Panels using standard HAL/tft/tft_(fsmc|spi|ltdc).h
|
||||
#if ENABLED(TFT_INTERFACE_FSMC)
|
||||
#define HAS_FSMC_TFT 1
|
||||
#if TFT_SCALED_DOGLCD
|
||||
@ -1158,6 +1166,13 @@
|
||||
#elif HAS_TFT_LVGL_UI
|
||||
#define HAS_TFT_LVGL_UI_SPI 1
|
||||
#endif
|
||||
#elif ENABLED(TFT_INTERFACE_LTDC)
|
||||
#define HAS_LTDC_TFT 1
|
||||
#if TFT_SCALED_DOGLCD
|
||||
#define HAS_LTDC_GRAPHICAL_TFT 1
|
||||
#elif HAS_TFT_LVGL_UI
|
||||
#define HAS_TFT_LVGL_UI_LTDC 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if ENABLED(TFT_COLOR_UI)
|
||||
@ -1179,6 +1194,10 @@
|
||||
#elif ENABLED(TFT_INTERFACE_FSMC)
|
||||
#define TFT_480x272
|
||||
#endif
|
||||
#elif TFT_HEIGHT == 600
|
||||
#if ENABLED(TFT_INTERFACE_LTDC)
|
||||
#define TFT_1024x600_LTDC
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -1188,9 +1207,13 @@
|
||||
#define HAS_UI_480x320 1
|
||||
#elif EITHER(TFT_480x272, TFT_480x272_SPI)
|
||||
#define HAS_UI_480x272 1
|
||||
#elif defined(TFT_1024x600_LTDC)
|
||||
#define HAS_UI_1024x600 1
|
||||
#endif
|
||||
#if ANY(HAS_UI_320x240, HAS_UI_480x320, HAS_UI_480x272)
|
||||
#define LCD_HEIGHT TERN(TOUCH_SCREEN, 6, 7) // Fewer lines with touch buttons onscreen
|
||||
#elif HAS_UI_1024x600
|
||||
#define LCD_HEIGHT TERN(TOUCH_SCREEN, 12, 13) // Fewer lines with touch buttons onscreen
|
||||
#endif
|
||||
|
||||
// This emulated DOGM has 'touch/xpt2046', not 'tft/xpt2046'
|
||||
|
@ -2404,7 +2404,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal
|
||||
#undef IS_EXTUI
|
||||
#undef IS_LEGACY_TFT
|
||||
|
||||
#if ANY(TFT_GENERIC, MKS_TS35_V2_0, MKS_ROBIN_TFT24, MKS_ROBIN_TFT28, MKS_ROBIN_TFT32, MKS_ROBIN_TFT35, MKS_ROBIN_TFT43, MKS_ROBIN_TFT_V1_1R, TFT_TRONXY_X5SA, ANYCUBIC_TFT35, ANYCUBIC_TFT35, LONGER_LK_TFT28, ANET_ET4_TFT28, ANET_ET5_TFT35)
|
||||
#if ANY(TFT_GENERIC, MKS_TS35_V2_0, MKS_ROBIN_TFT24, MKS_ROBIN_TFT28, MKS_ROBIN_TFT32, MKS_ROBIN_TFT35, MKS_ROBIN_TFT43, MKS_ROBIN_TFT_V1_1R, TFT_TRONXY_X5SA, ANYCUBIC_TFT35, ANYCUBIC_TFT35, LONGER_LK_TFT28, ANET_ET4_TFT28, ANET_ET5_TFT35, BIQU_BX_TFT70)
|
||||
#if NONE(TFT_COLOR_UI, TFT_CLASSIC_UI, TFT_LVGL_UI)
|
||||
#error "TFT_COLOR_UI, TFT_CLASSIC_UI, TFT_LVGL_UI is required for your TFT. Please enable one."
|
||||
#elif 1 < ENABLED(TFT_COLOR_UI) + ENABLED(TFT_CLASSIC_UI) + ENABLED(TFT_LVGL_UI)
|
||||
@ -2426,16 +2426,16 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal
|
||||
#error "Please enable only one LCD_SCREEN_ROT_* option: 0, 90, 180, or 270."
|
||||
#endif
|
||||
|
||||
#if MANY(TFT_RES_320x240, TFT_RES_480x272, TFT_RES_480x320)
|
||||
#error "Please select only one of TFT_RES_480x320, TFT_RES_480x320, or TFT_RES_480x272."
|
||||
#if MANY(TFT_RES_320x240, TFT_RES_480x272, TFT_RES_480x320, TFT_RES_1024x600)
|
||||
#error "Please select only one of TFT_RES_320x240, TFT_RES_480x272, TFT_RES_480x320, or TFT_RES_1024x600."
|
||||
#endif
|
||||
|
||||
#if HAS_TFT_LVGL_UI && DISABLED(TFT_RES_480x320)
|
||||
#error "(FMSC|SPI)TFT_LVGL_UI requires TFT_RES_480x320."
|
||||
#endif
|
||||
|
||||
#if defined(GRAPHICAL_TFT_UPSCALE) && !WITHIN(GRAPHICAL_TFT_UPSCALE, 2, 3)
|
||||
#error "GRAPHICAL_TFT_UPSCALE must be set to 2 or 3."
|
||||
#if defined(GRAPHICAL_TFT_UPSCALE) && !WITHIN(GRAPHICAL_TFT_UPSCALE, 2, 4)
|
||||
#error "GRAPHICAL_TFT_UPSCALE must be 2, 3, or 4."
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
@ -55,14 +55,14 @@
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#if HAS_MARLINUI_U8GLIB && (PIN_EXISTS(FSMC_CS) || HAS_SPI_GRAPHICAL_TFT)
|
||||
#if HAS_MARLINUI_U8GLIB && (PIN_EXISTS(FSMC_CS) || HAS_SPI_GRAPHICAL_TFT || HAS_LTDC_GRAPHICAL_TFT)
|
||||
|
||||
#include "HAL_LCD_com_defines.h"
|
||||
#include "marlinui_DOGM.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if EITHER(LCD_USE_DMA_FSMC, LCD_USE_DMA_SPI)
|
||||
#if ANY(LCD_USE_DMA_FSMC, LCD_USE_DMA_SPI, HAS_LTDC_GRAPHICAL_TFT)
|
||||
#define HAS_LCD_IO 1
|
||||
#endif
|
||||
|
||||
|
@ -55,7 +55,7 @@ constexpr static float gaugeThickness = 0.25;
|
||||
static float meshGetter(uint8_t x, uint8_t y, void*) {
|
||||
xy_uint8_t pos;
|
||||
pos.x = x;
|
||||
pos.y = y;
|
||||
pos.y = y;
|
||||
return ExtUI::getMeshPoint(pos);
|
||||
}
|
||||
|
||||
|
@ -46,6 +46,9 @@
|
||||
#elif HAS_UI_480x272
|
||||
#define TFT_WIDTH 480
|
||||
#define TFT_HEIGHT 272
|
||||
#elif HAS_UI_1024x600
|
||||
#define TFT_WIDTH 1024
|
||||
#define TFT_HEIGHT 600
|
||||
#else
|
||||
#error "Unsupported display resolution!"
|
||||
#endif
|
||||
|
927
Marlin/src/lcd/tft/ui_1024x600.cpp
Normal file
927
Marlin/src/lcd/tft/ui_1024x600.cpp
Normal file
@ -0,0 +1,927 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if HAS_UI_1024x600
|
||||
|
||||
#include "ui_common.h"
|
||||
|
||||
#include "../marlinui.h"
|
||||
#include "../menu/menu.h"
|
||||
#include "../../libs/numtostr.h"
|
||||
|
||||
#include "../../sd/cardreader.h"
|
||||
#include "../../module/temperature.h"
|
||||
#include "../../module/printcounter.h"
|
||||
#include "../../module/planner.h"
|
||||
#include "../../module/motion.h"
|
||||
|
||||
#if DISABLED(LCD_PROGRESS_BAR) && BOTH(FILAMENT_LCD_DISPLAY, SDSUPPORT)
|
||||
#include "../../feature/filwidth.h"
|
||||
#include "../../gcode/parser.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(AUTO_BED_LEVELING_UBL)
|
||||
#include "../../feature/bedlevel/bedlevel.h"
|
||||
#endif
|
||||
|
||||
void MarlinUI::tft_idle() {
|
||||
#if ENABLED(TOUCH_SCREEN)
|
||||
if (draw_menu_navigation) {
|
||||
add_control(104, TFT_HEIGHT - 34, PAGE_UP, imgPageUp, encoderTopLine > 0);
|
||||
add_control(344, TFT_HEIGHT - 34, PAGE_DOWN, imgPageDown, encoderTopLine + LCD_HEIGHT < screen_items);
|
||||
add_control(224, TFT_HEIGHT - 34, BACK, imgBack);
|
||||
draw_menu_navigation = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
tft.queue.async();
|
||||
TERN_(TOUCH_SCREEN, touch.idle());
|
||||
}
|
||||
|
||||
#if ENABLED(SHOW_BOOTSCREEN)
|
||||
void MarlinUI::show_bootscreen() {
|
||||
tft.queue.reset();
|
||||
|
||||
tft.canvas(0, 0, TFT_WIDTH, TFT_HEIGHT);
|
||||
#if ENABLED(BOOT_MARLIN_LOGO_SMALL)
|
||||
#define BOOT_LOGO_W 195 // MarlinLogo195x59x16
|
||||
#define BOOT_LOGO_H 59
|
||||
#define SITE_URL_Y (TFT_HEIGHT - 70)
|
||||
tft.set_background(COLOR_BACKGROUND);
|
||||
#else
|
||||
#define BOOT_LOGO_W TFT_WIDTH // MarlinLogo480x320x16
|
||||
#define BOOT_LOGO_H TFT_HEIGHT
|
||||
#define SITE_URL_Y (TFT_HEIGHT - 90)
|
||||
#endif
|
||||
tft.add_image((TFT_WIDTH - BOOT_LOGO_W) / 2, (TFT_HEIGHT - BOOT_LOGO_H) / 2, imgBootScreen);
|
||||
#ifdef WEBSITE_URL
|
||||
tft_string.set(WEBSITE_URL);
|
||||
tft.add_text(tft_string.center(TFT_WIDTH), SITE_URL_Y, COLOR_WEBSITE_URL, tft_string);
|
||||
#endif
|
||||
|
||||
tft.queue.sync();
|
||||
safe_delay(BOOTSCREEN_TIMEOUT);
|
||||
clear_lcd();
|
||||
}
|
||||
#endif
|
||||
|
||||
void MarlinUI::draw_kill_screen() {
|
||||
tft.queue.reset();
|
||||
tft.fill(0, 0, TFT_WIDTH, TFT_HEIGHT, COLOR_KILL_SCREEN_BG);
|
||||
|
||||
uint16_t line = 2;
|
||||
|
||||
menu_line(line++, COLOR_KILL_SCREEN_BG);
|
||||
tft_string.set(status_message);
|
||||
tft_string.trim();
|
||||
tft.add_text(tft_string.center(TFT_WIDTH), 0, COLOR_MENU_TEXT, tft_string);
|
||||
|
||||
line++;
|
||||
menu_line(line++, COLOR_KILL_SCREEN_BG);
|
||||
tft_string.set(GET_TEXT(MSG_HALTED));
|
||||
tft_string.trim();
|
||||
tft.add_text(tft_string.center(TFT_WIDTH), 0, COLOR_MENU_TEXT, tft_string);
|
||||
|
||||
menu_line(line++, COLOR_KILL_SCREEN_BG);
|
||||
tft_string.set(GET_TEXT(MSG_PLEASE_RESET));
|
||||
tft_string.trim();
|
||||
tft.add_text(tft_string.center(TFT_WIDTH), 0, COLOR_MENU_TEXT, tft_string);
|
||||
|
||||
tft.queue.sync();
|
||||
}
|
||||
|
||||
void draw_heater_status(uint16_t x, uint16_t y, const int8_t Heater) {
|
||||
MarlinImage image = imgHotEnd;
|
||||
uint16_t Color;
|
||||
celsius_t currentTemperature, targetTemperature;
|
||||
|
||||
if (Heater >= 0) { // HotEnd
|
||||
currentTemperature = thermalManager.degHotend(Heater);
|
||||
targetTemperature = thermalManager.degTargetHotend(Heater);
|
||||
}
|
||||
#if HAS_HEATED_BED
|
||||
else if (Heater == H_BED) {
|
||||
currentTemperature = thermalManager.degBed();
|
||||
targetTemperature = thermalManager.degTargetBed();
|
||||
}
|
||||
#endif
|
||||
#if HAS_TEMP_CHAMBER
|
||||
else if (Heater == H_CHAMBER) {
|
||||
currentTemperature = thermalManager.degChamber();
|
||||
#if HAS_HEATED_CHAMBER
|
||||
targetTemperature = thermalManager.degTargetChamber();
|
||||
#else
|
||||
targetTemperature = ABSOLUTE_ZERO;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#if HAS_TEMP_COOLER
|
||||
else if (Heater == H_COOLER) {
|
||||
currentTemperature = thermalManager.degCooler();
|
||||
targetTemperature = TERN(HAS_COOLER, thermalManager.degTargetCooler(), ABSOLUTE_ZERO);
|
||||
}
|
||||
#endif
|
||||
else return;
|
||||
|
||||
TERN_(TOUCH_SCREEN, if (targetTemperature >= 0) touch.add_control(HEATER, x, y, 80, 120, Heater));
|
||||
tft.canvas(x, y, 80, 120);
|
||||
tft.set_background(COLOR_BACKGROUND);
|
||||
|
||||
Color = currentTemperature < 0 ? COLOR_INACTIVE : COLOR_COLD;
|
||||
|
||||
if (Heater >= 0) { // HotEnd
|
||||
if (currentTemperature >= 50) Color = COLOR_HOTEND;
|
||||
}
|
||||
#if HAS_HEATED_BED
|
||||
else if (Heater == H_BED) {
|
||||
if (currentTemperature >= 50) Color = COLOR_HEATED_BED;
|
||||
image = targetTemperature > 0 ? imgBedHeated : imgBed;
|
||||
}
|
||||
#endif
|
||||
#if HAS_TEMP_CHAMBER
|
||||
else if (Heater == H_CHAMBER) {
|
||||
if (currentTemperature >= 50) Color = COLOR_CHAMBER;
|
||||
image = targetTemperature > 0 ? imgChamberHeated : imgChamber;
|
||||
}
|
||||
#endif
|
||||
|
||||
tft.add_image(8, 28, image, Color);
|
||||
|
||||
tft_string.set((uint8_t *)i16tostr3rj(currentTemperature));
|
||||
tft_string.add(LCD_STR_DEGREE);
|
||||
tft_string.trim();
|
||||
tft.add_text(tft_string.center(80) + 2, 82, Color, tft_string);
|
||||
|
||||
if (targetTemperature >= 0) {
|
||||
tft_string.set((uint8_t *)i16tostr3rj(targetTemperature));
|
||||
tft_string.add(LCD_STR_DEGREE);
|
||||
tft_string.trim();
|
||||
tft.add_text(tft_string.center(80) + 2, 8, Color, tft_string);
|
||||
}
|
||||
}
|
||||
|
||||
void draw_fan_status(uint16_t x, uint16_t y, const bool blink) {
|
||||
TERN_(TOUCH_SCREEN, touch.add_control(FAN, x, y, 80, 120));
|
||||
tft.canvas(x, y, 80, 120);
|
||||
tft.set_background(COLOR_BACKGROUND);
|
||||
|
||||
uint8_t fanSpeed = thermalManager.fan_speed[0];
|
||||
MarlinImage image;
|
||||
|
||||
if (fanSpeed >= 127)
|
||||
image = blink ? imgFanFast1 : imgFanFast0;
|
||||
else if (fanSpeed > 0)
|
||||
image = blink ? imgFanSlow1 : imgFanSlow0;
|
||||
else
|
||||
image = imgFanIdle;
|
||||
|
||||
tft.add_image(8, 20, image, COLOR_FAN);
|
||||
|
||||
tft_string.set((uint8_t *)ui8tostr4pctrj(thermalManager.fan_speed[0]));
|
||||
tft_string.trim();
|
||||
tft.add_text(tft_string.center(80) + 6, 82, COLOR_FAN, tft_string);
|
||||
}
|
||||
|
||||
void MarlinUI::draw_status_screen() {
|
||||
const bool blink = get_blink();
|
||||
|
||||
TERN_(TOUCH_SCREEN, touch.clear());
|
||||
|
||||
// heaters and fan
|
||||
uint16_t i, x, y = TFT_STATUS_TOP_Y;
|
||||
|
||||
for (i = 0 ; i < ITEMS_COUNT; i++) {
|
||||
x = (TFT_WIDTH / ITEMS_COUNT - 80) / 2 + (TFT_WIDTH * i / ITEMS_COUNT);
|
||||
switch (i) {
|
||||
#ifdef ITEM_E0
|
||||
case ITEM_E0: draw_heater_status(x, y, H_E0); break;
|
||||
#endif
|
||||
#ifdef ITEM_E1
|
||||
case ITEM_E1: draw_heater_status(x, y, H_E1); break;
|
||||
#endif
|
||||
#ifdef ITEM_E2
|
||||
case ITEM_E2: draw_heater_status(x, y, H_E2); break;
|
||||
#endif
|
||||
#ifdef ITEM_BED
|
||||
case ITEM_BED: draw_heater_status(x, y, H_BED); break;
|
||||
#endif
|
||||
#ifdef ITEM_CHAMBER
|
||||
case ITEM_CHAMBER: draw_heater_status(x, y, H_CHAMBER); break;
|
||||
#endif
|
||||
#ifdef ITEM_FAN
|
||||
case ITEM_FAN: draw_fan_status(x, y, blink); break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
y += 200;
|
||||
|
||||
// coordinates
|
||||
tft.canvas(4, y, TFT_WIDTH - 8, FONT_LINE_HEIGHT);
|
||||
tft.set_background(COLOR_BACKGROUND);
|
||||
tft.add_rectangle(0, 0, TFT_WIDTH - 8, FONT_LINE_HEIGHT, COLOR_AXIS_HOMED);
|
||||
|
||||
tft.add_text(200, 3, COLOR_AXIS_HOMED , "X");
|
||||
tft.add_text(500, 3, COLOR_AXIS_HOMED , "Y");
|
||||
tft.add_text(800, 3, COLOR_AXIS_HOMED , "Z");
|
||||
|
||||
bool not_homed = axis_should_home(X_AXIS);
|
||||
tft_string.set(blink && not_homed ? "?" : ftostr4sign(LOGICAL_X_POSITION(current_position.x)));
|
||||
tft.add_text(300 - tft_string.width(), 3, not_homed ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string);
|
||||
|
||||
not_homed = axis_should_home(Y_AXIS);
|
||||
tft_string.set(blink && not_homed ? "?" : ftostr4sign(LOGICAL_Y_POSITION(current_position.y)));
|
||||
tft.add_text(600 - tft_string.width(), 3, not_homed ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string);
|
||||
|
||||
uint16_t offset = 32;
|
||||
not_homed = axis_should_home(Z_AXIS);
|
||||
if (blink && not_homed)
|
||||
tft_string.set("?");
|
||||
else {
|
||||
const float z = LOGICAL_Z_POSITION(current_position.z);
|
||||
tft_string.set(ftostr52sp((int16_t)z));
|
||||
tft_string.rtrim();
|
||||
offset += tft_string.width();
|
||||
|
||||
tft_string.set(ftostr52sp(z));
|
||||
offset -= tft_string.width();
|
||||
}
|
||||
tft.add_text(900 - tft_string.width() - offset, 3, not_homed ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string);
|
||||
TERN_(TOUCH_SCREEN, touch.add_control(MOVE_AXIS, 4, y, TFT_WIDTH - 8, FONT_LINE_HEIGHT));
|
||||
|
||||
y += 100;
|
||||
// feed rate
|
||||
tft.canvas(274, y, 100, 32);
|
||||
tft.set_background(COLOR_BACKGROUND);
|
||||
uint16_t color = feedrate_percentage == 100 ? COLOR_RATE_100 : COLOR_RATE_ALTERED;
|
||||
tft.add_image(0, 0, imgFeedRate, color);
|
||||
tft_string.set(i16tostr3rj(feedrate_percentage));
|
||||
tft_string.add('%');
|
||||
tft.add_text(36, 1, color , tft_string);
|
||||
TERN_(TOUCH_SCREEN, touch.add_control(FEEDRATE, 96, 176, 100, 32));
|
||||
|
||||
// flow rate
|
||||
tft.canvas(650, y, 100, 32);
|
||||
tft.set_background(COLOR_BACKGROUND);
|
||||
color = planner.flow_percentage[0] == 100 ? COLOR_RATE_100 : COLOR_RATE_ALTERED;
|
||||
tft.add_image(0, 0, imgFlowRate, color);
|
||||
tft_string.set(i16tostr3rj(planner.flow_percentage[active_extruder]));
|
||||
tft_string.add('%');
|
||||
tft.add_text(36, 1, color , tft_string);
|
||||
TERN_(TOUCH_SCREEN, touch.add_control(FLOWRATE, 284, 176, 100, 32, active_extruder));
|
||||
|
||||
#if ENABLED(TOUCH_SCREEN)
|
||||
add_control(404, y, menu_main, imgSettings);
|
||||
TERN_(SDSUPPORT, add_control(12, y, menu_media, imgSD, !printingIsActive(), COLOR_CONTROL_ENABLED, card.isMounted() && printingIsActive() ? COLOR_BUSY : COLOR_CONTROL_DISABLED));
|
||||
#endif
|
||||
|
||||
y += 100;
|
||||
// print duration
|
||||
char buffer[14];
|
||||
duration_t elapsed = print_job_timer.duration();
|
||||
elapsed.toDigital(buffer);
|
||||
|
||||
tft.canvas((TFT_WIDTH - 128) / 2, y, 128, 29);
|
||||
tft.set_background(COLOR_BACKGROUND);
|
||||
tft_string.set(buffer);
|
||||
tft.add_text(tft_string.center(128), 0, COLOR_PRINT_TIME, tft_string);
|
||||
|
||||
y += 50;
|
||||
// progress bar
|
||||
const uint8_t progress = ui.get_progress_percent();
|
||||
tft.canvas(4, y, TFT_WIDTH - 8, 9);
|
||||
tft.set_background(COLOR_PROGRESS_BG);
|
||||
tft.add_rectangle(0, 0, TFT_WIDTH - 8, 9, COLOR_PROGRESS_FRAME);
|
||||
if (progress)
|
||||
tft.add_bar(1, 1, ((TFT_WIDTH - 10) * progress) / 100, 7, COLOR_PROGRESS_BAR);
|
||||
|
||||
y += 50;
|
||||
// status message
|
||||
tft.canvas(0, y, TFT_WIDTH, FONT_LINE_HEIGHT - 5);
|
||||
tft.set_background(COLOR_BACKGROUND);
|
||||
tft_string.set(status_message);
|
||||
tft_string.trim();
|
||||
tft.add_text(tft_string.center(TFT_WIDTH), 0, COLOR_STATUS_MESSAGE, tft_string);
|
||||
}
|
||||
|
||||
// Low-level draw_edit_screen can be used to draw an edit screen from anyplace
|
||||
void MenuEditItemBase::draw_edit_screen(PGM_P const pstr, const char * const value/*=nullptr*/) {
|
||||
ui.encoder_direction_normal();
|
||||
TERN_(TOUCH_SCREEN, touch.clear());
|
||||
|
||||
uint16_t line = 1;
|
||||
|
||||
menu_line(line++);
|
||||
tft_string.set(pstr, itemIndex, itemString);
|
||||
tft_string.trim();
|
||||
tft.add_text(tft_string.center(TFT_WIDTH), MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
|
||||
|
||||
TERN_(AUTO_BED_LEVELING_UBL, if (ui.external_control) line++); // ftostr52() will overwrite *value so *value has to be displayed first
|
||||
|
||||
menu_line(line);
|
||||
tft_string.set(value);
|
||||
tft_string.trim();
|
||||
tft.add_text(tft_string.center(TFT_WIDTH), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
|
||||
|
||||
#if ENABLED(AUTO_BED_LEVELING_UBL)
|
||||
if (ui.external_control) {
|
||||
menu_line(line - 1);
|
||||
|
||||
tft_string.set(X_LBL);
|
||||
tft.add_text((TFT_WIDTH / 2 - 120), MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
|
||||
tft_string.set(ftostr52(LOGICAL_X_POSITION(current_position.x)));
|
||||
tft_string.trim();
|
||||
tft.add_text((TFT_WIDTH / 2 - 16) - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
|
||||
|
||||
tft_string.set(Y_LBL);
|
||||
tft.add_text((TFT_WIDTH / 2 + 16), MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
|
||||
tft_string.set(ftostr52(LOGICAL_X_POSITION(current_position.y)));
|
||||
tft_string.trim();
|
||||
tft.add_text((TFT_WIDTH / 2 + 120) - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
|
||||
}
|
||||
#endif
|
||||
|
||||
extern screenFunc_t _manual_move_func_ptr;
|
||||
if (ui.currentScreen != _manual_move_func_ptr && !ui.external_control) {
|
||||
|
||||
#define SLIDER_LENGTH 336
|
||||
#define SLIDER_Y_POSITION 186
|
||||
|
||||
tft.canvas((TFT_WIDTH - SLIDER_LENGTH) / 2, SLIDER_Y_POSITION, SLIDER_LENGTH, 16);
|
||||
tft.set_background(COLOR_BACKGROUND);
|
||||
|
||||
int16_t position = (SLIDER_LENGTH - 2) * ui.encoderPosition / maxEditValue;
|
||||
tft.add_bar(0, 7, 1, 2, ui.encoderPosition == 0 ? COLOR_SLIDER_INACTIVE : COLOR_SLIDER);
|
||||
tft.add_bar(1, 6, position, 4, COLOR_SLIDER);
|
||||
tft.add_bar(position + 1, 6, SLIDER_LENGTH - 2 - position, 4, COLOR_SLIDER_INACTIVE);
|
||||
tft.add_bar(SLIDER_LENGTH - 1, 7, 1, 2, int32_t(ui.encoderPosition) == maxEditValue ? COLOR_SLIDER : COLOR_SLIDER_INACTIVE);
|
||||
|
||||
#if ENABLED(TOUCH_SCREEN)
|
||||
tft.add_image((SLIDER_LENGTH - 8) * ui.encoderPosition / maxEditValue, 0, imgSlider, COLOR_SLIDER);
|
||||
touch.add_control(SLIDER, (TFT_WIDTH - SLIDER_LENGTH) / 2, SLIDER_Y_POSITION - 8, SLIDER_LENGTH, 32, maxEditValue);
|
||||
#endif
|
||||
}
|
||||
|
||||
tft.draw_edit_screen_buttons();
|
||||
}
|
||||
|
||||
void TFT::draw_edit_screen_buttons() {
|
||||
#if ENABLED(TOUCH_SCREEN)
|
||||
add_control(64, TFT_HEIGHT - 64, DECREASE, imgDecrease);
|
||||
add_control(352, TFT_HEIGHT - 64, INCREASE, imgIncrease);
|
||||
add_control(208, TFT_HEIGHT - 64, CLICK, imgConfirm);
|
||||
#endif
|
||||
}
|
||||
|
||||
// The Select Screen presents a prompt and two "buttons"
|
||||
void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const bool yesno, PGM_P const pref, const char * const string/*=nullptr*/, PGM_P const suff/*=nullptr*/) {
|
||||
uint16_t line = 1;
|
||||
|
||||
if (!string) line++;
|
||||
|
||||
menu_line(line++);
|
||||
tft_string.set(pref);
|
||||
tft_string.trim();
|
||||
tft.add_text(tft_string.center(TFT_WIDTH), 0, COLOR_MENU_TEXT, tft_string);
|
||||
|
||||
if (string) {
|
||||
menu_line(line++);
|
||||
tft_string.set(string);
|
||||
tft_string.trim();
|
||||
tft.add_text(tft_string.center(TFT_WIDTH), 0, COLOR_MENU_TEXT, tft_string);
|
||||
}
|
||||
|
||||
if (suff) {
|
||||
menu_line(line);
|
||||
tft_string.set(suff);
|
||||
tft_string.trim();
|
||||
tft.add_text(tft_string.center(TFT_WIDTH), 0, COLOR_MENU_TEXT, tft_string);
|
||||
}
|
||||
#if ENABLED(TOUCH_SCREEN)
|
||||
add_control(88, TFT_HEIGHT - 64, CANCEL, imgCancel, true, yesno ? HALF(COLOR_CONTROL_CANCEL) : COLOR_CONTROL_CANCEL);
|
||||
add_control(328, TFT_HEIGHT - 64, CONFIRM, imgConfirm, true, yesno ? COLOR_CONTROL_CONFIRM : HALF(COLOR_CONTROL_CONFIRM));
|
||||
#else
|
||||
menu_line(++line);
|
||||
if (no) {
|
||||
tft_string.set(no);
|
||||
tft_string.trim();
|
||||
tft.add_text(tft_string.center(TFT_WIDTH / 2), 0, !yesno ? COLOR_RED : COLOR_MENU_TEXT, tft_string);
|
||||
}
|
||||
|
||||
if (yes) {
|
||||
tft_string.set(yes);
|
||||
tft_string.trim();
|
||||
tft.add_text(TFT_WIDTH / 2 + tft_string.center(TFT_WIDTH / 2), 0, yesno ? COLOR_RED : COLOR_MENU_TEXT, tft_string);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if ENABLED(ADVANCED_PAUSE_FEATURE)
|
||||
|
||||
void MarlinUI::draw_hotend_status(const uint8_t row, const uint8_t extruder) {
|
||||
#if ENABLED(TOUCH_SCREEN)
|
||||
touch.clear();
|
||||
draw_menu_navigation = false;
|
||||
touch.add_control(RESUME_CONTINUE , 0, 0, TFT_WIDTH, TFT_HEIGHT);
|
||||
#endif
|
||||
|
||||
menu_line(row);
|
||||
tft_string.set(GET_TEXT(MSG_FILAMENT_CHANGE_NOZZLE));
|
||||
tft_string.add('E');
|
||||
tft_string.add((char)('1' + extruder));
|
||||
tft_string.add(' ');
|
||||
tft_string.add(i16tostr3rj(thermalManager.degHotend(extruder)));
|
||||
tft_string.add(LCD_STR_DEGREE);
|
||||
tft_string.add(" / ");
|
||||
tft_string.add(i16tostr3rj(thermalManager.degTargetHotend(extruder)));
|
||||
tft_string.add(LCD_STR_DEGREE);
|
||||
tft_string.trim();
|
||||
tft.add_text(tft_string.center(TFT_WIDTH), 0, COLOR_MENU_TEXT, tft_string);
|
||||
}
|
||||
|
||||
#endif // ADVANCED_PAUSE_FEATURE
|
||||
|
||||
#if ENABLED(AUTO_BED_LEVELING_UBL)
|
||||
#define GRID_OFFSET_X 8
|
||||
#define GRID_OFFSET_Y 8
|
||||
#define GRID_WIDTH 192
|
||||
#define GRID_HEIGHT 192
|
||||
#define CONTROL_OFFSET 16
|
||||
|
||||
void MarlinUI::ubl_plot(const uint8_t x_plot, const uint8_t y_plot) {
|
||||
|
||||
tft.canvas(GRID_OFFSET_X, GRID_OFFSET_Y, GRID_WIDTH, GRID_HEIGHT);
|
||||
tft.set_background(COLOR_BACKGROUND);
|
||||
tft.add_rectangle(0, 0, GRID_WIDTH, GRID_HEIGHT, COLOR_WHITE);
|
||||
|
||||
for (uint16_t x = 0; x < GRID_MAX_POINTS_X ; x++)
|
||||
for (uint16_t y = 0; y < GRID_MAX_POINTS_Y ; y++)
|
||||
if (position_is_reachable({ ubl.mesh_index_to_xpos(x), ubl.mesh_index_to_ypos(y) }))
|
||||
tft.add_bar(1 + (x * 2 + 1) * (GRID_WIDTH - 4) / GRID_MAX_POINTS_X / 2, GRID_HEIGHT - 3 - ((y * 2 + 1) * (GRID_HEIGHT - 4) / GRID_MAX_POINTS_Y / 2), 2, 2, COLOR_UBL);
|
||||
|
||||
tft.add_rectangle((x_plot * 2 + 1) * (GRID_WIDTH - 4) / GRID_MAX_POINTS_X / 2 - 1, GRID_HEIGHT - 5 - ((y_plot * 2 + 1) * (GRID_HEIGHT - 4) / GRID_MAX_POINTS_Y / 2), 6, 6, COLOR_UBL);
|
||||
|
||||
const xy_pos_t pos = { ubl.mesh_index_to_xpos(x_plot), ubl.mesh_index_to_ypos(y_plot) },
|
||||
lpos = pos.asLogical();
|
||||
|
||||
tft.canvas(320, GRID_OFFSET_Y + (GRID_HEIGHT - MENU_ITEM_HEIGHT) / 2 - MENU_ITEM_HEIGHT, 120, MENU_ITEM_HEIGHT);
|
||||
tft.set_background(COLOR_BACKGROUND);
|
||||
tft_string.set(X_LBL);
|
||||
tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
|
||||
tft_string.set(ftostr52(lpos.x));
|
||||
tft_string.trim();
|
||||
tft.add_text(120 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
|
||||
|
||||
tft.canvas(320, GRID_OFFSET_Y + (GRID_HEIGHT - MENU_ITEM_HEIGHT) / 2, 120, MENU_ITEM_HEIGHT);
|
||||
tft.set_background(COLOR_BACKGROUND);
|
||||
tft_string.set(Y_LBL);
|
||||
tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
|
||||
tft_string.set(ftostr52(lpos.y));
|
||||
tft_string.trim();
|
||||
tft.add_text(120 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
|
||||
|
||||
tft.canvas(320, GRID_OFFSET_Y + (GRID_HEIGHT - MENU_ITEM_HEIGHT) / 2 + MENU_ITEM_HEIGHT, 120, MENU_ITEM_HEIGHT);
|
||||
tft.set_background(COLOR_BACKGROUND);
|
||||
tft_string.set(Z_LBL);
|
||||
tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
|
||||
tft_string.set(isnan(ubl.z_values[x_plot][y_plot]) ? "-----" : ftostr43sign(ubl.z_values[x_plot][y_plot]));
|
||||
tft_string.trim();
|
||||
tft.add_text(120 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
|
||||
|
||||
constexpr uint8_t w = (TFT_WIDTH) / 10;
|
||||
tft.canvas(GRID_OFFSET_X + (GRID_WIDTH - w) / 2, GRID_OFFSET_Y + GRID_HEIGHT + CONTROL_OFFSET - 5, w, MENU_ITEM_HEIGHT);
|
||||
tft.set_background(COLOR_BACKGROUND);
|
||||
tft_string.set(ui8tostr3rj(x_plot));
|
||||
tft_string.trim();
|
||||
tft.add_text(tft_string.center(w), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
|
||||
|
||||
tft.canvas(GRID_OFFSET_X + GRID_WIDTH + CONTROL_OFFSET + 16 - 24, GRID_OFFSET_Y + (GRID_HEIGHT - MENU_ITEM_HEIGHT) / 2, w, MENU_ITEM_HEIGHT);
|
||||
tft.set_background(COLOR_BACKGROUND);
|
||||
tft_string.set(ui8tostr3rj(y_plot));
|
||||
tft_string.trim();
|
||||
tft.add_text(tft_string.center(w), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
|
||||
|
||||
#if ENABLED(TOUCH_SCREEN)
|
||||
touch.clear();
|
||||
draw_menu_navigation = false;
|
||||
add_control(GRID_OFFSET_X + GRID_WIDTH + CONTROL_OFFSET, GRID_OFFSET_Y + CONTROL_OFFSET, UBL, ENCODER_STEPS_PER_MENU_ITEM * GRID_MAX_POINTS_X, imgUp);
|
||||
add_control(GRID_OFFSET_X + GRID_WIDTH + CONTROL_OFFSET, GRID_OFFSET_Y + GRID_HEIGHT - CONTROL_OFFSET - 32, UBL, - ENCODER_STEPS_PER_MENU_ITEM * GRID_MAX_POINTS_X, imgDown);
|
||||
add_control(GRID_OFFSET_X + CONTROL_OFFSET, GRID_OFFSET_Y + GRID_HEIGHT + CONTROL_OFFSET, UBL, - ENCODER_STEPS_PER_MENU_ITEM, imgLeft);
|
||||
add_control(GRID_OFFSET_X + GRID_WIDTH - CONTROL_OFFSET - 32, GRID_OFFSET_Y + GRID_HEIGHT + CONTROL_OFFSET, UBL, ENCODER_STEPS_PER_MENU_ITEM, imgRight);
|
||||
add_control(320, GRID_OFFSET_Y + GRID_HEIGHT + CONTROL_OFFSET, CLICK, imgLeveling);
|
||||
add_control(224, TFT_HEIGHT - 34, BACK, imgBack);
|
||||
#endif
|
||||
}
|
||||
#endif // AUTO_BED_LEVELING_UBL
|
||||
|
||||
#if ENABLED(BABYSTEP_ZPROBE_OFFSET)
|
||||
#include "../../feature/babystep.h"
|
||||
#endif
|
||||
|
||||
#if HAS_BED_PROBE
|
||||
#include "../../module/probe.h"
|
||||
#endif
|
||||
|
||||
#define Z_SELECTION_Z 1
|
||||
#define Z_SELECTION_Z_PROBE -1
|
||||
|
||||
struct MotionAxisState {
|
||||
xy_int_t xValuePos, yValuePos, zValuePos, eValuePos, stepValuePos, zTypePos, eNamePos;
|
||||
float currentStepSize = 10.0;
|
||||
int z_selection = Z_SELECTION_Z;
|
||||
uint8_t e_selection = 0;
|
||||
bool homming = false;
|
||||
bool blocked = false;
|
||||
char message[32];
|
||||
};
|
||||
|
||||
MotionAxisState motionAxisState;
|
||||
|
||||
#define E_BTN_COLOR COLOR_YELLOW
|
||||
#define X_BTN_COLOR COLOR_CORAL_RED
|
||||
#define Y_BTN_COLOR COLOR_VIVID_GREEN
|
||||
#define Z_BTN_COLOR COLOR_LIGHT_BLUE
|
||||
|
||||
#define BTN_WIDTH 64
|
||||
#define BTN_HEIGHT 52
|
||||
#define X_MARGIN 20
|
||||
#define Y_MARGIN 15
|
||||
|
||||
static void quick_feedback() {
|
||||
#if HAS_CHIRP
|
||||
ui.chirp(); // Buzz and wait. Is the delay needed for buttons to settle?
|
||||
#if BOTH(HAS_LCD_MENU, USE_BEEPER)
|
||||
for (int8_t i = 5; i--;) { buzzer.tick(); delay(2); }
|
||||
#elif HAS_LCD_MENU
|
||||
delay(10);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#define CUR_STEP_VALUE_WIDTH 104
|
||||
static void drawCurStepValue() {
|
||||
tft_string.set((uint8_t *)ftostr52sp(motionAxisState.currentStepSize));
|
||||
tft_string.add("mm");
|
||||
tft.canvas(motionAxisState.stepValuePos.x, motionAxisState.stepValuePos.y, CUR_STEP_VALUE_WIDTH, BTN_HEIGHT);
|
||||
tft.set_background(COLOR_BACKGROUND);
|
||||
tft.add_text(tft_string.center(CUR_STEP_VALUE_WIDTH), 0, COLOR_AXIS_HOMED, tft_string);
|
||||
}
|
||||
|
||||
static void drawCurZSelection() {
|
||||
tft_string.set("Z");
|
||||
tft.canvas(motionAxisState.zTypePos.x, motionAxisState.zTypePos.y, tft_string.width(), 34);
|
||||
tft.set_background(COLOR_BACKGROUND);
|
||||
tft.add_text(0, 0, Z_BTN_COLOR, tft_string);
|
||||
tft.queue.sync();
|
||||
tft_string.set("Offset");
|
||||
tft.canvas(motionAxisState.zTypePos.x, motionAxisState.zTypePos.y + 34, tft_string.width(), 34);
|
||||
tft.set_background(COLOR_BACKGROUND);
|
||||
if (motionAxisState.z_selection == Z_SELECTION_Z_PROBE) {
|
||||
tft.add_text(0, 0, Z_BTN_COLOR, tft_string);
|
||||
}
|
||||
}
|
||||
|
||||
static void drawCurESelection() {
|
||||
tft.canvas(motionAxisState.eNamePos.x, motionAxisState.eNamePos.y, BTN_WIDTH, BTN_HEIGHT);
|
||||
tft.set_background(COLOR_BACKGROUND);
|
||||
tft_string.set("E");
|
||||
tft.add_text(0, 0, E_BTN_COLOR , tft_string);
|
||||
tft.add_text(tft_string.width(), 0, E_BTN_COLOR, ui8tostr3rj(motionAxisState.e_selection));
|
||||
}
|
||||
|
||||
static void drawMessage(const char *msg) {
|
||||
tft.canvas(X_MARGIN, TFT_HEIGHT - Y_MARGIN - 34, TFT_HEIGHT / 2, 34);
|
||||
tft.set_background(COLOR_BACKGROUND);
|
||||
tft.add_text(0, 0, COLOR_YELLOW, msg);
|
||||
}
|
||||
|
||||
static void drawAxisValue(AxisEnum axis) {
|
||||
const float value =
|
||||
#if HAS_BED_PROBE
|
||||
axis == Z_AXIS && motionAxisState.z_selection == Z_SELECTION_Z_PROBE ?
|
||||
probe.offset.z :
|
||||
#endif
|
||||
NATIVE_TO_LOGICAL(
|
||||
ui.manual_move.processing ? destination[axis] : current_position[axis] + TERN0(IS_KINEMATIC, ui.manual_move.offset),
|
||||
axis
|
||||
);
|
||||
xy_int_t pos;
|
||||
uint16_t color;
|
||||
switch (axis) {
|
||||
case X_AXIS: pos = motionAxisState.xValuePos; color = X_BTN_COLOR; break;
|
||||
case Y_AXIS: pos = motionAxisState.yValuePos; color = Y_BTN_COLOR; break;
|
||||
case Z_AXIS: pos = motionAxisState.zValuePos; color = Z_BTN_COLOR; break;
|
||||
case E_AXIS: pos = motionAxisState.eValuePos; color = E_BTN_COLOR; break;
|
||||
default: return;
|
||||
}
|
||||
tft.canvas(pos.x, pos.y, BTN_WIDTH + X_MARGIN, BTN_HEIGHT);
|
||||
tft.set_background(COLOR_BACKGROUND);
|
||||
tft_string.set(ftostr52sp(value));
|
||||
tft.add_text(0, 0, color, tft_string);
|
||||
}
|
||||
|
||||
static void moveAxis(AxisEnum axis, const int8_t direction) {
|
||||
quick_feedback();
|
||||
|
||||
if (axis == E_AXIS && thermalManager.temp_hotend[motionAxisState.e_selection].celsius < EXTRUDE_MINTEMP) {
|
||||
drawMessage("Too cold");
|
||||
return;
|
||||
}
|
||||
|
||||
const float diff = motionAxisState.currentStepSize * direction;
|
||||
|
||||
if (axis == Z_AXIS && motionAxisState.z_selection == Z_SELECTION_Z_PROBE) {
|
||||
#if ENABLED(BABYSTEP_ZPROBE_OFFSET)
|
||||
const int16_t babystep_increment = direction * BABYSTEP_SIZE_Z;
|
||||
const bool do_probe = DISABLED(BABYSTEP_HOTEND_Z_OFFSET) || active_extruder == 0;
|
||||
const float bsDiff = planner.steps_to_mm[Z_AXIS] * babystep_increment,
|
||||
new_probe_offset = probe.offset.z + bsDiff,
|
||||
new_offs = TERN(BABYSTEP_HOTEND_Z_OFFSET
|
||||
, do_probe ? new_probe_offset : hotend_offset[active_extruder].z - bsDiff
|
||||
, new_probe_offset
|
||||
);
|
||||
if (WITHIN(new_offs, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) {
|
||||
babystep.add_steps(Z_AXIS, babystep_increment);
|
||||
if (do_probe)
|
||||
probe.offset.z = new_offs;
|
||||
else
|
||||
TERN(BABYSTEP_HOTEND_Z_OFFSET, hotend_offset[active_extruder].z = new_offs, NOOP);
|
||||
drawMessage(""); // clear the error
|
||||
drawAxisValue(axis);
|
||||
}
|
||||
else {
|
||||
drawMessage(GET_TEXT(MSG_LCD_SOFT_ENDSTOPS));
|
||||
}
|
||||
#elif HAS_BED_PROBE
|
||||
// only change probe.offset.z
|
||||
probe.offset.z += diff;
|
||||
if (direction < 0 && current_position[axis] < Z_PROBE_OFFSET_RANGE_MIN) {
|
||||
current_position[axis] = Z_PROBE_OFFSET_RANGE_MIN;
|
||||
drawMessage(GET_TEXT(MSG_LCD_SOFT_ENDSTOPS));
|
||||
}
|
||||
else if (direction > 0 && current_position[axis] > Z_PROBE_OFFSET_RANGE_MAX) {
|
||||
current_position[axis] = Z_PROBE_OFFSET_RANGE_MAX;
|
||||
drawMessage(GET_TEXT(MSG_LCD_SOFT_ENDSTOPS));
|
||||
}
|
||||
else {
|
||||
drawMessage(""); // clear the error
|
||||
}
|
||||
drawAxisValue(axis);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ui.manual_move.processing) {
|
||||
// Get motion limit from software endstops, if any
|
||||
float min, max;
|
||||
soft_endstop.get_manual_axis_limits(axis, min, max);
|
||||
|
||||
// Delta limits XY based on the current offset from center
|
||||
// This assumes the center is 0,0
|
||||
#if ENABLED(DELTA)
|
||||
if (axis != Z_AXIS && axis != E_AXIS) {
|
||||
max = SQRT(sq((float)(DELTA_PRINTABLE_RADIUS)) - sq(current_position[Y_AXIS - axis])); // (Y_AXIS - axis) == the other axis
|
||||
min = -max;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Get the new position
|
||||
#if IS_KINEMATIC
|
||||
ui.manual_move.offset += diff;
|
||||
if (direction < 0)
|
||||
NOLESS(ui.manual_move.offset, min - current_position[axis]);
|
||||
else
|
||||
NOMORE(ui.manual_move.offset, max - current_position[axis]);
|
||||
#else
|
||||
current_position[axis] += diff;
|
||||
const char *msg = NUL_STR; // clear the error
|
||||
if (direction < 0 && current_position[axis] < min) {
|
||||
current_position[axis] = min;
|
||||
msg = GET_TEXT(MSG_LCD_SOFT_ENDSTOPS);
|
||||
}
|
||||
else if (direction > 0 && current_position[axis] > max) {
|
||||
current_position[axis] = max;
|
||||
msg = GET_TEXT(MSG_LCD_SOFT_ENDSTOPS);
|
||||
}
|
||||
drawMessage(msg);
|
||||
#endif
|
||||
|
||||
ui.manual_move.soon(axis
|
||||
#if MULTI_MANUAL
|
||||
, motionAxisState.e_selection
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
drawAxisValue(axis);
|
||||
}
|
||||
|
||||
static void e_plus() { moveAxis(E_AXIS, 1); }
|
||||
static void e_minus() { moveAxis(E_AXIS, -1); }
|
||||
static void x_minus() { moveAxis(X_AXIS, -1); }
|
||||
static void x_plus() { moveAxis(X_AXIS, 1); }
|
||||
static void y_plus() { moveAxis(Y_AXIS, 1); }
|
||||
static void y_minus() { moveAxis(Y_AXIS, -1); }
|
||||
static void z_plus() { moveAxis(Z_AXIS, 1); }
|
||||
static void z_minus() { moveAxis(Z_AXIS, -1); }
|
||||
|
||||
#if ENABLED(TOUCH_SCREEN)
|
||||
static void e_select() {
|
||||
motionAxisState.e_selection++;
|
||||
if (motionAxisState.e_selection >= EXTRUDERS) {
|
||||
motionAxisState.e_selection = 0;
|
||||
}
|
||||
|
||||
quick_feedback();
|
||||
drawCurESelection();
|
||||
drawAxisValue(E_AXIS);
|
||||
}
|
||||
|
||||
static void do_home() {
|
||||
quick_feedback();
|
||||
drawMessage(GET_TEXT(MSG_LEVEL_BED_HOMING));
|
||||
queue.inject_P(G28_STR);
|
||||
// Disable touch until home is done
|
||||
TERN_(HAS_TFT_XPT2046, touch.disable());
|
||||
drawAxisValue(E_AXIS);
|
||||
drawAxisValue(X_AXIS);
|
||||
drawAxisValue(Y_AXIS);
|
||||
drawAxisValue(Z_AXIS);
|
||||
}
|
||||
|
||||
static void step_size() {
|
||||
motionAxisState.currentStepSize = motionAxisState.currentStepSize / 10.0;
|
||||
if (motionAxisState.currentStepSize < 0.0015) motionAxisState.currentStepSize = 10.0;
|
||||
quick_feedback();
|
||||
drawCurStepValue();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if HAS_BED_PROBE
|
||||
static void z_select() {
|
||||
motionAxisState.z_selection *= -1;
|
||||
quick_feedback();
|
||||
drawCurZSelection();
|
||||
drawAxisValue(Z_AXIS);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void disable_steppers() {
|
||||
quick_feedback();
|
||||
queue.inject_P(PSTR("M84"));
|
||||
}
|
||||
|
||||
static void drawBtn(int x, int y, const char *label, intptr_t data, MarlinImage img, uint16_t bgColor, bool enabled = true) {
|
||||
uint16_t width = Images[imgBtn52Rounded].width;
|
||||
uint16_t height = Images[imgBtn52Rounded].height;
|
||||
|
||||
if (!enabled) bgColor = COLOR_CONTROL_DISABLED;
|
||||
|
||||
tft.canvas(x, y, width, height);
|
||||
tft.set_background(COLOR_BACKGROUND);
|
||||
tft.add_image(0, 0, imgBtn52Rounded, bgColor, COLOR_BACKGROUND, COLOR_DARKGREY);
|
||||
|
||||
// TODO: Make an add_text() taking a font arg
|
||||
if (label) {
|
||||
tft_string.set(label);
|
||||
tft_string.trim();
|
||||
tft.add_text(tft_string.center(width), height / 2 - tft_string.font_height() / 2, bgColor, tft_string);
|
||||
}
|
||||
else {
|
||||
tft.add_image(0, 0, img, bgColor, COLOR_BACKGROUND, COLOR_DARKGREY);
|
||||
}
|
||||
|
||||
TERN_(HAS_TFT_XPT2046, if (enabled) touch.add_control(BUTTON, x, y, width, height, data));
|
||||
}
|
||||
|
||||
void MarlinUI::move_axis_screen() {
|
||||
// Reset
|
||||
defer_status_screen(true);
|
||||
motionAxisState.blocked = false;
|
||||
TERN_(HAS_TFT_XPT2046, touch.enable());
|
||||
|
||||
ui.clear_lcd();
|
||||
|
||||
TERN_(TOUCH_SCREEN, touch.clear());
|
||||
|
||||
const bool busy = printingIsActive();
|
||||
|
||||
// Babysteps during printing? Select babystep for Z probe offset
|
||||
if (busy && ENABLED(BABYSTEP_ZPROBE_OFFSET))
|
||||
motionAxisState.z_selection = Z_SELECTION_Z_PROBE;
|
||||
|
||||
// ROW 1 -> E- Y- CurY Z+
|
||||
int x = X_MARGIN, y = Y_MARGIN, spacing = 0;
|
||||
|
||||
drawBtn(x, y, "E+", (intptr_t)e_plus, imgUp, E_BTN_COLOR, !busy);
|
||||
|
||||
spacing = (TFT_WIDTH - X_MARGIN * 2 - 3 * BTN_WIDTH) / 2;
|
||||
x += BTN_WIDTH + spacing;
|
||||
drawBtn(x, y, "Y+", (intptr_t)y_plus, imgUp, Y_BTN_COLOR, !busy);
|
||||
|
||||
// Cur Y
|
||||
x += BTN_WIDTH;
|
||||
motionAxisState.yValuePos.x = x + 2;
|
||||
motionAxisState.yValuePos.y = y;
|
||||
drawAxisValue(Y_AXIS);
|
||||
|
||||
x += spacing;
|
||||
drawBtn(x, y, "Z+", (intptr_t)z_plus, imgUp, Z_BTN_COLOR, !busy || ENABLED(BABYSTEP_ZPROBE_OFFSET)); //only enabled when not busy or have baby step
|
||||
|
||||
// ROW 2 -> "Ex" X- HOME X+ "Z"
|
||||
y += BTN_HEIGHT + (TFT_HEIGHT - Y_MARGIN * 2 - 4 * BTN_HEIGHT) / 3;
|
||||
x = X_MARGIN;
|
||||
spacing = (TFT_WIDTH - X_MARGIN * 2 - 5 * BTN_WIDTH) / 4;
|
||||
|
||||
motionAxisState.eNamePos.x = x;
|
||||
motionAxisState.eNamePos.y = y;
|
||||
drawCurESelection();
|
||||
TERN_(HAS_TFT_XPT2046, if (!busy) touch.add_control(BUTTON, x, y, BTN_WIDTH, BTN_HEIGHT, (intptr_t)e_select));
|
||||
|
||||
x += BTN_WIDTH + spacing;
|
||||
drawBtn(x, y, "X-", (intptr_t)x_minus, imgLeft, X_BTN_COLOR, !busy);
|
||||
|
||||
x += BTN_WIDTH + spacing; //imgHome is 64x64
|
||||
TERN_(HAS_TFT_XPT2046, add_control(TFT_WIDTH / 2 - Images[imgHome].width / 2, y - (Images[imgHome].width - BTN_HEIGHT) / 2, BUTTON, (intptr_t)do_home, imgHome, !busy));
|
||||
|
||||
x += BTN_WIDTH + spacing;
|
||||
uint16_t xplus_x = x;
|
||||
drawBtn(x, y, "X+", (intptr_t)x_plus, imgRight, X_BTN_COLOR, !busy);
|
||||
|
||||
x += BTN_WIDTH + spacing;
|
||||
motionAxisState.zTypePos.x = x;
|
||||
motionAxisState.zTypePos.y = y;
|
||||
drawCurZSelection();
|
||||
#if BOTH(HAS_BED_PROBE, TOUCH_SCREEN)
|
||||
if (!busy) touch.add_control(BUTTON, x, y, BTN_WIDTH, 34 * 2, (intptr_t)z_select);
|
||||
#endif
|
||||
|
||||
// ROW 3 -> E- CurX Y- Z-
|
||||
y += BTN_HEIGHT + (TFT_HEIGHT - Y_MARGIN * 2 - 4 * BTN_HEIGHT) / 3;
|
||||
x = X_MARGIN;
|
||||
spacing = (TFT_WIDTH - X_MARGIN * 2 - 3 * BTN_WIDTH) / 2;
|
||||
|
||||
drawBtn(x, y, "E-", (intptr_t)e_minus, imgDown, E_BTN_COLOR, !busy);
|
||||
|
||||
// Cur E
|
||||
motionAxisState.eValuePos.x = x;
|
||||
motionAxisState.eValuePos.y = y + BTN_HEIGHT + 2;
|
||||
drawAxisValue(E_AXIS);
|
||||
|
||||
// Cur X
|
||||
motionAxisState.xValuePos.x = BTN_WIDTH + (TFT_WIDTH - X_MARGIN * 2 - 5 * BTN_WIDTH) / 4; //X- pos
|
||||
motionAxisState.xValuePos.y = y - 10;
|
||||
drawAxisValue(X_AXIS);
|
||||
|
||||
x += BTN_WIDTH + spacing;
|
||||
drawBtn(x, y, "Y-", (intptr_t)y_minus, imgDown, Y_BTN_COLOR, !busy);
|
||||
|
||||
x += BTN_WIDTH + spacing;
|
||||
drawBtn(x, y, "Z-", (intptr_t)z_minus, imgDown, Z_BTN_COLOR, !busy || ENABLED(BABYSTEP_ZPROBE_OFFSET)); //only enabled when not busy or have baby step
|
||||
|
||||
// Cur Z
|
||||
motionAxisState.zValuePos.x = x;
|
||||
motionAxisState.zValuePos.y = y + BTN_HEIGHT + 2;
|
||||
drawAxisValue(Z_AXIS);
|
||||
|
||||
// ROW 4 -> step_size disable steppers back
|
||||
y = TFT_HEIGHT - Y_MARGIN - 32; //
|
||||
x = TFT_WIDTH / 2 - CUR_STEP_VALUE_WIDTH / 2;
|
||||
motionAxisState.stepValuePos.x = x;
|
||||
motionAxisState.stepValuePos.y = y;
|
||||
if (!busy) {
|
||||
drawCurStepValue();
|
||||
TERN_(HAS_TFT_XPT2046, touch.add_control(BUTTON, motionAxisState.stepValuePos.x, motionAxisState.stepValuePos.y, CUR_STEP_VALUE_WIDTH, BTN_HEIGHT, (intptr_t)step_size));
|
||||
}
|
||||
|
||||
// aligned with x+
|
||||
drawBtn(xplus_x, TFT_HEIGHT - Y_MARGIN - BTN_HEIGHT, "off", (intptr_t)disable_steppers, imgCancel, COLOR_WHITE, !busy);
|
||||
|
||||
TERN_(HAS_TFT_XPT2046, add_control(TFT_WIDTH - X_MARGIN - BTN_WIDTH, y, BACK, imgBack));
|
||||
}
|
||||
|
||||
#undef BTN_WIDTH
|
||||
#undef BTN_HEIGHT
|
||||
|
||||
#endif // HAS_UI_480x320
|
43
Marlin/src/lcd/tft/ui_1024x600.h
Normal file
43
Marlin/src/lcd/tft/ui_1024x600.h
Normal file
@ -0,0 +1,43 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#define MARLIN_LOGO_FULL_SIZE MarlinLogo480x320x16
|
||||
|
||||
#include "ui_common.h"
|
||||
|
||||
#define TFT_STATUS_TOP_Y 4
|
||||
#define TFT_TOP_LINE_Y 4
|
||||
|
||||
#define MENU_TEXT_X_OFFSET 16
|
||||
#define MENU_TEXT_Y_OFFSET 7
|
||||
|
||||
#define MENU_ITEM_ICON_X 5
|
||||
#define MENU_ITEM_ICON_Y 5
|
||||
#define MENU_ITEM_ICON_SPACE 42
|
||||
|
||||
#define MENU_FONT_NAME Helvetica18
|
||||
#define SYMBOLS_FONT_NAME Helvetica18_symbols
|
||||
#define MENU_ITEM_HEIGHT 43
|
||||
#define FONT_LINE_HEIGHT 34
|
||||
|
||||
#define MENU_LINE_HEIGHT (MENU_ITEM_HEIGHT + 2)
|
@ -39,6 +39,10 @@
|
||||
#include "ui_320x240.h"
|
||||
#elif HAS_UI_480x320 || HAS_UI_480x272
|
||||
#include "ui_480x320.h"
|
||||
#elif HAS_UI_1024x600
|
||||
#include "ui_1024x600.h"
|
||||
#else
|
||||
#error "Unsupported display resolution!"
|
||||
#endif
|
||||
|
||||
void draw_heater_status(uint16_t x, uint16_t y, const int8_t Heater);
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
#include "tft_io.h"
|
||||
|
||||
#if HAS_SPI_TFT || HAS_FSMC_TFT
|
||||
#if HAS_SPI_TFT || HAS_FSMC_TFT || HAS_LTDC_TFT
|
||||
|
||||
#include "st7735.h"
|
||||
#include "st7789v.h"
|
||||
@ -90,6 +90,8 @@ if (lcd_id != 0xFFFFFFFF) return;
|
||||
lcd_id = io.GetID() & 0xFFFF;
|
||||
|
||||
switch (lcd_id) {
|
||||
case LTDC_RGB:
|
||||
break;
|
||||
case ST7796: // ST7796S 480x320
|
||||
DEBUG_ECHO_MSG(" ST7796S");
|
||||
write_esc_sequence(st7796s_init);
|
||||
@ -144,6 +146,17 @@ void TFT_IO::set_window(uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ym
|
||||
#endif
|
||||
|
||||
switch (lcd_id) {
|
||||
case LTDC_RGB:
|
||||
io.WriteReg(0x01);
|
||||
io.WriteData(Xmin);
|
||||
io.WriteReg(0x02);
|
||||
io.WriteData(Xmax);
|
||||
io.WriteReg(0x03);
|
||||
io.WriteData(Ymin);
|
||||
io.WriteReg(0x04);
|
||||
io.WriteData(Ymax);
|
||||
io.WriteReg(0x00);
|
||||
break;
|
||||
case ST7735: // ST7735 160x128
|
||||
case ST7789: // ST7789V 320x240
|
||||
case ST7796: // ST7796 480x320
|
||||
|
@ -23,14 +23,16 @@
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#if HAS_SPI_TFT || HAS_FSMC_TFT
|
||||
#if HAS_SPI_TFT || HAS_FSMC_TFT || HAS_LTDC_TFT
|
||||
|
||||
#if HAS_SPI_TFT
|
||||
#include HAL_PATH(../../HAL, tft/tft_spi.h)
|
||||
#elif HAS_FSMC_TFT
|
||||
#include HAL_PATH(../../HAL, tft/tft_fsmc.h)
|
||||
#elif HAS_LTDC_TFT
|
||||
#include HAL_PATH(../../HAL, tft/tft_ltdc.h)
|
||||
#else
|
||||
#error "TFT IO only supports SPI or FSMC interface"
|
||||
#error "TFT IO only supports SPI, FSMC or LTDC interface"
|
||||
#endif
|
||||
|
||||
#define TFT_EXCHANGE_XY (1UL << 1)
|
||||
@ -91,6 +93,7 @@
|
||||
#define TOUCH_ORIENTATION TOUCH_LANDSCAPE
|
||||
#endif
|
||||
|
||||
#define LTDC_RGB 0xABAB
|
||||
#define SSD1963 0x5761
|
||||
#define ST7735 0x89F0
|
||||
#define ST7789 0x8552
|
||||
|
@ -631,6 +631,8 @@
|
||||
#include "stm32f7/pins_REMRAM_V1.h" // STM32F7 env:REMRAM_V1
|
||||
#elif MB(NUCLEO_F767ZI)
|
||||
#include "stm32f7/pins_NUCLEO_F767ZI.h" // STM32F7 env:NUCLEO_F767ZI
|
||||
#elif MB(BTT_SKR_SE_BX)
|
||||
#include "stm32h7/pins_BTT_SKR_SE_BX.h" // STM32H7 env:BTT_SKR_SE_BX
|
||||
#elif MB(TEENSY41)
|
||||
#include "teensy4/pins_TEENSY41.h" // Teensy-4.x env:teensy41
|
||||
#elif MB(T41U5XBB)
|
||||
|
226
Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX.h
Normal file
226
Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX.h
Normal file
@ -0,0 +1,226 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#if NOT_TARGET(STM32H7)
|
||||
#error "Oops! Select an STM32H7 board in 'Tools > Board.'"
|
||||
#endif
|
||||
|
||||
#define BOARD_INFO_NAME "BTT SKR SE BX"
|
||||
#define DEFAULT_MACHINE_NAME "BIQU-BX"
|
||||
|
||||
// Onboard I2C EEPROM
|
||||
#define I2C_EEPROM
|
||||
#define MARLIN_EEPROM_SIZE 0x1000 // 4KB (24C32 ... 32Kb = 4KB)
|
||||
|
||||
// USB Flash Drive support
|
||||
#define HAS_OTG_USB_HOST_SUPPORT
|
||||
|
||||
//
|
||||
// Limit Switches
|
||||
//
|
||||
#define X_MIN_PIN PB11
|
||||
#define X_MAX_PIN PD13
|
||||
#define Y_MIN_PIN PB12
|
||||
#define Y_MAX_PIN PB13
|
||||
#define Z_MIN_PIN PD12
|
||||
#define Z_MAX_PIN PD11
|
||||
|
||||
#define FIL_RUNOUT_PIN PD13
|
||||
#define FIL_RUNOUT2_PIN PB13
|
||||
|
||||
#define LED_PIN PA13
|
||||
#define BEEPER_PIN PA14
|
||||
|
||||
#define TFT_BACKLIGHT_PIN PB5
|
||||
|
||||
#define POWER_MONITOR_PIN PB0
|
||||
#define RPI_POWER_PIN PE5
|
||||
|
||||
#define SAFE_POWER_PIN PI11
|
||||
#define SERVO0_PIN PA2
|
||||
|
||||
//
|
||||
// Z Probe (when not Z_MIN_PIN)
|
||||
//
|
||||
#ifndef Z_MIN_PROBE_PIN
|
||||
#define Z_MIN_PROBE_PIN PH2 // Probe
|
||||
#endif
|
||||
|
||||
//
|
||||
// Steppers
|
||||
//
|
||||
#define X_STEP_PIN PG13
|
||||
#define X_DIR_PIN PG12
|
||||
#define X_ENABLE_PIN PG14
|
||||
#define X_CS_PIN PG10
|
||||
|
||||
#define Y_STEP_PIN PB3
|
||||
#define Y_DIR_PIN PD3
|
||||
#define Y_ENABLE_PIN PB4
|
||||
#define Y_CS_PIN PD4
|
||||
|
||||
#define Z_STEP_PIN PD7
|
||||
#define Z_DIR_PIN PD6
|
||||
#define Z_ENABLE_PIN PG9
|
||||
#define Z_CS_PIN PD5
|
||||
|
||||
#define E0_STEP_PIN PC14
|
||||
#define E0_DIR_PIN PC13
|
||||
#define E0_ENABLE_PIN PC15
|
||||
#define E0_CS_PIN PI8
|
||||
|
||||
#define E1_STEP_PIN PA8
|
||||
#define E1_DIR_PIN PC9
|
||||
#define E1_ENABLE_PIN PD2
|
||||
#define E1_CS_PIN PC8
|
||||
|
||||
//
|
||||
// Software SPI pins for TMC2130 stepper drivers
|
||||
//
|
||||
#if ENABLED(TMC_USE_SW_SPI)
|
||||
#ifndef TMC_SW_MOSI
|
||||
#define TMC_SW_MOSI PC6
|
||||
#endif
|
||||
#ifndef TMC_SW_MISO
|
||||
#define TMC_SW_MISO PG3
|
||||
#endif
|
||||
#ifndef TMC_SW_SCK
|
||||
#define TMC_SW_SCK PC7
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if HAS_TMC_UART
|
||||
/**
|
||||
* TMC2208/TMC2209 stepper drivers
|
||||
*
|
||||
* Hardware serial communication ports.
|
||||
* If undefined software serial is used according to the pins below
|
||||
*/
|
||||
//#define X_HARDWARE_SERIAL Serial
|
||||
//#define X2_HARDWARE_SERIAL Serial1
|
||||
//#define Y_HARDWARE_SERIAL Serial1
|
||||
//#define Y2_HARDWARE_SERIAL Serial1
|
||||
//#define Z_HARDWARE_SERIAL Serial1
|
||||
//#define Z2_HARDWARE_SERIAL Serial1
|
||||
//#define E0_HARDWARE_SERIAL Serial1
|
||||
//#define E1_HARDWARE_SERIAL Serial1
|
||||
//#define E2_HARDWARE_SERIAL Serial1
|
||||
//#define E3_HARDWARE_SERIAL Serial1
|
||||
//#define E4_HARDWARE_SERIAL Serial1
|
||||
//#define E5_HARDWARE_SERIAL Serial1
|
||||
//#define E6_HARDWARE_SERIAL Serial1
|
||||
//#define E7_HARDWARE_SERIAL Serial1
|
||||
|
||||
//
|
||||
// Software serial
|
||||
//
|
||||
#define X_SERIAL_TX_PIN PG10
|
||||
#define X_SERIAL_RX_PIN PG10
|
||||
|
||||
#define Y_SERIAL_TX_PIN PD4
|
||||
#define Y_SERIAL_RX_PIN PD4
|
||||
|
||||
#define Z_SERIAL_TX_PIN PD5
|
||||
#define Z_SERIAL_RX_PIN PD5
|
||||
|
||||
#define E0_SERIAL_TX_PIN PI8
|
||||
#define E0_SERIAL_RX_PIN PI8
|
||||
|
||||
#define E1_SERIAL_TX_PIN PC8
|
||||
#define E1_SERIAL_RX_PIN PC8
|
||||
|
||||
// Reduce baud rate to improve software serial reliability
|
||||
#define TMC_BAUD_RATE 19200
|
||||
#endif
|
||||
|
||||
//
|
||||
// Temperature Sensors
|
||||
//
|
||||
#define TEMP_0_PIN PH4 // TH0
|
||||
#define TEMP_1_PIN PA3 // TH1
|
||||
#define TEMP_BED_PIN PH5 // TB
|
||||
|
||||
//
|
||||
// Heaters / Fans
|
||||
//
|
||||
#define HEATER_0_PIN PC4
|
||||
#define HEATER_1_PIN PC5
|
||||
#define HEATER_BED_PIN PA4
|
||||
|
||||
#define FAN_PIN PA5 // "FAN0"
|
||||
#define FAN1_PIN PA6 // "FAN1"
|
||||
#define FAN2_PIN PA7 // "FAN2"
|
||||
|
||||
#define NEOPIXEL_PIN PH3
|
||||
#define NEOPIXEL2_PIN PB1
|
||||
|
||||
#if HAS_LTDC_TFT
|
||||
|
||||
// LTDC_LCD Timing
|
||||
#define LTDC_LCD_CLK 50 // LTDC clock frequency = 50Mhz
|
||||
#define LTDC_LCD_HSYNC 30 // Horizontal synchronization
|
||||
#define LTDC_LCD_HBP 114 // Horizontal back porch
|
||||
#define LTDC_LCD_HFP 16 // Horizontal front porch
|
||||
#define LTDC_LCD_VSYNC 3 // Vertical synchronization
|
||||
#define LTDC_LCD_VBP 32 // Vertical back porch
|
||||
#define LTDC_LCD_VFP 10 // Vertical front porch
|
||||
|
||||
#define TFT_BACKLIGHT_PIN PB5
|
||||
#define LCD_DE_PIN PF10
|
||||
#define LCD_CLK_PIN PG7
|
||||
#define LCD_VSYNC_PIN PI9
|
||||
#define LCD_HSYNC_PIN PI10
|
||||
#define LCD_R7_PIN PG6 // R5
|
||||
#define LCD_R6_PIN PH12
|
||||
#define LCD_R5_PIN PH11
|
||||
#define LCD_R4_PIN PH10
|
||||
#define LCD_R3_PIN PH9
|
||||
#define LCD_G7_PIN PI2 // G6
|
||||
#define LCD_G6_PIN PI1
|
||||
#define LCD_G5_PIN PI0
|
||||
#define LCD_G4_PIN PH15
|
||||
#define LCD_G3_PIN PH14
|
||||
#define LCD_G2_PIN PH13
|
||||
#define LCD_B7_PIN PI7 // B5
|
||||
#define LCD_B6_PIN PI6
|
||||
#define LCD_B5_PIN PI5
|
||||
#define LCD_B4_PIN PI4
|
||||
#define LCD_B3_PIN PG11
|
||||
|
||||
#endif
|
||||
|
||||
#define BTN_EN1 PH6
|
||||
#define BTN_EN2 PH7
|
||||
#define BTN_ENC PH8
|
||||
|
||||
#ifndef SDCARD_CONNECTION
|
||||
#define SDCARD_CONNECTION ONBOARD
|
||||
#endif
|
||||
|
||||
#define SOFTWARE_SPI
|
||||
#define SDSS PA15
|
||||
#define SS_PIN SDSS
|
||||
#define SD_SCK_PIN PC10
|
||||
#define SD_MISO_PIN PC11
|
||||
#define SD_MOSI_PIN PC12
|
||||
#define SD_DETECT_PIN PI3
|
Reference in New Issue
Block a user