Skip to content

Commit

Permalink
Another FW size reduction
Browse files Browse the repository at this point in the history
  • Loading branch information
kisslorand committed Jun 5, 2023
1 parent 8a08dce commit 01da6d1
Show file tree
Hide file tree
Showing 38 changed files with 550 additions and 574 deletions.
2 changes: 1 addition & 1 deletion TFT/src/User/API/AddonHardware.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ bool FIL_SmartRunoutDetect(void)
return false;
}

bool FIL_IsRunout(void)
static bool FIL_IsRunout(void)
{
if (GET_BIT(infoSettings.runout, RUNOUT_ENABLED))
{
Expand Down
6 changes: 3 additions & 3 deletions TFT/src/User/API/LevelingControl.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ typedef struct XY_coord
LEVELING_POINT probedPoint = LEVEL_NO_POINT; // last probed point or LEVEL_NO_POINT in case of no new updates
float probedZ = 0.0f; // last Z offset measured by probe

int16_t setCoordValue(AXIS axis, ALIGN_POSITION align)
static int16_t __attribute__ ((noinline)) setCoordValue(AXIS axis, ALIGN_POSITION align)
{
return ((align == LEFT || align == BOTTOM) ? infoSettings.machine_size_min[axis] + infoSettings.level_edge
: infoSettings.machine_size_max[axis] - infoSettings.level_edge) - infoParameters.HomeOffset[axis];
}

void levelingGetPointCoords(LEVELING_POINT_COORDS coords)
static void levelingGetPointCoords(LEVELING_POINT_COORDS coords)
{
int16_t x_left = setCoordValue(X_AXIS, LEFT);
int16_t x_right = setCoordValue(X_AXIS, RIGHT);
Expand Down Expand Up @@ -45,7 +45,7 @@ void levelingGetPointCoords(LEVELING_POINT_COORDS coords)
coords[LEVEL_CENTER] = (COORD){(x_left + x_right) / 2, (y_bottom + y_top) / 2};
}

LEVELING_POINT levelingGetPoint(int16_t x, int16_t y)
static LEVELING_POINT levelingGetPoint(int16_t x, int16_t y)
{
LEVELING_POINT_COORDS coords;
uint8_t i;
Expand Down
2 changes: 1 addition & 1 deletion TFT/src/User/API/Notification.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ bool toastRunning(void)
}

// check if any new notification is available
bool toastAvailable(void)
static bool toastAvailable(void)
{
for (int i = 0; i < TOAST_MSG_COUNT; i++)
{
Expand Down
10 changes: 5 additions & 5 deletions TFT/src/User/API/Printing.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ bool getRunoutAlarm(void)
return filamentRunoutAlarm;
}

void clearQueueAndMore(void)
static void clearQueueAndMore(void)
{
clearCmdQueue();
setRunoutAlarmFalse();
Expand All @@ -75,7 +75,7 @@ void resumeAndContinue(void)
sendEmergencyCmd("M876 S1\n");
}

void abortAndTerminate(void)
static void abortAndTerminate(void)
{
clearQueueAndMore();

Expand All @@ -98,7 +98,7 @@ void abortAndTerminate(void)
}
}

void loopBreakToCondition(CONDITION_CALLBACK condCallback)
static void loopBreakToCondition(CONDITION_CALLBACK condCallback)
{
// M108 is sent to Marlin because consecutive blocking operations such as heating bed, extruder may defer processing of other gcodes.
// If there's any ongoing blocking command, "M108" will take that out from the closed loop and a response will be received
Expand Down Expand Up @@ -319,7 +319,7 @@ void preparePrintSummary(void)
}

// send print codes [0: start gcode, 1: end gcode 2: cancel gcode]
void sendPrintCodes(uint8_t index)
static void sendPrintCodes(uint8_t index)
{
PRINT_GCODES printcodes;

Expand Down Expand Up @@ -365,7 +365,7 @@ void clearInfoPrint(void)
memset(&infoPrinting, 0, sizeof(PRINTING));
}

void completePrint(void)
static void completePrint(void)
{
infoPrinting.cur = infoPrinting.size; // always update the print progress to 100% even if the print terminated
infoPrinting.progress = 100; // set progress to 100% in case progress is controlled by slicer
Expand Down
104 changes: 52 additions & 52 deletions TFT/src/User/API/UI/ListItem.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void setDynamicValue(uint8_t i, float value)
}

// draw item pressed feedback
void DrawListItemPress(const GUI_RECT * rect, bool pressed)
static void DrawListItemPress(const GUI_RECT * rect, bool pressed)
{
if (pressed)
{
Expand All @@ -57,6 +57,57 @@ void DrawListItemPress(const GUI_RECT * rect, bool pressed)
GUI_RestoreColorDefault();
}

// draw title text of list item
static void draw_itemtitle(GUI_POINT pos, LABEL label, uint8_t position, int textarea_width)
{
if (label.index != LABEL_NULL)
{
int textarea_width = LISTITEM_WIDTH - (pos.x + 1); // width after removing the width for icon

if (label.index == LABEL_DYNAMIC)
GUI_DispLenString(pos.x, pos.y, (uint8_t *)getDynamicLabel(position), textarea_width, true);
else
GUI_DispLenString(pos.x, pos.y, labelGetAddress(&label), textarea_width, true);
}
}

// display toggle button
static void ListItem_DisplayToggle(uint16_t sx, uint16_t sy, uint8_t iconchar_state)
{
GUI_SetTextMode(GUI_TEXTMODE_NORMAL);
GUI_SetColor(infoSettings.list_border_color);
_GUI_DispString(sx, sy, (uint8_t *)(char *)IconCharSelect(CHARICON_TOGGLE_BODY));

GUI_SetTextMode(GUI_TEXTMODE_TRANS);
GUI_SetColor(charIconColor[iconchar_state]);

_GUI_DispString(sx + (iconchar_state == CHARICON_TOGGLE_OFF ? 0 : BYTE_HEIGHT), sy, IconCharSelect(CHARICON_TOGGLE_SWITCH));

GUI_RestoreColorDefault();
}

// draw custom value for list item
static void ListItem_DisplayCustomValue(const GUI_RECT * rect, LABEL value, int i)
{
const GUI_RECT rectVal = {rect->x1 - BYTE_WIDTH * (CUSTOM_VAL_LEN + 1) - 1, rect->y0 + (LISTITEM_HEIGHT - BYTE_HEIGHT) / 2, rect->x1 - 1,
rect->y1 - (LISTITEM_HEIGHT - BYTE_HEIGHT) / 2};

GUI_ClearPrect(&rectVal);
GUI_SetTextMode(GUI_TEXTMODE_NORMAL);
GUI_SetColor(infoSettings.list_border_color);
GUI_DrawPrect(&rectVal);

GUI_SetTextMode(GUI_TEXTMODE_TRANS);
GUI_SetColor(LI_VAL_COLOR);

if (value.index == LABEL_CUSTOM_VALUE || value.index == LABEL_DYNAMIC) // show custom text value
GUI_DispStringInPrect(&rectVal, (uint8_t *)getDynamicTextValue(i));
else // show regular text labels
GUI_DispStringInPrect(&rectVal, (int32_t)value.index);

GUI_RestoreColorDefault();
}

void ListItem_Display(const GUI_RECT * rect, uint8_t position, const LISTITEM * curitem, bool pressed)
{
// draw navigation icons
Expand Down Expand Up @@ -161,54 +212,3 @@ void ListItem_Display(const GUI_RECT * rect, uint8_t position, const LISTITEM *
}
GUI_RestoreColorDefault();
}

// draw title text of list item
void draw_itemtitle(GUI_POINT pos, LABEL label, uint8_t position, int textarea_width)
{
if (label.index != LABEL_NULL)
{
int textarea_width = LISTITEM_WIDTH - (pos.x + 1); // width after removing the width for icon

if (label.index == LABEL_DYNAMIC)
GUI_DispLenString(pos.x, pos.y, (uint8_t *)getDynamicLabel(position), textarea_width, true);
else
GUI_DispLenString(pos.x, pos.y, labelGetAddress(&label), textarea_width, true);
}
}

// display toggle button
void ListItem_DisplayToggle(uint16_t sx, uint16_t sy, uint8_t iconchar_state)
{
GUI_SetTextMode(GUI_TEXTMODE_NORMAL);
GUI_SetColor(infoSettings.list_border_color);
_GUI_DispString(sx, sy, (uint8_t *)(char *)IconCharSelect(CHARICON_TOGGLE_BODY));

GUI_SetTextMode(GUI_TEXTMODE_TRANS);
GUI_SetColor(charIconColor[iconchar_state]);

_GUI_DispString(sx + (iconchar_state == CHARICON_TOGGLE_OFF ? 0 : BYTE_HEIGHT), sy, IconCharSelect(CHARICON_TOGGLE_SWITCH));

GUI_RestoreColorDefault();
}

// draw custom value for list item
void ListItem_DisplayCustomValue(const GUI_RECT * rect, LABEL value, int i)
{
const GUI_RECT rectVal = {rect->x1 - BYTE_WIDTH * (CUSTOM_VAL_LEN + 1) - 1, rect->y0 + (LISTITEM_HEIGHT - BYTE_HEIGHT) / 2, rect->x1 - 1,
rect->y1 - (LISTITEM_HEIGHT - BYTE_HEIGHT) / 2};

GUI_ClearPrect(&rectVal);
GUI_SetTextMode(GUI_TEXTMODE_NORMAL);
GUI_SetColor(infoSettings.list_border_color);
GUI_DrawPrect(&rectVal);

GUI_SetTextMode(GUI_TEXTMODE_TRANS);
GUI_SetColor(LI_VAL_COLOR);

if (value.index == LABEL_CUSTOM_VALUE || value.index == LABEL_DYNAMIC) // show custom text value
GUI_DispStringInPrect(&rectVal, (uint8_t *)getDynamicTextValue(i));
else // show regular text labels
GUI_DispStringInPrect(&rectVal, (int32_t)value.index);

GUI_RestoreColorDefault();
}
3 changes: 0 additions & 3 deletions TFT/src/User/API/UI/ListItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ void setDynamicValue(uint8_t i, float value); // set list item value to any

void ListItem_Display(const GUI_RECT * rect, uint8_t position, const LISTITEM * curitem, bool pressed);
void ListMenuSetItem(const LISTITEM * menuItem, uint8_t position);
void draw_itemtitle(GUI_POINT pos, LABEL label, uint8_t position, int textarea_width);
void ListItem_DisplayToggle(uint16_t sx, uint16_t sy, uint8_t iconchar_state);
void ListItem_DisplayCustomValue(const GUI_RECT * rect, LABEL value, int i);
GUI_POINT getTextStartPoint(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey,ALIGN_POSITION pos, const char * textchar);

#ifdef __cplusplus
Expand Down
80 changes: 40 additions & 40 deletions TFT/src/User/API/UI/ListManager.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,44 @@ static bool handleBack = true;
static void (*action_preparePage)(LISTITEMS * listItems, uint8_t index) = NULL;
static void (*action_prepareItem)(LISTITEM * item, uint16_t index, uint8_t itemPos) = NULL;

// display page at selected index
static void listViewSetCurPage(uint8_t curPage)
{
if (action_preparePage != NULL)
{
action_preparePage(&listItems, curPage);
}
else
{
for (uint8_t i = 0; i < LISTITEM_PER_PAGE; i++)
{
uint16_t index = curPage * LISTITEM_PER_PAGE + i;

if (index < maxItemCount)
{
if (totalItems != NULL)
listItems.items[i] = totalItems[index];

if (action_prepareItem != NULL)
action_prepareItem(&listItems.items[i], index, i);
}
else
{
listItems.items[i].icon = CHARICON_NULL;
}
}
}

// only 1 page or in first page, hide up button
listItems.items[5].icon = ((maxItemCount <= LISTITEM_PER_PAGE) || (curPage == 0)) ? CHARICON_NULL : CHARICON_PAGEUP;
// only 1 page or in last page, hide down button
listItems.items[6].icon = ((maxItemCount <= LISTITEM_PER_PAGE) || (curPage == maxPageCount - 1)) ? CHARICON_NULL : CHARICON_PAGEDOWN;

listItems.items[7].icon = CHARICON_BACK;

curPageIndex = curPage;
}

/**
* @brief Set and innitialize list menu
*
Expand Down Expand Up @@ -60,46 +98,8 @@ uint8_t listViewGetCurPage(void)
return curPageIndex;
}

// display page at selected index
void listViewSetCurPage(uint8_t curPage)
{
if (action_preparePage != NULL)
{
action_preparePage(&listItems, curPage);
}
else
{
for (uint8_t i = 0; i < LISTITEM_PER_PAGE; i++)
{
uint16_t index = curPage * LISTITEM_PER_PAGE + i;

if (index < maxItemCount)
{
if (totalItems != NULL)
listItems.items[i] = totalItems[index];

if (action_prepareItem != NULL)
action_prepareItem(&listItems.items[i], index, i);
}
else
{
listItems.items[i].icon = CHARICON_NULL;
}
}
}

// only 1 page or in first page, hide up button
listItems.items[5].icon = ((maxItemCount <= LISTITEM_PER_PAGE) || (curPage == 0)) ? CHARICON_NULL : CHARICON_PAGEUP;
// only 1 page or in last page, hide down button
listItems.items[6].icon = ((maxItemCount <= LISTITEM_PER_PAGE) || (curPage == maxPageCount - 1)) ? CHARICON_NULL : CHARICON_PAGEDOWN;

listItems.items[7].icon = CHARICON_BACK;

curPageIndex = curPage;
}

// open next page
bool listViewNextPage(void)
static bool listViewNextPage(void)
{
if (maxPageCount <= 1) return false; // only 0 or 1 page, can't goto next page
if (curPageIndex + 1 >= maxPageCount) return false; // already last page
Expand All @@ -116,7 +116,7 @@ bool listViewNextPage(void)
}

// open previous page
bool listViewPreviousPage(void)
static bool listViewPreviousPage(void)
{
if (maxPageCount <= 1) return false; // only 0 or 1 page, can't goto previous page
if (curPageIndex == 0) return false; // already first page
Expand Down
3 changes: 0 additions & 3 deletions TFT/src/User/API/UI/ListManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ void listViewCreate(LABEL title, LISTITEM * items, uint16_t max_items, uint16_t
void (*prepareItem_action)(LISTITEM * item, uint16_t index, uint8_t itemPos));

void listViewSetTitle(LABEL title);
void listViewSetCurPage(uint8_t cur_page);
bool listViewPreviousPage(void);
bool listViewNextPage(void);
void listViewRefreshPage(void);
void listViewRefreshMenu(void);
void listViewRefreshItem(uint16_t item);
Expand Down
Loading

0 comments on commit 01da6d1

Please sign in to comment.