Changeset a047aaa in mainline


Ignore:
Timestamp:
2014-11-13T00:27:06Z (9 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9696b01
Parents:
7e3581e
Message:

barber: visual liveness indicator (using the barber pole animation and blink(1) LEDs)
refactor the LED support from vlaunch into barber

Files:
32 added
5 edited

Legend:

Unmodified
Added
Removed
  • boot/Makefile.common

    r7e3581e ra047aaa  
    168168
    169169RD_APPS_NON_ESSENTIAL = \
     170        $(USPACE_PATH)/app/barber/barber \
    170171        $(USPACE_PATH)/app/bithenge/bithenge \
    171172        $(USPACE_PATH)/app/blkdump/blkdump \
  • uspace/Makefile

    r7e3581e ra047aaa  
    3434
    3535DIRS = \
     36        app/barber \
    3637        app/bdsh \
    3738        app/bithenge \
     
    212213        lib/fmtutil \
    213214        lib/scsi \
     215        lib/compress \
    214216        lib/softint \
    215217        lib/softfloat \
  • uspace/Makefile.common

    r7e3581e ra047aaa  
    144144LIBNIC_PREFIX = $(LIB_PREFIX)/nic
    145145LIBMINIX_PREFIX = $(LIB_PREFIX)/minix
     146LIBCOMPRESS_PREFIX = $(LIB_PREFIX)/compress
    146147
    147148LIBSCSI_PREFIX = $(LIB_PREFIX)/scsi
  • uspace/app/init/init.c

    r7e3581e ra047aaa  
    355355        int rc = compositor(HID_INPUT, HID_COMPOSITOR_SERVER);
    356356        if (rc == EOK) {
     357                gui_start("/app/barber", HID_COMPOSITOR_SERVER);
    357358                gui_start("/app/vlaunch", HID_COMPOSITOR_SERVER);
    358359                gui_start("/app/vterm", HID_COMPOSITOR_SERVER);
  • uspace/app/vlaunch/vlaunch.c

    r7e3581e ra047aaa  
    3737#include <stdio.h>
    3838#include <malloc.h>
    39 #include <io/pixel.h>
    4039#include <task.h>
    41 #include <str.h>
    4240#include <str_error.h>
    43 #include <loc.h>
    44 #include <fibril_synch.h>
    45 #include <io/pixel.h>
    46 #include <device/led_dev.h>
    4741
    4842#include <window.h>
     
    6458#define LOGO_HEIGHT  66
    6559
    66 #define PERIOD  1000000
    67 #define COLORS  7
    68 
    6960static char *winreg = NULL;
    70 static fibril_timer_t *timer = NULL;
    71 static list_t led_devs;
    72 
    73 static pixel_t colors[COLORS] = {
    74         PIXEL(0xff, 0xff, 0x00, 0x00),
    75         PIXEL(0xff, 0x00, 0xff, 0x00),
    76         PIXEL(0xff, 0x00, 0x00, 0xff),
    77         PIXEL(0xff, 0xff, 0xff, 0x00),
    78         PIXEL(0xff, 0xff, 0x00, 0xff),
    79         PIXEL(0xff, 0x00, 0xff, 0xff),
    80         PIXEL(0xff, 0xff, 0xff, 0xff)
    81 };
    82 
    83 static unsigned int color = 0;
    84 
    85 typedef struct {
    86         link_t link;
    87         service_id_t svc_id;
    88         async_sess_t *sess;
    89 } led_dev_t;
    9061
    9162static int app_launch(const char *app)
     
    129100}
    130101
    131 static void timer_callback(void *data)
    132 {
    133         pixel_t next_color = colors[color];
    134        
    135         color++;
    136         if (color >= COLORS)
    137                 color = 0;
    138        
    139         list_foreach(led_devs, link, led_dev_t, dev) {
    140                 if (dev->sess)
    141                         led_dev_color_set(dev->sess, next_color);
    142         }
    143        
    144         fibril_timer_set(timer, PERIOD, timer_callback, NULL);
    145 }
    146 
    147 static void loc_callback(void)
    148 {
    149         category_id_t led_cat;
    150         int rc = loc_category_get_id("led", &led_cat, IPC_FLAG_BLOCKING);
    151         if (rc != EOK)
    152                 return;
    153        
    154         service_id_t *svcs;
    155         size_t count;
    156         rc = loc_category_get_svcs(led_cat, &svcs, &count);
    157         if (rc != EOK)
    158                 return;
    159        
    160         for (size_t i = 0; i < count; i++) {
    161                 bool known = false;
    162                
    163                 /* Determine whether we already know this device. */
    164                 list_foreach(led_devs, link, led_dev_t, dev) {
    165                         if (dev->svc_id == svcs[i]) {
    166                                 known = true;
    167                                 break;
    168                         }
    169                 }
    170                
    171                 if (!known) {
    172                         led_dev_t *dev = (led_dev_t *) calloc(1, sizeof(led_dev_t));
    173                         if (!dev)
    174                                 continue;
    175                        
    176                         link_initialize(&dev->link);
    177                         dev->svc_id = svcs[i];
    178                         dev->sess = loc_service_connect(EXCHANGE_SERIALIZE, svcs[i], 0);
    179                        
    180                         list_append(&dev->link, &led_devs);
    181                 }
    182         }
    183        
    184         // FIXME: Handle LED device removal
    185        
    186         free(svcs);
    187 }
    188 
    189102int main(int argc, char *argv[])
    190103{
    191104        if (argc < 2) {
    192105                printf("Compositor server not specified.\n");
    193                 return 1;
    194         }
    195        
    196         list_initialize(&led_devs);
    197         int rc = loc_register_cat_change_cb(loc_callback);
    198         if (rc != EOK) {
    199                 printf("Unable to register callback for device discovery.\n");
    200                 return 1;
    201         }
    202        
    203         timer = fibril_timer_create(NULL);
    204         if (!timer) {
    205                 printf("Unable to create timer.\n");
    206106                return 1;
    207107        }
     
    262162        window_exec(main_window);
    263163       
    264         fibril_timer_set(timer, PERIOD, timer_callback, NULL);
    265        
    266164        task_retval(0);
    267165        async_manager();
Note: See TracChangeset for help on using the changeset viewer.