Add progress dots to USB tab, update rom_info.txt
This commit is contained in:
		@@ -14,7 +14,8 @@ LOCAL_SRC_FILES:= \
 | 
				
			|||||||
	listview.c \
 | 
						listview.c \
 | 
				
			||||||
	checkbox.c \
 | 
						checkbox.c \
 | 
				
			||||||
	button.c \
 | 
						button.c \
 | 
				
			||||||
	pong.c
 | 
						pong.c \
 | 
				
			||||||
 | 
						progressdots.c
 | 
				
			||||||
 | 
					
 | 
				
			||||||
LOCAL_MODULE:= multirom
 | 
					LOCAL_MODULE:= multirom
 | 
				
			||||||
LOCAL_MODULE_TAGS := eng
 | 
					LOCAL_MODULE_TAGS := eng
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1761,8 +1761,10 @@ void *multirom_usb_refresh_thread_work(void *status)
 | 
				
			|||||||
            if(stat("/dev/block", &info) >= 0 && info.st_ctime > last_change)
 | 
					            if(stat("/dev/block", &info) >= 0 && info.st_ctime > last_change)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                multirom_update_partitions((struct multirom_status*)status);
 | 
					                multirom_update_partitions((struct multirom_status*)status);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if(usb_refresh_handler)
 | 
					                if(usb_refresh_handler)
 | 
				
			||||||
                    (*usb_refresh_handler)();
 | 
					                    (*usb_refresh_handler)();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                last_change = info.st_ctime;
 | 
					                last_change = info.st_ctime;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            timer = 500;
 | 
					            timer = 500;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -16,6 +16,7 @@
 | 
				
			|||||||
#include "checkbox.h"
 | 
					#include "checkbox.h"
 | 
				
			||||||
#include "version.h"
 | 
					#include "version.h"
 | 
				
			||||||
#include "pong.h"
 | 
					#include "pong.h"
 | 
				
			||||||
 | 
					#include "progressdots.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define HEADER_HEIGHT 75
 | 
					#define HEADER_HEIGHT 75
 | 
				
			||||||
#define TAB_BTN_WIDTH 165
 | 
					#define TAB_BTN_WIDTH 165
 | 
				
			||||||
@@ -394,6 +395,7 @@ typedef struct
 | 
				
			|||||||
    fb_text *title_text;
 | 
					    fb_text *title_text;
 | 
				
			||||||
    fb_text *usb_text;
 | 
					    fb_text *usb_text;
 | 
				
			||||||
    button *boot_btn;
 | 
					    button *boot_btn;
 | 
				
			||||||
 | 
					    progdots *usb_prog;
 | 
				
			||||||
} tab_roms;
 | 
					} tab_roms;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void *multirom_ui_tab_rom_init(int tab_type)
 | 
					void *multirom_ui_tab_rom_init(int tab_type)
 | 
				
			||||||
@@ -475,6 +477,9 @@ void multirom_ui_tab_rom_destroy(void *data)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    fb_rm_text(t->rom_name);
 | 
					    fb_rm_text(t->rom_name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if(t->usb_prog)
 | 
				
			||||||
 | 
					        progdots_destroy(t->usb_prog);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    free(t);
 | 
					    free(t);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -600,9 +605,15 @@ void multirom_ui_tab_rom_set_empty(void *data, int empty)
 | 
				
			|||||||
        int y = center_y(HEADER_HEIGHT, t->list->h, SIZE_NORMAL);
 | 
					        int y = center_y(HEADER_HEIGHT, t->list->h, SIZE_NORMAL);
 | 
				
			||||||
        t->usb_text = fb_add_text(x, y, WHITE, SIZE_NORMAL, txt);
 | 
					        t->usb_text = fb_add_text(x, y, WHITE, SIZE_NORMAL, txt);
 | 
				
			||||||
        list_add(t->usb_text, &t->ui_elements);
 | 
					        list_add(t->usb_text, &t->ui_elements);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        x = (fb_width/2) - (PROGDOTS_W/2);
 | 
				
			||||||
 | 
					        t->usb_prog = progdots_create(x, y+100);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else if(!empty && t->usb_text)
 | 
					    else if(!empty && t->usb_text)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					        progdots_destroy(t->usb_prog);
 | 
				
			||||||
 | 
					        t->usb_prog = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        list_rm(t->usb_text, &t->ui_elements, &fb_remove_item);
 | 
					        list_rm(t->usb_text, &t->ui_elements, &fb_remove_item);
 | 
				
			||||||
        t->usb_text = NULL;
 | 
					        t->usb_text = NULL;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										68
									
								
								progressdots.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										68
									
								
								progressdots.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,68 @@
 | 
				
			|||||||
 | 
					#include <unistd.h>
 | 
				
			||||||
 | 
					#include "progressdots.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ms
 | 
				
			||||||
 | 
					#define SWITCH_SPEED 800
 | 
				
			||||||
 | 
					#define THREAD_SLEEP 50
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void *progdots_thread(void *data)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    progdots *p = (progdots*)data;
 | 
				
			||||||
 | 
					    int timer = SWITCH_SPEED;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    while(p->run)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if(timer <= THREAD_SLEEP)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if(++p->active_dot >= PROGDOTS_CNT)
 | 
				
			||||||
 | 
					                p->active_dot = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            progdots_set_active(p, p->active_dot); 
 | 
				
			||||||
 | 
					            fb_draw();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            timer = SWITCH_SPEED;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else timer -= THREAD_SLEEP;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        usleep(THREAD_SLEEP*1000);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    return NULL;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					progdots *progdots_create(int x, int y)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    progdots *p = malloc(sizeof(progdots));
 | 
				
			||||||
 | 
					    memset(p, 0, sizeof(progdots));
 | 
				
			||||||
 | 
					    p->x = x;
 | 
				
			||||||
 | 
					    p->y = y;
 | 
				
			||||||
 | 
					    p->run = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    int i;
 | 
				
			||||||
 | 
					    for(i = 0; i < PROGDOTS_CNT; ++i)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        p->dots[i] = fb_add_rect(x, y, PROGDOTS_H, PROGDOTS_H, (i == 0 ? LBLUE : WHITE));
 | 
				
			||||||
 | 
					        x += PROGDOTS_H + (PROGDOTS_W - (PROGDOTS_CNT*PROGDOTS_H))/(PROGDOTS_CNT-1);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    pthread_create(&p->thread, NULL, progdots_thread, p);
 | 
				
			||||||
 | 
					    fb_draw();
 | 
				
			||||||
 | 
					    return p;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void progdots_destroy(progdots *p)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    p->run = 0;
 | 
				
			||||||
 | 
					    pthread_join(p->thread, NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    int i;
 | 
				
			||||||
 | 
					    for(i = 0; i < PROGDOTS_CNT; ++i)
 | 
				
			||||||
 | 
					        fb_rm_rect(p->dots[i]);
 | 
				
			||||||
 | 
					    free(p);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void progdots_set_active(progdots *p, int dot)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    p->active_dot = dot;
 | 
				
			||||||
 | 
					    int i;
 | 
				
			||||||
 | 
					    for(i = 0; i < PROGDOTS_CNT; ++i)
 | 
				
			||||||
 | 
					        p->dots[i]->color = (i == dot ? LBLUE : WHITE);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										24
									
								
								progressdots.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								progressdots.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,24 @@
 | 
				
			|||||||
 | 
					#ifndef PROGRESSDOTS_H
 | 
				
			||||||
 | 
					#define PROGRESSDOTS_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <pthread.h>
 | 
				
			||||||
 | 
					#include "framebuffer.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define PROGDOTS_W 300
 | 
				
			||||||
 | 
					#define PROGDOTS_H 10
 | 
				
			||||||
 | 
					#define PROGDOTS_CNT 8
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					typedef struct
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    int x, y;
 | 
				
			||||||
 | 
					    pthread_t thread;
 | 
				
			||||||
 | 
					    volatile int run;
 | 
				
			||||||
 | 
					    fb_rect *dots[PROGDOTS_CNT];
 | 
				
			||||||
 | 
					    int active_dot;
 | 
				
			||||||
 | 
					} progdots;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					progdots *progdots_create(int x, int y);
 | 
				
			||||||
 | 
					void progdots_destroy(progdots *p);
 | 
				
			||||||
 | 
					void progdots_set_active(progdots *p, int dot);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
@@ -39,6 +39,6 @@ initrd_path="%r/boot/initrd.img"
 | 
				
			|||||||
#  - %s - root directory, from root of the root device
 | 
					#  - %s - root directory, from root of the root device
 | 
				
			||||||
#  - %i - root image, from root of the root device
 | 
					#  - %i - root image, from root of the root device
 | 
				
			||||||
#  - %f - fs of the root image
 | 
					#  - %f - fs of the root image
 | 
				
			||||||
base_cmdline="%b root=%d rootfstype=%r rw console=tty0 fbcon=rotate:1 access=m2 quiet splash rootflags=defaults,noatime,nodiratime"
 | 
					base_cmdline="%b root=%d rootfstype=%r rw console=tty0 access=m2 quiet splash rootflags=defaults,noatime,nodiratime"
 | 
				
			||||||
img_cmdline="loop=%i loopfstype=%f"
 | 
					img_cmdline="loop=%i loopfstype=%f"
 | 
				
			||||||
dir_cmdline="rootsubdir=%s"
 | 
					dir_cmdline="rootsubdir=%s"
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user