Exemplo n.º 1
0
static void update_pulsating_button(int state, enum rke_cbs_status status, int cbsid)
{
    const char *img_path = NULL, *img_pressed_path = NULL;
    char path[64];
    int color_idx = (status == CBSS_GRAY) ? 0 : status;
    pthread_mutex_lock(&ui_mutex);

    switch (cbsid) {
        case CBS_DETAIL_ID_ENGINE_OIL:
            img_path = engine_oil_image_array[color_idx][state];
            img_pressed_path = engine_oil_image_array[color_idx][2];
            break;
        case CBS_DETAIL_ID_VEHICLE_CHECK:
            img_path = vehicle_check_image_array[color_idx][state];
            img_pressed_path = vehicle_check_image_array[color_idx][2];
            break;
        case CBS_DETAIL_ID_FRONT_BRAKES:
            img_path = front_brakes_image_array[color_idx][state];
            img_pressed_path = front_brakes_image_array[color_idx][2];
            break;
        case CBS_DETAIL_ID_REAR_BRAKES:
            img_path = rear_brakes_image_array[color_idx][state];
            img_pressed_path = rear_brakes_image_array[color_idx][2];
            break;
        case CBS_DETAIL_ID_BRAKE_FLUID:
            img_path = breakfluid_image_array[color_idx][state];
            img_pressed_path = breakfluid_image_array[color_idx][2];
            break;
        case CBS_DETAIL_ID_INSPECTION:
            img_path = inspection_image_array[color_idx][state];
            img_pressed_path = inspection_image_array[color_idx][2];
            break;
        case CBS_NOTIFICATION:
        default:
            img_path = notification_image_array[color_idx][state];
            img_pressed_path = notification_image_array[color_idx][2];
            break;
    }

    snprintf(path, sizeof(path), "%s/%s", IMAGE_DIR, img_path);
    lite_set_button_image(serviceButton, LITE_BS_NORMAL, path);
    lite_set_button_image(serviceButton, LITE_BS_HILITE, path);
    snprintf(path, sizeof(path), "%s/%s", IMAGE_DIR, img_pressed_path);
    lite_set_button_image(serviceButton, LITE_BS_PRESSED, path);

    pthread_mutex_unlock(&ui_mutex);
}
Exemplo n.º 2
0
int
main (int argc, char *argv[])
{
     LiteButton   *button;
     LiteImage    *image;
     LiteLabel    *label;
     LiteTextLine *textline;
     LiteWindow   *window;
     DFBRectangle  rect;
     DFBResult     res;

     /* initialize */
     if (lite_open( &argc, &argv ))
          return 1;

     /* create a window */
     rect.x = LITE_CENTER_HORIZONTALLY;
     rect.y = LITE_CENTER_VERTICALLY;
     rect.w = 300;
     rect.h = 200;

     res = lite_new_window( NULL, 
                            &rect,
                            DWCAPS_ALPHACHANNEL, 
                            liteDefaultWindowTheme,
                            "Simple",
                            &window );


     /* setup the label */
     rect.x = 10; rect.y = 10; rect.w = 110;
     res = lite_new_label(LITE_BOX(window), &rect, liteNoLabelTheme, 20, &label);

     lite_set_label_text( label, "Hello World" );

     /* setup the textline */
     rect.x = 10; rect.y = 40; rect.w = 100; rect.h = 20;
     res = lite_new_textline(LITE_BOX(window), &rect, liteNoTextLineTheme, &textline);
     
     rect.x = 10; rect.y = 60; rect.w = 100; rect.h = 20;
     res = lite_new_textline(LITE_BOX(window), &rect, liteNoTextLineTheme, &textline);

     /* setup the button */
     rect.x = 180; rect.y = 130; rect.w = 50; rect.h = 50;
     res = lite_new_button(LITE_BOX(window), &rect, liteNoButtonTheme, &button);

     lite_set_button_image( button, LITE_BS_NORMAL, EXAMPLESDATADIR "/stop.png" );
     lite_set_button_image( button, LITE_BS_DISABLED, EXAMPLESDATADIR "/stop_disabled.png" );
     lite_set_button_image( button, LITE_BS_HILITE, EXAMPLESDATADIR "/stop_highlighted.png" );
     lite_set_button_image( button, LITE_BS_PRESSED, EXAMPLESDATADIR "/stop_pressed.png" );

     lite_on_button_press( button, button_pressed, window );
     
     /* 2nd button */
     rect.x = 230; rect.y = 130; rect.w = 50; rect.h = 50;
     res = lite_new_button(LITE_BOX(window), &rect, liteNoButtonTheme, &button);
     lite_set_button_type( button, LITE_BT_TOGGLE );
 
     lite_set_button_image( button, LITE_BS_NORMAL, EXAMPLESDATADIR "/toggle.png" );
     lite_set_button_image( button, LITE_BS_DISABLED, EXAMPLESDATADIR "/toggle_disabled.png" );
     lite_set_button_image( button, LITE_BS_HILITE, EXAMPLESDATADIR "/toggle_highlighted.png" );
     lite_set_button_image( button, LITE_BS_PRESSED, EXAMPLESDATADIR "/toggle_pressed.png" );
     lite_set_button_image( button, LITE_BS_HILITE_ON, EXAMPLESDATADIR "/toggle_highlighted_on.png" );
     lite_set_button_image( button, LITE_BS_DISABLED_ON, EXAMPLESDATADIR "/toggle_disabled_on.png" );

     lite_on_button_press( button, toggle_button_pressed, window );

     /* setup the image */
     rect.x = 200; rect.y = 20; rect.w = 64; rect.h = 50;
     res = lite_new_image(LITE_BOX(window), &rect, liteNoImageTheme, &image);

     lite_load_image( image, EXAMPLESDATADIR "/D.png" );


     /* show the window */
     lite_set_window_opacity( window, liteFullWindowOpacity );

     /* run the default event loop */
     lite_window_event_loop( window, 0 );

     /* destroy the window with all this children and resources */
     lite_destroy_window( window );

     /* deinitialize */
     lite_close();

     return 0;
}
Exemplo n.º 3
0
int loadMainMenu(LiteWindow *window) {
    DFBResult       res;
    DFBRectangle rect;
    LiteImage *backImg;
    LiteButton *lockButton;
    LiteButton *exitButton;
    LiteLabel *label;

    rect.x = 0;
    rect.y = 0;
    rect.w = MKD_SCREEN_WIDTH;
    rect.h = MKD_SCREEN_HEIGHT;

    lite_set_window_blend_mode(window, LITE_BLEND_AUTO, LITE_BLEND_ALWAYS);

    //lite_set_window_background(window, NULL);
    lite_set_window_background_color(window, 0, 0, 0, 1);

    /* Setup lock button */
    rect.x = 50; rect.y = 80; rect.w = 52; rect.h = 64;
    res = lite_new_button(LITE_BOX(window), &rect, liteNoButtonTheme, &lockButton);
    res = lite_set_button_image(lockButton, LITE_BS_NORMAL, IMAGE_DIR "car_lock_2.png");
    res = lite_set_button_image(lockButton, LITE_BS_HILITE, IMAGE_DIR "car_lock_2.png");
    res = lite_set_button_image(lockButton, LITE_BS_PRESSED, IMAGE_DIR "car_lock_2.png");
    //lite_new_text_button(LITE_BOX(window), &rect, "Vehicle Info", liteDefaultTextButtonTheme, &vinfoButton);
    //lite_on_button_press( lockButton, vehicleInfoPressed, window );

#if 0
    /* Load background */ 
    res = lite_new_image(LITE_BOX(window),
                        &rect,
                        liteNoImageTheme,
                        &backImg);
    res = lite_load_image(backImg, IMAGE_DIR "H1.png");


    /* Setup Vinfo button */
    rect.x = 10; rect.y = 49; rect.w = 204; rect.h = 46;
    res = lite_new_button(LITE_BOX(window), &rect, liteNoButtonTheme, &vinfoButton);
    res = lite_set_button_image(vinfoButton, LITE_BS_NORMAL, IMAGE_DIR "Vinfo_d.png");
    res = lite_set_button_image(vinfoButton, LITE_BS_HILITE, IMAGE_DIR "Vinfo_d.png");
    res = lite_set_button_image(vinfoButton, LITE_BS_PRESSED, IMAGE_DIR "Vinfo_d.png");
    //lite_new_text_button(LITE_BOX(window), &rect, "Vehicle Info", liteDefaultTextButtonTheme, &vinfoButton);
    lite_on_button_press( vinfoButton, vehicleInfoPressed, window );
    
    /* Setup climate button */
    rect.x = 0; rect.y = 151; rect.w = 224; rect.h = 53;
    res = lite_new_button(LITE_BOX(window), &rect, liteNoButtonTheme, &climateButton);
    res = lite_set_button_image(climateButton, LITE_BS_NORMAL, IMAGE_DIR "Climate_d.png");
    res = lite_set_button_image(climateButton, LITE_BS_HILITE, IMAGE_DIR "Climate_d.png");
    res = lite_set_button_image(climateButton, LITE_BS_PRESSED, IMAGE_DIR "Climate_a.png");
    lite_on_button_press( climateButton, climatePressed, window );
#endif    

    /* Setup firmware info */
    getFwVersion();
    rect.x = 130; rect.y = 293; rect.w = 80; 
    res = lite_new_label(LITE_BOX(window), &rect, liteNoLabelTheme, 18, &label); 
    DFBColor color;
    color.a = 1;
    color.r = 255;
    color.g = 255;
    color.b = 255;
    lite_set_label_color( label, &color);
    lite_set_label_text( label, fwinfo );

    /* Setup exit button */
    rect.x = 140; rect.y = 260; rect.w = 140; rect.h = 60;
    res = lite_new_button(LITE_BOX(window), &rect, liteNoButtonTheme, &exitButton);
    lite_on_button_press( exitButton, exitPressed, window );

    return MKD_OK;
}
Exemplo n.º 4
0
static void update_cbs_button()
{
    DFBResult res;
    char *img_path = NULL, *img_pressed_path = NULL;
    char path[64];

    pthread_mutex_lock(&ui_mutex);

    if (cbs_result_cmp(&curCbsResult, &preCbsResult) == 0 && first_icon_initialized) {
        pthread_mutex_unlock(&ui_mutex);
        LOG_DBG("%s: cbs result did not change. Ignore.\n", __func__);
        return;
    }

    if (first_icon_initialized == false) {
        first_icon_initialized = true;
    }

    /* Stop animation if it is pulsating now. */
    stopPulsatingAnimation();

    int red_count = cbs_count(&curCbsResult, CBSS_RED);
    int yellow_count = cbs_count(&curCbsResult, CBSS_YELLOW);
    int gray_count = cbs_count(&curCbsResult, CBSS_GRAY);
    int green_count = cbs_count(&curCbsResult, CBSS_GREEN);
    int prev_red_count = cbs_count(&preCbsResult, CBSS_RED);
    int prev_yellow_count = cbs_count(&preCbsResult, CBSS_YELLOW);
    int prev_gray_count = cbs_count(&preCbsResult, CBSS_GRAY);
    int prev_green_count = cbs_count(&preCbsResult, CBSS_GREEN);

    LOG_DBG("Current CBSResult count: %d,%d,%d,%d\n", red_count, yellow_count, gray_count, green_count);
    LOG_DBG("Previous CBSResult count: %d,%d,%d,%d\n", prev_red_count, prev_yellow_count, prev_gray_count, prev_green_count);

    if ((have_seen_cbs_detail == false) && (red_count > prev_red_count)) {
        pthread_mutex_unlock(&ui_mutex);
        if (red_count > 1 || (red_count > 0 && (yellow_count > 0 || gray_count > 0))) {
            /* Show RED initial notification */
            startPulsatingAnimation(CBSS_RED, CBS_NOTIFICATION);
        } else {
            /* Show the only one RED cbs initial icon */
            startPulsatingAnimation(CBSS_RED, find_cbsid(&curCbsResult, CBSS_RED));
        }
        return;
    } else if ((have_seen_cbs_detail == false) && (yellow_count > prev_yellow_count)) {
        pthread_mutex_unlock(&ui_mutex);
        if (red_count > 0) {
            /* Show RED initial notification */
            startPulsatingAnimation(CBSS_RED, CBS_NOTIFICATION);
        } else if (yellow_count > 1 || (yellow_count > 0 && gray_count > 0)) {
            /* Show Yellow initial notification */
            startPulsatingAnimation(CBSS_YELLOW, CBS_NOTIFICATION);
        } else {
            /* Show the only one YELLOW cbs initial icon */
            startPulsatingAnimation(CBSS_YELLOW, find_cbsid(&curCbsResult, CBSS_YELLOW));
        }
        return;
    } else if ((have_seen_cbs_detail == false) && (gray_count > prev_gray_count)) {
        pthread_mutex_unlock(&ui_mutex);
        if (red_count > 0) {
            /* Show RED initial notification */
            startPulsatingAnimation(CBSS_RED, CBS_NOTIFICATION);
        } else if (yellow_count > 0) {
            /* Show Yellow initial notification */
            startPulsatingAnimation(CBSS_YELLOW, CBS_NOTIFICATION);
        } else if (gray_count > 1) {
            /* Show Gray initial notification */
            startPulsatingAnimation(CBSS_GRAY, CBS_NOTIFICATION);
        } else {
            /* Show the only one GRAY cbs initial icon */
            startPulsatingAnimation(CBSS_GRAY, find_cbsid(&curCbsResult, CBSS_GRAY));
        }
        return;
    } else if (red_count > 1 || (red_count > 0 && (yellow_count > 0 || gray_count > 0))) {
        /* Show RED notification */
        img_path = "0_2_notification_red.png";
        img_pressed_path = "0_2_notification_red_press.png";
    } else if (yellow_count > 1 || (yellow_count > 0 && gray_count > 0)) {
        /* Show YELLOW notification */
        img_path = "0_2_notification_yellow.png";
        img_pressed_path = "0_2_notification_yellow_press.png";
    } else if (gray_count > 1) {
        /* Show GRAY notification */
        img_path = "0_2_notification_grey.png";
        img_pressed_path = "0_2_notification_grey_press.png";
    } else if ((red_count + yellow_count + gray_count) == 0) {
        /* Show OK notification */
        img_path = "0_2_ok.png";
        img_pressed_path = "0_2_ok_press.png";
    } else {
        /* Show bubbles */
        if (curCbsResult.engine_oil == CBSS_RED) {
            img_path = "0_2_engine_red.png";
            img_pressed_path = "0_2_engine_red_press.png";
        } else if (curCbsResult.engine_oil == CBSS_YELLOW) {
            img_path = "0_2_engine_yellow.png";
            img_pressed_path = "0_2_engine_yellow_press.png";
        } else if (curCbsResult.engine_oil == CBSS_GRAY) {
            img_path = "0_2_engine_grey.png";
            img_pressed_path = "0_2_engine_grey_press.png";
        } else if (curCbsResult.vehicle_check == CBSS_RED) {
            img_path = "0_2_vehiclecheck_red.png";
            img_pressed_path = "0_2_vehiclecheck_red_press.png";
        } else if (curCbsResult.vehicle_check == CBSS_YELLOW) {
            img_path = "0_2_vehiclecheck_yellow.png";
            img_pressed_path = "0_2_vehiclecheck_yellow_press.png";
        } else if (curCbsResult.vehicle_check == CBSS_GRAY) {
            img_path = "0_2_vehiclecheck_grey.png";
            img_pressed_path = "0_2_vehiclecheck_grey_press.png";
        } else if (curCbsResult.front_brakes == CBSS_RED) {
            img_path = "0_2_frontbreaks_red.png";
            img_pressed_path = "0_2_frontbreaks_red_press.png";
        } else if (curCbsResult.front_brakes == CBSS_YELLOW) {
            img_path = "0_2_frontbreaks_yellow.png";
            img_pressed_path = "0_2_frontbreaks_yellow_press.png";
        } else if (curCbsResult.front_brakes == CBSS_GRAY) {
            img_path = "0_2_frontbreaks_grey.png";
            img_pressed_path = "0_2_frontbreaks_grey_press.png";
        } else if (curCbsResult.rear_brakes == CBSS_RED) {
            img_path = "0_2_rearbreaks_red.png";
            img_pressed_path = "0_2_rearbreaks_red_press.png";
        } else if (curCbsResult.rear_brakes == CBSS_YELLOW) {
            img_path = "0_2_rearbreaks_yellow.png";
            img_pressed_path = "0_2_rearbreaks_yellow_press.png";
        } else if (curCbsResult.rear_brakes == CBSS_GRAY) {
            img_path = "0_2_rearbreaks_grey.png";
            img_pressed_path = "0_2_rearbreaks_grey_press.png";
        } else if (curCbsResult.breakfluid == CBSS_RED) {
            img_path = "0_2_breakflud_red.png";
            img_pressed_path = "0_2_breakflud_red_press.png";
        } else if (curCbsResult.breakfluid == CBSS_YELLOW) {
            img_path = "0_2_breakflud_yellow.png";
            img_pressed_path = "0_2_breakflud_yellow_press.png";
        } else if (curCbsResult.breakfluid == CBSS_GRAY) {
            img_path = "0_2_breakflud_grey.png";
            img_pressed_path = "0_2_breakflud_grey_press.png";
        } else if (curCbsResult.inspection == CBSS_RED) {
            img_path = "0_2_inspection_red.png";
            img_pressed_path = "0_2_inspection_red_press.png";
        } else if (curCbsResult.inspection == CBSS_YELLOW) {
            img_path = "0_2_inspection_yellow.png";
            img_pressed_path = "0_2_inspection_yellow_press.png";
        } else if (curCbsResult.inspection == CBSS_GRAY) {
            img_path = "0_2_inspection_grey.png";
            img_pressed_path = "0_2_inspection_grey_press.png";
        }
    }

    if (img_path == NULL || img_pressed_path == NULL) {
        LOG_ERR("Invalid cbs image path!\n");
        pthread_mutex_unlock(&ui_mutex);
        return;
    }

    snprintf(path, sizeof(path), "%s/%s", IMAGE_DIR, img_path);
    res = lite_set_button_image(serviceButton, LITE_BS_NORMAL, path);
    res = lite_set_button_image(serviceButton, LITE_BS_HILITE, path);
    snprintf(path, sizeof(path), "%s/%s", IMAGE_DIR, img_pressed_path);
    res = lite_set_button_image(serviceButton, LITE_BS_PRESSED, path);

    pthread_mutex_unlock(&ui_mutex);
}