Move ExtUI subfolders up a level (#21820)
This commit is contained in:
committed by
Scott Lahteine
parent
0b3420a012
commit
d3e902af76
317
Marlin/src/lcd/extui/mks_ui/SPIFlashStorage.cpp
Normal file
317
Marlin/src/lcd/extui/mks_ui/SPIFlashStorage.cpp
Normal file
@ -0,0 +1,317 @@
|
||||
/**
|
||||
* 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_TFT_LVGL_UI
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
#include "SPIFlashStorage.h"
|
||||
|
||||
extern W25QXXFlash W25QXX;
|
||||
|
||||
uint8_t SPIFlashStorage::m_pageData[SPI_FLASH_PageSize];
|
||||
uint32_t SPIFlashStorage::m_currentPage;
|
||||
uint16_t SPIFlashStorage::m_pageDataUsed;
|
||||
uint32_t SPIFlashStorage::m_startAddress;
|
||||
|
||||
#if HAS_SPI_FLASH_COMPRESSION
|
||||
|
||||
uint8_t SPIFlashStorage::m_compressedData[SPI_FLASH_PageSize];
|
||||
uint16_t SPIFlashStorage::m_compressedDataUsed;
|
||||
|
||||
template <typename T>
|
||||
static uint32_t rle_compress(T *output, uint32_t outputLength, T *input, uint32_t inputLength, uint32_t& inputProcessed) {
|
||||
uint32_t count = 0, out = 0, index, i;
|
||||
T pixel;
|
||||
//32767 for uint16_t
|
||||
//127 for uint16_t
|
||||
//calculated at compile time
|
||||
constexpr T max = (0xFFFFFFFF >> (8 * (4 - sizeof(T)))) / 2;
|
||||
|
||||
inputProcessed = 0;
|
||||
while (count < inputLength && out < outputLength) {
|
||||
index = count;
|
||||
pixel = input[index++];
|
||||
while (index < inputLength && index - count < max && input[index] == pixel)
|
||||
index++;
|
||||
if (index - count == 1) {
|
||||
/*
|
||||
* Failed to "replicate" the current pixel. See how many to copy.
|
||||
* Avoid a replicate run of only 2-pixels after a literal run. There
|
||||
* is no gain in this, and there is a risK of loss if the run after
|
||||
* the two identical pixels is another literal run. So search for
|
||||
* 3 identical pixels.
|
||||
*/
|
||||
while (index < inputLength && index - count < max && (input[index] != input[index - 1] || (index > 1 && input[index] != input[index - 2])))
|
||||
index++;
|
||||
/*
|
||||
* Check why this run stopped. If it found two identical pixels, reset
|
||||
* the index so we can add a run. Do this twice: the previous run
|
||||
* tried to detect a replicate run of at least 3 pixels. So we may be
|
||||
* able to back up two pixels if such a replicate run was found.
|
||||
*/
|
||||
while (index < inputLength && input[index] == input[index - 1])
|
||||
index--;
|
||||
// If the output buffer could overflow, stop at the remaining bytes
|
||||
NOMORE(index, count + outputLength - out - 1);
|
||||
output[out++] = (uint16_t)(count - index);
|
||||
for (i = count; i < index; i++)
|
||||
output[out++] = input[i];
|
||||
}
|
||||
else {
|
||||
// Need at least more 2 spaces
|
||||
if (out > outputLength - 2) break;
|
||||
output[out++] = (uint16_t)(index - count);
|
||||
output[out++] = pixel;
|
||||
}
|
||||
count = index;
|
||||
}
|
||||
inputProcessed = count;
|
||||
|
||||
// Padding
|
||||
if (out == outputLength - 1) output[out++] = 0;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
template <typename UT, typename T>
|
||||
static uint32_t rle_uncompress(UT *output, uint32_t outputLength, UT *input, uint32_t inputLength, uint32_t &outputFilled) {
|
||||
T count;
|
||||
UT i;
|
||||
uint32_t processedBytes = 0;
|
||||
outputFilled = 0;
|
||||
|
||||
while (outputLength > 0 && inputLength > 0) {
|
||||
processedBytes++;
|
||||
count = static_cast<T>(*input++);
|
||||
inputLength--;
|
||||
if (count > 0) { // Replicate run
|
||||
for (i = 0; i < count && outputLength > i; i++)
|
||||
output[i] = *input;
|
||||
outputFilled += i;
|
||||
// If copy incomplete, change the input buffer to start with remaining data in the next call
|
||||
if (i < count) {
|
||||
// Change to process the difference in the next call
|
||||
*(input - 1) = static_cast<UT>(count - i);
|
||||
return processedBytes - 1;
|
||||
}
|
||||
input++;
|
||||
inputLength--;
|
||||
processedBytes++;
|
||||
}
|
||||
else if (count < 0) { // literal run
|
||||
count = static_cast<T>(-count);
|
||||
// Copy, validating if the output have enough space
|
||||
for (i = 0; i < count && outputLength > i; i++)
|
||||
output[i] = input[i];
|
||||
outputFilled += i;
|
||||
// If copy incomplete, change the input buffer to start with remaining data in the next call
|
||||
if (i < count) {
|
||||
input[i - 1] = static_cast<UT>((count - i) * -1);
|
||||
// Back one
|
||||
return processedBytes + i - 1;
|
||||
}
|
||||
input += count;
|
||||
inputLength -= count;
|
||||
processedBytes += count;
|
||||
}
|
||||
output += count;
|
||||
outputLength -= count;
|
||||
}
|
||||
|
||||
return processedBytes;
|
||||
}
|
||||
|
||||
#endif // HAS_SPI_FLASH_COMPRESSION
|
||||
|
||||
void SPIFlashStorage::beginWrite(uint32_t startAddress) {
|
||||
m_pageDataUsed = 0;
|
||||
m_currentPage = 0;
|
||||
m_startAddress = startAddress;
|
||||
#if HAS_SPI_FLASH_COMPRESSION
|
||||
// Restart the compressed buffer, keep the pointers of the uncompressed buffer
|
||||
m_compressedDataUsed = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void SPIFlashStorage::endWrite() {
|
||||
// Flush remaining data
|
||||
#if HAS_SPI_FLASH_COMPRESSION
|
||||
if (m_compressedDataUsed > 0) {
|
||||
flushPage();
|
||||
savePage(m_compressedData);
|
||||
}
|
||||
#else
|
||||
if (m_pageDataUsed > 0) flushPage();
|
||||
#endif
|
||||
}
|
||||
|
||||
void SPIFlashStorage::savePage(uint8_t *buffer) {
|
||||
W25QXX.SPI_FLASH_BufferWrite(buffer, m_startAddress + (SPI_FLASH_PageSize * m_currentPage), SPI_FLASH_PageSize);
|
||||
// Test env
|
||||
// char fname[256];
|
||||
// snprintf(fname, sizeof(fname), "./pages/page-%03d.data", m_currentPage);
|
||||
// FILE *fp = fopen(fname, "wb");
|
||||
// fwrite(buffer, 1, m_compressedDataUsed, fp);
|
||||
// fclose(fp);
|
||||
}
|
||||
|
||||
void SPIFlashStorage::loadPage(uint8_t *buffer) {
|
||||
W25QXX.SPI_FLASH_BufferRead(buffer, m_startAddress + (SPI_FLASH_PageSize * m_currentPage), SPI_FLASH_PageSize);
|
||||
// Test env
|
||||
// char fname[256];
|
||||
// snprintf(fname, sizeof(fname), "./pages/page-%03d.data", m_currentPage);
|
||||
// FILE *fp = fopen(fname, "rb");
|
||||
// if (fp) {
|
||||
// fread(buffer, 1, SPI_FLASH_PageSize, fp);
|
||||
// fclose(fp);
|
||||
// }
|
||||
}
|
||||
|
||||
void SPIFlashStorage::flushPage() {
|
||||
#if HAS_SPI_FLASH_COMPRESSION
|
||||
// Work com with compressed in memory
|
||||
uint32_t inputProcessed;
|
||||
uint32_t compressedSize = rle_compress<uint16_t>((uint16_t *)(m_compressedData + m_compressedDataUsed), compressedDataFree() / 2, (uint16_t *)m_pageData, m_pageDataUsed / 2, inputProcessed) * 2;
|
||||
inputProcessed *= 2;
|
||||
m_compressedDataUsed += compressedSize;
|
||||
|
||||
// Space remaining in the compressed buffer?
|
||||
if (compressedDataFree() > 0) {
|
||||
// Free the uncompressed buffer
|
||||
m_pageDataUsed = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
// Part of the m_pageData was compressed, so ajust the pointers, freeing what was processed, shift the buffer
|
||||
// TODO: To avoid this copy, use a circular buffer
|
||||
memmove(m_pageData, m_pageData + inputProcessed, m_pageDataUsed - inputProcessed);
|
||||
m_pageDataUsed -= inputProcessed;
|
||||
|
||||
// No? So flush page with compressed data!!
|
||||
uint8_t *buffer = m_compressedData;
|
||||
#else
|
||||
uint8_t *buffer = m_pageData;
|
||||
#endif
|
||||
|
||||
savePage(buffer);
|
||||
|
||||
#if HAS_SPI_FLASH_COMPRESSION
|
||||
// Restart the compressed buffer, keep the pointers of the uncompressed buffer
|
||||
m_compressedDataUsed = 0;
|
||||
#else
|
||||
m_pageDataUsed = 0;
|
||||
#endif
|
||||
m_currentPage++;
|
||||
}
|
||||
|
||||
void SPIFlashStorage::readPage() {
|
||||
#if HAS_SPI_FLASH_COMPRESSION
|
||||
if (compressedDataFree() == 0) {
|
||||
loadPage(m_compressedData);
|
||||
m_currentPage++;
|
||||
m_compressedDataUsed = 0;
|
||||
}
|
||||
|
||||
// Need to uncompress data
|
||||
if (pageDataFree() == 0) {
|
||||
m_pageDataUsed = 0;
|
||||
uint32_t outpuProcessed = 0;
|
||||
uint32_t inputProcessed = rle_uncompress<uint16_t, int16_t>((uint16_t *)(m_pageData + m_pageDataUsed), pageDataFree() / 2, (uint16_t *)(m_compressedData + m_compressedDataUsed), compressedDataFree() / 2, outpuProcessed);
|
||||
inputProcessed *= 2;
|
||||
outpuProcessed *= 2;
|
||||
if (outpuProcessed < pageDataFree()) {
|
||||
m_pageDataUsed = SPI_FLASH_PageSize - outpuProcessed;
|
||||
// TODO: To avoid this copy, use a circular buffer
|
||||
memmove(m_pageData + m_pageDataUsed, m_pageData, outpuProcessed);
|
||||
}
|
||||
|
||||
m_compressedDataUsed += inputProcessed;
|
||||
}
|
||||
#else
|
||||
loadPage(m_pageData);
|
||||
m_pageDataUsed = 0;
|
||||
m_currentPage++;
|
||||
#endif
|
||||
}
|
||||
|
||||
uint16_t SPIFlashStorage::inData(uint8_t *data, uint16_t size) {
|
||||
// Don't write more than we can
|
||||
NOMORE(size, pageDataFree());
|
||||
memcpy(m_pageData + m_pageDataUsed, data, size);
|
||||
m_pageDataUsed += size;
|
||||
return size;
|
||||
}
|
||||
|
||||
void SPIFlashStorage::writeData(uint8_t *data, uint16_t size) {
|
||||
// Flush a page if needed
|
||||
if (pageDataFree() == 0) flushPage();
|
||||
|
||||
while (size > 0) {
|
||||
uint16_t written = inData(data, size);
|
||||
size -= written;
|
||||
// Need to write more? Flush page and continue!
|
||||
if (size > 0) {
|
||||
flushPage();
|
||||
data += written;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SPIFlashStorage::beginRead(uint32_t startAddress) {
|
||||
m_startAddress = startAddress;
|
||||
m_currentPage = 0;
|
||||
// Nothing in memory now
|
||||
m_pageDataUsed = SPI_FLASH_PageSize;
|
||||
#if HAS_SPI_FLASH_COMPRESSION
|
||||
m_compressedDataUsed = sizeof(m_compressedData);
|
||||
#endif
|
||||
}
|
||||
|
||||
uint16_t SPIFlashStorage::outData(uint8_t *data, uint16_t size) {
|
||||
// Don't read more than we have
|
||||
NOMORE(size, pageDataFree());
|
||||
memcpy(data, m_pageData + m_pageDataUsed, size);
|
||||
m_pageDataUsed += size;
|
||||
return size;
|
||||
}
|
||||
|
||||
void SPIFlashStorage::readData(uint8_t *data, uint16_t size) {
|
||||
// Read a page if needed
|
||||
if (pageDataFree() == 0) readPage();
|
||||
|
||||
while (size > 0) {
|
||||
uint16_t read = outData(data, size);
|
||||
size -= read;
|
||||
// Need to write more? Flush page and continue!
|
||||
if (size > 0) {
|
||||
readPage();
|
||||
data += read;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SPIFlashStorage SPIFlash;
|
||||
|
||||
#endif // HAS_TFT_LVGL_UI
|
108
Marlin/src/lcd/extui/mks_ui/SPIFlashStorage.h
Normal file
108
Marlin/src/lcd/extui/mks_ui/SPIFlashStorage.h
Normal file
@ -0,0 +1,108 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#include "../../../libs/W25Qxx.h"
|
||||
|
||||
#define HAS_SPI_FLASH_COMPRESSION 1
|
||||
|
||||
/**
|
||||
* This class manages and optimizes SPI Flash data storage,
|
||||
* keeping an internal buffer to write and save full SPI flash
|
||||
* pages as needed.
|
||||
*
|
||||
* Since the data is always in the buffer, the class is also
|
||||
* able to support fast on-the-fly RLE compression/decompression.
|
||||
*
|
||||
* In testing with the current LVGL_UI it compacts 2.9MB of icons
|
||||
* (which have lots of runs) down to 370kB!!! As a result the UI
|
||||
* refresh rate becomes faster and now all LVGL UI can fit into a
|
||||
* tiny 2MB SPI Flash, such as the Chitu Board.
|
||||
*
|
||||
* == Usage ==
|
||||
*
|
||||
* Writing:
|
||||
*
|
||||
* The class keeps an internal buffer that caches data until it
|
||||
* fits into a full SPI Flash page. Each time the buffer fills up
|
||||
* the page is saved to SPI Flash. Sequential writes are optimal.
|
||||
*
|
||||
* SPIFlashStorage.beginWrite(myStartAddress);
|
||||
* while (there is data to write)
|
||||
* SPIFlashStorage.addData(myBuffer, bufferSize);
|
||||
* SPIFlashStorage.endWrite(); // Flush remaining buffer data
|
||||
*
|
||||
* Reading:
|
||||
*
|
||||
* When reading, it loads a full page from SPI Flash at once and
|
||||
* keeps it in a private SRAM buffer. Data is loaded as needed to
|
||||
* fullfill requests. Sequential reads are optimal.
|
||||
*
|
||||
* SPIFlashStorage.beginRead(myStartAddress);
|
||||
* while (there is data to read)
|
||||
* SPIFlashStorage.readData(myBuffer, bufferSize);
|
||||
*
|
||||
* Compression:
|
||||
*
|
||||
* The biggest advantage of this class is the RLE compression.
|
||||
* With compression activated a second buffer holds the compressed
|
||||
* data, so when writing data, as this buffer becomes full it is
|
||||
* flushed to SPI Flash.
|
||||
*
|
||||
* The same goes for reading: A compressed page is read from SPI
|
||||
* flash, and the data is uncompressed as needed to provide the
|
||||
* requested amount of data.
|
||||
*/
|
||||
class SPIFlashStorage {
|
||||
public:
|
||||
// Write operation
|
||||
static void beginWrite(uint32_t startAddress);
|
||||
static void endWrite();
|
||||
static void writeData(uint8_t *data, uint16_t size);
|
||||
|
||||
// Read operation
|
||||
static void beginRead(uint32_t startAddress);
|
||||
static void readData(uint8_t *data, uint16_t size);
|
||||
|
||||
static uint32_t getCurrentPage() { return m_currentPage; }
|
||||
|
||||
private:
|
||||
static void flushPage();
|
||||
static void savePage(uint8_t *buffer);
|
||||
static void loadPage(uint8_t *buffer);
|
||||
static void readPage();
|
||||
static uint16_t inData(uint8_t *data, uint16_t size);
|
||||
static uint16_t outData(uint8_t *data, uint16_t size);
|
||||
|
||||
static uint8_t m_pageData[SPI_FLASH_PageSize];
|
||||
static uint32_t m_currentPage;
|
||||
static uint16_t m_pageDataUsed;
|
||||
static inline uint16_t pageDataFree() { return SPI_FLASH_PageSize - m_pageDataUsed; }
|
||||
static uint32_t m_startAddress;
|
||||
#if HAS_SPI_FLASH_COMPRESSION
|
||||
static uint8_t m_compressedData[SPI_FLASH_PageSize];
|
||||
static uint16_t m_compressedDataUsed;
|
||||
static inline uint16_t compressedDataFree() { return SPI_FLASH_PageSize - m_compressedDataUsed; }
|
||||
#endif
|
||||
};
|
||||
|
||||
extern SPIFlashStorage SPIFlash;
|
86
Marlin/src/lcd/extui/mks_ui/SPI_TFT.cpp
Normal file
86
Marlin/src/lcd/extui/mks_ui/SPI_TFT.cpp
Normal file
@ -0,0 +1,86 @@
|
||||
/**
|
||||
* 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_TFT_LVGL_UI
|
||||
|
||||
#include "SPI_TFT.h"
|
||||
#include "pic_manager.h"
|
||||
#include "tft_lvgl_configuration.h"
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
#include <SPI.h>
|
||||
|
||||
#include "draw_ui.h"
|
||||
|
||||
TFT SPI_TFT;
|
||||
|
||||
// use SPI1 for the spi tft.
|
||||
void TFT::spi_init(uint8_t spiRate) {
|
||||
tftio.Init();
|
||||
}
|
||||
|
||||
void TFT::SetPoint(uint16_t x, uint16_t y, uint16_t point) {
|
||||
if ((x > 480) || (y > 320)) return;
|
||||
|
||||
setWindow(x, y, 1, 1);
|
||||
tftio.WriteMultiple(point, (uint16_t)1);
|
||||
}
|
||||
|
||||
void TFT::setWindow(uint16_t x, uint16_t y, uint16_t with, uint16_t height) {
|
||||
tftio.set_window(x, y, (x + with - 1), (y + height - 1));
|
||||
}
|
||||
|
||||
void TFT::LCD_init() {
|
||||
tftio.InitTFT();
|
||||
#if PIN_EXISTS(TFT_BACKLIGHT)
|
||||
OUT_WRITE(TFT_BACKLIGHT_PIN, LOW);
|
||||
#endif
|
||||
delay(100);
|
||||
LCD_clear(0x0000);
|
||||
LCD_Draw_Logo();
|
||||
#if PIN_EXISTS(TFT_BACKLIGHT)
|
||||
OUT_WRITE(TFT_BACKLIGHT_PIN, HIGH);
|
||||
#endif
|
||||
#if HAS_LOGO_IN_FLASH
|
||||
delay(2000);
|
||||
#endif
|
||||
}
|
||||
|
||||
void TFT::LCD_clear(uint16_t color) {
|
||||
setWindow(0, 0, (TFT_WIDTH), (TFT_HEIGHT));
|
||||
tftio.WriteMultiple(color, (uint32_t)(TFT_WIDTH) * (TFT_HEIGHT));
|
||||
}
|
||||
|
||||
void TFT::LCD_Draw_Logo() {
|
||||
#if HAS_LOGO_IN_FLASH
|
||||
setWindow(0, 0, TFT_WIDTH, TFT_HEIGHT);
|
||||
for (uint16_t i = 0; i < (TFT_HEIGHT); i ++) {
|
||||
Pic_Logo_Read((uint8_t *)"", (uint8_t *)bmp_public_buf, (TFT_WIDTH) * 2);
|
||||
tftio.WriteSequence((uint16_t *)bmp_public_buf, TFT_WIDTH);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // HAS_TFT_LVGL_UI
|
38
Marlin/src/lcd/extui/mks_ui/SPI_TFT.h
Normal file
38
Marlin/src/lcd/extui/mks_ui/SPI_TFT.h
Normal file
@ -0,0 +1,38 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#include "../../tft_io/tft_io.h"
|
||||
#include <stdint.h>
|
||||
|
||||
class TFT {
|
||||
public:
|
||||
TFT_IO tftio;
|
||||
void spi_init(uint8_t spiRate);
|
||||
void SetPoint(uint16_t x, uint16_t y, uint16_t point);
|
||||
void setWindow(uint16_t x, uint16_t y, uint16_t with, uint16_t height);
|
||||
void LCD_init();
|
||||
void LCD_clear(uint16_t color);
|
||||
void LCD_Draw_Logo();
|
||||
};
|
||||
|
||||
extern TFT SPI_TFT;
|
65
Marlin/src/lcd/extui/mks_ui/draw_about.cpp
Normal file
65
Marlin/src/lcd/extui/mks_ui/draw_about.cpp
Normal file
@ -0,0 +1,65 @@
|
||||
/**
|
||||
* 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_TFT_LVGL_UI
|
||||
|
||||
#include "draw_ui.h"
|
||||
#include <lv_conf.h>
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
extern lv_group_t *g;
|
||||
static lv_obj_t *scr;
|
||||
static lv_obj_t *fw_type, *board;
|
||||
|
||||
enum { ID_A_RETURN = 1 };
|
||||
|
||||
static void event_handler(lv_obj_t *obj, lv_event_t event) {
|
||||
if (event != LV_EVENT_RELEASED) return;
|
||||
switch (obj->mks_obj_id) {
|
||||
case ID_A_RETURN:
|
||||
clear_cur_ui();
|
||||
draw_return_ui();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void lv_draw_about() {
|
||||
scr = lv_screen_create(ABOUT_UI);
|
||||
lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_A_RETURN);
|
||||
|
||||
fw_type = lv_label_create(scr, "Firmware: Marlin " SHORT_BUILD_VERSION);
|
||||
lv_obj_align(fw_type, nullptr, LV_ALIGN_CENTER, 0, -20);
|
||||
|
||||
board = lv_label_create(scr, "Board: " BOARD_INFO_NAME);
|
||||
lv_obj_align(board, nullptr, LV_ALIGN_CENTER, 0, -60);
|
||||
}
|
||||
|
||||
void lv_clear_about() {
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
|
||||
#endif
|
||||
lv_obj_del(scr);
|
||||
}
|
||||
|
||||
#endif // HAS_TFT_LVGL_UI
|
33
Marlin/src/lcd/extui/mks_ui/draw_about.h
Normal file
33
Marlin/src/lcd/extui/mks_ui/draw_about.h
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* C-declarations for C++ */
|
||||
#endif
|
||||
|
||||
void lv_draw_about();
|
||||
void lv_clear_about();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C-declarations for C++ */
|
||||
#endif
|
153
Marlin/src/lcd/extui/mks_ui/draw_acceleration_settings.cpp
Normal file
153
Marlin/src/lcd/extui/mks_ui/draw_acceleration_settings.cpp
Normal file
@ -0,0 +1,153 @@
|
||||
/**
|
||||
* 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_TFT_LVGL_UI
|
||||
|
||||
#include "draw_ui.h"
|
||||
#include <lv_conf.h>
|
||||
|
||||
#include "../../../module/planner.h"
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
extern lv_group_t *g;
|
||||
static lv_obj_t *scr;
|
||||
|
||||
enum {
|
||||
ID_ACCE_RETURN = 1,
|
||||
ID_ACCE_PRINT,
|
||||
ID_ACCE_RETRA,
|
||||
ID_ACCE_TRAVEL,
|
||||
ID_ACCE_X,
|
||||
ID_ACCE_Y,
|
||||
ID_ACCE_Z,
|
||||
ID_ACCE_E0,
|
||||
ID_ACCE_E1,
|
||||
ID_ACCE_UP,
|
||||
ID_ACCE_DOWN
|
||||
};
|
||||
|
||||
static void event_handler(lv_obj_t *obj, lv_event_t event) {
|
||||
if (event != LV_EVENT_RELEASED) return;
|
||||
switch (obj->mks_obj_id) {
|
||||
case ID_ACCE_RETURN:
|
||||
uiCfg.para_ui_page = false;
|
||||
lv_clear_acceleration_settings();
|
||||
draw_return_ui();
|
||||
break;
|
||||
case ID_ACCE_PRINT:
|
||||
value = PrintAcceleration;
|
||||
lv_clear_acceleration_settings();
|
||||
lv_draw_number_key();
|
||||
break;
|
||||
case ID_ACCE_RETRA:
|
||||
value = RetractAcceleration;
|
||||
lv_clear_acceleration_settings();
|
||||
lv_draw_number_key();
|
||||
break;
|
||||
case ID_ACCE_TRAVEL:
|
||||
value = TravelAcceleration;
|
||||
lv_clear_acceleration_settings();
|
||||
lv_draw_number_key();
|
||||
break;
|
||||
case ID_ACCE_X:
|
||||
value = XAcceleration;
|
||||
lv_clear_acceleration_settings();
|
||||
lv_draw_number_key();
|
||||
break;
|
||||
case ID_ACCE_Y:
|
||||
value = YAcceleration;
|
||||
lv_clear_acceleration_settings();
|
||||
lv_draw_number_key();
|
||||
break;
|
||||
case ID_ACCE_Z:
|
||||
value = ZAcceleration;
|
||||
lv_clear_acceleration_settings();
|
||||
lv_draw_number_key();
|
||||
break;
|
||||
case ID_ACCE_E0:
|
||||
value = E0Acceleration;
|
||||
lv_clear_acceleration_settings();
|
||||
lv_draw_number_key();
|
||||
break;
|
||||
case ID_ACCE_E1:
|
||||
value = E1Acceleration;
|
||||
lv_clear_acceleration_settings();
|
||||
lv_draw_number_key();
|
||||
break;
|
||||
case ID_ACCE_UP:
|
||||
uiCfg.para_ui_page = false;
|
||||
lv_clear_acceleration_settings();
|
||||
lv_draw_acceleration_settings();
|
||||
break;
|
||||
case ID_ACCE_DOWN:
|
||||
uiCfg.para_ui_page = true;
|
||||
lv_clear_acceleration_settings();
|
||||
lv_draw_acceleration_settings();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void lv_draw_acceleration_settings() {
|
||||
scr = lv_screen_create(ACCELERATION_UI, machine_menu.AccelerationConfTitle);
|
||||
if (!uiCfg.para_ui_page) {
|
||||
dtostrf(planner.settings.acceleration, 1, 1, public_buf_l);
|
||||
lv_screen_menu_item_1_edit(scr, machine_menu.PrintAcceleration, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_ACCE_PRINT, 0, public_buf_l);
|
||||
|
||||
dtostrf(planner.settings.retract_acceleration, 1, 1, public_buf_l);
|
||||
lv_screen_menu_item_1_edit(scr, machine_menu.RetractAcceleration, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_ACCE_RETRA, 1, public_buf_l);
|
||||
|
||||
dtostrf(planner.settings.travel_acceleration, 1, 1, public_buf_l);
|
||||
lv_screen_menu_item_1_edit(scr, machine_menu.TravelAcceleration, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_ACCE_TRAVEL, 2, public_buf_l);
|
||||
|
||||
itoa(planner.settings.max_acceleration_mm_per_s2[X_AXIS], public_buf_l, 10);
|
||||
lv_screen_menu_item_1_edit(scr, machine_menu.X_Acceleration, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_ACCE_X, 3, public_buf_l);
|
||||
|
||||
lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.next, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_ACCE_DOWN, true);
|
||||
}
|
||||
else {
|
||||
itoa(planner.settings.max_acceleration_mm_per_s2[Y_AXIS], public_buf_l, 10);
|
||||
lv_screen_menu_item_1_edit(scr, machine_menu.Y_Acceleration, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_ACCE_Y, 0, public_buf_l);
|
||||
|
||||
itoa(planner.settings.max_acceleration_mm_per_s2[Z_AXIS], public_buf_l, 10);
|
||||
lv_screen_menu_item_1_edit(scr, machine_menu.Z_Acceleration, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_ACCE_Z, 1, public_buf_l);
|
||||
|
||||
itoa(planner.settings.max_acceleration_mm_per_s2[E_AXIS], public_buf_l, 10);
|
||||
lv_screen_menu_item_1_edit(scr, machine_menu.E0_Acceleration, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_ACCE_E0, 2, public_buf_l);
|
||||
|
||||
itoa(planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(1)], public_buf_l, 10);
|
||||
lv_screen_menu_item_1_edit(scr, machine_menu.E1_Acceleration, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_ACCE_E1, 3, public_buf_l);
|
||||
|
||||
lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.previous, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_ACCE_UP, true);
|
||||
}
|
||||
|
||||
lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_ACCE_RETURN, true);
|
||||
}
|
||||
|
||||
void lv_clear_acceleration_settings() {
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
|
||||
#endif
|
||||
lv_obj_del(scr);
|
||||
}
|
||||
|
||||
#endif // HAS_TFT_LVGL_UI
|
33
Marlin/src/lcd/extui/mks_ui/draw_acceleration_settings.h
Normal file
33
Marlin/src/lcd/extui/mks_ui/draw_acceleration_settings.h
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* C-declarations for C++ */
|
||||
#endif
|
||||
|
||||
void lv_draw_acceleration_settings();
|
||||
void lv_clear_acceleration_settings();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C-declarations for C++ */
|
||||
#endif
|
96
Marlin/src/lcd/extui/mks_ui/draw_advance_settings.cpp
Normal file
96
Marlin/src/lcd/extui/mks_ui/draw_advance_settings.cpp
Normal file
@ -0,0 +1,96 @@
|
||||
/**
|
||||
* 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_TFT_LVGL_UI
|
||||
|
||||
#include "draw_ui.h"
|
||||
#include <lv_conf.h>
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
extern lv_group_t *g;
|
||||
static lv_obj_t *scr;
|
||||
|
||||
enum {
|
||||
ID_ADVANCE_RETURN = 1,
|
||||
ID_PAUSE_POS,
|
||||
ID_WIFI_PARA,
|
||||
ID_FILAMENT_SETTINGS,
|
||||
ID_ENCODER_SETTINGS
|
||||
};
|
||||
|
||||
static void event_handler(lv_obj_t *obj, lv_event_t event) {
|
||||
if (event != LV_EVENT_RELEASED) return;
|
||||
switch (obj->mks_obj_id) {
|
||||
case ID_ADVANCE_RETURN:
|
||||
lv_clear_advance_settings();
|
||||
draw_return_ui();
|
||||
break;
|
||||
case ID_PAUSE_POS:
|
||||
lv_clear_advance_settings();
|
||||
lv_draw_pause_position();
|
||||
break;
|
||||
case ID_FILAMENT_SETTINGS:
|
||||
lv_clear_advance_settings();
|
||||
lv_draw_filament_settings();
|
||||
break;
|
||||
#if ENABLED(MKS_WIFI_MODULE)
|
||||
case ID_WIFI_PARA:
|
||||
lv_clear_advance_settings();
|
||||
lv_draw_wifi_settings();
|
||||
break;
|
||||
#endif
|
||||
#if HAS_ROTARY_ENCODER
|
||||
case ID_ENCODER_SETTINGS:
|
||||
lv_clear_advance_settings();
|
||||
lv_draw_encoder_settings();
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void lv_draw_advance_settings() {
|
||||
scr = lv_screen_create(ADVANCED_UI, machine_menu.AdvancedConfTitle);
|
||||
|
||||
int index = 0;
|
||||
lv_screen_menu_item(scr, machine_menu.PausePosition, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_PAUSE_POS, index++);
|
||||
lv_screen_menu_item(scr, machine_menu.FilamentConf, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_FILAMENT_SETTINGS, index++);
|
||||
#if ENABLED(MKS_WIFI_MODULE)
|
||||
lv_screen_menu_item(scr, machine_menu.WifiSettings, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_WIFI_PARA, index++);
|
||||
#endif
|
||||
#if HAS_ROTARY_ENCODER
|
||||
lv_screen_menu_item(scr, machine_menu.EncoderSettings, PARA_UI_POS_X, PARA_UI_POS_Y * (index + 1), event_handler, ID_ENCODER_SETTINGS, index);
|
||||
index++;
|
||||
#endif
|
||||
|
||||
lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X + 10, PARA_UI_BACL_POS_Y, event_handler, ID_ADVANCE_RETURN, true);
|
||||
}
|
||||
|
||||
void lv_clear_advance_settings() {
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
|
||||
#endif
|
||||
lv_obj_del(scr);
|
||||
}
|
||||
|
||||
#endif // HAS_TFT_LVGL_UI
|
33
Marlin/src/lcd/extui/mks_ui/draw_advance_settings.h
Normal file
33
Marlin/src/lcd/extui/mks_ui/draw_advance_settings.h
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* C-declarations for C++ */
|
||||
#endif
|
||||
|
||||
void lv_draw_advance_settings();
|
||||
void lv_clear_advance_settings();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C-declarations for C++ */
|
||||
#endif
|
@ -0,0 +1,89 @@
|
||||
/**
|
||||
* 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 BOTH(HAS_TFT_LVGL_UI, HAS_BED_PROBE)
|
||||
|
||||
#include "draw_ui.h"
|
||||
#include <lv_conf.h>
|
||||
|
||||
#include "../../../module/probe.h"
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
extern lv_group_t *g;
|
||||
static lv_obj_t *scr;
|
||||
|
||||
enum {
|
||||
ID_OFFSET_RETURN = 1,
|
||||
ID_OFFSET_X,
|
||||
ID_OFFSET_Y,
|
||||
ID_OFFSET_Z
|
||||
};
|
||||
|
||||
static void event_handler(lv_obj_t *obj, lv_event_t event) {
|
||||
if (event != LV_EVENT_RELEASED) return;
|
||||
switch (obj->mks_obj_id) {
|
||||
case ID_OFFSET_RETURN:
|
||||
lv_clear_auto_level_offset_settings();
|
||||
draw_return_ui();
|
||||
break;
|
||||
case ID_OFFSET_X:
|
||||
value = x_offset;
|
||||
lv_clear_auto_level_offset_settings();
|
||||
lv_draw_number_key();
|
||||
break;
|
||||
case ID_OFFSET_Y:
|
||||
value = y_offset;
|
||||
lv_clear_auto_level_offset_settings();
|
||||
lv_draw_number_key();
|
||||
break;
|
||||
case ID_OFFSET_Z:
|
||||
value = z_offset;
|
||||
lv_clear_auto_level_offset_settings();
|
||||
lv_draw_number_key();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void lv_draw_auto_level_offset_settings() {
|
||||
scr = lv_screen_create(NOZZLE_PROBE_OFFSET_UI, machine_menu.OffsetConfTitle);
|
||||
|
||||
dtostrf(TERN0(HAS_PROBE_XY_OFFSET, probe.offset.x), 1, 1, public_buf_l);
|
||||
lv_screen_menu_item_1_edit(scr, machine_menu.Xoffset, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_OFFSET_X, 0, public_buf_l);
|
||||
|
||||
dtostrf(TERN0(HAS_PROBE_XY_OFFSET, probe.offset.y), 1, 1, public_buf_l);
|
||||
lv_screen_menu_item_1_edit(scr, machine_menu.Yoffset, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_OFFSET_Y, 1, public_buf_l);
|
||||
|
||||
dtostrf(TERN0(HAS_PROBE_XY_OFFSET, probe.offset.z), 1, 1, public_buf_l);
|
||||
lv_screen_menu_item_1_edit(scr, machine_menu.Zoffset, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_OFFSET_Z, 2, public_buf_l);
|
||||
|
||||
lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_OFFSET_RETURN, true);
|
||||
}
|
||||
|
||||
void lv_clear_auto_level_offset_settings() {
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
|
||||
#endif
|
||||
lv_obj_del(scr);
|
||||
}
|
||||
|
||||
#endif // HAS_TFT_LVGL_UI && HAS_BED_PROBE
|
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* C-declarations for C++ */
|
||||
#endif
|
||||
|
||||
void lv_draw_auto_level_offset_settings();
|
||||
void lv_clear_auto_level_offset_settings();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C-declarations for C++ */
|
||||
#endif
|
181
Marlin/src/lcd/extui/mks_ui/draw_baby_stepping.cpp
Normal file
181
Marlin/src/lcd/extui/mks_ui/draw_baby_stepping.cpp
Normal file
@ -0,0 +1,181 @@
|
||||
/**
|
||||
* 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_TFT_LVGL_UI
|
||||
|
||||
#include "draw_ui.h"
|
||||
#include <lv_conf.h>
|
||||
|
||||
#include "../../../gcode/queue.h"
|
||||
#include "../../../gcode/gcode.h"
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(EEPROM_SETTINGS)
|
||||
#include "../../../module/settings.h"
|
||||
#endif
|
||||
|
||||
#if HAS_BED_PROBE
|
||||
#include "../../../module/probe.h"
|
||||
#endif
|
||||
|
||||
extern lv_group_t *g;
|
||||
static lv_obj_t *scr;
|
||||
|
||||
static lv_obj_t *labelV, *buttonV, *zOffsetText;
|
||||
|
||||
enum {
|
||||
ID_BABY_STEP_X_P = 1,
|
||||
ID_BABY_STEP_X_N,
|
||||
ID_BABY_STEP_Y_P,
|
||||
ID_BABY_STEP_Y_N,
|
||||
ID_BABY_STEP_Z_P,
|
||||
ID_BABY_STEP_Z_N,
|
||||
ID_BABY_STEP_DIST,
|
||||
ID_BABY_STEP_RETURN
|
||||
};
|
||||
|
||||
static float babystep_dist=0.01;
|
||||
static uint8_t has_adjust_z = 0;
|
||||
|
||||
static void event_handler(lv_obj_t *obj, lv_event_t event) {
|
||||
if (event != LV_EVENT_RELEASED) return;
|
||||
char baby_buf[30] = { 0 };
|
||||
char str_1[16];
|
||||
switch (obj->mks_obj_id) {
|
||||
case ID_BABY_STEP_X_P:
|
||||
sprintf_P(baby_buf, PSTR("M290 X%s"), dtostrf(babystep_dist, 1, 3, str_1));
|
||||
gcode.process_subcommands_now_P(PSTR(baby_buf));
|
||||
has_adjust_z = 1;
|
||||
break;
|
||||
case ID_BABY_STEP_X_N:
|
||||
sprintf_P(baby_buf, PSTR("M290 X%s"), dtostrf(-babystep_dist, 1, 3, str_1));
|
||||
gcode.process_subcommands_now_P(PSTR(baby_buf));
|
||||
has_adjust_z = 1;
|
||||
break;
|
||||
case ID_BABY_STEP_Y_P:
|
||||
sprintf_P(baby_buf, PSTR("M290 Y%s"), dtostrf(babystep_dist, 1, 3, str_1));
|
||||
gcode.process_subcommands_now_P(PSTR(baby_buf));
|
||||
has_adjust_z = 1;
|
||||
break;
|
||||
case ID_BABY_STEP_Y_N:
|
||||
sprintf_P(baby_buf, PSTR("M290 Y%s"), dtostrf(-babystep_dist, 1, 3, str_1));
|
||||
gcode.process_subcommands_now_P(PSTR(baby_buf));
|
||||
has_adjust_z = 1;
|
||||
break;
|
||||
case ID_BABY_STEP_Z_P:
|
||||
sprintf_P(baby_buf, PSTR("M290 Z%s"), dtostrf(babystep_dist, 1, 3, str_1));
|
||||
gcode.process_subcommands_now_P(PSTR(baby_buf));
|
||||
has_adjust_z = 1;
|
||||
break;
|
||||
case ID_BABY_STEP_Z_N:
|
||||
sprintf_P(baby_buf, PSTR("M290 Z%s"), dtostrf(-babystep_dist, 1, 3, str_1));
|
||||
gcode.process_subcommands_now_P(PSTR(baby_buf));
|
||||
has_adjust_z = 1;
|
||||
break;
|
||||
case ID_BABY_STEP_DIST:
|
||||
if (abs((int)(100 * babystep_dist)) == 1)
|
||||
babystep_dist = 0.05;
|
||||
else if (abs((int)(100 * babystep_dist)) == 5)
|
||||
babystep_dist = 0.1;
|
||||
else
|
||||
babystep_dist = 0.01;
|
||||
disp_baby_step_dist();
|
||||
break;
|
||||
case ID_BABY_STEP_RETURN:
|
||||
if (has_adjust_z == 1) {
|
||||
TERN_(EEPROM_SETTINGS, (void)settings.save());
|
||||
has_adjust_z = 0;
|
||||
}
|
||||
clear_cur_ui();
|
||||
draw_return_ui();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void lv_draw_baby_stepping() {
|
||||
scr = lv_screen_create(BABY_STEP_UI);
|
||||
lv_big_button_create(scr, "F:/bmp_xAdd.bin", move_menu.x_add, INTERVAL_V, titleHeight, event_handler, ID_BABY_STEP_X_P);
|
||||
lv_big_button_create(scr, "F:/bmp_xDec.bin", move_menu.x_dec, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_BABY_STEP_X_N);
|
||||
lv_big_button_create(scr, "F:/bmp_yAdd.bin", move_menu.y_add, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_BABY_STEP_Y_P);
|
||||
lv_big_button_create(scr, "F:/bmp_yDec.bin", move_menu.y_dec, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_BABY_STEP_Y_N);
|
||||
lv_big_button_create(scr, "F:/bmp_zAdd.bin", move_menu.z_add, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_BABY_STEP_Z_P);
|
||||
lv_big_button_create(scr, "F:/bmp_zDec.bin", move_menu.z_dec, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_BABY_STEP_Z_N);
|
||||
buttonV = lv_imgbtn_create(scr, nullptr, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_BABY_STEP_DIST);
|
||||
labelV = lv_label_create_empty(buttonV);
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) {
|
||||
lv_group_add_obj(g, buttonV);
|
||||
}
|
||||
#endif
|
||||
|
||||
lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_BABY_STEP_RETURN);
|
||||
|
||||
disp_baby_step_dist();
|
||||
|
||||
zOffsetText = lv_label_create(scr, 290, TITLE_YPOS, nullptr);
|
||||
disp_z_offset_value();
|
||||
}
|
||||
|
||||
void disp_baby_step_dist() {
|
||||
if ((int)(100 * babystep_dist) == 1)
|
||||
lv_imgbtn_set_src_both(buttonV, "F:/bmp_baby_move0_01.bin");
|
||||
else if ((int)(100 * babystep_dist) == 5)
|
||||
lv_imgbtn_set_src_both(buttonV, "F:/bmp_baby_move0_05.bin");
|
||||
else if ((int)(100 * babystep_dist) == 10)
|
||||
lv_imgbtn_set_src_both(buttonV, "F:/bmp_baby_move0_1.bin");
|
||||
|
||||
if (gCfgItems.multiple_language) {
|
||||
if ((int)(100 * babystep_dist) == 1) {
|
||||
lv_label_set_text(labelV, move_menu.step_001mm);
|
||||
lv_obj_align(labelV, buttonV, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
||||
}
|
||||
else if ((int)(100 * babystep_dist) == 5) {
|
||||
lv_label_set_text(labelV, move_menu.step_005mm);
|
||||
lv_obj_align(labelV, buttonV, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
||||
}
|
||||
else if ((int)(100 * babystep_dist) == 10) {
|
||||
lv_label_set_text(labelV, move_menu.step_01mm);
|
||||
lv_obj_align(labelV, buttonV, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void disp_z_offset_value() {
|
||||
char buf[20];
|
||||
#if HAS_BED_PROBE
|
||||
char str_1[16];
|
||||
sprintf_P(buf, PSTR("Offset Z: %s mm"), dtostrf(probe.offset.z, 1, 3, str_1));
|
||||
#else
|
||||
strcpy_P(buf, PSTR("Offset Z: 0 mm"));
|
||||
#endif
|
||||
lv_label_set_text(zOffsetText, buf);
|
||||
}
|
||||
|
||||
void lv_clear_baby_stepping() {
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
|
||||
#endif
|
||||
lv_obj_del(scr);
|
||||
}
|
||||
|
||||
#endif // HAS_TFT_LVGL_UI
|
35
Marlin/src/lcd/extui/mks_ui/draw_baby_stepping.h
Normal file
35
Marlin/src/lcd/extui/mks_ui/draw_baby_stepping.h
Normal file
@ -0,0 +1,35 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* C-declarations for C++ */
|
||||
#endif
|
||||
|
||||
void lv_draw_baby_stepping();
|
||||
void lv_clear_baby_stepping();
|
||||
void disp_baby_step_dist();
|
||||
void disp_z_offset_value();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C-declarations for C++ */
|
||||
#endif
|
225
Marlin/src/lcd/extui/mks_ui/draw_change_speed.cpp
Normal file
225
Marlin/src/lcd/extui/mks_ui/draw_change_speed.cpp
Normal file
@ -0,0 +1,225 @@
|
||||
/**
|
||||
* 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_TFT_LVGL_UI
|
||||
|
||||
#include "draw_ui.h"
|
||||
#include <lv_conf.h>
|
||||
|
||||
#include "../../../module/planner.h"
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
extern lv_group_t *g;
|
||||
static lv_obj_t *scr;
|
||||
static lv_obj_t *labelStep, *buttonStep, *buttonMov, *buttonExt;
|
||||
static lv_obj_t *labelMov, *labelExt;
|
||||
static lv_obj_t *printSpeedText;
|
||||
|
||||
enum {
|
||||
ID_C_ADD = 1,
|
||||
ID_C_DEC,
|
||||
ID_C_MOVE,
|
||||
ID_C_EXT,
|
||||
ID_C_STEP,
|
||||
ID_C_RETURN
|
||||
};
|
||||
|
||||
static bool editingFlowrate;
|
||||
|
||||
static void event_handler(lv_obj_t *obj, lv_event_t event) {
|
||||
if (event != LV_EVENT_RELEASED) return;
|
||||
switch (obj->mks_obj_id) {
|
||||
case ID_C_ADD:
|
||||
if (!editingFlowrate) {
|
||||
if (feedrate_percentage < MAX_EXT_SPEED_PERCENT - uiCfg.stepPrintSpeed)
|
||||
feedrate_percentage += uiCfg.stepPrintSpeed;
|
||||
else
|
||||
feedrate_percentage = MAX_EXT_SPEED_PERCENT;
|
||||
}
|
||||
else {
|
||||
if (planner.flow_percentage[0] < MAX_EXT_SPEED_PERCENT - uiCfg.stepPrintSpeed)
|
||||
planner.flow_percentage[0] += uiCfg.stepPrintSpeed;
|
||||
else
|
||||
planner.flow_percentage[0] = MAX_EXT_SPEED_PERCENT;
|
||||
planner.refresh_e_factor(0);
|
||||
#if HAS_MULTI_EXTRUDER
|
||||
planner.flow_percentage[1] = planner.flow_percentage[0];
|
||||
planner.refresh_e_factor(1);
|
||||
#endif
|
||||
}
|
||||
disp_print_speed();
|
||||
break;
|
||||
case ID_C_DEC:
|
||||
if (!editingFlowrate) {
|
||||
if (feedrate_percentage > MIN_EXT_SPEED_PERCENT + uiCfg.stepPrintSpeed)
|
||||
feedrate_percentage -= uiCfg.stepPrintSpeed;
|
||||
else
|
||||
feedrate_percentage = MIN_EXT_SPEED_PERCENT;
|
||||
}
|
||||
else {
|
||||
if (planner.flow_percentage[0] > MIN_EXT_SPEED_PERCENT + uiCfg.stepPrintSpeed)
|
||||
planner.flow_percentage[0] -= uiCfg.stepPrintSpeed;
|
||||
else
|
||||
planner.flow_percentage[0] = MIN_EXT_SPEED_PERCENT;
|
||||
planner.refresh_e_factor(0);
|
||||
#if HAS_MULTI_EXTRUDER
|
||||
planner.flow_percentage[1] = planner.flow_percentage[0];
|
||||
planner.refresh_e_factor(1);
|
||||
#endif
|
||||
}
|
||||
disp_print_speed();
|
||||
break;
|
||||
case ID_C_MOVE:
|
||||
editingFlowrate = false;
|
||||
disp_speed_type();
|
||||
disp_print_speed();
|
||||
break;
|
||||
case ID_C_EXT:
|
||||
editingFlowrate = true;
|
||||
disp_speed_type();
|
||||
disp_print_speed();
|
||||
break;
|
||||
case ID_C_STEP:
|
||||
if (uiCfg.stepPrintSpeed == 1)
|
||||
uiCfg.stepPrintSpeed = 5;
|
||||
else if (uiCfg.stepPrintSpeed == 5)
|
||||
uiCfg.stepPrintSpeed = 10;
|
||||
else
|
||||
uiCfg.stepPrintSpeed = 1;
|
||||
disp_speed_step();
|
||||
break;
|
||||
case ID_C_RETURN:
|
||||
clear_cur_ui();
|
||||
draw_return_ui();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void lv_draw_change_speed() {
|
||||
scr = lv_screen_create(CHANGE_SPEED_UI);
|
||||
// Create an Image button
|
||||
lv_big_button_create(scr, "F:/bmp_Add.bin", speed_menu.add, INTERVAL_V, titleHeight, event_handler, ID_C_ADD);
|
||||
lv_big_button_create(scr, "F:/bmp_Dec.bin", speed_menu.dec, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_C_DEC);
|
||||
buttonMov = lv_imgbtn_create(scr, nullptr, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_C_MOVE);
|
||||
buttonExt = lv_imgbtn_create(scr, nullptr, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_C_EXT);
|
||||
buttonStep = lv_imgbtn_create(scr, nullptr, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_C_STEP);
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) {
|
||||
lv_group_add_obj(g, buttonMov);
|
||||
lv_group_add_obj(g, buttonExt);
|
||||
lv_group_add_obj(g, buttonStep);
|
||||
}
|
||||
#endif
|
||||
lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_C_RETURN);
|
||||
|
||||
// Create labels on the image buttons
|
||||
labelMov = lv_label_create_empty(buttonMov);
|
||||
labelExt = lv_label_create_empty(buttonExt);
|
||||
labelStep = lv_label_create_empty(buttonStep);
|
||||
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) {
|
||||
lv_group_add_obj(g, buttonMov);
|
||||
lv_group_add_obj(g, buttonExt);
|
||||
lv_group_add_obj(g, buttonStep);
|
||||
}
|
||||
#endif
|
||||
|
||||
disp_speed_type();
|
||||
disp_speed_step();
|
||||
|
||||
printSpeedText = lv_label_create_empty(scr);
|
||||
lv_obj_set_style(printSpeedText, &tft_style_label_rel);
|
||||
disp_print_speed();
|
||||
}
|
||||
|
||||
void disp_speed_step() {
|
||||
if (uiCfg.stepPrintSpeed == 1)
|
||||
lv_imgbtn_set_src_both(buttonStep, "F:/bmp_step1_percent.bin");
|
||||
else if (uiCfg.stepPrintSpeed == 5)
|
||||
lv_imgbtn_set_src_both(buttonStep, "F:/bmp_step5_percent.bin");
|
||||
else if (uiCfg.stepPrintSpeed == 10)
|
||||
lv_imgbtn_set_src_both(buttonStep, "F:/bmp_step10_percent.bin");
|
||||
|
||||
if (gCfgItems.multiple_language) {
|
||||
if (uiCfg.stepPrintSpeed == 1) {
|
||||
lv_label_set_text(labelStep, speed_menu.step_1percent);
|
||||
lv_obj_align(labelStep, buttonStep, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
||||
}
|
||||
else if (uiCfg.stepPrintSpeed == 5) {
|
||||
lv_label_set_text(labelStep, speed_menu.step_5percent);
|
||||
lv_obj_align(labelStep, buttonStep, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
||||
}
|
||||
else if (uiCfg.stepPrintSpeed == 10) {
|
||||
lv_label_set_text(labelStep, speed_menu.step_10percent);
|
||||
lv_obj_align(labelStep, buttonStep, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void disp_print_speed() {
|
||||
char buf[30] = { 0 };
|
||||
|
||||
public_buf_l[0] = '\0';
|
||||
|
||||
int16_t val;
|
||||
const char *lbl;
|
||||
if (editingFlowrate) {
|
||||
lbl = speed_menu.extrude_speed;
|
||||
val = planner.flow_percentage[0];
|
||||
}
|
||||
else {
|
||||
lbl = speed_menu.move_speed;
|
||||
val = feedrate_percentage;
|
||||
}
|
||||
strcpy(public_buf_l, lbl);
|
||||
strcat_P(public_buf_l, PSTR(": "));
|
||||
sprintf_P(buf, PSTR("%d%%"), val);
|
||||
strcat(public_buf_l, buf);
|
||||
lv_label_set_text(printSpeedText, public_buf_l);
|
||||
lv_obj_align(printSpeedText, nullptr, LV_ALIGN_CENTER, 0, -65);
|
||||
}
|
||||
|
||||
void disp_speed_type() {
|
||||
lv_imgbtn_set_src_both(buttonMov, editingFlowrate ? "F:/bmp_mov_changeSpeed.bin" : "F:/bmp_mov_sel.bin");
|
||||
lv_imgbtn_set_src_both(buttonExt, editingFlowrate ? "F:/bmp_extruct_sel.bin" : "F:/bmp_speed_extruct.bin");
|
||||
lv_obj_refresh_ext_draw_pad(buttonExt);
|
||||
lv_obj_refresh_ext_draw_pad(buttonMov);
|
||||
|
||||
if (gCfgItems.multiple_language) {
|
||||
lv_label_set_text(labelMov, speed_menu.move);
|
||||
lv_obj_align(labelMov, buttonMov, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
||||
|
||||
lv_label_set_text(labelExt, speed_menu.extrude);
|
||||
lv_obj_align(labelExt, buttonExt, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
||||
}
|
||||
}
|
||||
|
||||
void lv_clear_change_speed() {
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
|
||||
#endif
|
||||
lv_obj_del(scr);
|
||||
}
|
||||
|
||||
#endif // HAS_TFT_LVGL_UI
|
39
Marlin/src/lcd/extui/mks_ui/draw_change_speed.h
Normal file
39
Marlin/src/lcd/extui/mks_ui/draw_change_speed.h
Normal file
@ -0,0 +1,39 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* C-declarations for C++ */
|
||||
#endif
|
||||
|
||||
#define MIN_EXT_SPEED_PERCENT 10
|
||||
#define MAX_EXT_SPEED_PERCENT 999
|
||||
|
||||
void lv_draw_change_speed();
|
||||
void lv_clear_change_speed();
|
||||
void disp_speed_step();
|
||||
void disp_print_speed();
|
||||
void disp_speed_type();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C-declarations for C++ */
|
||||
#endif
|
205
Marlin/src/lcd/extui/mks_ui/draw_cloud_bind.cpp
Normal file
205
Marlin/src/lcd/extui/mks_ui/draw_cloud_bind.cpp
Normal file
@ -0,0 +1,205 @@
|
||||
/**
|
||||
* 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 BOTH(HAS_TFT_LVGL_UI, MKS_WIFI_MODULE)
|
||||
|
||||
#include "lv_conf.h"
|
||||
#include "draw_ui.h"
|
||||
|
||||
#include "../../../MarlinCore.h"
|
||||
#include "../../../module/temperature.h"
|
||||
|
||||
#include "QR_Encode.h"
|
||||
|
||||
extern lv_group_t * g;
|
||||
static lv_obj_t * scr;
|
||||
static lv_obj_t *button_bind_or_not = NULL, *label_bind_or_not = NULL;
|
||||
static lv_obj_t *buttonReleaseBind = NULL, *label_ReleaseBind = NULL;
|
||||
static lv_obj_t * text_id;
|
||||
|
||||
static uint8_t unbinding_flag = 0;
|
||||
static uint8_t id_mark = 0;
|
||||
|
||||
#define ID_CLOUD_BIND_RETURN 1
|
||||
#define ID_CLOUD_BIND_OR_NOT 2
|
||||
#define ID_CLOUD_RELEASE_BIND 3
|
||||
|
||||
static void event_handler(lv_obj_t * obj, lv_event_t event) {
|
||||
if (event != LV_EVENT_RELEASED) return;
|
||||
switch (obj->mks_obj_id) {
|
||||
case ID_CLOUD_BIND_RETURN:
|
||||
clear_cur_ui();
|
||||
draw_return_ui();
|
||||
break;
|
||||
case ID_CLOUD_RELEASE_BIND:
|
||||
if (cloud_para.state == 0x12) {
|
||||
clear_cur_ui();
|
||||
lv_draw_dialog(DIALOG_TYPE_UNBIND);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void lv_draw_cloud_bind() {
|
||||
lv_obj_t *buttonBack = NULL, *label_Back = NULL;
|
||||
scr = lv_screen_create(BIND_UI);
|
||||
|
||||
button_bind_or_not = lv_btn_create(scr, NULL);
|
||||
lv_obj_set_pos(button_bind_or_not, TFT_WIDTH - 130, TFT_HEIGHT - 80 * 3);
|
||||
lv_obj_set_size(button_bind_or_not, PARA_UI_VALUE_BTN_X_SIZE + 15, PARA_UI_VALUE_BTN_Y_SIZE + 15);
|
||||
lv_obj_set_event_cb_mks(button_bind_or_not, event_handler, ID_CLOUD_BIND_OR_NOT, NULL, 0);
|
||||
lv_btn_set_style(button_bind_or_not, LV_BTN_STYLE_REL, &style_para_value);
|
||||
lv_btn_set_style(button_bind_or_not, LV_BTN_STYLE_PR, &style_para_value);
|
||||
label_bind_or_not = lv_label_create_empty(button_bind_or_not);
|
||||
|
||||
buttonReleaseBind = lv_btn_create(scr, NULL);
|
||||
lv_obj_set_pos(buttonReleaseBind, TFT_WIDTH - 130, TFT_HEIGHT - 80 * 2);
|
||||
lv_obj_set_size(buttonReleaseBind, PARA_UI_VALUE_BTN_X_SIZE + 15, PARA_UI_VALUE_BTN_Y_SIZE + 15);
|
||||
lv_obj_set_event_cb_mks(buttonReleaseBind, event_handler, ID_CLOUD_RELEASE_BIND, NULL, 0);
|
||||
label_ReleaseBind = lv_label_create_empty(buttonReleaseBind);
|
||||
lv_label_set_text(label_ReleaseBind, cloud_menu.unbind);
|
||||
lv_obj_align(label_ReleaseBind, buttonReleaseBind, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
buttonBack = lv_btn_create(scr, NULL);
|
||||
lv_obj_set_pos(buttonBack, TFT_WIDTH - 130, TFT_HEIGHT - 80);
|
||||
lv_obj_set_size(buttonBack, PARA_UI_VALUE_BTN_X_SIZE + 15, PARA_UI_VALUE_BTN_Y_SIZE + 15);
|
||||
lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_CLOUD_BIND_RETURN, NULL, 0);
|
||||
lv_btn_set_style(buttonBack, LV_BTN_STYLE_REL, &style_para_back);
|
||||
lv_btn_set_style(buttonBack, LV_BTN_STYLE_PR, &style_para_back);
|
||||
label_Back = lv_label_create_empty(buttonBack);
|
||||
lv_label_set_text(label_Back, common_menu.text_back);
|
||||
lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
#if BUTTONS_EXIST(EN1, EN2, ENC)
|
||||
if (gCfgItems.encoder_enable) {
|
||||
lv_group_add_obj(g, buttonReleaseBind);
|
||||
lv_group_add_obj(g, buttonBack);
|
||||
}
|
||||
#endif
|
||||
|
||||
text_id = lv_label_create_empty(scr);
|
||||
lv_obj_set_pos(text_id, 50, 60 + 200 + 20);
|
||||
lv_obj_set_style(text_id, &tft_style_label_rel);
|
||||
lv_label_set_text(text_id, (char *)cloud_para.id);
|
||||
|
||||
id_mark = 0;
|
||||
|
||||
disp_bind_state();
|
||||
}
|
||||
|
||||
void disp_bind_state() {
|
||||
if (cloud_para.state != 0x12)
|
||||
unbinding_flag = 0;
|
||||
|
||||
if (unbinding_flag) {
|
||||
lv_label_set_text(label_bind_or_not, cloud_menu.unbinding);
|
||||
lv_obj_align(label_bind_or_not, button_bind_or_not, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_btn_set_style(buttonReleaseBind, LV_BTN_STYLE_REL, &style_para_value);
|
||||
lv_btn_set_style(buttonReleaseBind, LV_BTN_STYLE_PR, &style_para_value);
|
||||
}
|
||||
else {
|
||||
if (cloud_para.state == 0x10) {
|
||||
lv_label_set_text(label_bind_or_not, cloud_menu.disconnected);
|
||||
lv_obj_align(label_bind_or_not, button_bind_or_not, LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
else if (cloud_para.state == 0x11) {
|
||||
lv_label_set_text(label_bind_or_not, cloud_menu.unbinded);
|
||||
lv_obj_align(label_bind_or_not, button_bind_or_not, LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
else if (cloud_para.state == 0x12) {
|
||||
lv_label_set_text(label_bind_or_not, cloud_menu.binded);
|
||||
lv_obj_align(label_bind_or_not, button_bind_or_not, LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
else {
|
||||
lv_label_set_text(label_bind_or_not, cloud_menu.disable);
|
||||
lv_obj_align(label_bind_or_not, button_bind_or_not, LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (cloud_para.state == 0x12 && !unbinding_flag) {
|
||||
lv_btn_set_style(buttonReleaseBind, LV_BTN_STYLE_REL, &style_para_back);
|
||||
lv_btn_set_style(buttonReleaseBind, LV_BTN_STYLE_PR, &style_para_back);
|
||||
}
|
||||
else {
|
||||
lv_btn_set_style(buttonReleaseBind, LV_BTN_STYLE_REL, &style_para_value);
|
||||
lv_btn_set_style(buttonReleaseBind, LV_BTN_STYLE_PR, &style_para_value);
|
||||
}
|
||||
}
|
||||
|
||||
static char last_cloud_state = 0;
|
||||
void refresh_bind_ui() {
|
||||
if ((last_cloud_state != cloud_para.state) || unbinding_flag) {
|
||||
disp_bind_state();
|
||||
last_cloud_state = cloud_para.state;
|
||||
}
|
||||
if (cloud_para.id[0]) {
|
||||
if (!id_mark) {
|
||||
display_qrcode((uint8_t *)cloud_para.id);
|
||||
lv_label_set_text(text_id, (char *)cloud_para.id);
|
||||
}
|
||||
}
|
||||
else
|
||||
id_mark = 0;
|
||||
}
|
||||
|
||||
void display_qrcode(uint8_t *qrcode_data) {
|
||||
uint8_t i, j;
|
||||
uint16_t x, y, p;
|
||||
|
||||
if (!id_mark) {
|
||||
EncodeData((char *)qrcode_data);
|
||||
id_mark = 1;
|
||||
}
|
||||
|
||||
lv_fill_rect(10, QRCODE_Y, 300, QRCODE_Y + 300, LV_COLOR_WHITE);
|
||||
|
||||
if (m_nSymbleSize * 2 > QRCODE_WIDTH) return;
|
||||
|
||||
for (i = 0; i < 40; i++)
|
||||
if ((m_nSymbleSize * i * 2) > QRCODE_WIDTH) break;
|
||||
|
||||
p = (i - 1) * 2;
|
||||
|
||||
x = QRCODE_X + 70;
|
||||
y = QRCODE_Y + 70;
|
||||
|
||||
for (i = 0; i < m_nSymbleSize; i++)
|
||||
for (j = 0; j < m_nSymbleSize; j++)
|
||||
if (m_byModuleData[i][j] == 1)
|
||||
lv_fill_rect(x + p * i, y + p * j, x + p * (i + 1) - 1, y + p * (j + 1) - 1, LV_COLOR_BACKGROUND);
|
||||
}
|
||||
|
||||
void cloud_unbind() {
|
||||
package_to_wifi(WIFI_CLOUD_UNBIND, nullptr, 0);
|
||||
unbinding_flag = 1;
|
||||
}
|
||||
|
||||
void lv_clear_cloud_bind() {
|
||||
#if BUTTONS_EXIST(EN1, EN2, ENC)
|
||||
if (gCfgItems.encoder_enable)
|
||||
lv_group_remove_all_objs(g);
|
||||
#endif
|
||||
lv_obj_del(scr);
|
||||
}
|
||||
|
||||
#endif // HAS_TFT_LVGL_UI
|
37
Marlin/src/lcd/extui/mks_ui/draw_cloud_bind.h
Normal file
37
Marlin/src/lcd/extui/mks_ui/draw_cloud_bind.h
Normal file
@ -0,0 +1,37 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* C-declarations for C++ */
|
||||
#endif
|
||||
|
||||
void lv_draw_cloud_bind();
|
||||
void lv_clear_cloud_bind();
|
||||
void disp_bind_state();
|
||||
void refresh_bind_ui();
|
||||
void display_qrcode(uint8_t *qrcode_data);
|
||||
void cloud_unbind();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C-declarations for C++ */
|
||||
#endif
|
571
Marlin/src/lcd/extui/mks_ui/draw_dialog.cpp
Normal file
571
Marlin/src/lcd/extui/mks_ui/draw_dialog.cpp
Normal file
@ -0,0 +1,571 @@
|
||||
/**
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* draw_dialog.cpp
|
||||
*/
|
||||
|
||||
#include "../../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if HAS_TFT_LVGL_UI
|
||||
|
||||
#include "draw_ui.h"
|
||||
#include <lv_conf.h>
|
||||
|
||||
#include "../../../sd/cardreader.h"
|
||||
#include "../../../gcode/queue.h"
|
||||
#include "../../../module/temperature.h"
|
||||
#include "../../../module/planner.h"
|
||||
#include "../../../gcode/gcode.h"
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(EEPROM_SETTINGS)
|
||||
#include "../../../module/settings.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(POWER_LOSS_RECOVERY)
|
||||
#include "../../../feature/powerloss.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(PARK_HEAD_ON_PAUSE)
|
||||
#include "../../../feature/pause.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
|
||||
#include "../../tft_io/touch_calibration.h"
|
||||
#include "draw_touch_calibration.h"
|
||||
#endif
|
||||
|
||||
extern lv_group_t *g;
|
||||
static lv_obj_t *scr, *tempText1, *filament_bar;
|
||||
|
||||
extern uint8_t sel_id;
|
||||
extern bool once_flag, gcode_preview_over;
|
||||
extern int upload_result;
|
||||
extern uint32_t upload_time;
|
||||
extern uint32_t upload_size;
|
||||
extern bool temps_update_flag;
|
||||
|
||||
//#define CANCEL_ON_RIGHT // Put 'Cancel' on the right (as it was before)
|
||||
|
||||
#define BTN_OK_X TERN(CANCEL_ON_RIGHT, 100, 280)
|
||||
#define BTN_CANCEL_X TERN(CANCEL_ON_RIGHT, 280, 100)
|
||||
#define BTN_OK_Y 180
|
||||
#define BTN_CANCEL_Y 180
|
||||
|
||||
static void btn_ok_event_cb(lv_obj_t *btn, lv_event_t event) {
|
||||
if (event != LV_EVENT_RELEASED) return;
|
||||
if (DIALOG_IS(TYPE_PRINT_FILE)) {
|
||||
#if HAS_GCODE_PREVIEW
|
||||
preview_gcode_prehandle(list_file.file_name[sel_id]);
|
||||
#endif
|
||||
reset_print_time();
|
||||
start_print_time();
|
||||
|
||||
uiCfg.print_state = WORKING;
|
||||
lv_clear_dialog();
|
||||
lv_draw_printing();
|
||||
|
||||
#if ENABLED(SDSUPPORT)
|
||||
if (!gcode_preview_over) {
|
||||
char *cur_name;
|
||||
cur_name = strrchr(list_file.file_name[sel_id], '/');
|
||||
|
||||
SdFile file, *curDir;
|
||||
card.endFilePrint();
|
||||
const char * const fname = card.diveToFile(true, curDir, cur_name);
|
||||
if (!fname) return;
|
||||
if (file.open(curDir, fname, O_READ)) {
|
||||
gCfgItems.curFilesize = file.fileSize();
|
||||
file.close();
|
||||
update_spi_flash();
|
||||
}
|
||||
card.openFileRead(cur_name);
|
||||
if (card.isFileOpen()) {
|
||||
feedrate_percentage = 100;
|
||||
planner.flow_percentage[0] = 100;
|
||||
planner.e_factor[0] = planner.flow_percentage[0] * 0.01f;
|
||||
#if HAS_MULTI_EXTRUDER
|
||||
planner.flow_percentage[1] = 100;
|
||||
planner.e_factor[1] = planner.flow_percentage[1] * 0.01f;
|
||||
#endif
|
||||
card.startFileprint();
|
||||
#if ENABLED(POWER_LOSS_RECOVERY)
|
||||
recovery.prepare();
|
||||
#endif
|
||||
once_flag = false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if (DIALOG_IS(TYPE_STOP)) {
|
||||
wait_for_heatup = false;
|
||||
stop_print_time();
|
||||
lv_clear_dialog();
|
||||
lv_draw_ready_print();
|
||||
|
||||
#if ENABLED(SDSUPPORT)
|
||||
uiCfg.print_state = IDLE;
|
||||
card.flag.abort_sd_printing = true;
|
||||
#endif
|
||||
}
|
||||
else if (DIALOG_IS(TYPE_FINISH_PRINT)) {
|
||||
clear_cur_ui();
|
||||
lv_draw_ready_print();
|
||||
}
|
||||
#if ENABLED(ADVANCED_PAUSE_FEATURE)
|
||||
else if (DIALOG_IS(PAUSE_MESSAGE_WAITING, PAUSE_MESSAGE_INSERT, PAUSE_MESSAGE_HEAT))
|
||||
wait_for_user = false;
|
||||
else if (DIALOG_IS(PAUSE_MESSAGE_OPTION))
|
||||
pause_menu_response = PAUSE_RESPONSE_EXTRUDE_MORE;
|
||||
else if (DIALOG_IS(PAUSE_MESSAGE_RESUME)) {
|
||||
clear_cur_ui();
|
||||
draw_return_ui();
|
||||
}
|
||||
#endif
|
||||
else if (DIALOG_IS(STORE_EEPROM_TIPS)) {
|
||||
TERN_(EEPROM_SETTINGS, (void)settings.save());
|
||||
clear_cur_ui();
|
||||
draw_return_ui();
|
||||
}
|
||||
else if (DIALOG_IS(READ_EEPROM_TIPS)) {
|
||||
TERN_(EEPROM_SETTINGS, (void)settings.load());
|
||||
clear_cur_ui();
|
||||
draw_return_ui();
|
||||
}
|
||||
else if (DIALOG_IS(REVERT_EEPROM_TIPS)) {
|
||||
TERN_(EEPROM_SETTINGS, (void)settings.reset());
|
||||
clear_cur_ui();
|
||||
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
|
||||
const bool do_draw_cal = touch_calibration.need_calibration();
|
||||
if (do_draw_cal) {
|
||||
disp_state_stack._disp_index--; // We are asynchronous from the dialog, so let's remove the dialog from the stack
|
||||
lv_draw_touch_calibration_screen();
|
||||
}
|
||||
#else
|
||||
constexpr bool do_draw_cal = false;
|
||||
#endif
|
||||
if (!do_draw_cal) draw_return_ui();
|
||||
}
|
||||
else if (DIALOG_IS(WIFI_CONFIG_TIPS)) {
|
||||
uiCfg.configWifi = true;
|
||||
clear_cur_ui();
|
||||
draw_return_ui();
|
||||
}
|
||||
else if (DIALOG_IS(TYPE_FILAMENT_HEAT_LOAD_COMPLETED))
|
||||
uiCfg.filament_heat_completed_load = true;
|
||||
else if (DIALOG_IS(TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED))
|
||||
uiCfg.filament_heat_completed_unload = true;
|
||||
else if (DIALOG_IS(TYPE_FILAMENT_LOAD_COMPLETED, TYPE_FILAMENT_UNLOAD_COMPLETED)) {
|
||||
clear_cur_ui();
|
||||
draw_return_ui();
|
||||
}
|
||||
#if ENABLED(MKS_WIFI_MODULE)
|
||||
else if (DIALOG_IS(TYPE_UNBIND)) {
|
||||
cloud_unbind();
|
||||
clear_cur_ui();
|
||||
draw_return_ui();
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
clear_cur_ui();
|
||||
draw_return_ui();
|
||||
}
|
||||
}
|
||||
|
||||
static void btn_cancel_event_cb(lv_obj_t *btn, lv_event_t event) {
|
||||
if (event != LV_EVENT_RELEASED) return;
|
||||
if (DIALOG_IS(PAUSE_MESSAGE_OPTION)) {
|
||||
TERN_(ADVANCED_PAUSE_FEATURE, pause_menu_response = PAUSE_RESPONSE_RESUME_PRINT);
|
||||
}
|
||||
else if (DIALOG_IS(TYPE_FILAMENT_LOAD_HEAT, TYPE_FILAMENT_UNLOAD_HEAT, TYPE_FILAMENT_HEAT_LOAD_COMPLETED, TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED)) {
|
||||
thermalManager.setTargetHotend(uiCfg.hotendTargetTempBak, uiCfg.extruderIndex);
|
||||
clear_cur_ui();
|
||||
draw_return_ui();
|
||||
}
|
||||
else if (DIALOG_IS(TYPE_FILAMENT_LOADING, TYPE_FILAMENT_UNLOADING)) {
|
||||
queue.enqueue_one_P(PSTR("M410"));
|
||||
uiCfg.filament_rate = 0;
|
||||
uiCfg.filament_loading_completed = false;
|
||||
uiCfg.filament_unloading_completed = false;
|
||||
uiCfg.filament_loading_time_flg = false;
|
||||
uiCfg.filament_loading_time_cnt = 0;
|
||||
uiCfg.filament_unloading_time_flg = false;
|
||||
uiCfg.filament_unloading_time_cnt = 0;
|
||||
thermalManager.setTargetHotend(uiCfg.hotendTargetTempBak, uiCfg.extruderIndex);
|
||||
clear_cur_ui();
|
||||
draw_return_ui();
|
||||
}
|
||||
else {
|
||||
clear_cur_ui();
|
||||
draw_return_ui();
|
||||
}
|
||||
}
|
||||
|
||||
void lv_draw_dialog(uint8_t type) {
|
||||
lv_obj_t *btnOk = nullptr, *btnCancel = nullptr;
|
||||
uiCfg.dialogType = type;
|
||||
scr = lv_screen_create(DIALOG_UI);
|
||||
|
||||
lv_obj_t *labelDialog = lv_label_create(scr, "");
|
||||
|
||||
if (DIALOG_IS(TYPE_FINISH_PRINT, PAUSE_MESSAGE_RESUME)) {
|
||||
btnOk = lv_button_btn_create(scr, BTN_OK_X + 90, BTN_OK_Y, 100, 50, btn_ok_event_cb);
|
||||
lv_obj_t *labelOk = lv_label_create_empty(btnOk); // Add a label to the button
|
||||
lv_label_set_text(labelOk, print_file_dialog_menu.confirm); // Set the labels text
|
||||
}
|
||||
else if (DIALOG_IS(PAUSE_MESSAGE_WAITING, PAUSE_MESSAGE_INSERT, PAUSE_MESSAGE_HEAT)) {
|
||||
btnOk = lv_button_btn_create(scr, BTN_OK_X + 90, BTN_OK_Y, 100, 50, btn_ok_event_cb);
|
||||
lv_obj_t *labelOk = lv_label_create_empty(btnOk); // Add a label to the button
|
||||
lv_label_set_text(labelOk, print_file_dialog_menu.confirm); // Set the labels text
|
||||
}
|
||||
else if (DIALOG_IS(PAUSE_MESSAGE_PAUSING, PAUSE_MESSAGE_CHANGING, PAUSE_MESSAGE_UNLOAD, PAUSE_MESSAGE_LOAD, PAUSE_MESSAGE_PURGE, PAUSE_MESSAGE_RESUME, PAUSE_MESSAGE_HEATING)) {
|
||||
// nothing to do
|
||||
}
|
||||
else if (DIALOG_IS(WIFI_ENABLE_TIPS)) {
|
||||
btnCancel = lv_button_btn_create(scr, BTN_OK_X + 90, BTN_OK_Y, 100, 50, btn_cancel_event_cb);
|
||||
lv_obj_t *labelCancel = lv_label_create_empty(btnCancel);
|
||||
lv_label_set_text(labelCancel, print_file_dialog_menu.cancel);
|
||||
}
|
||||
else if (DIALOG_IS(TRANSFER_NO_DEVICE)) {
|
||||
btnCancel = lv_button_btn_create(scr, BTN_OK_X + 90, BTN_OK_Y, 100, 50, btn_cancel_event_cb);
|
||||
lv_obj_t *labelCancel = lv_label_create_empty(btnCancel);
|
||||
lv_label_set_text(labelCancel, print_file_dialog_menu.cancel);
|
||||
}
|
||||
#if ENABLED(MKS_WIFI_MODULE)
|
||||
else if (DIALOG_IS(TYPE_UPLOAD_FILE)) {
|
||||
if (upload_result == 2) {
|
||||
btnCancel = lv_button_btn_create(scr, BTN_OK_X + 90, BTN_OK_Y, 100, 50, btn_cancel_event_cb);
|
||||
lv_obj_t *labelCancel = lv_label_create_empty(btnCancel);
|
||||
lv_label_set_text(labelCancel, print_file_dialog_menu.cancel);
|
||||
}
|
||||
else if (upload_result == 3) {
|
||||
btnOk = lv_button_btn_create(scr, BTN_OK_X + 90, BTN_OK_Y, 100, 50, btn_ok_event_cb);
|
||||
lv_obj_t *labelOk = lv_label_create_empty(btnOk);
|
||||
lv_label_set_text(labelOk, print_file_dialog_menu.confirm);
|
||||
}
|
||||
}
|
||||
else if (DIALOG_IS(TYPE_UPDATE_ESP_FIRMWARE)) {
|
||||
// nothing to do
|
||||
}
|
||||
#endif
|
||||
else if (DIALOG_IS(TYPE_FILAMENT_LOAD_HEAT, TYPE_FILAMENT_UNLOAD_HEAT)) {
|
||||
btnCancel = lv_button_btn_create(scr, BTN_OK_X+90, BTN_OK_Y, 100, 50, btn_cancel_event_cb);
|
||||
lv_obj_t *labelCancel = lv_label_create_empty(btnCancel);
|
||||
lv_label_set_text(labelCancel, print_file_dialog_menu.cancel);
|
||||
|
||||
tempText1 = lv_label_create_empty(scr);
|
||||
filament_sprayer_temp();
|
||||
}
|
||||
else if (DIALOG_IS(TYPE_FILAMENT_LOAD_COMPLETED, TYPE_FILAMENT_UNLOAD_COMPLETED)) {
|
||||
btnOk = lv_button_btn_create(scr, BTN_OK_X + 90, BTN_OK_Y, 100, 50, btn_ok_event_cb);
|
||||
lv_obj_t *labelOk = lv_label_create_empty(btnOk);
|
||||
lv_label_set_text(labelOk, print_file_dialog_menu.confirm);
|
||||
}
|
||||
else if (DIALOG_IS(TYPE_FILAMENT_LOADING, TYPE_FILAMENT_UNLOADING)) {
|
||||
btnCancel = lv_button_btn_create(scr, BTN_OK_X + 90, BTN_OK_Y, 100, 50, btn_cancel_event_cb);
|
||||
lv_obj_t *labelCancel = lv_label_create_empty(btnCancel);
|
||||
lv_label_set_text(labelCancel, print_file_dialog_menu.cancel);
|
||||
|
||||
filament_bar = lv_bar_create(scr, nullptr);
|
||||
lv_obj_set_pos(filament_bar, (TFT_WIDTH-400)/2, ((TFT_HEIGHT - titleHeight)-40)/2);
|
||||
lv_obj_set_size(filament_bar, 400, 25);
|
||||
lv_bar_set_style(filament_bar, LV_BAR_STYLE_INDIC, &lv_bar_style_indic);
|
||||
lv_bar_set_anim_time(filament_bar, 1000);
|
||||
lv_bar_set_value(filament_bar, 0, LV_ANIM_ON);
|
||||
}
|
||||
else {
|
||||
btnOk = lv_button_btn_create(scr, BTN_OK_X, BTN_OK_Y, 100, 50, btn_ok_event_cb);
|
||||
lv_obj_t *labelOk = lv_label_create_empty(btnOk); // Add a label to the button
|
||||
|
||||
btnCancel = lv_button_btn_create(scr, BTN_CANCEL_X, BTN_CANCEL_Y, 100, 50, btn_cancel_event_cb);
|
||||
lv_obj_t *labelCancel = lv_label_create_empty(btnCancel); // Add a label to the button
|
||||
|
||||
if (DIALOG_IS(PAUSE_MESSAGE_OPTION)) {
|
||||
lv_label_set_text(labelOk, pause_msg_menu.purgeMore); // Set the labels text
|
||||
lv_label_set_text(labelCancel, pause_msg_menu.continuePrint);
|
||||
}
|
||||
else {
|
||||
lv_label_set_text(labelOk, print_file_dialog_menu.confirm); // Set the labels text
|
||||
lv_label_set_text(labelCancel, print_file_dialog_menu.cancel);
|
||||
}
|
||||
}
|
||||
if (DIALOG_IS(TYPE_PRINT_FILE)) {
|
||||
lv_label_set_text(labelDialog, print_file_dialog_menu.print_file);
|
||||
lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
|
||||
|
||||
lv_obj_t *labelFile = lv_label_create(scr, list_file.long_name[sel_id]);
|
||||
lv_obj_align(labelFile, nullptr, LV_ALIGN_CENTER, 0, -60);
|
||||
}
|
||||
else if (DIALOG_IS(TYPE_STOP)) {
|
||||
lv_label_set_text(labelDialog, print_file_dialog_menu.cancel_print);
|
||||
lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
|
||||
}
|
||||
else if (DIALOG_IS(TYPE_FINISH_PRINT)) {
|
||||
lv_label_set_text(labelDialog, print_file_dialog_menu.print_finish);
|
||||
lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
|
||||
}
|
||||
else if (DIALOG_IS(PAUSE_MESSAGE_PAUSING)) {
|
||||
lv_label_set_text(labelDialog, pause_msg_menu.pausing);
|
||||
lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
|
||||
}
|
||||
else if (DIALOG_IS(PAUSE_MESSAGE_CHANGING)) {
|
||||
lv_label_set_text(labelDialog, pause_msg_menu.changing);
|
||||
lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
|
||||
}
|
||||
else if (DIALOG_IS(PAUSE_MESSAGE_UNLOAD)) {
|
||||
lv_label_set_text(labelDialog, pause_msg_menu.unload);
|
||||
lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
|
||||
}
|
||||
else if (DIALOG_IS(PAUSE_MESSAGE_WAITING)) {
|
||||
lv_label_set_text(labelDialog, pause_msg_menu.waiting);
|
||||
lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
|
||||
}
|
||||
else if (DIALOG_IS(PAUSE_MESSAGE_INSERT)) {
|
||||
lv_label_set_text(labelDialog, pause_msg_menu.insert);
|
||||
lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
|
||||
}
|
||||
else if (DIALOG_IS(PAUSE_MESSAGE_LOAD)) {
|
||||
lv_label_set_text(labelDialog, pause_msg_menu.load);
|
||||
lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
|
||||
}
|
||||
else if (DIALOG_IS(PAUSE_MESSAGE_PURGE)) {
|
||||
lv_label_set_text(labelDialog, pause_msg_menu.purge);
|
||||
lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
|
||||
}
|
||||
else if (DIALOG_IS(PAUSE_MESSAGE_RESUME)) {
|
||||
lv_label_set_text(labelDialog, pause_msg_menu.resume);
|
||||
lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
|
||||
}
|
||||
else if (DIALOG_IS(PAUSE_MESSAGE_HEAT)) {
|
||||
lv_label_set_text(labelDialog, pause_msg_menu.heat);
|
||||
lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
|
||||
}
|
||||
else if (DIALOG_IS(PAUSE_MESSAGE_HEATING)) {
|
||||
lv_label_set_text(labelDialog, pause_msg_menu.heating);
|
||||
lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
|
||||
}
|
||||
else if (DIALOG_IS(PAUSE_MESSAGE_OPTION)) {
|
||||
lv_label_set_text(labelDialog, pause_msg_menu.option);
|
||||
lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
|
||||
}
|
||||
else if (DIALOG_IS(STORE_EEPROM_TIPS)) {
|
||||
lv_label_set_text(labelDialog, eeprom_menu.storeTips);
|
||||
lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
|
||||
}
|
||||
else if (DIALOG_IS(READ_EEPROM_TIPS)) {
|
||||
lv_label_set_text(labelDialog, eeprom_menu.readTips);
|
||||
lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
|
||||
}
|
||||
else if (DIALOG_IS(REVERT_EEPROM_TIPS)) {
|
||||
lv_label_set_text(labelDialog, eeprom_menu.revertTips);
|
||||
lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
|
||||
}
|
||||
else if (DIALOG_IS(WIFI_CONFIG_TIPS)) {
|
||||
lv_label_set_text(labelDialog, machine_menu.wifiConfigTips);
|
||||
lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
|
||||
}
|
||||
else if (DIALOG_IS(WIFI_ENABLE_TIPS)) {
|
||||
lv_label_set_text(labelDialog, print_file_dialog_menu.wifi_enable_tips);
|
||||
lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
|
||||
}
|
||||
else if (DIALOG_IS(TRANSFER_NO_DEVICE)) {
|
||||
lv_label_set_text(labelDialog, DIALOG_UPDATE_NO_DEVICE_EN);
|
||||
lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
|
||||
}
|
||||
#if ENABLED(MKS_WIFI_MODULE)
|
||||
else if (DIALOG_IS(TYPE_UPLOAD_FILE)) {
|
||||
if (upload_result == 1) {
|
||||
lv_label_set_text(labelDialog, DIALOG_UPLOAD_ING_EN);
|
||||
lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
|
||||
}
|
||||
else if (upload_result == 2) {
|
||||
lv_label_set_text(labelDialog, DIALOG_UPLOAD_ERROR_EN);
|
||||
lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
|
||||
}
|
||||
else if (upload_result == 3) {
|
||||
char buf[200];
|
||||
int _index = 0;
|
||||
|
||||
strcpy(buf, DIALOG_UPLOAD_FINISH_EN);
|
||||
_index = strlen(buf);
|
||||
buf[_index] = '\n';
|
||||
_index++;
|
||||
strcat(buf, DIALOG_UPLOAD_SIZE_EN);
|
||||
|
||||
_index = strlen(buf);
|
||||
buf[_index] = ':';
|
||||
_index++;
|
||||
sprintf(&buf[_index], " %d KBytes\n", (int)(upload_size / 1024));
|
||||
|
||||
strcat(buf, DIALOG_UPLOAD_TIME_EN);
|
||||
_index = strlen(buf);
|
||||
buf[_index] = ':';
|
||||
_index++;
|
||||
sprintf(&buf[_index], " %d s\n", (int)upload_time);
|
||||
|
||||
strcat(buf, DIALOG_UPLOAD_SPEED_EN);
|
||||
_index = strlen(buf);
|
||||
buf[_index] = ':';
|
||||
_index++;
|
||||
sprintf(&buf[_index], " %d KBytes/s\n", (int)(upload_size / upload_time / 1024));
|
||||
|
||||
lv_label_set_text(labelDialog, buf);
|
||||
lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
|
||||
}
|
||||
}
|
||||
else if (DIALOG_IS(TYPE_UPDATE_ESP_FIRMWARE)) {
|
||||
lv_label_set_text(labelDialog, DIALOG_UPDATE_WIFI_FIRMWARE_EN);
|
||||
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
|
||||
}
|
||||
#endif // MKS_WIFI_MODULE
|
||||
else if (DIALOG_IS(TYPE_FILAMENT_LOAD_HEAT)) {
|
||||
lv_label_set_text(labelDialog, filament_menu.filament_dialog_load_heat);
|
||||
lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
|
||||
}
|
||||
else if (DIALOG_IS(TYPE_FILAMENT_HEAT_LOAD_COMPLETED)) {
|
||||
lv_label_set_text(labelDialog, filament_menu.filament_dialog_load_heat_confirm);
|
||||
lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
|
||||
}
|
||||
else if (DIALOG_IS(TYPE_FILAMENT_UNLOAD_HEAT)) {
|
||||
lv_label_set_text(labelDialog, filament_menu.filament_dialog_unload_heat);
|
||||
lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
|
||||
}
|
||||
else if (DIALOG_IS(TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED)) {
|
||||
lv_label_set_text(labelDialog, filament_menu.filament_dialog_unload_heat_confirm);
|
||||
lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
|
||||
}
|
||||
else if (DIALOG_IS(TYPE_FILAMENT_LOAD_COMPLETED)) {
|
||||
lv_label_set_text(labelDialog, filament_menu.filament_dialog_load_completed);
|
||||
lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
|
||||
}
|
||||
else if (DIALOG_IS(TYPE_FILAMENT_UNLOAD_COMPLETED)) {
|
||||
lv_label_set_text(labelDialog, filament_menu.filament_dialog_unload_completed);
|
||||
lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
|
||||
}
|
||||
else if (DIALOG_IS(TYPE_FILAMENT_LOADING)) {
|
||||
lv_label_set_text(labelDialog, filament_menu.filament_dialog_loading);
|
||||
lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -70);
|
||||
}
|
||||
else if (DIALOG_IS(TYPE_FILAMENT_UNLOADING)) {
|
||||
lv_label_set_text(labelDialog, filament_menu.filament_dialog_unloading);
|
||||
lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -70);
|
||||
}
|
||||
#if ENABLED(MKS_WIFI_MODULE)
|
||||
else if (DIALOG_IS(TYPE_UNBIND)) {
|
||||
lv_label_set_text(labelDialog, common_menu.unbind_printer_tips);
|
||||
lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -70);
|
||||
}
|
||||
#endif
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) {
|
||||
if (btnOk) lv_group_add_obj(g, btnOk);
|
||||
if (btnCancel) lv_group_add_obj(g, btnCancel);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void filament_sprayer_temp() {
|
||||
char buf[20] = {0};
|
||||
sprintf(buf, preheat_menu.value_state, thermalManager.wholeDegHotend(uiCfg.extruderIndex), thermalManager.degTargetHotend(uiCfg.extruderIndex));
|
||||
|
||||
strcpy(public_buf_l, uiCfg.extruderIndex < 1 ? extrude_menu.ext1 : extrude_menu.ext2);
|
||||
strcat_P(public_buf_l, PSTR(": "));
|
||||
strcat(public_buf_l, buf);
|
||||
lv_label_set_text(tempText1, public_buf_l);
|
||||
lv_obj_align(tempText1, nullptr, LV_ALIGN_CENTER, 0, -50);
|
||||
}
|
||||
|
||||
void filament_dialog_handle() {
|
||||
if (temps_update_flag && (DIALOG_IS(TYPE_FILAMENT_LOAD_HEAT, TYPE_FILAMENT_UNLOAD_HEAT))) {
|
||||
filament_sprayer_temp();
|
||||
temps_update_flag = false;
|
||||
}
|
||||
if (uiCfg.filament_heat_completed_load) {
|
||||
uiCfg.filament_heat_completed_load = false;
|
||||
lv_clear_dialog();
|
||||
lv_draw_dialog(DIALOG_TYPE_FILAMENT_LOADING);
|
||||
planner.synchronize();
|
||||
uiCfg.filament_loading_time_flg = true;
|
||||
uiCfg.filament_loading_time_cnt = 0;
|
||||
sprintf_P(public_buf_m, PSTR("T%d\nG91\nG1 E%d F%d\nG90"), uiCfg.extruderIndex, gCfgItems.filamentchange_load_length, gCfgItems.filamentchange_load_speed);
|
||||
queue.inject(public_buf_m);
|
||||
}
|
||||
if (uiCfg.filament_heat_completed_unload) {
|
||||
uiCfg.filament_heat_completed_unload = false;
|
||||
lv_clear_dialog();
|
||||
lv_draw_dialog(DIALOG_TYPE_FILAMENT_UNLOADING);
|
||||
planner.synchronize();
|
||||
uiCfg.filament_unloading_time_flg = true;
|
||||
uiCfg.filament_unloading_time_cnt = 0;
|
||||
sprintf_P(public_buf_m, PSTR("T%d\nG91\nG1 E-%d F%d\nG90"), uiCfg.extruderIndex, gCfgItems.filamentchange_unload_length, gCfgItems.filamentchange_unload_speed);
|
||||
queue.inject(public_buf_m);
|
||||
}
|
||||
|
||||
if (uiCfg.filament_load_heat_flg) {
|
||||
const celsius_t diff = thermalManager.wholeDegHotend(uiCfg.extruderIndex) - gCfgItems.filament_limit_temp;
|
||||
if (abs(diff) < 2 || diff > 0) {
|
||||
uiCfg.filament_load_heat_flg = false;
|
||||
lv_clear_dialog();
|
||||
lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED);
|
||||
}
|
||||
}
|
||||
|
||||
if (uiCfg.filament_loading_completed) {
|
||||
uiCfg.filament_rate = 0;
|
||||
uiCfg.filament_loading_completed = false;
|
||||
lv_clear_dialog();
|
||||
lv_draw_dialog(DIALOG_TYPE_FILAMENT_LOAD_COMPLETED);
|
||||
}
|
||||
|
||||
if (uiCfg.filament_unload_heat_flg) {
|
||||
const celsius_t diff = thermalManager.wholeDegHotend(uiCfg.extruderIndex) - gCfgItems.filament_limit_temp;
|
||||
if (abs(diff) < 2 || diff > 0) {
|
||||
uiCfg.filament_unload_heat_flg = false;
|
||||
lv_clear_dialog();
|
||||
lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED);
|
||||
}
|
||||
}
|
||||
|
||||
if (uiCfg.filament_unloading_completed) {
|
||||
uiCfg.filament_rate = 0;
|
||||
uiCfg.filament_unloading_completed = false;
|
||||
lv_clear_dialog();
|
||||
lv_draw_dialog(DIALOG_TYPE_FILAMENT_UNLOAD_COMPLETED);
|
||||
}
|
||||
|
||||
if (DIALOG_IS(TYPE_FILAMENT_LOADING, TYPE_FILAMENT_UNLOADING))
|
||||
lv_filament_setbar();
|
||||
}
|
||||
|
||||
void lv_filament_setbar() {
|
||||
lv_bar_set_value(filament_bar, uiCfg.filament_rate, LV_ANIM_ON);
|
||||
}
|
||||
|
||||
void lv_clear_dialog() {
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
|
||||
#endif
|
||||
lv_obj_del(scr);
|
||||
}
|
||||
|
||||
#endif // HAS_TFT_LVGL_UI
|
85
Marlin/src/lcd/extui/mks_ui/draw_dialog.h
Normal file
85
Marlin/src/lcd/extui/mks_ui/draw_dialog.h
Normal file
@ -0,0 +1,85 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* C-declarations for C++ */
|
||||
#endif
|
||||
|
||||
enum {
|
||||
DIALOG_TYPE_STOP = 0,
|
||||
DIALOG_TYPE_PRINT_FILE,
|
||||
DIALOG_TYPE_REPRINT_NO_FILE,
|
||||
|
||||
DIALOG_TYPE_M80_FAIL,
|
||||
DIALOG_TYPE_MESSAGE_ERR1,
|
||||
|
||||
DIALOG_TYPE_UPDATE_ESP_FIRMWARE,
|
||||
DIALOG_TYPE_UPDATE_ESP_DATA,
|
||||
DIALOG_TYPE_UPLOAD_FILE,
|
||||
DIALOG_TYPE_UNBIND,
|
||||
|
||||
DIALOG_TYPE_FILAMENT_LOAD_HEAT,
|
||||
DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED,
|
||||
DIALOG_TYPE_FILAMENT_LOADING,
|
||||
DIALOG_TYPE_FILAMENT_LOAD_COMPLETED,
|
||||
DIALOG_TYPE_FILAMENT_UNLOAD_HEAT,
|
||||
DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED,
|
||||
DIALOG_TYPE_FILAMENT_UNLOADING,
|
||||
DIALOG_TYPE_FILAMENT_UNLOAD_COMPLETED,
|
||||
|
||||
DIALOG_TYPE_FILE_LOADING,
|
||||
|
||||
DIALOG_TYPE_FILAMENT_NO_PRESS,
|
||||
DIALOG_TYPE_FINISH_PRINT,
|
||||
|
||||
DIALOG_WIFI_ENABLE_TIPS,
|
||||
|
||||
DIALOG_PAUSE_MESSAGE_PAUSING,
|
||||
DIALOG_PAUSE_MESSAGE_CHANGING,
|
||||
DIALOG_PAUSE_MESSAGE_UNLOAD,
|
||||
DIALOG_PAUSE_MESSAGE_WAITING,
|
||||
DIALOG_PAUSE_MESSAGE_INSERT,
|
||||
DIALOG_PAUSE_MESSAGE_LOAD,
|
||||
DIALOG_PAUSE_MESSAGE_PURGE,
|
||||
DIALOG_PAUSE_MESSAGE_RESUME,
|
||||
DIALOG_PAUSE_MESSAGE_HEAT,
|
||||
DIALOG_PAUSE_MESSAGE_HEATING,
|
||||
DIALOG_PAUSE_MESSAGE_OPTION,
|
||||
|
||||
DIALOG_STORE_EEPROM_TIPS,
|
||||
DIALOG_READ_EEPROM_TIPS,
|
||||
DIALOG_REVERT_EEPROM_TIPS,
|
||||
|
||||
DIALOG_WIFI_CONFIG_TIPS,
|
||||
DIALOG_TRANSFER_NO_DEVICE
|
||||
};
|
||||
|
||||
void lv_draw_dialog(uint8_t type);
|
||||
void lv_clear_dialog();
|
||||
void filament_sprayer_temp();
|
||||
void filament_dialog_handle();
|
||||
void lv_filament_setbar();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C-declarations for C++ */
|
||||
#endif
|
82
Marlin/src/lcd/extui/mks_ui/draw_eeprom_settings.cpp
Normal file
82
Marlin/src/lcd/extui/mks_ui/draw_eeprom_settings.cpp
Normal file
@ -0,0 +1,82 @@
|
||||
/**
|
||||
* 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_TFT_LVGL_UI
|
||||
|
||||
#include "draw_ui.h"
|
||||
#include <lv_conf.h>
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
extern lv_group_t *g;
|
||||
static lv_obj_t *scr;
|
||||
|
||||
enum {
|
||||
ID_EEPROM_RETURN = 1,
|
||||
ID_EEPROM_STORE,
|
||||
ID_EEPROM_STORE_ARROW,
|
||||
ID_EEPROM_READ,
|
||||
ID_EEPROM_READ_ARROW,
|
||||
ID_EEPROM_REVERT,
|
||||
ID_EEPROM_REVERT_ARROW
|
||||
};
|
||||
|
||||
static void event_handler(lv_obj_t *obj, lv_event_t event) {
|
||||
if (event != LV_EVENT_RELEASED) return;
|
||||
switch (obj->mks_obj_id) {
|
||||
case ID_EEPROM_RETURN:
|
||||
lv_clear_eeprom_settings();
|
||||
draw_return_ui();
|
||||
break;
|
||||
case ID_EEPROM_STORE:
|
||||
lv_clear_eeprom_settings();
|
||||
lv_draw_dialog(DIALOG_STORE_EEPROM_TIPS);
|
||||
break;
|
||||
#if 0
|
||||
case ID_EEPROM_READ:
|
||||
lv_clear_eeprom_settings();
|
||||
lv_draw_dialog(DIALOG_READ_EEPROM_TIPS);
|
||||
break;
|
||||
#endif
|
||||
case ID_EEPROM_REVERT:
|
||||
lv_clear_eeprom_settings();
|
||||
lv_draw_dialog(DIALOG_REVERT_EEPROM_TIPS);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void lv_draw_eeprom_settings() {
|
||||
scr = lv_screen_create(EEPROM_SETTINGS_UI);
|
||||
lv_screen_menu_item(scr, eeprom_menu.revert, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_EEPROM_REVERT, 0);
|
||||
lv_screen_menu_item(scr, eeprom_menu.store, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_EEPROM_STORE, 1);
|
||||
lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_EEPROM_RETURN, true);
|
||||
}
|
||||
|
||||
void lv_clear_eeprom_settings() {
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
|
||||
#endif
|
||||
lv_obj_del(scr);
|
||||
}
|
||||
|
||||
#endif // HAS_TFT_LVGL_UI
|
33
Marlin/src/lcd/extui/mks_ui/draw_eeprom_settings.h
Normal file
33
Marlin/src/lcd/extui/mks_ui/draw_eeprom_settings.h
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* C-declarations for C++ */
|
||||
#endif
|
||||
|
||||
void lv_draw_eeprom_settings();
|
||||
void lv_clear_eeprom_settings();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C-declarations for C++ */
|
||||
#endif
|
72
Marlin/src/lcd/extui/mks_ui/draw_encoder_settings.cpp
Normal file
72
Marlin/src/lcd/extui/mks_ui/draw_encoder_settings.cpp
Normal file
@ -0,0 +1,72 @@
|
||||
/**
|
||||
* 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_TFT_LVGL_UI
|
||||
|
||||
#include "draw_ui.h"
|
||||
#include <lv_conf.h>
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
#if BUTTONS_EXIST(EN1, EN2)
|
||||
|
||||
extern lv_group_t *g;
|
||||
static lv_obj_t *scr;
|
||||
static lv_obj_t *buttonEncoderState = nullptr;
|
||||
|
||||
enum {
|
||||
ID_ENCODER_RETURN = 1,
|
||||
ID_ENCODER_STATE
|
||||
};
|
||||
|
||||
static void event_handler(lv_obj_t *obj, lv_event_t event) {
|
||||
if (event != LV_EVENT_RELEASED) return;
|
||||
switch (obj->mks_obj_id) {
|
||||
case ID_ENCODER_RETURN:
|
||||
lv_clear_encoder_settings();
|
||||
draw_return_ui();
|
||||
break;
|
||||
case ID_ENCODER_STATE:
|
||||
gCfgItems.encoder_enable ^= true;
|
||||
lv_screen_menu_item_onoff_update(buttonEncoderState, gCfgItems.encoder_enable);
|
||||
update_spi_flash();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void lv_draw_encoder_settings() {
|
||||
scr = lv_screen_create(ENCODER_SETTINGS_UI, machine_menu.EncoderConfTitle);
|
||||
buttonEncoderState = lv_screen_menu_item_onoff(scr, machine_menu.EncoderConfText, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_ENCODER_STATE, 0, gCfgItems.encoder_enable);
|
||||
lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_ENCODER_RETURN, true);
|
||||
}
|
||||
|
||||
void lv_clear_encoder_settings() {
|
||||
#if HAS_ROTARY_ENCODER
|
||||
lv_group_remove_all_objs(g);
|
||||
#endif
|
||||
lv_obj_del(scr);
|
||||
}
|
||||
|
||||
#endif // BUTTONS_EXIST(EN1, EN2)
|
||||
|
||||
#endif // HAS_TFT_LVGL_UI
|
33
Marlin/src/lcd/extui/mks_ui/draw_encoder_settings.h
Normal file
33
Marlin/src/lcd/extui/mks_ui/draw_encoder_settings.h
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* C-declarations for C++ */
|
||||
#endif
|
||||
|
||||
void lv_draw_encoder_settings();
|
||||
void lv_clear_encoder_settings();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C-declarations for C++ */
|
||||
#endif
|
46
Marlin/src/lcd/extui/mks_ui/draw_error_message.cpp
Normal file
46
Marlin/src/lcd/extui/mks_ui/draw_error_message.cpp
Normal file
@ -0,0 +1,46 @@
|
||||
/**
|
||||
* 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_TFT_LVGL_UI
|
||||
|
||||
#include "draw_ui.h"
|
||||
#include <lv_conf.h>
|
||||
|
||||
#include "tft_lvgl_configuration.h"
|
||||
|
||||
#include "SPI_TFT.h"
|
||||
#include "mks_hardware_test.h"
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
static lv_obj_t *scr;
|
||||
|
||||
void lv_draw_error_message(PGM_P const msg) {
|
||||
SPI_TFT.LCD_clear(0x0000);
|
||||
if (msg) disp_string((TFT_WIDTH - strlen(msg) * 16) / 2, 100, msg, 0xFFFF, 0x0000);
|
||||
disp_string((TFT_WIDTH - strlen("PRINTER HALTED") * 16) / 2, 140, "PRINTER HALTED", 0xFFFF, 0x0000);
|
||||
disp_string((TFT_WIDTH - strlen("Please Reset") * 16) / 2, 180, "Please Reset", 0xFFFF, 0x0000);
|
||||
}
|
||||
|
||||
void lv_clear_error_message() { lv_obj_del(scr); }
|
||||
|
||||
#endif // HAS_TFT_LVGL_UI
|
37
Marlin/src/lcd/extui/mks_ui/draw_error_message.h
Normal file
37
Marlin/src/lcd/extui/mks_ui/draw_error_message.h
Normal file
@ -0,0 +1,37 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* C-declarations for C++ */
|
||||
#endif
|
||||
|
||||
#ifndef PGM_P
|
||||
#define PGM_P const char *
|
||||
#endif
|
||||
|
||||
void lv_draw_error_message(PGM_P const msg);
|
||||
void lv_clear_error_message();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C-declarations for C++ */
|
||||
#endif
|
254
Marlin/src/lcd/extui/mks_ui/draw_extrusion.cpp
Normal file
254
Marlin/src/lcd/extui/mks_ui/draw_extrusion.cpp
Normal file
@ -0,0 +1,254 @@
|
||||
/**
|
||||
* 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_TFT_LVGL_UI
|
||||
|
||||
#include "draw_ui.h"
|
||||
#include <lv_conf.h>
|
||||
|
||||
#include "../../../module/temperature.h"
|
||||
#include "../../../gcode/queue.h"
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
static lv_obj_t *scr;
|
||||
extern lv_group_t *g;
|
||||
static lv_obj_t *buttonType, *buttonStep, *buttonSpeed;
|
||||
static lv_obj_t *labelType;
|
||||
static lv_obj_t *labelStep;
|
||||
static lv_obj_t *labelSpeed;
|
||||
static lv_obj_t *tempText;
|
||||
static lv_obj_t *ExtruText;
|
||||
|
||||
enum {
|
||||
ID_E_ADD = 1,
|
||||
ID_E_DEC,
|
||||
ID_E_TYPE,
|
||||
ID_E_STEP,
|
||||
ID_E_SPEED,
|
||||
ID_E_RETURN
|
||||
};
|
||||
|
||||
static int32_t extrudeAmount;
|
||||
|
||||
static void event_handler(lv_obj_t *obj, lv_event_t event) {
|
||||
if (event != LV_EVENT_RELEASED) return;
|
||||
switch (obj->mks_obj_id) {
|
||||
case ID_E_ADD:
|
||||
if (thermalManager.degHotend(uiCfg.extruderIndex) >= EXTRUDE_MINTEMP) {
|
||||
sprintf_P((char *)public_buf_l, PSTR("G91\nG1 E%d F%d\nG90"), uiCfg.extruStep, 60 * uiCfg.extruSpeed);
|
||||
queue.inject(public_buf_l);
|
||||
extrudeAmount += uiCfg.extruStep;
|
||||
disp_extru_amount();
|
||||
}
|
||||
break;
|
||||
case ID_E_DEC:
|
||||
if (thermalManager.degHotend(uiCfg.extruderIndex) >= EXTRUDE_MINTEMP) {
|
||||
sprintf_P((char *)public_buf_l, PSTR("G91\nG1 E%d F%d\nG90"), 0 - uiCfg.extruStep, 60 * uiCfg.extruSpeed);
|
||||
queue.enqueue_one_now(public_buf_l);
|
||||
extrudeAmount -= uiCfg.extruStep;
|
||||
disp_extru_amount();
|
||||
}
|
||||
break;
|
||||
case ID_E_TYPE:
|
||||
if (ENABLED(HAS_MULTI_EXTRUDER)) {
|
||||
if (uiCfg.extruderIndex == 0) {
|
||||
uiCfg.extruderIndex = 1;
|
||||
queue.inject_P(PSTR("T1"));
|
||||
}
|
||||
else {
|
||||
uiCfg.extruderIndex = 0;
|
||||
queue.inject_P(PSTR("T0"));
|
||||
}
|
||||
}
|
||||
else
|
||||
uiCfg.extruderIndex = 0;
|
||||
|
||||
extrudeAmount = 0;
|
||||
disp_hotend_temp();
|
||||
disp_ext_type();
|
||||
disp_extru_amount();
|
||||
break;
|
||||
case ID_E_STEP:
|
||||
switch (abs(uiCfg.extruStep)) {
|
||||
case 1: uiCfg.extruStep = 5; break;
|
||||
case 5: uiCfg.extruStep = 10; break;
|
||||
case 10: uiCfg.extruStep = 1; break;
|
||||
default: break;
|
||||
}
|
||||
disp_ext_step();
|
||||
break;
|
||||
case ID_E_SPEED:
|
||||
switch (uiCfg.extruSpeed) {
|
||||
case 1: uiCfg.extruSpeed = 10; break;
|
||||
case 10: uiCfg.extruSpeed = 20; break;
|
||||
case 20: uiCfg.extruSpeed = 1; break;
|
||||
default: break;
|
||||
}
|
||||
disp_ext_speed();
|
||||
break;
|
||||
case ID_E_RETURN:
|
||||
clear_cur_ui();
|
||||
draw_return_ui();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void lv_draw_extrusion() {
|
||||
scr = lv_screen_create(EXTRUSION_UI);
|
||||
// Create image buttons
|
||||
lv_obj_t *buttonAdd = lv_big_button_create(scr, "F:/bmp_in.bin", extrude_menu.in, INTERVAL_V, titleHeight, event_handler, ID_E_ADD);
|
||||
lv_obj_clear_protect(buttonAdd, LV_PROTECT_FOLLOW);
|
||||
lv_big_button_create(scr, "F:/bmp_out.bin", extrude_menu.out, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_E_DEC);
|
||||
|
||||
buttonType = lv_imgbtn_create(scr, nullptr, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_E_TYPE);
|
||||
buttonStep = lv_imgbtn_create(scr, nullptr, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_E_STEP);
|
||||
buttonSpeed = lv_imgbtn_create(scr, nullptr, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_E_SPEED);
|
||||
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) {
|
||||
lv_group_add_obj(g, buttonType);
|
||||
lv_group_add_obj(g, buttonStep);
|
||||
lv_group_add_obj(g, buttonSpeed);
|
||||
}
|
||||
#endif
|
||||
|
||||
lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_E_RETURN);
|
||||
|
||||
// Create labels on the image buttons
|
||||
labelType = lv_label_create_empty(buttonType);
|
||||
labelStep = lv_label_create_empty(buttonStep);
|
||||
labelSpeed = lv_label_create_empty(buttonSpeed);
|
||||
|
||||
disp_ext_type();
|
||||
disp_ext_step();
|
||||
disp_ext_speed();
|
||||
|
||||
tempText = lv_label_create_empty(scr);
|
||||
lv_obj_set_style(tempText, &tft_style_label_rel);
|
||||
disp_hotend_temp();
|
||||
|
||||
ExtruText = lv_label_create_empty(scr);
|
||||
lv_obj_set_style(ExtruText, &tft_style_label_rel);
|
||||
disp_extru_amount();
|
||||
}
|
||||
|
||||
void disp_ext_type() {
|
||||
if (uiCfg.extruderIndex == 1) {
|
||||
lv_imgbtn_set_src_both(buttonType, "F:/bmp_extru2.bin");
|
||||
if (gCfgItems.multiple_language) {
|
||||
lv_label_set_text(labelType, extrude_menu.ext2);
|
||||
lv_obj_align(labelType, buttonType, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
||||
}
|
||||
}
|
||||
else {
|
||||
lv_imgbtn_set_src_both(buttonType, "F:/bmp_extru1.bin");
|
||||
if (gCfgItems.multiple_language) {
|
||||
lv_label_set_text(labelType, extrude_menu.ext1);
|
||||
lv_obj_align(labelType, buttonType, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void disp_ext_speed() {
|
||||
if (uiCfg.extruSpeed == 20)
|
||||
lv_imgbtn_set_src_both(buttonSpeed, "F:/bmp_speed_high.bin");
|
||||
else if (uiCfg.extruSpeed == 1)
|
||||
lv_imgbtn_set_src_both(buttonSpeed, "F:/bmp_speed_slow.bin");
|
||||
else
|
||||
lv_imgbtn_set_src_both(buttonSpeed, "F:/bmp_speed_normal.bin");
|
||||
|
||||
if (gCfgItems.multiple_language) {
|
||||
if (uiCfg.extruSpeed == 20) {
|
||||
lv_label_set_text(labelSpeed, extrude_menu.high);
|
||||
lv_obj_align(labelSpeed, buttonSpeed, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
||||
}
|
||||
else if (uiCfg.extruSpeed == 1) {
|
||||
lv_label_set_text(labelSpeed, extrude_menu.low);
|
||||
lv_obj_align(labelSpeed, buttonSpeed, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
||||
}
|
||||
else {
|
||||
lv_label_set_text(labelSpeed, extrude_menu.normal);
|
||||
lv_obj_align(labelSpeed, buttonSpeed, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void disp_hotend_temp() {
|
||||
char buf[20] = {0};
|
||||
sprintf(buf, extrude_menu.temp_value, thermalManager.wholeDegHotend(uiCfg.extruderIndex), thermalManager.degTargetHotend(uiCfg.extruderIndex));
|
||||
strcpy(public_buf_l, extrude_menu.temper_text);
|
||||
strcat(public_buf_l, buf);
|
||||
lv_label_set_text(tempText, public_buf_l);
|
||||
lv_obj_align(tempText, nullptr, LV_ALIGN_CENTER, 0, -50);
|
||||
}
|
||||
|
||||
void disp_extru_amount() {
|
||||
char buf1[10] = {0};
|
||||
|
||||
public_buf_l[0] = '\0';
|
||||
|
||||
if (extrudeAmount < 999 && extrudeAmount > -99)
|
||||
sprintf(buf1, extrude_menu.count_value_mm, extrudeAmount);
|
||||
else if (extrudeAmount < 9999 && extrudeAmount > -999)
|
||||
sprintf(buf1, extrude_menu.count_value_cm, extrudeAmount / 10);
|
||||
else
|
||||
sprintf(buf1, extrude_menu.count_value_m, extrudeAmount / 1000);
|
||||
strcat(public_buf_l, uiCfg.extruderIndex == 0 ? extrude_menu.ext1 : extrude_menu.ext2);
|
||||
strcat(public_buf_l, buf1);
|
||||
|
||||
lv_label_set_text(ExtruText, public_buf_l);
|
||||
lv_obj_align(ExtruText, nullptr, LV_ALIGN_CENTER, 0, -75);
|
||||
}
|
||||
|
||||
void disp_ext_step() {
|
||||
if (uiCfg.extruStep == 1)
|
||||
lv_imgbtn_set_src_both(buttonStep, "F:/bmp_step1_mm.bin");
|
||||
else if (uiCfg.extruStep == 5)
|
||||
lv_imgbtn_set_src_both(buttonStep, "F:/bmp_step5_mm.bin");
|
||||
else if (uiCfg.extruStep == 10)
|
||||
lv_imgbtn_set_src_both(buttonStep, "F:/bmp_step10_mm.bin");
|
||||
|
||||
if (gCfgItems.multiple_language) {
|
||||
if (uiCfg.extruStep == 1) {
|
||||
lv_label_set_text(labelStep, extrude_menu.step_1mm);
|
||||
lv_obj_align(labelStep, buttonStep, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
||||
}
|
||||
else if (uiCfg.extruStep == 5) {
|
||||
lv_label_set_text(labelStep, extrude_menu.step_5mm);
|
||||
lv_obj_align(labelStep, buttonStep, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
||||
}
|
||||
else if (uiCfg.extruStep == 10) {
|
||||
lv_label_set_text(labelStep, extrude_menu.step_10mm);
|
||||
lv_obj_align(labelStep, buttonStep, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void lv_clear_extrusion() {
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
|
||||
#endif
|
||||
lv_obj_del(scr);
|
||||
}
|
||||
|
||||
#endif // HAS_TFT_LVGL_UI
|
38
Marlin/src/lcd/extui/mks_ui/draw_extrusion.h
Normal file
38
Marlin/src/lcd/extui/mks_ui/draw_extrusion.h
Normal file
@ -0,0 +1,38 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* C-declarations for C++ */
|
||||
#endif
|
||||
|
||||
void lv_draw_extrusion();
|
||||
void lv_clear_extrusion();
|
||||
void disp_ext_type();
|
||||
void disp_ext_step();
|
||||
void disp_ext_speed();
|
||||
void disp_hotend_temp();
|
||||
void disp_extru_amount();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C-declarations for C++ */
|
||||
#endif
|
95
Marlin/src/lcd/extui/mks_ui/draw_fan.cpp
Normal file
95
Marlin/src/lcd/extui/mks_ui/draw_fan.cpp
Normal file
@ -0,0 +1,95 @@
|
||||
/**
|
||||
* 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_TFT_LVGL_UI
|
||||
|
||||
#include "draw_ui.h"
|
||||
#include <lv_conf.h>
|
||||
|
||||
#include "../../../module/temperature.h"
|
||||
#include "../../../gcode/queue.h"
|
||||
#include "../../../gcode/gcode.h"
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
extern lv_group_t *g;
|
||||
static lv_obj_t *scr, *fanText;
|
||||
|
||||
enum {
|
||||
ID_F_ADD = 1,
|
||||
ID_F_DEC,
|
||||
ID_F_HIGH,
|
||||
ID_F_MID,
|
||||
ID_F_OFF,
|
||||
ID_F_RETURN
|
||||
};
|
||||
|
||||
static void event_handler(lv_obj_t *obj, lv_event_t event) {
|
||||
if (event != LV_EVENT_RELEASED) return;
|
||||
uint8_t fanPercent = map(thermalManager.fan_speed[0], 0, 255, 0, 100);
|
||||
switch (obj->mks_obj_id) {
|
||||
case ID_F_ADD: if (fanPercent < 100) fanPercent++; break;
|
||||
case ID_F_DEC: if (fanPercent != 0) fanPercent--; break;
|
||||
case ID_F_HIGH: fanPercent = 100; break;
|
||||
case ID_F_MID: fanPercent = 50; break;
|
||||
case ID_F_OFF: fanPercent = 0; break;
|
||||
case ID_F_RETURN: clear_cur_ui(); draw_return_ui(); return;
|
||||
}
|
||||
thermalManager.set_fan_speed(0, map(fanPercent, 0, 100, 0, 255));
|
||||
}
|
||||
|
||||
void lv_draw_fan() {
|
||||
lv_obj_t *buttonAdd;
|
||||
|
||||
scr = lv_screen_create(FAN_UI);
|
||||
// Create an Image button
|
||||
buttonAdd = lv_big_button_create(scr, "F:/bmp_Add.bin", fan_menu.add, INTERVAL_V, titleHeight, event_handler, ID_F_ADD);
|
||||
lv_obj_clear_protect(buttonAdd, LV_PROTECT_FOLLOW);
|
||||
lv_big_button_create(scr, "F:/bmp_Dec.bin", fan_menu.dec, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_F_DEC);
|
||||
lv_big_button_create(scr, "F:/bmp_speed255.bin", fan_menu.full, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_F_HIGH);
|
||||
lv_big_button_create(scr, "F:/bmp_speed127.bin", fan_menu.half, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_F_MID);
|
||||
lv_big_button_create(scr, "F:/bmp_speed0.bin", fan_menu.off, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_F_OFF);
|
||||
lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_F_RETURN);
|
||||
|
||||
fanText = lv_label_create_empty(scr);
|
||||
lv_obj_set_style(fanText, &tft_style_label_rel);
|
||||
disp_fan_value();
|
||||
}
|
||||
|
||||
void disp_fan_value() {
|
||||
#if HAS_FAN
|
||||
sprintf_P(public_buf_l, PSTR("%s: %3d%%"), fan_menu.state, (int)map(thermalManager.fan_speed[0], 0, 255, 0, 100));
|
||||
#else
|
||||
sprintf_P(public_buf_l, PSTR("%s: ---"), fan_menu.state);
|
||||
#endif
|
||||
lv_label_set_text(fanText, public_buf_l);
|
||||
lv_obj_align(fanText, nullptr, LV_ALIGN_CENTER, 0, -65);
|
||||
}
|
||||
|
||||
void lv_clear_fan() {
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
|
||||
#endif
|
||||
lv_obj_del(scr);
|
||||
}
|
||||
|
||||
#endif // HAS_TFT_LVGL_UI
|
34
Marlin/src/lcd/extui/mks_ui/draw_fan.h
Normal file
34
Marlin/src/lcd/extui/mks_ui/draw_fan.h
Normal file
@ -0,0 +1,34 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* C-declarations for C++ */
|
||||
#endif
|
||||
|
||||
void lv_draw_fan();
|
||||
void lv_clear_fan();
|
||||
void disp_fan_value();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C-declarations for C++ */
|
||||
#endif
|
172
Marlin/src/lcd/extui/mks_ui/draw_filament_change.cpp
Normal file
172
Marlin/src/lcd/extui/mks_ui/draw_filament_change.cpp
Normal file
@ -0,0 +1,172 @@
|
||||
/**
|
||||
* 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_TFT_LVGL_UI
|
||||
|
||||
#include "draw_ui.h"
|
||||
#include <lv_conf.h>
|
||||
|
||||
#include "../../../module/temperature.h"
|
||||
#include "../../../gcode/gcode.h"
|
||||
#include "../../../module/motion.h"
|
||||
#include "../../../module/planner.h"
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
extern lv_group_t *g;
|
||||
static lv_obj_t *scr;
|
||||
static lv_obj_t *buttonType;
|
||||
static lv_obj_t *labelType;
|
||||
static lv_obj_t *tempText1;
|
||||
|
||||
enum {
|
||||
ID_FILAMNT_IN = 1,
|
||||
ID_FILAMNT_OUT,
|
||||
ID_FILAMNT_TYPE,
|
||||
ID_FILAMNT_RETURN
|
||||
};
|
||||
|
||||
static void event_handler(lv_obj_t *obj, lv_event_t event) {
|
||||
if (event != LV_EVENT_RELEASED) return;
|
||||
switch (obj->mks_obj_id) {
|
||||
case ID_FILAMNT_IN:
|
||||
uiCfg.filament_load_heat_flg = true;
|
||||
if (abs(thermalManager.degTargetHotend(uiCfg.extruderIndex) - thermalManager.wholeDegHotend(uiCfg.extruderIndex)) <= 1
|
||||
|| gCfgItems.filament_limit_temp <= thermalManager.wholeDegHotend(uiCfg.extruderIndex)) {
|
||||
lv_clear_filament_change();
|
||||
lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED);
|
||||
}
|
||||
else {
|
||||
lv_clear_filament_change();
|
||||
lv_draw_dialog(DIALOG_TYPE_FILAMENT_LOAD_HEAT);
|
||||
if (thermalManager.degTargetHotend(uiCfg.extruderIndex) < gCfgItems.filament_limit_temp) {
|
||||
thermalManager.setTargetHotend(gCfgItems.filament_limit_temp, uiCfg.extruderIndex);
|
||||
thermalManager.start_watching_hotend(uiCfg.extruderIndex);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ID_FILAMNT_OUT:
|
||||
uiCfg.filament_unload_heat_flg = true;
|
||||
if (thermalManager.degTargetHotend(uiCfg.extruderIndex)
|
||||
&& (abs(thermalManager.degTargetHotend(uiCfg.extruderIndex) - thermalManager.wholeDegHotend(uiCfg.extruderIndex)) <= 1
|
||||
|| thermalManager.wholeDegHotend(uiCfg.extruderIndex) >= gCfgItems.filament_limit_temp)
|
||||
) {
|
||||
lv_clear_filament_change();
|
||||
lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED);
|
||||
}
|
||||
else {
|
||||
lv_clear_filament_change();
|
||||
lv_draw_dialog(DIALOG_TYPE_FILAMENT_UNLOAD_HEAT);
|
||||
if (thermalManager.degTargetHotend(uiCfg.extruderIndex) < gCfgItems.filament_limit_temp) {
|
||||
thermalManager.setTargetHotend(gCfgItems.filament_limit_temp, uiCfg.extruderIndex);
|
||||
thermalManager.start_watching_hotend(uiCfg.extruderIndex);
|
||||
}
|
||||
filament_sprayer_temp();
|
||||
}
|
||||
break;
|
||||
case ID_FILAMNT_TYPE:
|
||||
#if HAS_MULTI_EXTRUDER
|
||||
uiCfg.extruderIndex = !uiCfg.extruderIndex;
|
||||
#endif
|
||||
disp_filament_type();
|
||||
break;
|
||||
case ID_FILAMNT_RETURN:
|
||||
#if HAS_MULTI_EXTRUDER
|
||||
if (uiCfg.print_state != IDLE && uiCfg.print_state != REPRINTED)
|
||||
gcode.process_subcommands_now_P(uiCfg.extruderIndexBak == 1 ? PSTR("T1") : PSTR("T0"));
|
||||
#endif
|
||||
feedrate_mm_s = (float)uiCfg.moveSpeed_bak;
|
||||
if (uiCfg.print_state == PAUSED)
|
||||
planner.set_e_position_mm((destination.e = current_position.e = uiCfg.current_e_position_bak));
|
||||
thermalManager.setTargetHotend(uiCfg.hotendTargetTempBak, uiCfg.extruderIndex);
|
||||
|
||||
clear_cur_ui();
|
||||
draw_return_ui();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void lv_draw_filament_change() {
|
||||
scr = lv_screen_create(FILAMENTCHANGE_UI);
|
||||
// Create an Image button
|
||||
lv_obj_t *buttonIn = lv_big_button_create(scr, "F:/bmp_in.bin", filament_menu.in, INTERVAL_V, titleHeight, event_handler, ID_FILAMNT_IN);
|
||||
lv_obj_clear_protect(buttonIn, LV_PROTECT_FOLLOW);
|
||||
lv_big_button_create(scr, "F:/bmp_out.bin", filament_menu.out, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_FILAMNT_OUT);
|
||||
|
||||
buttonType = lv_imgbtn_create(scr, nullptr, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_FILAMNT_TYPE);
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) {
|
||||
lv_group_add_obj(g, buttonType);
|
||||
}
|
||||
#endif
|
||||
|
||||
lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_FILAMNT_RETURN);
|
||||
|
||||
// Create labels on the image buttons
|
||||
labelType = lv_label_create_empty(buttonType);
|
||||
|
||||
disp_filament_type();
|
||||
|
||||
tempText1 = lv_label_create_empty(scr);
|
||||
lv_obj_set_style(tempText1, &tft_style_label_rel);
|
||||
disp_filament_temp();
|
||||
}
|
||||
|
||||
void disp_filament_type() {
|
||||
if (uiCfg.extruderIndex == 1) {
|
||||
lv_imgbtn_set_src_both(buttonType, "F:/bmp_extru2.bin");
|
||||
if (gCfgItems.multiple_language) {
|
||||
lv_label_set_text(labelType, preheat_menu.ext2);
|
||||
lv_obj_align(labelType, buttonType, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
||||
}
|
||||
}
|
||||
else {
|
||||
lv_imgbtn_set_src_both(buttonType, "F:/bmp_extru1.bin");
|
||||
if (gCfgItems.multiple_language) {
|
||||
lv_label_set_text(labelType, preheat_menu.ext1);
|
||||
lv_obj_align(labelType, buttonType, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void disp_filament_temp() {
|
||||
char buf[20] = {0};
|
||||
|
||||
public_buf_l[0] = '\0';
|
||||
|
||||
strcat(public_buf_l, uiCfg.extruderIndex < 1 ? preheat_menu.ext1 : preheat_menu.ext2);
|
||||
sprintf(buf, preheat_menu.value_state, thermalManager.wholeDegHotend(uiCfg.extruderIndex), thermalManager.degTargetHotend(uiCfg.extruderIndex));
|
||||
|
||||
strcat_P(public_buf_l, PSTR(": "));
|
||||
strcat(public_buf_l, buf);
|
||||
lv_label_set_text(tempText1, public_buf_l);
|
||||
lv_obj_align(tempText1, nullptr, LV_ALIGN_CENTER, 0, -50);
|
||||
}
|
||||
|
||||
void lv_clear_filament_change() {
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
|
||||
#endif
|
||||
lv_obj_del(scr);
|
||||
}
|
||||
|
||||
#endif // HAS_TFT_LVGL_UI
|
35
Marlin/src/lcd/extui/mks_ui/draw_filament_change.h
Normal file
35
Marlin/src/lcd/extui/mks_ui/draw_filament_change.h
Normal file
@ -0,0 +1,35 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* C-declarations for C++ */
|
||||
#endif
|
||||
|
||||
void lv_draw_filament_change();
|
||||
void lv_clear_filament_change();
|
||||
void disp_filament_type();
|
||||
void disp_filament_temp();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C-declarations for C++ */
|
||||
#endif
|
126
Marlin/src/lcd/extui/mks_ui/draw_filament_settings.cpp
Normal file
126
Marlin/src/lcd/extui/mks_ui/draw_filament_settings.cpp
Normal file
@ -0,0 +1,126 @@
|
||||
/**
|
||||
* 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_TFT_LVGL_UI
|
||||
|
||||
#include "draw_ui.h"
|
||||
#include <lv_conf.h>
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
extern lv_group_t *g;
|
||||
static lv_obj_t *scr;
|
||||
|
||||
enum {
|
||||
ID_FILAMENT_SET_RETURN = 1,
|
||||
ID_FILAMENT_SET_IN_LENGTH,
|
||||
ID_FILAMENT_SET_IN_SPEED,
|
||||
ID_FILAMENT_SET_OUT_LENGTH,
|
||||
ID_FILAMENT_SET_OUT_SPEED,
|
||||
ID_FILAMENT_SET_TEMP,
|
||||
ID_FILAMENT_SET_DOWN,
|
||||
ID_FILAMENT_SET_UP
|
||||
};
|
||||
|
||||
static void event_handler(lv_obj_t *obj, lv_event_t event) {
|
||||
if (event != LV_EVENT_RELEASED) return;
|
||||
switch (obj->mks_obj_id) {
|
||||
case ID_FILAMENT_SET_RETURN:
|
||||
uiCfg.para_ui_page = false;
|
||||
lv_clear_filament_settings();
|
||||
draw_return_ui();
|
||||
break;
|
||||
case ID_FILAMENT_SET_IN_LENGTH:
|
||||
value = load_length;
|
||||
lv_clear_filament_settings();
|
||||
lv_draw_number_key();
|
||||
break;
|
||||
case ID_FILAMENT_SET_IN_SPEED:
|
||||
value = load_speed;
|
||||
lv_clear_filament_settings();
|
||||
lv_draw_number_key();
|
||||
break;
|
||||
case ID_FILAMENT_SET_OUT_LENGTH:
|
||||
value = unload_length;
|
||||
lv_clear_filament_settings();
|
||||
lv_draw_number_key();
|
||||
break;
|
||||
case ID_FILAMENT_SET_OUT_SPEED:
|
||||
value = unload_speed;
|
||||
lv_clear_filament_settings();
|
||||
lv_draw_number_key();
|
||||
break;
|
||||
case ID_FILAMENT_SET_TEMP:
|
||||
value = filament_temp;
|
||||
lv_clear_filament_settings();
|
||||
lv_draw_number_key();
|
||||
break;
|
||||
case ID_FILAMENT_SET_UP:
|
||||
uiCfg.para_ui_page = false;
|
||||
lv_clear_filament_settings();
|
||||
lv_draw_filament_settings();
|
||||
break;
|
||||
case ID_FILAMENT_SET_DOWN:
|
||||
uiCfg.para_ui_page = true;
|
||||
lv_clear_filament_settings();
|
||||
lv_draw_filament_settings();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void lv_draw_filament_settings() {
|
||||
scr = lv_screen_create(FILAMENT_SETTINGS_UI, machine_menu.FilamentConfTitle);
|
||||
|
||||
if (!uiCfg.para_ui_page) {
|
||||
itoa(gCfgItems.filamentchange_load_length, public_buf_l, 10);
|
||||
lv_screen_menu_item_1_edit(scr, machine_menu.InLength, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_FILAMENT_SET_IN_LENGTH, 0, public_buf_l);
|
||||
|
||||
itoa(gCfgItems.filamentchange_load_speed, public_buf_l, 10);
|
||||
lv_screen_menu_item_1_edit(scr, machine_menu.InSpeed, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_FILAMENT_SET_IN_SPEED, 1, public_buf_l);
|
||||
|
||||
itoa(gCfgItems.filamentchange_unload_length, public_buf_l, 10);
|
||||
lv_screen_menu_item_1_edit(scr, machine_menu.OutLength, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_FILAMENT_SET_OUT_LENGTH, 2, public_buf_l);
|
||||
|
||||
itoa(gCfgItems.filamentchange_unload_speed, public_buf_l, 10);
|
||||
lv_screen_menu_item_1_edit(scr, machine_menu.OutSpeed, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_FILAMENT_SET_OUT_SPEED, 3, public_buf_l);
|
||||
|
||||
lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.next, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_FILAMENT_SET_DOWN, true);
|
||||
}
|
||||
else {
|
||||
itoa(gCfgItems.filament_limit_temp, public_buf_l, 10);
|
||||
lv_screen_menu_item_1_edit(scr, machine_menu.FilamentTemperature, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_FILAMENT_SET_TEMP, 0, public_buf_l);
|
||||
|
||||
lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.previous, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_FILAMENT_SET_UP, true);
|
||||
}
|
||||
|
||||
lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_FILAMENT_SET_RETURN, true);
|
||||
}
|
||||
|
||||
void lv_clear_filament_settings() {
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
|
||||
#endif
|
||||
lv_obj_del(scr);
|
||||
}
|
||||
|
||||
#endif // HAS_TFT_LVGL_UI
|
33
Marlin/src/lcd/extui/mks_ui/draw_filament_settings.h
Normal file
33
Marlin/src/lcd/extui/mks_ui/draw_filament_settings.h
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* C-declarations for C++ */
|
||||
#endif
|
||||
|
||||
void lv_draw_filament_settings();
|
||||
void lv_clear_filament_settings();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C-declarations for C++ */
|
||||
#endif
|
109
Marlin/src/lcd/extui/mks_ui/draw_gcode.cpp
Normal file
109
Marlin/src/lcd/extui/mks_ui/draw_gcode.cpp
Normal file
@ -0,0 +1,109 @@
|
||||
/**
|
||||
* 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_TFT_LVGL_UI
|
||||
|
||||
#include "draw_ui.h"
|
||||
#include <lv_conf.h>
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
extern lv_group_t *g;
|
||||
static lv_obj_t *scr,*outL,*outV = 0;
|
||||
static int currentWritePos = 0;
|
||||
extern uint8_t public_buf[513];
|
||||
extern "C" { extern char public_buf_m[100]; }
|
||||
|
||||
enum {
|
||||
ID_GCODE_RETURN = 1,
|
||||
ID_GCODE_COMMAND,
|
||||
};
|
||||
|
||||
static void event_handler(lv_obj_t *obj, lv_event_t event) {
|
||||
if (event != LV_EVENT_RELEASED) return;
|
||||
lv_clear_gcode();
|
||||
switch (obj->mks_obj_id) {
|
||||
case ID_GCODE_RETURN:
|
||||
lv_draw_more();
|
||||
return;
|
||||
case ID_GCODE_COMMAND:
|
||||
keyboard_value = GCodeCommand;
|
||||
lv_draw_keyboard();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void lv_show_gcode_output(void * that, const char * txt) {
|
||||
// Ignore echo of command
|
||||
if (!memcmp(txt, "echo:", 5)) {
|
||||
public_buf[0] = 0; // Clear output buffer
|
||||
return;
|
||||
}
|
||||
|
||||
// Avoid overflow if the answer is too large
|
||||
size_t len = strlen((const char*)public_buf), tlen = strlen(txt);
|
||||
if (len + tlen + 1 < sizeof(public_buf)) {
|
||||
memcpy(public_buf + len, txt, tlen);
|
||||
public_buf[len + tlen] = '\n';
|
||||
}
|
||||
}
|
||||
|
||||
void lv_serial_capt_hook(void * userPointer, uint8_t c)
|
||||
{
|
||||
if (c == '\n' || currentWritePos == sizeof(public_buf_m) - 1) { // End of line, probably end of command anyway
|
||||
public_buf_m[currentWritePos] = 0;
|
||||
lv_show_gcode_output(userPointer, public_buf_m);
|
||||
currentWritePos = 0;
|
||||
}
|
||||
else public_buf_m[currentWritePos++] = c;
|
||||
}
|
||||
void lv_eom_hook(void *)
|
||||
{
|
||||
// Message is done, let's remove the hook now
|
||||
MYSERIAL1.setHook();
|
||||
// We are back from the keyboard, so let's redraw ourselves
|
||||
draw_return_ui();
|
||||
}
|
||||
|
||||
void lv_draw_gcode(bool clear) {
|
||||
if (clear) {
|
||||
currentWritePos = 0;
|
||||
public_buf[0] = 0;
|
||||
}
|
||||
scr = lv_screen_create(GCODE_UI, more_menu.gcode);
|
||||
lv_screen_menu_item(scr, more_menu.entergcode, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_GCODE_COMMAND, 1);
|
||||
outL = lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 2, "Result:");
|
||||
outV = lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 3, (const char*)public_buf);
|
||||
|
||||
lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X + 10, PARA_UI_BACL_POS_Y, event_handler, ID_GCODE_RETURN, true);
|
||||
}
|
||||
|
||||
void lv_clear_gcode() {
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
|
||||
#endif
|
||||
lv_obj_del(scr);
|
||||
outV = 0;
|
||||
}
|
||||
|
||||
#endif // HAS_TFT_LVGL_UI
|
33
Marlin/src/lcd/extui/mks_ui/draw_gcode.h
Normal file
33
Marlin/src/lcd/extui/mks_ui/draw_gcode.h
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* C-declarations for C++ */
|
||||
#endif
|
||||
|
||||
void lv_draw_gcode(bool clear = false);
|
||||
void lv_clear_gcode();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C-declarations for C++ */
|
||||
#endif
|
93
Marlin/src/lcd/extui/mks_ui/draw_home.cpp
Normal file
93
Marlin/src/lcd/extui/mks_ui/draw_home.cpp
Normal file
@ -0,0 +1,93 @@
|
||||
/**
|
||||
* 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_TFT_LVGL_UI
|
||||
|
||||
#include "draw_ready_print.h"
|
||||
#include "draw_set.h"
|
||||
#include "draw_ui.h"
|
||||
#include <lv_conf.h>
|
||||
|
||||
#include "../../../gcode/queue.h"
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
extern lv_group_t *g;
|
||||
static lv_obj_t *scr;
|
||||
|
||||
enum {
|
||||
ID_H_ALL = 1,
|
||||
ID_H_X,
|
||||
ID_H_Y,
|
||||
ID_H_Z,
|
||||
ID_H_RETURN,
|
||||
ID_H_OFF_ALL,
|
||||
ID_H_OFF_XY
|
||||
};
|
||||
|
||||
static void event_handler(lv_obj_t *obj, lv_event_t event) {
|
||||
if (event != LV_EVENT_RELEASED) return;
|
||||
switch (obj->mks_obj_id) {
|
||||
case ID_H_ALL:
|
||||
queue.inject_P(G28_STR);
|
||||
break;
|
||||
case ID_H_X:
|
||||
queue.inject_P(PSTR("G28X"));
|
||||
break;
|
||||
case ID_H_Y:
|
||||
queue.inject_P(PSTR("G28Y"));
|
||||
break;
|
||||
case ID_H_Z:
|
||||
queue.inject_P(PSTR("G28Z"));
|
||||
break;
|
||||
case ID_H_OFF_ALL:
|
||||
queue.inject_P(PSTR("M84"));
|
||||
break;
|
||||
case ID_H_OFF_XY:
|
||||
queue.inject_P(PSTR("M84XY"));
|
||||
break;
|
||||
case ID_H_RETURN:
|
||||
clear_cur_ui();
|
||||
draw_return_ui();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void lv_draw_home() {
|
||||
scr = lv_screen_create(ZERO_UI);
|
||||
lv_big_button_create(scr, "F:/bmp_zeroAll.bin", home_menu.home_all, INTERVAL_V, titleHeight, event_handler, ID_H_ALL);
|
||||
lv_big_button_create(scr, "F:/bmp_zeroX.bin", home_menu.home_x, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_H_X);
|
||||
lv_big_button_create(scr, "F:/bmp_zeroY.bin", home_menu.home_y, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_H_Y);
|
||||
lv_big_button_create(scr, "F:/bmp_zeroZ.bin", home_menu.home_z, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_H_Z);
|
||||
lv_big_button_create(scr, "F:/bmp_function1.bin", set_menu.motoroff, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_H_OFF_ALL);
|
||||
lv_big_button_create(scr, "F:/bmp_function1.bin", set_menu.motoroffXY, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_H_OFF_XY);
|
||||
lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_H_RETURN);
|
||||
}
|
||||
|
||||
void lv_clear_home() {
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
|
||||
#endif
|
||||
lv_obj_del(scr);
|
||||
}
|
||||
|
||||
#endif // HAS_TFT_LVGL_UI
|
33
Marlin/src/lcd/extui/mks_ui/draw_home.h
Normal file
33
Marlin/src/lcd/extui/mks_ui/draw_home.h
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* C-declarations for C++ */
|
||||
#endif
|
||||
|
||||
void lv_draw_home();
|
||||
void lv_clear_home();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C-declarations for C++ */
|
||||
#endif
|
104
Marlin/src/lcd/extui/mks_ui/draw_homing_sensitivity_settings.cpp
Normal file
104
Marlin/src/lcd/extui/mks_ui/draw_homing_sensitivity_settings.cpp
Normal file
@ -0,0 +1,104 @@
|
||||
/**
|
||||
* 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/MarlinConfig.h"
|
||||
|
||||
#if HAS_TFT_LVGL_UI && USE_SENSORLESS
|
||||
|
||||
#include "draw_ui.h"
|
||||
#include <lv_conf.h>
|
||||
|
||||
#include "../../../module/planner.h"
|
||||
#include "../../../module/probe.h"
|
||||
#include "../../../module/stepper/indirection.h"
|
||||
#include "../../../feature/tmc_util.h"
|
||||
|
||||
extern lv_group_t *g;
|
||||
static lv_obj_t *scr;
|
||||
|
||||
enum {
|
||||
ID_SENSITIVITY_RETURN = 1,
|
||||
ID_SENSITIVITY_X,
|
||||
ID_SENSITIVITY_Y,
|
||||
ID_SENSITIVITY_Z,
|
||||
ID_SENSITIVITY_Z2
|
||||
};
|
||||
|
||||
static void event_handler(lv_obj_t *obj, lv_event_t event) {
|
||||
if (event != LV_EVENT_RELEASED) return;
|
||||
switch (obj->mks_obj_id) {
|
||||
case ID_SENSITIVITY_RETURN:
|
||||
lv_clear_homing_sensitivity_settings();
|
||||
draw_return_ui();
|
||||
break;
|
||||
case ID_SENSITIVITY_X:
|
||||
value = x_sensitivity;
|
||||
lv_clear_homing_sensitivity_settings();
|
||||
lv_draw_number_key();
|
||||
break;
|
||||
case ID_SENSITIVITY_Y:
|
||||
value = y_sensitivity;
|
||||
lv_clear_homing_sensitivity_settings();
|
||||
lv_draw_number_key();
|
||||
break;
|
||||
case ID_SENSITIVITY_Z:
|
||||
value = z_sensitivity;
|
||||
lv_clear_homing_sensitivity_settings();
|
||||
lv_draw_number_key();
|
||||
break;
|
||||
#if Z2_SENSORLESS
|
||||
case ID_SENSITIVITY_Z2:
|
||||
value = z2_sensitivity;
|
||||
lv_clear_homing_sensitivity_settings();
|
||||
lv_draw_number_key();
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void lv_draw_homing_sensitivity_settings() {
|
||||
scr = lv_screen_create(HOMING_SENSITIVITY_UI, machine_menu.HomingSensitivityConfTitle);
|
||||
|
||||
itoa(TERN(X_SENSORLESS, stepperX.homing_threshold(), 0), public_buf_l, 10);
|
||||
lv_screen_menu_item_1_edit(scr, machine_menu.X_Sensitivity, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_SENSITIVITY_X, 0, public_buf_l);
|
||||
|
||||
itoa(TERN(Y_SENSORLESS, stepperY.homing_threshold(), 0), public_buf_l, 10);
|
||||
lv_screen_menu_item_1_edit(scr, machine_menu.Y_Sensitivity, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_SENSITIVITY_Y, 1, public_buf_l);
|
||||
|
||||
itoa(TERN(Z_SENSORLESS, stepperZ.homing_threshold(), 0), public_buf_l, 10);
|
||||
lv_screen_menu_item_1_edit(scr, machine_menu.Z_Sensitivity, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_SENSITIVITY_Z, 2, public_buf_l);
|
||||
|
||||
#if Z2_SENSORLESS
|
||||
itoa(TERN(Z2_SENSORLESS, stepperZ2.homing_threshold(), 0), public_buf_l, 10);
|
||||
lv_screen_menu_item_1_edit(scr, machine_menu.Z2_Sensitivity, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_SENSITIVITY_Z2, 3, public_buf_l);
|
||||
#endif
|
||||
|
||||
lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_SENSITIVITY_RETURN, true);
|
||||
}
|
||||
|
||||
void lv_clear_homing_sensitivity_settings() {
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
|
||||
#endif
|
||||
lv_obj_del(scr);
|
||||
}
|
||||
|
||||
#endif // HAS_TFT_LVGL_UI && USE_SENSORLESS
|
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* C-declarations for C++ */
|
||||
#endif
|
||||
|
||||
void lv_draw_homing_sensitivity_settings();
|
||||
void lv_clear_homing_sensitivity_settings();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C-declarations for C++ */
|
||||
#endif
|
98
Marlin/src/lcd/extui/mks_ui/draw_jerk_settings.cpp
Normal file
98
Marlin/src/lcd/extui/mks_ui/draw_jerk_settings.cpp
Normal file
@ -0,0 +1,98 @@
|
||||
/**
|
||||
* 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 BOTH(HAS_TFT_LVGL_UI, HAS_CLASSIC_JERK)
|
||||
|
||||
#include "draw_ui.h"
|
||||
#include <lv_conf.h>
|
||||
|
||||
#include "../../../module/planner.h"
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
extern lv_group_t *g;
|
||||
static lv_obj_t *scr;
|
||||
|
||||
enum {
|
||||
ID_JERK_RETURN = 1,
|
||||
ID_JERK_X,
|
||||
ID_JERK_Y,
|
||||
ID_JERK_Z,
|
||||
ID_JERK_E
|
||||
};
|
||||
|
||||
static void event_handler(lv_obj_t *obj, lv_event_t event) {
|
||||
if (event != LV_EVENT_RELEASED) return;
|
||||
switch (obj->mks_obj_id) {
|
||||
case ID_JERK_RETURN:
|
||||
lv_clear_jerk_settings();
|
||||
draw_return_ui();
|
||||
break;
|
||||
case ID_JERK_X:
|
||||
value = XJerk;
|
||||
lv_clear_jerk_settings();
|
||||
lv_draw_number_key();
|
||||
break;
|
||||
case ID_JERK_Y:
|
||||
value = YJerk;
|
||||
lv_clear_jerk_settings();
|
||||
lv_draw_number_key();
|
||||
break;
|
||||
case ID_JERK_Z:
|
||||
value = ZJerk;
|
||||
lv_clear_jerk_settings();
|
||||
lv_draw_number_key();
|
||||
break;
|
||||
case ID_JERK_E:
|
||||
value = EJerk;
|
||||
lv_clear_jerk_settings();
|
||||
lv_draw_number_key();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void lv_draw_jerk_settings() {
|
||||
scr = lv_screen_create(JERK_UI, machine_menu.JerkConfTitle);
|
||||
|
||||
dtostrf(planner.max_jerk[X_AXIS], 1, 1, public_buf_l);
|
||||
lv_screen_menu_item_1_edit(scr, machine_menu.X_Jerk, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_JERK_X, 0, public_buf_l);
|
||||
|
||||
dtostrf(planner.max_jerk[Y_AXIS], 1, 1, public_buf_l);
|
||||
lv_screen_menu_item_1_edit(scr, machine_menu.Y_Jerk, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_JERK_Y, 1, public_buf_l);
|
||||
|
||||
dtostrf(planner.max_jerk[Z_AXIS], 1, 1, public_buf_l);
|
||||
lv_screen_menu_item_1_edit(scr, machine_menu.Z_Jerk, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_JERK_Z, 2, public_buf_l);
|
||||
|
||||
dtostrf(planner.max_jerk[E_AXIS], 1, 1, public_buf_l);
|
||||
lv_screen_menu_item_1_edit(scr, machine_menu.E_Jerk, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_JERK_E, 3, public_buf_l);
|
||||
|
||||
lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_JERK_RETURN, true);
|
||||
}
|
||||
|
||||
void lv_clear_jerk_settings() {
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
|
||||
#endif
|
||||
lv_obj_del(scr);
|
||||
}
|
||||
|
||||
#endif // HAS_TFT_LVGL_UI && HAS_CLASSIC_JERK
|
33
Marlin/src/lcd/extui/mks_ui/draw_jerk_settings.h
Normal file
33
Marlin/src/lcd/extui/mks_ui/draw_jerk_settings.h
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* C-declarations for C++ */
|
||||
#endif
|
||||
|
||||
void lv_draw_jerk_settings();
|
||||
void lv_clear_jerk_settings();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C-declarations for C++ */
|
||||
#endif
|
275
Marlin/src/lcd/extui/mks_ui/draw_keyboard.cpp
Normal file
275
Marlin/src/lcd/extui/mks_ui/draw_keyboard.cpp
Normal file
@ -0,0 +1,275 @@
|
||||
/**
|
||||
* 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_TFT_LVGL_UI
|
||||
|
||||
#include "draw_ui.h"
|
||||
#include <lv_conf.h>
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
#include "../../../gcode/queue.h"
|
||||
|
||||
extern lv_group_t *g;
|
||||
static lv_obj_t *scr;
|
||||
|
||||
#define LV_KB_CTRL_BTN_FLAGS (LV_BTNM_CTRL_NO_REPEAT | LV_BTNM_CTRL_CLICK_TRIG)
|
||||
|
||||
static const char * kb_map_lc[] = {"1#", "q", "w", "e", "r", "t", "y", "u", "i", "o", "p", LV_SYMBOL_BACKSPACE, "\n",
|
||||
"ABC", "a", "s", "d", "f", "g", "h", "j", "k", "l", LV_SYMBOL_NEW_LINE, "\n",
|
||||
"_", "-", "z", "x", "c", "v", "b", "n", "m", ".", ",", ":", "\n",
|
||||
LV_SYMBOL_CLOSE, LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, LV_SYMBOL_OK, ""};
|
||||
|
||||
static const lv_btnm_ctrl_t kb_ctrl_lc_map[] = {
|
||||
LV_KB_CTRL_BTN_FLAGS | 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 7,
|
||||
LV_KB_CTRL_BTN_FLAGS | 6, 3, 3, 3, 3, 3, 3, 3, 3, 3, 7,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
LV_KB_CTRL_BTN_FLAGS | 2, 2, 6, 2, LV_KB_CTRL_BTN_FLAGS | 2};
|
||||
|
||||
static const char * kb_map_uc[] = {"1#", "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", LV_SYMBOL_BACKSPACE, "\n",
|
||||
"abc", "A", "S", "D", "F", "G", "H", "J", "K", "L", LV_SYMBOL_NEW_LINE, "\n",
|
||||
"_", "-", "Z", "X", "C", "V", "B", "N", "M", ".", ",", ":", "\n",
|
||||
LV_SYMBOL_CLOSE, LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, LV_SYMBOL_OK, ""};
|
||||
|
||||
static const lv_btnm_ctrl_t kb_ctrl_uc_map[] = {
|
||||
LV_KB_CTRL_BTN_FLAGS | 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 7,
|
||||
LV_KB_CTRL_BTN_FLAGS | 6, 3, 3, 3, 3, 3, 3, 3, 3, 3, 7,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
LV_KB_CTRL_BTN_FLAGS | 2, 2, 6, 2, LV_KB_CTRL_BTN_FLAGS | 2};
|
||||
|
||||
static const char * kb_map_spec[] = {"0", "1", "2", "3", "4" ,"5", "6", "7", "8", "9", ".", LV_SYMBOL_BACKSPACE, "\n",
|
||||
"abc", "+", "-", "/", "*", "=", "%", "!", "?", "#", "<", ">", "\n",
|
||||
"\\", "@", "$", "(", ")", "{", "}", "[", "]", ";", "\"", "'", "\n",
|
||||
LV_SYMBOL_CLOSE, LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, LV_SYMBOL_OK, ""};
|
||||
|
||||
static const lv_btnm_ctrl_t kb_ctrl_spec_map[] = {
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, LV_KB_CTRL_BTN_FLAGS | 2,
|
||||
LV_KB_CTRL_BTN_FLAGS | 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
LV_KB_CTRL_BTN_FLAGS | 2, 2, 6, 2, LV_KB_CTRL_BTN_FLAGS | 2};
|
||||
|
||||
static const lv_btnm_ctrl_t kb_ctrl_num_map[] = {
|
||||
1, 1, 1, LV_KB_CTRL_BTN_FLAGS | 2,
|
||||
1, 1, 1, LV_KB_CTRL_BTN_FLAGS | 2,
|
||||
1, 1, 1, 2,
|
||||
1, 1, 1, 1, 1};
|
||||
|
||||
static void lv_kb_event_cb(lv_obj_t *kb, lv_event_t event) {
|
||||
if (event != LV_EVENT_VALUE_CHANGED) return;
|
||||
|
||||
lv_kb_ext_t * ext = (lv_kb_ext_t * )lv_obj_get_ext_attr(kb);
|
||||
const uint16_t btn_id = lv_btnm_get_active_btn(kb);
|
||||
if (btn_id == LV_BTNM_BTN_NONE) return;
|
||||
if (lv_btnm_get_btn_ctrl(kb, btn_id, LV_BTNM_CTRL_HIDDEN | LV_BTNM_CTRL_INACTIVE)) return;
|
||||
if (lv_btnm_get_btn_ctrl(kb, btn_id, LV_BTNM_CTRL_NO_REPEAT) && event == LV_EVENT_LONG_PRESSED_REPEAT) return;
|
||||
|
||||
const char * txt = lv_btnm_get_active_btn_text(kb);
|
||||
if (!txt) return;
|
||||
|
||||
// Do the corresponding action according to the text of the button
|
||||
if (strcmp(txt, "abc") == 0) {
|
||||
lv_btnm_set_map(kb, kb_map_lc);
|
||||
lv_btnm_set_ctrl_map(kb, kb_ctrl_lc_map);
|
||||
return;
|
||||
}
|
||||
else if (strcmp(txt, "ABC") == 0) {
|
||||
lv_btnm_set_map(kb, kb_map_uc);
|
||||
lv_btnm_set_ctrl_map(kb, kb_ctrl_uc_map);
|
||||
return;
|
||||
}
|
||||
else if (strcmp(txt, "1#") == 0) {
|
||||
lv_btnm_set_map(kb, kb_map_spec);
|
||||
lv_btnm_set_ctrl_map(kb, kb_ctrl_spec_map);
|
||||
return;
|
||||
}
|
||||
else if (strcmp(txt, LV_SYMBOL_CLOSE) == 0) {
|
||||
if (kb->event_cb != lv_kb_def_event_cb) {
|
||||
lv_clear_keyboard();
|
||||
draw_return_ui();
|
||||
}
|
||||
else {
|
||||
lv_kb_set_ta(kb, nullptr); // De-assign the text area to hide its cursor if needed
|
||||
lv_obj_del(kb);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if (strcmp(txt, LV_SYMBOL_OK) == 0) {
|
||||
if (kb->event_cb != lv_kb_def_event_cb) {
|
||||
const char * ret_ta_txt = lv_ta_get_text(ext->ta);
|
||||
switch (keyboard_value) {
|
||||
#if ENABLED(MKS_WIFI_MODULE)
|
||||
case wifiName:
|
||||
memcpy(uiCfg.wifi_name,ret_ta_txt,sizeof(uiCfg.wifi_name));
|
||||
lv_clear_keyboard();
|
||||
draw_return_ui();
|
||||
break;
|
||||
case wifiPassWord:
|
||||
memcpy(uiCfg.wifi_key,ret_ta_txt,sizeof(uiCfg.wifi_name));
|
||||
lv_clear_keyboard();
|
||||
draw_return_ui();
|
||||
break;
|
||||
case wifiConfig:
|
||||
ZERO(uiCfg.wifi_name);
|
||||
memcpy((void *)uiCfg.wifi_name, wifi_list.wifiName[wifi_list.nameIndex], 32);
|
||||
|
||||
ZERO(uiCfg.wifi_key);
|
||||
memcpy((void *)uiCfg.wifi_key, ret_ta_txt, sizeof(uiCfg.wifi_key));
|
||||
|
||||
gCfgItems.wifi_mode_sel = STA_MODEL;
|
||||
|
||||
package_to_wifi(WIFI_PARA_SET, nullptr, 0);
|
||||
|
||||
public_buf_l[0] = 0xA5;
|
||||
public_buf_l[1] = 0x09;
|
||||
public_buf_l[2] = 0x01;
|
||||
public_buf_l[3] = 0x00;
|
||||
public_buf_l[4] = 0x01;
|
||||
public_buf_l[5] = 0xFC;
|
||||
public_buf_l[6] = 0x00;
|
||||
raw_send_to_wifi((uint8_t*)public_buf_l, 6);
|
||||
|
||||
last_disp_state = KEYBOARD_UI;
|
||||
lv_clear_keyboard();
|
||||
wifi_tips_type = TIPS_TYPE_JOINING;
|
||||
lv_draw_wifi_tips();
|
||||
break;
|
||||
#endif // MKS_WIFI_MODULE
|
||||
case autoLevelGcodeCommand:
|
||||
uint8_t buf[100];
|
||||
strncpy((char *)buf,ret_ta_txt,sizeof(buf));
|
||||
update_gcode_command(AUTO_LEVELING_COMMAND_ADDR,buf);
|
||||
lv_clear_keyboard();
|
||||
draw_return_ui();
|
||||
break;
|
||||
case GCodeCommand:
|
||||
if (!queue.ring_buffer.full(3)) {
|
||||
// Hook anything that goes to the serial port
|
||||
MYSERIAL1.setHook(lv_serial_capt_hook, lv_eom_hook, 0);
|
||||
queue.enqueue_one_now(ret_ta_txt);
|
||||
}
|
||||
lv_clear_keyboard();
|
||||
// draw_return_ui is called in the end of message hook
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
else
|
||||
lv_kb_set_ta(kb, nullptr); // De-assign the text area to hide it cursor if needed
|
||||
return;
|
||||
}
|
||||
|
||||
// Add the characters to the text area if set
|
||||
if (!ext->ta) return;
|
||||
|
||||
if (strcmp(txt, "Enter") == 0 || strcmp(txt, LV_SYMBOL_NEW_LINE) == 0)
|
||||
lv_ta_add_char(ext->ta, '\n');
|
||||
else if (strcmp(txt, LV_SYMBOL_LEFT) == 0)
|
||||
lv_ta_cursor_left(ext->ta);
|
||||
else if (strcmp(txt, LV_SYMBOL_RIGHT) == 0)
|
||||
lv_ta_cursor_right(ext->ta);
|
||||
else if (strcmp(txt, LV_SYMBOL_BACKSPACE) == 0)
|
||||
lv_ta_del_char(ext->ta);
|
||||
else if (strcmp(txt, "+/-") == 0) {
|
||||
uint16_t cur = lv_ta_get_cursor_pos(ext->ta);
|
||||
const char * ta_txt = lv_ta_get_text(ext->ta);
|
||||
if (ta_txt[0] == '-') {
|
||||
lv_ta_set_cursor_pos(ext->ta, 1);
|
||||
lv_ta_del_char(ext->ta);
|
||||
lv_ta_add_char(ext->ta, '+');
|
||||
lv_ta_set_cursor_pos(ext->ta, cur);
|
||||
}
|
||||
else if (ta_txt[0] == '+') {
|
||||
lv_ta_set_cursor_pos(ext->ta, 1);
|
||||
lv_ta_del_char(ext->ta);
|
||||
lv_ta_add_char(ext->ta, '-');
|
||||
lv_ta_set_cursor_pos(ext->ta, cur);
|
||||
}
|
||||
else {
|
||||
lv_ta_set_cursor_pos(ext->ta, 0);
|
||||
lv_ta_add_char(ext->ta, '-');
|
||||
lv_ta_set_cursor_pos(ext->ta, cur + 1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
lv_ta_add_text(ext->ta, txt);
|
||||
}
|
||||
}
|
||||
|
||||
void lv_draw_keyboard() {
|
||||
scr = lv_screen_create(KEYBOARD_UI, "");
|
||||
|
||||
// Create styles for the keyboard
|
||||
static lv_style_t rel_style, pr_style;
|
||||
|
||||
lv_style_copy(&rel_style, &lv_style_btn_rel);
|
||||
rel_style.body.radius = 0;
|
||||
rel_style.body.border.width = 1;
|
||||
rel_style.body.main_color = lv_color_make(0xA9, 0x62, 0x1D);
|
||||
rel_style.body.grad_color = lv_color_make(0xA7, 0x59, 0x0E);
|
||||
|
||||
lv_style_copy(&pr_style, &lv_style_btn_pr);
|
||||
pr_style.body.radius = 0;
|
||||
pr_style.body.border.width = 1;
|
||||
pr_style.body.main_color = lv_color_make(0x72, 0x42, 0x15);
|
||||
pr_style.body.grad_color = lv_color_make(0x6A, 0x3A, 0x0C);
|
||||
|
||||
// Create a keyboard and apply the styles
|
||||
lv_obj_t *kb = lv_kb_create(scr, nullptr);
|
||||
lv_obj_set_event_cb(kb, lv_kb_event_cb);
|
||||
lv_kb_set_cursor_manage(kb, true);
|
||||
lv_kb_set_style(kb, LV_KB_STYLE_BG, &lv_style_transp_tight);
|
||||
lv_kb_set_style(kb, LV_KB_STYLE_BTN_REL, &rel_style);
|
||||
lv_kb_set_style(kb, LV_KB_STYLE_BTN_PR, &pr_style);
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) {
|
||||
}
|
||||
#endif
|
||||
|
||||
// Create a text area. The keyboard will write here
|
||||
lv_obj_t *ta = lv_ta_create(scr, nullptr);
|
||||
lv_obj_align(ta, nullptr, LV_ALIGN_IN_TOP_MID, 0, 10);
|
||||
switch (keyboard_value) {
|
||||
case autoLevelGcodeCommand:
|
||||
get_gcode_command(AUTO_LEVELING_COMMAND_ADDR,(uint8_t *)public_buf_m);
|
||||
public_buf_m[sizeof(public_buf_m)-1] = 0;
|
||||
lv_ta_set_text(ta, public_buf_m);
|
||||
break;
|
||||
case GCodeCommand:
|
||||
// Start with uppercase by default
|
||||
lv_btnm_set_map(kb, kb_map_uc);
|
||||
lv_btnm_set_ctrl_map(kb, kb_ctrl_uc_map);
|
||||
// Fallthrough
|
||||
default:
|
||||
lv_ta_set_text(ta, "");
|
||||
}
|
||||
|
||||
// Assign the text area to the keyboard
|
||||
lv_kb_set_ta(kb, ta);
|
||||
}
|
||||
|
||||
void lv_clear_keyboard() {
|
||||
lv_obj_del(scr);
|
||||
}
|
||||
|
||||
|
||||
#endif // HAS_TFT_LVGL_UI
|
33
Marlin/src/lcd/extui/mks_ui/draw_keyboard.h
Normal file
33
Marlin/src/lcd/extui/mks_ui/draw_keyboard.h
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* C-declarations for C++ */
|
||||
#endif
|
||||
|
||||
void lv_draw_keyboard();
|
||||
void lv_clear_keyboard();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C-declarations for C++ */
|
||||
#endif
|
208
Marlin/src/lcd/extui/mks_ui/draw_language.cpp
Normal file
208
Marlin/src/lcd/extui/mks_ui/draw_language.cpp
Normal file
@ -0,0 +1,208 @@
|
||||
/**
|
||||
* 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_TFT_LVGL_UI
|
||||
|
||||
#include "draw_ui.h"
|
||||
#include <lv_conf.h>
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
#include <string.h>
|
||||
|
||||
enum {
|
||||
ID_CN = 1,
|
||||
ID_T_CN,
|
||||
ID_EN,
|
||||
ID_RU,
|
||||
ID_ES,
|
||||
ID_FR,
|
||||
ID_IT,
|
||||
ID_L_RETURN
|
||||
};
|
||||
|
||||
#define SELECTED 1
|
||||
#define UNSELECTED 0
|
||||
|
||||
static void disp_language(uint8_t language, uint8_t state);
|
||||
|
||||
extern lv_group_t *g;
|
||||
static lv_obj_t *scr;
|
||||
static lv_obj_t *buttonCN, *buttonT_CN, *buttonEN, *buttonRU;
|
||||
static lv_obj_t *buttonES, *buttonFR, *buttonIT;
|
||||
|
||||
static void event_handler(lv_obj_t *obj, lv_event_t event) {
|
||||
if (event != LV_EVENT_RELEASED) return;
|
||||
switch (obj->mks_obj_id) {
|
||||
case ID_CN:
|
||||
disp_language(gCfgItems.language, UNSELECTED);
|
||||
lv_imgbtn_set_src_both(buttonCN, "F:/bmp_simplified_cn_sel.bin");
|
||||
lv_obj_refresh_ext_draw_pad(buttonCN);
|
||||
gCfgItems.language = LANG_SIMPLE_CHINESE;
|
||||
update_spi_flash();
|
||||
disp_language_init();
|
||||
break;
|
||||
case ID_T_CN:
|
||||
disp_language(gCfgItems.language, UNSELECTED);
|
||||
lv_imgbtn_set_src_both(buttonT_CN, "F:/bmp_traditional_cn_sel.bin");
|
||||
lv_obj_refresh_ext_draw_pad(buttonT_CN);
|
||||
gCfgItems.language = LANG_COMPLEX_CHINESE;
|
||||
update_spi_flash();
|
||||
disp_language_init();
|
||||
break;
|
||||
case ID_EN:
|
||||
disp_language(gCfgItems.language, UNSELECTED);
|
||||
lv_imgbtn_set_src_both(buttonEN, "F:/bmp_english_sel.bin");
|
||||
lv_obj_refresh_ext_draw_pad(buttonEN);
|
||||
gCfgItems.language = LANG_ENGLISH;
|
||||
update_spi_flash();
|
||||
disp_language_init();
|
||||
break;
|
||||
case ID_RU:
|
||||
disp_language(gCfgItems.language, UNSELECTED);
|
||||
lv_imgbtn_set_src_both(buttonRU, "F:/bmp_russian_sel.bin");
|
||||
lv_obj_refresh_ext_draw_pad(buttonRU);
|
||||
gCfgItems.language = LANG_RUSSIAN;
|
||||
update_spi_flash();
|
||||
disp_language_init();
|
||||
break;
|
||||
case ID_ES:
|
||||
disp_language(gCfgItems.language, UNSELECTED);
|
||||
lv_imgbtn_set_src_both(buttonES, "F:/bmp_spanish_sel.bin");
|
||||
lv_obj_refresh_ext_draw_pad(buttonES);
|
||||
gCfgItems.language = LANG_SPANISH;
|
||||
update_spi_flash();
|
||||
disp_language_init();
|
||||
break;
|
||||
case ID_FR:
|
||||
disp_language(gCfgItems.language, UNSELECTED);
|
||||
lv_imgbtn_set_src_both(buttonFR, "F:/bmp_french_sel.bin");
|
||||
lv_obj_refresh_ext_draw_pad(buttonFR);
|
||||
gCfgItems.language = LANG_FRENCH;
|
||||
update_spi_flash();
|
||||
disp_language_init();
|
||||
break;
|
||||
case ID_IT:
|
||||
disp_language(gCfgItems.language, UNSELECTED);
|
||||
lv_imgbtn_set_src_both(buttonIT, "F:/bmp_italy_sel.bin");
|
||||
lv_obj_refresh_ext_draw_pad(buttonIT);
|
||||
gCfgItems.language = LANG_ITALY;
|
||||
update_spi_flash();
|
||||
disp_language_init();
|
||||
break;
|
||||
case ID_L_RETURN:
|
||||
buttonCN = nullptr;
|
||||
buttonT_CN = nullptr;
|
||||
buttonEN = nullptr;
|
||||
buttonRU = nullptr;
|
||||
buttonES = nullptr;
|
||||
buttonFR = nullptr;
|
||||
buttonFR = nullptr;
|
||||
buttonIT = nullptr;
|
||||
lv_clear_language();
|
||||
lv_draw_set();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void disp_language(uint8_t language, uint8_t state) {
|
||||
uint16_t id;
|
||||
lv_obj_t *obj;
|
||||
|
||||
public_buf_l[0] = '\0';
|
||||
|
||||
switch (language) {
|
||||
case LANG_SIMPLE_CHINESE:
|
||||
id = ID_CN;
|
||||
strcpy_P(public_buf_l, PSTR("F:/bmp_simplified_cn"));
|
||||
obj = buttonCN;
|
||||
break;
|
||||
case LANG_COMPLEX_CHINESE:
|
||||
id = ID_T_CN;
|
||||
strcpy_P(public_buf_l, PSTR("F:/bmp_traditional_cn"));
|
||||
obj = buttonT_CN;
|
||||
break;
|
||||
case LANG_ENGLISH:
|
||||
id = ID_EN;
|
||||
strcpy_P(public_buf_l, PSTR("F:/bmp_english"));
|
||||
obj = buttonEN;
|
||||
break;
|
||||
case LANG_RUSSIAN:
|
||||
id = ID_RU;
|
||||
strcpy_P(public_buf_l, PSTR("F:/bmp_russian"));
|
||||
obj = buttonRU;
|
||||
break;
|
||||
case LANG_SPANISH:
|
||||
id = ID_ES;
|
||||
strcpy_P(public_buf_l, PSTR("F:/bmp_spanish"));
|
||||
obj = buttonES;
|
||||
break;
|
||||
case LANG_FRENCH:
|
||||
id = ID_FR;
|
||||
strcpy_P(public_buf_l, PSTR("F:/bmp_french"));
|
||||
obj = buttonFR;
|
||||
break;
|
||||
case LANG_ITALY:
|
||||
id = ID_IT;
|
||||
strcpy_P(public_buf_l, PSTR("F:/bmp_italy"));
|
||||
obj = buttonIT;
|
||||
break;
|
||||
default:
|
||||
id = ID_CN;
|
||||
strcpy_P(public_buf_l, PSTR("F:/bmp_simplified_cn"));
|
||||
obj = buttonCN;
|
||||
break;
|
||||
}
|
||||
|
||||
if (state == SELECTED) strcat_P(public_buf_l, PSTR("_sel"));
|
||||
|
||||
strcat_P(public_buf_l, PSTR(".bin"));
|
||||
|
||||
lv_obj_set_event_cb_mks(obj, event_handler, id, "", 0);
|
||||
lv_imgbtn_set_src_both(obj, public_buf_l);
|
||||
|
||||
if (state == UNSELECTED) lv_obj_refresh_ext_draw_pad(obj);
|
||||
}
|
||||
|
||||
void lv_draw_language() {
|
||||
scr = lv_screen_create(LANGUAGE_UI);
|
||||
// Create image buttons
|
||||
buttonCN = lv_big_button_create(scr, "F:/bmp_simplified_cn.bin", language_menu.chinese_s, INTERVAL_V, titleHeight, event_handler, ID_CN);
|
||||
lv_obj_clear_protect(buttonCN, LV_PROTECT_FOLLOW);
|
||||
buttonT_CN = lv_big_button_create(scr, "F:/bmp_traditional_cn.bin", language_menu.chinese_t, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_T_CN);
|
||||
buttonEN = lv_big_button_create(scr, "F:/bmp_english.bin", language_menu.english, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_EN);
|
||||
buttonRU = lv_big_button_create(scr, "F:/bmp_russian.bin", language_menu.russian, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_RU);
|
||||
buttonES = lv_big_button_create(scr, "F:/bmp_spanish.bin", language_menu.spanish, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_ES);
|
||||
buttonFR = lv_big_button_create(scr, "F:/bmp_french.bin", language_menu.french, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_FR);
|
||||
buttonIT = lv_big_button_create(scr, "F:/bmp_italy.bin", language_menu.italy, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_IT);
|
||||
lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_L_RETURN);
|
||||
disp_language(gCfgItems.language, SELECTED);
|
||||
}
|
||||
|
||||
void lv_clear_language() {
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
|
||||
#endif
|
||||
lv_obj_del(scr);
|
||||
}
|
||||
|
||||
#endif // HAS_TFT_LVGL_UI
|
33
Marlin/src/lcd/extui/mks_ui/draw_language.h
Normal file
33
Marlin/src/lcd/extui/mks_ui/draw_language.h
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* C-declarations for C++ */
|
||||
#endif
|
||||
|
||||
void lv_draw_language();
|
||||
void lv_clear_language();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C-declarations for C++ */
|
||||
#endif
|
80
Marlin/src/lcd/extui/mks_ui/draw_level_settings.cpp
Normal file
80
Marlin/src/lcd/extui/mks_ui/draw_level_settings.cpp
Normal file
@ -0,0 +1,80 @@
|
||||
/**
|
||||
* 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_TFT_LVGL_UI
|
||||
|
||||
#include "draw_ui.h"
|
||||
#include <lv_conf.h>
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
extern lv_group_t *g;
|
||||
static lv_obj_t *scr;
|
||||
|
||||
enum {
|
||||
ID_LEVEL_RETURN = 1,
|
||||
ID_LEVEL_POSITION,
|
||||
ID_LEVEL_COMMAND,
|
||||
ID_LEVEL_ZOFFSET
|
||||
};
|
||||
|
||||
static void event_handler(lv_obj_t *obj, lv_event_t event) {
|
||||
if (event != LV_EVENT_RELEASED) return;
|
||||
lv_clear_level_settings();
|
||||
switch (obj->mks_obj_id) {
|
||||
case ID_LEVEL_RETURN:
|
||||
draw_return_ui();
|
||||
break;
|
||||
case ID_LEVEL_POSITION:
|
||||
lv_draw_tramming_pos_settings();
|
||||
break;
|
||||
case ID_LEVEL_COMMAND:
|
||||
keyboard_value = autoLevelGcodeCommand;
|
||||
lv_draw_keyboard();
|
||||
break;
|
||||
#if HAS_BED_PROBE
|
||||
case ID_LEVEL_ZOFFSET:
|
||||
lv_draw_auto_level_offset_settings();
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void lv_draw_level_settings() {
|
||||
scr = lv_screen_create(LEVELING_PARA_UI, machine_menu.LevelingParaConfTitle);
|
||||
lv_screen_menu_item(scr, machine_menu.TrammingPosConf, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_LEVEL_POSITION, 0);
|
||||
lv_screen_menu_item(scr, machine_menu.LevelingAutoCommandConf, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_LEVEL_COMMAND, 1);
|
||||
#if HAS_BED_PROBE
|
||||
lv_screen_menu_item(scr, machine_menu.LevelingAutoZoffsetConf, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_LEVEL_ZOFFSET, 2);
|
||||
#endif
|
||||
lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X + 10, PARA_UI_BACL_POS_Y, event_handler, ID_LEVEL_RETURN, true);
|
||||
}
|
||||
|
||||
void lv_clear_level_settings() {
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
|
||||
#endif
|
||||
lv_obj_del(scr);
|
||||
}
|
||||
|
||||
#endif // HAS_TFT_LVGL_UI
|
33
Marlin/src/lcd/extui/mks_ui/draw_level_settings.h
Normal file
33
Marlin/src/lcd/extui/mks_ui/draw_level_settings.h
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* C-declarations for C++ */
|
||||
#endif
|
||||
|
||||
void lv_draw_level_settings();
|
||||
void lv_clear_level_settings();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C-declarations for C++ */
|
||||
#endif
|
84
Marlin/src/lcd/extui/mks_ui/draw_machine_para.cpp
Normal file
84
Marlin/src/lcd/extui/mks_ui/draw_machine_para.cpp
Normal file
@ -0,0 +1,84 @@
|
||||
/**
|
||||
* 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_TFT_LVGL_UI
|
||||
|
||||
#include "draw_ui.h"
|
||||
#include <lv_conf.h>
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
extern lv_group_t *g;
|
||||
static lv_obj_t *scr;
|
||||
|
||||
enum {
|
||||
ID_PARA_RETURN = 1,
|
||||
ID_PARA_MACHINE,
|
||||
ID_PARA_MOTOR,
|
||||
ID_PARA_LEVEL,
|
||||
ID_PARA_ADVANCE
|
||||
};
|
||||
|
||||
static void event_handler(lv_obj_t *obj, lv_event_t event) {
|
||||
if (event != LV_EVENT_RELEASED) return;
|
||||
switch (obj->mks_obj_id) {
|
||||
case ID_PARA_RETURN:
|
||||
lv_clear_machine_para();
|
||||
draw_return_ui();
|
||||
break;
|
||||
case ID_PARA_MACHINE:
|
||||
lv_clear_machine_para();
|
||||
lv_draw_machine_settings();
|
||||
break;
|
||||
case ID_PARA_MOTOR:
|
||||
lv_clear_machine_para();
|
||||
lv_draw_motor_settings();
|
||||
break;
|
||||
case ID_PARA_LEVEL:
|
||||
lv_clear_machine_para();
|
||||
lv_draw_level_settings();
|
||||
break;
|
||||
case ID_PARA_ADVANCE:
|
||||
lv_clear_machine_para();
|
||||
lv_draw_advance_settings();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void lv_draw_machine_para() {
|
||||
scr = lv_screen_create(MACHINE_PARA_UI);
|
||||
lv_screen_menu_item(scr, MachinePara_menu.MachineSetting, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_PARA_MACHINE, 0);
|
||||
lv_screen_menu_item(scr, MachinePara_menu.MotorSetting, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_PARA_MOTOR, 1);
|
||||
lv_screen_menu_item(scr, MachinePara_menu.leveling, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_PARA_LEVEL, 2);
|
||||
lv_screen_menu_item(scr, MachinePara_menu.AdvanceSetting, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_PARA_ADVANCE, 3);
|
||||
lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X + 10, PARA_UI_BACL_POS_Y, event_handler, ID_PARA_RETURN, true);
|
||||
}
|
||||
|
||||
void lv_clear_machine_para() {
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
|
||||
#endif
|
||||
lv_obj_del(scr);
|
||||
}
|
||||
|
||||
#endif // HAS_TFT_LVGL_UI
|
33
Marlin/src/lcd/extui/mks_ui/draw_machine_para.h
Normal file
33
Marlin/src/lcd/extui/mks_ui/draw_machine_para.h
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* C-declarations for C++ */
|
||||
#endif
|
||||
|
||||
void lv_draw_machine_para();
|
||||
void lv_clear_machine_para();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C-declarations for C++ */
|
||||
#endif
|
82
Marlin/src/lcd/extui/mks_ui/draw_machine_settings.cpp
Normal file
82
Marlin/src/lcd/extui/mks_ui/draw_machine_settings.cpp
Normal file
@ -0,0 +1,82 @@
|
||||
/**
|
||||
* 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_TFT_LVGL_UI
|
||||
|
||||
#include "draw_ui.h"
|
||||
#include <lv_conf.h>
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
extern lv_group_t *g;
|
||||
static lv_obj_t *scr;
|
||||
|
||||
enum {
|
||||
ID_MACHINE_RETURN = 1,
|
||||
ID_MACHINE_ACCELERATION,
|
||||
ID_MACHINE_FEEDRATE,
|
||||
ID_MACHINE_JERK
|
||||
};
|
||||
|
||||
static void event_handler(lv_obj_t *obj, lv_event_t event) {
|
||||
if (event != LV_EVENT_RELEASED) return;
|
||||
switch (obj->mks_obj_id) {
|
||||
case ID_MACHINE_RETURN:
|
||||
lv_clear_machine_settings();
|
||||
draw_return_ui();
|
||||
break;
|
||||
case ID_MACHINE_ACCELERATION:
|
||||
lv_clear_machine_settings();
|
||||
lv_draw_acceleration_settings();
|
||||
break;
|
||||
case ID_MACHINE_FEEDRATE:
|
||||
lv_clear_machine_settings();
|
||||
lv_draw_max_feedrate_settings();
|
||||
break;
|
||||
#if HAS_CLASSIC_JERK
|
||||
case ID_MACHINE_JERK:
|
||||
lv_clear_machine_settings();
|
||||
lv_draw_jerk_settings();
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void lv_draw_machine_settings() {
|
||||
scr = lv_screen_create(MACHINE_SETTINGS_UI, machine_menu.MachineConfigTitle);
|
||||
lv_screen_menu_item(scr, machine_menu.AccelerationConf, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_MACHINE_ACCELERATION, 0);
|
||||
lv_screen_menu_item(scr, machine_menu.MaxFeedRateConf, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_MACHINE_FEEDRATE, 1);
|
||||
#if HAS_CLASSIC_JERK
|
||||
lv_screen_menu_item(scr, machine_menu.JerkConf, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_MACHINE_JERK, 2);
|
||||
#endif
|
||||
lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X + 10, PARA_UI_BACL_POS_Y, event_handler, ID_MACHINE_RETURN, true);
|
||||
}
|
||||
|
||||
void lv_clear_machine_settings() {
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
|
||||
#endif
|
||||
lv_obj_del(scr);
|
||||
}
|
||||
|
||||
#endif // HAS_TFT_LVGL_UI
|
33
Marlin/src/lcd/extui/mks_ui/draw_machine_settings.h
Normal file
33
Marlin/src/lcd/extui/mks_ui/draw_machine_settings.h
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* C-declarations for C++ */
|
||||
#endif
|
||||
|
||||
void lv_draw_machine_settings();
|
||||
void lv_clear_machine_settings();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C-declarations for C++ */
|
||||
#endif
|
87
Marlin/src/lcd/extui/mks_ui/draw_manuaLevel.cpp
Normal file
87
Marlin/src/lcd/extui/mks_ui/draw_manuaLevel.cpp
Normal file
@ -0,0 +1,87 @@
|
||||
/**
|
||||
* 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_TFT_LVGL_UI
|
||||
|
||||
#include "draw_ui.h"
|
||||
#include <lv_conf.h>
|
||||
|
||||
#include "../../../gcode/queue.h"
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
extern const char G28_STR[];
|
||||
|
||||
extern lv_group_t *g;
|
||||
static lv_obj_t *scr;
|
||||
|
||||
enum {
|
||||
ID_M_POINT1 = 1,
|
||||
ID_M_POINT2,
|
||||
ID_M_POINT3,
|
||||
ID_M_POINT4,
|
||||
ID_M_POINT5,
|
||||
ID_MANUAL_RETURN
|
||||
};
|
||||
|
||||
static void event_handler(lv_obj_t *obj, lv_event_t event) {
|
||||
if (event != LV_EVENT_RELEASED) return;
|
||||
|
||||
switch (obj->mks_obj_id) {
|
||||
case ID_M_POINT1 ... ID_M_POINT5:
|
||||
if (queue.ring_buffer.empty()) {
|
||||
if (uiCfg.leveling_first_time) {
|
||||
uiCfg.leveling_first_time = false;
|
||||
queue.inject_P(G28_STR);
|
||||
}
|
||||
const int ind = obj->mks_obj_id - ID_M_POINT1;
|
||||
sprintf_P(public_buf_l, PSTR("G1Z10\nG1X%dY%d\nG1Z0"), gCfgItems.trammingPos[ind].x, gCfgItems.trammingPos[ind].y);
|
||||
queue.inject(public_buf_l);
|
||||
}
|
||||
break;
|
||||
case ID_MANUAL_RETURN:
|
||||
lv_clear_manualLevel();
|
||||
lv_draw_tool();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void lv_draw_manualLevel() {
|
||||
scr = lv_screen_create(LEVELING_UI);
|
||||
// Create an Image button
|
||||
lv_obj_t *buttonPoint1 = lv_big_button_create(scr, "F:/bmp_leveling1.bin", leveling_menu.position1, INTERVAL_V, titleHeight, event_handler, ID_M_POINT1);
|
||||
lv_obj_clear_protect(buttonPoint1, LV_PROTECT_FOLLOW);
|
||||
lv_big_button_create(scr, "F:/bmp_leveling2.bin", leveling_menu.position2, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_M_POINT2);
|
||||
lv_big_button_create(scr, "F:/bmp_leveling3.bin", leveling_menu.position3, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_M_POINT3);
|
||||
lv_big_button_create(scr, "F:/bmp_leveling4.bin", leveling_menu.position4, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_M_POINT4);
|
||||
lv_big_button_create(scr, "F:/bmp_leveling5.bin", leveling_menu.position5, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_M_POINT5);
|
||||
lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_MANUAL_RETURN);
|
||||
}
|
||||
|
||||
void lv_clear_manualLevel() {
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
|
||||
#endif
|
||||
lv_obj_del(scr);
|
||||
}
|
||||
|
||||
#endif // HAS_TFT_LVGL_UI
|
33
Marlin/src/lcd/extui/mks_ui/draw_manuaLevel.h
Normal file
33
Marlin/src/lcd/extui/mks_ui/draw_manuaLevel.h
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* C-declarations for C++ */
|
||||
#endif
|
||||
|
||||
void lv_draw_manualLevel();
|
||||
void lv_clear_manualLevel();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C-declarations for C++ */
|
||||
#endif
|
117
Marlin/src/lcd/extui/mks_ui/draw_max_feedrate_settings.cpp
Normal file
117
Marlin/src/lcd/extui/mks_ui/draw_max_feedrate_settings.cpp
Normal file
@ -0,0 +1,117 @@
|
||||
/**
|
||||
* 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_TFT_LVGL_UI
|
||||
|
||||
#include "draw_ui.h"
|
||||
#include <lv_conf.h>
|
||||
|
||||
#include "../../../module/planner.h"
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
extern lv_group_t *g;
|
||||
static lv_obj_t *scr;
|
||||
|
||||
enum {
|
||||
ID_FEED_RETURN = 1,
|
||||
ID_FEED_X,
|
||||
ID_FEED_Y,
|
||||
ID_FEED_Z,
|
||||
ID_FEED_E0,
|
||||
ID_FEED_E1,
|
||||
ID_FEED_DOWN,
|
||||
ID_FEED_UP
|
||||
};
|
||||
|
||||
static void event_handler(lv_obj_t *obj, lv_event_t event) {
|
||||
if (event != LV_EVENT_RELEASED) return;
|
||||
|
||||
lv_clear_max_feedrate_settings();
|
||||
switch (obj->mks_obj_id) {
|
||||
case ID_FEED_RETURN:
|
||||
uiCfg.para_ui_page = false;
|
||||
draw_return_ui();
|
||||
return;
|
||||
case ID_FEED_X:
|
||||
value = XMaxFeedRate;
|
||||
break;
|
||||
case ID_FEED_Y:
|
||||
value = YMaxFeedRate;
|
||||
break;
|
||||
case ID_FEED_Z:
|
||||
value = ZMaxFeedRate;
|
||||
break;
|
||||
case ID_FEED_E0:
|
||||
value = E0MaxFeedRate;
|
||||
break;
|
||||
case ID_FEED_E1:
|
||||
value = E1MaxFeedRate;
|
||||
break;
|
||||
case ID_FEED_UP:
|
||||
uiCfg.para_ui_page = false;
|
||||
lv_draw_max_feedrate_settings();
|
||||
return;
|
||||
case ID_FEED_DOWN:
|
||||
uiCfg.para_ui_page = true;
|
||||
lv_draw_max_feedrate_settings();
|
||||
return;
|
||||
}
|
||||
lv_draw_number_key();
|
||||
}
|
||||
|
||||
void lv_draw_max_feedrate_settings() {
|
||||
scr = lv_screen_create(MAXFEEDRATE_UI, machine_menu.MaxFeedRateConfTitle);
|
||||
|
||||
if (!uiCfg.para_ui_page) {
|
||||
dtostrf(planner.settings.max_feedrate_mm_s[X_AXIS], 1, 1, public_buf_l);
|
||||
lv_screen_menu_item_1_edit(scr, machine_menu.XMaxFeedRate, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_FEED_X, 0, public_buf_l);
|
||||
|
||||
dtostrf(planner.settings.max_feedrate_mm_s[Y_AXIS], 1, 1, public_buf_l);
|
||||
lv_screen_menu_item_1_edit(scr, machine_menu.YMaxFeedRate, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_FEED_Y, 1, public_buf_l);
|
||||
|
||||
dtostrf(planner.settings.max_feedrate_mm_s[Z_AXIS], 1, 1, public_buf_l);
|
||||
lv_screen_menu_item_1_edit(scr, machine_menu.ZMaxFeedRate, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_FEED_Z, 2, public_buf_l);
|
||||
|
||||
dtostrf(planner.settings.max_feedrate_mm_s[E_AXIS], 1, 1, public_buf_l);
|
||||
lv_screen_menu_item_1_edit(scr, machine_menu.E0MaxFeedRate, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_FEED_E0, 3, public_buf_l);
|
||||
|
||||
lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.next, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_FEED_DOWN, true);
|
||||
}
|
||||
else {
|
||||
dtostrf(planner.settings.max_feedrate_mm_s[E_AXIS_N(1)], 1, 1, public_buf_l);
|
||||
lv_screen_menu_item_1_edit(scr, machine_menu.E1MaxFeedRate, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_FEED_E1, 0, public_buf_l);
|
||||
|
||||
lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.previous, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_FEED_UP, true);
|
||||
}
|
||||
|
||||
lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_FEED_RETURN, true);
|
||||
}
|
||||
|
||||
void lv_clear_max_feedrate_settings() {
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
|
||||
#endif
|
||||
lv_obj_del(scr);
|
||||
}
|
||||
|
||||
#endif // HAS_TFT_LVGL_UI
|
33
Marlin/src/lcd/extui/mks_ui/draw_max_feedrate_settings.h
Normal file
33
Marlin/src/lcd/extui/mks_ui/draw_max_feedrate_settings.h
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* C-declarations for C++ */
|
||||
#endif
|
||||
|
||||
void lv_draw_max_feedrate_settings();
|
||||
void lv_clear_max_feedrate_settings();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C-declarations for C++ */
|
||||
#endif
|
73
Marlin/src/lcd/extui/mks_ui/draw_media_select.cpp
Normal file
73
Marlin/src/lcd/extui/mks_ui/draw_media_select.cpp
Normal file
@ -0,0 +1,73 @@
|
||||
/**
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
#include "../../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if BOTH(HAS_TFT_LVGL_UI, MULTI_VOLUME)
|
||||
|
||||
#include "draw_ui.h"
|
||||
#include <lv_conf.h>
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
#include "../../../sd/cardreader.h"
|
||||
|
||||
extern lv_group_t *g;
|
||||
static lv_obj_t *scr;
|
||||
|
||||
enum {
|
||||
ID_T_USB_DISK = 1,
|
||||
ID_T_SD_DISK,
|
||||
ID_T_RETURN
|
||||
};
|
||||
|
||||
#if ENABLED(MKS_TEST)
|
||||
extern uint8_t curent_disp_ui;
|
||||
#endif
|
||||
|
||||
static void event_handler(lv_obj_t *obj, lv_event_t event) {
|
||||
if (event != LV_EVENT_RELEASED) return;
|
||||
lv_clear_media_select();
|
||||
switch (obj->mks_obj_id) {
|
||||
case ID_T_USB_DISK: card.changeMedia(&card.media_usbFlashDrive); break;
|
||||
case ID_T_SD_DISK: card.changeMedia(&card.media_sd_spi); break;
|
||||
case ID_T_RETURN:
|
||||
TERN_(MKS_TEST, curent_disp_ui = 1);
|
||||
lv_draw_ready_print();
|
||||
return;
|
||||
}
|
||||
lv_draw_print_file();
|
||||
}
|
||||
|
||||
void lv_draw_media_select() {
|
||||
scr = lv_screen_create(MEDIA_SELECT_UI);
|
||||
lv_big_button_create(scr, "F:/bmp_sd.bin", media_select_menu.sd_disk, INTERVAL_V, titleHeight, event_handler, ID_T_SD_DISK);
|
||||
lv_big_button_create(scr, "F:/bmp_usb_disk.bin", media_select_menu.usb_disk, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_T_USB_DISK);
|
||||
lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_T_RETURN);
|
||||
}
|
||||
|
||||
void lv_clear_media_select() {
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
|
||||
#endif
|
||||
lv_obj_del(scr);
|
||||
}
|
||||
|
||||
#endif // HAS_TFT_LVGL_UI
|
33
Marlin/src/lcd/extui/mks_ui/draw_media_select.h
Normal file
33
Marlin/src/lcd/extui/mks_ui/draw_media_select.h
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* C-declarations for C++ */
|
||||
#endif
|
||||
|
||||
extern void lv_draw_media_select();
|
||||
extern void lv_clear_media_select();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C-declarations for C++ */
|
||||
#endif
|
202
Marlin/src/lcd/extui/mks_ui/draw_more.cpp
Normal file
202
Marlin/src/lcd/extui/mks_ui/draw_more.cpp
Normal file
@ -0,0 +1,202 @@
|
||||
/**
|
||||
* 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_TFT_LVGL_UI
|
||||
|
||||
#include "../../../MarlinCore.h"
|
||||
#include "draw_ready_print.h"
|
||||
#include "draw_set.h"
|
||||
#include "lv_conf.h"
|
||||
#include "draw_ui.h"
|
||||
#include "../../../gcode/queue.h"
|
||||
|
||||
extern lv_group_t * g;
|
||||
static lv_obj_t * scr;
|
||||
|
||||
enum {
|
||||
ID_GCODE = 1,
|
||||
#if HAS_USER_ITEM(1)
|
||||
ID_CUSTOM_1,
|
||||
#endif
|
||||
#if HAS_USER_ITEM(2)
|
||||
ID_CUSTOM_2,
|
||||
#endif
|
||||
#if HAS_USER_ITEM(3)
|
||||
ID_CUSTOM_3,
|
||||
#endif
|
||||
#if HAS_USER_ITEM(4)
|
||||
ID_CUSTOM_4,
|
||||
#endif
|
||||
#if HAS_USER_ITEM(5)
|
||||
ID_CUSTOM_5,
|
||||
#endif
|
||||
#if HAS_USER_ITEM(6)
|
||||
ID_CUSTOM_6,
|
||||
#endif
|
||||
ID_M_RETURN,
|
||||
};
|
||||
|
||||
static void event_handler(lv_obj_t * obj, lv_event_t event) {
|
||||
if (event != LV_EVENT_RELEASED) return;
|
||||
switch (obj->mks_obj_id) {
|
||||
case ID_GCODE: lv_clear_more(); lv_draw_gcode(true); break;
|
||||
#if HAS_USER_ITEM(1)
|
||||
case ID_CUSTOM_1: queue.inject_P(PSTR(USER_GCODE_1)); break;
|
||||
#endif
|
||||
#if HAS_USER_ITEM(2)
|
||||
case ID_CUSTOM_2: queue.inject_P(PSTR(USER_GCODE_2)); break;
|
||||
#endif
|
||||
#if HAS_USER_ITEM(3)
|
||||
case ID_CUSTOM_3: queue.inject_P(PSTR(USER_GCODE_3)); break;
|
||||
#endif
|
||||
#if HAS_USER_ITEM(4)
|
||||
case ID_CUSTOM_4: queue.inject_P(PSTR(USER_GCODE_4)); break;
|
||||
#endif
|
||||
#if HAS_USER_ITEM(5)
|
||||
case ID_CUSTOM_5: queue.inject_P(PSTR(USER_GCODE_5)); break;
|
||||
#endif
|
||||
#if HAS_USER_ITEM(6)
|
||||
case ID_CUSTOM_6: queue.inject_P(PSTR(USER_GCODE_6)); break;
|
||||
#endif
|
||||
case ID_M_RETURN:
|
||||
lv_clear_more();
|
||||
lv_draw_tool();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void lv_draw_more() {
|
||||
scr = lv_screen_create(MORE_UI);
|
||||
|
||||
const bool enc_ena = TERN0(HAS_ROTARY_ENCODER, gCfgItems.encoder_enable);
|
||||
|
||||
lv_obj_t *buttonGCode = lv_imgbtn_create(scr, "F:/bmp_machine_para.bin", INTERVAL_V, titleHeight, event_handler, ID_GCODE);
|
||||
if (enc_ena) lv_group_add_obj(g, buttonGCode);
|
||||
lv_obj_t *labelGCode = lv_label_create_empty(buttonGCode);
|
||||
|
||||
#if HAS_USER_ITEM(1)
|
||||
lv_obj_t *buttonCustom1 = lv_imgbtn_create(scr, "F:/bmp_custom1.bin", BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_CUSTOM_1);
|
||||
if (enc_ena) lv_group_add_obj(g, buttonCustom1);
|
||||
lv_obj_t *labelCustom1 = lv_label_create_empty(buttonCustom1);
|
||||
#endif
|
||||
|
||||
#if HAS_USER_ITEM(2)
|
||||
lv_obj_t *buttonCustom2 = lv_imgbtn_create(scr, "F:/bmp_custom2.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_CUSTOM_2);
|
||||
if (enc_ena) lv_group_add_obj(g, buttonCustom2);
|
||||
lv_obj_t *labelCustom2 = lv_label_create_empty(buttonCustom2);
|
||||
#endif
|
||||
|
||||
#if HAS_USER_ITEM(3)
|
||||
lv_obj_t *buttonCustom3 = lv_imgbtn_create(scr, "F:/bmp_custom3.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_CUSTOM_3);
|
||||
if (enc_ena) lv_group_add_obj(g, buttonCustom3);
|
||||
lv_obj_t *labelCustom3 = lv_label_create_empty(buttonCustom3);
|
||||
#endif
|
||||
|
||||
#if HAS_USER_ITEM(4)
|
||||
lv_obj_t *buttonCustom4 = lv_imgbtn_create(scr, "F:/bmp_custom4.bin", INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_CUSTOM_4);
|
||||
if (enc_ena) lv_group_add_obj(g, buttonCustom4);
|
||||
lv_obj_t *labelCustom4 = lv_label_create_empty(buttonCustom4);
|
||||
#endif
|
||||
|
||||
#if HAS_USER_ITEM(5)
|
||||
lv_obj_t *buttonCustom5 = lv_imgbtn_create(scr, "F:/bmp_custom5.bin", BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_CUSTOM_5);
|
||||
if (enc_ena) lv_group_add_obj(g, buttonCustom5);
|
||||
lv_obj_t *labelCustom5 = lv_label_create_empty(buttonCustom5);
|
||||
#endif
|
||||
|
||||
#if HAS_USER_ITEM(6)
|
||||
lv_obj_t *buttonCustom6 = lv_imgbtn_create(scr, "F:/bmp_custom6.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_CUSTOM_6);
|
||||
if (enc_ena) lv_group_add_obj(g, buttonCustom6);
|
||||
lv_obj_t *labelCustom6 = lv_label_create_empty(buttonCustom6);
|
||||
#endif
|
||||
|
||||
lv_obj_t *buttonBack = lv_imgbtn_create(scr, "F:/bmp_return.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_M_RETURN);
|
||||
if (enc_ena) lv_group_add_obj(g, buttonBack);
|
||||
lv_obj_t *label_Back = lv_label_create_empty(buttonBack);
|
||||
|
||||
if (gCfgItems.multiple_language != 0) {
|
||||
lv_label_set_text(labelGCode, more_menu.gcode);
|
||||
lv_obj_align(labelGCode, buttonGCode, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
||||
|
||||
#if HAS_USER_ITEM(1)
|
||||
lv_label_set_text(labelCustom1, more_menu.custom1);
|
||||
lv_obj_align(labelCustom1, buttonCustom1, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
||||
#endif
|
||||
#if HAS_USER_ITEM(2)
|
||||
lv_label_set_text(labelCustom2, more_menu.custom2);
|
||||
lv_obj_align(labelCustom2, buttonCustom2, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
||||
#endif
|
||||
#if HAS_USER_ITEM(3)
|
||||
lv_label_set_text(labelCustom3, more_menu.custom3);
|
||||
lv_obj_align(labelCustom3, buttonCustom3, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
||||
#endif
|
||||
#if HAS_USER_ITEM(4)
|
||||
lv_label_set_text(labelCustom4, more_menu.custom4);
|
||||
lv_obj_align(labelCustom4, buttonCustom4, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
||||
#endif
|
||||
#if HAS_USER_ITEM(5)
|
||||
lv_label_set_text(labelCustom5, more_menu.custom5);
|
||||
lv_obj_align(labelCustom5, buttonCustom5, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
||||
#endif
|
||||
#if HAS_USER_ITEM(6)
|
||||
lv_label_set_text(labelCustom6, more_menu.custom6);
|
||||
lv_obj_align(labelCustom6, buttonCustom6, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
||||
#endif
|
||||
lv_label_set_text(label_Back, common_menu.text_back);
|
||||
lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
||||
}
|
||||
|
||||
#if BUTTONS_EXIST(EN1, EN2, ENC)
|
||||
if (enc_ena) {
|
||||
lv_group_add_obj(g, buttonGCode);
|
||||
#if HAS_USER_ITEM(1)
|
||||
lv_group_add_obj(g, buttonCustom1);
|
||||
#endif
|
||||
#if HAS_USER_ITEM(2)
|
||||
lv_group_add_obj(g, buttonCustom2);
|
||||
#endif
|
||||
#if HAS_USER_ITEM(3)
|
||||
lv_group_add_obj(g, buttonCustom3);
|
||||
#endif
|
||||
#if HAS_USER_ITEM(4)
|
||||
lv_group_add_obj(g, buttonCustom4);
|
||||
#endif
|
||||
#if HAS_USER_ITEM(5)
|
||||
lv_group_add_obj(g, buttonCustom5);
|
||||
#endif
|
||||
#if HAS_USER_ITEM(6)
|
||||
lv_group_add_obj(g, buttonCustom6);
|
||||
#endif
|
||||
lv_group_add_obj(g, buttonBack);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void lv_clear_more() {
|
||||
#if BUTTONS_EXIST(EN1, EN2, ENC)
|
||||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
|
||||
#endif
|
||||
lv_obj_del(scr);
|
||||
}
|
||||
|
||||
#endif // HAS_TFT_LVGL_UI
|
33
Marlin/src/lcd/extui/mks_ui/draw_more.h
Normal file
33
Marlin/src/lcd/extui/mks_ui/draw_more.h
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* C-declarations for C++ */
|
||||
#endif
|
||||
|
||||
void lv_draw_more();
|
||||
void lv_clear_more();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C-declarations for C++ */
|
||||
#endif
|
98
Marlin/src/lcd/extui/mks_ui/draw_motor_settings.cpp
Normal file
98
Marlin/src/lcd/extui/mks_ui/draw_motor_settings.cpp
Normal file
@ -0,0 +1,98 @@
|
||||
/**
|
||||
* 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_TFT_LVGL_UI
|
||||
|
||||
#include "draw_ui.h"
|
||||
#include <lv_conf.h>
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
extern lv_group_t *g;
|
||||
static lv_obj_t *scr;
|
||||
|
||||
enum {
|
||||
ID_MOTOR_RETURN = 1,
|
||||
ID_MOTOR_STEPS,
|
||||
ID_MOTOR_TMC_CURRENT,
|
||||
ID_MOTOR_STEP_MODE,
|
||||
ID_HOME_SENSE
|
||||
};
|
||||
|
||||
static void event_handler(lv_obj_t *obj, lv_event_t event) {
|
||||
if (event != LV_EVENT_RELEASED) return;
|
||||
lv_clear_motor_settings();
|
||||
switch (obj->mks_obj_id) {
|
||||
case ID_MOTOR_RETURN:
|
||||
draw_return_ui();
|
||||
break;
|
||||
case ID_MOTOR_STEPS:
|
||||
lv_draw_step_settings();
|
||||
break;
|
||||
#if USE_SENSORLESS
|
||||
case ID_HOME_SENSE:
|
||||
lv_draw_homing_sensitivity_settings();
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if HAS_TRINAMIC_CONFIG
|
||||
case ID_MOTOR_TMC_CURRENT:
|
||||
lv_draw_tmc_current_settings();
|
||||
break;
|
||||
#if HAS_STEALTHCHOP
|
||||
case ID_MOTOR_STEP_MODE:
|
||||
lv_draw_tmc_step_mode_settings();
|
||||
break;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void lv_draw_motor_settings() {
|
||||
int index = 0;
|
||||
|
||||
scr = lv_screen_create(MOTOR_SETTINGS_UI, machine_menu.MotorConfTitle);
|
||||
lv_screen_menu_item(scr, machine_menu.StepsConf, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_MOTOR_STEPS, index++);
|
||||
#if USE_SENSORLESS
|
||||
lv_screen_menu_item(scr, machine_menu.HomingSensitivityConf, PARA_UI_POS_X, PARA_UI_POS_Y * (index + 1), event_handler, ID_HOME_SENSE, index);
|
||||
index++;
|
||||
#endif
|
||||
#if HAS_TRINAMIC_CONFIG
|
||||
lv_screen_menu_item(scr, machine_menu.TMCcurrentConf, PARA_UI_POS_X, PARA_UI_POS_Y * (index + 1), event_handler, ID_MOTOR_TMC_CURRENT, index);
|
||||
index++;
|
||||
#if HAS_STEALTHCHOP
|
||||
lv_screen_menu_item(scr, machine_menu.TMCStepModeConf, PARA_UI_POS_X, PARA_UI_POS_Y * (index + 1), event_handler, ID_MOTOR_STEP_MODE, index);
|
||||
index++;
|
||||
#endif
|
||||
#endif
|
||||
lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X + 10, PARA_UI_BACL_POS_Y, event_handler, ID_MOTOR_RETURN, true);
|
||||
}
|
||||
|
||||
void lv_clear_motor_settings() {
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
|
||||
#endif
|
||||
lv_obj_del(scr);
|
||||
}
|
||||
|
||||
#endif // HAS_TFT_LVGL_UI
|
33
Marlin/src/lcd/extui/mks_ui/draw_motor_settings.h
Normal file
33
Marlin/src/lcd/extui/mks_ui/draw_motor_settings.h
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* C-declarations for C++ */
|
||||
#endif
|
||||
|
||||
void lv_draw_motor_settings();
|
||||
void lv_clear_motor_settings();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C-declarations for C++ */
|
||||
#endif
|
164
Marlin/src/lcd/extui/mks_ui/draw_move_motor.cpp
Normal file
164
Marlin/src/lcd/extui/mks_ui/draw_move_motor.cpp
Normal file
@ -0,0 +1,164 @@
|
||||
/**
|
||||
* 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_TFT_LVGL_UI
|
||||
|
||||
#include "draw_ui.h"
|
||||
#include <lv_conf.h>
|
||||
|
||||
#include "../../../gcode/queue.h"
|
||||
#include "../../../module/motion.h"
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
extern lv_group_t *g;
|
||||
static lv_obj_t *scr;
|
||||
|
||||
static lv_obj_t *labelV, *buttonV, *labelP;
|
||||
static lv_task_t *updatePosTask;
|
||||
static char cur_label = 'Z';
|
||||
static float cur_pos = 0;
|
||||
|
||||
enum {
|
||||
ID_M_X_P = 1,
|
||||
ID_M_X_N,
|
||||
ID_M_Y_P,
|
||||
ID_M_Y_N,
|
||||
ID_M_Z_P,
|
||||
ID_M_Z_N,
|
||||
ID_M_STEP,
|
||||
ID_M_RETURN
|
||||
};
|
||||
|
||||
void disp_cur_pos() {
|
||||
char str_1[16];
|
||||
sprintf_P(public_buf_l, PSTR("%c:%s mm"), cur_label, dtostrf(cur_pos, 1, 1, str_1));
|
||||
if (labelP) lv_label_set_text(labelP, public_buf_l);
|
||||
}
|
||||
|
||||
static void event_handler(lv_obj_t *obj, lv_event_t event) {
|
||||
char str_1[16];
|
||||
if (event != LV_EVENT_RELEASED) return;
|
||||
if (!queue.ring_buffer.full(3)) {
|
||||
bool do_inject = true;
|
||||
float dist = uiCfg.move_dist;
|
||||
switch (obj->mks_obj_id) {
|
||||
case ID_M_X_N: dist *= -1; case ID_M_X_P: cur_label = 'X'; break;
|
||||
case ID_M_Y_N: dist *= -1; case ID_M_Y_P: cur_label = 'Y'; break;
|
||||
case ID_M_Z_N: dist *= -1; case ID_M_Z_P: cur_label = 'Z'; break;
|
||||
default: do_inject = false;
|
||||
}
|
||||
if (do_inject) {
|
||||
sprintf_P(public_buf_l, PSTR("G91\nG1 %c%s F%d\nG90"), cur_label, dtostrf(dist, 1, 3, str_1), uiCfg.moveSpeed);
|
||||
queue.inject(public_buf_l);
|
||||
}
|
||||
}
|
||||
|
||||
switch (obj->mks_obj_id) {
|
||||
case ID_M_STEP:
|
||||
if (abs(10 * (int)uiCfg.move_dist) == 100)
|
||||
uiCfg.move_dist = 0.1;
|
||||
else
|
||||
uiCfg.move_dist *= 10.0f;
|
||||
disp_move_dist();
|
||||
break;
|
||||
case ID_M_RETURN:
|
||||
clear_cur_ui();
|
||||
draw_return_ui();
|
||||
return;
|
||||
}
|
||||
disp_cur_pos();
|
||||
}
|
||||
|
||||
void refresh_pos(lv_task_t *) {
|
||||
switch (cur_label) {
|
||||
case 'X': cur_pos = current_position.x; break;
|
||||
case 'Y': cur_pos = current_position.y; break;
|
||||
case 'Z': cur_pos = current_position.z; break;
|
||||
default: return;
|
||||
}
|
||||
disp_cur_pos();
|
||||
}
|
||||
|
||||
void lv_draw_move_motor() {
|
||||
scr = lv_screen_create(MOVE_MOTOR_UI);
|
||||
lv_obj_t *buttonXI = lv_big_button_create(scr, "F:/bmp_xAdd.bin", move_menu.x_add, INTERVAL_V, titleHeight, event_handler, ID_M_X_P);
|
||||
lv_obj_clear_protect(buttonXI, LV_PROTECT_FOLLOW);
|
||||
lv_big_button_create(scr, "F:/bmp_xDec.bin", move_menu.x_dec, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_M_X_N);
|
||||
lv_big_button_create(scr, "F:/bmp_yAdd.bin", move_menu.y_add, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_M_Y_P);
|
||||
lv_big_button_create(scr, "F:/bmp_yDec.bin", move_menu.y_dec, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_M_Y_N);
|
||||
lv_big_button_create(scr, "F:/bmp_zAdd.bin", move_menu.z_add, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_M_Z_P);
|
||||
lv_big_button_create(scr, "F:/bmp_zDec.bin", move_menu.z_dec, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_M_Z_N);
|
||||
|
||||
// button with image and label changed dynamically by disp_move_dist
|
||||
buttonV = lv_imgbtn_create(scr, nullptr, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_M_STEP);
|
||||
labelV = lv_label_create_empty(buttonV);
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonV);
|
||||
#endif
|
||||
|
||||
lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_M_RETURN);
|
||||
|
||||
// We need to patch the title to leave some space on the right for displaying the status
|
||||
lv_obj_t * title = lv_obj_get_child_back(scr, NULL);
|
||||
if (title != NULL) lv_obj_set_width(title, TFT_WIDTH - 101);
|
||||
labelP = lv_label_create(scr, TFT_WIDTH - 100, TITLE_YPOS, "Z:0.0mm");
|
||||
if (labelP != NULL)
|
||||
updatePosTask = lv_task_create(refresh_pos, 300, LV_TASK_PRIO_LOWEST, 0);
|
||||
|
||||
disp_move_dist();
|
||||
disp_cur_pos();
|
||||
}
|
||||
|
||||
void disp_move_dist() {
|
||||
if ((int)(10 * uiCfg.move_dist) == 1)
|
||||
lv_imgbtn_set_src_both(buttonV, "F:/bmp_step_move0_1.bin");
|
||||
else if ((int)(10 * uiCfg.move_dist) == 10)
|
||||
lv_imgbtn_set_src_both(buttonV, "F:/bmp_step_move1.bin");
|
||||
else if ((int)(10 * uiCfg.move_dist) == 100)
|
||||
lv_imgbtn_set_src_both(buttonV, "F:/bmp_step_move10.bin");
|
||||
|
||||
if (gCfgItems.multiple_language) {
|
||||
if ((int)(10 * uiCfg.move_dist) == 1) {
|
||||
lv_label_set_text(labelV, move_menu.step_01mm);
|
||||
lv_obj_align(labelV, buttonV, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
||||
}
|
||||
else if ((int)(10 * uiCfg.move_dist) == 10) {
|
||||
lv_label_set_text(labelV, move_menu.step_1mm);
|
||||
lv_obj_align(labelV, buttonV, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
||||
}
|
||||
else if ((int)(10 * uiCfg.move_dist) == 100) {
|
||||
lv_label_set_text(labelV, move_menu.step_10mm);
|
||||
lv_obj_align(labelV, buttonV, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void lv_clear_move_motor() {
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
|
||||
#endif
|
||||
lv_task_del(updatePosTask);
|
||||
lv_obj_del(scr);
|
||||
}
|
||||
|
||||
#endif // HAS_TFT_LVGL_UI
|
34
Marlin/src/lcd/extui/mks_ui/draw_move_motor.h
Normal file
34
Marlin/src/lcd/extui/mks_ui/draw_move_motor.h
Normal file
@ -0,0 +1,34 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* C-declarations for C++ */
|
||||
#endif
|
||||
|
||||
void lv_draw_move_motor();
|
||||
void lv_clear_move_motor();
|
||||
void disp_move_dist();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C-declarations for C++ */
|
||||
#endif
|
539
Marlin/src/lcd/extui/mks_ui/draw_number_key.cpp
Normal file
539
Marlin/src/lcd/extui/mks_ui/draw_number_key.cpp
Normal file
@ -0,0 +1,539 @@
|
||||
/**
|
||||
* 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_TFT_LVGL_UI
|
||||
|
||||
#include "draw_ui.h"
|
||||
#include <lv_conf.h>
|
||||
|
||||
#include "../../../gcode/gcode.h"
|
||||
#include "../../../gcode/queue.h"
|
||||
#include "../../../module/planner.h"
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(POWER_LOSS_RECOVERY)
|
||||
#include "../../../feature/powerloss.h"
|
||||
#endif
|
||||
|
||||
#if HAS_TRINAMIC_CONFIG
|
||||
#include "../../../module/stepper/indirection.h"
|
||||
#include "../../../feature/tmc_util.h"
|
||||
#endif
|
||||
|
||||
#if HAS_BED_PROBE
|
||||
#include "../../../module/probe.h"
|
||||
#endif
|
||||
|
||||
extern lv_group_t *g;
|
||||
static lv_obj_t *scr;
|
||||
static lv_obj_t *buttonValue = nullptr;
|
||||
static lv_obj_t *labelValue = nullptr;
|
||||
|
||||
static char key_value[11] = { 0 };
|
||||
static uint8_t cnt = 0;
|
||||
static bool point_flag = true;
|
||||
|
||||
enum {
|
||||
ID_NUM_KEY1 = 1,
|
||||
ID_NUM_KEY2,
|
||||
ID_NUM_KEY3,
|
||||
ID_NUM_KEY4,
|
||||
ID_NUM_KEY5,
|
||||
ID_NUM_KEY6,
|
||||
ID_NUM_KEY7,
|
||||
ID_NUM_KEY8,
|
||||
ID_NUM_KEY9,
|
||||
ID_NUM_KEY0,
|
||||
ID_NUM_BACK,
|
||||
ID_NUM_RESET,
|
||||
ID_NUM_CONFIRM,
|
||||
ID_NUM_POINT,
|
||||
ID_NUM_NEGATIVE
|
||||
};
|
||||
|
||||
static void disp_key_value() {
|
||||
char *temp;
|
||||
TERN_(HAS_TRINAMIC_CONFIG, float milliamps);
|
||||
|
||||
switch (value) {
|
||||
case PrintAcceleration:
|
||||
dtostrf(planner.settings.acceleration, 1, 1, public_buf_m);
|
||||
break;
|
||||
case RetractAcceleration:
|
||||
dtostrf(planner.settings.retract_acceleration, 1, 1, public_buf_m);
|
||||
break;
|
||||
case TravelAcceleration:
|
||||
dtostrf(planner.settings.travel_acceleration, 1, 1, public_buf_m);
|
||||
break;
|
||||
case XAcceleration:
|
||||
itoa(planner.settings.max_acceleration_mm_per_s2[X_AXIS], public_buf_m, 10);
|
||||
break;
|
||||
case YAcceleration:
|
||||
itoa(planner.settings.max_acceleration_mm_per_s2[Y_AXIS], public_buf_m, 10);
|
||||
break;
|
||||
case ZAcceleration:
|
||||
itoa(planner.settings.max_acceleration_mm_per_s2[Z_AXIS], public_buf_m, 10);
|
||||
break;
|
||||
case E0Acceleration:
|
||||
itoa(planner.settings.max_acceleration_mm_per_s2[E_AXIS], public_buf_m, 10);
|
||||
break;
|
||||
case E1Acceleration:
|
||||
itoa(planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(1)], public_buf_m, 10);
|
||||
break;
|
||||
case XMaxFeedRate:
|
||||
dtostrf(planner.settings.max_feedrate_mm_s[X_AXIS], 1, 1, public_buf_m);
|
||||
break;
|
||||
case YMaxFeedRate:
|
||||
dtostrf(planner.settings.max_feedrate_mm_s[Y_AXIS], 1, 1, public_buf_m);
|
||||
break;
|
||||
case ZMaxFeedRate:
|
||||
dtostrf(planner.settings.max_feedrate_mm_s[Z_AXIS], 1, 1, public_buf_m);
|
||||
break;
|
||||
case E0MaxFeedRate:
|
||||
dtostrf(planner.settings.max_feedrate_mm_s[E_AXIS], 1, 1, public_buf_m);
|
||||
break;
|
||||
case E1MaxFeedRate:
|
||||
dtostrf(planner.settings.max_feedrate_mm_s[E_AXIS_N(1)], 1, 1, public_buf_m);
|
||||
break;
|
||||
|
||||
case XJerk:
|
||||
#if HAS_CLASSIC_JERK
|
||||
dtostrf(planner.max_jerk[X_AXIS], 1, 1, public_buf_m);
|
||||
#endif
|
||||
break;
|
||||
case YJerk:
|
||||
#if HAS_CLASSIC_JERK
|
||||
dtostrf(planner.max_jerk[Y_AXIS], 1, 1, public_buf_m);
|
||||
#endif
|
||||
break;
|
||||
case ZJerk:
|
||||
#if HAS_CLASSIC_JERK
|
||||
dtostrf(planner.max_jerk[Z_AXIS], 1, 1, public_buf_m);
|
||||
#endif
|
||||
break;
|
||||
case EJerk:
|
||||
#if HAS_CLASSIC_JERK
|
||||
dtostrf(planner.max_jerk[E_AXIS], 1, 1, public_buf_m);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case Xstep:
|
||||
dtostrf(planner.settings.axis_steps_per_mm[X_AXIS], 1, 1, public_buf_m);
|
||||
break;
|
||||
case Ystep:
|
||||
dtostrf(planner.settings.axis_steps_per_mm[Y_AXIS], 1, 1, public_buf_m);
|
||||
|
||||
break;
|
||||
case Zstep:
|
||||
dtostrf(planner.settings.axis_steps_per_mm[Z_AXIS], 1, 1, public_buf_m);
|
||||
|
||||
break;
|
||||
case E0step:
|
||||
dtostrf(planner.settings.axis_steps_per_mm[E_AXIS], 1, 1, public_buf_m);
|
||||
|
||||
break;
|
||||
case E1step:
|
||||
dtostrf(planner.settings.axis_steps_per_mm[E_AXIS_N(1)], 1, 1, public_buf_m);
|
||||
break;
|
||||
|
||||
case Xcurrent:
|
||||
#if AXIS_IS_TMC(X)
|
||||
milliamps = stepperX.getMilliamps();
|
||||
dtostrf(milliamps, 1, 1, public_buf_m);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case Ycurrent:
|
||||
#if AXIS_IS_TMC(Y)
|
||||
milliamps = stepperY.getMilliamps();
|
||||
dtostrf(milliamps, 1, 1, public_buf_m);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case Zcurrent:
|
||||
#if AXIS_IS_TMC(Z)
|
||||
milliamps = stepperZ.getMilliamps();
|
||||
dtostrf(milliamps, 1, 1, public_buf_m);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case E0current:
|
||||
#if AXIS_IS_TMC(E0)
|
||||
milliamps = stepperE0.getMilliamps();
|
||||
dtostrf(milliamps, 1, 1, public_buf_m);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case E1current:
|
||||
#if AXIS_IS_TMC(E1)
|
||||
milliamps = stepperE1.getMilliamps();
|
||||
dtostrf(milliamps, 1, 1, public_buf_m);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case pause_pos_x:
|
||||
dtostrf(gCfgItems.pausePosX, 1, 1, public_buf_m);
|
||||
break;
|
||||
case pause_pos_y:
|
||||
dtostrf(gCfgItems.pausePosY, 1, 1, public_buf_m);
|
||||
break;
|
||||
case pause_pos_z:
|
||||
dtostrf(gCfgItems.pausePosZ, 1, 1, public_buf_m);
|
||||
break;
|
||||
case level_pos_x1:
|
||||
itoa(gCfgItems.trammingPos[0].x, public_buf_m, 10);
|
||||
break;
|
||||
case level_pos_y1:
|
||||
itoa(gCfgItems.trammingPos[0].y, public_buf_m, 10);
|
||||
break;
|
||||
case level_pos_x2:
|
||||
itoa(gCfgItems.trammingPos[1].x, public_buf_m, 10);
|
||||
break;
|
||||
case level_pos_y2:
|
||||
itoa(gCfgItems.trammingPos[1].y, public_buf_m, 10);
|
||||
break;
|
||||
case level_pos_x3:
|
||||
itoa(gCfgItems.trammingPos[2].x, public_buf_m, 10);
|
||||
break;
|
||||
case level_pos_y3:
|
||||
itoa(gCfgItems.trammingPos[2].y, public_buf_m, 10);
|
||||
break;
|
||||
case level_pos_x4:
|
||||
itoa(gCfgItems.trammingPos[3].x, public_buf_m, 10);
|
||||
break;
|
||||
case level_pos_y4:
|
||||
itoa(gCfgItems.trammingPos[3].y, public_buf_m, 10);
|
||||
break;
|
||||
case level_pos_x5:
|
||||
itoa(gCfgItems.trammingPos[4].x, public_buf_m, 10);
|
||||
break;
|
||||
case level_pos_y5:
|
||||
itoa(gCfgItems.trammingPos[4].y, public_buf_m, 10);
|
||||
break;
|
||||
#if HAS_BED_PROBE
|
||||
case x_offset:
|
||||
#if HAS_PROBE_XY_OFFSET
|
||||
dtostrf(probe.offset.x, 1, 3, public_buf_m);
|
||||
#endif
|
||||
break;
|
||||
case y_offset:
|
||||
#if HAS_PROBE_XY_OFFSET
|
||||
dtostrf(probe.offset.y, 1, 3, public_buf_m);
|
||||
#endif
|
||||
break;
|
||||
case z_offset:
|
||||
dtostrf(probe.offset.z, 1, 3, public_buf_m);
|
||||
break;
|
||||
#endif
|
||||
case load_length:
|
||||
itoa(gCfgItems.filamentchange_load_length, public_buf_m, 10);
|
||||
break;
|
||||
case load_speed:
|
||||
itoa(gCfgItems.filamentchange_load_speed, public_buf_m, 10);
|
||||
break;
|
||||
case unload_length:
|
||||
itoa(gCfgItems.filamentchange_unload_length, public_buf_m, 10);
|
||||
break;
|
||||
case unload_speed:
|
||||
itoa(gCfgItems.filamentchange_unload_speed, public_buf_m, 10);
|
||||
break;
|
||||
case filament_temp:
|
||||
itoa(gCfgItems.filament_limit_temp, public_buf_m, 10);
|
||||
break;
|
||||
case x_sensitivity:
|
||||
#if X_SENSORLESS
|
||||
itoa(TERN(X_SENSORLESS, stepperX.homing_threshold(), 0), public_buf_m, 10);
|
||||
#endif
|
||||
break;
|
||||
case y_sensitivity:
|
||||
#if Y_SENSORLESS
|
||||
itoa(TERN(Y_SENSORLESS, stepperY.homing_threshold(), 0), public_buf_m, 10);
|
||||
#endif
|
||||
break;
|
||||
case z_sensitivity:
|
||||
#if Z_SENSORLESS
|
||||
itoa(TERN(Z_SENSORLESS, stepperZ.homing_threshold(), 0), public_buf_m, 10);
|
||||
#endif
|
||||
break;
|
||||
case z2_sensitivity:
|
||||
#if Z2_SENSORLESS
|
||||
itoa(TERN(Z2_SENSORLESS, stepperZ2.homing_threshold(), 0), public_buf_m, 10);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
strcpy(key_value, public_buf_m);
|
||||
cnt = strlen(key_value);
|
||||
temp = strchr(key_value, '.');
|
||||
point_flag = !temp;
|
||||
lv_label_set_text(labelValue, key_value);
|
||||
lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
}
|
||||
|
||||
static void set_value_confirm() {
|
||||
switch (value) {
|
||||
case PrintAcceleration: planner.settings.acceleration = atof(key_value); break;
|
||||
case RetractAcceleration: planner.settings.retract_acceleration = atof(key_value); break;
|
||||
case TravelAcceleration: planner.settings.travel_acceleration = atof(key_value); break;
|
||||
case XAcceleration: planner.settings.max_acceleration_mm_per_s2[X_AXIS] = atof(key_value); break;
|
||||
case YAcceleration: planner.settings.max_acceleration_mm_per_s2[Y_AXIS] = atof(key_value); break;
|
||||
case ZAcceleration: planner.settings.max_acceleration_mm_per_s2[Z_AXIS] = atof(key_value); break;
|
||||
case E0Acceleration: planner.settings.max_acceleration_mm_per_s2[E_AXIS] = atof(key_value); break;
|
||||
case E1Acceleration: planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(1)] = atof(key_value); break;
|
||||
case XMaxFeedRate: planner.settings.max_feedrate_mm_s[X_AXIS] = atof(key_value); break;
|
||||
case YMaxFeedRate: planner.settings.max_feedrate_mm_s[Y_AXIS] = atof(key_value); break;
|
||||
case ZMaxFeedRate: planner.settings.max_feedrate_mm_s[Z_AXIS] = atof(key_value); break;
|
||||
case E0MaxFeedRate: planner.settings.max_feedrate_mm_s[E_AXIS] = atof(key_value); break;
|
||||
case E1MaxFeedRate: planner.settings.max_feedrate_mm_s[E_AXIS_N(1)] = atof(key_value); break;
|
||||
case XJerk: TERN_(HAS_CLASSIC_JERK, planner.max_jerk[X_AXIS] = atof(key_value)); break;
|
||||
case YJerk: TERN_(HAS_CLASSIC_JERK, planner.max_jerk[Y_AXIS] = atof(key_value)); break;
|
||||
case ZJerk: TERN_(HAS_CLASSIC_JERK, planner.max_jerk[Z_AXIS] = atof(key_value)); break;
|
||||
case EJerk: TERN_(HAS_CLASSIC_JERK, planner.max_jerk[E_AXIS] = atof(key_value)); break;
|
||||
case Xstep: planner.settings.axis_steps_per_mm[X_AXIS] = atof(key_value); planner.refresh_positioning(); break;
|
||||
case Ystep: planner.settings.axis_steps_per_mm[Y_AXIS] = atof(key_value); planner.refresh_positioning(); break;
|
||||
case Zstep: planner.settings.axis_steps_per_mm[Z_AXIS] = atof(key_value); planner.refresh_positioning(); break;
|
||||
case E0step: planner.settings.axis_steps_per_mm[E_AXIS] = atof(key_value); planner.refresh_positioning(); break;
|
||||
case E1step: planner.settings.axis_steps_per_mm[E_AXIS_N(1)] = atof(key_value); planner.refresh_positioning(); break;
|
||||
case Xcurrent:
|
||||
#if AXIS_IS_TMC(X)
|
||||
stepperX.rms_current(atoi(key_value));
|
||||
#endif
|
||||
break;
|
||||
case Ycurrent:
|
||||
#if AXIS_IS_TMC(Y)
|
||||
stepperY.rms_current(atoi(key_value));
|
||||
#endif
|
||||
break;
|
||||
case Zcurrent:
|
||||
#if AXIS_IS_TMC(Z)
|
||||
stepperZ.rms_current(atoi(key_value));
|
||||
#endif
|
||||
break;
|
||||
case E0current:
|
||||
#if AXIS_IS_TMC(E0)
|
||||
stepperE0.rms_current(atoi(key_value));
|
||||
#endif
|
||||
break;
|
||||
case E1current:
|
||||
#if AXIS_IS_TMC(E1)
|
||||
stepperE1.rms_current(atoi(key_value));
|
||||
#endif
|
||||
break;
|
||||
case pause_pos_x: gCfgItems.pausePosX = atof(key_value); update_spi_flash(); break;
|
||||
case pause_pos_y: gCfgItems.pausePosY = atof(key_value); update_spi_flash(); break;
|
||||
case pause_pos_z: gCfgItems.pausePosZ = atof(key_value); update_spi_flash(); break;
|
||||
case level_pos_x1: gCfgItems.trammingPos[0].x = atoi(key_value); update_spi_flash(); break;
|
||||
case level_pos_y1: gCfgItems.trammingPos[0].y = atoi(key_value); update_spi_flash(); break;
|
||||
case level_pos_x2: gCfgItems.trammingPos[1].x = atoi(key_value); update_spi_flash(); break;
|
||||
case level_pos_y2: gCfgItems.trammingPos[1].y = atoi(key_value); update_spi_flash(); break;
|
||||
case level_pos_x3: gCfgItems.trammingPos[2].x = atoi(key_value); update_spi_flash(); break;
|
||||
case level_pos_y3: gCfgItems.trammingPos[2].y = atoi(key_value); update_spi_flash(); break;
|
||||
case level_pos_x4: gCfgItems.trammingPos[3].x = atoi(key_value); update_spi_flash(); break;
|
||||
case level_pos_y4: gCfgItems.trammingPos[3].y = atoi(key_value); update_spi_flash(); break;
|
||||
case level_pos_x5: gCfgItems.trammingPos[4].x = atoi(key_value); update_spi_flash(); break;
|
||||
case level_pos_y5: gCfgItems.trammingPos[4].y = atoi(key_value); update_spi_flash(); break;
|
||||
#if HAS_BED_PROBE
|
||||
case x_offset: {
|
||||
#if HAS_PROBE_XY_OFFSET
|
||||
const float x = atof(key_value);
|
||||
if (WITHIN(x, -(X_BED_SIZE), X_BED_SIZE))
|
||||
probe.offset.x = x;
|
||||
#endif
|
||||
} break;
|
||||
case y_offset: {
|
||||
#if HAS_PROBE_XY_OFFSET
|
||||
const float y = atof(key_value);
|
||||
if (WITHIN(y, -(Y_BED_SIZE), Y_BED_SIZE))
|
||||
probe.offset.y = y;
|
||||
#endif
|
||||
} break;
|
||||
case z_offset: {
|
||||
const float z = atof(key_value);
|
||||
if (WITHIN(z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX))
|
||||
probe.offset.z = z;
|
||||
} break;
|
||||
#endif
|
||||
case load_length:
|
||||
gCfgItems.filamentchange_load_length = atoi(key_value);
|
||||
uiCfg.filament_loading_time = (uint32_t)((gCfgItems.filamentchange_load_length*60.0/gCfgItems.filamentchange_load_speed)+0.5);
|
||||
update_spi_flash();
|
||||
break;
|
||||
case load_speed:
|
||||
gCfgItems.filamentchange_load_speed = atoi(key_value);
|
||||
uiCfg.filament_loading_time = (uint32_t)((gCfgItems.filamentchange_load_length*60.0/gCfgItems.filamentchange_load_speed)+0.5);
|
||||
update_spi_flash();
|
||||
break;
|
||||
case unload_length:
|
||||
gCfgItems.filamentchange_unload_length = atoi(key_value);
|
||||
uiCfg.filament_unloading_time = (uint32_t)((gCfgItems.filamentchange_unload_length*60.0/gCfgItems.filamentchange_unload_speed)+0.5);
|
||||
update_spi_flash();
|
||||
break;
|
||||
case unload_speed:
|
||||
gCfgItems.filamentchange_unload_speed = atoi(key_value);
|
||||
uiCfg.filament_unloading_time = (uint32_t)((gCfgItems.filamentchange_unload_length*60.0/gCfgItems.filamentchange_unload_speed)+0.5);
|
||||
update_spi_flash();
|
||||
break;
|
||||
case filament_temp:
|
||||
gCfgItems.filament_limit_temp = atoi(key_value);
|
||||
update_spi_flash();
|
||||
break;
|
||||
case x_sensitivity: TERN_(X_SENSORLESS, stepperX.homing_threshold(atoi(key_value))); break;
|
||||
case y_sensitivity: TERN_(Y_SENSORLESS, stepperY.homing_threshold(atoi(key_value))); break;
|
||||
case z_sensitivity: TERN_(Z_SENSORLESS, stepperZ.homing_threshold(atoi(key_value))); break;
|
||||
case z2_sensitivity: TERN_(Z2_SENSORLESS, stepperZ2.homing_threshold(atoi(key_value))); break;
|
||||
}
|
||||
gcode.process_subcommands_now_P(PSTR("M500"));
|
||||
}
|
||||
|
||||
static void event_handler(lv_obj_t *obj, lv_event_t event) {
|
||||
if (event != LV_EVENT_RELEASED) return;
|
||||
switch (obj->mks_obj_id) {
|
||||
case ID_NUM_KEY1 ... ID_NUM_KEY0:
|
||||
if (cnt <= 10) {
|
||||
key_value[cnt] = (obj->mks_obj_id == ID_NUM_KEY0) ? (char)'0' : char('1' + obj->mks_obj_id - ID_NUM_KEY1);
|
||||
lv_label_set_text(labelValue, key_value);
|
||||
lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
|
||||
cnt++;
|
||||
}
|
||||
break;
|
||||
case ID_NUM_BACK:
|
||||
if (cnt > 0) cnt--;
|
||||
if (key_value[cnt] == (char)'.') point_flag = true;
|
||||
key_value[cnt] = (char)'\0';
|
||||
lv_label_set_text(labelValue, key_value);
|
||||
lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
|
||||
break;
|
||||
case ID_NUM_RESET:
|
||||
ZERO(key_value);
|
||||
cnt = 0;
|
||||
key_value[cnt] = (char)'0';
|
||||
point_flag = true;
|
||||
lv_label_set_text(labelValue, key_value);
|
||||
lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
|
||||
break;
|
||||
case ID_NUM_POINT:
|
||||
if (cnt != 0 && point_flag) {
|
||||
point_flag = false;
|
||||
key_value[cnt] = (char)'.';
|
||||
lv_label_set_text(labelValue, key_value);
|
||||
lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
|
||||
cnt++;
|
||||
}
|
||||
break;
|
||||
case ID_NUM_NEGATIVE:
|
||||
if (cnt == 0) {
|
||||
key_value[cnt] = (char)'-';
|
||||
lv_label_set_text(labelValue, key_value);
|
||||
lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
|
||||
cnt++;
|
||||
}
|
||||
break;
|
||||
case ID_NUM_CONFIRM:
|
||||
last_disp_state = NUMBER_KEY_UI;
|
||||
if (strlen(key_value) != 0) set_value_confirm();
|
||||
lv_clear_number_key();
|
||||
draw_return_ui();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void lv_draw_number_key() {
|
||||
scr = lv_screen_create(NUMBER_KEY_UI, "");
|
||||
|
||||
buttonValue = lv_btn_create(scr, 92, 40, 296, 40, event_handler, ID_NUM_KEY1, &style_num_text);
|
||||
labelValue = lv_label_create_empty(buttonValue);
|
||||
|
||||
#define DRAW_NUMBER_KEY(N,X,Y) \
|
||||
lv_obj_t *NumberKey_##N = lv_btn_create(scr, X, Y, 68, 40, event_handler, ID_NUM_KEY##N, &style_num_key_pre); \
|
||||
lv_obj_t *labelKey_##N = lv_label_create_empty(NumberKey_##N); \
|
||||
lv_label_set_text(labelKey_##N, machine_menu.key_##N); \
|
||||
lv_obj_align(labelKey_##N, NumberKey_##N, LV_ALIGN_CENTER, 0, 0)
|
||||
|
||||
DRAW_NUMBER_KEY(1, 92, 90);
|
||||
DRAW_NUMBER_KEY(2, 168, 90);
|
||||
DRAW_NUMBER_KEY(3, 244, 90);
|
||||
DRAW_NUMBER_KEY(4, 92, 140);
|
||||
DRAW_NUMBER_KEY(5, 168, 140);
|
||||
DRAW_NUMBER_KEY(6, 244, 140);
|
||||
DRAW_NUMBER_KEY(7, 92, 190);
|
||||
DRAW_NUMBER_KEY(8, 168, 190);
|
||||
DRAW_NUMBER_KEY(9, 244, 190);
|
||||
DRAW_NUMBER_KEY(0, 92, 240);
|
||||
|
||||
lv_obj_t *KeyBack = lv_btn_create(scr, 320, 90, 68, 40, event_handler, ID_NUM_BACK, &style_num_key_pre);
|
||||
lv_obj_t *labelKeyBack = lv_label_create_empty(KeyBack);
|
||||
lv_label_set_text(labelKeyBack, machine_menu.key_back);
|
||||
lv_obj_align(labelKeyBack, KeyBack, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
lv_obj_t *KeyReset = lv_btn_create(scr, 320, 140, 68, 40, event_handler, ID_NUM_RESET, &style_num_key_pre);
|
||||
lv_obj_t *labelKeyReset = lv_label_create_empty(KeyReset);
|
||||
lv_label_set_text(labelKeyReset, machine_menu.key_reset);
|
||||
lv_obj_align(labelKeyReset, KeyReset, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
lv_obj_t *KeyConfirm = lv_btn_create(scr, 320, 190, 68, 90, event_handler, ID_NUM_CONFIRM, &style_num_key_pre);
|
||||
lv_obj_t *labelKeyConfirm = lv_label_create_empty(KeyConfirm);
|
||||
lv_label_set_text(labelKeyConfirm, machine_menu.key_confirm);
|
||||
lv_obj_align(labelKeyConfirm, KeyConfirm, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
lv_obj_t *KeyPoint = lv_btn_create(scr, 244, 240, 68, 40, event_handler, ID_NUM_POINT, &style_num_key_pre);
|
||||
lv_obj_t *labelKeyPoint = lv_label_create_empty(KeyPoint);
|
||||
lv_label_set_text(labelKeyPoint, machine_menu.key_point);
|
||||
lv_obj_align(labelKeyPoint, KeyPoint, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
lv_obj_t *Minus = lv_btn_create(scr, 168, 240, 68, 40, event_handler, ID_NUM_NEGATIVE, &style_num_key_pre);
|
||||
lv_obj_t *labelMinus = lv_label_create_empty(Minus);
|
||||
lv_label_set_text(labelMinus, machine_menu.negative);
|
||||
lv_obj_align(labelMinus, Minus, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) {
|
||||
lv_group_add_obj(g, NumberKey_1);
|
||||
lv_group_add_obj(g, NumberKey_2);
|
||||
lv_group_add_obj(g, NumberKey_3);
|
||||
lv_group_add_obj(g, KeyBack);
|
||||
lv_group_add_obj(g, NumberKey_4);
|
||||
lv_group_add_obj(g, NumberKey_5);
|
||||
lv_group_add_obj(g, NumberKey_6);
|
||||
lv_group_add_obj(g, KeyReset);
|
||||
lv_group_add_obj(g, NumberKey_7);
|
||||
lv_group_add_obj(g, NumberKey_8);
|
||||
lv_group_add_obj(g, NumberKey_9);
|
||||
lv_group_add_obj(g, NumberKey_0);
|
||||
lv_group_add_obj(g, Minus);
|
||||
lv_group_add_obj(g, KeyPoint);
|
||||
lv_group_add_obj(g, KeyConfirm);
|
||||
}
|
||||
#endif
|
||||
|
||||
disp_key_value();
|
||||
}
|
||||
|
||||
void lv_clear_number_key() {
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
|
||||
#endif
|
||||
lv_obj_del(scr);
|
||||
}
|
||||
|
||||
#endif // HAS_TFT_LVGL_UI
|
33
Marlin/src/lcd/extui/mks_ui/draw_number_key.h
Normal file
33
Marlin/src/lcd/extui/mks_ui/draw_number_key.h
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* C-declarations for C++ */
|
||||
#endif
|
||||
|
||||
void lv_draw_number_key();
|
||||
void lv_clear_number_key();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C-declarations for C++ */
|
||||
#endif
|
229
Marlin/src/lcd/extui/mks_ui/draw_operation.cpp
Normal file
229
Marlin/src/lcd/extui/mks_ui/draw_operation.cpp
Normal file
@ -0,0 +1,229 @@
|
||||
/**
|
||||
* 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_TFT_LVGL_UI
|
||||
|
||||
#include "draw_ui.h"
|
||||
#include <lv_conf.h>
|
||||
|
||||
#include "../../../module/temperature.h"
|
||||
#include "../../../module/motion.h"
|
||||
#include "../../../sd/cardreader.h"
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
extern lv_group_t *g;
|
||||
static lv_obj_t *scr;
|
||||
|
||||
enum {
|
||||
ID_O_PRE_HEAT = 1,
|
||||
ID_O_EXTRUCT,
|
||||
ID_O_MOV,
|
||||
ID_O_FILAMENT,
|
||||
ID_O_SPEED,
|
||||
ID_O_RETURN,
|
||||
ID_O_FAN,
|
||||
ID_O_POWER_OFF,
|
||||
ID_O_BABY_STEP
|
||||
};
|
||||
|
||||
static lv_obj_t *label_PowerOff;
|
||||
static lv_obj_t *buttonPowerOff;
|
||||
|
||||
static void event_handler(lv_obj_t *obj, lv_event_t event) {
|
||||
if (event != LV_EVENT_RELEASED) return;
|
||||
switch (obj->mks_obj_id) {
|
||||
case ID_O_PRE_HEAT:
|
||||
lv_clear_operation();
|
||||
lv_draw_preHeat();
|
||||
break;
|
||||
case ID_O_EXTRUCT:
|
||||
lv_clear_operation();
|
||||
lv_draw_extrusion();
|
||||
break;
|
||||
case ID_O_MOV:
|
||||
lv_clear_operation();
|
||||
lv_draw_move_motor();
|
||||
break;
|
||||
case ID_O_FILAMENT:
|
||||
#if HAS_MULTI_EXTRUDER
|
||||
uiCfg.extruderIndexBak = active_extruder;
|
||||
#endif
|
||||
if (uiCfg.print_state == WORKING) {
|
||||
#if ENABLED(SDSUPPORT)
|
||||
card.pauseSDPrint();
|
||||
stop_print_time();
|
||||
uiCfg.print_state = PAUSING;
|
||||
#endif
|
||||
}
|
||||
uiCfg.moveSpeed_bak = (uint16_t)feedrate_mm_s;
|
||||
uiCfg.hotendTargetTempBak = thermalManager.degTargetHotend(active_extruder);
|
||||
lv_clear_operation();
|
||||
lv_draw_filament_change();
|
||||
break;
|
||||
case ID_O_FAN:
|
||||
lv_clear_operation();
|
||||
lv_draw_fan();
|
||||
break;
|
||||
case ID_O_SPEED:
|
||||
lv_clear_operation();
|
||||
lv_draw_change_speed();
|
||||
break;
|
||||
case ID_O_RETURN:
|
||||
clear_cur_ui();
|
||||
draw_return_ui();
|
||||
break;
|
||||
case ID_O_POWER_OFF:
|
||||
if (gCfgItems.finish_power_off) {
|
||||
gCfgItems.finish_power_off = false;
|
||||
lv_imgbtn_set_src_both(buttonPowerOff, "F:/bmp_manual_off.bin");
|
||||
lv_label_set_text(label_PowerOff, printing_more_menu.manual);
|
||||
}
|
||||
else {
|
||||
gCfgItems.finish_power_off = true;
|
||||
lv_imgbtn_set_src_both(buttonPowerOff, "F:/bmp_auto_off.bin");
|
||||
lv_label_set_text(label_PowerOff, printing_more_menu.auto_close);
|
||||
}
|
||||
lv_obj_align(label_PowerOff, buttonPowerOff, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
||||
lv_obj_refresh_ext_draw_pad(label_PowerOff);
|
||||
update_spi_flash();
|
||||
break;
|
||||
case ID_O_BABY_STEP:
|
||||
lv_clear_operation();
|
||||
lv_draw_baby_stepping();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void lv_draw_operation() {
|
||||
lv_obj_t *buttonExtrusion = nullptr, *buttonSpeed = nullptr,
|
||||
*buttonBack = nullptr,
|
||||
*labelPreHeat = nullptr, *labelExtrusion = nullptr,
|
||||
*label_Back = nullptr, *label_Speed = nullptr, *label_Fan = nullptr,
|
||||
*buttonMove = nullptr, *label_Move = nullptr,
|
||||
*buttonBabyStep = nullptr, *label_BabyStep = nullptr,
|
||||
*label_Filament = nullptr;
|
||||
|
||||
scr = lv_screen_create(OPERATE_UI);
|
||||
|
||||
// Create image buttons
|
||||
lv_obj_t *buttonPreHeat = lv_imgbtn_create(scr, "F:/bmp_temp.bin", INTERVAL_V, titleHeight, event_handler, ID_O_PRE_HEAT);
|
||||
lv_obj_t *buttonFilament = lv_imgbtn_create(scr, "F:/bmp_filamentchange.bin", BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_O_FILAMENT);
|
||||
lv_obj_t *buttonFan = lv_imgbtn_create(scr, "F:/bmp_fan.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_O_FAN);
|
||||
buttonPowerOff = lv_imgbtn_create(scr, gCfgItems.finish_power_off ? "F:/bmp_auto_off.bin" : "F:/bmp_manual_off.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_O_POWER_OFF);
|
||||
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) {
|
||||
lv_group_add_obj(g, buttonPreHeat);
|
||||
lv_group_add_obj(g, buttonFilament);
|
||||
lv_group_add_obj(g, buttonFan);
|
||||
lv_group_add_obj(g, buttonPowerOff);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (uiCfg.print_state != WORKING) {
|
||||
buttonExtrusion = lv_imgbtn_create(scr, "F:/bmp_extrude_opr.bin", INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_O_EXTRUCT);
|
||||
buttonMove = lv_imgbtn_create(scr, "F:/bmp_move_opr.bin", BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_O_MOV);
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) {
|
||||
lv_group_add_obj(g, buttonExtrusion);
|
||||
lv_group_add_obj(g, buttonMove);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
buttonSpeed = lv_imgbtn_create(scr, "F:/bmp_speed.bin", INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_O_SPEED);
|
||||
buttonBabyStep = lv_imgbtn_create(scr, "F:/bmp_mov.bin", BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_O_BABY_STEP);
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) {
|
||||
lv_group_add_obj(g, buttonSpeed);
|
||||
lv_group_add_obj(g, buttonBabyStep);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
buttonBack = lv_imgbtn_create(scr, "F:/bmp_return.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_O_RETURN);
|
||||
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
|
||||
#endif
|
||||
|
||||
// Create labels on the image buttons
|
||||
labelPreHeat = lv_label_create_empty(buttonPreHeat);
|
||||
label_Filament = lv_label_create_empty(buttonFilament);
|
||||
label_Fan = lv_label_create_empty(buttonFan);
|
||||
label_PowerOff = lv_label_create_empty(buttonPowerOff);
|
||||
|
||||
if (uiCfg.print_state != WORKING) {
|
||||
labelExtrusion = lv_label_create_empty(buttonExtrusion);
|
||||
label_Move = lv_label_create_empty(buttonMove);
|
||||
}
|
||||
else {
|
||||
label_Speed = lv_label_create_empty(buttonSpeed);
|
||||
label_BabyStep = lv_label_create_empty(buttonBabyStep);
|
||||
}
|
||||
label_Back = lv_label_create_empty(buttonBack);
|
||||
|
||||
if (gCfgItems.multiple_language) {
|
||||
lv_label_set_text(labelPreHeat, operation_menu.temp);
|
||||
lv_obj_align(labelPreHeat, buttonPreHeat, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
||||
|
||||
lv_label_set_text(label_Filament, operation_menu.filament);
|
||||
lv_obj_align(label_Filament, buttonFilament, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
||||
|
||||
lv_label_set_text(label_Fan, operation_menu.fan);
|
||||
lv_obj_align(label_Fan, buttonFan, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
||||
|
||||
if (gCfgItems.finish_power_off)
|
||||
lv_label_set_text(label_PowerOff, printing_more_menu.auto_close);
|
||||
else
|
||||
lv_label_set_text(label_PowerOff, printing_more_menu.manual);
|
||||
lv_obj_align(label_PowerOff, buttonPowerOff, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
||||
|
||||
if (uiCfg.print_state != WORKING) {
|
||||
lv_label_set_text(labelExtrusion, operation_menu.extr);
|
||||
lv_obj_align(labelExtrusion, buttonExtrusion, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
||||
|
||||
lv_label_set_text(label_Move, operation_menu.move);
|
||||
lv_obj_align(label_Move, buttonMove, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
||||
}
|
||||
else {
|
||||
lv_label_set_text(label_Speed, operation_menu.speed);
|
||||
lv_obj_align(label_Speed, buttonSpeed, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
||||
|
||||
lv_label_set_text(label_BabyStep, operation_menu.babystep);
|
||||
lv_obj_align(label_BabyStep, buttonBabyStep, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
||||
}
|
||||
|
||||
lv_label_set_text(label_Back, common_menu.text_back);
|
||||
lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
||||
}
|
||||
}
|
||||
|
||||
void lv_clear_operation() {
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
|
||||
#endif
|
||||
lv_obj_del(scr);
|
||||
}
|
||||
|
||||
#endif // HAS_TFT_LVGL_UI
|
33
Marlin/src/lcd/extui/mks_ui/draw_operation.h
Normal file
33
Marlin/src/lcd/extui/mks_ui/draw_operation.h
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* C-declarations for C++ */
|
||||
#endif
|
||||
|
||||
void lv_draw_operation();
|
||||
void lv_clear_operation();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C-declarations for C++ */
|
||||
#endif
|
51
Marlin/src/lcd/extui/mks_ui/draw_pause_message.cpp
Normal file
51
Marlin/src/lcd/extui/mks_ui/draw_pause_message.cpp
Normal file
@ -0,0 +1,51 @@
|
||||
/**
|
||||
* 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 BOTH(HAS_TFT_LVGL_UI, ADVANCED_PAUSE_FEATURE)
|
||||
|
||||
#include "draw_ui.h"
|
||||
#include <lv_conf.h>
|
||||
|
||||
#include "../../../feature/pause.h"
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
void lv_draw_pause_message(const PauseMessage msg) {
|
||||
switch (msg) {
|
||||
case PAUSE_MESSAGE_PAUSING: clear_cur_ui(); lv_draw_dialog(DIALOG_PAUSE_MESSAGE_PAUSING); break;
|
||||
case PAUSE_MESSAGE_CHANGING: clear_cur_ui(); lv_draw_dialog(DIALOG_PAUSE_MESSAGE_CHANGING); break;
|
||||
case PAUSE_MESSAGE_UNLOAD: clear_cur_ui(); lv_draw_dialog(DIALOG_PAUSE_MESSAGE_UNLOAD); break;
|
||||
case PAUSE_MESSAGE_WAITING: clear_cur_ui(); lv_draw_dialog(DIALOG_PAUSE_MESSAGE_WAITING); break;
|
||||
case PAUSE_MESSAGE_INSERT: clear_cur_ui(); lv_draw_dialog(DIALOG_PAUSE_MESSAGE_INSERT); break;
|
||||
case PAUSE_MESSAGE_LOAD: clear_cur_ui(); lv_draw_dialog(DIALOG_PAUSE_MESSAGE_LOAD); break;
|
||||
case PAUSE_MESSAGE_PURGE: clear_cur_ui(); lv_draw_dialog(DIALOG_PAUSE_MESSAGE_PURGE); break;
|
||||
case PAUSE_MESSAGE_RESUME: clear_cur_ui(); lv_draw_dialog(DIALOG_PAUSE_MESSAGE_RESUME); break;
|
||||
case PAUSE_MESSAGE_HEAT: clear_cur_ui(); lv_draw_dialog(DIALOG_PAUSE_MESSAGE_HEAT); break;
|
||||
case PAUSE_MESSAGE_HEATING: clear_cur_ui(); lv_draw_dialog(DIALOG_PAUSE_MESSAGE_HEATING); break;
|
||||
case PAUSE_MESSAGE_OPTION: pause_menu_response = PAUSE_RESPONSE_WAIT_FOR;
|
||||
clear_cur_ui(); lv_draw_dialog(DIALOG_PAUSE_MESSAGE_OPTION); break;
|
||||
case PAUSE_MESSAGE_STATUS:
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // HAS_TFT_LVGL_UI && ADVANCED_PAUSE_FEATURE
|
32
Marlin/src/lcd/extui/mks_ui/draw_pause_message.h
Normal file
32
Marlin/src/lcd/extui/mks_ui/draw_pause_message.h
Normal file
@ -0,0 +1,32 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* C-declarations for C++ */
|
||||
#endif
|
||||
|
||||
void lv_draw_pause_message(const PauseMessage msg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C-declarations for C++ */
|
||||
#endif
|
84
Marlin/src/lcd/extui/mks_ui/draw_pause_position.cpp
Normal file
84
Marlin/src/lcd/extui/mks_ui/draw_pause_position.cpp
Normal file
@ -0,0 +1,84 @@
|
||||
/**
|
||||
* 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_TFT_LVGL_UI
|
||||
|
||||
#include "draw_ui.h"
|
||||
#include <lv_conf.h>
|
||||
|
||||
#include "../../../module/planner.h"
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
extern lv_group_t *g;
|
||||
static lv_obj_t *scr;
|
||||
|
||||
enum {
|
||||
ID_PAUSE_RETURN = 1,
|
||||
ID_PAUSE_X,
|
||||
ID_PAUSE_Y,
|
||||
ID_PAUSE_Z
|
||||
};
|
||||
|
||||
static void event_handler(lv_obj_t *obj, lv_event_t event) {
|
||||
if (event != LV_EVENT_RELEASED) return;
|
||||
lv_clear_pause_position();
|
||||
switch (obj->mks_obj_id) {
|
||||
case ID_PAUSE_RETURN:
|
||||
draw_return_ui();
|
||||
return;
|
||||
case ID_PAUSE_X:
|
||||
value = pause_pos_x;
|
||||
break;
|
||||
case ID_PAUSE_Y:
|
||||
value = pause_pos_y;
|
||||
break;
|
||||
case ID_PAUSE_Z:
|
||||
value = pause_pos_z;
|
||||
break;
|
||||
}
|
||||
lv_draw_number_key();
|
||||
}
|
||||
|
||||
void lv_draw_pause_position() {
|
||||
scr = lv_screen_create(PAUSE_POS_UI, machine_menu.PausePosText);
|
||||
|
||||
dtostrf(gCfgItems.pausePosX, 1, 1, public_buf_l);
|
||||
lv_screen_menu_item_1_edit(scr, machine_menu.xPos, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_PAUSE_X, 0, public_buf_l);
|
||||
|
||||
dtostrf(gCfgItems.pausePosY, 1, 1, public_buf_l);
|
||||
lv_screen_menu_item_1_edit(scr, machine_menu.yPos, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_PAUSE_Y, 1, public_buf_l);
|
||||
|
||||
dtostrf(gCfgItems.pausePosZ, 1, 1, public_buf_l);
|
||||
lv_screen_menu_item_1_edit(scr, machine_menu.zPos, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_PAUSE_Z, 2, public_buf_l);
|
||||
|
||||
lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_PAUSE_RETURN, true);
|
||||
}
|
||||
|
||||
void lv_clear_pause_position() {
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
|
||||
#endif
|
||||
lv_obj_del(scr);
|
||||
}
|
||||
|
||||
#endif // HAS_TFT_LVGL_UI
|
33
Marlin/src/lcd/extui/mks_ui/draw_pause_position.h
Normal file
33
Marlin/src/lcd/extui/mks_ui/draw_pause_position.h
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* C-declarations for C++ */
|
||||
#endif
|
||||
|
||||
void lv_draw_pause_position();
|
||||
void lv_clear_pause_position();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C-declarations for C++ */
|
||||
#endif
|
267
Marlin/src/lcd/extui/mks_ui/draw_preHeat.cpp
Normal file
267
Marlin/src/lcd/extui/mks_ui/draw_preHeat.cpp
Normal file
@ -0,0 +1,267 @@
|
||||
/**
|
||||
* 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_TFT_LVGL_UI
|
||||
|
||||
#include "draw_ui.h"
|
||||
#include <lv_conf.h>
|
||||
|
||||
#include "../../../module/temperature.h"
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
static lv_obj_t *scr;
|
||||
extern lv_group_t* g;
|
||||
static lv_obj_t *buttonType, *buttonStep;
|
||||
static lv_obj_t *labelType;
|
||||
static lv_obj_t *labelStep;
|
||||
static lv_obj_t *tempText1;
|
||||
|
||||
enum {
|
||||
ID_P_ADD = 1,
|
||||
ID_P_DEC,
|
||||
ID_P_TYPE,
|
||||
ID_P_STEP,
|
||||
ID_P_OFF,
|
||||
ID_P_RETURN
|
||||
};
|
||||
|
||||
static void event_handler(lv_obj_t *obj, lv_event_t event) {
|
||||
if (event != LV_EVENT_RELEASED) return;
|
||||
switch (obj->mks_obj_id) {
|
||||
case ID_P_ADD: {
|
||||
if (uiCfg.curTempType == 0) {
|
||||
int16_t max_target;
|
||||
thermalManager.temp_hotend[uiCfg.extruderIndex].target += uiCfg.stepHeat;
|
||||
if (uiCfg.extruderIndex == 0)
|
||||
max_target = HEATER_0_MAXTEMP - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1);
|
||||
#if HAS_MULTI_HOTEND
|
||||
else
|
||||
max_target = HEATER_1_MAXTEMP - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1);
|
||||
#endif
|
||||
if (thermalManager.degTargetHotend(uiCfg.extruderIndex) > max_target)
|
||||
thermalManager.setTargetHotend(max_target, uiCfg.extruderIndex);
|
||||
thermalManager.start_watching_hotend(uiCfg.extruderIndex);
|
||||
}
|
||||
else {
|
||||
#if HAS_HEATED_BED
|
||||
constexpr int16_t max_target = BED_MAXTEMP - (WATCH_BED_TEMP_INCREASE + TEMP_BED_HYSTERESIS + 1);
|
||||
thermalManager.temp_bed.target += uiCfg.stepHeat;
|
||||
if (thermalManager.degTargetBed() > max_target)
|
||||
thermalManager.setTargetBed(max_target);
|
||||
thermalManager.start_watching_bed();
|
||||
#endif
|
||||
}
|
||||
disp_desire_temp();
|
||||
} break;
|
||||
|
||||
case ID_P_DEC:
|
||||
if (uiCfg.curTempType == 0) {
|
||||
if (thermalManager.degTargetHotend(uiCfg.extruderIndex) > uiCfg.stepHeat)
|
||||
thermalManager.temp_hotend[uiCfg.extruderIndex].target -= uiCfg.stepHeat;
|
||||
else
|
||||
thermalManager.setTargetHotend(0, uiCfg.extruderIndex);
|
||||
thermalManager.start_watching_hotend(uiCfg.extruderIndex);
|
||||
}
|
||||
#if HAS_HEATED_BED
|
||||
else {
|
||||
if (thermalManager.degTargetBed() > uiCfg.stepHeat)
|
||||
thermalManager.temp_bed.target -= uiCfg.stepHeat;
|
||||
else
|
||||
thermalManager.setTargetBed(0);
|
||||
|
||||
thermalManager.start_watching_bed();
|
||||
}
|
||||
#endif
|
||||
disp_desire_temp();
|
||||
break;
|
||||
case ID_P_TYPE:
|
||||
if (uiCfg.curTempType == 0) {
|
||||
if (ENABLED(HAS_MULTI_EXTRUDER)) {
|
||||
if (uiCfg.extruderIndex == 0) {
|
||||
uiCfg.extruderIndex = 1;
|
||||
}
|
||||
else if (uiCfg.extruderIndex == 1) {
|
||||
if (TEMP_SENSOR_BED != 0) {
|
||||
uiCfg.curTempType = 1;
|
||||
}
|
||||
else {
|
||||
uiCfg.curTempType = 0;
|
||||
uiCfg.extruderIndex = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (uiCfg.extruderIndex == 0) {
|
||||
if (TEMP_SENSOR_BED != 0)
|
||||
uiCfg.curTempType = 1;
|
||||
else
|
||||
uiCfg.curTempType = 0;
|
||||
}
|
||||
}
|
||||
else if (uiCfg.curTempType == 1) {
|
||||
uiCfg.extruderIndex = 0;
|
||||
uiCfg.curTempType = 0;
|
||||
}
|
||||
disp_temp_type();
|
||||
break;
|
||||
case ID_P_STEP:
|
||||
switch (uiCfg.stepHeat) {
|
||||
case 1: uiCfg.stepHeat = 5; break;
|
||||
case 5: uiCfg.stepHeat = 10; break;
|
||||
case 10: uiCfg.stepHeat = 1; break;
|
||||
default: break;
|
||||
}
|
||||
disp_step_heat();
|
||||
break;
|
||||
case ID_P_OFF:
|
||||
if (uiCfg.curTempType == 0) {
|
||||
thermalManager.setTargetHotend(0, uiCfg.extruderIndex);
|
||||
thermalManager.start_watching_hotend(uiCfg.extruderIndex);
|
||||
}
|
||||
#if HAS_HEATED_BED
|
||||
else {
|
||||
thermalManager.temp_bed.target = 0;
|
||||
thermalManager.start_watching_bed();
|
||||
}
|
||||
#endif
|
||||
disp_desire_temp();
|
||||
break;
|
||||
case ID_P_RETURN:
|
||||
clear_cur_ui();
|
||||
draw_return_ui();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void lv_draw_preHeat() {
|
||||
scr = lv_screen_create(PRE_HEAT_UI);
|
||||
|
||||
// Create image buttons
|
||||
lv_big_button_create(scr, "F:/bmp_Add.bin", preheat_menu.add, INTERVAL_V, titleHeight, event_handler, ID_P_ADD);
|
||||
lv_big_button_create(scr, "F:/bmp_Dec.bin", preheat_menu.dec, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_P_DEC);
|
||||
|
||||
buttonType = lv_imgbtn_create(scr, nullptr, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_P_TYPE);
|
||||
buttonStep = lv_imgbtn_create(scr, nullptr, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_P_STEP);
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) {
|
||||
lv_group_add_obj(g, buttonType);
|
||||
lv_group_add_obj(g, buttonStep);
|
||||
}
|
||||
#endif
|
||||
|
||||
lv_big_button_create(scr, "F:/bmp_speed0.bin", preheat_menu.off, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_P_OFF);
|
||||
lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_P_RETURN);
|
||||
|
||||
// Create labels on the image buttons
|
||||
labelType = lv_label_create_empty(buttonType);
|
||||
labelStep = lv_label_create_empty(buttonStep);
|
||||
|
||||
disp_temp_type();
|
||||
disp_step_heat();
|
||||
|
||||
tempText1 = lv_label_create_empty(scr);
|
||||
lv_obj_set_style(tempText1, &tft_style_label_rel);
|
||||
disp_desire_temp();
|
||||
}
|
||||
|
||||
void disp_temp_type() {
|
||||
if (uiCfg.curTempType == 0) {
|
||||
if (uiCfg.extruderIndex == 1) {
|
||||
lv_imgbtn_set_src_both(buttonType, "F:/bmp_extru2.bin");
|
||||
if (gCfgItems.multiple_language) {
|
||||
lv_label_set_text(labelType, preheat_menu.ext2);
|
||||
lv_obj_align(labelType, buttonType, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
||||
}
|
||||
}
|
||||
else {
|
||||
lv_imgbtn_set_src_both(buttonType, "F:/bmp_extru1.bin");
|
||||
if (gCfgItems.multiple_language) {
|
||||
lv_label_set_text(labelType, preheat_menu.ext1);
|
||||
lv_obj_align(labelType, buttonType, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
lv_imgbtn_set_src_both(buttonType, "F:/bmp_bed.bin");
|
||||
if (gCfgItems.multiple_language) {
|
||||
lv_label_set_text(labelType, preheat_menu.hotbed);
|
||||
lv_obj_align(labelType, buttonType, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void disp_desire_temp() {
|
||||
char buf[20] = { 0 };
|
||||
public_buf_l[0] = '\0';
|
||||
|
||||
if (uiCfg.curTempType == 0) {
|
||||
strcat(public_buf_l, uiCfg.extruderIndex < 1 ? preheat_menu.ext1 : preheat_menu.ext2);
|
||||
sprintf(buf, preheat_menu.value_state, thermalManager.wholeDegHotend(uiCfg.extruderIndex), thermalManager.degTargetHotend(uiCfg.extruderIndex));
|
||||
}
|
||||
else {
|
||||
#if HAS_HEATED_BED
|
||||
strcat(public_buf_l, preheat_menu.hotbed);
|
||||
sprintf(buf, preheat_menu.value_state, thermalManager.wholeDegBed(), thermalManager.degTargetBed());
|
||||
#endif
|
||||
}
|
||||
strcat_P(public_buf_l, PSTR(": "));
|
||||
strcat(public_buf_l, buf);
|
||||
lv_label_set_text(tempText1, public_buf_l);
|
||||
lv_obj_align(tempText1, nullptr, LV_ALIGN_CENTER, 0, -50);
|
||||
}
|
||||
|
||||
void disp_step_heat() {
|
||||
if (uiCfg.stepHeat == 1) {
|
||||
lv_imgbtn_set_src_both(buttonStep, "F:/bmp_step1_degree.bin");
|
||||
}
|
||||
else if (uiCfg.stepHeat == 5) {
|
||||
lv_imgbtn_set_src_both(buttonStep, "F:/bmp_step5_degree.bin");
|
||||
}
|
||||
else if (uiCfg.stepHeat == 10) {
|
||||
lv_imgbtn_set_src_both(buttonStep, "F:/bmp_step10_degree.bin");
|
||||
}
|
||||
|
||||
if (gCfgItems.multiple_language) {
|
||||
if (uiCfg.stepHeat == 1) {
|
||||
lv_label_set_text(labelStep, preheat_menu.step_1c);
|
||||
lv_obj_align(labelStep, buttonStep, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
||||
}
|
||||
else if (uiCfg.stepHeat == 5) {
|
||||
lv_label_set_text(labelStep, preheat_menu.step_5c);
|
||||
lv_obj_align(labelStep, buttonStep, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
||||
}
|
||||
else if (uiCfg.stepHeat == 10) {
|
||||
lv_label_set_text(labelStep, preheat_menu.step_10c);
|
||||
lv_obj_align(labelStep, buttonStep, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void lv_clear_preHeat() {
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
|
||||
#endif
|
||||
lv_obj_del(scr);
|
||||
}
|
||||
|
||||
#endif // HAS_TFT_LVGL_UI
|
36
Marlin/src/lcd/extui/mks_ui/draw_preHeat.h
Normal file
36
Marlin/src/lcd/extui/mks_ui/draw_preHeat.h
Normal file
@ -0,0 +1,36 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* C-declarations for C++ */
|
||||
#endif
|
||||
|
||||
void lv_draw_preHeat();
|
||||
void lv_clear_preHeat();
|
||||
void disp_temp_type();
|
||||
void disp_step_heat();
|
||||
void disp_desire_temp();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C-declarations for C++ */
|
||||
#endif
|
554
Marlin/src/lcd/extui/mks_ui/draw_print_file.cpp
Normal file
554
Marlin/src/lcd/extui/mks_ui/draw_print_file.cpp
Normal file
@ -0,0 +1,554 @@
|
||||
/**
|
||||
* 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_TFT_LVGL_UI
|
||||
|
||||
#include "draw_ui.h"
|
||||
#include <lv_conf.h>
|
||||
//#include "../lvgl/src/lv_objx/lv_imgbtn.h"
|
||||
//#include "../lvgl/src/lv_objx/lv_img.h"
|
||||
//#include "../lvgl/src/lv_core/lv_disp.h"
|
||||
//#include "../lvgl/src/lv_core/lv_refr.h"
|
||||
|
||||
#include "../../../sd/cardreader.h"
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
static lv_obj_t *scr;
|
||||
extern lv_group_t* g;
|
||||
|
||||
static lv_obj_t *buttonPageUp, *buttonPageDown, *buttonBack,
|
||||
*buttonGcode[FILE_BTN_CNT], *labelPageUp[FILE_BTN_CNT], *buttonText[FILE_BTN_CNT];
|
||||
|
||||
enum {
|
||||
ID_P_UP = 7,
|
||||
ID_P_DOWN,
|
||||
ID_P_RETURN
|
||||
};
|
||||
|
||||
int8_t curDirLever = 0;
|
||||
LIST_FILE list_file;
|
||||
DIR_OFFSET dir_offset[10];
|
||||
|
||||
extern uint8_t public_buf[513];
|
||||
extern char public_buf_m[100];
|
||||
|
||||
uint8_t sel_id = 0;
|
||||
|
||||
#if ENABLED(SDSUPPORT)
|
||||
|
||||
static uint8_t search_file() {
|
||||
int valid_name_cnt = 0;
|
||||
//char tmp[SHORT_NEME_LEN*MAX_DIR_LEVEL+1];
|
||||
|
||||
list_file.Sd_file_cnt = 0;
|
||||
//list_file.Sd_file_offset = dir_offset[curDirLever].cur_page_first_offset;
|
||||
|
||||
//root2.rewind();
|
||||
//SERIAL_ECHOLN(list_file.curDirPath);
|
||||
|
||||
if (curDirLever != 0)
|
||||
card.cd(list_file.curDirPath);
|
||||
else
|
||||
card.cdroot();
|
||||
|
||||
const uint16_t fileCnt = card.get_num_Files();
|
||||
|
||||
for (uint16_t i = 0; i < fileCnt; i++) {
|
||||
if (list_file.Sd_file_cnt == list_file.Sd_file_offset) {
|
||||
card.getfilename_sorted(SD_ORDER(i, fileCnt));
|
||||
|
||||
list_file.IsFolder[valid_name_cnt] = card.flag.filenameIsDir;
|
||||
strcpy(list_file.file_name[valid_name_cnt], list_file.curDirPath);
|
||||
strcat_P(list_file.file_name[valid_name_cnt], PSTR("/"));
|
||||
strcat(list_file.file_name[valid_name_cnt], card.filename);
|
||||
strcpy(list_file.long_name[valid_name_cnt], card.longest_filename());
|
||||
|
||||
valid_name_cnt++;
|
||||
if (valid_name_cnt == 1)
|
||||
dir_offset[curDirLever].cur_page_first_offset = list_file.Sd_file_offset;
|
||||
if (valid_name_cnt >= FILE_NUM) {
|
||||
dir_offset[curDirLever].cur_page_last_offset = list_file.Sd_file_offset;
|
||||
list_file.Sd_file_offset++;
|
||||
break;
|
||||
}
|
||||
list_file.Sd_file_offset++;
|
||||
}
|
||||
list_file.Sd_file_cnt++;
|
||||
}
|
||||
//card.closefile(false);
|
||||
return valid_name_cnt;
|
||||
}
|
||||
|
||||
#endif // SDSUPPORT
|
||||
|
||||
bool have_pre_pic(char *path) {
|
||||
#if ENABLED(SDSUPPORT)
|
||||
char *ps1, *ps2, *cur_name = strrchr(path, '/');
|
||||
card.openFileRead(cur_name);
|
||||
card.read(public_buf, 512);
|
||||
ps1 = strstr((char *)public_buf, ";simage:");
|
||||
card.read(public_buf, 512);
|
||||
ps2 = strstr((char *)public_buf, ";simage:");
|
||||
card.closefile();
|
||||
if (ps1 || ps2) return true;
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void event_handler(lv_obj_t *obj, lv_event_t event) {
|
||||
if (event != LV_EVENT_RELEASED) return;
|
||||
uint8_t i, file_count = 0;
|
||||
//switch (obj->mks_obj_id)
|
||||
//{
|
||||
if (obj->mks_obj_id == ID_P_UP) {
|
||||
if (dir_offset[curDirLever].curPage > 0) {
|
||||
// 2015.05.19
|
||||
list_file.Sd_file_cnt = 0;
|
||||
|
||||
if (dir_offset[curDirLever].cur_page_first_offset >= FILE_NUM)
|
||||
list_file.Sd_file_offset = dir_offset[curDirLever].cur_page_first_offset - FILE_NUM;
|
||||
|
||||
#if ENABLED(SDSUPPORT)
|
||||
file_count = search_file();
|
||||
#endif
|
||||
if (file_count != 0) {
|
||||
dir_offset[curDirLever].curPage--;
|
||||
lv_clear_print_file();
|
||||
disp_gcode_icon(file_count);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (obj->mks_obj_id == ID_P_DOWN) {
|
||||
if (dir_offset[curDirLever].cur_page_last_offset > 0) {
|
||||
list_file.Sd_file_cnt = 0;
|
||||
list_file.Sd_file_offset = dir_offset[curDirLever].cur_page_last_offset + 1;
|
||||
#if ENABLED(SDSUPPORT)
|
||||
file_count = search_file();
|
||||
#endif
|
||||
if (file_count != 0) {
|
||||
dir_offset[curDirLever].curPage++;
|
||||
lv_clear_print_file();
|
||||
disp_gcode_icon(file_count);
|
||||
}
|
||||
if (file_count < FILE_NUM)
|
||||
dir_offset[curDirLever].cur_page_last_offset = 0;
|
||||
}
|
||||
}
|
||||
else if (obj->mks_obj_id == ID_P_RETURN) {
|
||||
if (curDirLever > 0) {
|
||||
int8_t *ch = (int8_t *)strrchr(list_file.curDirPath, '/');
|
||||
if (ch) {
|
||||
*ch = 0;
|
||||
#if ENABLED(SDSUPPORT)
|
||||
card.cdup();
|
||||
#endif
|
||||
dir_offset[curDirLever].curPage = 0;
|
||||
dir_offset[curDirLever].cur_page_first_offset = 0;
|
||||
dir_offset[curDirLever].cur_page_last_offset = 0;
|
||||
curDirLever--;
|
||||
list_file.Sd_file_offset = dir_offset[curDirLever].cur_page_first_offset;
|
||||
#if ENABLED(SDSUPPORT)
|
||||
file_count = search_file();
|
||||
#endif
|
||||
lv_clear_print_file();
|
||||
disp_gcode_icon(file_count);
|
||||
}
|
||||
}
|
||||
else {
|
||||
lv_clear_print_file();
|
||||
TERN(MULTI_VOLUME, lv_draw_media_select(), lv_draw_ready_print());
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (i = 0; i < FILE_BTN_CNT; i++) {
|
||||
if (obj->mks_obj_id == (i + 1)) {
|
||||
if (list_file.file_name[i][0] != 0) {
|
||||
if (list_file.IsFolder[i]) {
|
||||
strcpy(list_file.curDirPath, list_file.file_name[i]);
|
||||
curDirLever++;
|
||||
list_file.Sd_file_offset = dir_offset[curDirLever].cur_page_first_offset;
|
||||
#if ENABLED(SDSUPPORT)
|
||||
file_count = search_file();
|
||||
#endif
|
||||
lv_clear_print_file();
|
||||
disp_gcode_icon(file_count);
|
||||
}
|
||||
else {
|
||||
sel_id = i;
|
||||
lv_clear_print_file();
|
||||
lv_draw_dialog(DIALOG_TYPE_PRINT_FILE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void lv_draw_print_file() {
|
||||
//uint8_t i;
|
||||
uint8_t file_count;
|
||||
|
||||
curDirLever = 0;
|
||||
dir_offset[curDirLever].curPage = 0;
|
||||
|
||||
list_file.Sd_file_offset = 0;
|
||||
list_file.Sd_file_cnt = 0;
|
||||
|
||||
ZERO(dir_offset);
|
||||
ZERO(list_file.IsFolder);
|
||||
ZERO(list_file.curDirPath);
|
||||
|
||||
list_file.Sd_file_offset = dir_offset[curDirLever].cur_page_first_offset;
|
||||
#if ENABLED(SDSUPPORT)
|
||||
card.mount();
|
||||
file_count = search_file();
|
||||
#endif
|
||||
disp_gcode_icon(file_count);
|
||||
|
||||
//lv_obj_t *labelPageUp = lv_label_create_empty(buttonPageUp);
|
||||
//lv_obj_t *labelPageDown = lv_label_create_empty(buttonPageDown);
|
||||
//lv_obj_t *label_Back = lv_label_create_empty(buttonBack);
|
||||
|
||||
/*
|
||||
if (gCfgItems.multiple_language) {
|
||||
lv_label_set_text(labelPageUp, tool_menu.preheat);
|
||||
lv_obj_align(labelPageUp, buttonPageUp, LV_ALIGN_IN_BOTTOM_MID,0, BUTTON_TEXT_Y_OFFSET);
|
||||
|
||||
lv_label_set_text(labelPageDown, tool_menu.extrude);
|
||||
lv_obj_align(labelPageDown, buttonPageDown, LV_ALIGN_IN_BOTTOM_MID,0, BUTTON_TEXT_Y_OFFSET);
|
||||
|
||||
lv_label_set_text(label_Back, common_menu.text_back);
|
||||
lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID,0, BUTTON_TEXT_Y_OFFSET);
|
||||
}
|
||||
*/
|
||||
}
|
||||
static char test_public_buf_l[40];
|
||||
void disp_gcode_icon(uint8_t file_num) {
|
||||
uint8_t i;
|
||||
|
||||
// TODO: set current media title?!
|
||||
scr = lv_screen_create(PRINT_FILE_UI, "");
|
||||
|
||||
// Create image buttons
|
||||
buttonPageUp = lv_imgbtn_create(scr, "F:/bmp_pageUp.bin", OTHER_BTN_XPIEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_P_UP);
|
||||
buttonPageDown = lv_imgbtn_create(scr, "F:/bmp_pageDown.bin", OTHER_BTN_XPIEL * 3 + INTERVAL_V * 4, titleHeight + OTHER_BTN_YPIEL + INTERVAL_H, event_handler, ID_P_DOWN);
|
||||
buttonBack = lv_imgbtn_create(scr, "F:/bmp_back.bin", OTHER_BTN_XPIEL * 3 + INTERVAL_V * 4, titleHeight + OTHER_BTN_YPIEL * 2 + INTERVAL_H * 2, event_handler, ID_P_RETURN);
|
||||
|
||||
// Create labels on the image buttons
|
||||
for (i = 0; i < FILE_BTN_CNT; i++) {
|
||||
/*
|
||||
if (seq) {
|
||||
j = (FILE_BTN_CNT-1) - i;
|
||||
back_flg = 1;
|
||||
}
|
||||
else {
|
||||
j = i;
|
||||
back_flg = 0;
|
||||
}
|
||||
*/
|
||||
if (i >= file_num) break;
|
||||
|
||||
#ifdef TFT35
|
||||
buttonGcode[i] = lv_imgbtn_create(scr, nullptr);
|
||||
|
||||
lv_imgbtn_use_label_style(buttonGcode[i]);
|
||||
lv_obj_clear_protect(buttonGcode[i], LV_PROTECT_FOLLOW);
|
||||
lv_btn_set_layout(buttonGcode[i], LV_LAYOUT_OFF);
|
||||
|
||||
ZERO(public_buf_m);
|
||||
cutFileName((char *)list_file.long_name[i], 16, 8, (char *)public_buf_m);
|
||||
|
||||
if (list_file.IsFolder[i]) {
|
||||
lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), "", 0);
|
||||
lv_imgbtn_set_src_both(buttonGcode[i], "F:/bmp_dir.bin");
|
||||
if (i < 3)
|
||||
lv_obj_set_pos(buttonGcode[i], BTN_X_PIXEL * i + INTERVAL_V * (i + 1), titleHeight);
|
||||
else
|
||||
lv_obj_set_pos(buttonGcode[i], BTN_X_PIXEL * (i - 3) + INTERVAL_V * ((i - 3) + 1), BTN_Y_PIXEL + INTERVAL_H + titleHeight);
|
||||
|
||||
labelPageUp[i] = lv_label_create(buttonGcode[i], public_buf_m);
|
||||
lv_obj_align(labelPageUp[i], buttonGcode[i], LV_ALIGN_IN_BOTTOM_MID, 0, -5);
|
||||
}
|
||||
else {
|
||||
if (have_pre_pic((char *)list_file.file_name[i])) {
|
||||
|
||||
//lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), list_file.file_name[i], 1);
|
||||
|
||||
strcpy(test_public_buf_l, "S:");
|
||||
strcat(test_public_buf_l, list_file.file_name[i]);
|
||||
char *temp = strstr(test_public_buf_l, ".GCO");
|
||||
if (temp) strcpy(temp, ".bin");
|
||||
lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), test_public_buf_l, 0);
|
||||
lv_imgbtn_set_src_both(buttonGcode[i], buttonGcode[i]->mks_pic_name);
|
||||
if (i < 3) {
|
||||
lv_obj_set_pos(buttonGcode[i], BTN_X_PIXEL * i + INTERVAL_V * (i + 1) + FILE_PRE_PIC_X_OFFSET, titleHeight + FILE_PRE_PIC_Y_OFFSET);
|
||||
buttonText[i] = lv_btn_create(scr, nullptr);
|
||||
//lv_obj_set_event_cb(buttonText[i], event_handler);
|
||||
|
||||
lv_btn_use_label_style(buttonText[i]);
|
||||
lv_obj_clear_protect(buttonText[i], LV_PROTECT_FOLLOW);
|
||||
lv_btn_set_layout(buttonText[i], LV_LAYOUT_OFF);
|
||||
//lv_obj_set_event_cb_mks(buttonText[i], event_handler,(i+10),"", 0);
|
||||
lv_obj_set_pos(buttonText[i], BTN_X_PIXEL * i + INTERVAL_V * (i + 1) + FILE_PRE_PIC_X_OFFSET, titleHeight + FILE_PRE_PIC_Y_OFFSET + 100);
|
||||
lv_obj_set_size(buttonText[i], 100, 40);
|
||||
}
|
||||
else {
|
||||
lv_obj_set_pos(buttonGcode[i], BTN_X_PIXEL * (i - 3) + INTERVAL_V * ((i - 3) + 1) + FILE_PRE_PIC_X_OFFSET, BTN_Y_PIXEL + INTERVAL_H + titleHeight + FILE_PRE_PIC_Y_OFFSET);
|
||||
buttonText[i] = lv_btn_create(scr, nullptr);
|
||||
//lv_obj_set_event_cb(buttonText[i], event_handler);
|
||||
|
||||
lv_btn_use_label_style(buttonText[i]);
|
||||
lv_obj_clear_protect(buttonText[i], LV_PROTECT_FOLLOW);
|
||||
lv_btn_set_layout(buttonText[i], LV_LAYOUT_OFF);
|
||||
//lv_obj_set_event_cb_mks(buttonText[i], event_handler,(i+10),"", 0);
|
||||
lv_obj_set_pos(buttonText[i], BTN_X_PIXEL * (i - 3) + INTERVAL_V * ((i - 3) + 1) + FILE_PRE_PIC_X_OFFSET, BTN_Y_PIXEL + INTERVAL_H + titleHeight + FILE_PRE_PIC_Y_OFFSET + 100);
|
||||
lv_obj_set_size(buttonText[i], 100, 40);
|
||||
}
|
||||
labelPageUp[i] = lv_label_create(buttonText[i], public_buf_m);
|
||||
lv_obj_align(labelPageUp[i], buttonText[i], LV_ALIGN_IN_BOTTOM_MID, 0, 0);
|
||||
}
|
||||
else {
|
||||
lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), "", 0);
|
||||
lv_imgbtn_set_src_both(buttonGcode[i], "F:/bmp_file.bin");
|
||||
if (i < 3)
|
||||
lv_obj_set_pos(buttonGcode[i], BTN_X_PIXEL * i + INTERVAL_V * (i + 1), titleHeight);
|
||||
else
|
||||
lv_obj_set_pos(buttonGcode[i], BTN_X_PIXEL * (i - 3) + INTERVAL_V * ((i - 3) + 1), BTN_Y_PIXEL + INTERVAL_H + titleHeight);
|
||||
|
||||
labelPageUp[i] = lv_label_create(buttonGcode[i], public_buf_m);
|
||||
lv_obj_align(labelPageUp[i], buttonGcode[i], LV_ALIGN_IN_BOTTOM_MID, 0, -5);
|
||||
}
|
||||
}
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonGcode[i]);
|
||||
#endif
|
||||
|
||||
#else // !TFT35
|
||||
#endif // !TFT35
|
||||
}
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) {
|
||||
lv_group_add_obj(g, buttonPageUp);
|
||||
lv_group_add_obj(g, buttonPageDown);
|
||||
lv_group_add_obj(g, buttonBack);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
uint32_t lv_open_gcode_file(char *path) {
|
||||
#if ENABLED(SDSUPPORT)
|
||||
uint32_t *ps4;
|
||||
uint32_t pre_sread_cnt = UINT32_MAX;
|
||||
char *cur_name;
|
||||
|
||||
cur_name = strrchr(path, '/');
|
||||
|
||||
card.openFileRead(cur_name);
|
||||
card.read(public_buf, 512);
|
||||
ps4 = (uint32_t *)strstr((char *)public_buf, ";simage:");
|
||||
// Ignore the beginning message of gcode file
|
||||
if (ps4) {
|
||||
pre_sread_cnt = (uint32_t)ps4 - (uint32_t)((uint32_t *)(&public_buf[0]));
|
||||
card.setIndex(pre_sread_cnt);
|
||||
}
|
||||
return pre_sread_cnt;
|
||||
#endif // SDSUPPORT
|
||||
}
|
||||
|
||||
int ascii2dec_test(char *ascii) {
|
||||
int result = 0;
|
||||
if (ascii == 0) return 0;
|
||||
|
||||
if (*(ascii) >= '0' && *(ascii) <= '9')
|
||||
result = *(ascii) - '0';
|
||||
else if (*(ascii) >= 'a' && *(ascii) <= 'f')
|
||||
result = *(ascii) - 'a' + 0x0A;
|
||||
else if (*(ascii) >= 'A' && *(ascii) <= 'F')
|
||||
result = *(ascii) - 'A' + 0x0A;
|
||||
else
|
||||
return 0;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void lv_gcode_file_read(uint8_t *data_buf) {
|
||||
#if ENABLED(SDSUPPORT)
|
||||
uint16_t i = 0, j = 0, k = 0;
|
||||
uint16_t row_1 = 0;
|
||||
bool ignore_start = true;
|
||||
char temp_test[200];
|
||||
volatile uint16_t *p_index;
|
||||
|
||||
watchdog_refresh();
|
||||
memset(public_buf, 0, 200);
|
||||
|
||||
while (card.isFileOpen()) {
|
||||
if (ignore_start) card.read(temp_test, 8); // line start -> ignore
|
||||
card.read(temp_test, 200); // data
|
||||
// \r;;gimage: we got the bit img, so stop here
|
||||
if (temp_test[1] == ';') {
|
||||
card.closefile();
|
||||
break;
|
||||
}
|
||||
for (i = 0; i < 200;) {
|
||||
public_buf[row_1 * 200 + 100 * k + j] = (char)(ascii2dec_test(&temp_test[i]) << 4 | ascii2dec_test(&temp_test[i + 1]));
|
||||
j++;
|
||||
i += 2;
|
||||
}
|
||||
|
||||
uint16_t c = card.get();
|
||||
// check for more data or end of line (CR or LF)
|
||||
if (ISEOL(c)) {
|
||||
c = card.get(); // more eol?
|
||||
if (!ISEOL(c)) card.setIndex(card.getIndex() - 1);
|
||||
break;
|
||||
}
|
||||
card.setIndex(card.getIndex() - 1);
|
||||
k++;
|
||||
j = 0;
|
||||
ignore_start = false;
|
||||
if (k > 1) {
|
||||
card.closefile();
|
||||
break;
|
||||
}
|
||||
}
|
||||
#if HAS_TFT_LVGL_UI_SPI
|
||||
for (i = 0; i < 200;) {
|
||||
p_index = (uint16_t *)(&public_buf[i]);
|
||||
|
||||
//Color = (*p_index >> 8);
|
||||
//*p_index = Color | ((*p_index & 0xFF) << 8);
|
||||
i += 2;
|
||||
if (*p_index == 0x0000) *p_index = LV_COLOR_BACKGROUND.full;
|
||||
}
|
||||
#else // !HAS_TFT_LVGL_UI_SPI
|
||||
for (i = 0; i < 200;) {
|
||||
p_index = (uint16_t *)(&public_buf[i]);
|
||||
//Color = (*p_index >> 8);
|
||||
//*p_index = Color | ((*p_index & 0xFF) << 8);
|
||||
i += 2;
|
||||
if (*p_index == 0x0000) *p_index = LV_COLOR_BACKGROUND.full; // 0x18C3;
|
||||
}
|
||||
#endif // !HAS_TFT_LVGL_UI_SPI
|
||||
memcpy(data_buf, public_buf, 200);
|
||||
#endif // SDSUPPORT
|
||||
}
|
||||
|
||||
void lv_close_gcode_file() {TERN_(SDSUPPORT, card.closefile());}
|
||||
|
||||
void lv_gcode_file_seek(uint32_t pos) {
|
||||
card.setIndex(pos);
|
||||
}
|
||||
|
||||
void cutFileName(char *path, int len, int bytePerLine, char *outStr) {
|
||||
#if _LFN_UNICODE
|
||||
TCHAR *tmpFile;
|
||||
TCHAR *strIndex1 = 0, *strIndex2 = 0, *beginIndex;
|
||||
TCHAR secSeg[10] = {0};
|
||||
TCHAR gFileTail[4] = {'~', '.', 'g', '\0'};
|
||||
#else
|
||||
char *tmpFile;
|
||||
char *strIndex1 = 0, *strIndex2 = 0, *beginIndex;
|
||||
char secSeg[10] = {0};
|
||||
#endif
|
||||
|
||||
if (path == 0 || len <= 3 || outStr == 0) return;
|
||||
|
||||
tmpFile = path;
|
||||
#if _LFN_UNICODE
|
||||
strIndex1 = (WCHAR *)wcsstr((const WCHAR *)tmpFile, (const WCHAR *)'/');
|
||||
strIndex2 = (WCHAR *)wcsstr((const WCHAR *)tmpFile, (const WCHAR *)'.');
|
||||
#else
|
||||
strIndex1 = (char *)strrchr(tmpFile, '/');
|
||||
strIndex2 = (char *)strrchr(tmpFile, '.');
|
||||
#endif
|
||||
|
||||
beginIndex = (strIndex1 != 0
|
||||
//&& (strIndex2 != 0) && (strIndex1 < strIndex2)
|
||||
) ? strIndex1 + 1 : tmpFile;
|
||||
|
||||
if (strIndex2 == 0 || (strIndex1 > strIndex2)) { // not gcode file
|
||||
#if _LFN_UNICODE
|
||||
if (wcslen(beginIndex) > len)
|
||||
wcsncpy(outStr, beginIndex, len);
|
||||
else
|
||||
wcscpy(outStr, beginIndex);
|
||||
#else
|
||||
if ((int)strlen(beginIndex) > len)
|
||||
strncpy(outStr, beginIndex, len);
|
||||
else
|
||||
strcpy(outStr, beginIndex);
|
||||
#endif
|
||||
}
|
||||
else { // gcode file
|
||||
if (strIndex2 - beginIndex > (len - 2)) {
|
||||
#if _LFN_UNICODE
|
||||
wcsncpy(outStr, (const WCHAR *)beginIndex, len - 3);
|
||||
wcscat(outStr, (const WCHAR *)gFileTail);
|
||||
#else
|
||||
//strncpy(outStr, beginIndex, len - 3);
|
||||
strncpy(outStr, beginIndex, len - 4);
|
||||
strcat_P(outStr, PSTR("~.g"));
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
#if _LFN_UNICODE
|
||||
wcsncpy(outStr, (const WCHAR *)beginIndex, strIndex2 - beginIndex + 1);
|
||||
wcscat(outStr, (const WCHAR *)&gFileTail[3]);
|
||||
#else
|
||||
strncpy(outStr, beginIndex, strIndex2 - beginIndex + 1);
|
||||
strcat_P(outStr, PSTR("g"));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#if _LFN_UNICODE
|
||||
if (wcslen(outStr) > bytePerLine) {
|
||||
wcscpy(secSeg, (const WCHAR *)&outStr[bytePerLine]);
|
||||
outStr[bytePerLine] = '\n';
|
||||
outStr[bytePerLine + 1] = '\0';
|
||||
wcscat(outStr, (const WCHAR *)secSeg);
|
||||
}
|
||||
#else
|
||||
if ((int)strlen(outStr) > bytePerLine) {
|
||||
strcpy(secSeg, &outStr[bytePerLine]);
|
||||
outStr[bytePerLine] = '\n';
|
||||
outStr[bytePerLine + 1] = '\0';
|
||||
strcat(outStr, secSeg);
|
||||
}
|
||||
else {
|
||||
strcat_P(outStr, PSTR("\n"));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void lv_clear_print_file() {
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
|
||||
#endif
|
||||
lv_obj_del(scr);
|
||||
}
|
||||
|
||||
#endif // HAS_TFT_LVGL_UI
|
64
Marlin/src/lcd/extui/mks_ui/draw_print_file.h
Normal file
64
Marlin/src/lcd/extui/mks_ui/draw_print_file.h
Normal file
@ -0,0 +1,64 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* C-declarations for C++ */
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
int cur_page_first_offset;
|
||||
int cur_page_last_offset;
|
||||
int curPage;
|
||||
} DIR_OFFSET;
|
||||
extern DIR_OFFSET dir_offset[10];
|
||||
|
||||
#define FILE_NUM 6
|
||||
#define SHORT_NAME_LEN 13
|
||||
#define NAME_CUT_LEN 23
|
||||
|
||||
#define MAX_DIR_LEVEL 10
|
||||
|
||||
typedef struct {
|
||||
char file_name[FILE_NUM][SHORT_NAME_LEN * MAX_DIR_LEVEL + 1];
|
||||
char curDirPath[SHORT_NAME_LEN * MAX_DIR_LEVEL + 1];
|
||||
char long_name[FILE_NUM][SHORT_NAME_LEN * 2 + 1];
|
||||
bool IsFolder[FILE_NUM];
|
||||
char Sd_file_cnt;
|
||||
char sd_file_index;
|
||||
char Sd_file_offset;
|
||||
} LIST_FILE;
|
||||
extern LIST_FILE list_file;
|
||||
|
||||
void disp_gcode_icon(uint8_t file_num);
|
||||
void lv_draw_print_file();
|
||||
uint32_t lv_open_gcode_file(char *path);
|
||||
void lv_gcode_file_read(uint8_t *data_buf);
|
||||
void lv_close_gcode_file();
|
||||
void cutFileName(char *path, int len, int bytePerLine, char *outStr);
|
||||
int ascii2dec_test(char *ascii);
|
||||
void lv_clear_print_file();
|
||||
void lv_gcode_file_seek(uint32_t pos);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C-declarations for C++ */
|
||||
#endif
|
324
Marlin/src/lcd/extui/mks_ui/draw_printing.cpp
Normal file
324
Marlin/src/lcd/extui/mks_ui/draw_printing.cpp
Normal file
@ -0,0 +1,324 @@
|
||||
/**
|
||||
* 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_TFT_LVGL_UI
|
||||
|
||||
#include "draw_ui.h"
|
||||
#include <lv_conf.h>
|
||||
|
||||
#include "../../../MarlinCore.h" // for marlin_state
|
||||
#include "../../../module/temperature.h"
|
||||
#include "../../../module/motion.h"
|
||||
#include "../../../sd/cardreader.h"
|
||||
#include "../../../gcode/queue.h"
|
||||
#include "../../../gcode/gcode.h"
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(POWER_LOSS_RECOVERY)
|
||||
#include "../../../feature/powerloss.h"
|
||||
#endif
|
||||
|
||||
#if BOTH(LCD_SET_PROGRESS_MANUALLY, USE_M73_REMAINING_TIME)
|
||||
#include "../../marlinui.h"
|
||||
#endif
|
||||
|
||||
extern lv_group_t *g;
|
||||
static lv_obj_t *scr;
|
||||
static lv_obj_t *labelExt1, *labelFan, *labelZpos, *labelTime;
|
||||
static lv_obj_t *labelPause, *labelStop, *labelOperat;
|
||||
static lv_obj_t *bar1, *bar1ValueText;
|
||||
static lv_obj_t *buttonPause, *buttonOperat, *buttonStop, *buttonExt1, *buttonExt2, *buttonBedstate, *buttonFanstate, *buttonZpos;
|
||||
|
||||
#if ENABLED(HAS_MULTI_EXTRUDER)
|
||||
static lv_obj_t *labelExt2;
|
||||
#endif
|
||||
|
||||
#if HAS_HEATED_BED
|
||||
static lv_obj_t* labelBed;
|
||||
#endif
|
||||
|
||||
enum {
|
||||
ID_PAUSE = 1,
|
||||
ID_STOP,
|
||||
ID_OPTION,
|
||||
ID_TEMP_EXT,
|
||||
ID_TEMP_BED,
|
||||
ID_BABYSTEP,
|
||||
ID_FAN
|
||||
};
|
||||
|
||||
bool once_flag; // = false
|
||||
extern bool flash_preview_begin, default_preview_flg, gcode_preview_over;
|
||||
extern uint32_t To_pre_view;
|
||||
|
||||
static void event_handler(lv_obj_t *obj, lv_event_t event) {
|
||||
if (event != LV_EVENT_RELEASED) return;
|
||||
if (gcode_preview_over) return;
|
||||
switch (obj->mks_obj_id) {
|
||||
case ID_PAUSE:
|
||||
if (uiCfg.print_state == WORKING) {
|
||||
#if ENABLED(SDSUPPORT)
|
||||
card.pauseSDPrint();
|
||||
stop_print_time();
|
||||
uiCfg.print_state = PAUSING;
|
||||
#endif
|
||||
lv_imgbtn_set_src_both(buttonPause, "F:/bmp_resume.bin");
|
||||
lv_label_set_text(labelPause, printing_menu.resume);
|
||||
lv_obj_align(labelPause, buttonPause, LV_ALIGN_CENTER, 30, 0);
|
||||
}
|
||||
else if (uiCfg.print_state == PAUSED) {
|
||||
uiCfg.print_state = RESUMING;
|
||||
lv_imgbtn_set_src_both(obj, "F:/bmp_pause.bin");
|
||||
lv_label_set_text(labelPause, printing_menu.pause);
|
||||
lv_obj_align(labelPause, buttonPause, LV_ALIGN_CENTER, 30, 0);
|
||||
}
|
||||
#if ENABLED(POWER_LOSS_RECOVERY)
|
||||
else if (uiCfg.print_state == REPRINTING) {
|
||||
uiCfg.print_state = REPRINTED;
|
||||
lv_imgbtn_set_src_both(obj, "F:/bmp_pause.bin");
|
||||
lv_label_set_text(labelPause, printing_menu.pause);
|
||||
lv_obj_align(labelPause, buttonPause, LV_ALIGN_CENTER, 30, 0);
|
||||
print_time.minutes = recovery.info.print_job_elapsed / 60;
|
||||
print_time.seconds = recovery.info.print_job_elapsed % 60;
|
||||
print_time.hours = print_time.minutes / 60;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case ID_STOP:
|
||||
lv_clear_printing();
|
||||
lv_draw_dialog(DIALOG_TYPE_STOP);
|
||||
break;
|
||||
case ID_OPTION:
|
||||
lv_clear_printing();
|
||||
lv_draw_operation();
|
||||
break;
|
||||
case ID_TEMP_EXT:
|
||||
uiCfg.curTempType = 0;
|
||||
lv_clear_printing();
|
||||
lv_draw_preHeat();
|
||||
break;
|
||||
case ID_TEMP_BED:
|
||||
uiCfg.curTempType = 1;
|
||||
lv_clear_printing();
|
||||
lv_draw_preHeat();
|
||||
break;
|
||||
case ID_BABYSTEP:
|
||||
lv_clear_printing();
|
||||
lv_draw_baby_stepping();
|
||||
break;
|
||||
case ID_FAN:
|
||||
lv_clear_printing();
|
||||
lv_draw_fan();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void lv_draw_printing() {
|
||||
disp_state_stack._disp_index = 0;
|
||||
ZERO(disp_state_stack._disp_state);
|
||||
scr = lv_screen_create(PRINTING_UI);
|
||||
|
||||
// Create image buttons
|
||||
buttonExt1 = lv_imgbtn_create(scr, "F:/bmp_ext1_state.bin", 206, 136, event_handler, ID_TEMP_EXT);
|
||||
|
||||
#if HAS_MULTI_EXTRUDER
|
||||
buttonExt2 = lv_imgbtn_create(scr, "F:/bmp_ext2_state.bin", 350, 136, event_handler, ID_TEMP_EXT);
|
||||
#endif
|
||||
|
||||
#if HAS_HEATED_BED
|
||||
buttonBedstate = lv_imgbtn_create(scr, "F:/bmp_bed_state.bin", 206, 186, event_handler, ID_TEMP_BED);
|
||||
#endif
|
||||
|
||||
buttonFanstate = lv_imgbtn_create(scr, "F:/bmp_fan_state.bin", 350, 186, event_handler, ID_FAN);
|
||||
|
||||
lv_obj_t *buttonTime = lv_img_create(scr, nullptr);
|
||||
lv_img_set_src(buttonTime, "F:/bmp_time_state.bin");
|
||||
lv_obj_set_pos(buttonTime, 206, 86);
|
||||
|
||||
buttonZpos = lv_imgbtn_create(scr, "F:/bmp_zpos_state.bin", 350, 86, event_handler, ID_BABYSTEP);
|
||||
|
||||
buttonPause = lv_imgbtn_create(scr, uiCfg.print_state == WORKING ? "F:/bmp_pause.bin" : "F:/bmp_resume.bin", 5, 240, event_handler, ID_PAUSE);
|
||||
buttonStop = lv_imgbtn_create(scr, "F:/bmp_stop.bin", 165, 240, event_handler, ID_STOP);
|
||||
buttonOperat = lv_imgbtn_create(scr, "F:/bmp_operate.bin", 325, 240, event_handler, ID_OPTION);
|
||||
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) {
|
||||
lv_group_add_obj(g, buttonPause);
|
||||
lv_group_add_obj(g, buttonStop);
|
||||
lv_group_add_obj(g, buttonOperat);
|
||||
lv_group_add_obj(g, buttonPause);
|
||||
lv_group_add_obj(g, buttonPause);
|
||||
lv_group_add_obj(g, buttonPause);
|
||||
}
|
||||
#endif
|
||||
|
||||
labelExt1 = lv_label_create(scr, 250, 146, nullptr);
|
||||
|
||||
#if HAS_MULTI_EXTRUDER
|
||||
labelExt2 = lv_label_create(scr, 395, 146, nullptr);
|
||||
#endif
|
||||
|
||||
#if HAS_HEATED_BED
|
||||
labelBed = lv_label_create(scr, 250, 196, nullptr);
|
||||
#endif
|
||||
|
||||
labelFan = lv_label_create(scr, 395, 196, nullptr);
|
||||
labelTime = lv_label_create(scr, 250, 96, nullptr);
|
||||
labelZpos = lv_label_create(scr, 395, 96, nullptr);
|
||||
|
||||
labelPause = lv_label_create_empty(buttonPause);
|
||||
labelStop = lv_label_create_empty(buttonStop);
|
||||
labelOperat = lv_label_create_empty(buttonOperat);
|
||||
|
||||
if (gCfgItems.multiple_language) {
|
||||
lv_label_set_text(labelPause, uiCfg.print_state == WORKING ? printing_menu.pause : printing_menu.resume);
|
||||
lv_obj_align(labelPause, buttonPause, LV_ALIGN_CENTER, 20, 0);
|
||||
|
||||
lv_label_set_text(labelStop, printing_menu.stop);
|
||||
lv_obj_align(labelStop, buttonStop, LV_ALIGN_CENTER, 20, 0);
|
||||
|
||||
lv_label_set_text(labelOperat, printing_menu.option);
|
||||
lv_obj_align(labelOperat, buttonOperat, LV_ALIGN_CENTER, 20, 0);
|
||||
}
|
||||
|
||||
bar1 = lv_bar_create(scr, nullptr);
|
||||
lv_obj_set_pos(bar1, 205, 36);
|
||||
lv_obj_set_size(bar1, 270, 40);
|
||||
lv_bar_set_style(bar1, LV_BAR_STYLE_INDIC, &lv_bar_style_indic);
|
||||
lv_bar_set_anim_time(bar1, 1000);
|
||||
lv_bar_set_value(bar1, 0, LV_ANIM_ON);
|
||||
bar1ValueText = lv_label_create_empty(bar1);
|
||||
lv_label_set_text(bar1ValueText,"0%");
|
||||
lv_obj_align(bar1ValueText, bar1, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
disp_ext_temp();
|
||||
disp_bed_temp();
|
||||
disp_fan_speed();
|
||||
disp_print_time();
|
||||
disp_fan_Zpos();
|
||||
}
|
||||
|
||||
void disp_ext_temp() {
|
||||
sprintf(public_buf_l, printing_menu.temp1, thermalManager.wholeDegHotend(0), thermalManager.degTargetHotend(0));
|
||||
lv_label_set_text(labelExt1, public_buf_l);
|
||||
|
||||
#if HAS_MULTI_EXTRUDER
|
||||
sprintf(public_buf_l, printing_menu.temp1, thermalManager.wholeDegHotend(1), thermalManager.degTargetHotend(1));
|
||||
lv_label_set_text(labelExt2, public_buf_l);
|
||||
#endif
|
||||
}
|
||||
|
||||
void disp_bed_temp() {
|
||||
#if HAS_HEATED_BED
|
||||
sprintf(public_buf_l, printing_menu.bed_temp, thermalManager.wholeDegBed(), thermalManager.degTargetBed());
|
||||
lv_label_set_text(labelBed, public_buf_l);
|
||||
#endif
|
||||
}
|
||||
|
||||
void disp_fan_speed() {
|
||||
sprintf_P(public_buf_l, PSTR("%d%%"), (int)thermalManager.fanSpeedPercent(0));
|
||||
lv_label_set_text(labelFan, public_buf_l);
|
||||
}
|
||||
|
||||
void disp_print_time() {
|
||||
#if BOTH(LCD_SET_PROGRESS_MANUALLY, USE_M73_REMAINING_TIME)
|
||||
const uint32_t r = ui.get_remaining_time();
|
||||
sprintf_P(public_buf_l, PSTR("%02d:%02d R"), r / 3600, (r % 3600) / 60);
|
||||
#else
|
||||
sprintf_P(public_buf_l, PSTR("%d%d:%d%d:%d%d"), print_time.hours / 10, print_time.hours % 10, print_time.minutes / 10, print_time.minutes % 10, print_time.seconds / 10, print_time.seconds % 10);
|
||||
#endif
|
||||
lv_label_set_text(labelTime, public_buf_l);
|
||||
}
|
||||
|
||||
void disp_fan_Zpos() {
|
||||
dtostrf(current_position.z, 1, 3, public_buf_l);
|
||||
lv_label_set_text(labelZpos, public_buf_l);
|
||||
}
|
||||
|
||||
void reset_print_time() {
|
||||
print_time.hours = 0;
|
||||
print_time.minutes = 0;
|
||||
print_time.seconds = 0;
|
||||
print_time.ms_10 = 0;
|
||||
}
|
||||
|
||||
void start_print_time() { print_time.start = 1; }
|
||||
|
||||
void stop_print_time() { print_time.start = 0; }
|
||||
|
||||
void setProBarRate() {
|
||||
int rate;
|
||||
volatile long long rate_tmp_r;
|
||||
|
||||
if (!gCfgItems.from_flash_pic) {
|
||||
#if ENABLED(SDSUPPORT)
|
||||
rate_tmp_r = (long long)card.getIndex() * 100;
|
||||
#endif
|
||||
rate = rate_tmp_r / gCfgItems.curFilesize;
|
||||
}
|
||||
else {
|
||||
#if ENABLED(SDSUPPORT)
|
||||
rate_tmp_r = (long long)card.getIndex();
|
||||
#endif
|
||||
rate = (rate_tmp_r - (PREVIEW_SIZE + To_pre_view)) * 100 / (gCfgItems.curFilesize - (PREVIEW_SIZE + To_pre_view));
|
||||
}
|
||||
|
||||
if (rate <= 0) return;
|
||||
|
||||
if (disp_state == PRINTING_UI) {
|
||||
lv_bar_set_value(bar1, rate, LV_ANIM_ON);
|
||||
sprintf_P(public_buf_l, "%d%%", rate);
|
||||
lv_label_set_text(bar1ValueText,public_buf_l);
|
||||
lv_obj_align(bar1ValueText, bar1, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
if (marlin_state == MF_SD_COMPLETE) {
|
||||
if (once_flag == 0) {
|
||||
stop_print_time();
|
||||
|
||||
flash_preview_begin = false;
|
||||
default_preview_flg = false;
|
||||
lv_clear_printing();
|
||||
lv_draw_dialog(DIALOG_TYPE_FINISH_PRINT);
|
||||
|
||||
once_flag = true;
|
||||
|
||||
#if HAS_SUICIDE
|
||||
if (gCfgItems.finish_power_off) {
|
||||
gcode.process_subcommands_now_P(PSTR("M1001"));
|
||||
queue.inject_P(PSTR("M81"));
|
||||
marlin_state = MF_RUNNING;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void lv_clear_printing() {
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
|
||||
#endif
|
||||
lv_obj_del(scr);
|
||||
}
|
||||
|
||||
#endif // HAS_TFT_LVGL_UI
|
53
Marlin/src/lcd/extui/mks_ui/draw_printing.h
Normal file
53
Marlin/src/lcd/extui/mks_ui/draw_printing.h
Normal file
@ -0,0 +1,53 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* C-declarations for C++ */
|
||||
#endif
|
||||
|
||||
enum {
|
||||
IDLE,
|
||||
WORKING,
|
||||
PAUSING,
|
||||
PAUSED,
|
||||
REPRINTING,
|
||||
REPRINTED,
|
||||
RESUMING,
|
||||
STOP
|
||||
};
|
||||
|
||||
void lv_draw_printing();
|
||||
void lv_clear_printing();
|
||||
void disp_ext_temp();
|
||||
void disp_bed_temp();
|
||||
void disp_fan_speed();
|
||||
void disp_print_time();
|
||||
void disp_fan_Zpos();
|
||||
void reset_print_time();
|
||||
void start_print_time();
|
||||
void stop_print_time();
|
||||
void setProBarRate();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C-declarations for C++ */
|
||||
#endif
|
280
Marlin/src/lcd/extui/mks_ui/draw_ready_print.cpp
Normal file
280
Marlin/src/lcd/extui/mks_ui/draw_ready_print.cpp
Normal file
@ -0,0 +1,280 @@
|
||||
/**
|
||||
* 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_TFT_LVGL_UI
|
||||
|
||||
#include "draw_ready_print.h"
|
||||
#include "draw_tool.h"
|
||||
#include <lv_conf.h>
|
||||
#include "tft_lvgl_configuration.h"
|
||||
#include "mks_hardware_test.h"
|
||||
#include "draw_ui.h"
|
||||
|
||||
#include <lvgl.h>
|
||||
|
||||
#include "../../../module/temperature.h"
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
|
||||
#include "../../tft_io/touch_calibration.h"
|
||||
#include "draw_touch_calibration.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define ICON_POS_Y 38
|
||||
#define TARGET_LABEL_MOD_Y -36
|
||||
#define LABEL_MOD_Y 30
|
||||
|
||||
extern lv_group_t* g;
|
||||
static lv_obj_t *scr;
|
||||
static lv_obj_t *labelExt1, *labelExt1Target, *labelFan;
|
||||
|
||||
#if HAS_MULTI_EXTRUDER
|
||||
static lv_obj_t *labelExt2, *labelExt2Target;
|
||||
#endif
|
||||
|
||||
#if HAS_HEATED_BED
|
||||
static lv_obj_t *labelBed, *labelBedTarget;
|
||||
#endif
|
||||
|
||||
#if ENABLED(MKS_TEST)
|
||||
uint8_t curent_disp_ui = 0;
|
||||
#endif
|
||||
|
||||
enum { ID_TOOL = 1, ID_SET, ID_PRINT, ID_INFO_EXT, ID_INFO_BED, ID_INFO_FAN };
|
||||
|
||||
static void event_handler(lv_obj_t *obj, lv_event_t event) {
|
||||
if (event != LV_EVENT_RELEASED) return;
|
||||
lv_clear_ready_print();
|
||||
switch (obj->mks_obj_id) {
|
||||
case ID_TOOL: lv_draw_tool(); break;
|
||||
case ID_SET: lv_draw_set(); break;
|
||||
case ID_INFO_EXT: uiCfg.curTempType = 0; lv_draw_preHeat(); break;
|
||||
case ID_INFO_BED: uiCfg.curTempType = 1; lv_draw_preHeat(); break;
|
||||
case ID_INFO_FAN: lv_draw_fan(); break;
|
||||
case ID_PRINT: TERN(MULTI_VOLUME, lv_draw_media_select(), lv_draw_print_file()); break;
|
||||
}
|
||||
}
|
||||
|
||||
lv_obj_t *limit_info, *det_info;
|
||||
lv_style_t limit_style, det_style;
|
||||
void disp_Limit_ok() {
|
||||
limit_style.text.color.full = 0xFFFF;
|
||||
lv_obj_set_style(limit_info, &limit_style);
|
||||
lv_label_set_text(limit_info, "Limit:ok");
|
||||
}
|
||||
void disp_Limit_error() {
|
||||
limit_style.text.color.full = 0xF800;
|
||||
lv_obj_set_style(limit_info, &limit_style);
|
||||
lv_label_set_text(limit_info, "Limit:error");
|
||||
}
|
||||
|
||||
void disp_det_ok() {
|
||||
det_style.text.color.full = 0xFFFF;
|
||||
lv_obj_set_style(det_info, &det_style);
|
||||
lv_label_set_text(det_info, "det:ok");
|
||||
}
|
||||
void disp_det_error() {
|
||||
det_style.text.color.full = 0xF800;
|
||||
lv_obj_set_style(det_info, &det_style);
|
||||
lv_label_set_text(det_info, "det:error");
|
||||
}
|
||||
|
||||
lv_obj_t *e1, *e2, *e3, *bed;
|
||||
void mks_disp_test() {
|
||||
char buf[30] = {0};
|
||||
sprintf_P(buf, PSTR("e1:%d"), thermalManager.wholeDegHotend(0));
|
||||
lv_label_set_text(e1, buf);
|
||||
#if HAS_MULTI_HOTEND
|
||||
sprintf_P(buf, PSTR("e2:%d"), thermalManager.wholeDegHotend(1));
|
||||
lv_label_set_text(e2, buf);
|
||||
#endif
|
||||
#if HAS_HEATED_BED
|
||||
sprintf_P(buf, PSTR("bed:%d"), thermalManager.wholeDegBed());
|
||||
lv_label_set_text(bed, buf);
|
||||
#endif
|
||||
}
|
||||
|
||||
void lv_draw_ready_print() {
|
||||
char buf[30] = {0};
|
||||
lv_obj_t *buttonTool;
|
||||
|
||||
disp_state_stack._disp_index = 0;
|
||||
ZERO(disp_state_stack._disp_state);
|
||||
scr = lv_screen_create(PRINT_READY_UI, "");
|
||||
|
||||
if (mks_test_flag == 0x1E) {
|
||||
// Create image buttons
|
||||
buttonTool = lv_imgbtn_create(scr, "F:/bmp_tool.bin", event_handler, ID_TOOL);
|
||||
|
||||
lv_obj_set_pos(buttonTool, 360, 180);
|
||||
|
||||
lv_obj_t *label_tool = lv_label_create_empty(buttonTool);
|
||||
if (gCfgItems.multiple_language) {
|
||||
lv_label_set_text(label_tool, main_menu.tool);
|
||||
lv_obj_align(label_tool, buttonTool, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
||||
}
|
||||
|
||||
e1 = lv_label_create_empty(scr);
|
||||
lv_obj_set_pos(e1, 20, 20);
|
||||
sprintf_P(buf, PSTR("e1: %d"), thermalManager.wholeDegHotend(0));
|
||||
lv_label_set_text(e1, buf);
|
||||
|
||||
#if HAS_MULTI_HOTEND
|
||||
e2 = lv_label_create_empty(scr);
|
||||
lv_obj_set_pos(e2, 20, 45);
|
||||
sprintf_P(buf, PSTR("e1: %d"), thermalManager.wholeDegHotend(1));
|
||||
lv_label_set_text(e2, buf);
|
||||
#endif
|
||||
|
||||
#if HAS_HEATED_BED
|
||||
bed = lv_label_create_empty(scr);
|
||||
lv_obj_set_pos(bed, 20, 95);
|
||||
sprintf_P(buf, PSTR("bed: %d"), thermalManager.wholeDegBed());
|
||||
lv_label_set_text(bed, buf);
|
||||
#endif
|
||||
|
||||
limit_info = lv_label_create_empty(scr);
|
||||
|
||||
lv_style_copy(&limit_style, &lv_style_scr);
|
||||
limit_style.body.main_color.full = 0x0000;
|
||||
limit_style.body.grad_color.full = 0x0000;
|
||||
limit_style.text.color.full = 0xFFFF;
|
||||
lv_obj_set_style(limit_info, &limit_style);
|
||||
|
||||
lv_obj_set_pos(limit_info, 20, 120);
|
||||
lv_label_set_text(limit_info, " ");
|
||||
|
||||
det_info = lv_label_create_empty(scr);
|
||||
|
||||
lv_style_copy(&det_style, &lv_style_scr);
|
||||
det_style.body.main_color.full = 0x0000;
|
||||
det_style.body.grad_color.full = 0x0000;
|
||||
det_style.text.color.full = 0xFFFF;
|
||||
lv_obj_set_style(det_info, &det_style);
|
||||
|
||||
lv_obj_set_pos(det_info, 20, 145);
|
||||
lv_label_set_text(det_info, " ");
|
||||
}
|
||||
else {
|
||||
lv_big_button_create(scr, "F:/bmp_tool.bin", main_menu.tool, 20, 180, event_handler, ID_TOOL);
|
||||
lv_big_button_create(scr, "F:/bmp_set.bin", main_menu.set, 180, 180, event_handler, ID_SET);
|
||||
lv_big_button_create(scr, "F:/bmp_printing.bin", main_menu.print, 340, 180, event_handler, ID_PRINT);
|
||||
|
||||
// Monitoring
|
||||
lv_obj_t *buttonExt1 = lv_big_button_create(scr, "F:/bmp_ext1_state.bin", " ", 55, ICON_POS_Y, event_handler, ID_INFO_EXT);
|
||||
#if HAS_MULTI_EXTRUDER
|
||||
lv_obj_t *buttonExt2 = lv_big_button_create(scr, "F:/bmp_ext2_state.bin", " ", 163, ICON_POS_Y, event_handler, ID_INFO_EXT);
|
||||
#if HAS_HEATED_BED
|
||||
lv_obj_t *buttonBedstate = lv_big_button_create(scr, "F:/bmp_bed_state.bin", " ", 271, ICON_POS_Y, event_handler, ID_INFO_BED);
|
||||
#endif
|
||||
#else
|
||||
#if HAS_HEATED_BED
|
||||
lv_obj_t *buttonBedstate = lv_big_button_create(scr, "F:/bmp_bed_state.bin", " ", 210, ICON_POS_Y, event_handler, ID_INFO_BED);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
lv_obj_t *buttonFanstate = lv_big_button_create(scr, "F:/bmp_fan_state.bin", " ", 380, ICON_POS_Y, event_handler, ID_INFO_FAN);
|
||||
|
||||
labelExt1 = lv_label_create(scr, 55, LABEL_MOD_Y, nullptr);
|
||||
labelExt1Target = lv_label_create(scr, 55, LABEL_MOD_Y, nullptr);
|
||||
|
||||
#if HAS_MULTI_EXTRUDER
|
||||
labelExt2 = lv_label_create(scr, 163, LABEL_MOD_Y, nullptr);
|
||||
labelExt2Target = lv_label_create(scr, 163, LABEL_MOD_Y, nullptr);
|
||||
#if HAS_HEATED_BED
|
||||
labelBed = lv_label_create(scr, 271, LABEL_MOD_Y, nullptr);
|
||||
labelBedTarget = lv_label_create(scr, 271, LABEL_MOD_Y, nullptr);
|
||||
#endif
|
||||
#else
|
||||
#if HAS_HEATED_BED
|
||||
labelBed = lv_label_create(scr, 210, LABEL_MOD_Y, nullptr);
|
||||
labelBedTarget = lv_label_create(scr, 210, LABEL_MOD_Y, nullptr);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
labelFan = lv_label_create(scr, 380, 80, nullptr);
|
||||
|
||||
itoa(thermalManager.degHotend(0), buf, 10);
|
||||
lv_label_set_text(labelExt1, buf);
|
||||
lv_obj_align(labelExt1, buttonExt1, LV_ALIGN_CENTER, 0, LABEL_MOD_Y);
|
||||
sprintf_P(buf, PSTR("-> %d"), thermalManager.degTargetHotend(0));
|
||||
lv_label_set_text(labelExt1Target, buf);
|
||||
lv_obj_align(labelExt1Target, buttonExt1, LV_ALIGN_CENTER, 0, TARGET_LABEL_MOD_Y);
|
||||
|
||||
#if HAS_MULTI_EXTRUDER
|
||||
itoa(thermalManager.degHotend(1), buf, 10);
|
||||
lv_label_set_text(labelExt2, buf);
|
||||
lv_obj_align(labelExt2, buttonExt2, LV_ALIGN_CENTER, 0, LABEL_MOD_Y);
|
||||
sprintf_P(buf, PSTR("-> %d"), thermalManager.degTargetHotend(1));
|
||||
lv_label_set_text(labelExt2Target, buf);
|
||||
lv_obj_align(labelExt2Target, buttonExt2, LV_ALIGN_CENTER, 0, TARGET_LABEL_MOD_Y);
|
||||
#endif
|
||||
|
||||
#if HAS_HEATED_BED
|
||||
itoa(thermalManager.degBed(), buf, 10);
|
||||
lv_label_set_text(labelBed, buf);
|
||||
lv_obj_align(labelBed, buttonBedstate, LV_ALIGN_CENTER, 0, LABEL_MOD_Y);
|
||||
sprintf_P(buf, PSTR("-> %d"), thermalManager.degTargetBed());
|
||||
lv_label_set_text(labelBedTarget, buf);
|
||||
lv_obj_align(labelBedTarget, buttonBedstate, LV_ALIGN_CENTER, 0, TARGET_LABEL_MOD_Y);
|
||||
#endif
|
||||
|
||||
sprintf_P(buf, PSTR("%d%%"), (int)thermalManager.fanSpeedPercent(0));
|
||||
lv_label_set_text(labelFan, buf);
|
||||
lv_obj_align(labelFan, buttonFanstate, LV_ALIGN_CENTER, 0, LABEL_MOD_Y);
|
||||
}
|
||||
|
||||
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
|
||||
// If calibration is required, let's trigger it now, handles the case when there is default value in configuration files
|
||||
if (!touch_calibration.calibration_loaded()) {
|
||||
lv_clear_ready_print();
|
||||
lv_draw_touch_calibration_screen();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void lv_temp_refr() {
|
||||
#if HAS_HEATED_BED
|
||||
sprintf(public_buf_l, printing_menu.bed_temp, thermalManager.wholeDegBed(), thermalManager.degTargetBed());
|
||||
lv_label_set_text(labelBed, public_buf_l);
|
||||
#endif
|
||||
|
||||
sprintf(public_buf_l, printing_menu.temp1, thermalManager.wholeDegHotend(0), thermalManager.degTargetHotend(0));
|
||||
lv_label_set_text(labelExt1, public_buf_l);
|
||||
|
||||
#if HAS_MULTI_EXTRUDER
|
||||
sprintf(public_buf_l, printing_menu.temp1, thermalManager.wholeDegHotend(1), thermalManager.degTargetHotend(1));
|
||||
lv_label_set_text(labelExt2, public_buf_l);
|
||||
#endif
|
||||
}
|
||||
|
||||
void lv_clear_ready_print() {
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
|
||||
#endif
|
||||
lv_obj_del(scr);
|
||||
}
|
||||
|
||||
#endif // HAS_TFT_LVGL_UI
|
39
Marlin/src/lcd/extui/mks_ui/draw_ready_print.h
Normal file
39
Marlin/src/lcd/extui/mks_ui/draw_ready_print.h
Normal file
@ -0,0 +1,39 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* C-declarations for C++ */
|
||||
#endif
|
||||
|
||||
void lv_draw_ready_print();
|
||||
void mks_disp_test();
|
||||
void disp_Limit_ok();
|
||||
void disp_Limit_error();
|
||||
void disp_det_error();
|
||||
void disp_det_ok();
|
||||
void lv_clear_ready_print();
|
||||
void lv_temp_refr();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C-declarations for C++ */
|
||||
#endif
|
135
Marlin/src/lcd/extui/mks_ui/draw_set.cpp
Normal file
135
Marlin/src/lcd/extui/mks_ui/draw_set.cpp
Normal file
@ -0,0 +1,135 @@
|
||||
/**
|
||||
* 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_TFT_LVGL_UI
|
||||
|
||||
#include "draw_ready_print.h"
|
||||
#include "draw_set.h"
|
||||
#include "draw_ui.h"
|
||||
#include <lv_conf.h>
|
||||
|
||||
#include "pic_manager.h"
|
||||
|
||||
#include "../../../gcode/queue.h"
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
#if HAS_SUICIDE
|
||||
#include "../../../MarlinCore.h"
|
||||
#endif
|
||||
|
||||
static lv_obj_t *scr;
|
||||
extern lv_group_t* g;
|
||||
|
||||
enum {
|
||||
ID_S_WIFI = 1,
|
||||
ID_S_FAN,
|
||||
ID_S_ABOUT,
|
||||
ID_S_CONTINUE,
|
||||
ID_S_MOTOR_OFF,
|
||||
ID_S_LANGUAGE,
|
||||
ID_S_MACHINE_PARA,
|
||||
ID_S_EEPROM_SET,
|
||||
ID_S_RETURN
|
||||
};
|
||||
|
||||
static void event_handler(lv_obj_t *obj, lv_event_t event) {
|
||||
if (event != LV_EVENT_RELEASED) return;
|
||||
if (obj->mks_obj_id == ID_S_CONTINUE) return;
|
||||
if (obj->mks_obj_id == ID_S_MOTOR_OFF) {
|
||||
TERN(HAS_SUICIDE, suicide(), queue.enqueue_now_P(PSTR("M84")));
|
||||
return;
|
||||
}
|
||||
lv_clear_set();
|
||||
switch (obj->mks_obj_id) {
|
||||
case ID_S_FAN:
|
||||
lv_draw_fan();
|
||||
break;
|
||||
case ID_S_ABOUT:
|
||||
lv_draw_about();
|
||||
break;
|
||||
case ID_S_LANGUAGE:
|
||||
lv_draw_language();
|
||||
break;
|
||||
case ID_S_MACHINE_PARA:
|
||||
lv_draw_machine_para();
|
||||
break;
|
||||
case ID_S_EEPROM_SET:
|
||||
lv_draw_eeprom_settings();
|
||||
break;
|
||||
case ID_S_RETURN:
|
||||
lv_draw_ready_print();
|
||||
break;
|
||||
|
||||
#if ENABLED(MKS_WIFI_MODULE)
|
||||
case ID_S_WIFI:
|
||||
if (gCfgItems.wifi_mode_sel == STA_MODEL) {
|
||||
if (wifi_link_state == WIFI_CONNECTED) {
|
||||
last_disp_state = SET_UI;
|
||||
lv_draw_wifi();
|
||||
}
|
||||
else {
|
||||
if (uiCfg.command_send) {
|
||||
uint8_t cmd_wifi_list[] = { 0xA5, 0x07, 0x00, 0x00, 0xFC };
|
||||
raw_send_to_wifi(cmd_wifi_list, COUNT(cmd_wifi_list));
|
||||
last_disp_state = SET_UI;
|
||||
lv_draw_wifi_list();
|
||||
}
|
||||
else {
|
||||
last_disp_state = SET_UI;
|
||||
lv_draw_dialog(DIALOG_WIFI_ENABLE_TIPS);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
last_disp_state = SET_UI;
|
||||
lv_draw_wifi();
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void lv_draw_set() {
|
||||
scr = lv_screen_create(SET_UI);
|
||||
lv_big_button_create(scr, "F:/bmp_eeprom_settings.bin", set_menu.eepromSet, INTERVAL_V, titleHeight, event_handler, ID_S_EEPROM_SET);
|
||||
lv_big_button_create(scr, "F:/bmp_fan.bin", set_menu.fan, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_S_FAN);
|
||||
lv_big_button_create(scr, "F:/bmp_about.bin", set_menu.about, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_S_ABOUT);
|
||||
lv_big_button_create(scr, ENABLED(HAS_SUICIDE) ? "F:/bmp_manual_off.bin" : "F:/bmp_function1.bin", set_menu.TERN(HAS_SUICIDE, shutdown, motoroff), BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_S_MOTOR_OFF);
|
||||
lv_big_button_create(scr, "F:/bmp_machine_para.bin", set_menu.machine_para, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_S_MACHINE_PARA);
|
||||
#if HAS_LANG_SELECT_SCREEN
|
||||
lv_big_button_create(scr, "F:/bmp_language.bin", set_menu.language, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_S_LANGUAGE);
|
||||
#endif
|
||||
#if ENABLED(MKS_WIFI_MODULE)
|
||||
lv_big_button_create(scr, "F:/bmp_wifi.bin", set_menu.wifi, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_S_WIFI);
|
||||
#endif
|
||||
lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_S_RETURN);
|
||||
}
|
||||
|
||||
void lv_clear_set() {
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
|
||||
#endif
|
||||
lv_obj_del(scr);
|
||||
}
|
||||
|
||||
#endif // HAS_TFT_LVGL_UI
|
33
Marlin/src/lcd/extui/mks_ui/draw_set.h
Normal file
33
Marlin/src/lcd/extui/mks_ui/draw_set.h
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* C-declarations for C++ */
|
||||
#endif
|
||||
|
||||
void lv_draw_set();
|
||||
void lv_clear_set();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C-declarations for C++ */
|
||||
#endif
|
116
Marlin/src/lcd/extui/mks_ui/draw_step_settings.cpp
Normal file
116
Marlin/src/lcd/extui/mks_ui/draw_step_settings.cpp
Normal file
@ -0,0 +1,116 @@
|
||||
/**
|
||||
* 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_TFT_LVGL_UI
|
||||
|
||||
#include "draw_ui.h"
|
||||
#include <lv_conf.h>
|
||||
|
||||
#include "../../../module/planner.h"
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
extern lv_group_t *g;
|
||||
static lv_obj_t *scr;
|
||||
|
||||
enum {
|
||||
ID_STEP_RETURN = 1,
|
||||
ID_STEP_X,
|
||||
ID_STEP_Y,
|
||||
ID_STEP_Z,
|
||||
ID_STEP_E0,
|
||||
ID_STEP_E1,
|
||||
ID_STEP_DOWN,
|
||||
ID_STEP_UP
|
||||
};
|
||||
|
||||
static void event_handler(lv_obj_t *obj, lv_event_t event) {
|
||||
if (event != LV_EVENT_RELEASED) return;
|
||||
lv_clear_step_settings();
|
||||
switch (obj->mks_obj_id) {
|
||||
case ID_STEP_RETURN:
|
||||
uiCfg.para_ui_page = false;
|
||||
draw_return_ui();
|
||||
return;
|
||||
case ID_STEP_X:
|
||||
value = Xstep;
|
||||
break;
|
||||
case ID_STEP_Y:
|
||||
value = Ystep;
|
||||
break;
|
||||
case ID_STEP_Z:
|
||||
value = Zstep;
|
||||
break;
|
||||
case ID_STEP_E0:
|
||||
value = E0step;
|
||||
break;
|
||||
case ID_STEP_E1:
|
||||
value = E1step;
|
||||
break;
|
||||
case ID_STEP_UP:
|
||||
uiCfg.para_ui_page = false;
|
||||
lv_draw_step_settings();
|
||||
return;
|
||||
case ID_STEP_DOWN:
|
||||
uiCfg.para_ui_page = true;
|
||||
lv_draw_step_settings();
|
||||
return;
|
||||
}
|
||||
lv_draw_number_key();
|
||||
}
|
||||
|
||||
void lv_draw_step_settings() {
|
||||
scr = lv_screen_create(STEPS_UI, machine_menu.StepsConfTitle);
|
||||
|
||||
if (!uiCfg.para_ui_page) {
|
||||
dtostrf(planner.settings.axis_steps_per_mm[X_AXIS], 1, 1, public_buf_l);
|
||||
lv_screen_menu_item_1_edit(scr, machine_menu.X_Steps, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_STEP_X, 0, public_buf_l);
|
||||
|
||||
dtostrf(planner.settings.axis_steps_per_mm[Y_AXIS], 1, 1, public_buf_l);
|
||||
lv_screen_menu_item_1_edit(scr, machine_menu.Y_Steps, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_STEP_Y, 1, public_buf_l);
|
||||
|
||||
dtostrf(planner.settings.axis_steps_per_mm[Z_AXIS], 1, 1, public_buf_l);
|
||||
lv_screen_menu_item_1_edit(scr, machine_menu.Z_Steps, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_STEP_Z, 2, public_buf_l);
|
||||
|
||||
dtostrf(planner.settings.axis_steps_per_mm[E_AXIS], 1, 1, public_buf_l);
|
||||
lv_screen_menu_item_1_edit(scr, machine_menu.E0_Steps, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_STEP_E0, 3, public_buf_l);
|
||||
|
||||
lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.next, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_STEP_DOWN, true);
|
||||
}
|
||||
else {
|
||||
dtostrf(planner.settings.axis_steps_per_mm[E_AXIS_N(1)], 1, 1, public_buf_l);
|
||||
lv_screen_menu_item_1_edit(scr, machine_menu.E1_Steps, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_STEP_E1, 0, public_buf_l);
|
||||
|
||||
lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.previous, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_STEP_UP, true);
|
||||
}
|
||||
|
||||
lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_STEP_RETURN, true);
|
||||
}
|
||||
|
||||
void lv_clear_step_settings() {
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
|
||||
#endif
|
||||
lv_obj_del(scr);
|
||||
}
|
||||
|
||||
#endif // HAS_TFT_LVGL_UI
|
33
Marlin/src/lcd/extui/mks_ui/draw_step_settings.h
Normal file
33
Marlin/src/lcd/extui/mks_ui/draw_step_settings.h
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* C-declarations for C++ */
|
||||
#endif
|
||||
|
||||
void lv_draw_step_settings();
|
||||
void lv_clear_step_settings();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C-declarations for C++ */
|
||||
#endif
|
155
Marlin/src/lcd/extui/mks_ui/draw_tmc_current_settings.cpp
Normal file
155
Marlin/src/lcd/extui/mks_ui/draw_tmc_current_settings.cpp
Normal file
@ -0,0 +1,155 @@
|
||||
/**
|
||||
* 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 BOTH(HAS_TFT_LVGL_UI, HAS_TRINAMIC_CONFIG)
|
||||
|
||||
#include "draw_ui.h"
|
||||
#include <lv_conf.h>
|
||||
|
||||
#include "../../../module/stepper/indirection.h"
|
||||
#include "../../../feature/tmc_util.h"
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
extern lv_group_t *g;
|
||||
static lv_obj_t *scr;
|
||||
|
||||
enum {
|
||||
ID_TMC_CURRENT_RETURN = 1,
|
||||
ID_TMC_CURRENT_X,
|
||||
ID_TMC_CURRENT_Y,
|
||||
ID_TMC_CURRENT_Z,
|
||||
ID_TMC_CURRENT_E0,
|
||||
ID_TMC_CURRENT_E1,
|
||||
ID_TMC_CURRENT_DOWN,
|
||||
ID_TMC_CURRENT_UP
|
||||
};
|
||||
|
||||
static void event_handler(lv_obj_t *obj, lv_event_t event) {
|
||||
if (event != LV_EVENT_RELEASED) return;
|
||||
lv_clear_tmc_current_settings();
|
||||
switch (obj->mks_obj_id) {
|
||||
case ID_TMC_CURRENT_RETURN:
|
||||
uiCfg.para_ui_page = false;
|
||||
draw_return_ui();
|
||||
return;
|
||||
#if AXIS_IS_TMC(X)
|
||||
case ID_TMC_CURRENT_X:
|
||||
value = Xcurrent;
|
||||
break;
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Y)
|
||||
case ID_TMC_CURRENT_Y:
|
||||
value = Ycurrent;
|
||||
break;
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Z)
|
||||
case ID_TMC_CURRENT_Z:
|
||||
value = Zcurrent;
|
||||
break;
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E0)
|
||||
case ID_TMC_CURRENT_E0:
|
||||
value = E0current;
|
||||
break;
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E1)
|
||||
case ID_TMC_CURRENT_E1:
|
||||
value = E1current;
|
||||
break;
|
||||
#endif
|
||||
|
||||
case ID_TMC_CURRENT_UP:
|
||||
uiCfg.para_ui_page = false;
|
||||
lv_draw_tmc_current_settings();
|
||||
return;
|
||||
case ID_TMC_CURRENT_DOWN:
|
||||
uiCfg.para_ui_page = true;
|
||||
lv_draw_tmc_current_settings();
|
||||
return;
|
||||
}
|
||||
lv_draw_number_key();
|
||||
|
||||
}
|
||||
|
||||
void lv_draw_tmc_current_settings() {
|
||||
scr = lv_screen_create(TMC_CURRENT_UI, machine_menu.TmcCurrentConfTitle);
|
||||
|
||||
float milliamps;
|
||||
if (!uiCfg.para_ui_page) {
|
||||
#if AXIS_IS_TMC(X)
|
||||
milliamps = stepperX.getMilliamps();
|
||||
#else
|
||||
milliamps = -1;
|
||||
#endif
|
||||
dtostrf(milliamps, 1, 1, public_buf_l);
|
||||
lv_screen_menu_item_1_edit(scr, machine_menu.X_Current, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_TMC_CURRENT_X, 0, public_buf_l);
|
||||
|
||||
#if AXIS_IS_TMC(Y)
|
||||
milliamps = stepperY.getMilliamps();
|
||||
#else
|
||||
milliamps = -1;
|
||||
#endif
|
||||
dtostrf(milliamps, 1, 1, public_buf_l);
|
||||
lv_screen_menu_item_1_edit(scr, machine_menu.Y_Current, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_TMC_CURRENT_Y, 1, public_buf_l);
|
||||
|
||||
#if AXIS_IS_TMC(Z)
|
||||
milliamps = stepperZ.getMilliamps();
|
||||
#else
|
||||
milliamps = -1;
|
||||
#endif
|
||||
dtostrf(milliamps, 1, 1, public_buf_l);
|
||||
lv_screen_menu_item_1_edit(scr, machine_menu.Z_Current, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_TMC_CURRENT_Z, 2, public_buf_l);
|
||||
|
||||
#if AXIS_IS_TMC(E0)
|
||||
milliamps = stepperE0.getMilliamps();
|
||||
#else
|
||||
milliamps = -1;
|
||||
#endif
|
||||
dtostrf(milliamps, 1, 1, public_buf_l);
|
||||
lv_screen_menu_item_1_edit(scr, machine_menu.E0_Current, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_TMC_CURRENT_E0, 3, public_buf_l);
|
||||
|
||||
lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.next, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_TMC_CURRENT_DOWN, true);
|
||||
}
|
||||
else {
|
||||
#if AXIS_IS_TMC(E1)
|
||||
milliamps = stepperE1.getMilliamps();
|
||||
#else
|
||||
milliamps = -1;
|
||||
#endif
|
||||
dtostrf(milliamps, 1, 1, public_buf_l);
|
||||
lv_screen_menu_item_1_edit(scr, machine_menu.E1_Current, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_TMC_CURRENT_E1, 0, public_buf_l);
|
||||
|
||||
lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.previous, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_TMC_CURRENT_UP, true);
|
||||
}
|
||||
|
||||
lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_TMC_CURRENT_RETURN, true);
|
||||
}
|
||||
|
||||
void lv_clear_tmc_current_settings() {
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
|
||||
#endif
|
||||
lv_obj_del(scr);
|
||||
}
|
||||
|
||||
#endif // HAS_TFT_LVGL_UI && HAS_TRINAMIC_CONFIG
|
33
Marlin/src/lcd/extui/mks_ui/draw_tmc_current_settings.h
Normal file
33
Marlin/src/lcd/extui/mks_ui/draw_tmc_current_settings.h
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* C-declarations for C++ */
|
||||
#endif
|
||||
|
||||
void lv_draw_tmc_current_settings();
|
||||
void lv_clear_tmc_current_settings();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C-declarations for C++ */
|
||||
#endif
|
154
Marlin/src/lcd/extui/mks_ui/draw_tmc_step_mode_settings.cpp
Normal file
154
Marlin/src/lcd/extui/mks_ui/draw_tmc_step_mode_settings.cpp
Normal file
@ -0,0 +1,154 @@
|
||||
/**
|
||||
* 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 BOTH(HAS_TFT_LVGL_UI, HAS_STEALTHCHOP)
|
||||
|
||||
#include "draw_ui.h"
|
||||
#include <lv_conf.h>
|
||||
|
||||
#include "../../../module/stepper/indirection.h"
|
||||
#include "../../../feature/tmc_util.h"
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(EEPROM_SETTINGS)
|
||||
#include "../../../module/settings.h"
|
||||
#endif
|
||||
|
||||
extern lv_group_t *g;
|
||||
static lv_obj_t *scr;
|
||||
|
||||
enum {
|
||||
ID_TMC_MODE_RETURN = 1,
|
||||
ID_TMC_MODE_X,
|
||||
ID_TMC_MODE_Y,
|
||||
ID_TMC_MODE_Z,
|
||||
ID_TMC_MODE_E0,
|
||||
ID_TMC_MODE_E1,
|
||||
ID_TMC_MODE_DOWN,
|
||||
ID_TMC_MODE_UP
|
||||
};
|
||||
|
||||
static lv_obj_t *buttonXState = nullptr, *buttonYState = nullptr, *buttonZState = nullptr, *buttonE0State = nullptr;
|
||||
|
||||
static lv_obj_t *buttonE1State = nullptr;
|
||||
|
||||
static void event_handler(lv_obj_t *obj, lv_event_t event) {
|
||||
if (event != LV_EVENT_RELEASED) return;
|
||||
|
||||
auto toggle_chop = [&](auto &stepper, auto &button) {
|
||||
const bool isena = stepper.toggle_stepping_mode();
|
||||
lv_screen_menu_item_onoff_update(button, isena);
|
||||
TERN_(EEPROM_SETTINGS, (void)settings.save());
|
||||
};
|
||||
|
||||
switch (obj->mks_obj_id) {
|
||||
case ID_TMC_MODE_RETURN:
|
||||
uiCfg.para_ui_page = false;
|
||||
lv_clear_tmc_step_mode_settings();
|
||||
draw_return_ui();
|
||||
break;
|
||||
|
||||
#if AXIS_HAS_STEALTHCHOP(X)
|
||||
case ID_TMC_MODE_X:
|
||||
toggle_chop(stepperX, buttonXState);
|
||||
break;
|
||||
#endif
|
||||
#if AXIS_HAS_STEALTHCHOP(Y)
|
||||
case ID_TMC_MODE_Y:
|
||||
toggle_chop(stepperY, buttonYState);
|
||||
break;
|
||||
#endif
|
||||
#if AXIS_HAS_STEALTHCHOP(Z)
|
||||
case ID_TMC_MODE_Z:
|
||||
toggle_chop(stepperZ, buttonZState);
|
||||
break;
|
||||
#endif
|
||||
#if AXIS_HAS_STEALTHCHOP(E0)
|
||||
case ID_TMC_MODE_E0:
|
||||
toggle_chop(stepperE0, buttonE0State);
|
||||
break;
|
||||
#endif
|
||||
#if AXIS_HAS_STEALTHCHOP(E1)
|
||||
case ID_TMC_MODE_E1:
|
||||
toggle_chop(stepperE1, buttonE1State);
|
||||
break;
|
||||
#endif
|
||||
|
||||
case ID_TMC_MODE_UP:
|
||||
uiCfg.para_ui_page = false;
|
||||
lv_clear_tmc_step_mode_settings();
|
||||
lv_draw_tmc_step_mode_settings();
|
||||
break;
|
||||
case ID_TMC_MODE_DOWN:
|
||||
uiCfg.para_ui_page = true;
|
||||
lv_clear_tmc_step_mode_settings();
|
||||
lv_draw_tmc_step_mode_settings();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void lv_draw_tmc_step_mode_settings() {
|
||||
buttonXState = buttonYState = buttonZState = buttonE0State = buttonE1State = nullptr;
|
||||
|
||||
scr = lv_screen_create(TMC_MODE_UI, machine_menu.TmcStepModeConfTitle);
|
||||
|
||||
bool stealth_X = false, stealth_Y = false, stealth_Z = false, stealth_E0 = false, stealth_E1 = false;
|
||||
#if AXIS_HAS_STEALTHCHOP(X)
|
||||
stealth_X = stepperX.get_stealthChop();
|
||||
#endif
|
||||
#if AXIS_HAS_STEALTHCHOP(Y)
|
||||
stealth_Y = stepperY.get_stealthChop();
|
||||
#endif
|
||||
#if AXIS_HAS_STEALTHCHOP(Z)
|
||||
stealth_Z = stepperZ.get_stealthChop();
|
||||
#endif
|
||||
#if AXIS_HAS_STEALTHCHOP(E0)
|
||||
stealth_E0 = stepperE0.get_stealthChop();
|
||||
#endif
|
||||
#if AXIS_HAS_STEALTHCHOP(E1)
|
||||
stealth_E1 = stepperE1.get_stealthChop();
|
||||
#endif
|
||||
|
||||
if (!uiCfg.para_ui_page) {
|
||||
buttonXState = lv_screen_menu_item_onoff(scr, machine_menu.X_StepMode, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_TMC_MODE_X, 0, stealth_X);
|
||||
buttonYState = lv_screen_menu_item_onoff(scr, machine_menu.Y_StepMode, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_TMC_MODE_Y, 1, stealth_Y);
|
||||
buttonZState = lv_screen_menu_item_onoff(scr, machine_menu.Z_StepMode, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_TMC_MODE_Z, 2, stealth_Z);
|
||||
buttonE0State = lv_screen_menu_item_onoff(scr, machine_menu.E0_StepMode, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_TMC_MODE_E0, 2, stealth_E0);
|
||||
lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.next, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_TMC_MODE_DOWN, true);
|
||||
}
|
||||
else {
|
||||
buttonE1State = lv_screen_menu_item_onoff(scr, machine_menu.E1_StepMode, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_TMC_MODE_E1, 0, stealth_E1);
|
||||
lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.previous, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_TMC_MODE_UP, true);
|
||||
}
|
||||
|
||||
lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_TMC_MODE_RETURN, true);
|
||||
}
|
||||
|
||||
void lv_clear_tmc_step_mode_settings() {
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
|
||||
#endif
|
||||
lv_obj_del(scr);
|
||||
}
|
||||
|
||||
#endif // HAS_TFT_LVGL_UI && HAS_STEALTHCHOP
|
33
Marlin/src/lcd/extui/mks_ui/draw_tmc_step_mode_settings.h
Normal file
33
Marlin/src/lcd/extui/mks_ui/draw_tmc_step_mode_settings.h
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* C-declarations for C++ */
|
||||
#endif
|
||||
|
||||
void lv_draw_tmc_step_mode_settings();
|
||||
void lv_clear_tmc_step_mode_settings();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C-declarations for C++ */
|
||||
#endif
|
103
Marlin/src/lcd/extui/mks_ui/draw_tool.cpp
Normal file
103
Marlin/src/lcd/extui/mks_ui/draw_tool.cpp
Normal file
@ -0,0 +1,103 @@
|
||||
/**
|
||||
* 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_TFT_LVGL_UI
|
||||
|
||||
#include "draw_ui.h"
|
||||
#include <lv_conf.h>
|
||||
|
||||
#include "../../../gcode/queue.h"
|
||||
#include "../../../module/temperature.h"
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
extern lv_group_t *g;
|
||||
static lv_obj_t *scr;
|
||||
|
||||
enum {
|
||||
ID_T_PRE_HEAT = 1,
|
||||
ID_T_EXTRUCT,
|
||||
ID_T_MOV,
|
||||
ID_T_HOME,
|
||||
ID_T_LEVELING,
|
||||
ID_T_FILAMENT,
|
||||
ID_T_MORE,
|
||||
ID_T_RETURN
|
||||
};
|
||||
|
||||
#if ENABLED(MKS_TEST)
|
||||
extern uint8_t curent_disp_ui;
|
||||
#endif
|
||||
|
||||
static void event_handler(lv_obj_t *obj, lv_event_t event) {
|
||||
if (event != LV_EVENT_RELEASED) return;
|
||||
if (TERN1(AUTO_BED_LEVELING_BILINEAR, obj->mks_obj_id != ID_T_LEVELING))
|
||||
lv_clear_tool();
|
||||
switch (obj->mks_obj_id) {
|
||||
case ID_T_PRE_HEAT: lv_draw_preHeat(); break;
|
||||
case ID_T_EXTRUCT: lv_draw_extrusion(); break;
|
||||
case ID_T_MOV: lv_draw_move_motor(); break;
|
||||
case ID_T_HOME: lv_draw_home(); break;
|
||||
case ID_T_LEVELING:
|
||||
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
||||
get_gcode_command(AUTO_LEVELING_COMMAND_ADDR,(uint8_t *)public_buf_m);
|
||||
public_buf_m[sizeof(public_buf_m)-1] = 0;
|
||||
queue.inject_P(PSTR(public_buf_m));
|
||||
#else
|
||||
uiCfg.leveling_first_time = true;
|
||||
lv_draw_manualLevel();
|
||||
#endif
|
||||
break;
|
||||
case ID_T_FILAMENT:
|
||||
uiCfg.hotendTargetTempBak = thermalManager.degTargetHotend(uiCfg.extruderIndex);
|
||||
lv_draw_filament_change();
|
||||
break;
|
||||
case ID_T_MORE:
|
||||
lv_draw_more();
|
||||
break;
|
||||
case ID_T_RETURN:
|
||||
TERN_(MKS_TEST, curent_disp_ui = 1);
|
||||
lv_draw_ready_print();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void lv_draw_tool() {
|
||||
scr = lv_screen_create(TOOL_UI);
|
||||
lv_big_button_create(scr, "F:/bmp_preHeat.bin", tool_menu.preheat, INTERVAL_V, titleHeight, event_handler, ID_T_PRE_HEAT);
|
||||
lv_big_button_create(scr, "F:/bmp_extruct.bin", tool_menu.extrude, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_T_EXTRUCT);
|
||||
lv_big_button_create(scr, "F:/bmp_mov.bin", tool_menu.move, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_T_MOV);
|
||||
lv_big_button_create(scr, "F:/bmp_zero.bin", tool_menu.home, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_T_HOME);
|
||||
lv_big_button_create(scr, "F:/bmp_leveling.bin", tool_menu.TERN(AUTO_BED_LEVELING_BILINEAR, autoleveling, leveling), INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_T_LEVELING);
|
||||
lv_big_button_create(scr, "F:/bmp_filamentchange.bin", tool_menu.filament, BTN_X_PIXEL+INTERVAL_V*2,BTN_Y_PIXEL+INTERVAL_H+titleHeight, event_handler,ID_T_FILAMENT);
|
||||
lv_big_button_create(scr, "F:/bmp_more.bin", tool_menu.more, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_T_MORE);
|
||||
lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_T_RETURN);
|
||||
}
|
||||
|
||||
void lv_clear_tool() {
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
|
||||
#endif
|
||||
lv_obj_del(scr);
|
||||
}
|
||||
|
||||
#endif // HAS_TFT_LVGL_UI
|
33
Marlin/src/lcd/extui/mks_ui/draw_tool.h
Normal file
33
Marlin/src/lcd/extui/mks_ui/draw_tool.h
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* C-declarations for C++ */
|
||||
#endif
|
||||
|
||||
void lv_draw_tool();
|
||||
void lv_clear_tool();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C-declarations for C++ */
|
||||
#endif
|
118
Marlin/src/lcd/extui/mks_ui/draw_touch_calibration.cpp
Normal file
118
Marlin/src/lcd/extui/mks_ui/draw_touch_calibration.cpp
Normal file
@ -0,0 +1,118 @@
|
||||
/**
|
||||
* 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 BOTH(HAS_TFT_LVGL_UI, TOUCH_SCREEN_CALIBRATION)
|
||||
|
||||
#include "draw_ui.h"
|
||||
#include "draw_touch_calibration.h"
|
||||
#include <lv_conf.h>
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
#include "../../tft_io/touch_calibration.h"
|
||||
#include "SPI_TFT.h"
|
||||
|
||||
static lv_obj_t *scr;
|
||||
static lv_obj_t *status_label;
|
||||
|
||||
static void event_handler(lv_obj_t *obj, lv_event_t event);
|
||||
|
||||
enum {
|
||||
ID_TC_RETURN = 1
|
||||
};
|
||||
|
||||
static void drawCross(uint16_t x, uint16_t y, uint16_t color) {
|
||||
SPI_TFT.tftio.set_window(x - 15, y, x + 15, y);
|
||||
SPI_TFT.tftio.WriteMultiple(color, 31);
|
||||
SPI_TFT.tftio.set_window(x, y - 15, x, y + 15);
|
||||
SPI_TFT.tftio.WriteMultiple(color, 31);
|
||||
}
|
||||
|
||||
void lv_update_touch_calibration_screen() {
|
||||
uint16_t x, y;
|
||||
|
||||
calibrationState calibration_stage = touch_calibration.get_calibration_state();
|
||||
if (calibration_stage == CALIBRATION_NONE) {
|
||||
// start and clear screen
|
||||
calibration_stage = touch_calibration.calibration_start();
|
||||
}
|
||||
else {
|
||||
// clear last cross
|
||||
x = touch_calibration.calibration_points[_MIN(calibration_stage - 1, CALIBRATION_BOTTOM_RIGHT)].x;
|
||||
y = touch_calibration.calibration_points[_MIN(calibration_stage - 1, CALIBRATION_BOTTOM_RIGHT)].y;
|
||||
drawCross(x, y, LV_COLOR_BACKGROUND.full);
|
||||
}
|
||||
|
||||
const char *str = nullptr;
|
||||
if (calibration_stage < CALIBRATION_SUCCESS) {
|
||||
// handle current state
|
||||
switch (calibration_stage) {
|
||||
case CALIBRATION_TOP_LEFT: str = GET_TEXT(MSG_TOP_LEFT); break;
|
||||
case CALIBRATION_BOTTOM_LEFT: str = GET_TEXT(MSG_BOTTOM_LEFT); break;
|
||||
case CALIBRATION_TOP_RIGHT: str = GET_TEXT(MSG_TOP_RIGHT); break;
|
||||
case CALIBRATION_BOTTOM_RIGHT: str = GET_TEXT(MSG_BOTTOM_RIGHT); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
x = touch_calibration.calibration_points[calibration_stage].x;
|
||||
y = touch_calibration.calibration_points[calibration_stage].y;
|
||||
drawCross(x, y, LV_COLOR_WHITE.full);
|
||||
}
|
||||
else {
|
||||
// end calibration
|
||||
str = calibration_stage == CALIBRATION_SUCCESS ? GET_TEXT(MSG_CALIBRATION_COMPLETED) : GET_TEXT(MSG_CALIBRATION_FAILED);
|
||||
touch_calibration.calibration_end();
|
||||
lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_TC_RETURN);
|
||||
}
|
||||
|
||||
// draw current message
|
||||
lv_label_set_text(status_label, str);
|
||||
lv_obj_align(status_label, nullptr, LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
|
||||
static void event_handler(lv_obj_t *obj, lv_event_t event) {
|
||||
if (event != LV_EVENT_RELEASED) return;
|
||||
switch (obj->mks_obj_id) {
|
||||
case ID_TC_RETURN:
|
||||
TERN_(MKS_TEST, curent_disp_ui = 1);
|
||||
lv_clear_touch_calibration_screen();
|
||||
draw_return_ui();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void lv_draw_touch_calibration_screen() {
|
||||
scr = lv_screen_create(TOUCH_CALIBRATION_UI, "");
|
||||
|
||||
status_label = lv_label_create(scr, "");
|
||||
lv_obj_align(status_label, nullptr, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
lv_refr_now(lv_refr_get_disp_refreshing());
|
||||
|
||||
lv_update_touch_calibration_screen();
|
||||
}
|
||||
|
||||
void lv_clear_touch_calibration_screen() {
|
||||
lv_obj_del(scr);
|
||||
}
|
||||
|
||||
#endif // HAS_TFT_LVGL_UI && TOUCH_SCREEN_CALIBRATION
|
34
Marlin/src/lcd/extui/mks_ui/draw_touch_calibration.h
Normal file
34
Marlin/src/lcd/extui/mks_ui/draw_touch_calibration.h
Normal file
@ -0,0 +1,34 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* C-declarations for C++ */
|
||||
#endif
|
||||
|
||||
void lv_draw_touch_calibration_screen();
|
||||
void lv_clear_touch_calibration_screen();
|
||||
void lv_update_touch_calibration_screen();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C-declarations for C++ */
|
||||
#endif
|
146
Marlin/src/lcd/extui/mks_ui/draw_tramming_pos_settings.cpp
Normal file
146
Marlin/src/lcd/extui/mks_ui/draw_tramming_pos_settings.cpp
Normal file
@ -0,0 +1,146 @@
|
||||
/**
|
||||
* 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_TFT_LVGL_UI
|
||||
|
||||
#include "draw_ui.h"
|
||||
#include <lv_conf.h>
|
||||
|
||||
#include "../../../module/planner.h"
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
extern lv_group_t *g;
|
||||
static lv_obj_t *scr;
|
||||
|
||||
enum {
|
||||
ID_MANUAL_POS_RETURN = 1,
|
||||
ID_MANUAL_POS_X1,
|
||||
ID_MANUAL_POS_Y1,
|
||||
ID_MANUAL_POS_X2,
|
||||
ID_MANUAL_POS_Y2,
|
||||
ID_MANUAL_POS_X3,
|
||||
ID_MANUAL_POS_Y3,
|
||||
ID_MANUAL_POS_X4,
|
||||
ID_MANUAL_POS_Y4,
|
||||
ID_MANUAL_POS_X5,
|
||||
ID_MANUAL_POS_Y5,
|
||||
ID_MANUAL_POS_DOWN,
|
||||
ID_MANUAL_POS_UP
|
||||
};
|
||||
|
||||
static void event_handler(lv_obj_t *obj, lv_event_t event) {
|
||||
if (event != LV_EVENT_RELEASED) return;
|
||||
switch (obj->mks_obj_id) {
|
||||
case ID_MANUAL_POS_RETURN:
|
||||
uiCfg.para_ui_page = false;
|
||||
lv_clear_tramming_pos_settings();
|
||||
draw_return_ui();
|
||||
return;
|
||||
case ID_MANUAL_POS_X1:
|
||||
value = level_pos_x1;
|
||||
break;
|
||||
case ID_MANUAL_POS_Y1:
|
||||
value = level_pos_y1;
|
||||
break;
|
||||
case ID_MANUAL_POS_X2:
|
||||
value = level_pos_x2;
|
||||
break;
|
||||
case ID_MANUAL_POS_Y2:
|
||||
value = level_pos_y2;
|
||||
break;
|
||||
case ID_MANUAL_POS_X3:
|
||||
value = level_pos_x3;
|
||||
break;
|
||||
case ID_MANUAL_POS_Y3:
|
||||
value = level_pos_y3;
|
||||
break;
|
||||
case ID_MANUAL_POS_X4:
|
||||
value = level_pos_x4;
|
||||
break;
|
||||
case ID_MANUAL_POS_Y4:
|
||||
value = level_pos_y4;
|
||||
break;
|
||||
case ID_MANUAL_POS_X5:
|
||||
value = level_pos_x5;
|
||||
break;
|
||||
case ID_MANUAL_POS_Y5:
|
||||
value = level_pos_y5;
|
||||
break;
|
||||
case ID_MANUAL_POS_UP:
|
||||
uiCfg.para_ui_page = false;
|
||||
lv_clear_tramming_pos_settings();
|
||||
lv_draw_tramming_pos_settings();
|
||||
return;
|
||||
case ID_MANUAL_POS_DOWN:
|
||||
uiCfg.para_ui_page = true;
|
||||
lv_clear_tramming_pos_settings();
|
||||
lv_draw_tramming_pos_settings();
|
||||
return;
|
||||
}
|
||||
lv_clear_tramming_pos_settings();
|
||||
lv_draw_number_key();
|
||||
}
|
||||
|
||||
void lv_draw_tramming_pos_settings() {
|
||||
char buf2[50];
|
||||
|
||||
scr = lv_screen_create(MANUAL_LEVELING_POSIGION_UI, machine_menu.LevelingParaConfTitle);
|
||||
|
||||
if (!uiCfg.para_ui_page) {
|
||||
itoa(gCfgItems.trammingPos[0].x, public_buf_l, 10);
|
||||
itoa(gCfgItems.trammingPos[0].y, buf2, 10);
|
||||
lv_screen_menu_item_2_edit(scr, leveling_menu.position1, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_MANUAL_POS_Y1, 0, buf2, ID_MANUAL_POS_X1, public_buf_l);
|
||||
|
||||
itoa(gCfgItems.trammingPos[1].x, public_buf_l, 10);
|
||||
itoa(gCfgItems.trammingPos[1].y, buf2, 10);
|
||||
lv_screen_menu_item_2_edit(scr, leveling_menu.position2, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_MANUAL_POS_Y2, 1, buf2, ID_MANUAL_POS_X2, public_buf_l);
|
||||
|
||||
itoa(gCfgItems.trammingPos[2].x, public_buf_l, 10);
|
||||
itoa(gCfgItems.trammingPos[2].y, buf2, 10);
|
||||
lv_screen_menu_item_2_edit(scr, leveling_menu.position3, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_MANUAL_POS_Y3, 2, buf2, ID_MANUAL_POS_X3, public_buf_l);
|
||||
|
||||
itoa(gCfgItems.trammingPos[3].x, public_buf_l, 10);
|
||||
itoa(gCfgItems.trammingPos[3].y, buf2, 10);
|
||||
lv_screen_menu_item_2_edit(scr, leveling_menu.position4, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_MANUAL_POS_Y4, 3, buf2, ID_MANUAL_POS_X4, public_buf_l);
|
||||
|
||||
lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.next, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_MANUAL_POS_DOWN, true);
|
||||
}
|
||||
else {
|
||||
itoa(gCfgItems.trammingPos[4].x, public_buf_l, 10);
|
||||
itoa(gCfgItems.trammingPos[4].y, buf2, 10);
|
||||
lv_screen_menu_item_2_edit(scr, leveling_menu.position5, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_MANUAL_POS_Y5, 0, buf2, ID_MANUAL_POS_X5, public_buf_l);
|
||||
|
||||
lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.previous, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_MANUAL_POS_UP, true);
|
||||
}
|
||||
|
||||
lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X + 10, PARA_UI_BACL_POS_Y, event_handler, ID_MANUAL_POS_RETURN, true);
|
||||
}
|
||||
|
||||
void lv_clear_tramming_pos_settings() {
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
|
||||
#endif
|
||||
lv_obj_del(scr);
|
||||
}
|
||||
|
||||
#endif // HAS_TFT_LVGL_UI
|
33
Marlin/src/lcd/extui/mks_ui/draw_tramming_pos_settings.h
Normal file
33
Marlin/src/lcd/extui/mks_ui/draw_tramming_pos_settings.h
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* C-declarations for C++ */
|
||||
#endif
|
||||
|
||||
void lv_draw_tramming_pos_settings();
|
||||
void lv_clear_tramming_pos_settings();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C-declarations for C++ */
|
||||
#endif
|
1382
Marlin/src/lcd/extui/mks_ui/draw_ui.cpp
Normal file
1382
Marlin/src/lcd/extui/mks_ui/draw_ui.cpp
Normal file
File diff suppressed because it is too large
Load Diff
542
Marlin/src/lcd/extui/mks_ui/draw_ui.h
Normal file
542
Marlin/src/lcd/extui/mks_ui/draw_ui.h
Normal file
@ -0,0 +1,542 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#include <lvgl.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
// the colors of the last MKS Ui
|
||||
#undef LV_COLOR_BACKGROUND
|
||||
#define LV_COLOR_BACKGROUND LV_COLOR_MAKE(0x1A, 0x1A, 0x1A)
|
||||
|
||||
#define TFT_LV_PARA_BACK_BODY_COLOR LV_COLOR_MAKE(0x4A, 0x52, 0xFF)
|
||||
|
||||
#include "tft_lvgl_configuration.h"
|
||||
#include "tft_multi_language.h"
|
||||
#include "pic_manager.h"
|
||||
#include "draw_ready_print.h"
|
||||
#include "draw_language.h"
|
||||
#include "draw_set.h"
|
||||
#include "draw_tool.h"
|
||||
#include "draw_print_file.h"
|
||||
#include "draw_dialog.h"
|
||||
#include "draw_printing.h"
|
||||
#include "draw_operation.h"
|
||||
#include "draw_preHeat.h"
|
||||
#include "draw_extrusion.h"
|
||||
#include "draw_home.h"
|
||||
#include "draw_gcode.h"
|
||||
#include "draw_more.h"
|
||||
#include "draw_move_motor.h"
|
||||
#include "draw_fan.h"
|
||||
#include "draw_about.h"
|
||||
#include "draw_change_speed.h"
|
||||
#include "draw_manuaLevel.h"
|
||||
#include "draw_error_message.h"
|
||||
#include "printer_operation.h"
|
||||
#include "draw_machine_para.h"
|
||||
#include "draw_machine_settings.h"
|
||||
#include "draw_motor_settings.h"
|
||||
#include "draw_advance_settings.h"
|
||||
#include "draw_acceleration_settings.h"
|
||||
#include "draw_number_key.h"
|
||||
#include "draw_jerk_settings.h"
|
||||
#include "draw_pause_position.h"
|
||||
#include "draw_step_settings.h"
|
||||
#include "draw_tmc_current_settings.h"
|
||||
#include "draw_eeprom_settings.h"
|
||||
#include "draw_max_feedrate_settings.h"
|
||||
#include "draw_tmc_step_mode_settings.h"
|
||||
#include "draw_level_settings.h"
|
||||
#include "draw_tramming_pos_settings.h"
|
||||
#include "draw_auto_level_offset_settings.h"
|
||||
#include "draw_filament_change.h"
|
||||
#include "draw_filament_settings.h"
|
||||
#include "draw_homing_sensitivity_settings.h"
|
||||
#include "draw_baby_stepping.h"
|
||||
#include "draw_keyboard.h"
|
||||
#include "draw_media_select.h"
|
||||
#include "draw_encoder_settings.h"
|
||||
|
||||
#include "../../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if ENABLED(MKS_WIFI_MODULE)
|
||||
#include "wifiSerial.h"
|
||||
#include "wifi_module.h"
|
||||
#include "wifi_upload.h"
|
||||
#include "draw_wifi_settings.h"
|
||||
#include "draw_wifi.h"
|
||||
#include "draw_wifi_list.h"
|
||||
#include "draw_wifi_tips.h"
|
||||
#include "draw_cloud_bind.h"
|
||||
#endif
|
||||
|
||||
#define ESP_WIFI 0x02
|
||||
#define AP_MODEL 0x01
|
||||
#define STA_MODEL 0x02
|
||||
|
||||
#define FILE_SYS_USB 0
|
||||
#define FILE_SYS_SD 1
|
||||
|
||||
#define TICK_CYCLE 1
|
||||
|
||||
#define PARA_SEL_ICON_TEXT_COLOR LV_COLOR_MAKE(0x4A, 0x52, 0xFF);
|
||||
|
||||
#define TFT35
|
||||
|
||||
#ifdef TFT35
|
||||
|
||||
#define TFT_WIDTH 480
|
||||
#define TFT_HEIGHT 320
|
||||
|
||||
#define titleHeight 36 // TFT_screen.title_high
|
||||
#define INTERVAL_H 2 // TFT_screen.gap_h // 2
|
||||
#define INTERVAL_V 2 // TFT_screen.gap_v // 2
|
||||
#define BTN_X_PIXEL 117 // TFT_screen.btn_x_pixel
|
||||
#define BTN_Y_PIXEL 140 // TFT_screen.btn_y_pixel
|
||||
|
||||
#define SIMPLE_FIRST_PAGE_GRAP 30
|
||||
|
||||
#define BUTTON_TEXT_Y_OFFSET -20
|
||||
|
||||
#define TITLE_XPOS 3 // TFT_screen.title_xpos
|
||||
#define TITLE_YPOS 5 // TFT_screen.title_ypos
|
||||
|
||||
#define FILE_BTN_CNT 6
|
||||
|
||||
#define OTHER_BTN_XPIEL 117
|
||||
#define OTHER_BTN_YPIEL 92
|
||||
|
||||
#define FILE_PRE_PIC_X_OFFSET 8
|
||||
#define FILE_PRE_PIC_Y_OFFSET 0
|
||||
|
||||
#define PREVIEW_LITTLE_PIC_SIZE 40910 // 400*100+9*101+1
|
||||
#define PREVIEW_SIZE 202720 // (PREVIEW_LITTLE_PIC_SIZE+800*200+201*9+1)
|
||||
|
||||
// machine parameter ui
|
||||
#define PARA_UI_POS_X 10
|
||||
#define PARA_UI_POS_Y 50
|
||||
|
||||
#define PARA_UI_SIZE_X 450
|
||||
#define PARA_UI_SIZE_Y 40
|
||||
|
||||
#define PARA_UI_ARROW_V 12
|
||||
|
||||
#define PARA_UI_BACL_POS_X 400
|
||||
#define PARA_UI_BACL_POS_Y 270
|
||||
|
||||
#define PARA_UI_TURN_PAGE_POS_X 320
|
||||
#define PARA_UI_TURN_PAGE_POS_Y 270
|
||||
|
||||
#define PARA_UI_VALUE_SIZE_X 370
|
||||
#define PARA_UI_VALUE_POS_X 400
|
||||
#define PARA_UI_VALUE_V 5
|
||||
|
||||
#define PARA_UI_STATE_POS_X 380
|
||||
#define PARA_UI_STATE_V 2
|
||||
|
||||
#define PARA_UI_VALUE_SIZE_X_2 200
|
||||
#define PARA_UI_VALUE_POS_X_2 320
|
||||
#define PARA_UI_VALUE_V_2 5
|
||||
|
||||
#define PARA_UI_VALUE_BTN_X_SIZE 70
|
||||
#define PARA_UI_VALUE_BTN_Y_SIZE 28
|
||||
|
||||
#define PARA_UI_BACK_BTN_X_SIZE 70
|
||||
#define PARA_UI_BACK_BTN_Y_SIZE 40
|
||||
|
||||
#define QRCODE_X 20
|
||||
#define QRCODE_Y 40
|
||||
#define QRCODE_WIDTH 160
|
||||
|
||||
#else // ifdef TFT35
|
||||
|
||||
#define TFT_WIDTH 320
|
||||
#define TFT_HEIGHT 240
|
||||
|
||||
#endif // ifdef TFT35
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* C-declarations for C++ */
|
||||
#endif
|
||||
|
||||
extern char public_buf_m[100];
|
||||
extern char public_buf_l[30];
|
||||
|
||||
typedef struct {
|
||||
uint32_t spi_flash_flag;
|
||||
uint8_t disp_rotation_180;
|
||||
bool multiple_language;
|
||||
uint8_t language;
|
||||
uint8_t leveling_mode;
|
||||
bool from_flash_pic;
|
||||
bool finish_power_off;
|
||||
bool pause_reprint;
|
||||
uint8_t wifi_mode_sel;
|
||||
uint8_t fileSysType;
|
||||
uint8_t wifi_type;
|
||||
bool cloud_enable,
|
||||
encoder_enable;
|
||||
xy_int_t trammingPos[5];
|
||||
int filamentchange_load_length,
|
||||
filamentchange_load_speed,
|
||||
filamentchange_unload_length,
|
||||
filamentchange_unload_speed;
|
||||
celsius_t filament_limit_temp;
|
||||
float pausePosX, pausePosY, pausePosZ;
|
||||
uint32_t curFilesize;
|
||||
} CFG_ITMES;
|
||||
|
||||
typedef struct {
|
||||
uint8_t curTempType:1,
|
||||
extruderIndex:3,
|
||||
stepHeat:4,
|
||||
extruderIndexBak:4;
|
||||
bool leveling_first_time:1,
|
||||
para_ui_page:1,
|
||||
configWifi:1,
|
||||
command_send:1,
|
||||
filament_load_heat_flg:1,
|
||||
filament_heat_completed_load:1,
|
||||
filament_unload_heat_flg:1,
|
||||
filament_heat_completed_unload:1,
|
||||
filament_loading_completed:1,
|
||||
filament_unloading_completed:1,
|
||||
filament_loading_time_flg:1,
|
||||
filament_unloading_time_flg:1;
|
||||
uint8_t wifi_name[32];
|
||||
uint8_t wifi_key[64];
|
||||
uint8_t cloud_hostUrl[96];
|
||||
uint8_t extruStep;
|
||||
uint8_t extruSpeed;
|
||||
uint8_t print_state;
|
||||
uint8_t stepPrintSpeed;
|
||||
uint8_t waitEndMoves;
|
||||
uint8_t dialogType;
|
||||
uint8_t F[4];
|
||||
uint8_t filament_rate;
|
||||
uint16_t moveSpeed;
|
||||
uint16_t cloud_port;
|
||||
uint16_t moveSpeed_bak;
|
||||
uint32_t totalSend;
|
||||
uint32_t filament_loading_time,
|
||||
filament_unloading_time,
|
||||
filament_loading_time_cnt,
|
||||
filament_unloading_time_cnt;
|
||||
float move_dist;
|
||||
celsius_t hotendTargetTempBak;
|
||||
float current_x_position_bak,
|
||||
current_y_position_bak,
|
||||
current_z_position_bak,
|
||||
current_e_position_bak;
|
||||
} UI_CFG;
|
||||
|
||||
typedef enum {
|
||||
MAIN_UI,
|
||||
PRINT_READY_UI,
|
||||
PRINT_FILE_UI,
|
||||
PRINTING_UI,
|
||||
MOVE_MOTOR_UI,
|
||||
OPERATE_UI,
|
||||
PAUSE_UI,
|
||||
EXTRUSION_UI,
|
||||
FAN_UI,
|
||||
PRE_HEAT_UI,
|
||||
CHANGE_SPEED_UI,
|
||||
TEMP_UI,
|
||||
SET_UI,
|
||||
ZERO_UI,
|
||||
SPRAYER_UI,
|
||||
MACHINE_UI,
|
||||
LANGUAGE_UI,
|
||||
ABOUT_UI,
|
||||
LOG_UI,
|
||||
DISK_UI,
|
||||
CALIBRATE_UI,
|
||||
DIALOG_UI,
|
||||
WIFI_UI,
|
||||
MORE_UI,
|
||||
FILETRANSFER_UI,
|
||||
FILETRANSFERSTATE_UI,
|
||||
PRINT_MORE_UI,
|
||||
FILAMENTCHANGE_UI,
|
||||
LEVELING_UI,
|
||||
MESHLEVELING_UI,
|
||||
BIND_UI,
|
||||
#if HAS_BED_PROBE
|
||||
NOZZLE_PROBE_OFFSET_UI,
|
||||
#endif
|
||||
TOOL_UI,
|
||||
HARDWARE_TEST_UI,
|
||||
WIFI_LIST_UI,
|
||||
KEYBOARD_UI,
|
||||
WIFI_TIPS_UI,
|
||||
MACHINE_PARA_UI,
|
||||
MACHINE_SETTINGS_UI,
|
||||
TEMPERATURE_SETTINGS_UI,
|
||||
MOTOR_SETTINGS_UI,
|
||||
MACHINETYPE_UI,
|
||||
STROKE_UI,
|
||||
HOME_DIR_UI,
|
||||
ENDSTOP_TYPE_UI,
|
||||
FILAMENT_SETTINGS_UI,
|
||||
LEVELING_SETTIGNS_UI,
|
||||
LEVELING_PARA_UI,
|
||||
DELTA_LEVELING_PARA_UI,
|
||||
MANUAL_LEVELING_POSIGION_UI,
|
||||
MAXFEEDRATE_UI,
|
||||
STEPS_UI,
|
||||
ACCELERATION_UI,
|
||||
JERK_UI,
|
||||
MOTORDIR_UI,
|
||||
HOMESPEED_UI,
|
||||
NOZZLE_CONFIG_UI,
|
||||
HOTBED_CONFIG_UI,
|
||||
ADVANCED_UI,
|
||||
DOUBLE_Z_UI,
|
||||
ENABLE_INVERT_UI,
|
||||
NUMBER_KEY_UI,
|
||||
BABY_STEP_UI,
|
||||
ERROR_MESSAGE_UI,
|
||||
PAUSE_POS_UI,
|
||||
TMC_CURRENT_UI,
|
||||
TMC_MODE_UI,
|
||||
EEPROM_SETTINGS_UI,
|
||||
WIFI_SETTINGS_UI,
|
||||
HOMING_SENSITIVITY_UI,
|
||||
ENCODER_SETTINGS_UI,
|
||||
TOUCH_CALIBRATION_UI,
|
||||
GCODE_UI,
|
||||
MEDIA_SELECT_UI,
|
||||
} DISP_STATE;
|
||||
|
||||
typedef struct {
|
||||
DISP_STATE _disp_state[100];
|
||||
int _disp_index;
|
||||
} DISP_STATE_STACK;
|
||||
|
||||
typedef struct {
|
||||
int16_t days;
|
||||
uint16_t hours;
|
||||
uint8_t minutes;
|
||||
volatile int8_t seconds;
|
||||
int8_t ms_10;
|
||||
int8_t start;
|
||||
} PRINT_TIME;
|
||||
extern PRINT_TIME print_time;
|
||||
|
||||
typedef enum {
|
||||
PrintAcceleration,
|
||||
RetractAcceleration,
|
||||
TravelAcceleration,
|
||||
XAcceleration,
|
||||
YAcceleration,
|
||||
ZAcceleration,
|
||||
E0Acceleration,
|
||||
E1Acceleration,
|
||||
|
||||
XMaxFeedRate,
|
||||
YMaxFeedRate,
|
||||
ZMaxFeedRate,
|
||||
E0MaxFeedRate,
|
||||
E1MaxFeedRate,
|
||||
|
||||
XJerk,
|
||||
YJerk,
|
||||
ZJerk,
|
||||
EJerk,
|
||||
|
||||
Xstep,
|
||||
Ystep,
|
||||
Zstep,
|
||||
E0step,
|
||||
E1step,
|
||||
|
||||
Xcurrent,
|
||||
Ycurrent,
|
||||
Zcurrent,
|
||||
E0current,
|
||||
E1current,
|
||||
|
||||
pause_pos_x,
|
||||
pause_pos_y,
|
||||
pause_pos_z,
|
||||
|
||||
level_pos_x1,
|
||||
level_pos_y1,
|
||||
level_pos_x2,
|
||||
level_pos_y2,
|
||||
level_pos_x3,
|
||||
level_pos_y3,
|
||||
level_pos_x4,
|
||||
level_pos_y4,
|
||||
level_pos_x5,
|
||||
level_pos_y5,
|
||||
#if HAS_BED_PROBE
|
||||
x_offset,
|
||||
y_offset,
|
||||
z_offset,
|
||||
#endif
|
||||
load_length,
|
||||
load_speed,
|
||||
unload_length,
|
||||
unload_speed,
|
||||
filament_temp,
|
||||
|
||||
x_sensitivity,
|
||||
y_sensitivity,
|
||||
z_sensitivity,
|
||||
z2_sensitivity
|
||||
} num_key_value_state;
|
||||
extern num_key_value_state value;
|
||||
|
||||
typedef enum {
|
||||
wifiName,
|
||||
wifiPassWord,
|
||||
wifiConfig,
|
||||
autoLevelGcodeCommand,
|
||||
GCodeCommand,
|
||||
} keyboard_value_state;
|
||||
extern keyboard_value_state keyboard_value;
|
||||
|
||||
extern CFG_ITMES gCfgItems;
|
||||
extern UI_CFG uiCfg;
|
||||
extern DISP_STATE disp_state;
|
||||
extern DISP_STATE last_disp_state;
|
||||
extern DISP_STATE_STACK disp_state_stack;
|
||||
|
||||
extern lv_style_t tft_style_scr;
|
||||
extern lv_style_t tft_style_label_pre;
|
||||
extern lv_style_t tft_style_label_rel;
|
||||
extern lv_style_t style_line;
|
||||
extern lv_style_t style_para_value_pre;
|
||||
extern lv_style_t style_para_value_rel;
|
||||
extern lv_style_t style_num_key_pre;
|
||||
extern lv_style_t style_num_key_rel;
|
||||
extern lv_style_t style_num_text;
|
||||
extern lv_style_t style_sel_text;
|
||||
extern lv_style_t style_para_value;
|
||||
extern lv_style_t style_para_back;
|
||||
extern lv_style_t lv_bar_style_indic;
|
||||
extern lv_style_t style_btn_pr;
|
||||
extern lv_style_t style_btn_rel;
|
||||
|
||||
extern lv_point_t line_points[4][2];
|
||||
|
||||
void gCfgItems_init();
|
||||
void ui_cfg_init();
|
||||
void tft_style_init();
|
||||
extern char *creat_title_text();
|
||||
void preview_gcode_prehandle(char *path);
|
||||
void update_spi_flash();
|
||||
void update_gcode_command(int addr,uint8_t *s);
|
||||
void get_gcode_command(int addr,uint8_t *d);
|
||||
void lv_serial_capt_hook(void *, uint8_t);
|
||||
void lv_eom_hook(void *);
|
||||
#if HAS_GCODE_PREVIEW
|
||||
void disp_pre_gcode(int xpos_pixel, int ypos_pixel);
|
||||
#endif
|
||||
void GUI_RefreshPage();
|
||||
void clear_cur_ui();
|
||||
void draw_return_ui();
|
||||
void sd_detection();
|
||||
void gCfg_to_spiFlah();
|
||||
void print_time_count();
|
||||
|
||||
void LV_TASK_HANDLER();
|
||||
void lv_ex_line(lv_obj_t *line, lv_point_t *points);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C-declarations for C++ */
|
||||
#endif
|
||||
|
||||
// Set the same image for both Released and Pressed
|
||||
void lv_imgbtn_set_src_both(lv_obj_t *imgbtn, const void *src);
|
||||
|
||||
// Set label styles for Released and Pressed
|
||||
void lv_imgbtn_use_label_style(lv_obj_t *imgbtn);
|
||||
|
||||
// Set label styles for Released and Pressed
|
||||
void lv_btn_use_label_style(lv_obj_t *btn);
|
||||
|
||||
// Set the same style for both Released and Pressed
|
||||
void lv_btn_set_style_both(lv_obj_t *btn, lv_style_t *style);
|
||||
|
||||
// Create a screen
|
||||
lv_obj_t* lv_screen_create(DISP_STATE newScreenType, const char *title = nullptr);
|
||||
|
||||
// Create an empty label
|
||||
lv_obj_t* lv_label_create_empty(lv_obj_t *par);
|
||||
|
||||
// Create a label with style and text
|
||||
lv_obj_t* lv_label_create(lv_obj_t *par, const char *text);
|
||||
|
||||
// Create a label with style, position, and text
|
||||
lv_obj_t* lv_label_create(lv_obj_t *par, lv_coord_t x, lv_coord_t y, const char *text);
|
||||
|
||||
// Create a button with callback, ID, and Style.
|
||||
lv_obj_t* lv_btn_create(lv_obj_t *par, lv_event_cb_t cb, const int id, lv_style_t *style=&style_para_value);
|
||||
|
||||
// Create a button with callback and ID, with label style.
|
||||
lv_obj_t* lv_label_btn_create(lv_obj_t *par, lv_event_cb_t cb, const int id=0);
|
||||
|
||||
// Create a button with callback and ID, with button style.
|
||||
lv_obj_t* lv_button_btn_create(lv_obj_t *par, lv_event_cb_t cb, const int id=0);
|
||||
|
||||
// Create a button with position, size, callback, ID, and style.
|
||||
lv_obj_t* lv_btn_create(lv_obj_t *par, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h, lv_event_cb_t cb, const int id, lv_style_t *style);
|
||||
|
||||
// Create a button with position, size, callback, and ID. Style set to style_para_value.
|
||||
lv_obj_t* lv_btn_create(lv_obj_t *par, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h, lv_event_cb_t cb, const int id=0);
|
||||
|
||||
// Create a button with position, size, callback, and ID, with label style.
|
||||
lv_obj_t* lv_label_btn_create(lv_obj_t *par, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h, lv_event_cb_t cb, const int id=0);
|
||||
|
||||
// Create a button with position, size, callback, and ID, with button style.
|
||||
lv_obj_t* lv_button_btn_create(lv_obj_t *par, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h, lv_event_cb_t cb, const int id=0);
|
||||
|
||||
// Create a button with callback and ID. Style set to style_para_back.
|
||||
lv_obj_t* lv_btn_create_back(lv_obj_t *par, lv_event_cb_t cb, const int id=0);
|
||||
|
||||
// Create a button with position, size, callback, and ID. Style set to style_para_back.
|
||||
lv_obj_t* lv_btn_create_back(lv_obj_t *par, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h, lv_event_cb_t cb, const int id=0);
|
||||
|
||||
// Create an image button with image, callback, and ID. Use label style.
|
||||
lv_obj_t* lv_imgbtn_create(lv_obj_t *par, const char *img, lv_event_cb_t cb, const int id=0);
|
||||
|
||||
// Create an image button with image, position, callback, and ID. Use label style.
|
||||
lv_obj_t* lv_imgbtn_create(lv_obj_t *par, const char *img, lv_coord_t x, lv_coord_t y, lv_event_cb_t cb, const int id=0);
|
||||
|
||||
// Create a big image button with a label, follow the LVGL UI standard.
|
||||
lv_obj_t* lv_big_button_create(lv_obj_t *par, const char *img, const char *text, lv_coord_t x, lv_coord_t y, lv_event_cb_t cb, const int id, bool centerLabel = false);
|
||||
|
||||
// Create a menu item, follow the LVGL UI standard.
|
||||
lv_obj_t* lv_screen_menu_item(lv_obj_t *par, const char *text, lv_coord_t x, lv_coord_t y, lv_event_cb_t cb, const int id, const int index, bool drawArrow = true);
|
||||
lv_obj_t* lv_screen_menu_item_1_edit(lv_obj_t *par, const char *text, lv_coord_t x, lv_coord_t y, lv_event_cb_t cb, const int id, const int index, const char *editValue);
|
||||
lv_obj_t* lv_screen_menu_item_2_edit(lv_obj_t *par, const char *text, lv_coord_t x, lv_coord_t y, lv_event_cb_t cb, const int id, const int index, const char *editValue, const int idEdit2, const char *editValue2);
|
||||
lv_obj_t* lv_screen_menu_item_onoff(lv_obj_t *par, const char *text, lv_coord_t x, lv_coord_t y, lv_event_cb_t cb, const int id, const int index, const bool curValue);
|
||||
void lv_screen_menu_item_onoff_update(lv_obj_t *btn, const bool curValue);
|
||||
|
||||
#define _DIA_1(T) (uiCfg.dialogType == DIALOG_##T)
|
||||
#define DIALOG_IS(V...) DO(DIA,||,V)
|
166
Marlin/src/lcd/extui/mks_ui/draw_wifi.cpp
Normal file
166
Marlin/src/lcd/extui/mks_ui/draw_wifi.cpp
Normal file
@ -0,0 +1,166 @@
|
||||
/**
|
||||
* 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_TFT_LVGL_UI
|
||||
|
||||
#include <lv_conf.h>
|
||||
#include "tft_lvgl_configuration.h"
|
||||
|
||||
#if ENABLED(MKS_WIFI_MODULE)
|
||||
|
||||
#include "draw_ui.h"
|
||||
|
||||
extern lv_group_t *g;
|
||||
static lv_obj_t *scr, *wifi_name_text, *wifi_key_text, *wifi_state_text, *wifi_ip_text;
|
||||
|
||||
enum {
|
||||
ID_W_RETURN = 1,
|
||||
ID_W_CLOUD,
|
||||
ID_W_RECONNECT
|
||||
};
|
||||
|
||||
static void event_handler(lv_obj_t *obj, lv_event_t event) {
|
||||
if (event != LV_EVENT_RELEASED) return;
|
||||
clear_cur_ui();
|
||||
switch (obj->mks_obj_id) {
|
||||
case ID_W_RETURN:
|
||||
lv_draw_set();
|
||||
break;
|
||||
case ID_W_CLOUD:
|
||||
lv_draw_cloud_bind();
|
||||
break;
|
||||
#if ENABLED(MKS_WIFI_MODULE)
|
||||
case ID_W_RECONNECT: {
|
||||
uint8_t cmd_wifi_list[] = { 0xA5, 0x07, 0x00, 0x00, 0xFC };
|
||||
raw_send_to_wifi(cmd_wifi_list, COUNT(cmd_wifi_list));
|
||||
lv_draw_wifi_list();
|
||||
} break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void lv_draw_wifi() {
|
||||
scr = lv_screen_create(WIFI_UI);
|
||||
|
||||
lv_obj_t *buttonReconnect = nullptr, *label_Reconnect = nullptr;
|
||||
lv_obj_t *buttonCloud = nullptr, *label_Cloud = nullptr;
|
||||
|
||||
const bool enc_ena = TERN0(HAS_ROTARY_ENCODER, gCfgItems.encoder_enable);
|
||||
|
||||
if (gCfgItems.wifi_mode_sel == STA_MODEL) {
|
||||
|
||||
if (gCfgItems.cloud_enable)
|
||||
buttonCloud = lv_imgbtn_create(scr, "F:/bmp_cloud.bin", BTN_X_PIXEL+INTERVAL_V*2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_W_CLOUD);
|
||||
|
||||
buttonReconnect = lv_imgbtn_create(scr, "F:/bmp_wifi.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_W_RECONNECT);
|
||||
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.cloud_enable) lv_group_add_obj(g, buttonCloud);
|
||||
if (enc_ena) lv_group_add_obj(g, buttonReconnect);
|
||||
#endif
|
||||
|
||||
label_Reconnect = lv_label_create_empty(buttonReconnect);
|
||||
if (gCfgItems.cloud_enable) label_Cloud = lv_label_create_empty(buttonCloud);
|
||||
}
|
||||
|
||||
// Create an Image button
|
||||
lv_obj_t *buttonBack = lv_imgbtn_create(scr, "F:/bmp_return.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_W_RETURN);
|
||||
if (enc_ena) lv_group_add_obj(g, buttonBack);
|
||||
lv_obj_t *label_Back = lv_label_create_empty(buttonBack);
|
||||
|
||||
if (gCfgItems.multiple_language) {
|
||||
if (gCfgItems.wifi_mode_sel == STA_MODEL) {
|
||||
if (gCfgItems.cloud_enable) {
|
||||
lv_label_set_text(label_Cloud, wifi_menu.cloud);
|
||||
lv_obj_align(label_Cloud, buttonCloud, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
||||
}
|
||||
lv_label_set_text(label_Reconnect, wifi_menu.reconnect);
|
||||
lv_obj_align(label_Reconnect, buttonReconnect, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
||||
}
|
||||
lv_label_set_text(label_Back, common_menu.text_back);
|
||||
lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
|
||||
}
|
||||
|
||||
wifi_ip_text = lv_label_create_empty(scr);
|
||||
lv_obj_set_style(wifi_ip_text, &tft_style_label_rel);
|
||||
wifi_name_text = lv_label_create_empty(scr);
|
||||
lv_obj_set_style(wifi_name_text, &tft_style_label_rel);
|
||||
wifi_key_text = lv_label_create_empty(scr);
|
||||
lv_obj_set_style(wifi_key_text, &tft_style_label_rel);
|
||||
wifi_state_text = lv_label_create_empty(scr);
|
||||
lv_obj_set_style(wifi_state_text, &tft_style_label_rel);
|
||||
|
||||
disp_wifi_state();
|
||||
}
|
||||
|
||||
void disp_wifi_state() {
|
||||
strcpy(public_buf_m, wifi_menu.ip);
|
||||
strcat(public_buf_m, ipPara.ip_addr);
|
||||
lv_label_set_text(wifi_ip_text, public_buf_m);
|
||||
lv_obj_align(wifi_ip_text, nullptr, LV_ALIGN_CENTER, 0, -100);
|
||||
|
||||
strcpy(public_buf_m, wifi_menu.wifi);
|
||||
strcat(public_buf_m, wifiPara.ap_name);
|
||||
lv_label_set_text(wifi_name_text, public_buf_m);
|
||||
lv_obj_align(wifi_name_text, nullptr, LV_ALIGN_CENTER, 0, -70);
|
||||
|
||||
if (wifiPara.mode == AP_MODEL) {
|
||||
strcpy(public_buf_m, wifi_menu.key);
|
||||
strcat(public_buf_m, wifiPara.keyCode);
|
||||
lv_label_set_text(wifi_key_text, public_buf_m);
|
||||
lv_obj_align(wifi_key_text, nullptr, LV_ALIGN_CENTER, 0, -40);
|
||||
|
||||
strcpy(public_buf_m, wifi_menu.state_ap);
|
||||
if (wifi_link_state == WIFI_CONNECTED)
|
||||
strcat(public_buf_m, wifi_menu.connected);
|
||||
else if (wifi_link_state == WIFI_NOT_CONFIG)
|
||||
strcat(public_buf_m, wifi_menu.disconnected);
|
||||
else
|
||||
strcat(public_buf_m, wifi_menu.exception);
|
||||
lv_label_set_text(wifi_state_text, public_buf_m);
|
||||
lv_obj_align(wifi_state_text, nullptr, LV_ALIGN_CENTER, 0, -10);
|
||||
}
|
||||
else {
|
||||
strcpy(public_buf_m, wifi_menu.state_sta);
|
||||
if (wifi_link_state == WIFI_CONNECTED)
|
||||
strcat(public_buf_m, wifi_menu.connected);
|
||||
else if (wifi_link_state == WIFI_NOT_CONFIG)
|
||||
strcat(public_buf_m, wifi_menu.disconnected);
|
||||
else
|
||||
strcat(public_buf_m, wifi_menu.exception);
|
||||
lv_label_set_text(wifi_state_text, public_buf_m);
|
||||
lv_obj_align(wifi_state_text, nullptr, LV_ALIGN_CENTER, 0, -40);
|
||||
|
||||
lv_label_set_text(wifi_key_text, "");
|
||||
lv_obj_align(wifi_key_text, nullptr, LV_ALIGN_CENTER, 0, -10);
|
||||
}
|
||||
}
|
||||
|
||||
void lv_clear_wifi() {
|
||||
if (TERN0(HAS_ROTARY_ENCODER, gCfgItems.encoder_enable))
|
||||
lv_group_remove_all_objs(g);
|
||||
lv_obj_del(scr);
|
||||
}
|
||||
|
||||
#endif // MKS_WIFI_MODULE
|
||||
#endif // HAS_TFT_LVGL_UI
|
35
Marlin/src/lcd/extui/mks_ui/draw_wifi.h
Normal file
35
Marlin/src/lcd/extui/mks_ui/draw_wifi.h
Normal file
@ -0,0 +1,35 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* C-declarations for C++ */
|
||||
#endif
|
||||
|
||||
|
||||
void lv_draw_wifi();
|
||||
void lv_clear_wifi();
|
||||
void disp_wifi_state();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C-declarations for C++ */
|
||||
#endif
|
177
Marlin/src/lcd/extui/mks_ui/draw_wifi_list.cpp
Normal file
177
Marlin/src/lcd/extui/mks_ui/draw_wifi_list.cpp
Normal file
@ -0,0 +1,177 @@
|
||||
/**
|
||||
* 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_TFT_LVGL_UI
|
||||
|
||||
#include <lv_conf.h>
|
||||
#include "tft_lvgl_configuration.h"
|
||||
|
||||
#if ENABLED(MKS_WIFI_MODULE)
|
||||
|
||||
#include "draw_ui.h"
|
||||
|
||||
#define NAME_BTN_X 330
|
||||
#define NAME_BTN_Y 48
|
||||
|
||||
#define MARK_BTN_X 0
|
||||
#define MARK_BTN_Y 68
|
||||
|
||||
WIFI_LIST wifi_list;
|
||||
list_menu_def list_menu;
|
||||
|
||||
extern lv_group_t *g;
|
||||
static lv_obj_t *scr;
|
||||
static lv_obj_t *buttonWifiN[NUMBER_OF_PAGE];
|
||||
static lv_obj_t *labelWifiText[NUMBER_OF_PAGE];
|
||||
static lv_obj_t *labelPageText;
|
||||
|
||||
#define ID_WL_RETURN 11
|
||||
#define ID_WL_DOWN 12
|
||||
|
||||
static void event_handler(lv_obj_t *obj, lv_event_t event) {
|
||||
if (event != LV_EVENT_RELEASED) return;
|
||||
|
||||
if (obj->mks_obj_id == ID_WL_RETURN) {
|
||||
clear_cur_ui();
|
||||
lv_draw_set();
|
||||
}
|
||||
else if (obj->mks_obj_id == ID_WL_DOWN) {
|
||||
if (wifi_list.getNameNum > 0) {
|
||||
if ((wifi_list.nameIndex + NUMBER_OF_PAGE) >= wifi_list.getNameNum) {
|
||||
wifi_list.nameIndex = 0;
|
||||
wifi_list.currentWifipage = 1;
|
||||
}
|
||||
else {
|
||||
wifi_list.nameIndex += NUMBER_OF_PAGE;
|
||||
wifi_list.currentWifipage++;
|
||||
}
|
||||
disp_wifi_list();
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (uint8_t i = 0; i < NUMBER_OF_PAGE; i++) {
|
||||
if (obj->mks_obj_id == i + 1) {
|
||||
if (wifi_list.getNameNum != 0) {
|
||||
const bool do_wifi = wifi_link_state == WIFI_CONNECTED && strcmp((const char *)wifi_list.wifiConnectedName, (const char *)wifi_list.wifiName[wifi_list.nameIndex + i]) == 0;
|
||||
wifi_list.nameIndex += i;
|
||||
last_disp_state = WIFI_LIST_UI;
|
||||
lv_clear_wifi_list();
|
||||
if (do_wifi)
|
||||
lv_draw_wifi();
|
||||
else {
|
||||
keyboard_value = wifiConfig;
|
||||
lv_draw_keyboard();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void lv_draw_wifi_list() {
|
||||
scr = lv_screen_create(WIFI_LIST_UI);
|
||||
|
||||
lv_obj_t *buttonDown = lv_imgbtn_create(scr, "F:/bmp_pageDown.bin", OTHER_BTN_XPIEL * 3 + INTERVAL_V * 4, titleHeight + OTHER_BTN_YPIEL + INTERVAL_H, event_handler, ID_WL_DOWN);
|
||||
lv_obj_t *buttonBack = lv_imgbtn_create(scr, "F:/bmp_back.bin", OTHER_BTN_XPIEL * 3 + INTERVAL_V * 4, titleHeight + (OTHER_BTN_YPIEL + INTERVAL_H) * 2, event_handler, ID_WL_RETURN);
|
||||
|
||||
for (uint8_t i = 0; i < NUMBER_OF_PAGE; i++) {
|
||||
buttonWifiN[i] = lv_label_btn_create(scr, 0, NAME_BTN_Y * i + 10 + titleHeight, NAME_BTN_X, NAME_BTN_Y, event_handler, i + 1);
|
||||
labelWifiText[i] = lv_label_create_empty(buttonWifiN[i]);
|
||||
#if HAS_ROTARY_ENCODER
|
||||
uint8_t j = 0;
|
||||
if (gCfgItems.encoder_enable) {
|
||||
j = wifi_list.nameIndex + i;
|
||||
if (j < wifi_list.getNameNum) lv_group_add_obj(g, buttonWifiN[i]);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
labelPageText = lv_label_create_empty(scr);
|
||||
lv_obj_set_style(labelPageText, &tft_style_label_rel);
|
||||
|
||||
wifi_list.nameIndex = 0;
|
||||
wifi_list.currentWifipage = 1;
|
||||
|
||||
if (wifi_link_state == WIFI_CONNECTED && wifiPara.mode == STA_MODEL) {
|
||||
ZERO(wifi_list.wifiConnectedName);
|
||||
memcpy(wifi_list.wifiConnectedName, wifiPara.ap_name, sizeof(wifi_list.wifiConnectedName));
|
||||
}
|
||||
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) {
|
||||
lv_group_add_obj(g, buttonDown);
|
||||
lv_group_add_obj(g, buttonBack);
|
||||
}
|
||||
#else
|
||||
UNUSED(buttonDown);
|
||||
UNUSED(buttonBack);
|
||||
#endif
|
||||
|
||||
disp_wifi_list();
|
||||
}
|
||||
|
||||
void disp_wifi_list() {
|
||||
int8_t tmpStr[WIFI_NAME_BUFFER_SIZE] = { 0 };
|
||||
uint8_t i, j;
|
||||
|
||||
sprintf((char *)tmpStr, list_menu.file_pages, wifi_list.currentWifipage, wifi_list.getPage);
|
||||
lv_label_set_text(labelPageText, (const char *)tmpStr);
|
||||
lv_obj_align(labelPageText, nullptr, LV_ALIGN_CENTER, 50, -100);
|
||||
|
||||
for (i = 0; i < NUMBER_OF_PAGE; i++) {
|
||||
ZERO(tmpStr);
|
||||
|
||||
j = wifi_list.nameIndex + i;
|
||||
if (j >= wifi_list.getNameNum) {
|
||||
lv_label_set_text(labelWifiText[i], (const char *)tmpStr);
|
||||
lv_obj_align(labelWifiText[i], buttonWifiN[i], LV_ALIGN_IN_LEFT_MID, 20, 0);
|
||||
}
|
||||
else {
|
||||
lv_label_set_text(labelWifiText[i], (char const *)wifi_list.wifiName[j]);
|
||||
lv_obj_align(labelWifiText[i], buttonWifiN[i], LV_ALIGN_IN_LEFT_MID, 20, 0);
|
||||
|
||||
const bool btext = (wifi_link_state == WIFI_CONNECTED && strcmp((const char *)wifi_list.wifiConnectedName, (const char *)wifi_list.wifiName[j]) == 0);
|
||||
lv_btn_set_style(buttonWifiN[i], LV_BTN_STYLE_REL, btext ? &style_sel_text : &tft_style_label_rel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void wifi_scan_handle() {
|
||||
if (!DIALOG_IS(WIFI_ENABLE_TIPS) || !uiCfg.command_send) return;
|
||||
last_disp_state = DIALOG_UI;
|
||||
lv_clear_dialog();
|
||||
if (wifi_link_state == WIFI_CONNECTED && wifiPara.mode != AP_MODEL)
|
||||
lv_draw_wifi();
|
||||
else
|
||||
lv_draw_wifi_list();
|
||||
}
|
||||
|
||||
void lv_clear_wifi_list() {
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
|
||||
#endif
|
||||
lv_obj_del(scr);
|
||||
}
|
||||
|
||||
#endif // MKS_WIFI_MODULE
|
||||
#endif // HAS_TFT_LVGL_UI
|
76
Marlin/src/lcd/extui/mks_ui/draw_wifi_list.h
Normal file
76
Marlin/src/lcd/extui/mks_ui/draw_wifi_list.h
Normal file
@ -0,0 +1,76 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { /* C-declarations for C++ */
|
||||
#endif
|
||||
|
||||
void lv_draw_wifi_list();
|
||||
void lv_clear_wifi_list();
|
||||
void disp_wifi_list();
|
||||
void cutWifiName(char *name, int len,char *outStr);
|
||||
void wifi_scan_handle();
|
||||
|
||||
#define NUMBER_OF_PAGE 5
|
||||
|
||||
#define WIFI_TOTAL_NUMBER 20
|
||||
#define WIFI_NAME_BUFFER_SIZE 33
|
||||
|
||||
typedef struct {
|
||||
int8_t getNameNum;
|
||||
int8_t nameIndex;
|
||||
int8_t currentWifipage;
|
||||
int8_t getPage;
|
||||
int8_t RSSI[WIFI_TOTAL_NUMBER];
|
||||
uint8_t wifiName[WIFI_TOTAL_NUMBER][WIFI_NAME_BUFFER_SIZE];
|
||||
uint8_t wifiConnectedName[WIFI_NAME_BUFFER_SIZE];
|
||||
} WIFI_LIST;
|
||||
extern WIFI_LIST wifi_list;
|
||||
|
||||
typedef struct list_menu_disp {
|
||||
const char *title;
|
||||
const char *file_pages;
|
||||
} list_menu_def;
|
||||
extern list_menu_def list_menu;
|
||||
|
||||
typedef struct keyboard_menu_disp {
|
||||
const char *title;
|
||||
const char *apply;
|
||||
const char *password;
|
||||
const char *letter;
|
||||
const char *digital;
|
||||
const char *symbol;
|
||||
const char *space;
|
||||
} keyboard_menu_def;
|
||||
extern keyboard_menu_def keyboard_menu;
|
||||
|
||||
typedef struct tips_menu_disp {
|
||||
const char *joining;
|
||||
const char *failedJoin;
|
||||
const char *wifiConected;
|
||||
} tips_menu_def;
|
||||
extern tips_menu_def tips_menu;
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C-declarations for C++ */
|
||||
#endif
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user