// saves the actual active overlay data to a file. void save_edge_overlay(void) { char fn[64]; char msg[64]; FILE *fd; DIR* d; int fnum = 0; int fr = 0; int zoom = 0; struct dirent* de; static struct utimbuf t; // nothing to save? then dont save if( !is_buffer_ready() ) { draw_string(0, 0, "No overlay to save.", user_color(conf.osd_color)); return; } zoom = shooting_get_zoom(); // first figure out the most appropriate filename to use d = opendir(EDGE_SAVE_DIR); if( ! d ) { return; } while( (de = readdir(d)) ) { fr = get_edge_file_num(de->d_name); if( fr > fnum ) { fnum = fr; } } ++fnum; // the highest is set, we use the next one get_viewport_size(); // open the right file sprintf(fn, EDGE_SAVE_DIR "/" EDGE_FILE_FORMAT, fnum ); fd = fopen(fn, "wb"); if(fd !=NULL) { // write the data fwrite(edgebuf->ptr,edgebuf->ptrLen,1,fd); fwrite(&zoom,sizeof(zoom),1,fd); fclose(fd); t.actime = t.modtime = time(NULL); utime(fn, &t); sprintf(msg, "Saved as %s",fn); draw_string(0, 0, msg, user_color(conf.osd_color)); } closedir(d); }
void console_draw(int force_redraw) { char buf[MAX_CONSOLE_LINE_LENGTH+1]; console_ensure_inited(); twoColors col = user_color(conf.osd_color); long t = get_tick_count(); if (t <= console_last_modified + (conf.console_timeout*1000)) // Redraw if changed { if ((console_displayed == 0) || force_redraw) { int y = (console_y + console_max_lines - 1) * FONT_HEIGHT; int x = console_x * FONT_WIDTH + camera_screen.disp_left; int c, i; for (c = 0, i = console_cur_line; c < console_num_lines; ++c, --i) { if (i < 0) i = MAX_CONSOLE_HISTORY-1; strncpy(buf,console_buf[i],console_line_length); buf[console_line_length] = 0; draw_string_justified(x, y - c * FONT_HEIGHT, buf, col, 0, console_line_length * FONT_WIDTH, TEXT_LEFT|TEXT_FILL); console_displayed = 1; } } } else if (console_displayed && !camera_info.state.state_kbd_script_run) // Erase if drawn and script not running { gui_set_need_restore(); console_displayed = 0; } }
//------------------------------------------------------------------- static void gui_console_draw() { if (console_redraw_flag) { twoColors col = user_color(conf.menu_color); int w = MAX_CONSOLE_LINE_LENGTH; int h = MAX_CONSOLE_DISP_LINES; coord x = (camera_screen.width - w * FONT_WIDTH) >> 1; coord y = (camera_screen.height - (h+1) * FONT_HEIGHT) >> 1; draw_rectangle(x-3, y-3, x+w*FONT_WIDTH+3, y+(h+1)*FONT_HEIGHT+2, col, RECT_BORDER1|DRAW_FILLED); // main box draw_rectangle(x-2, y-2, x+w*FONT_WIDTH+2, y+FONT_HEIGHT+1, col, RECT_BORDER1|DRAW_FILLED); //title draw_string_justified(x, y, "Console - press SET to close", col, 0, w*FONT_WIDTH, TEXT_CENTER); //title text y += FONT_HEIGHT + 2; int c, i; for (c = h-1, i = console_cur_line-console_scroll; c >= 0; --c, --i) { if (i < 0) i += MAX_CONSOLE_HISTORY; draw_string_justified(x-1, y + c * FONT_HEIGHT, console_buf[i], col, 0, w * FONT_WIDTH, TEXT_LEFT|TEXT_FILL); } // Scrollbar draw_rectangle(x+w*FONT_WIDTH, y+((MAX_CONSOLE_HISTORY-console_scroll-h)*(h*FONT_HEIGHT))/MAX_CONSOLE_HISTORY, x+w*FONT_WIDTH+2, y+((MAX_CONSOLE_HISTORY-console_scroll)*(h*FONT_HEIGHT))/MAX_CONSOLE_HISTORY-1, MAKE_COLOR(COLOR_RED, COLOR_RED), RECT_BORDER0|DRAW_FILLED); console_redraw_flag = 0; } }
static void gui_print_osd_misc_string() { sprintf(osd_buf+strlen(osd_buf), "%9s", ""); osd_buf[9]=0; // limit length to 9 max draw_osd_string(conf.values_pos, 0, m, osd_buf, user_color(conf.osd_color), conf.values_scale); m+=FONT_HEIGHT; }
//------------------------------------------------------------------- void gui_osd_draw_raw_info(int is_osd_edit) { if (is_osd_edit || (conf.save_raw && conf.show_raw_state && !camera_info.state.mode_video && !camera_info.state.is_shutter_half_press && camera_info.state.mode_rec_or_review ) ) { static int b; if (is_raw_enabled() || is_osd_edit) { int raw_count = GetRawCount(); twoColors col = user_color(((raw_count > conf.remaining_raw_treshold) || (b <= 6)) ? conf.osd_color : conf.osd_color_warn); if (conf.show_remaining_raw || is_osd_edit) { sprintf(osd_buf, "%s:%3d", (conf.dng_raw)?"DNG":"RAW", raw_count); draw_osd_string(conf.mode_raw_pos, 0, 0, osd_buf, col, conf.mode_raw_scale); } else draw_osd_string(conf.mode_raw_pos, 0, 0, (conf.dng_raw)?"DNG":"RAW", col, conf.mode_raw_scale); if (++b > 12) b = 0; } else if (conf.raw_exceptions_warn) { gui_print_osd_state_string_chr((conf.dng_raw)?"DNG Disabled":"RAW Disabled",""); } } }
//------------------------------------------------------------------- static void draw_temp(char *lbl, int val, int yofst) { if (conf.temperature_unit != 0) val = (val*18+320)/10; sprintf(osd_buf,"%s: %i\xb0",lbl, val); draw_osd_string(conf.temp_pos, 0, yofst*FONT_HEIGHT, osd_buf, user_color(conf.osd_color), conf.temp_scale); }
//------------------------------------------------------------------- void gui_osd_draw_ev_video(int is_osd_edit) { #if CAM_EV_IN_VIDEO if (!is_video_recording() && !is_osd_edit) return; int visible = get_ev_video_avail() || is_osd_edit; int x0=conf.ev_video_pos.x, y0=conf.ev_video_pos.y; int i, deltax; twoColors col = user_color(conf.osd_color); draw_rectangle(x0,y0,x0+70,y0+24, visible? MAKE_COLOR(BG_COLOR(col),BG_COLOR(col)): COLOR_TRANSPARENT, RECT_BORDER1|DRAW_FILLED); if (!visible) { return; } for (i=0;i<9;i++) draw_line(x0+2+i*8, y0+12, x0+2+i*8, y0+12-(i&1 ? 5 : 10), col); for (i=0;i<9;i++) draw_line(x0+2+i*8+1, y0+12, x0+2+i*8+1, y0+12-(i&1 ? 5 : 10), col); deltax=8*get_ev_video(); x0+=deltax; draw_line(x0+34,y0+16,x0+34,y0+22,col); draw_line(x0+35,y0+16,x0+35,y0+22,col); draw_line(x0+32,y0+19,x0+32,y0+22,col); draw_line(x0+33,y0+18,x0+33,y0+22,col); draw_line(x0+36,y0+18,x0+36,y0+22,col); draw_line(x0+37,y0+19,x0+37,y0+22,col); #endif }
user_info::user_info( us::user_info_ptr p, us::user_service_ptr s, QPushButton* action, bool enable_double_click) : _contact{p}, _service{s}, _action{action} { REQUIRE(p); REQUIRE(s); auto* layout = new QGridLayout{this}; setLayout(layout); auto version = s->check_contact_version(p->id()); _user_text = new user_label{p->name().c_str(), enable_double_click, action}; _user_text->setToolTip( user_tooltip(p, determine_state(_removed, s, p), version).c_str()); _text_color = QColor{0, 0, 0, 0}; layout->addWidget(_user_text, 0,0); if(_action) layout->addWidget(_action, 0,1); layout->setContentsMargins(2,2,2,2); set_text_color_to(user_color(_contact, determine_state(_removed, s, p), version)); ENSURE(_contact); ENSURE(_user_text); }
static void gui_print_osd_state_string() { sprintf(osd_buf+strlen(osd_buf), "%12s", ""); osd_buf[12]=0; // limit length to 12 max draw_osd_string(conf.mode_state_pos, 0, n, osd_buf, user_color(conf.osd_color_override), conf.mode_state_scale); n+=FONT_HEIGHT; }
static void gui_osd_draw_single_histo(int hist, coord x, coord y, int small) { twoColors hc = user_color(conf.histo_color); twoColors hc2 = user_color(conf.histo_color2); register unsigned int i, v, threshold; register color cl, cl_over, cl_bg = BG_COLOR(hc); coord w=HISTO_WIDTH, h=HISTO_HEIGHT; switch (hist) { case HISTO_R: cl=COLOR_RED; break; case HISTO_G: cl=COLOR_GREEN; break; case HISTO_B: cl=COLOR_BLUE; break; case HISTO_RGB: case HISTO_Y: default: cl=FG_COLOR(hc); break; } if (small) { h>>=1; w>>=1; for (i=0; i<w; ++i) { threshold = (histogram[hist][i<<1]+histogram[hist][(i<<1)+1])>>2; for (v=1; v<h-1; ++v) draw_pixel(x+1+i, y+h-v, (v<=threshold)?cl:cl_bg); cl_over = (threshold==h && conf.show_overexp)?BG_COLOR(hc2):cl; for (; v<h; ++v) draw_pixel(x+1+i, y+h-v, (v<=threshold)?cl_over:cl_bg); } } else { for (i=0; i<w; ++i) {
void gui_osd_draw_clock(int x, int y, twoColors cl, int is_osd_edit) { if (conf.show_clock || is_osd_edit) { static char *ampm[2][3] = { { " AM", "A", " "}, { " PM", "P", "." } }; struct tm *ttm = get_localtime(); int w = 0; // Extra width from AM/PM indicator and seconds (if displayed) if ((FG_COLOR(cl) == 0) && (BG_COLOR(cl) == 0)) cl = user_color(conf.osd_color); if ((camera_info.state.is_shutter_half_press == 0) || (conf.clock_halfpress == 0) || is_osd_edit) { unsigned int hour = (ttm->tm_hour); char *ampm_ind = ""; // AM / PM indicator if (conf.clock_format == CLOCK_FORMAT_12) { ampm_ind = ampm[hour/12][conf.clock_indicator]; //(hour >= 12) ? pm : am; w = strlen(ampm_ind); if (hour == 0) hour = 12; else if (hour > 12) hour = hour - 12; } if ((conf.show_clock != CLOCK_WITHOUT_SEC) || is_osd_edit) { sprintf(osd_buf, "%2u:%02u:%02u%s", hour, ttm->tm_min, ttm->tm_sec, ampm_ind); w += 3; } else { sprintf(osd_buf, "%2u:%02u%s", hour, ttm->tm_min, ampm_ind); } if (x) // for gui_4wins.c draw_string(x, y, osd_buf, cl); else draw_osd_string(conf.clock_pos, 0, 0, osd_buf, cl, conf.clock_scale); } else if (camera_info.state.is_shutter_half_press && (conf.clock_halfpress == 1)) { sprintf(osd_buf, "%02u", ttm->tm_sec); if (conf.clock_pos.x >= 4*FONT_WIDTH) w = 3; draw_osd_string(conf.clock_pos, w*FONT_WIDTH, 0, osd_buf, cl, conf.clock_scale); } } }
void user_info::update(std::function<bool(us::user_info&)> f, bool update_action) { INVARIANT(_service); INVARIANT(_contact); INVARIANT(_user_text); bool online = is_online(_contact, _service , !f(*_contact)); auto version = _service->check_contact_version(_contact->id()); _user_text->setText(_contact->name().c_str()); _user_text->setToolTip( user_tooltip(_contact, determine_state(_removed, _service, _contact), version).c_str()); set_text_color_to( user_color(_contact, determine_state(_removed, _service, _contact), version)); if(_action && update_action) _action->setVisible(!_removed && online); }
void gui_osd_draw_ev(int is_osd_edit) { static char *s[6] = {" ", "1/6", "1/3", "1/2", "2/3", "5/6"}; if ((!camera_info.state.mode_video && camera_info.state.mode_rec && conf.fast_ev) || is_osd_edit) { short ev = shooting_get_ev_correction1(); if (ev/96 || (ev==0)) sprintf(osd_buf, "EV: %d %s", abs(ev/96), s[abs(ev/16%6)]); else sprintf(osd_buf, "EV: %s ", s[abs(ev/16%6)]); if (ev>0) osd_buf[4]='+'; else if (ev<0) osd_buf[4]='-'; draw_osd_string(conf.mode_ev_pos, 0, 0, osd_buf, user_color(conf.osd_color), conf.mode_ev_scale); } }
static void gui_print_osd_dof_string_dist(const char * title, int value, short use_good_color, short is_hyp) { strcpy(osd_buf, title); int i=strlen(osd_buf); twoColors col = user_color(conf.osd_color); twoColors valid_col = MAKE_COLOR(BG_COLOR(col), COLOR_GREEN); if (i<8) { draw_osd_string(conf.values_pos, 0, m, osd_buf, col, conf.values_scale); if (is_hyp) { sprintf_dist_hyp(osd_buf, value); } else { sprintf_dist(osd_buf, value); } sprintf(osd_buf+strlen(osd_buf), "%9s", ""); osd_buf[9-i]=0; draw_osd_string(conf.values_pos, i*FONT_WIDTH, m, osd_buf, use_good_color?valid_col:col, conf.values_scale); } else { osd_buf[9]=0; draw_osd_string(conf.values_pos, 0, m, osd_buf, col,conf.values_scale); } m+=FONT_HEIGHT; }
void gui_osd_draw_dof(int is_osd_edit) { if (conf.show_dof != DOF_DONT_SHOW) shooting_update_dof_values(); if (is_osd_edit || (camera_info.state.mode_rec_or_review && ((conf.show_dof == DOF_SHOW_IN_DOF) || (conf.show_dof == DOF_SHOW_IN_DOF_EX)) && (((camera_info.state.is_shutter_half_press || camera_info.state.state_kbd_script_run || shooting_get_common_focus_mode()) && (camera_info.state.mode_photo || camera_info.state.mode_shooting==MODE_STITCH)) || ((camera_info.state.mode_video || is_video_recording()) && conf.show_values_in_video)))) { twoColors col = user_color(conf.osd_color); twoColors valid_col = MAKE_COLOR(BG_COLOR(col), COLOR_GREEN); int i = 8, j; short f_ex = (conf.show_dof==DOF_SHOW_IN_DOF_EX); draw_osd_string(conf.dof_pos, 0, 0, "S/NL/FL:", col, conf.dof_scale); sprintf_dist(osd_buf, camera_info.dof_values.subject_distance); j = strlen(osd_buf); draw_osd_string(conf.dof_pos, i*FONT_WIDTH, 0, osd_buf, (f_ex && (camera_info.dof_values.distance_valid || shooting_get_focus_mode()))?valid_col:col, conf.dof_scale); i = i+j; draw_osd_string(conf.dof_pos, i*FONT_WIDTH, 0, "/", col, conf.dof_scale); sprintf_dist(osd_buf, camera_info.dof_values.near_limit); j = strlen(osd_buf); draw_osd_string(conf.dof_pos, (++i)*FONT_WIDTH, 0, osd_buf, (f_ex && camera_info.dof_values.distance_valid)?valid_col:col, conf.dof_scale); i = i+j; draw_osd_string(conf.dof_pos, i*FONT_WIDTH, 0, "/", col, conf.dof_scale); sprintf_dist(osd_buf, camera_info.dof_values.far_limit); draw_osd_string(conf.dof_pos, (++i)*FONT_WIDTH, 0, osd_buf, (f_ex && camera_info.dof_values.distance_valid)?valid_col:col, conf.dof_scale); i = 8; draw_osd_string(conf.dof_pos, 0, FONT_HEIGHT, "DOF/HYP:", col, conf.dof_scale); sprintf_dist(osd_buf, camera_info.dof_values.depth_of_field); j = strlen(osd_buf); draw_osd_string(conf.dof_pos, i*FONT_WIDTH, FONT_HEIGHT, osd_buf, (f_ex && camera_info.dof_values.distance_valid)?valid_col:col, conf.dof_scale); i = i+j; draw_osd_string(conf.dof_pos, i*FONT_WIDTH, FONT_HEIGHT, "/", col, conf.dof_scale); sprintf_dist_hyp(osd_buf, camera_info.dof_values.hyperfocal_distance); draw_osd_string(conf.dof_pos, (++i)*FONT_WIDTH, FONT_HEIGHT, osd_buf, (f_ex && camera_info.dof_values.hyperfocal_valid)?valid_col:col, conf.dof_scale); } }
void handle(char * line) { char * c = line; while (c < line + strlen(line)) { char * e = strstr(c, "\r\n"); if (e > line + strlen(line)) { break; } if (!e) { WRITE(c); goto next; } *e = '\0'; if (strstr(c, "PING") == c) { char tmp[100]; char * t = strstr(c, ":"); fprintf(sock, "PONG %s\r\n", t); fflush(sock); goto next; } char * user; char * command; char * channel; char * message; user = c; if (user[0] == ':') { user++; } command = strstr(user, " "); if (!command) { WRITE("%s\n", user); goto next; } command[0] = '\0'; command++; channel = strstr(command, " "); if (!channel) { WRITE("%s %s\n", user, command); goto next; } channel[0] = '\0'; channel++; message = strstr(channel, " "); if (message) { message[0] = '\0'; message++; if (message[0] == ':') { message++; } } int hr, min, sec; get_time(&hr, &min, &sec); if (!strcmp(command, "PRIVMSG")) { if (!message) continue; char * t = strstr(user, "!"); if (t) { t[0] = '\0'; } t = strstr(user, "@"); if (t) { t[0] = '\0'; } if (strstr(message, "\001ACTION ") == message) { message = message + 8; char * x = strstr(message, "\001"); if (x) *x = '\0'; WRITE(TIME_FMT " * %d%s %s\n", TIME_ARGS, user_color(user), user, message); } else { WRITE(TIME_FMT " 14<%d%s14> %s\n", TIME_ARGS, user_color(user), user, message); } } else if (!strcmp(command, "332")) { if (!message) { continue; } spin_lock(&c_lock); wmove(topic_win, 0, 0); wprintw(topic_win, " %s", message); wrefresh(topic_win); spin_unlock(&c_lock); } else if (!strcmp(command, "JOIN")) { char * t = strstr(user, "!"); if (t) { t[0] = '\0'; } t = strstr(user, "@"); if (t) { t[0] = '\0'; } if (channel[0] == ':') { channel++; } WRITE(TIME_FMT " 12-!12-11 %s has joined %s\n", TIME_ARGS, user, channel); } else if (!strcmp(command, "PART")) { char * t = strstr(user, "!"); if (t) { t[0] = '\0'; } t = strstr(user, "@"); if (t) { t[0] = '\0'; } if (channel[0] == ':') { channel++; } WRITE(TIME_FMT " 12-!12-10 %s has left %s\n", TIME_ARGS, user, channel); } else if (!strcmp(command,"372")) { WRITE(TIME_FMT " 14%s %s\n", TIME_ARGS, user, message ? message : ""); } else if (!strcmp(command,"376")) { WRITE(TIME_FMT " 14%s (end of MOTD)\n", TIME_ARGS, user); } else { WRITE(TIME_FMT " 10%s %s %s %s\n", TIME_ARGS, user, command, channel, message ? message : ""); } next: if (!e) break; c = e + 2; } }
//------------------------------------------------------------------- // Draw menu scroll bar if needed, and title bar static void gui_draw_initial() { count = gui_menu_disp_rows(); if (count > num_lines) { y = ((camera_screen.height-(num_lines-1)*rbf_font_height())>>1); wplus = 8; // scrollbar background draw_rectangle((x+w), y, (x+w)+wplus, y+num_lines*rbf_font_height()-1, MAKE_COLOR(BG_COLOR(user_color(conf.menu_color)), BG_COLOR(user_color(conf.menu_color))), RECT_BORDER0|DRAW_FILLED); }
static void gui_osd_draw_movie_time_left() { static int card_used, init_space, elapsed, avg_use, time_left; static long init_time; static int record_running = 0; static int init = 0; static unsigned int skipcalls = 1; unsigned int hour=0, min=0, sec=0; twoColors col = user_color(conf.osd_color); if ((conf.show_movie_time > 0) && (camera_info.state.mode_video || is_video_recording()) && !camera_info.state.mode_play) { #if CAM_CHDK_HAS_EXT_VIDEO_MENU if (camera_info.state.mode_video || is_video_recording()) { // if manual adjust, show the field item to be adjusted // if any value overriden, show the override value #if !CAM_VIDEO_QUALITY_ONLY if ((conf.video_mode == 0 && conf.fast_movie_quality_control==1) || conf.video_bitrate != VIDEO_DEFAULT_BITRATE) { // gui_print_osd_state_string_chr("Bitrate: ",video_bitrate_strings[conf.video_bitrate]); sprintf(osd_buf, "Bit:%5s",gui_video_bitrate_enum(0,0)); draw_osd_string(conf.mode_video_pos, 0, 2*FONT_HEIGHT, osd_buf, col, conf.mode_video_scale); } #endif if ((conf.video_mode == 1 && conf.fast_movie_quality_control==1) || conf.video_quality != VIDEO_DEFAULT_QUALITY) { // gui_print_osd_state_string_int("Quality: ",conf.video_quality); sprintf(osd_buf, "Qual:%2i",conf.video_quality); draw_osd_string(conf.mode_video_pos, 0, 3*FONT_HEIGHT, osd_buf, col, conf.mode_video_scale); } // everything else is for when recording if (!is_video_recording()) { record_running = 0; init = 0; return; } } #endif if (movie_reset == 1) { init = 0; movie_reset = 0; } if (is_video_recording()) record_running = 1; else { record_running = 0; init = 0; } if (record_running == 1 && init == 0) { init = 1; init_space = GetFreeCardSpaceKb(); init_time = get_tick_count(); } if (init == 1) { card_used = init_space - GetFreeCardSpaceKb(); elapsed = (int) ( get_tick_count() - init_time ) / 1000; avg_use = card_used / elapsed; // running average Kb/sec time_left = (GetFreeCardSpaceKb() / avg_use); hour = time_left / 3600; min = (time_left % 3600) / 60; sec = (time_left % 3600) % 60; if (elapsed < 1) { sprintf(osd_buf, "Calc..."); draw_osd_string(conf.mode_video_pos, 0, 0, osd_buf, col, conf.mode_video_scale); } if (--skipcalls ==0) { if (elapsed > 1) { int time_yofst = 0; if (conf.show_movie_time == 3) { // Both lines displayed so offset time value below bit rate time_yofst = FONT_HEIGHT; } if (conf.show_movie_time & 2) { sprintf(osd_buf, "%04d KB/s", avg_use); draw_osd_string(conf.mode_video_pos, 0, 0, osd_buf, col, conf.mode_video_scale); } if (conf.show_movie_time & 1) { sprintf(osd_buf, "-%02d:%02d:%02d", hour, min, sec); draw_osd_string(conf.mode_video_pos, 0, time_yofst, osd_buf, col, conf.mode_video_scale); } #if CAM_CHDK_HAS_EXT_VIDEO_TIME if( (int)conf.ext_video_time == 1 ) { draw_txt_string(0, 13, lang_str(LANG_WARN_VIDEO_EXT_TIME), user_color(conf.osd_color_warn)); } #endif } skipcalls = conf.show_movie_refresh*5; } } } }
//------------------------------------------------------------------- void gui_read_draw(int force_redraw) { if (do_not_draw) return; busy_drawing = 1; twoColors col = user_color(conf.reader_color); static int first_draw = 1; if (first_draw || force_redraw) { if (first_draw) { // font has to be loaded from here (SpyTask) rbf_load_from_file(conf.reader_rbf_file, conf.reader_codepage); } draw_rectangle(camera_screen.disp_left, 0, camera_screen.disp_right, y-1, MAKE_COLOR(COLOR_BLACK, COLOR_BLACK), RECT_BORDER0|DRAW_FILLED); draw_rectangle(camera_screen.disp_left, y, camera_screen.disp_right, camera_screen.height-1, MAKE_COLOR(BG_COLOR(col), BG_COLOR(col)), RECT_BORDER0|DRAW_FILLED); gui_read_draw_scroll_indicator(); read_to_draw = 1; first_draw = 0; } if (conf.reader_autoscroll && !pause && get_tick_count()-last_time >= conf.reader_autoscroll_delay*1000 && (conf.reader_pos+read_on_screen)<read_file_size) { conf.reader_pos += read_on_screen; read_to_draw = 1; } if (read_to_draw) { int n, m, i, ii, ll, new_word=1; xx=x; yy=y; lseek(read_file, conf.reader_pos, SEEK_SET); read_on_screen=0; while (yy<=y+h-rbf_font_height()) { n=read(read_file, buffer, READ_BUFFER_SIZE); if (n==0) { read_goto_next_line(); if (yy < y+h) draw_rectangle(x, yy, x+w-1, y+h-1, MAKE_COLOR(BG_COLOR(col), BG_COLOR(col)), RECT_BORDER0|DRAW_FILLED); break; } else if (n<0) { // read failed do_not_draw = 1; busy_drawing = 0; return; } i=0; while (i<n && yy<=y+h-rbf_font_height()) { switch (buffer[i]) { case '\r': new_word = 1; break; case '\n': read_goto_next_line(); new_word = 1; break; case '\t': buffer[i] = ' '; // no break here default: if (conf.reader_wrap_by_words) { if (buffer[i] == ' ') { new_word = 1; if (xx==x) //ignore leading spaces break; } else if (new_word) { new_word = 0; for (ii=i, ll=0; ii<n && buffer[ii]!=' ' && buffer[ii]!='\t' && buffer[ii]!='\r' && buffer[ii]!='\n'; ++ii) { ll+=rbf_char_width(buffer[ii]); } if (ii==n) { memcpy(buffer, buffer+i, n-i); n=ii=n-i; read_on_screen+=i; i=0; m=read(read_file, buffer+n, READ_BUFFER_SIZE-n); if (m<0) { // read failed do_not_draw = 1; busy_drawing = 0; return; } n+=m; for (; ii<n && buffer[ii]!=' ' && buffer[ii]!='\t' && buffer[ii]!='\r' && buffer[ii]!='\n'; ++ii) { ll+=rbf_char_width(buffer[ii]); } } if (xx+ll>=x+w && ll<w) { read_goto_next_line(); continue; } } } if (!read_fit_next_char(buffer[i])) { read_goto_next_line(); continue; } xx+=rbf_draw_char(xx, yy, buffer[i], col); break; } ++i; if (xx >= x+w) { xx = x; yy += rbf_font_height(); } } read_on_screen+=i; } sprintf(buffer, "(%3d%%) %d/%d", (read_file_size)?(conf.reader_pos*100/read_file_size):0, conf.reader_pos, read_file_size); draw_string_justified(camera_screen.disp_left, 0, buffer, MAKE_COLOR(COLOR_BLACK, COLOR_WHITE), 0, 20*FONT_WIDTH, TEXT_LEFT|TEXT_FILL); //title infoline // scrollbar if (read_file_size) { i=h-1 -1; // full height n=i*read_on_screen/read_file_size; // bar height if (n<20) n=20; i=(i-n)*conf.reader_pos/read_file_size; // top pos draw_rectangle(x+w+6+2, y+1, x+w+6+6, y+1+i, MAKE_COLOR(COLOR_BLACK, COLOR_BLACK), RECT_BORDER0|DRAW_FILLED); draw_rectangle(x+w+6+2, y+i+n, x+w+6+6, y+h-1-1, MAKE_COLOR(COLOR_BLACK, COLOR_BLACK), RECT_BORDER0|DRAW_FILLED); draw_rectangle(x+w+6+2, y+1+i, x+w+6+6, y+i+n, MAKE_COLOR(COLOR_WHITE, COLOR_WHITE), RECT_BORDER0|DRAW_FILLED); } else { draw_rectangle((x+w)*FONT_WIDTH+2, y*FONT_HEIGHT+1, (x+w)*FONT_WIDTH+6, (y+h)*FONT_HEIGHT-1-1, MAKE_COLOR(COLOR_BLACK, COLOR_BLACK), RECT_BORDER0|DRAW_FILLED); } read_to_draw = 0; last_time = get_tick_count(); } gui_read_draw_batt(); gui_read_draw_clock(); busy_drawing = 0; }
//------------------------------------------------------------------- static void read_goto_next_line() { twoColors col = user_color(conf.reader_color); draw_rectangle(xx, yy, x+w-1, yy+rbf_font_height()-1, MAKE_COLOR(BG_COLOR(col), BG_COLOR(col)), RECT_BORDER0|DRAW_FILLED); xx = x; yy += rbf_font_height(); }
void core_spytask() { int cnt = 1; int i=0; #ifdef CAM_HAS_GPS int gps_delay_timer = 200 ; int gps_state = -1 ; #endif #if (OPT_DISABLE_CAM_ERROR) extern void DisableCamError(); int dce_cnt=0; int dce_prevmode=0; int dce_nowmode; #endif parse_version(&chdk_version, BUILD_NUMBER, BUILD_SVNREV); // Init camera_info bits that can't be done statically camera_info_init(); spytask_can_start=0; extern void aram_malloc_init(void); aram_malloc_init(); extern void exmem_malloc_init(void); exmem_malloc_init(); #ifdef CAM_CHDK_PTP extern void init_chdk_ptp_task(); init_chdk_ptp_task(); #endif while((i++<400) && !spytask_can_start) msleep(10); started(); msleep(50); finished(); #if !CAM_DRYOS drv_self_unhide(); #endif conf_restore(); extern void gui_init(); gui_init(); #if CAM_CONSOLE_LOG_ENABLED extern void cam_console_init(); cam_console_init(); #endif static char *chdk_dirs[] = { "A/CHDK", "A/CHDK/FONTS", "A/CHDK/SYMBOLS", "A/CHDK/SCRIPTS", "A/CHDK/LANG", "A/CHDK/BOOKS", "A/CHDK/MODULES", "A/CHDK/MODULES/CFG", "A/CHDK/GRIDS", "A/CHDK/CURVES", "A/CHDK/DATA", "A/CHDK/LOGS", "A/CHDK/EDGE", }; for (i = 0; i < sizeof(chdk_dirs) / sizeof(char*); i++) mkdir_if_not_exist(chdk_dirs[i]); no_modules_flag = stat("A/CHDK/MODULES/FSELECT.FLT",0) ? 1 : 0 ; // Calculate the value of get_tick_count() when the clock ticks over to the next second // Used to calculate the SubSecondTime value when saving DNG files. long t1, t2; t2 = time(0); do { t1 = t2; camera_info.tick_count_offset = get_tick_count(); t2 = time(0); msleep(10); } while (t1 != t2); camera_info.tick_count_offset = camera_info.tick_count_offset % 1000; // remote autostart if (conf.script_startup==SCRIPT_AUTOSTART_ALWAYS) { script_autostart(); } else if (conf.script_startup==SCRIPT_AUTOSTART_ONCE) { conf.script_startup=SCRIPT_AUTOSTART_NONE; conf_save(); script_autostart(); } shooting_init(); while (1) { // Set up camera mode & state variables mode_get(); // update HDMI power override based on mode and remote settings #ifdef CAM_REMOTE_HDMI_POWER_OVERRIDE extern void update_hdmi_power_override(void); update_hdmi_power_override(); #endif extern void set_palette(); set_palette(); #if (OPT_DISABLE_CAM_ERROR) dce_nowmode = camera_info.state.mode_play; if (dce_prevmode==dce_nowmode) { //no mode change dce_cnt++; // overflow is not a concern here } else { //mode has changed dce_cnt=0; } if (dce_cnt==100) { // 1..2s past play <-> rec mode change DisableCamError(); } dce_prevmode=dce_nowmode; #endif if ( memdmptick && (get_tick_count() >= memdmptick) ) { memdmptick = 0; dump_memory(); } #ifdef CAM_HAS_GPS if ( --gps_delay_timer == 0 ) { gps_delay_timer = 50 ; if ( gps_state != (int)conf.gps_on_off ) { gps_state = (int)conf.gps_on_off ; init_gps_startup(!gps_state) ; } } #endif // Change ALT mode if the KBD task has flagged a state change gui_activate_alt_mode(); #ifdef CAM_LOAD_CUSTOM_COLORS // Color palette function extern void load_chdk_palette(); load_chdk_palette(); #endif if (raw_data_available) { raw_process(); extern void hook_raw_save_complete(); hook_raw_save_complete(); raw_data_available = 0; #ifdef CAM_HAS_GPS if (((int)conf.gps_on_off == 1) && ((int)conf.gps_waypoint_save == 1)) gps_waypoint(); #endif #if defined(CAM_CALC_BLACK_LEVEL) // Reset to default in case used by non-RAW process code (e.g. raw merge) camera_sensor.black_level = CAM_BLACK_LEVEL; #endif continue; } if ((camera_info.state.state_shooting_progress != SHOOTING_PROGRESS_PROCESSING) || recreview_hold) { if (((cnt++) & 3) == 0) gui_redraw(); } if (camera_info.state.state_shooting_progress != SHOOTING_PROGRESS_PROCESSING) { if (conf.show_histo) libhisto->histogram_process(); if ((camera_info.state.gui_mode_none || camera_info.state.gui_mode_alt) && conf.edge_overlay_thresh && conf.edge_overlay_enable) { // We need to skip first tick because stability if (chdk_started_flag) { libedgeovr->edge_overlay(); } } } if ((camera_info.state.state_shooting_progress == SHOOTING_PROGRESS_PROCESSING) && (!shooting_in_progress())) { camera_info.state.state_shooting_progress = SHOOTING_PROGRESS_DONE; } i = 0; #ifdef DEBUG_PRINT_TO_LCD sprintf(osd_buf, "%d", cnt ); // modify cnt to what you want to display draw_txt_string(1, i++, osd_buf, user_color(conf.osd_color)); #endif #if defined(OPT_FILEIO_STATS) sprintf(osd_buf, "%3d %3d %3d %3d %3d %3d %3d %4d", camera_info.fileio_stats.fileio_semaphore_errors, camera_info.fileio_stats.close_badfile_count, camera_info.fileio_stats.write_badfile_count, camera_info.fileio_stats.open_count, camera_info.fileio_stats.close_count, camera_info.fileio_stats.open_fail_count, camera_info.fileio_stats.close_fail_count, camera_info.fileio_stats.max_semaphore_timeout); draw_txt_string(1, i++, osd_buf,user_color( conf.osd_color)); #endif if (camera_info.perf.md_af_tuning) { sprintf(osd_buf, "MD last %-4d min %-4d max %-4d avg %-4d", camera_info.perf.af_led.last, camera_info.perf.af_led.min, camera_info.perf.af_led.max, (camera_info.perf.af_led.count>0)?camera_info.perf.af_led.sum/camera_info.perf.af_led.count:0); draw_txt_string(1, i++, osd_buf, user_color(conf.osd_color)); } // Process async module unload requests module_tick_unloader(); msleep(20); chdk_started_flag=1; } }
static int draw_edge_overlay() { int shutter_fullpress = kbd_is_key_pressed(KEY_SHOOT_FULL); int x, y; int x_off, y_off; const color cl = FG_COLOR(user_color(conf.edge_overlay_color)); const int y_slice_min = camera_screen.edge_hmargin+ slice *slice_height; const int y_slice_max = camera_screen.edge_hmargin+(slice+1)*slice_height; const int y_min = camera_screen.edge_hmargin; const int y_max = camera_screen.edge_hmargin+viewport_height; const int x_min = 2; const int x_max = (viewport_width - 2); if( !is_buffer_ready() ) return 0; for (y = y_slice_min; y < y_slice_max; ++y) { y_off = y + yoffset; shutter_fullpress |= kbd_is_key_pressed(KEY_SHOOT_FULL); if ((unsigned)(y_off-y_min) < (y_max-y_min)) // is the same as ((y_off > y_min) && (y_off < y_max)) // do not draw outside of allowed area { const int y_edgebuf = (y-y_min) * viewport_width; for (x = x_min; x < x_max; ++x) { x_off = x + xoffset; if ((unsigned)(x_off-x_min) < (x_max-x_min)) // is the same as ((x_off > x_min) && (x_off < x_max)) // do not draw outside of allowed area { // Draw a pixel to the screen wherever we detected an edge. // If there is no edge based on the newest data, but there is one painted on the screen // from previous calls, delete it from the screen. const int bEdge = bv_get(edgebuf, y_edgebuf + x); const int bDraw = bEdge || (draw_get_pixel_unrotated(x_off+viewport_xoffset, y_off+viewport_yoffset) == cl); if (bEdge || bDraw) draw_pixel_unrotated(x_off+viewport_xoffset, y_off+viewport_yoffset, bEdge ? cl : 0); } } // for x } } // for y // Drawing the overlay is over. // But as a finishing touch we clear up garbage on the screen // by clearing those parts that the overlay has left. if (xoffset != 0) { // Cleans up leftover from horizontal motion const int x_min_c = (xoffset < 0) ? x_max + xoffset : x_min; const int x_max_c = (xoffset > 0) ? x_min + xoffset : x_max; for (y = y_min; y < y_max; ++y) { for (x = x_min_c; x < x_max_c; ++x) { // if there is an edge drawn on the screen but there is no edge there based on the newest data, delete it from the screen if (draw_get_pixel_unrotated(x+viewport_xoffset, y+viewport_yoffset) == cl) draw_pixel_unrotated(x+viewport_xoffset, y+viewport_yoffset, 0 ); } } } if (yoffset != 0) { // Cleans up leftover from vertical motion const int y_min_c = (yoffset < 0) ? y_max + yoffset : y_min; const int y_max_c = (yoffset > 0) ? y_min + yoffset : y_max; for (y = y_min_c; y < y_max_c; ++y) { for (x = x_min; x < x_max; ++x) { // if there is an edge drawn on the screen but there is no edge there based on the newest data, delete it from the screen if (draw_get_pixel_unrotated(x+viewport_xoffset, y+viewport_yoffset) == cl) draw_pixel_unrotated(x+viewport_xoffset, y+viewport_yoffset, 0 ); } } } return shutter_fullpress; }