neutrino: avoid float for percent calculations

This commit is contained in:
Stefan Seyfried
2011-12-25 23:19:54 +01:00
parent 37c5f7c7d3
commit fb6633b7aa
5 changed files with 10 additions and 10 deletions

View File

@@ -888,7 +888,7 @@ void CLCD::showAudioProgress(const char perc, bool isMuted)
if (mode == MODE_AUDIO) if (mode == MODE_AUDIO)
{ {
display.draw_fill_rect (11,53,73,61, CLCDDisplay::PIXEL_OFF); display.draw_fill_rect (11,53,73,61, CLCDDisplay::PIXEL_OFF);
int dp = int( perc/100.0*61.0+12.0); int dp = perc * 61 / 100 + 12;
display.draw_fill_rect (11,54,dp,60, CLCDDisplay::PIXEL_ON); display.draw_fill_rect (11,54,dp,60, CLCDDisplay::PIXEL_ON);
if(isMuted) if(isMuted)
{ {

View File

@@ -336,7 +336,7 @@ void CVFD::showVolume(const char vol, const bool /*perform_update*/)
ShowIcon(VFD_ICON_FRAME, true); ShowIcon(VFD_ICON_FRAME, true);
if ((mode == MODE_TVRADIO) && g_settings.lcd_setting[SNeutrinoSettings::LCD_SHOW_VOLUME]) { if ((mode == MODE_TVRADIO) && g_settings.lcd_setting[SNeutrinoSettings::LCD_SHOW_VOLUME]) {
int pp = (int) round((double) vol * (double) 8 / (double) 100); int pp = (vol * 8 + 50) / 100;
if(pp > 8) pp = 8; if(pp > 8) pp = 8;
if(oldpp != pp) { if(oldpp != pp) {
@@ -368,7 +368,7 @@ void CVFD::showPercentOver(const unsigned char perc, const bool /*perform_update
if(perc == 255) if(perc == 255)
pp = 0; pp = 0;
else else
pp = (int) round((double) perc * (double) 8 / (double) 100); pp = (perc * 8 + 50) / 100;
//printf("CVFD::showPercentOver: %d, bar %d\n", (int) perc, pp); //printf("CVFD::showPercentOver: %d, bar %d\n", (int) perc, pp);
if(pp > 8) pp = 8; if(pp > 8) pp = 8;
if(pp != percentOver) { if(pp != percentOver) {

View File

@@ -2193,7 +2193,7 @@ void CInfoViewer::showLcdPercentOver ()
if (jetzt < info_CurrentNext.current_zeit.startzeit) if (jetzt < info_CurrentNext.current_zeit.startzeit)
runningPercent = 0; runningPercent = 0;
else else
runningPercent = MIN ((unsigned) ((float) (jetzt - info_CurrentNext.current_zeit.startzeit) / (float) info_CurrentNext.current_zeit.dauer * 100.), 100); runningPercent = MIN ((jetzt - info_CurrentNext.current_zeit.startzeit) * 100 / info_CurrentNext.current_zeit.dauer, 100);
} }
CVFD::getInstance ()->showPercentOver (runningPercent); CVFD::getInstance ()->showPercentOver (runningPercent);
} }

View File

@@ -1224,7 +1224,7 @@ void CMovieBrowser::refreshMovieInfo(void)
} }
bool logo_ok = false; bool logo_ok = false;
int picw = (int)(((float)16 / (float)9) * (float)m_cBoxFrameInfo.iHeight); int picw = m_cBoxFrameInfo.iHeight * 16 / 9;
int pich = m_cBoxFrameInfo.iHeight; int pich = m_cBoxFrameInfo.iHeight;
std::string fname = getScreenshotName(m_movieSelectionHandler->file.Name); std::string fname = getScreenshotName(m_movieSelectionHandler->file.Name);
logo_ok = (fname != ""); logo_ok = (fname != "");
@@ -1271,7 +1271,7 @@ void CMovieBrowser::info_hdd_level(bool paint_hdd)
if(getSelectedFile() != NULL){ if(getSelectedFile() != NULL){
if (::statfs(getSelectedFile()->Name.c_str(), &s) == 0) { if (::statfs(getSelectedFile()->Name.c_str(), &s) == 0) {
long blocks_used = s.f_blocks - s.f_bfree; long blocks_used = s.f_blocks - s.f_bfree;
blocks_percent_used = (long)(blocks_used * 100.0 / (blocks_used + s.f_bavail) + 0.5); blocks_percent_used = (blocks_used * 1000 / (blocks_used + s.f_bavail) + 5)/10;
} }
} }
@@ -4114,7 +4114,7 @@ if(buf[0] != 0x47) printf("cut: buffer not aligned at %lld\n", sdone);
} }
sdone += r; sdone += r;
spos += r - wptr; spos += r - wptr;
percent = (int) ((float)(spos)/(float)(newsize)*100.); percent = spos * 100 / newsize;
timescale->paintProgressBar2(x + 41, y + 12, percent); timescale->paintProgressBar2(x + 41, y + 12, percent);
#if REAL_CUT #if REAL_CUT
int wr = write(dstfd, &buf[wptr], r-wptr); int wr = write(dstfd, &buf[wptr], r-wptr);
@@ -4342,7 +4342,7 @@ if(buf[0] != 0x47) printf("copy: buffer not aligned at %lld\n", sdone);
bskip -= r; bskip -= r;
spos += r - wptr; spos += r - wptr;
btotal += r; btotal += r;
percent = (int) ((float)(btotal)/(float)(newsize)*100.); percent = btotal * 100 / newsize;
timescale->paintProgressBar2(x + 41, y + 12, percent); timescale->paintProgressBar2(x + 41, y + 12, percent);
#if REAL_CUT #if REAL_CUT
int wr = write(dstfd, &buf[wptr], r-wptr); int wr = write(dstfd, &buf[wptr], r-wptr);

View File

@@ -80,7 +80,7 @@ void CProgressWindow::showGlobalStatus(const unsigned int prog)
if (global_progress > 100) if (global_progress > 100)
global_progress = 100; global_progress = 100;
pos += int( float(width-20)/100.0 * global_progress); pos += (width - 20) * global_progress / 100;
//vordergrund //vordergrund
frameBuffer->paintBox(x+10, globalstatusY,pos, globalstatusY+10, COL_MENUCONTENT_PLUS_7); frameBuffer->paintBox(x+10, globalstatusY,pos, globalstatusY+10, COL_MENUCONTENT_PLUS_7);
} }
@@ -106,7 +106,7 @@ void CProgressWindow::showLocalStatus(const unsigned int prog)
if (local_progress > 100) if (local_progress > 100)
local_progress = 100; local_progress = 100;
pos += int( float(width-20)/100.0 * local_progress); pos += (width - 20) * local_progress / 100;
//vordergrund //vordergrund
frameBuffer->paintBox(x+10, localstatusY,pos, localstatusY+10, COL_MENUCONTENT_PLUS_7); frameBuffer->paintBox(x+10, localstatusY,pos, localstatusY+10, COL_MENUCONTENT_PLUS_7);
} }