Skip to content

Commit

Permalink
fixed #2881 and wrong buffer allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
digant73 committed Jan 10, 2024
1 parent 0dffbb6 commit e979e57
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
6 changes: 5 additions & 1 deletion TFT/src/User/API/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -801,11 +801,15 @@ void menuDrawTitle(void)
}

// draw title
uint8_t *titleString = labelGetAddress(curTitle);
uint16_t start_y = (TITLE_END_Y - BYTE_HEIGHT) / 2;
uint16_t start_x = 10;
uint16_t end_x = drawTemperatureStatus();

// NOTE: load the label just before displaying it. This is needed only in case a secondary language pack (.ini file) is used
// by the TFT (secondary language shares a common buffer where all labels are loaded from flash memory) just to avoid the
// possibility to display a wrong label
uint8_t *titleString = labelGetAddress(curTitle);

GUI_SetBkColor(infoSettings.title_bg_color);

if (titleString)
Expand Down
2 changes: 1 addition & 1 deletion TFT/src/User/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -1117,7 +1117,7 @@
* Monitoring Debug
* Uncomment/Enable to monitor/show system resources usage in Monitoring menu.
*/
#define DEBUG_MONITORING // Default: commented (disabled)
#define DEBUG_MONITORING // Default: uncommented (enabled)

/**
* Generic Debug
Expand Down
28 changes: 15 additions & 13 deletions TFT/src/User/Menu/PersistentInfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ void loopTemperatureStatus(void)
if (getMenuType() == MENU_TYPE_FULLSCREEN) return;
if (!temperatureStatusValid()) return;

bool update = false;
static int16_t lastCurrent[3];
static int16_t lastTarget[3];
uint8_t tmpHeater[3]; // chamber, bed, hotend
static int16_t lastCurrent[4]; // chamber, bed, 1-2 hotend
static int16_t lastTarget[4];

uint8_t tmpHeater[4]; // chamber, bed, 1-2 hotend
uint8_t tmpIndex = 0;
bool update = false;

if (infoSettings.hotend_count) // global hotend
{
Expand Down Expand Up @@ -64,6 +65,7 @@ void loopTemperatureStatus(void)
{
lastCurrent[tmpIndex] = actCurrent;
lastTarget[tmpIndex] = actTarget;

update = true;
}
}
Expand All @@ -78,8 +80,8 @@ int16_t drawTemperatureStatus(void)

if (!temperatureStatusValid()) return x_offset;

uint8_t tmpHeater[3]; // chamber, bed, 1-2hotend
uint16_t tmpIcon[3];
uint16_t tmpIcon[4]; // chamber, bed, 1-2 hotend
uint8_t tmpHeater[4];
uint8_t tmpIndex = 0;

if (infoSettings.hotend_count)
Expand All @@ -99,13 +101,13 @@ int16_t drawTemperatureStatus(void)
}

if (infoSettings.bed_en)
{ // global bed
{ // global bed
tmpIcon[tmpIndex] = ICON_GLOBAL_BED;
tmpHeater[tmpIndex++] = BED;
}

if (infoSettings.chamber_en)
{ // global chamber
{ // global chamber
tmpIcon[tmpIndex] = ICON_GLOBAL_CHAMBER;
tmpHeater[tmpIndex++] = CHAMBER;
}
Expand All @@ -116,20 +118,20 @@ int16_t drawTemperatureStatus(void)

while (tmpIndex > 0)
{
char tempstr[10];

tmpIndex--;

char tempstr[10];

x_offset -= GLOBALICON_INTERVAL;
GUI_ClearRect(x_offset, start_y, x_offset + GLOBALICON_INTERVAL, start_y + GLOBALICON_HEIGHT);
sprintf(tempstr, "%d/%d", heatGetCurrentTemp(tmpHeater[tmpIndex]), heatGetTargetTemp(tmpHeater[tmpIndex]));

sprintf(tempstr, "%d/%d", heatGetCurrentTemp(tmpHeater[tmpIndex]), heatGetTargetTemp(tmpHeater[tmpIndex]));
x_offset -= GUI_StrPixelWidth((uint8_t *)tempstr);
GUI_StrPixelWidth(LABEL_10_PERCENT);

GUI_DispString(x_offset, start_y, (uint8_t *)tempstr); // value

x_offset -= GLOBALICON_INTERVAL;
GUI_ClearRect(x_offset, start_y, x_offset + GLOBALICON_INTERVAL, start_y + GLOBALICON_HEIGHT);

x_offset -= GLOBALICON_WIDTH;
ICON_ReadDisplay(x_offset, start_y, tmpIcon[tmpIndex]); // icon
}
Expand Down

0 comments on commit e979e57

Please sign in to comment.