Skip to content

Commit

Permalink
Tiny fixes, tiny program size reduction (#2459)
Browse files Browse the repository at this point in the history
  • Loading branch information
kisslorand authored Mar 26, 2022
1 parent e17407d commit baf2ae2
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 111 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ label_disable_steppers:Mot.tilt
label_xy_unlock:X-Y Felold
label_start_print:%s\nfájl kiválasztva.\nElindítod a nyomtatását?
label_stop_print:Megállítod a nyomtatást?
label_is_pause:A művelet tiltva van a nyomtatás alatt.\nSzünetelteted a nyomtatást?
label_m0_pause:Szünetelés M0 parancsal
label_is_pause:Nyomtatás idején a művelet tiltott.\nSzünetelteted a nyomtatást?
label_m0_pause:Szünetelés M0 paranccsal
label_test:Teszt
label_deploy:Bevetés
label_stow:Elhelyezés
Expand Down
4 changes: 2 additions & 2 deletions TFT/src/User/API/Language/language_hu.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@

#define STRING_START_PRINT "%s\nfájl kiválasztva.\nElindítod a nyomtatását?"
#define STRING_STOP_PRINT "Megállítod a nyomtatást?"
#define STRING_IS_PAUSE "A művelet tiltva van a nyomtatás alatt.\nSzünetelteted a nyomtatást?"
#define STRING_M0_PAUSE "Szünetelés M0 parancsal"
#define STRING_IS_PAUSE "Nyomtatás idején a művelet tiltott.\nSzünetelteted a nyomtatást?"
#define STRING_M0_PAUSE "Szünetelés M0 paranccsal"

#define STRING_TEST "Teszt"
#define STRING_DEPLOY "Bevetés"
Expand Down
32 changes: 14 additions & 18 deletions TFT/src/User/API/UI/GUI.c
Original file line number Diff line number Diff line change
Expand Up @@ -1206,27 +1206,23 @@ void GUI_DrawButton(const BUTTON *button, uint8_t pressed)

void GUI_DrawWindow(const WINDOW *window, const uint8_t *title, const uint8_t *inf, bool actionBar)
{
GUI_RECT w_rect = window->rect;

uint16_t title_height = window->titleHeight;
// uint16_t action_height = window->actionBarHeight;
uint16_t title_txt_y0 = w_rect.y0 + (title_height - BYTE_HEIGHT) / 2;
uint16_t title_y0 = window->rect.y0 + (window->titleHeight - BYTE_HEIGHT) / 2;
uint16_t title_y1 = window->rect.y0 + window->titleHeight;
uint16_t action_y0 = (actionBar) ? window->rect.y1 - window->actionBarHeight : w_rect.y1;
uint16_t info_y1 = (actionBar) ? window->rect.y1 - window->actionBarHeight : window->rect.y1;
uint8_t margin = BYTE_WIDTH / 2;

// draw title background
GUI_SetColor(window->title.backColor);
GUI_FillRect(w_rect.x0, w_rect.y0, w_rect.x1, title_y1);
GUI_FillRect(window->rect.x0, window->rect.y0, window->rect.x1, title_y1);

// draw info background
GUI_SetColor(window->info.backColor);
GUI_FillRect(w_rect.x0, title_y1, w_rect.x1, action_y0);
GUI_FillRect(window->rect.x0, title_y1, window->rect.x1, info_y1);

if (actionBar)
{ // draw action bar background
GUI_SetColor(window->actionBar.backColor);
GUI_FillRect(w_rect.x0, action_y0, w_rect.x1, w_rect.y1);
GUI_FillRect(window->rect.x0, info_y1, window->rect.x1, window->rect.y1);
}

// draw window type icon
Expand Down Expand Up @@ -1262,37 +1258,37 @@ void GUI_DrawWindow(const WINDOW *window, const uint8_t *title, const uint8_t *i
}

GUI_SetTextMode(GUI_TEXTMODE_TRANS);
GUI_DispString(w_rect.x0 + BYTE_WIDTH, title_txt_y0, char_icon);
GUI_DispString(window->rect.x0 + BYTE_WIDTH, title_y0, char_icon);

// draw title accent line
GUI_DrawRect(w_rect.x0, title_y1 - 1, w_rect.x1, title_y1 + 1);
GUI_DrawRect(window->rect.x0, title_y1 - 1, window->rect.x1, title_y1 + 1);

if (actionBar)
{ // draw actionbar accent line
GUI_SetColor(GRAY);
GUI_DrawRect(w_rect.x0, action_y0 - 1, w_rect.x1, action_y0 + 1);
GUI_DrawRect(window->rect.x0, info_y1 - 1, window->rect.x1, info_y1 + 1);
}

// draw window border
GUI_SetColor(window->lineColor);

for (uint8_t i = 0; i < window->lineWidth; i++)
{
GUI_DrawRect(w_rect.x0 - i, w_rect.y0 - i, w_rect.x1 + i, w_rect.y1 + i);
GUI_DrawRect(window->rect.x0 - i, window->rect.y0 - i, window->rect.x1 + i, window->rect.y1 + i);
}

// draw title text
GUI_SetColor(window->title.fontColor);
GUI_DispLenString(w_rect.x0 + BYTE_HEIGHT * 2, title_txt_y0, title,
window->rect.x1 - (w_rect.x0 + BYTE_HEIGHT * 2), true);
GUI_DispLenString(window->rect.x0 + BYTE_HEIGHT * 2, title_y0, title,
window->rect.x1 - (window->rect.x0 + BYTE_HEIGHT * 2), true);

// draw info text
GUI_SetColor(window->info.fontColor);

if ((GUI_StrPixelWidth(inf) < w_rect.x1 - w_rect.x0) && (strchr((const char *)inf,'\n') == NULL))
GUI_DispStringInRect(w_rect.x0, title_y1, w_rect.x1, action_y0, inf);
if ((GUI_StrPixelWidth(inf) < window->rect.x1 - window->rect.x0) && (strchr((const char *)inf,'\n') == NULL))
GUI_DispStringInRect(window->rect.x0, title_y1, window->rect.x1, info_y1, inf);
else
GUI_DispStringInRectEOL(w_rect.x0 + margin, title_y1 + margin, w_rect.x1 - margin, action_y0 - margin, inf);
GUI_DispStringInRectEOL(window->rect.x0 + margin, title_y1 + margin, window->rect.x1 - margin, info_y1 - margin, inf);

GUI_RestoreColorDefault();
}
1 change: 1 addition & 0 deletions TFT/src/User/API/parseACK.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ void parseACK(void)
storeCmd("M211\n"); // retrieve the software endstops state
storeCmd("M115\n"); // as last command to identify the FW type!
storeCmd("M401 H\n"); // check the state of BLTouch HighSpeed mode
storeCmd("M402\n)"); // if Marlin is older than 12.III.2022 BLTouch probe will deploy by "M401 H" so it needs to be stowed back
}

infoHost.connected = true;
Expand Down
176 changes: 87 additions & 89 deletions TFT/src/User/Menu/BLTouch.c
Original file line number Diff line number Diff line change
@@ -1,89 +1,87 @@
#include "BLTouch.h"
#include "includes.h"

#define SERVO_GCODE "M280 P0 S%d\n"

static BLT_HS_MODE bltHSmode = HS_DISABLED;

void setHSmode(BLT_HS_MODE hsMode)
{
bltHSmode = hsMode;
}


void menuBLTouch(void)
{
KEY_VALUES key_num = KEY_IDLE;
uint8_t hsModeOld = HS_DISABLED;

MENUITEMS BLTouchItems = {
// title
LABEL_BLTOUCH,
// icon label
{
{ICON_BLTOUCH_RESET, LABEL_RESET},
{ICON_BLTOUCH_TEST, LABEL_TEST},
{ICON_BLTOUCH_DEPLOY, LABEL_DEPLOY},
{ICON_BLTOUCH_STOW, LABEL_STOW},
{ICON_BLTOUCH_REPEAT, LABEL_REPEAT},
{ICON_NULL, LABEL_NULL},
{ICON_NULL, LABEL_NULL},
{ICON_BACK, LABEL_BACK},
}
};

menuDrawPage(&BLTouchItems);

while (MENU_IS(menuBLTouch))
{
key_num = menuKeyGetValue();
switch (key_num)
{
case KEY_ICON_0:
storeCmd(SERVO_GCODE, 160);
break;

case KEY_ICON_1:
storeCmd(SERVO_GCODE, 120);
break;

case KEY_ICON_2:
storeCmd(SERVO_GCODE, 10);
break;

case KEY_ICON_3:
storeCmd(SERVO_GCODE, 90);
break;

case KEY_ICON_4:
storeCmd("G28\n");
storeCmd("M48\n");
break;

case KEY_ICON_5:
if (infoMachineSettings.firmwareType == FW_MARLIN && bltHSmode != HS_DISABLED)
{
bltHSmode = !bltHSmode;
storeCmd("M401 S%u\n", bltHSmode);
}
break;

case KEY_ICON_7:
CLOSE_MENU();
break;

default:
break;
}

if (infoMachineSettings.firmwareType == FW_MARLIN && bltHSmode != hsModeOld)
{
hsModeOld = bltHSmode;
BLTouchItems.items[5].icon = (bltHSmode == HS_ON) ? ICON_FAST_SPEED : ICON_SLOW_SPEED;
BLTouchItems.items[5].label.index = (bltHSmode == HS_ON) ? LABEL_HS_ON : LABEL_HS_OFF;
menuDrawItem(&BLTouchItems.items[5], 5);
}

loopProcess();
}
}
#include "BLTouch.h"
#include "includes.h"

#define SERVO_GCODE "M280 P0 S%d\n"

static BLT_HS_MODE bltHSmode = HS_DISABLED;

void setHSmode(BLT_HS_MODE hsMode)
{
bltHSmode = hsMode;
}


void menuBLTouch(void)
{
KEY_VALUES key_num = KEY_IDLE;
uint8_t hsModeOld = HS_DISABLED;

MENUITEMS BLTouchItems = {
// title
LABEL_BLTOUCH,
// icon label
{
{ICON_BLTOUCH_RESET, LABEL_RESET},
{ICON_BLTOUCH_TEST, LABEL_TEST},
{ICON_BLTOUCH_DEPLOY, LABEL_DEPLOY},
{ICON_BLTOUCH_STOW, LABEL_STOW},
{ICON_BLTOUCH_REPEAT, LABEL_REPEAT},
{ICON_NULL, LABEL_NULL},
{ICON_NULL, LABEL_NULL},
{ICON_BACK, LABEL_BACK},
}
};

menuDrawPage(&BLTouchItems);

while (MENU_IS(menuBLTouch))
{
key_num = menuKeyGetValue();
switch (key_num)
{
case KEY_ICON_0:
storeCmd(SERVO_GCODE, 160);
break;

case KEY_ICON_1:
storeCmd(SERVO_GCODE, 120);
break;

case KEY_ICON_2:
storeCmd(SERVO_GCODE, 10);
break;

case KEY_ICON_3:
storeCmd(SERVO_GCODE, 90);
break;

case KEY_ICON_4:
storeCmd("G28\n");
storeCmd("M48\n");
break;

case KEY_ICON_5:
if (infoMachineSettings.firmwareType == FW_MARLIN && bltHSmode != HS_DISABLED)
storeCmd("M401 S%u\n", !bltHSmode); // Switch HS mode On/Off
// "bltHSmode" will be updated in parseACK() if "M401 Sx" is sent successfully
break;

case KEY_ICON_7:
CLOSE_MENU();
break;

default:
break;
}

if (infoMachineSettings.firmwareType == FW_MARLIN && bltHSmode != hsModeOld)
{
hsModeOld = bltHSmode;
BLTouchItems.items[5].icon = (bltHSmode == HS_ON) ? ICON_FAST_SPEED : ICON_SLOW_SPEED;
BLTouchItems.items[5].label.index = (bltHSmode == HS_ON) ? LABEL_HS_ON : LABEL_HS_OFF;
menuDrawItem(&BLTouchItems.items[5], 5);
}

loopProcess();
}
}

0 comments on commit baf2ae2

Please sign in to comment.