Create CPU + RAM visualization demo.

This commit is contained in:
GutPuncher 2023-05-07 23:58:47 -04:00
parent 0b6c7d6722
commit bd5b85389e
No known key found for this signature in database
GPG key ID: 38CE0A7B6841D1C7

59
src/Demo/Graphics/Usage.ZC Executable file
View file

@ -0,0 +1,59 @@
U0 UsageDrawIt(CTask *, CDC *dc)
{
I64 i, b;
CCPU *c;
F64 f;
dc->thick = 1;
dc->color = GREEN;
GrPrint(dc, 8, 8, "CPU");
dc->color = DKGRAY;
GrRect(dc, 8, 16, 100, 8 + 16 * (mp_count - 1));
dc->color = GREEN;
for (i = 0; i < mp_count; i++)
{
c = &cpu_structs[i];
f = 100.0 * (1.0 - c->idle_factor);
if (f < 1.0)
f = 1.0;
GrRect(dc, 8, 16 + (16*i), ToI64(f), 8);
}
b = sys_code_bp->alloced_u8s - sys_code_bp->used_u8s;
if (sys_data_bp)
b += sys_data_bp->alloced_u8s - sys_data_bp->used_u8s;
f = 1.0 * b / MemBIOSTotal;
dc->color = RED;
GrPrint(dc, 116, 8, "RAM");
dc->color = DKGRAY;
GrRect(dc, 116, 16, 100, 8);
dc->color = RED;
GrRect(dc, 116, 16, ToI64(100.0 * (1.0 - f)), 8);
Sleep(1);
}
U0 Usage()
{
SettingsPush;
DocClear;
DocCursor;
Fs->draw_it = &UsageDrawIt;
StrCopy(Fs->task_title, "Usage");
while (CharGet(,FALSE) != CH_SHIFT_ESC) {};
SettingsPop;
};
Usage;