static size_t write_data(void *ptr, size_t size, size_t nmemb, void *stream) { int written = fwrite(ptr, size, nmemb, (FILE *)stream); static char* last_showd=NULL; char* w=q("\r"); last_showd=last_showd?last_showd:q(""); count+=written*size; if(download_opt&&content_length) { int i,len=width*count/content_length-width*(count-written*size)/content_length; s(w); for(i=0;i<len;++i) fprintf(c_out,"#"),fflush(c_out); return written; } if(content_length) { int i; for(i=0;i<width;++i) w=s_cat2(w,q((i>=(count/(content_length/(width)))?" ":"#"))); w=s_cat2(w,qsprintf(8," %3d%%",(100*(count/100))/(content_length/100))); }else { int current,aux; aux=1024>count?' ':1024*1024>count?(current=count/1024,'K'): 1024*1024*1024>count?(current=count/(1024*1024),'M'):(current=count/(1024*1024*1024),'G'); w=s_cat2(w,qsprintf(20,"%4d%c downloaded.",current,aux)); } if(strcmp(w,last_showd)){ if(!(download_opt&1)) fprintf(c_out, "%s", w),fflush(c_out); s(last_showd),last_showd=q(w); } s(w);return written; }
void idle_tick() { qsprintf("\r\n idle tick : %d/s, adc: %d/s\r\n", st_hw.idle, st_hw.adc_pd); }