mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2024-12-25 15:10:28 +00:00
Create CPU + RAM visualization demo.
This commit is contained in:
parent
0b6c7d6722
commit
bd5b85389e
1 changed files with 59 additions and 0 deletions
59
src/Demo/Graphics/Usage.ZC
Executable file
59
src/Demo/Graphics/Usage.ZC
Executable 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;
|
Loading…
Reference in a new issue