Anet ET4 / ET4P and Anet TFT28 / TFT35 (#20280)
This commit is contained in:
@ -95,7 +95,7 @@ void CANVAS::AddImage(int16_t x, int16_t y, MarlinImage image, uint16_t *colors)
|
||||
if (line >= startLine && line < endLine) {
|
||||
uint16_t *pixel = buffer + x + (line - startLine) * width;
|
||||
for (int16_t j = 0; j < image_width; j++) {
|
||||
if ((x + j >= 0) && (x + j < width)) *pixel = *data;
|
||||
if ((x + j >= 0) && (x + j < width)) *pixel = ENDIAN_COLOR(*data);
|
||||
pixel++;
|
||||
data++;
|
||||
}
|
||||
|
@ -30,6 +30,13 @@
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#if TFT_INTERFACE_FSMC_8BIT
|
||||
// When we have a 8 bit interface, we need to invert the bytes of the color
|
||||
#define ENDIAN_COLOR(C) (((C) >> 8) | ((C) << 8))
|
||||
#else
|
||||
#define ENDIAN_COLOR(C) (C)
|
||||
#endif
|
||||
|
||||
#if HAS_UI_320x240
|
||||
#define TFT_WIDTH 320
|
||||
#define TFT_HEIGHT 240
|
||||
|
@ -158,7 +158,7 @@ void TFT_Queue::fill(uint16_t x, uint16_t y, uint16_t width, uint16_t height, ui
|
||||
task_parameters->y = y;
|
||||
task_parameters->width = width;
|
||||
task_parameters->height = height;
|
||||
task_parameters->color = color;
|
||||
task_parameters->color = ENDIAN_COLOR(color);
|
||||
task_parameters->count = width * height;
|
||||
|
||||
*end_of_queue = TASK_END_OF_QUEUE;
|
||||
@ -200,7 +200,7 @@ void TFT_Queue::set_background(uint16_t color) {
|
||||
last_parameter = end_of_queue;
|
||||
|
||||
parameters->type = CANVAS_SET_BACKGROUND;
|
||||
parameters->color = color;
|
||||
parameters->color = ENDIAN_COLOR(color);
|
||||
|
||||
end_of_queue += sizeof(parametersCanvasBackground_t);
|
||||
task_parameters->count++;
|
||||
@ -227,7 +227,7 @@ void TFT_Queue::add_text(uint16_t x, uint16_t y, uint16_t color, uint8_t *string
|
||||
parameters->type = CANVAS_ADD_TEXT;
|
||||
parameters->x = x;
|
||||
parameters->y = y;
|
||||
parameters->color = color;
|
||||
parameters->color = ENDIAN_COLOR(color);
|
||||
parameters->stringLength = 0;
|
||||
parameters->maxWidth = maxWidth;
|
||||
|
||||
@ -261,18 +261,19 @@ void TFT_Queue::add_image(int16_t x, int16_t y, MarlinImage image, uint16_t *col
|
||||
if (color_mode == HIGHCOLOR) return;
|
||||
|
||||
uint16_t *color = (uint16_t *)end_of_queue;
|
||||
uint8_t number_of_color = 0;
|
||||
uint8_t color_count = 0;
|
||||
|
||||
switch (color_mode) {
|
||||
case GREYSCALE1: number_of_color = 1; break;
|
||||
case GREYSCALE2: number_of_color = 3; break;
|
||||
case GREYSCALE4: number_of_color = 15; break;
|
||||
default:
|
||||
break;
|
||||
case GREYSCALE1: color_count = 1; break;
|
||||
case GREYSCALE2: color_count = 3; break;
|
||||
case GREYSCALE4: color_count = 15; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
while (number_of_color--) {
|
||||
*color++ = *colors++;
|
||||
uint16_t tmp;
|
||||
while (color_count--) {
|
||||
tmp = *colors++;
|
||||
*color++ = ENDIAN_COLOR(tmp);
|
||||
}
|
||||
|
||||
end_of_queue = (uint8_t *)color;
|
||||
@ -326,7 +327,7 @@ void TFT_Queue::add_bar(uint16_t x, uint16_t y, uint16_t width, uint16_t height,
|
||||
parameters->y = y;
|
||||
parameters->width = width;
|
||||
parameters->height = height;
|
||||
parameters->color = color;
|
||||
parameters->color = ENDIAN_COLOR(color);
|
||||
|
||||
end_of_queue += sizeof(parametersCanvasBar_t);
|
||||
task_parameters->count++;
|
||||
@ -344,7 +345,7 @@ void TFT_Queue::add_rectangle(uint16_t x, uint16_t y, uint16_t width, uint16_t h
|
||||
parameters->y = y;
|
||||
parameters->width = width;
|
||||
parameters->height = height;
|
||||
parameters->color = color;
|
||||
parameters->color = ENDIAN_COLOR(color);
|
||||
|
||||
end_of_queue += sizeof(parametersCanvasRectangle_t);
|
||||
task_parameters->count++;
|
||||
|
@ -414,21 +414,21 @@ void MenuEditItemBase::draw_edit_screen(PGM_P const pstr, const char* const valu
|
||||
extern screenFunc_t _manual_move_func_ptr;
|
||||
if (ui.currentScreen != _manual_move_func_ptr && !ui.external_control) {
|
||||
|
||||
#define SLIDER_LENGHT 224
|
||||
#define SLIDER_LENGTH 224
|
||||
#define SLIDER_Y_POSITION 140
|
||||
|
||||
tft.canvas((TFT_WIDTH - SLIDER_LENGHT) / 2, SLIDER_Y_POSITION, SLIDER_LENGHT, 16);
|
||||
tft.canvas((TFT_WIDTH - SLIDER_LENGTH) / 2, SLIDER_Y_POSITION, SLIDER_LENGTH, 16);
|
||||
tft.set_background(COLOR_BACKGROUND);
|
||||
|
||||
int16_t position = (SLIDER_LENGHT - 2) * ui.encoderPosition / maxEditValue;
|
||||
int16_t position = (SLIDER_LENGTH - 2) * ui.encoderPosition / maxEditValue;
|
||||
tft.add_bar(0, 7, 1, 2, ui.encoderPosition == 0 ? COLOR_SLIDER_INACTIVE : COLOR_SLIDER);
|
||||
tft.add_bar(1, 6, position, 4, COLOR_SLIDER);
|
||||
tft.add_bar(position + 1, 6, SLIDER_LENGHT - 2 - position, 4, COLOR_SLIDER_INACTIVE);
|
||||
tft.add_bar(SLIDER_LENGHT - 1, 7, 1, 2, int32_t(ui.encoderPosition) == maxEditValue ? COLOR_SLIDER : COLOR_SLIDER_INACTIVE);
|
||||
tft.add_bar(position + 1, 6, SLIDER_LENGTH - 2 - position, 4, COLOR_SLIDER_INACTIVE);
|
||||
tft.add_bar(SLIDER_LENGTH - 1, 7, 1, 2, int32_t(ui.encoderPosition) == maxEditValue ? COLOR_SLIDER : COLOR_SLIDER_INACTIVE);
|
||||
|
||||
#if ENABLED(TOUCH_SCREEN)
|
||||
tft.add_image((SLIDER_LENGHT - 8) * ui.encoderPosition / maxEditValue, 0, imgSlider, COLOR_SLIDER);
|
||||
touch.add_control(SLIDER, (TFT_WIDTH - SLIDER_LENGHT) / 2, SLIDER_Y_POSITION - 8, SLIDER_LENGHT, 32, maxEditValue);
|
||||
tft.add_image((SLIDER_LENGTH - 8) * ui.encoderPosition / maxEditValue, 0, imgSlider, COLOR_SLIDER);
|
||||
touch.add_control(SLIDER, (TFT_WIDTH - SLIDER_LENGTH) / 2, SLIDER_Y_POSITION - 8, SLIDER_LENGTH, 32, maxEditValue);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -75,8 +75,20 @@
|
||||
#define TOUCH_LANDSCAPE 1
|
||||
#define TOUCH_PORTRAIT 2
|
||||
|
||||
#ifndef TOUCH_CALIBRATION_X
|
||||
#define TOUCH_CALIBRATION_X 0
|
||||
#endif
|
||||
#ifndef TOUCH_CALIBRATION_Y
|
||||
#define TOUCH_CALIBRATION_Y 0
|
||||
#endif
|
||||
#ifndef TOUCH_OFFSET_X
|
||||
#define TOUCH_OFFSET_X 0
|
||||
#endif
|
||||
#ifndef TOUCH_OFFSET_Y
|
||||
#define TOUCH_OFFSET_Y 0
|
||||
#endif
|
||||
#ifndef TOUCH_ORIENTATION
|
||||
#define TOUCH_ORIENTATION TOUCH_LANDSCAPE
|
||||
#define TOUCH_ORIENTATION TOUCH_LANDSCAPE
|
||||
#endif
|
||||
|
||||
#define SSD1963 0x5761
|
||||
|
Reference in New Issue
Block a user