summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/plugins/resistor.c59
1 files changed, 27 insertions, 32 deletions
diff --git a/apps/plugins/resistor.c b/apps/plugins/resistor.c
index 14d3aa30dd..eb02ce6d8d 100644
--- a/apps/plugins/resistor.c
+++ b/apps/plugins/resistor.c
@@ -199,7 +199,7 @@ static enum color get_band_rtoc(int in_val)
199 case 9: 199 case 9:
200 return_color = RES_WHITE; 200 return_color = RES_WHITE;
201 break; 201 break;
202 } 202 }
203 return return_color; 203 return return_color;
204} 204}
205 205
@@ -388,7 +388,7 @@ static enum color do_second_band_menu(void)
388 default: 388 default:
389 band_color_selection = RES_INVALID; 389 band_color_selection = RES_INVALID;
390 break; 390 break;
391 } 391 }
392 return band_color_selection; 392 return band_color_selection;
393} 393}
394 394
@@ -443,7 +443,7 @@ static enum color do_third_band_menu(void)
443 default: 443 default:
444 band_color_selection = RES_INVALID; 444 band_color_selection = RES_INVALID;
445 break; 445 break;
446 } 446 }
447 return band_color_selection; 447 return band_color_selection;
448} 448}
449 449
@@ -475,7 +475,7 @@ static enum color do_fourth_band_menu(void)
475 default: 475 default:
476 band_color_selection = RES_INVALID; 476 band_color_selection = RES_INVALID;
477 break; 477 break;
478 } 478 }
479 return band_color_selection; 479 return band_color_selection;
480} 480}
481 481
@@ -559,13 +559,13 @@ static void display_helpfile(void)
559 "own", "judgement", "when", "using", "these", "output", "values.", 559 "own", "judgement", "when", "using", "these", "output", "values.",
560 "Power", "rating", "and", "displayed", "resistance", "are", "rounded", 560 "Power", "rating", "and", "displayed", "resistance", "are", "rounded",
561 "up", "to", "the", "nearest", "common", "value." 561 "up", "to", "the", "nearest", "common", "value."
562 }; 562 };
563 static struct style_text formatting[] = { 563 static struct style_text formatting[] = {
564 { 0, TEXT_CENTER|TEXT_UNDERLINE }, 564 { 0, TEXT_CENTER|TEXT_UNDERLINE },
565 { 3, TEXT_UNDERLINE }, 565 { 3, TEXT_UNDERLINE },
566 { 159, TEXT_UNDERLINE }, 566 { 159, TEXT_UNDERLINE },
567 LAST_STYLE_ITEM 567 LAST_STYLE_ITEM
568 }; 568 };
569 569
570 display_text(ARRAYLEN(helpfile_text), helpfile_text, formatting, 570 display_text(ARRAYLEN(helpfile_text), helpfile_text, formatting,
571 NULL, true); 571 NULL, true);
@@ -651,7 +651,7 @@ static void led_resistance_calc(void)
651 case 5: 651 case 5:
652 led_voltage = 460; 652 led_voltage = 460;
653 break; 653 break;
654 } 654 }
655 switch(fwd_current_selection) { 655 switch(fwd_current_selection) {
656 case 0: /* 20mA */ 656 case 0: /* 20mA */
657 foreward_current = 2; /* 20mA * 100 */ 657 foreward_current = 2; /* 20mA * 100 */
@@ -663,7 +663,7 @@ static void led_resistance_calc(void)
663 rb->kbd_input(fwd_kbd_buffer, sizeof(fwd_kbd_buffer)); 663 rb->kbd_input(fwd_kbd_buffer, sizeof(fwd_kbd_buffer));
664 foreward_current = ((rb->atoi(fwd_kbd_buffer))/10); 664 foreward_current = ((rb->atoi(fwd_kbd_buffer))/10);
665 break; 665 break;
666 } 666 }
667 667
668 if(foreward_current == 0) break; 668 if(foreward_current == 0) break;
669 669
@@ -678,7 +678,7 @@ static void led_resistance_calc(void)
678 if(led_voltage > input_voltage) { 678 if(led_voltage > input_voltage) {
679 rb->splash(HZ, "Problem: LED voltage is higher than the source."); 679 rb->splash(HZ, "Problem: LED voltage is higher than the source.");
680 break; 680 break;
681 } 681 }
682 682
683 for(j = 0; j < total_common_values; j++) { 683 for(j = 0; j < total_common_values; j++) {
684 for(k = 1; k < 5; k++) { 684 for(k = 1; k < 5; k++) {
@@ -686,16 +686,16 @@ static void led_resistance_calc(void)
686 rounded_resistance = (common_values[j] * powi(10, k)); 686 rounded_resistance = (common_values[j] * powi(10, k));
687 /* perfect match */ 687 /* perfect match */
688 break; 688 break;
689 } 689 }
690 else if(resistance >= (common_values[j] * powi(10, k)) && 690 else if(resistance >= (common_values[j] * powi(10, k)) &&
691 resistance <= (common_values[j+1] * powi(10, k))) { 691 resistance <= (common_values[j+1] * powi(10, k))) {
692 rounded_resistance = (common_values[j+1] * powi(10, k)); 692 rounded_resistance = (common_values[j+1] * powi(10, k));
693 /* the higher resistance, to be safe */ 693 /* the higher resistance, to be safe */
694 break; 694 break;
695 }
696 else { break; }
697 } 695 }
696 else { break; }
698 } 697 }
698 }
699 699
700 if(rounded_resistance == 0) 700 if(rounded_resistance == 0)
701 { 701 {
@@ -708,21 +708,20 @@ static void led_resistance_calc(void)
708 if((int)power_rating_in == power_ratings[l]) { 708 if((int)power_rating_in == power_ratings[l]) {
709 rounded_power_rating = (power_ratings[l]); 709 rounded_power_rating = (power_ratings[l]);
710 break; 710 break;
711 } 711 }
712 else if(power_rating_in >= power_ratings[l] && 712 else if(power_rating_in >= power_ratings[l] &&
713 power_rating_in <= power_ratings[l+1]) { 713 power_rating_in <= power_ratings[l+1]) {
714 rounded_power_rating = power_ratings[l+1]; 714 rounded_power_rating = power_ratings[l+1];
715 break; 715 break;
716 }
717 else { break; }
718 } 716 }
717 else { break; }
718 }
719 719
720 get_power_rating_str(rounded_power_rating); 720 get_power_rating_str(rounded_power_rating);
721 721
722 power_ten=0; 722 power_ten=0;
723 temp=rounded_resistance; 723 temp=rounded_resistance;
724 while(temp>=100) 724 while(temp>=100) {
725 {
726 temp/=10; 725 temp/=10;
727 power_ten++; 726 power_ten++;
728 } 727 }
@@ -769,8 +768,8 @@ static void led_resistance_calc(void)
769 quit = true; 768 quit = true;
770 backlight_use_settings(); 769 backlight_use_settings();
771 break; 770 break;
772 }
773 } 771 }
772 }
774 display->set_viewport(&text_vp); 773 display->set_viewport(&text_vp);
775 rb->lcd_stop_scroll(); 774 rb->lcd_stop_scroll();
776 display->set_viewport(&screen_vp); 775 display->set_viewport(&screen_vp);
@@ -842,7 +841,7 @@ static void resistance_to_color(void)
842 case 4: /* 20% */ 841 case 4: /* 20% */
843 fourth_band = RES_NONE; 842 fourth_band = RES_NONE;
844 break; 843 break;
845 } 844 }
846 845
847 kbd_input_int = rb->atoi(kbd_buffer); 846 kbd_input_int = rb->atoi(kbd_buffer);
848 in_resistance_int = kbd_input_int; 847 in_resistance_int = kbd_input_int;
@@ -864,11 +863,10 @@ static void resistance_to_color(void)
864 power_ten=9; 863 power_ten=9;
865 units_used = RES_WHITE; 864 units_used = RES_WHITE;
866 break; 865 break;
867 } 866 }
868 867
869 temp=kbd_input_int; 868 temp=kbd_input_int;
870 while(temp>=100) 869 while(temp>=100) {
871 {
872 temp/=10; 870 temp/=10;
873 power_ten++; 871 power_ten++;
874 } 872 }
@@ -881,8 +879,7 @@ static void resistance_to_color(void)
881 879
882 if( first_band == RES_INVALID 880 if( first_band == RES_INVALID
883 || second_band == RES_INVALID 881 || second_band == RES_INVALID
884 || multiplier == RES_INVALID) 882 || multiplier == RES_INVALID) {
885 {
886 rb->splashf(HZ, "%d %s can not be represented", 883 rb->splashf(HZ, "%d %s can not be represented",
887 in_resistance_int,band_data[units_used].unit); 884 in_resistance_int,band_data[units_used].unit);
888 return; 885 return;
@@ -909,8 +906,8 @@ static void resistance_to_color(void)
909 quit = true; 906 quit = true;
910 backlight_use_settings(); 907 backlight_use_settings();
911 break; 908 break;
912 }
913 } 909 }
910 }
914 display->set_viewport(&text_vp); 911 display->set_viewport(&text_vp);
915 rb->lcd_stop_scroll(); 912 rb->lcd_stop_scroll();
916 display->set_viewport(&screen_vp); 913 display->set_viewport(&screen_vp);
@@ -959,16 +956,14 @@ static void color_to_resistance(void)
959#endif 956#endif
960 draw_resistor_text(first_band, second_band, third_band, fourth_band); 957 draw_resistor_text(first_band, second_band, third_band, fourth_band);
961 958
962 if(total_resistance_centiunits % 100 == 0) 959 if(total_resistance_centiunits % 100 == 0) {
963 {
964 /* No decimals */ 960 /* No decimals */
965 rb->snprintf(total_resistance_str, sizeof(total_resistance_str), 961 rb->snprintf(total_resistance_str, sizeof(total_resistance_str),
966 "Resistance: %d %s", 962 "Resistance: %d %s",
967 total_resistance_centiunits/100, 963 total_resistance_centiunits/100,
968 unit_abbrev); 964 unit_abbrev);
969 } 965 }
970 else 966 else {
971 {
972 rb->snprintf(total_resistance_str, sizeof(total_resistance_str), 967 rb->snprintf(total_resistance_str, sizeof(total_resistance_str),
973 "Resistance: %d.%2.2d %s", 968 "Resistance: %d.%2.2d %s",
974 total_resistance_centiunits/100, 969 total_resistance_centiunits/100,
@@ -992,8 +987,8 @@ static void color_to_resistance(void)
992 quit = true; 987 quit = true;
993 backlight_use_settings(); 988 backlight_use_settings();
994 break; 989 break;
995 } 990 }
996 } 991 }
997 display->set_viewport(&text_vp); 992 display->set_viewport(&text_vp);
998 rb->lcd_stop_scroll(); 993 rb->lcd_stop_scroll();
999 display->set_viewport(&screen_vp); 994 display->set_viewport(&screen_vp);
@@ -1045,7 +1040,7 @@ enum plugin_status plugin_start(const void* nothing)
1045 break; 1040 break;
1046 case MENU_ATTACHED_USB: 1041 case MENU_ATTACHED_USB:
1047 return PLUGIN_USB_CONNECTED; 1042 return PLUGIN_USB_CONNECTED;
1048 }
1049 } 1043 }
1044 }
1050 return PLUGIN_OK; 1045 return PLUGIN_OK;
1051} 1046}