1
0
Fork 0
forked from len0rd/rockbox

Resistor calculator: make brace-style consistent

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28282 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Frank Gevaerts 2010-10-14 20:13:05 +00:00
parent 6ebec89ac6
commit 0d91797d96

View file

@ -199,7 +199,7 @@ static enum color get_band_rtoc(int in_val)
case 9: case 9:
return_color = RES_WHITE; return_color = RES_WHITE;
break; break;
} }
return return_color; return return_color;
} }
@ -388,7 +388,7 @@ static enum color do_second_band_menu(void)
default: default:
band_color_selection = RES_INVALID; band_color_selection = RES_INVALID;
break; break;
} }
return band_color_selection; return band_color_selection;
} }
@ -443,7 +443,7 @@ static enum color do_third_band_menu(void)
default: default:
band_color_selection = RES_INVALID; band_color_selection = RES_INVALID;
break; break;
} }
return band_color_selection; return band_color_selection;
} }
@ -475,7 +475,7 @@ static enum color do_fourth_band_menu(void)
default: default:
band_color_selection = RES_INVALID; band_color_selection = RES_INVALID;
break; break;
} }
return band_color_selection; return band_color_selection;
} }
@ -559,13 +559,13 @@ static void display_helpfile(void)
"own", "judgement", "when", "using", "these", "output", "values.", "own", "judgement", "when", "using", "these", "output", "values.",
"Power", "rating", "and", "displayed", "resistance", "are", "rounded", "Power", "rating", "and", "displayed", "resistance", "are", "rounded",
"up", "to", "the", "nearest", "common", "value." "up", "to", "the", "nearest", "common", "value."
}; };
static struct style_text formatting[] = { static struct style_text formatting[] = {
{ 0, TEXT_CENTER|TEXT_UNDERLINE }, { 0, TEXT_CENTER|TEXT_UNDERLINE },
{ 3, TEXT_UNDERLINE }, { 3, TEXT_UNDERLINE },
{ 159, TEXT_UNDERLINE }, { 159, TEXT_UNDERLINE },
LAST_STYLE_ITEM LAST_STYLE_ITEM
}; };
display_text(ARRAYLEN(helpfile_text), helpfile_text, formatting, display_text(ARRAYLEN(helpfile_text), helpfile_text, formatting,
NULL, true); NULL, true);
@ -651,7 +651,7 @@ static void led_resistance_calc(void)
case 5: case 5:
led_voltage = 460; led_voltage = 460;
break; break;
} }
switch(fwd_current_selection) { switch(fwd_current_selection) {
case 0: /* 20mA */ case 0: /* 20mA */
foreward_current = 2; /* 20mA * 100 */ foreward_current = 2; /* 20mA * 100 */
@ -663,7 +663,7 @@ static void led_resistance_calc(void)
rb->kbd_input(fwd_kbd_buffer, sizeof(fwd_kbd_buffer)); rb->kbd_input(fwd_kbd_buffer, sizeof(fwd_kbd_buffer));
foreward_current = ((rb->atoi(fwd_kbd_buffer))/10); foreward_current = ((rb->atoi(fwd_kbd_buffer))/10);
break; break;
} }
if(foreward_current == 0) break; if(foreward_current == 0) break;
@ -678,7 +678,7 @@ static void led_resistance_calc(void)
if(led_voltage > input_voltage) { if(led_voltage > input_voltage) {
rb->splash(HZ, "Problem: LED voltage is higher than the source."); rb->splash(HZ, "Problem: LED voltage is higher than the source.");
break; break;
} }
for(j = 0; j < total_common_values; j++) { for(j = 0; j < total_common_values; j++) {
for(k = 1; k < 5; k++) { for(k = 1; k < 5; k++) {
@ -686,16 +686,16 @@ static void led_resistance_calc(void)
rounded_resistance = (common_values[j] * powi(10, k)); rounded_resistance = (common_values[j] * powi(10, k));
/* perfect match */ /* perfect match */
break; break;
} }
else if(resistance >= (common_values[j] * powi(10, k)) && else if(resistance >= (common_values[j] * powi(10, k)) &&
resistance <= (common_values[j+1] * powi(10, k))) { resistance <= (common_values[j+1] * powi(10, k))) {
rounded_resistance = (common_values[j+1] * powi(10, k)); rounded_resistance = (common_values[j+1] * powi(10, k));
/* the higher resistance, to be safe */ /* the higher resistance, to be safe */
break; break;
}
else { break; }
} }
else { break; }
} }
}
if(rounded_resistance == 0) if(rounded_resistance == 0)
{ {
@ -708,21 +708,20 @@ static void led_resistance_calc(void)
if((int)power_rating_in == power_ratings[l]) { if((int)power_rating_in == power_ratings[l]) {
rounded_power_rating = (power_ratings[l]); rounded_power_rating = (power_ratings[l]);
break; break;
} }
else if(power_rating_in >= power_ratings[l] && else if(power_rating_in >= power_ratings[l] &&
power_rating_in <= power_ratings[l+1]) { power_rating_in <= power_ratings[l+1]) {
rounded_power_rating = power_ratings[l+1]; rounded_power_rating = power_ratings[l+1];
break; break;
}
else { break; }
} }
else { break; }
}
get_power_rating_str(rounded_power_rating); get_power_rating_str(rounded_power_rating);
power_ten=0; power_ten=0;
temp=rounded_resistance; temp=rounded_resistance;
while(temp>=100) while(temp>=100) {
{
temp/=10; temp/=10;
power_ten++; power_ten++;
} }
@ -769,8 +768,8 @@ static void led_resistance_calc(void)
quit = true; quit = true;
backlight_use_settings(); backlight_use_settings();
break; break;
}
} }
}
display->set_viewport(&text_vp); display->set_viewport(&text_vp);
rb->lcd_stop_scroll(); rb->lcd_stop_scroll();
display->set_viewport(&screen_vp); display->set_viewport(&screen_vp);
@ -842,7 +841,7 @@ static void resistance_to_color(void)
case 4: /* 20% */ case 4: /* 20% */
fourth_band = RES_NONE; fourth_band = RES_NONE;
break; break;
} }
kbd_input_int = rb->atoi(kbd_buffer); kbd_input_int = rb->atoi(kbd_buffer);
in_resistance_int = kbd_input_int; in_resistance_int = kbd_input_int;
@ -864,11 +863,10 @@ static void resistance_to_color(void)
power_ten=9; power_ten=9;
units_used = RES_WHITE; units_used = RES_WHITE;
break; break;
} }
temp=kbd_input_int; temp=kbd_input_int;
while(temp>=100) while(temp>=100) {
{
temp/=10; temp/=10;
power_ten++; power_ten++;
} }
@ -881,8 +879,7 @@ static void resistance_to_color(void)
if( first_band == RES_INVALID if( first_band == RES_INVALID
|| second_band == RES_INVALID || second_band == RES_INVALID
|| multiplier == RES_INVALID) || multiplier == RES_INVALID) {
{
rb->splashf(HZ, "%d %s can not be represented", rb->splashf(HZ, "%d %s can not be represented",
in_resistance_int,band_data[units_used].unit); in_resistance_int,band_data[units_used].unit);
return; return;
@ -909,8 +906,8 @@ static void resistance_to_color(void)
quit = true; quit = true;
backlight_use_settings(); backlight_use_settings();
break; break;
}
} }
}
display->set_viewport(&text_vp); display->set_viewport(&text_vp);
rb->lcd_stop_scroll(); rb->lcd_stop_scroll();
display->set_viewport(&screen_vp); display->set_viewport(&screen_vp);
@ -959,16 +956,14 @@ static void color_to_resistance(void)
#endif #endif
draw_resistor_text(first_band, second_band, third_band, fourth_band); draw_resistor_text(first_band, second_band, third_band, fourth_band);
if(total_resistance_centiunits % 100 == 0) if(total_resistance_centiunits % 100 == 0) {
{
/* No decimals */ /* No decimals */
rb->snprintf(total_resistance_str, sizeof(total_resistance_str), rb->snprintf(total_resistance_str, sizeof(total_resistance_str),
"Resistance: %d %s", "Resistance: %d %s",
total_resistance_centiunits/100, total_resistance_centiunits/100,
unit_abbrev); unit_abbrev);
} }
else else {
{
rb->snprintf(total_resistance_str, sizeof(total_resistance_str), rb->snprintf(total_resistance_str, sizeof(total_resistance_str),
"Resistance: %d.%2.2d %s", "Resistance: %d.%2.2d %s",
total_resistance_centiunits/100, total_resistance_centiunits/100,
@ -992,8 +987,8 @@ static void color_to_resistance(void)
quit = true; quit = true;
backlight_use_settings(); backlight_use_settings();
break; break;
} }
} }
display->set_viewport(&text_vp); display->set_viewport(&text_vp);
rb->lcd_stop_scroll(); rb->lcd_stop_scroll();
display->set_viewport(&screen_vp); display->set_viewport(&screen_vp);
@ -1045,7 +1040,7 @@ enum plugin_status plugin_start(const void* nothing)
break; break;
case MENU_ATTACHED_USB: case MENU_ATTACHED_USB:
return PLUGIN_USB_CONNECTED; return PLUGIN_USB_CONNECTED;
}
} }
}
return PLUGIN_OK; return PLUGIN_OK;
} }