diff options
| author | James Barnett <noreply@jamesbarnett.xyz> | 2019-10-06 12:56:26 +0100 |
|---|---|---|
| committer | James Barnett <noreply@jamesbarnett.xyz> | 2019-10-06 12:56:26 +0100 |
| commit | 64aa82592c6c2b043d8c62100d4ce110bf616c1e (patch) | |
| tree | 73387e2516ac2b7066c43ebf2dbe76e313edbcfc /os/main.c | |
| parent | bd77381c27ef5b61bf1c123efef3895b98a7a615 (diff) | |
| download | tinyOS-64aa82592c6c2b043d8c62100d4ce110bf616c1e.tar.xz tinyOS-64aa82592c6c2b043d8c62100d4ce110bf616c1e.zip | |
Add os statusbar. Start stdlib
Diffstat (limited to 'os/main.c')
| -rw-r--r-- | os/main.c | 65 |
1 files changed, 60 insertions, 5 deletions
@@ -2,13 +2,12 @@ #include "../kernel/gpu/text_mode/colours.h" #include "main.h" #include "./shell/shell.h" +#include "./stdlib/sdtlib.h" Program_t focused_program; void os_show_splash() { - scrn_enable_cursor(10, 12); - scrn_clear(); scrn_set_text_colour(COLOUR_LIGHT_GREEN, COLOUR_BLACK); scrn_println(" _ _ ____ _____ "); @@ -24,19 +23,75 @@ void os_show_splash() scrn_newline(); } -void os_start() +void line_pad(unsigned int width) { - os_show_splash(); + for(int i = 0; i < width; i++) + { + scrn_putchar(' '); + } +} + +void os_update_infobar_rc() +{ + + int curr_attr_byte = scrn_get_char_attr_byte(); + int curr_r = scrn_get_cursor_row(); + int curr_c = scrn_get_cursor_col(); + + scrn_set_text_colour(COLOUR_WHITE, COLOUR_BLUE); + scrn_set_cursor_pos(0, 64); + scrn_print("row "); + + if (curr_r < 9) { + scrn_print("0"); + } + scrn_print(int_to_str(curr_r +1)); + + scrn_print(", col "); + if (curr_c < 9) { + scrn_print("0"); + } + scrn_print(int_to_str(curr_c+1)); + + scrn_set_char_attr_byte(curr_attr_byte); + scrn_set_cursor_pos(curr_r, curr_c); +} + +void os_init_infobar() +{ + scrn_clear(); + scrn_set_cursor_pos(0, 0); + scrn_set_text_colour(COLOUR_WHITE, COLOUR_BLUE); + line_pad(80); // fill line + scrn_set_cursor_pos(0, 2); + scrn_print("tinyOS"); + scrn_set_cursor_pos(0, 30); + scrn_print("running: "); + scrn_print(focused_program.name); + + os_update_infobar_rc(); + scrn_set_text_colour(COLOUR_WHITE, COLOUR_BLACK); + scrn_set_cursor_pos(1, 0); } // TODO keep a stack of running programs void os_update_focused_program(Program_t program) { - focused_program = shell_run(); + focused_program = program; } // Send keypress from kernel to the currently focused programs keypress handler void os_proxy_keypress(unsigned char key) { (focused_program.keypress_handler)(key); + os_update_infobar_rc(); +} + +void os_start() +{ + os_update_focused_program(shell_run()); + scrn_enable_cursor(10, 12); + os_init_infobar(); + os_show_splash(); + os_update_infobar_rc(); } // TODO display handling
\ No newline at end of file |