Merge pull request #792 from Riksu9000/memory_saving
Memory savings by replacing strings
This commit is contained in:
commit
cfc11ea83b
|
@ -209,7 +209,7 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen4() {
|
||||||
static constexpr uint8_t maxTaskCount = 9;
|
static constexpr uint8_t maxTaskCount = 9;
|
||||||
TaskStatus_t tasksStatus[maxTaskCount];
|
TaskStatus_t tasksStatus[maxTaskCount];
|
||||||
|
|
||||||
lv_obj_t* infoTask = lv_table_create(lv_scr_act(), NULL);
|
lv_obj_t* infoTask = lv_table_create(lv_scr_act(), nullptr);
|
||||||
lv_table_set_col_cnt(infoTask, 4);
|
lv_table_set_col_cnt(infoTask, 4);
|
||||||
lv_table_set_row_cnt(infoTask, maxTaskCount + 1);
|
lv_table_set_row_cnt(infoTask, maxTaskCount + 1);
|
||||||
lv_obj_set_style_local_pad_all(infoTask, LV_TABLE_PART_CELL1, LV_STATE_DEFAULT, 0);
|
lv_obj_set_style_local_pad_all(infoTask, LV_TABLE_PART_CELL1, LV_STATE_DEFAULT, 0);
|
||||||
|
@ -227,35 +227,37 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen4() {
|
||||||
auto nb = uxTaskGetSystemState(tasksStatus, maxTaskCount, nullptr);
|
auto nb = uxTaskGetSystemState(tasksStatus, maxTaskCount, nullptr);
|
||||||
std::sort(tasksStatus, tasksStatus + nb, sortById);
|
std::sort(tasksStatus, tasksStatus + nb, sortById);
|
||||||
for (uint8_t i = 0; i < nb && i < maxTaskCount; i++) {
|
for (uint8_t i = 0; i < nb && i < maxTaskCount; i++) {
|
||||||
|
char buffer[7] = {0};
|
||||||
|
|
||||||
lv_table_set_cell_value(infoTask, i + 1, 0, std::to_string(tasksStatus[i].xTaskNumber).c_str());
|
sprintf(buffer, "%lu", tasksStatus[i].xTaskNumber);
|
||||||
char state[2] = {0};
|
lv_table_set_cell_value(infoTask, i + 1, 0, buffer);
|
||||||
switch (tasksStatus[i].eCurrentState) {
|
switch (tasksStatus[i].eCurrentState) {
|
||||||
case eReady:
|
case eReady:
|
||||||
case eRunning:
|
case eRunning:
|
||||||
state[0] = 'R';
|
buffer[0] = 'R';
|
||||||
break;
|
break;
|
||||||
case eBlocked:
|
case eBlocked:
|
||||||
state[0] = 'B';
|
buffer[0] = 'B';
|
||||||
break;
|
break;
|
||||||
case eSuspended:
|
case eSuspended:
|
||||||
state[0] = 'S';
|
buffer[0] = 'S';
|
||||||
break;
|
break;
|
||||||
case eDeleted:
|
case eDeleted:
|
||||||
state[0] = 'D';
|
buffer[0] = 'D';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
state[0] = 'I'; // Invalid
|
buffer[0] = 'I'; // Invalid
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
lv_table_set_cell_value(infoTask, i + 1, 1, state);
|
buffer[1] = '\0';
|
||||||
|
lv_table_set_cell_value(infoTask, i + 1, 1, buffer);
|
||||||
lv_table_set_cell_value(infoTask, i + 1, 2, tasksStatus[i].pcTaskName);
|
lv_table_set_cell_value(infoTask, i + 1, 2, tasksStatus[i].pcTaskName);
|
||||||
if (tasksStatus[i].usStackHighWaterMark < 20) {
|
if (tasksStatus[i].usStackHighWaterMark < 20) {
|
||||||
std::string str1 = std::to_string(tasksStatus[i].usStackHighWaterMark) + " low";
|
sprintf(buffer, "%d low", tasksStatus[i].usStackHighWaterMark);
|
||||||
lv_table_set_cell_value(infoTask, i + 1, 3, str1.c_str());
|
|
||||||
} else {
|
} else {
|
||||||
lv_table_set_cell_value(infoTask, i + 1, 3, std::to_string(tasksStatus[i].usStackHighWaterMark).c_str());
|
sprintf(buffer, "%d", tasksStatus[i].usStackHighWaterMark);
|
||||||
}
|
}
|
||||||
|
lv_table_set_cell_value(infoTask, i + 1, 3, buffer);
|
||||||
}
|
}
|
||||||
return std::make_unique<Screens::Label>(3, 5, app, infoTask);
|
return std::make_unique<Screens::Label>(3, 5, app, infoTask);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#include "Twos.h"
|
#include "Twos.h"
|
||||||
#include <lvgl/lvgl.h>
|
|
||||||
#include <string>
|
|
||||||
#include <charconv>
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <vector>
|
#include <cstdio>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <lvgl/lvgl.h>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
using namespace Pinetime::Applications::Screens;
|
using namespace Pinetime::Applications::Screens;
|
||||||
|
|
||||||
|
@ -265,7 +265,9 @@ void Twos::updateGridDisplay(Tile grid[][4]) {
|
||||||
for (int row = 0; row < 4; row++) {
|
for (int row = 0; row < 4; row++) {
|
||||||
for (int col = 0; col < 4; col++) {
|
for (int col = 0; col < 4; col++) {
|
||||||
if (grid[row][col].value) {
|
if (grid[row][col].value) {
|
||||||
lv_table_set_cell_value(gridDisplay, row, col, (std::to_string(grid[row][col].value)).c_str());
|
char buffer[7];
|
||||||
|
sprintf(buffer, "%d", grid[row][col].value);
|
||||||
|
lv_table_set_cell_value(gridDisplay, row, col, buffer);
|
||||||
} else {
|
} else {
|
||||||
lv_table_set_cell_value(gridDisplay, row, col, "");
|
lv_table_set_cell_value(gridDisplay, row, col, "");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue