Skip to content

Commit

Permalink
Add loading screen for apps
Browse files Browse the repository at this point in the history
  • Loading branch information
konect-V committed Sep 1, 2024
1 parent 0f4162d commit 201b5a1
Show file tree
Hide file tree
Showing 12 changed files with 57 additions and 18 deletions.
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,9 @@
"untar.h": "c",
"ft2build.h": "c",
"wait.h": "c",
"ctype.h": "c"
"ctype.h": "c",
"format": "c",
"stacktrace": "c"
},
"files.exclude": {
"bundled": true,
Expand Down
26 changes: 26 additions & 0 deletions bootstrap/sys-apps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,32 @@ packages:
- '@THIS_SOURCE_DIR@/target/@OPTION:arch_name@/bin/.'
- '@SOURCE_ROOT@/target/boot_disk_kot_mount/.'

- name: store-ui
source:
subdir: 'sources/core/apps'
tools_required:
- host-gcc
pkgs_required:
- mlibc
- curl
- cjson
build:
- args:
- 'make'
- '-C'
- '@THIS_SOURCE_DIR@/target/@OPTION:arch_name@'
- 'build'
environ:
CC: "@OPTION:cc@"
CXX: "@OPTION:cxx@"
LD: "@OPTION:ld@"
ASMC: "@OPTION:asmc@"
- args:
- 'cp'
- '-r'
- '@THIS_SOURCE_DIR@/target/@OPTION:arch_name@/bin/.'
- '@SOURCE_ROOT@/target/boot_disk_kot_mount/.'

- name: welcome
source:
subdir: 'sources/core/apps'
Expand Down
6 changes: 6 additions & 0 deletions sources/core/apps/desktop/icons/icons.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
"executablePath": "/usr/bin/lock",
"appName": "Lock"
},
{
"cwdPath": "/usr/bin/",
"iconPath": "/usr/bin/icons/store-ui.tga",
"executablePath": "/usr/bin/store-ui",
"appName": "Store UI"
},
{
"cwdPath": "/usr/bin/",
"iconPath": "/usr/bin/icons/weather-ui.tga",
Expand Down
Binary file added sources/core/apps/desktop/icons/store-ui.tga
Binary file not shown.
21 changes: 19 additions & 2 deletions sources/core/apps/desktop/source/core/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ kfont_t font;

int fb_fd = -1;
kframebuffer_t fb;
kframebuffer_t loading_fb;
struct fb_fix_screeninfo fix_screeninfo;
struct fb_var_screeninfo var_screeninfo;

Expand Down Expand Up @@ -100,6 +101,10 @@ void draw_frame(){
write(fb_fd, fb.buffer, fb.size);
}

void draw_loading_frame(){
write(fb_fd, loading_fb.buffer, loading_fb.size);
}

int get_key(int* pressed, uint64_t* key){
int64_t buffer;
if(read(fb_fd, &buffer, 1) > 0){
Expand All @@ -123,8 +128,6 @@ void get_current_date_time(char *time_str) {
int load_fb(){
fb_fd = open("/dev/fb0", O_RDWR);

printf("Loading desktop...\n");

assert(fb_fd >= 0);


Expand All @@ -146,6 +149,8 @@ int load_fb(){
fb.height = var_screeninfo.yres_virtual;
fb.buffer = malloc(fb.size);
memset(fb.buffer, 0, fb.size);
memcpy(&loading_fb, &fb, sizeof(kframebuffer_t));
loading_fb.buffer = malloc(loading_fb.size);
}else{
perror("'/dev/fb0' : format not supported\n");
return EXIT_FAILURE;
Expand Down Expand Up @@ -397,6 +402,12 @@ int reload_icons(){
return 0;
}

void show_loading_screen(raw_image_t* icon_image){
memset(loading_fb.buffer, 0, fb.size);
draw_image_with_binary_transparency(&loading_fb, icon_image, (loading_fb.width - ICON_IMAGE_WIDTH) / 2, (loading_fb.height - ICON_IMAGE_HEIGHT) / 2, ICON_IMAGE_WIDTH, ICON_IMAGE_HEIGHT);
draw_loading_frame();
}

void get_input(){
static bool arrow_pressed = false;
static bool wait_release = false;
Expand Down Expand Up @@ -469,6 +480,12 @@ void get_input(){
int c = focus_icon_column + focus_icon_row * icon_column_count;

{
if(icons_image[c] != NULL){
show_loading_screen(icons_image[c]);
}else{
show_loading_screen(default_icon_image);
}

pid_t p = fork();
if(p < 0){
perror("desktop: fork failed");
Expand Down
2 changes: 0 additions & 2 deletions sources/core/apps/explorer/source/core/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,6 @@ char* get_file_ext(char* name) {
int load_fb(){
fb_fd = open("/dev/fb0", O_RDWR);

printf("Loading explorer...\n");

assert(fb_fd >= 0);


Expand Down
2 changes: 0 additions & 2 deletions sources/core/apps/image-reader/source/core/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ int wait_escape(){
int load_fb(){
fb_fd = open("/dev/fb0", O_RDWR);

printf("Loading image-reader...\n");

assert(fb_fd >= 0);


Expand Down
6 changes: 2 additions & 4 deletions sources/core/apps/lock/source/core/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void get_current_time(char *time_str) {
void get_current_date(char *date_str) {
time_t now = time(NULL);
struct tm *t = localtime(&now);
strftime(date_str, 20, "%A, %B %d", t);
strftime(date_str, 30, "%A, %B %d", t);
}

int wait_escape(){
Expand Down Expand Up @@ -181,8 +181,6 @@ int check_pin(char* pin, char* pin_expected){
int main(int argc, char* argv[]){
fb_fd = open("/dev/fb0", O_RDWR);

printf("Loading lock screen...\n");

assert(fb_fd >= 0);


Expand Down Expand Up @@ -330,7 +328,7 @@ int main(int argc, char* argv[]){
while(true){
while(true){
char time_str[6];
char date_str[20];
char date_str[30];

draw_image(&fb, wallpaper_resized, 0, 0, fb.width, fb.height);

Expand Down
2 changes: 0 additions & 2 deletions sources/core/apps/text-reader/source/core/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,6 @@ char* get_file_ext(char* name) {
int load_fb(){
fb_fd = open("/dev/fb0", O_RDWR);

printf("Loading text-reader...\n");

assert(fb_fd >= 0);


Expand Down
2 changes: 0 additions & 2 deletions sources/core/apps/weather-ui/source/core/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,6 @@ void convert_name_to_path(char* name){
int load_fb(){
fb_fd = open("/dev/fb0", O_RDWR);

printf("Loading weather-ui...\n");

assert(fb_fd >= 0);


Expand Down
2 changes: 0 additions & 2 deletions sources/core/apps/welcome/source/core/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,6 @@ int wait_for_the_next_slide(){
int main(int argc, char* argv[]){
fb_fd = open("/dev/fb0", O_RDWR);

printf("Loading welcome app...\n");

assert(fb_fd >= 0);


Expand Down
2 changes: 1 addition & 1 deletion target/boot-disk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function mount_boot_disk {
mkdir -p $(dirname ${BOOT_DISK})

if ! [[ -b $BOOT_DISK ]]; then
sudo dd if=/dev/zero bs=5M count=0 seek=128 of=${BOOT_DISK}
sudo dd if=/dev/zero bs=10M count=0 seek=128 of=${BOOT_DISK}
fi

# Configure GPT partition table
Expand Down

0 comments on commit 201b5a1

Please sign in to comment.