static void find_response_curve(const char* fname)
{
    char fname_real[255];
    snprintf(fname_real, sizeof(fname_real), "ML/LOGS/%s", fname);
    FILE* f = FIO_CreateFile(fname_real);

    ensure_movie_mode();
    clrscr();
    set_lv_zoom(5);

    msleep(1000);

    for (int i = 0; i < 64*2; i+=8)
        bmp_draw_rect(COLOR_BLACK,  i*5+40, 0, 8*5, 380);

    draw_line( 40,  190,  720-40,  190, COLOR_BLACK);

    extern int bv_auto;
    //int bva0 = bv_auto;
    bv_auto = 0; // make sure it won't interfere

    bv_enable(); // for enabling fine 1/8 EV increments

    int ma = (lens_info.raw_aperture_min + 7) & ~7;
    for (int i = 0; i < 64*2; i++)
    {
        int a = (i/2) & ~7;                                // change aperture in full-stop increments
        lens_set_rawaperture(ma + a);
        lens_set_rawshutter(96 + i - a);                   // shutter can be changed in finer increments
        msleep(400);
        int Y,U,V;
        get_spot_yuv(180, &Y, &U, &V);
        dot( i*5 + 40 - 16,  380 - Y*380/255 - 16, COLOR_BLUE, 3); // dot has an offset of 16px
        my_fprintf(f, "%d %d %d %d\n", i, Y, U, V);
    }
    FIO_CloseFile(f);
    beep();
    //~ call("dispcheck");
    lens_set_rawaperture(ma);
    lens_set_rawshutter(96);
}
Exemple #2
0
static void console_draw(int tiny)
{
    int cbpos0 = mod((console_buffer_index / CONSOLE_W) * CONSOLE_W  + CONSOLE_W, BUFSIZE);
    
    /* display last two lines that actually contain something (don't display the cursor-only line) */
    if (tiny && console_buffer_index % CONSOLE_W == 0)
        cbpos0 -= CONSOLE_W;

    int skipped_lines = 0;
    int chopped_columns = 0;

    /* skip empty lines at the top */
    for (int i = 0; i < CONSOLE_H; i++)
    {
        int cbpos = cbpos0 + i * CONSOLE_W;
        int empty = 1;
        for (int j = 0; j < CONSOLE_W; j++)
            if (CONSOLE_BUFFER(cbpos + j) != ' ')
                { empty = 0; break; }
        if (empty) skipped_lines++;
        else break;
    }
    
    if (skipped_lines == CONSOLE_H) // nothing to show
        return;
    
    if (tiny)
        skipped_lines = CONSOLE_H - 3;
    
    /* chop empty columns from the right */
    for (int j = CONSOLE_W-1; j > 0; j--)
    {
        int empty = 1;
        for (int i = skipped_lines; i < CONSOLE_H; i++)
            if (CONSOLE_BUFFER(cbpos0 + i*CONSOLE_W + j) != ' ')
                { empty = 0; break; }
        if (empty) chopped_columns++;
        else break;
    }
    chopped_columns = MIN(chopped_columns, CONSOLE_W - (console_buffer_index % CONSOLE_W));
    
    if (skipped_lines < 5) skipped_lines = 0;
    if (chopped_columns < 5) chopped_columns = 0;

    /* can we use large fonts? */
    int can_use_large_font = (skipped_lines > 7 && chopped_columns > 25 && !tiny);

    /* top-left corner of "full" console (without lines/columns skipped) */
    unsigned x0 =  720/2 - fontspec_font(CONSOLE_FONT)->width * CONSOLE_W/2;
    unsigned y0 =  480/2 - fontspec_font(CONSOLE_FONT)->height * CONSOLE_H/2;

    /* correct y to account for skipped lines */
    int yc = y0;
    if (tiny)
    {
        yc = gui_menu_shown() || MENU_MODE ? 415 : y0;
    }
    else
    {
        yc = y0 + fontspec_font(CONSOLE_FONT)->height * skipped_lines;
    }
    if (can_use_large_font) yc -= (fontspec_font(FONT_LARGE)->height - fontspec_font(CONSOLE_FONT)->height) * (CONSOLE_H - skipped_lines);

    int fnt = FONT(can_use_large_font ? FONT_LARGE : CONSOLE_FONT,COLOR_WHITE, (lv || PLAY_OR_QR_MODE) ? COLOR_BG_DARK : COLOR_ALMOST_BLACK);

    int xa = (x0 & ~3) - 1;
    int ya = (yc-1);
    int w = fontspec_font(fnt)->width * (CONSOLE_W - chopped_columns) + 2;
    int h = fontspec_font(fnt)->height * (CONSOLE_H - skipped_lines) + 2;

    /* did the console shrink? if so, redraw Canon GUI around it */
    static int prev_w = 0;
    static int prev_h = 0;
    if (w < prev_w || h < prev_h)
    {
        canon_gui_enable_front_buffer(1); // force a redraw
        prev_w = w;
        prev_h = h;
        //return; // better luck next time :)
    }
    else if (!tiny)
        /* fixme: prevent Canon code from drawing over the console (ugly) */
        canon_gui_disable_front_buffer();
    prev_w = w;
    prev_h = h;


    bmp_draw_rect(60, xa, ya, w, h);
    bmp_draw_rect(COLOR_BLACK, xa-1, ya-1, w+2, h+2);

    /* display each line */
    int found_cursor = 0;
    for (int i = skipped_lines; i < CONSOLE_H; i++)
    {
        char buf[CONSOLE_W+1];
        int cbpos = cbpos0 + i * CONSOLE_W;
        for (int j = 0; j < CONSOLE_W; j++)
        {
            // last character should be on last line => this ensures proper scrolling
            if (mod(cbpos+j, BUFSIZE) == mod(console_buffer_index, BUFSIZE)) // end of data
            {
                if (!found_cursor)
                {
                    buf[j] = '_';
                    found_cursor = 1;
                    continue;
                }
            }
            buf[j] = found_cursor ? ' ' : CONSOLE_BUFFER(cbpos+j);
        }
        buf[CONSOLE_W - chopped_columns] = 0;
        int y = yc + fontspec_font(fnt)->height * (i - skipped_lines);
        bmp_printf(fnt, x0, y, buf);
    }
}