Browse Source

FTDI Touch UI fix and reorganize (#21487)

vanilla_fb_2.0.x
Marcio T 3 years ago
committed by GitHub
parent
commit
7573524a14
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 49
      Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/adjuster_widget.cpp
  2. 31
      Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/adjuster_widget.h
  3. 108
      Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/circular_progress.cpp
  4. 27
      Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/circular_progress.h
  5. 3
      Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/ftdi_extended.h
  6. 0
      Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/poly_ui.h
  7. 105
      Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extras/circular_progress.h
  8. 0
      Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/scripts/bitmap2cpp.py
  9. 0
      Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/scripts/svg2cpp.py
  10. 2
      Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_screen.cpp
  11. 2
      Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_printing_dialog_box.cpp
  12. 2
      Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_status_screen.cpp
  13. 1
      Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/boot_screen.cpp
  14. 2
      Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_load_chocolate.cpp
  15. 2
      Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_preheat_screen.cpp
  16. 2
      Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_status_screen.cpp
  17. 4
      Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/screens.h

49
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extras/adjuster_widget.cpp → Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/adjuster_widget.cpp

@ -19,10 +19,9 @@
* location: <https://www.gnu.org/licenses/>. *
****************************************************************************/
#include "../ftdi_eve_lib.h"
#include "../extended/grid_layout.h"
#include "ftdi_extended.h"
#include "adjuster_widget.h"
#if ENABLED(FTDI_EXTENDED)
#define SUB_COLS 9
#define SUB_ROWS 1
@ -30,28 +29,32 @@
#define INC_POS SUB_POS(6,1), SUB_SIZE(2,1)
#define DEC_POS SUB_POS(8,1), SUB_SIZE(2,1)
void draw_adjuster_value(CommandProcessor& cmd, int16_t x, int16_t y, int16_t w, int16_t h, float value, progmem_str units, int8_t width, uint8_t precision) {
char str[width + precision + 10 + (units ? strlen_P((const char*) units) : 0)];
if (isnan(value))
strcpy_P(str, PSTR("-"));
else
dtostrf(value, width, precision, str);
namespace FTDI {
void draw_adjuster_value(CommandProcessor& cmd, int16_t x, int16_t y, int16_t w, int16_t h, float value, progmem_str units, int8_t width, uint8_t precision) {
char str[width + precision + 10 + (units ? strlen_P((const char*) units) : 0)];
if (isnan(value))
strcpy_P(str, PSTR("-"));
else
dtostrf(value, width, precision, str);
if (units) {
strcat_P(str, PSTR(" "));
strcat_P(str, (const char*) units);
}
if (units) {
strcat_P(str, PSTR(" "));
strcat_P(str, (const char*) units);
}
cmd.text(VAL_POS, str);
}
cmd.text(VAL_POS, str);
}
void draw_adjuster(CommandProcessor& cmd, int16_t x, int16_t y, int16_t w, int16_t h, uint8_t tag, float value, progmem_str units, int8_t width, uint8_t precision, draw_mode_t what) {
if (what & BACKGROUND)
cmd.tag(0).button(VAL_POS, F(""), FTDI::OPT_FLAT);
void draw_adjuster(CommandProcessor& cmd, int16_t x, int16_t y, int16_t w, int16_t h, uint8_t tag, float value, progmem_str units, int8_t width, uint8_t precision, draw_mode_t what) {
if (what & BACKGROUND)
cmd.tag(0).button(VAL_POS, F(""), FTDI::OPT_FLAT);
if (what & FOREGROUND) {
draw_adjuster_value(cmd, x, y, w, h, value, units, width, precision);
cmd.tag(tag ).button(INC_POS, F("-"))
.tag(tag+1).button(DEC_POS, F("+"));
if (what & FOREGROUND) {
draw_adjuster_value(cmd, x, y, w, h, value, units, width, precision);
cmd.tag(tag ).button(INC_POS, F("-"))
.tag(tag+1).button(DEC_POS, F("+"));
}
}
}
} // namespace FTDI
#endif // FTDI_EXTENDED

31
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extras/adjuster_widget.h → Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/adjuster_widget.h

@ -20,20 +20,21 @@
****************************************************************************/
#pragma once
#include "../extended/screen_types.h"
void draw_adjuster_value(
CommandProcessor& cmd,
int16_t x, int16_t y, int16_t w, int16_t h,
float value, progmem_str units = nullptr,
int8_t width = 5, uint8_t precision = 1
);
namespace FTDI {
void draw_adjuster_value(
CommandProcessor& cmd,
int16_t x, int16_t y, int16_t w, int16_t h,
float value, progmem_str units = nullptr,
int8_t width = 5, uint8_t precision = 1
);
void draw_adjuster(
CommandProcessor& cmd,
int16_t x, int16_t y, int16_t w, int16_t h,
uint8_t tag,
float value, progmem_str units = nullptr,
int8_t width = 5, uint8_t precision = 1,
draw_mode_t what = BOTH
);
void draw_adjuster(
CommandProcessor& cmd,
int16_t x, int16_t y, int16_t w, int16_t h,
uint8_t tag,
float value, progmem_str units = nullptr,
int8_t width = 5, uint8_t precision = 1,
draw_mode_t what = BOTH
);
}

108
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/circular_progress.cpp

@ -0,0 +1,108 @@
/*************************
* circular_progress.cpp *
*************************/
/****************************************************************************
* Written By Marcio Teixeira 2019 - Aleph Objects, Inc. *
* *
* 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. *
* *
* To view a copy of the GNU General Public License, go to the following *
* location: <https://www.gnu.org/licenses/>. *
****************************************************************************/
#include "ftdi_extended.h"
#if ENABLED(FTDI_EXTENDED)
/* This function draws a circular progress "ring" */
namespace FTDI {
void draw_circular_progress(CommandProcessor& cmd, int x, int y, int w, int h, float percent, char *text, uint32_t bgcolor, uint32_t fgcolor) {
const float rim = 0.3;
const float a = percent/100.0*2.0*PI;
const float a1 = min(PI/2, a);
const float a2 = min(PI/2, a-a1);
const float a3 = min(PI/2, a-a1-a2);
const float a4 = min(PI/2, a-a1-a2-a3);
const int ro = min(w,h) * 8;
const int rr = ro * rim;
const int cx = x * 16 + w * 8;
const int cy = y * 16 + h * 8;
// Load a rim shape into stencil buffer
cmd.cmd(SAVE_CONTEXT());
cmd.cmd(TAG_MASK(0));
cmd.cmd(CLEAR(0,1,0));
cmd.cmd(COLOR_MASK(0,0,0,0));
cmd.cmd(STENCIL_OP(STENCIL_OP_KEEP, STENCIL_OP_INVERT));
cmd.cmd(STENCIL_FUNC(STENCIL_FUNC_ALWAYS, 255, 255));
cmd.cmd(BEGIN(POINTS));
cmd.cmd(POINT_SIZE(ro));
cmd.cmd(VERTEX2F(cx, cy));
cmd.cmd(POINT_SIZE(ro - rr));
cmd.cmd(VERTEX2F(cx, cy));
cmd.cmd(RESTORE_CONTEXT());
// Mask further drawing by stencil buffer
cmd.cmd(SAVE_CONTEXT());
cmd.cmd(STENCIL_FUNC(STENCIL_FUNC_NOTEQUAL, 0, 255));
// Fill the background
cmd.cmd(COLOR_RGB(bgcolor));
cmd.cmd(BEGIN(POINTS));
cmd.cmd(POINT_SIZE(ro));
cmd.cmd(VERTEX2F(cx, cy));
cmd.cmd(COLOR_RGB(fgcolor));
// Paint upper-right quadrant
cmd.cmd(BEGIN(EDGE_STRIP_A));
cmd.cmd(VERTEX2F(cx, cy));
cmd.cmd(VERTEX2F(cx + ro*sin(a1) + 16,cy - ro*cos(a1) + 8));
// Paint lower-right quadrant
if (a > PI/2) {
cmd.cmd(BEGIN(EDGE_STRIP_R));
cmd.cmd(VERTEX2F(cx, cy));
cmd.cmd(VERTEX2F(cx + ro*cos(a2),cy + ro*sin(a2) + 16));
}
// Paint lower-left quadrant
if (a > PI) {
cmd.cmd(BEGIN(EDGE_STRIP_B));
cmd.cmd(VERTEX2F(cx, cy));
cmd.cmd(VERTEX2F(cx - ro*sin(a3) - 8,cy + ro*cos(a3)));
}
// Paint upper-left quadrant
if (a > 1.5*PI) {
cmd.cmd(BEGIN(EDGE_STRIP_L));
cmd.cmd(VERTEX2F(cx, cy));
cmd.cmd(VERTEX2F(cx - ro*cos(a4),cy - ro*sin(a4)));
}
cmd.cmd(RESTORE_CONTEXT());
// Draw the text
cmd.cmd(SAVE_CONTEXT());
cmd.cmd(COLOR_RGB(fgcolor));
cmd.text(x,y,w,h,text, OPT_CENTERX | OPT_CENTERY);
cmd.cmd(RESTORE_CONTEXT());
}
void draw_circular_progress(CommandProcessor& cmd, int x, int y, int w, int h, float percent, uint32_t bgcolor, uint32_t fgcolor) {
char str[5];
sprintf(str,"%d\%%",int(percent));
draw_circular_progress(cmd, x, y, w, h, percent, str, bgcolor, fgcolor);
}
} // namespace FTDI
#endif // FTDI_EXTENDED

27
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/circular_progress.h

@ -0,0 +1,27 @@
/***********************
* circular_progress.h *
***********************/
/****************************************************************************
* Written By Marcio Teixeira 2019 - Aleph Objects, Inc. *
* *
* 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. *
* *
* To view a copy of the GNU General Public License, go to the following *
* location: <https://www.gnu.org/licenses/>. *
****************************************************************************/
#pragma once
namespace FTDI {
void draw_circular_progress(CommandProcessor& cmd, int x, int y, int w, int h, float percent, char *text, uint32_t bgcolor, uint32_t fgcolor);
void draw_circular_progress(CommandProcessor& cmd, int x, int y, int w, int h, float percent, uint32_t bgcolor, uint32_t fgcolor);
}

3
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/ftdi_extended.h

@ -47,6 +47,9 @@
#include "sound_player.h"
#include "sound_list.h"
#include "polygon.h"
#include "poly_ui.h"
#include "text_box.h"
#include "text_ellipsis.h"
#include "adjuster_widget.h"
#include "circular_progress.h"
#endif

0
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extras/poly_ui.h → Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/poly_ui.h

105
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extras/circular_progress.h

@ -1,105 +0,0 @@
/***********************
* circular_progress.h *
***********************/
/****************************************************************************
* Written By Marcio Teixeira 2019 - Aleph Objects, Inc. *
* *
* 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. *
* *
* To view a copy of the GNU General Public License, go to the following *
* location: <https://www.gnu.org/licenses/>. *
****************************************************************************/
#pragma once
/* This function draws a circular progress "ring" */
void draw_circular_progress(CommandProcessor& cmd, int x, int y, int w, int h, float percent, char *text, uint32_t bgcolor, uint32_t fgcolor) {
using namespace FTDI;
const float rim = 0.3;
const float a = percent/100.0*2.0*PI;
const float a1 = min(PI/2, a);
const float a2 = min(PI/2, a-a1);
const float a3 = min(PI/2, a-a1-a2);
const float a4 = min(PI/2, a-a1-a2-a3);
const int ro = min(w,h) * 8;
const int rr = ro * rim;
const int cx = x * 16 + w * 8;
const int cy = y * 16 + h * 8;
// Load a rim shape into stencil buffer
cmd.cmd(SAVE_CONTEXT());
cmd.cmd(TAG_MASK(0));
cmd.cmd(CLEAR(0,1,0));
cmd.cmd(COLOR_MASK(0,0,0,0));
cmd.cmd(STENCIL_OP(STENCIL_OP_KEEP, STENCIL_OP_INVERT));
cmd.cmd(STENCIL_FUNC(STENCIL_FUNC_ALWAYS, 255, 255));
cmd.cmd(BEGIN(POINTS));
cmd.cmd(POINT_SIZE(ro));
cmd.cmd(VERTEX2F(cx, cy));
cmd.cmd(POINT_SIZE(ro - rr));
cmd.cmd(VERTEX2F(cx, cy));
cmd.cmd(RESTORE_CONTEXT());
// Mask further drawing by stencil buffer
cmd.cmd(SAVE_CONTEXT());
cmd.cmd(STENCIL_FUNC(STENCIL_FUNC_NOTEQUAL, 0, 255));
// Fill the background
cmd.cmd(COLOR_RGB(bgcolor));
cmd.cmd(BEGIN(POINTS));
cmd.cmd(POINT_SIZE(ro));
cmd.cmd(VERTEX2F(cx, cy));
cmd.cmd(COLOR_RGB(fgcolor));
// Paint upper-right quadrant
cmd.cmd(BEGIN(EDGE_STRIP_A));
cmd.cmd(VERTEX2F(cx, cy));
cmd.cmd(VERTEX2F(cx + ro*sin(a1) + 16,cy - ro*cos(a1) + 8));
// Paint lower-right quadrant
if (a > PI/2) {
cmd.cmd(BEGIN(EDGE_STRIP_R));
cmd.cmd(VERTEX2F(cx, cy));
cmd.cmd(VERTEX2F(cx + ro*cos(a2),cy + ro*sin(a2) + 16));
}
// Paint lower-left quadrant
if (a > PI) {
cmd.cmd(BEGIN(EDGE_STRIP_B));
cmd.cmd(VERTEX2F(cx, cy));
cmd.cmd(VERTEX2F(cx - ro*sin(a3) - 8,cy + ro*cos(a3)));
}
// Paint upper-left quadrant
if (a > 1.5*PI) {
cmd.cmd(BEGIN(EDGE_STRIP_L));
cmd.cmd(VERTEX2F(cx, cy));
cmd.cmd(VERTEX2F(cx - ro*cos(a4),cy - ro*sin(a4)));
}
cmd.cmd(RESTORE_CONTEXT());
// Draw the text
cmd.cmd(SAVE_CONTEXT());
cmd.cmd(COLOR_RGB(fgcolor));
cmd.text(x,y,w,h,text, OPT_CENTERX | OPT_CENTERY);
cmd.cmd(RESTORE_CONTEXT());
}
void draw_circular_progress(CommandProcessor& cmd, int x, int y, int w, int h, float percent, uint32_t bgcolor, uint32_t fgcolor) {
char str[5];
sprintf(str,"%d\%%",int(percent));
draw_circular_progress(cmd, x, y, w, h, percent, str, bgcolor, fgcolor);
}

0
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extras/bitmap2cpp.py → Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/scripts/bitmap2cpp.py

0
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extras/svg2cpp.py → Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/scripts/svg2cpp.py

2
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_screen.cpp

@ -25,8 +25,6 @@
#ifdef FTDI_BED_MESH_SCREEN
#include "../ftdi_eve_lib/extras/adjuster_widget.h"
using namespace FTDI;
using namespace Theme;
using namespace ExtUI;

2
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_printing_dialog_box.cpp

@ -25,8 +25,6 @@
#ifdef FTDI_BIO_PRINTING_DIALOG_BOX
#include "../ftdi_eve_lib/extras/circular_progress.h"
using namespace FTDI;
using namespace ExtUI;
using namespace Theme;

2
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bio_status_screen.cpp

@ -26,8 +26,6 @@
#ifdef FTDI_BIO_STATUS_SCREEN
#include "../ftdi_eve_lib/extras/poly_ui.h"
#if ENABLED(TOUCH_UI_PORTRAIT)
#include "bio_printer_ui_portrait.h"
#else

1
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/boot_screen.cpp

@ -26,7 +26,6 @@
#ifdef FTDI_BOOT_SCREEN
#include "../ftdi_eve_lib/extras/poly_ui.h"
#include "../archim2-flash/flash_storage.h"
#if ENABLED(SHOW_CUSTOM_BOOTSCREEN)

2
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_load_chocolate.cpp

@ -27,8 +27,6 @@
#ifdef FTDI_COCOA_LOAD_CHOCOLATE_SCREEN
#include "../ftdi_eve_lib/extras/poly_ui.h"
#include "cocoa_press_ui.h"
#define POLY(A) PolyUI::poly_reader_t(A, sizeof(A)/sizeof(A[0]))

2
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_preheat_screen.cpp

@ -25,8 +25,6 @@
#ifdef FTDI_COCOA_PREHEAT_SCREEN
#include "../ftdi_eve_lib/extras/circular_progress.h"
using namespace FTDI;
using namespace ExtUI;
using namespace Theme;

2
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/cocoa_press_status_screen.cpp

@ -26,8 +26,6 @@
#ifdef FTDI_COCOA_STATUS_SCREEN
#include "../ftdi_eve_lib/extras/poly_ui.h"
#include "cocoa_press_ui.h"
#define POLY(A) PolyUI::poly_reader_t(A, sizeof(A)/sizeof(A[0]))

4
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/screens.h

@ -22,6 +22,8 @@
#pragma once
#if ENABLED(TOUCH_UI_FTDI_EVE)
#include "../ftdi_eve_lib/ftdi_eve_lib.h"
#include "../language/language.h"
#include "../theme/theme.h"
@ -260,3 +262,5 @@ enum {
#if NUM_LANGUAGES > 1
#include "language_menu.h"
#endif
#endif // TOUCH_UI_FTDI_EVE

Loading…
Cancel
Save