Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance and fix FTDI Eve Touch UI file select screen #22651

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**************
* arrows.cpp *
**************/

/****************************************************************************
* Written By Marcio Teixeira 2021 - SynDaver 3D *
* *
* 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)

#define COORD(X,Y) cx + s*(swapXY ? Y : (flipX ? -X : X)), cy + s*(swapXY ? (flipX ? -X : X) : Y)

namespace FTDI {

void drawArrow(int x, int y, int w, int h, Direction direction) {
const bool swapXY = direction == UP || direction == DOWN;
const bool flipX = direction == UP || direction == LEFT;
const int s = min(w,h);
const int cx = (x + w/2)*16;
const int cy = (y + h/2)*16;

CommandProcessor cmd;
cmd.cmd(SAVE_CONTEXT())
.cmd(LINE_WIDTH(s/2))
.cmd(BEGIN(LINES))
.cmd(VERTEX2F(COORD( 5, 0)))
.cmd(VERTEX2F(COORD( 2,-2)))
.cmd(VERTEX2F(COORD( 5, 0)))
.cmd(VERTEX2F(COORD( 2, 2)))
.cmd(VERTEX2F(COORD( 5, 0)))
.cmd(VERTEX2F(COORD(-5, 0)))
.cmd(RESTORE_CONTEXT());
}

} // namespace FTDI

#endif // FTDI_EXTENDED
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/************
* arrows.h *
************/

/****************************************************************************
* Written By Marcio Teixeira 2021 - SynDaver 3D *
* *
* 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 {
enum Direction {UP, DOWN, LEFT, RIGHT};

void drawArrow(int x, int y, int w, int h, Direction direction);
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#include "sound_list.h"
#include "polygon.h"
#include "poly_ui.h"
#include "arrows.h"
#include "text_box.h"
#include "text_ellipsis.h"
#include "adjuster_widget.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,37 +54,47 @@
#define EDGE_L 0
#define EDGE_R 0

// GRID_X and GRID_Y computes the positions of the divisions on
// _GRID_X and _GRID_Y computes the positions of the divisions on
// the layout grid.
#define GRID_X(x) ((x)*(FTDI::display_width-EDGE_R-EDGE_L)/GRID_COLS+EDGE_L)
#define GRID_Y(y) ((y)*(FTDI::display_height-EDGE_B-EDGE_T)/GRID_ROWS+EDGE_T)
#define _GRID_X(x) ((x)*(FTDI::display_width-EDGE_R-EDGE_L)/GRID_COLS+EDGE_L)
#define _GRID_Y(y) ((y)*(FTDI::display_height-EDGE_B-EDGE_T)/GRID_ROWS+EDGE_T)

// BOX_X, BOX_Y, BOX_W and BOX_X returns the top-left and width
// and height of position on the grid.

#define BOX_X(x) (_GRID_X((x)-1))
#define BOX_Y(y) (_GRID_Y((y)-1))
#define BOX_W(w) (_GRID_X(w) - _GRID_X(0))
#define BOX_H(h) (_GRID_Y(h) - _GRID_Y(0))

// BTN_X, BTN_Y, BTN_W and BTN_X returns the top-left and width
// and height of a button, taking into account the button margins.

#define BTN_X(x) (GRID_X((x)-1) + MARGIN_L)
#define BTN_Y(y) (GRID_Y((y)-1) + MARGIN_T)
#define BTN_W(w) (GRID_X(w) - GRID_X(0) - MARGIN_L - MARGIN_R)
#define BTN_H(h) (GRID_Y(h) - GRID_Y(0) - MARGIN_T - MARGIN_B)
#define BTN_X(x) (BOX_X(x) + MARGIN_L)
#define BTN_Y(y) (BOX_Y(y) + MARGIN_T)
#define BTN_W(w) (BOX_W(w) - MARGIN_L - MARGIN_R)
#define BTN_H(h) (BOX_H(h) - MARGIN_T - MARGIN_B)

// Abbreviations for common phrases, to allow a button to be
// defined in one line of source.
// Abbreviations for common phrases, to allow a box or button
// to be defined in one line of source.
#define BTN_POS(x,y) BTN_X(x), BTN_Y(y)
#define BTN_SIZE(w,h) BTN_W(w), BTN_H(h)
#define BOX_POS(x,y) BOX_X(x), BOX_Y(y)
#define BOX_SIZE(w,h) BOX_W(w), BOX_H(h)

// Draw a reference grid for ease of spacing out widgets.
#define DRAW_LAYOUT_GRID \
{ \
cmd.cmd(LINE_WIDTH(4)); \
for (int i = 1; i <= GRID_COLS; i++) { \
cmd.cmd(BEGIN(LINES)); \
cmd.cmd(VERTEX2F(GRID_X(i) *16, 0 *16)); \
cmd.cmd(VERTEX2F(GRID_X(i) *16, FTDI::display_height *16)); \
cmd.cmd(VERTEX2F(_GRID_X(i) *16, 0 *16)); \
cmd.cmd(VERTEX2F(_GRID_X(i) *16, FTDI::display_height *16)); \
} \
for (int i = 1; i < GRID_ROWS; i++) { \
cmd.cmd(BEGIN(LINES)); \
cmd.cmd(VERTEX2F(0 *16, GRID_Y(i) *16)); \
cmd.cmd(VERTEX2F(FTDI::display_width *16, GRID_Y(i) *16)); \
cmd.cmd(VERTEX2F(0 *16, _GRID_Y(i) *16)); \
cmd.cmd(VERTEX2F(FTDI::display_width *16, _GRID_Y(i) *16)); \
} \
cmd.cmd(LINE_WIDTH(16)); \
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,6 @@ void BedMeshViewScreen::doProbe() {
injectCommands_P(PSTR(BED_LEVELING_COMMANDS));
}

void BedMeshViewScreen::doMeshValidation() {
mydata.count = 0;
GOTO_SCREEN(StatusScreen);
injectCommands_P(PSTR("G28\nM117 Heating...\nG26 R X0 Y0\nG27"));
}

void BedMeshViewScreen::show() {
injectCommands_P(PSTR("G29 L1"));
GOTO_SCREEN(BedMeshViewScreen);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,5 @@ class BedMeshViewScreen : public BedMeshBase, public CachedScreen<BED_MESH_VIEW_
static bool onTouchEnd(uint8_t tag);

static void doProbe();
static void doMeshValidation();
static void show();
};
Loading