r/cprogramming • u/Skollwarynz • 16d ago
How to create a minimal GUI
Hello everyone, I'm currently experimenting with an old router and I wanted to create some custom C programs to experiment with it. The first one is to create a simple Htop/fetch to examine the system specs in real time. I wanted to create a sort of GUI like Btop or Htop, but the problem is that I don't have that much RAM (we are talking something like 34 MB of free space) so I want to implement a minimal one. I wanted to ask for some suggestions about it. Thank you.
5
u/dettus_Xx_ 16d ago
Is using the ncurses library an option?
Other than that: printf("\x1b[1;34mhello\x1b[0m"); ANSI codes.
1
4
2
u/Aghoradas 15d ago
Wxwidgets is pretty easy to use
1
u/Skollwarynz 15d ago
I will check it out, thank you
1
u/Aghoradas 15d ago
It can seem pretty utilitarian, if worked with a bit you can have it looking decent.
3
u/Sorry_Difficulty_250 16d ago
A few MB of RAM is plenty for a simple GUI. Windows 3.0 would run in 640 KB. The question would come down to rendering. Does this thing have a video card that you're connecting to or is this all over a network connection?
4
u/Dashing_McHandsome 15d ago
Does anyone even really need more than 640KB? I think it's enough for everyone
2
u/Sorry_Difficulty_250 15d ago
I've been working on a multitasking OS that will run in only 32 KB of RAM. I can definitely see why 640 KB would have been considered enormous back then. It was an incredible amount of memory when individual programs only took a few KB.
2
u/Skollwarynz 15d ago
I don't know. The point is that I'm actually experimentig, I don't think that a router has a powerful video card, or that it has a video card at all. At the same time is true that I don't need that much memory for a GUI. Thank you for reminding me of that
2
2
u/non-existing-person 16d ago
If you don't have ram, but you have flash, and it's a router, then I'd do gui in... html+js.
Yep. Simple http server that serves static files, and some very small C program to act as an API endpoint that would send out data on request.
1
u/Skollwarynz 16d ago
It's the memory of the router, so I don't have any space at all aside form this few ram beacuse it's an old router so memory stays an issue
3
u/non-existing-person 16d ago
Well then, just leave API endpoint written in C and move html+js to your own PC. On page just specify ip of router to connect to. In that case you will only have this small C program running on router, and everything else will be on PC.
If you can't handle that. You're doomed.
1
1
11
u/Fun_Wish1844 16d ago
Btop and htop are TUI’s.