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

Bugfixes, restoration, cleanup, speedup, some FW size reduction #2776

Closed
Closed
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
2 changes: 1 addition & 1 deletion TFT/src/User/API/BabystepControl.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ static float babystep_value = BABYSTEP_DEFAULT_VALUE;
#define BABYSTEP_CMD_SMW "G43.2 Z%.2f\n"

// Set current babystep value
void babystepSetValue(float value)
void babystepSetValue(const float value)
{
babystep_value = value;
}
Expand Down
2 changes: 1 addition & 1 deletion TFT/src/User/API/BabystepControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ extern "C" {
#include <stdint.h>

// Set current babystep value
void babystepSetValue(float value);
void babystepSetValue(const float value);

// Get current babystep value
float babystepGetValue(void);
Expand Down
2 changes: 1 addition & 1 deletion TFT/src/User/API/Gcode/gcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ void request_M98(const char * filename)
mustStoreCmd(command);

// prevent a race condition when rrfStatusQuery returns !busy before executing the macro
TASK_LOOP_WHILE(isEnqueued(command))
TASK_LOOP_WHILE(isEnqueued(command));

rrfStatusQueryFast();

Expand Down
3 changes: 2 additions & 1 deletion TFT/src/User/API/ModeSwitching.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ void Mode_Switch(void)
LOGO_ReadDisplay();
updateNextHeatCheckTime(); // send "M105" after a delay, because of mega2560 will be hanged when received data at startup

TASK_LOOP_WHILE(OS_GetTimeMs() - startUpTime < BTT_BOOTSCREEN_TIME) // display logo BTT_BOOTSCREEN_TIME ms
// display logo BTT_BOOTSCREEN_TIME ms
TASK_LOOP_WHILE(OS_GetTimeMs() - startUpTime < BTT_BOOTSCREEN_TIME);

heatSetUpdateSeconds(TEMPERATURE_QUERY_SLOW_SECONDS);
modeFreshBoot = false;
Expand Down
106 changes: 50 additions & 56 deletions TFT/src/User/API/Notification.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
const GUI_RECT toastRect = {START_X + TITLE_END_Y - (TOAST_Y_PAD * 2), TOAST_Y_PAD, LCD_WIDTH - START_X, TITLE_END_Y - TOAST_Y_PAD};
const GUI_RECT toastIconRect = {START_X, TOAST_Y_PAD, START_X + TITLE_END_Y - (TOAST_Y_PAD * 2), TITLE_END_Y - TOAST_Y_PAD};

// toast notification variables
static TOAST toastlist[TOAST_MSG_COUNT];
static struct
{
DIALOG_TYPE style;
uint8_t isNew;
char text[TOAST_MSG_LENGTH];
} toastlist[TOAST_MSG_COUNT];

static uint8_t nextToastIndex = 0; // next index to store new toast
static uint8_t curToastDisplay = 0; // current toast notification being displayed
Expand All @@ -24,11 +28,9 @@ void addToast(DIALOG_TYPE style, char * text)
{
LCD_WAKE();

TOAST t;
strncpy_no_pad(t.text, text, TOAST_MSG_LENGTH);
t.style = style;
t.isNew = true;
toastlist[nextToastIndex] = t;
strscpy(toastlist[nextToastIndex].text, text, TOAST_MSG_LENGTH);
toastlist[nextToastIndex].style = style;
toastlist[nextToastIndex].isNew = true;
nextToastIndex = (nextToastIndex + 1) % TOAST_MSG_COUNT;
}

Expand All @@ -41,7 +43,7 @@ bool toastRunning(void)
// check if any new notification is available
bool toastAvailable(void)
{
for (int i = 0; i < TOAST_MSG_COUNT; i++)
for (uint8_t i = 0; i < TOAST_MSG_COUNT; i++)
{
if (toastlist[i].isNew == true)
return true;
Expand All @@ -62,29 +64,35 @@ void drawToast(bool redraw)

// draw icon
uint8_t *icon;
uint8_t cursound;
if (toastlist[curToastDisplay].style == DIALOG_TYPE_ERROR)
{
GUI_SetColor(NOTIF_ICON_ERROR_BG_COLOR);
icon = IconCharSelect(CHARICON_ERROR);
cursound = SOUND_ERROR;
}
else if (toastlist[curToastDisplay].style == DIALOG_TYPE_SUCCESS)
SOUND cursound;

switch (toastlist[curToastDisplay].style)
{
GUI_SetColor(NOTIF_ICON_SUCCESS_BG_COLOR);
icon = IconCharSelect(CHARICON_OK_ROUND);
cursound = SOUND_SUCCESS;
case DIALOG_TYPE_ERROR:
GUI_SetColor(NOTIF_ICON_ERROR_BG_COLOR);
icon = IconCharSelect(CHARICON_ERROR);
cursound = SOUND_ERROR;
break;

case DIALOG_TYPE_SUCCESS:
GUI_SetColor(NOTIF_ICON_SUCCESS_BG_COLOR);
icon = IconCharSelect(CHARICON_OK_ROUND);
cursound = SOUND_SUCCESS;
break;

default:
GUI_SetColor(NOTIF_ICON_INFO_BG_COLOR);
icon = IconCharSelect(CHARICON_INFO);
cursound = SOUND_TOAST;
break;
}
else

if (!redraw) // if notification is new
{
GUI_SetColor(NOTIF_ICON_INFO_BG_COLOR);
icon = IconCharSelect(CHARICON_INFO);
cursound = SOUND_TOAST;
BUZZER_PLAY(cursound); // play sound
nextToastTime = OS_GetTimeMs() + SEC_TO_MS(TOAST_DURATION); // set new timer
}

if (cursound >= 0 && !redraw)
BUZZER_PLAY(cursound);

GUI_SetTextMode(GUI_TEXTMODE_TRANS);
GUI_FillPrect(&toastIconRect);
GUI_SetColor(NOTIF_ICON_FG_COLOR);
Expand All @@ -99,21 +107,14 @@ void drawToast(bool redraw)
// set current toast notification as old/completed
toastlist[curToastDisplay].isNew = false;

// set new timer if notification is new
if (!redraw)
nextToastTime = OS_GetTimeMs() + SEC_TO_MS(TOAST_DURATION);

GUI_RestoreColorDefault();
}
}

// check and control toast notification display
void loopToast(void)
{
if (getMenuType() == MENU_TYPE_FULLSCREEN)
return;

if (OS_GetTimeMs() > nextToastTime)
if (getMenuType() != MENU_TYPE_FULLSCREEN && OS_GetTimeMs() > nextToastTime)
{
if (toastAvailable())
{
Expand All @@ -130,36 +131,32 @@ void loopToast(void)
}

// add new message to notification queue
void addNotification(DIALOG_TYPE style, char *title, char *text, bool ShowDialog)
void addNotification(DIALOG_TYPE style, char *title, char *text, bool draw_dialog)
{
LCD_WAKE();

if (nextMsgIndex > MAX_MSG_COUNT - 1)
if (nextMsgIndex >= MAX_MSG_COUNT)
{
// remove oldest message and move all messages up one step
for (int i = 0; i < MAX_MSG_COUNT - 1; i++)
{
memcpy(&msglist[i], &msglist[i + 1], sizeof(NOTIFICATION));
}
memmove(msglist, &msglist[1], (MAX_MSG_COUNT - 1) * (sizeof(NOTIFICATION)));
nextMsgIndex = MAX_MSG_COUNT - 1;
}

// store message
msglist[nextMsgIndex].style = style;
strncpy_no_pad(msglist[nextMsgIndex].text, text, MAX_MSG_LENGTH);
strncpy_no_pad(msglist[nextMsgIndex].title, title, MAX_MSG_TITLE_LENGTH);

if (ShowDialog && MENU_IS_NOT(menuNotification))
popupReminder(style, (uint8_t *)title, (uint8_t *)msglist[nextMsgIndex].text);
msglist[nextMsgIndex].style = style;
strscpy(msglist[nextMsgIndex].text, text, MAX_MSG_LENGTH);
strscpy(msglist[nextMsgIndex].title, title, MAX_MSG_TITLE_LENGTH);
nextMsgIndex++;

if (nextMsgIndex < MAX_MSG_COUNT) nextMsgIndex += 1; //(nextMsgIndex + 1) % MAX_MSG_COUNT;
if (draw_dialog && MENU_IS_NOT(menuNotification))
popupReminder(style, (uint8_t *)title, (uint8_t *)text);

if (notificationHandler != NULL)
notificationHandler();

notificationDot();

statusScreen_setMsg((uint8_t *)title, (uint8_t *)text);
statusScreenSetMsg((uint8_t *)title, (uint8_t *)text);
}

// replay a notification
Expand All @@ -172,30 +169,27 @@ void replayNotification(uint8_t index)
// retrieve a stored notification
NOTIFICATION *getNotification(uint8_t index)
{
if (strlen(msglist[index].title) > 0 && strlen(msglist[index].text) > 0)
if (msglist[index].title[0] != '\0' && msglist[index].text[0] != '\0')
return &msglist[index];
else
return NULL;
}

bool hasNotification(void)
{
if (nextMsgIndex == 0)
return false;
else
return true;
return (nextMsgIndex != 0);
}

void clearNotification(void)
{
nextMsgIndex = 0;
for (int i = 0; i < MAX_MSG_COUNT; i++)
{
msglist[i].text[0] = 0;
msglist[i].title[0] = 0;
msglist[i].text[0] = '\0';
msglist[i].title[0] = '\0';
}
notificationDot();
statusScreen_setReady();
statusScreenSetReady();
}

// check if pressed on titlebar area
Expand Down
7 changes: 0 additions & 7 deletions TFT/src/User/API/Notification.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@ extern "C" {
#define MAX_MSG_TITLE_LENGTH 15
#define MAX_MSG_LENGTH 70

typedef struct
{
DIALOG_TYPE style;
uint8_t isNew;
char text[TOAST_MSG_LENGTH];
} TOAST;

typedef struct
{
DIALOG_TYPE style;
Expand Down
2 changes: 1 addition & 1 deletion TFT/src/User/API/Printing.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ void initPrintSummary(void)
infoPrintSummary = (PRINT_SUMMARY){.name[0] = '\0', 0, 0, 0, 0, false};

// save print filename (short or long filename)
sprintf(infoPrintSummary.name, "%." STRINGIFY(SUMMARY_NAME_LEN) "s", getPrintFilename());
strscpy(infoPrintSummary.name, getPrintFilename(), SUMMARY_NAME_LEN);
}

void preparePrintSummary(void)
Expand Down
2 changes: 1 addition & 1 deletion TFT/src/User/API/ProbeHeightControl.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#define ENDSTOP_CMD "M211 S%d\n"
#define ENDSTOP_CMD_RRF "M564 S%d H%d\n" // for RRF
#define MOVE_Z_CMD "G1 Z%.2f F%d\n"
#define MOVE_Z_CMD "G0 Z%.2f F%d\n"

#define PROBE_UPDATE_DELAY 200 // 1 seconds is 1000

Expand Down
3 changes: 2 additions & 1 deletion TFT/src/User/API/ProbeOffsetControl.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ void probeOffsetEnable(float shim)
{
levelingProbePoint(LEVEL_CENTER); // probe center of bed

TASK_LOOP_WHILE(levelingGetProbedPoint() == LEVEL_NO_POINT) // if probed Z is set, exit from loop and read probed Z
// if probed Z is set, exit from loop and read probed Z
TASK_LOOP_WHILE(levelingGetProbedPoint() == LEVEL_NO_POINT);

probedZ = levelingGetProbedZ();
levelingResetProbedPoint(); // reset to check for new updates
Expand Down
6 changes: 3 additions & 3 deletions TFT/src/User/API/RRFParseACK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,19 +209,19 @@ void ParseACKJsonParser::value(const char *value)
{
setupMachine(FW_REPRAPFW);
string_end = strstr(string_start, "ELECTRONICS");
infoSetFirmwareName((uint8_t *)string_start, string_end-string_start);
infoSetFirmwareName(string_start, string_end-string_start);
}
else if ((string_start = strstr(value, (char *)"access point")) != NULL) // parse M552
{
string_end = strstr(string_start, ",");
string_start += 13;
infoSetAccessPoint((uint8_t *)string_start, string_end-string_start);
infoSetAccessPoint(string_start, string_end-string_start);

if ((string_start = strstr(string_start, (char *)"IP address")) != NULL)
{
string_end = strstr(string_start, "\\n");
string_start += 11;
infoSetIPAddress((uint8_t *)string_start, string_end-string_start);
infoSetIPAddress(string_start, string_end-string_start);
}
}
else if ((string_start = strstr(value, (char *)"printing byte")) != NULL) // parse M27 {"seq":21,"resp":"SD printing byte 1226/5040433\n"}
Expand Down
Loading