Skip to content

Commit

Permalink
minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
digant73 committed Jan 12, 2024
1 parent 3359080 commit 0ee66e6
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 88 deletions.
4 changes: 2 additions & 2 deletions TFT/src/User/API/Notification.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ void addNotification(DIALOG_TYPE style, char * title, char * text, bool drawDial

notificationDot();

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

// replay a notification
Expand Down Expand Up @@ -195,7 +195,7 @@ void clearNotification(void)
msglist[i].title[0] = '\0';
}
notificationDot();
statusScreen_setReady();
statusSetReady();
}

// check if pressed on titlebar area
Expand Down
41 changes: 23 additions & 18 deletions TFT/src/User/API/boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,6 @@ const char * const iconBmpName[] = {
#define X_ICON(NAME) #NAME ,
#include "icon_list.inc"
#undef X_ICON
// add new icons in icon_list.inc only
};

// This List is Auto-Generated. Please add new icons in small_icon_list.inc only
const char * const smallIconBmpName[] = {
#define X_SMALLICON(NAME) #NAME ,
#include "small_icon_list.inc"
#undef X_SMALLICON
// add new icons in small_icon_list.inc only
};

BMPUPDATE_STAT bmpDecode(char * bmp, uint32_t addr)
Expand All @@ -64,6 +55,7 @@ BMPUPDATE_STAT bmpDecode(char * bmp, uint32_t addr)
if (memcmp(magic, "BM", 2))
{
f_close(&bmpFile);

return BMP_INVALIDFILE;
}

Expand All @@ -78,6 +70,7 @@ BMPUPDATE_STAT bmpDecode(char * bmp, uint32_t addr)
if (bpp < 24)
{
f_close(&bmpFile);

return BMP_NOT24BIT;
}

Expand All @@ -94,8 +87,8 @@ BMPUPDATE_STAT bmpDecode(char * bmp, uint32_t addr)
W25Qxx_EraseSector(addr + bnum * W25QXX_SECTOR_SIZE);
}

bnum = 0;
// store size of BMP
bnum = 0;
memcpy(buf, (uint8_t *)&w, sizeof(uint16_t));
bnum += sizeof(uint16_t);
memcpy(buf + bnum, (uint8_t *)&h, sizeof(uint16_t));
Expand Down Expand Up @@ -130,6 +123,7 @@ BMPUPDATE_STAT bmpDecode(char * bmp, uint32_t addr)
W25Qxx_WritePage(buf,addr,bnum);
addr+=bnum;
f_close(&bmpFile);

return BMP_SUCCESS;
}

Expand All @@ -147,9 +141,11 @@ void dispIconFail(uint8_t * lbl, BMPUPDATE_STAT bmpState)
case BMP_INVALIDFILE:
stat_txt = "BMP file not valid ";
break;

case BMP_NOT24BIT:
stat_txt = "Format is not 24Bit";
break;

case BMP_NOTFOUND:
default:
stat_txt = "BMP file not found ";
Expand Down Expand Up @@ -194,25 +190,27 @@ static inline bool updateIcon(char * rootDir)
for (int i = 0; i < COUNT(iconBmpName); i++)
{
GUI_POINT last_size = bmp_size;

sprintf(curBmpPath, "%s" BMP_UPDATE_DIR "/%s.bmp", rootDir, iconBmpName[i]);
GUI_ClearPrect(&labelUpdateRect);
GUI_DispString(labelUpdateRect.x0, labelUpdateRect.y0, (uint8_t *)curBmpPath);

bmpState = bmpDecode(curBmpPath, ICON_ADDR(i));

if (bmpState == BMP_SUCCESS)
{ // display bmp update success
{ // display bmp update success
found++;
GUI_ClearRect(iconUpdateRect.x0, iconUpdateRect.y0, iconUpdateRect.x0 + last_size.x, iconUpdateRect.y0 + last_size.y);
IMAGE_ReadDisplay(iconUpdateRect.x0, iconUpdateRect.y0, ICON_ADDR(i));
}
else
{ // display bmp update fail
{ // display bmp update fail
notfound++;
GUI_ClearRect(iconUpdateRect.x0, iconUpdateRect.y0, iconUpdateRect.x0 + last_size.x, iconUpdateRect.y0 + last_size.y);
dispIconFail((uint8_t *)curBmpPath, bmpState);
}
// Display icon update progress

// display icon update progress
sprintf(tempstr, "Updated: %d | Not Updated: %d", found, notfound);
GUI_DispString(statUpdateRect.x0, statUpdateRect.y0, (uint8_t *)tempstr);
}
Expand Down Expand Up @@ -261,7 +259,8 @@ static inline bool updateFont(char * font, uint32_t addr)

while (!f_eof(&myfp))
{
if (f_read(&myfp, tempbuf, W25QXX_SECTOR_SIZE, &rnum) != FR_OK) break;
if (f_read(&myfp, tempbuf, W25QXX_SECTOR_SIZE, &rnum) != FR_OK)
break;

W25Qxx_EraseSector(addr + offset);
W25Qxx_WriteBuffer(tempbuf, addr + offset, W25QXX_SECTOR_SIZE);
Expand All @@ -273,18 +272,21 @@ static inline bool updateFont(char * font, uint32_t addr)
GUI_DispDec(0 + BYTE_WIDTH * 9, 140, progress, 3, RIGHT);
}

if (rnum !=W25QXX_SECTOR_SIZE) break;
if (rnum != W25QXX_SECTOR_SIZE)
break;
}

f_close(&myfp);
free(tempbuf);

return true;
}

static inline void scanResetDir(char * rootDir)
{
char curPath[100];
char renamedPath[100];

GET_FULL_PATH(curPath, rootDir, TFT_RESET_FILE);
GET_FULL_PATH(renamedPath, rootDir, TFT_RESET_FILE ".DONE");

Expand Down Expand Up @@ -331,7 +333,7 @@ static inline void scanRenameUpdate(char * rootDir)
GET_FULL_PATH(curPath, rootDir, UPDATE_DIR);

if (f_dir_exists(curPath))
{ // UPDATE_DIR exists
{ // UPDATE_DIR exists
GET_FULL_PATH(renamedPath, rootDir, renamedDIR);

if (f_dir_exists(renamedPath)) // old UPDATE_DIR also exists
Expand Down Expand Up @@ -391,12 +393,15 @@ void scanUpdates(void)

// check for font update
GET_FULL_PATH(curfilePath, rootDir, FONT_UPDATE_DIR);

if (f_dir_exists(curfilePath))
{
bool updateOk = true;

for (uint8_t i = 0; i < COUNT(fontAddrList); i++)
{
GET_FULL_PATH(curfilePath, rootDir, fontPathList[i]);

if (!updateFont(curfilePath, fontAddrList[i]))
updateOk = false; // set update to false if any font fails to update
}
Expand All @@ -410,6 +415,7 @@ void scanUpdates(void)

// check for icon/bmp update
GET_FULL_PATH(curfilePath, rootDir, BMP_UPDATE_DIR);

if (f_dir_exists(BMP_UPDATE_DIR))
{
if (updateIcon(rootDir) && (saved_flash_sign[icon_sign] != ICON_CHECK_SIGN))
Expand All @@ -421,6 +427,7 @@ void scanUpdates(void)

// check for config update
GET_FULL_PATH(curfilePath, rootDir, CONFIG_FILE_PATH);

if (getConfigFromFile(curfilePath) && (saved_flash_sign[config_sign] != CONFIG_CHECK_SIGN))
{
saved_flash_sign[config_sign] = CONFIG_CHECK_SIGN;
Expand All @@ -442,9 +449,7 @@ void scanUpdates(void)

// update flash sign
if (flash_sign_updated)
{
saveflashSign((uint8_t *)saved_flash_sign, sizeof(saved_flash_sign));
}
}

#ifdef USB_FLASH_DRIVE_SUPPORT
Expand Down
21 changes: 3 additions & 18 deletions TFT/src/User/API/boot.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,24 +72,10 @@ enum
#define X_ICON(NAME) ICON_##NAME ,
#include "icon_list.inc"
#undef X_ICON
// add new icons in icon_list.inc only
//ICON_RESERVE

// Preview should be in the last place before ICON_NULL to save flash storage space
ICON_PREVIEW,
// Back ground sign
ICON_NULL
};

// This List is Auto-Generated. Please add new icons in small_icon_list.inc only
enum
{
#define X_SMALLICON(NAME) SMALL_ICON_##NAME ,
#include "small_icon_list.inc"
#undef X_SMALLICON
// add new icons in small_icon_list.inc only
// Back ground sign
SMALL_ICON_NULL
//ICON_RESERVE,
ICON_PREVIEW, // preview should be in the last place before ICON_NULL to save flash storage space
ICON_NULL // back ground sign
};

typedef enum
Expand All @@ -112,7 +98,6 @@ typedef union
} GUI_COLOR;

void scanUpdates(void);
BMPUPDATE_STAT bmpDecode(char * bmp, uint32_t addr);

#ifdef __cplusplus
}
Expand Down
2 changes: 1 addition & 1 deletion TFT/src/User/API/interfaceCmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@ void sendQueueCmd(void)
stripChecksum(rawMsg);
msgText = stripHead(rawMsg);

statusScreen_setMsg((uint8_t *)"M117", (uint8_t *)msgText);
statusSetMsg((uint8_t *)"M117", (uint8_t *)msgText);

if (MENU_IS_NOT(menuStatus))
addToast(DIALOG_TYPE_INFO, (char *)msgText);
Expand Down
2 changes: 1 addition & 1 deletion TFT/src/User/API/parseACK.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ static inline void hostActionCommands(void)
}
else
{
statusScreen_setMsg((uint8_t *)magic_echo, (uint8_t *)ack_cache + index); // always display the notification on status screen
statusSetMsg((uint8_t *)magic_echo, (uint8_t *)ack_cache + index); // always display the notification on status screen

if (!ack_continue_seen("Ready.")) // avoid to display unneeded/frequent useless notifications (e.g. "My printer Ready.")
{
Expand Down
14 changes: 0 additions & 14 deletions TFT/src/User/API/small_icon_list.inc

This file was deleted.

2 changes: 1 addition & 1 deletion TFT/src/User/Menu/ScreenSettings.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ void menuLanguage(void)

if (memcmp(&now, &infoSettings, sizeof(SETTINGS)))
{
statusScreen_setReady(); // restore msg buffer when language is changed
statusSetReady(); // restore msg buffer when language is changed
storePara();
}
}
Expand Down
2 changes: 1 addition & 1 deletion TFT/src/User/Menu/SettingsMenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void infoSetMachineType(char * machine, uint8_t type_len)
type_len++; // add space for terminal '\0' character
strncpy_no_pad(machine_type, machine, MIN(sizeof(machine_type), type_len));

statusScreen_setReady();
statusSetReady();
}

void infoSetAccessPoint(char * ssid, uint8_t ssid_len)
Expand Down
Loading

0 comments on commit 0ee66e6

Please sign in to comment.