Index: apps/plugins/CATEGORIES
===================================================================
--- apps/plugins/CATEGORIES	(revision 27856)
+++ apps/plugins/CATEGORIES	(working copy)
@@ -73,6 +73,7 @@
 properties,viewers
 random_folder_advance_config,apps
 remote_control,apps
+resistor,apps
 reversi,games
 robotfindskitten,games
 rockblox,games
Index: apps/plugins/bitmaps/native/SOURCES
===================================================================
--- apps/plugins/bitmaps/native/SOURCES	(revision 27856)
+++ apps/plugins/bitmaps/native/SOURCES	(working copy)
@@ -886,5 +886,11 @@
 #endif
 #endif /* Complex condition for pitch detector */
 
+/* Resistor Calculator */
+#if (LCD_WIDTH >= 220)
+resistor.176x220x16.bmp
+#elif (LCD_WIDTH >= 176)
+resistor.220x176x16.bmp
+#endif
 
 #endif /* HAVE_LCD_BITMAP */
Index: apps/plugins/SOURCES
===================================================================
--- apps/plugins/SOURCES	(revision 27856)
+++ apps/plugins/SOURCES	(working copy)
@@ -150,6 +150,8 @@
 xobox.c
 spacerocks.c
 
+resistor.c
+
 /* Plugins needing the grayscale lib on low-depth LCDs */
 fire.c
 plasma.c
Index: apps/plugins/resistor.c
===================================================================
--- apps/plugins/resistor.c	(revision 0)
+++ apps/plugins/resistor.c	(revision 0)
@@ -0,0 +1,735 @@
+/* === Rockbox Resistor code/value calculator ===
+TODO:
+[ in progress] Support more targets, even greyscale/BW targets
+*/
+ 
+#include "plugin.h"
+#include "lib/display_text.h"
+#include "lib/pluginlib_actions.h"
+#include "lib/picture.h"
+
+
+/* Defining player-specific constants */
+
+#if defined(HAVE_LCD_COLOR) && LCD_WIDTH >= 220 && LCD_HEIGHT >= 176 /* Fuze or larger */
+#define    RESISTOR_BMP_X           12
+#define    RESISTOR_BMP_Y           15
+
+#elif defined(HAVE_LCD_COLOR) && LCD_WIDTH >= 176 && LCD_HEIGHT >= 220 /* e200 or larger */
+#define    RESISTOR_BMP_X          3
+#define    RESISTOR_BMP_Y          11
+
+#elif defined(HAVE_LCD_COLOR) &&  LCD_WIDTH >= 176 && LCD_HEIGHT >= 132 /* ipod nano or larger */
+#define RESISTOR_BMP_X             3
+#define RESISTOR_BMP_Y             7
+
+#else
+
+#define    USE_TEXT_ONLY
+#endif
+
+#ifdef USE_TEXT_ONLY
+#define    resistance_val_x         0
+#define    resistance_val_y         1
+
+#define total_resistance_str_x     0
+#define total_resistance_str_y     15
+#define tolerance_str_x            0
+#define tolerance_str_y            30
+#else
+
+#include "pluginbitmaps/resistor.h"
+
+#define band_width                 (BMPWIDTH_resistor/15)
+#define band_height                (BMPHEIGHT_resistor*9/10)
+
+#define first_band_x               (BMPWIDTH_resistor/4 + RESISTOR_BMP_X - band_width/2)
+#define second_band_x              (3*BMPWIDTH_resistor/8 + RESISTOR_BMP_X - band_width/2)
+#define third_band_x               (BMPWIDTH_resistor/2 + RESISTOR_BMP_X - band_width/2)
+#define fourth_band_x              (3*BMPWIDTH_resistor/4 + RESISTOR_BMP_X - band_width/2)
+#define universal_y                (RESISTOR_BMP_Y+(BMPHEIGHT_resistor)/2 - band_height/2)
+
+#define total_resistance_str_x     (LCD_WIDTH/14)
+#define total_resistance_str_y     (2*RESISTOR_BMP_Y + BMPHEIGHT_resistor)
+#define resistance_val_x           (LCD_WIDTH/14)
+#define resistance_val_y           (total_resistance_str_y + 15)
+#define tolerance_str_x            (LCD_WIDTH/14)
+#define tolerance_str_y            (total_resistance_str_y + 15)
+#define r_to_c_out_str_x           (LCD_WIDTH/14)
+#define r_to_c_out_str_y           (total_resistance_str_y + 25)
+/* tolerance_str and resistance_val will never be shown at the same time */
+#endif
+
+PLUGIN_HEADER
+
+enum color {
+    RES_BLACK,
+    RES_BROWN,
+    RES_RED,
+    RES_ORANGE,
+    RES_YELLOW,
+    RES_GREEN,
+    RES_BLUE,
+    RES_VIOLET,
+    RES_GREY,
+    RES_WHITE,
+    RES_GOLD,
+    RES_SILVER,
+    RES_NONE,
+};
+
+#ifndef LCD_RGBPACK
+/* Warning: dirty kludge */
+#define LCD_RGBPACK(x,y,z) 0
+#endif
+
+struct band_data
+{
+    enum color color;
+    char *name;
+    int color_value;
+    int resistance_value;
+    int multiplier;
+    char *unit;
+    int tolerance;
+} band_data[] =
+{
+    { RES_BLACK,  "Black",  LCD_RGBPACK(0, 0, 0),        0,   100,   "Ohms", -1 },
+    { RES_BROWN,  "Brown",  LCD_RGBPACK(118, 78, 0),     1,  1000,   "Ohms",  1 },
+    { RES_RED,    "Red",    LCD_RGBPACK(255, 0, 0),      2, 10000,  "KOhms",  2 },
+    { RES_ORANGE, "Orange", LCD_RGBPACK(255, 199, 76),   3,   100,  "KOhms", -1 },
+    { RES_YELLOW, "Yellow", LCD_RGBPACK(255, 255, 0),    4,  1000,  "KOhms", -1 },
+    { RES_GREEN,  "Green",  LCD_RGBPACK(0, 128, 0),      5, 10000,  "MOhms", -1 },
+    { RES_BLUE,   "Blue",   LCD_RGBPACK(0, 0, 255),      6,   100,  "MOhms", -1 },
+    { RES_VIOLET, "Violet", LCD_RGBPACK(153, 51, 255),   7,    -1,       0, -1 },
+    { RES_GREY,   "Grey",   LCD_RGBPACK(192, 192, 192),  8,    -1,       0, -1 },
+    { RES_WHITE,  "White",  LCD_RGBPACK(255, 255, 255),  9,    -1,       0, -1 },
+    { RES_GOLD,   "Gold",   LCD_RGBPACK(146, 146, 0),   -1,     1,   "Ohms",  5 },
+    { RES_SILVER, "Silver", LCD_RGBPACK(213, 213, 213), -1,    10,   "Ohms", 10 },
+    { RES_NONE,   "None",   -1                        , -1,    -1,       0, 20 }
+};
+
+/* For use in the color_to_resistance_menu() function */
+#define    firstband_m    0
+#define    secondband_m   1
+#define    thirdband_m    2
+#define    fourthband_m   3
+
+char *unit_abbrev;
+char tolerance_str [14];			
+int r_to_c_first_band;
+int r_to_c_second_band;
+int r_to_c_third_band;
+
+char str [4][7];
+
+int get_power_ten(float in_val)
+{
+    int power = 0;
+    if(in_val <= 9 && in_val >= 0) { power = 0; }
+    else if(in_val <= 99 && in_val >= 10) {power = 1;}
+    else if(in_val <= 999 && in_val >= 100) {power = 2;}
+    else if(in_val <= 9999 && in_val >= 1000) {power = 3;}
+    else if(in_val <= 99999 && in_val >= 10000) {power = 4;}
+    else if(in_val <= 999999 && in_val >= 100000) {power = 5;}
+    else if(in_val <= 9999999 && in_val >= 1000000) {power = 6;}   
+    return power;
+}
+
+int powi(int num, int exp)
+{
+    int i, product = 1;
+    for (i = 0; i < exp; i++) {
+    product *= num; }
+
+    return product;
+}
+
+enum color get_band_rtoc(int in_val)
+{
+    int return_color;
+    switch(in_val) {
+        case 0:
+            return_color = RES_BLACK;
+            break;
+        case 1:
+            return_color = RES_BROWN;
+            break;
+        case 2:
+            return_color = RES_RED;
+            break;
+        case 3:
+            return_color = RES_ORANGE;
+            break;
+        case 4:
+            return_color = RES_YELLOW;
+            break;
+        case 5:
+            return_color = RES_GREEN;
+            break;
+        case 6:
+            return_color = RES_BLUE;
+            break;
+        case 7:
+            return_color = RES_VIOLET;
+            break;
+        case 8:
+            return_color = RES_GREY;
+            break;
+        case 9:
+            return_color = RES_WHITE;
+            break;
+        }
+    return return_color;
+}
+
+void get_tolerance_str(enum color color)
+{
+    rb->snprintf(tolerance_str, sizeof(tolerance_str), "%d%% tolerance",
+                 band_data[color].tolerance);
+}
+    
+void draw_resistor_text(enum color firstband_color,
+                        enum color secondband_color,
+                        enum color thirdband_color,
+                        enum color fourthband_color)
+{
+    char resistance_vals_str[64];
+    rb->snprintf(resistance_vals_str, sizeof(resistance_vals_str),
+                 "%s - %s - %s - %s", band_data[firstband_color].name,
+                                      band_data[secondband_color].name,
+                                      band_data[thirdband_color].name,
+                                      band_data[fourthband_color].name);
+    rb->lcd_putsxy(resistance_val_x, resistance_val_y, resistance_vals_str);
+    rb->lcd_update();
+}
+
+#ifndef USE_TEXT_ONLY
+void draw_resistor(enum color firstband_color,
+                   enum color secondband_color,
+                   enum color thirdband_color,
+                   enum color fourthband_color)
+{
+    rb->lcd_clear_display();
+    rb->lcd_bitmap_transparent(resistor, RESISTOR_BMP_X, RESISTOR_BMP_Y, 
+                               BMPWIDTH_resistor, BMPHEIGHT_resistor);
+        
+    rb->lcd_set_foreground(band_data[firstband_color].color_value);
+    rb->lcd_fillrect(first_band_x, universal_y, band_width, band_height);
+          
+    rb->lcd_set_foreground(band_data[secondband_color].color_value);
+    rb->lcd_fillrect(second_band_x, universal_y, band_width, band_height);
+            
+    rb->lcd_set_foreground(band_data[thirdband_color].color_value);
+    rb->lcd_fillrect(third_band_x, universal_y, band_width, band_height);
+            
+    rb->lcd_set_foreground(band_data[fourthband_color].color_value);
+    rb->lcd_fillrect(fourth_band_x, universal_y, band_width, band_height);
+    
+    rb->lcd_set_foreground(LCD_WHITE); 
+            
+    rb->lcd_update();
+    return;
+}
+#else
+
+void draw_resistor(enum color firstband_color,
+                   enum color secondband_color,
+                   enum color thirdband_color,
+                   enum color fourthband_color)
+{
+    char resistance_vals_str[64];
+    rb->snprintf(resistance_vals_str, sizeof(resistance_vals_str), 
+                 "%s - %s - %s - %s", band_data[firstband_color].name,
+                                      band_data[secondband_color].name,
+                                      band_data[thirdband_color].name,
+                                      band_data[fourthband_color].name);
+    rb->lcd_puts_scroll(resistance_val_x, resistance_val_y, resistance_vals_str);
+    rb->lcd_update(); 
+}
+#endif
+
+int calculate_resistance(enum color first_band,
+                         enum color second_band, 
+                         enum color third_band)
+{
+    int tens = band_data[first_band].resistance_value;
+    int units = band_data[second_band].resistance_value;
+    int multiplier = band_data[third_band].multiplier;
+    int total_resistance_centiunits = (10 * tens + units ) * multiplier;
+    unit_abbrev = band_data[third_band].unit;
+
+    return total_resistance_centiunits;
+}
+
+enum color do_first_band_menu(void)
+{
+    int band_selection = 0;
+    enum color band_color_selection = 0;
+            
+    MENUITEM_STRINGLIST(colors_menu_first, "First band colour:", NULL, 
+                        "Black", "Brown", "Red", "Orange", "Yellow",
+                         "Green", "Blue", "Violet", "Grey", "White");
+    band_selection = rb->do_menu(&colors_menu_first, &band_selection, NULL, 
+                                false);
+    switch(band_selection) {
+        case 0: /* Black */
+            band_color_selection = band_data[RES_BLACK].color_value;
+            break;
+        case 1: /* Brown */
+            band_color_selection = band_data[RES_BROWN].color_value;
+            break;
+        case 2: /* Red */
+            band_color_selection = band_data[RES_RED].color_value;
+            break;
+        case 3: /* Orange */
+            band_color_selection = band_data[RES_ORANGE].color_value;
+            break;
+        case 4: /* Yellow */
+            band_color_selection = band_data[RES_YELLOW].color_value;
+            break;
+        case 5: /* Green */
+            band_color_selection = band_data[RES_GREEN].color_value;
+            break;
+        case 6: /* Blue */
+            band_color_selection = band_data[RES_BLUE].color_value;
+            break;
+        case 7: /* Violet */
+            band_color_selection = band_data[RES_VIOLET].color_value;
+            break;
+        case 8: /* Grey */
+            band_color_selection = band_data[RES_GREY].color_value;
+            break;
+        case 9: /* White */
+            band_color_selection = band_data[RES_WHITE].color_value;
+            break;
+        }
+    return band_color_selection;
+}
+            
+enum color do_second_band_menu(void) 
+{
+    int band_selection = 0;
+    enum color band_color_selection = 0;
+            
+    MENUITEM_STRINGLIST(colors_menu_second, "Second band colour:", NULL, 
+                        "Black", "Brown", "Red", "Orange", "Yellow", 
+                        "Green", "Blue", "Violet", "Grey", "White");
+    band_selection = rb->do_menu(&colors_menu_second, &band_selection, NULL, 
+                                false);
+    switch(band_selection) {
+        case 0: /* Black */
+            band_color_selection = RES_BLACK;
+            break;
+        case 1: /* Brown */
+            band_color_selection = RES_BROWN;
+            break;
+        case 2: /* Red */
+            band_color_selection = RES_RED;
+            break;
+        case 3: /* Orange */
+            band_color_selection = RES_ORANGE;
+            break;
+        case 4: /* Yellow */
+            band_color_selection = RES_YELLOW;
+            break;
+        case 5: /* Green */
+            band_color_selection = RES_GREEN;
+            break;
+        case 6: /* Blue */
+            band_color_selection = RES_BLUE;
+            break;
+        case 7: /* Violet */
+            band_color_selection = RES_VIOLET;
+            break;
+        case 8: /* Grey */
+            band_color_selection = RES_GREY;
+            break;
+        case 9: /* White */
+            band_color_selection = RES_WHITE;
+        break;
+                    }
+    return band_color_selection;
+}
+    
+enum color do_third_band_menu(void) 
+{
+    int band_selection = 0;
+    enum color band_color_selection = 0;
+            
+    MENUITEM_STRINGLIST(colors_menu_third, "Third band colour:", NULL, 
+                        "Black", "Brown", "Red", "Orange", "Yellow",
+                         "Green", "Blue", "Silver", "Gold");
+    band_selection = rb->do_menu(&colors_menu_third, &band_selection, NULL, 
+                                false);
+    switch(band_selection) {
+        case 0: /* Black */
+            band_color_selection = RES_BLACK;
+            break;
+        case 1: /* Brown */
+            band_color_selection = RES_BROWN;
+            break;
+        case 2: /* Red */
+            band_color_selection = RES_RED;
+            break;
+        case 3: /* Orange */
+            band_color_selection = RES_ORANGE;
+            break;
+        case 4: /* Yellow */
+            band_color_selection= RES_YELLOW;
+            break;
+        case 5: /* Green */
+            band_color_selection = RES_GREEN;
+            break;
+        case 6: /* Blue */
+            band_color_selection = RES_BLUE;
+            break;
+        case 7: /* Silver */
+            band_color_selection = RES_SILVER;
+            break;
+        case 8: /* Gold */
+            band_color_selection= RES_GOLD;
+            break;
+                    }
+    return band_color_selection;
+}
+            
+enum color do_fourth_band_menu(void) 
+{
+    int band_selection = 0;
+    enum color band_color_selection = 0;
+            
+    MENUITEM_STRINGLIST(colors_menu_fourth, "Fourth band colour:", NULL, 
+                        "Gold", "Brown", "Red", "Silver", "(none)");
+    band_selection = rb->do_menu(&colors_menu_fourth, &band_selection, NULL, 
+                                false);
+    switch(band_selection) {
+        case 0: /* Gold */
+            band_color_selection = RES_GOLD;
+            break;
+        case 1: /* Brown */
+            band_color_selection = RES_BROWN;
+            break;
+        case 2: /* Red */
+            band_color_selection = RES_RED;
+            break;
+        case 3: /* Silver */
+            band_color_selection = RES_SILVER;
+            break;
+        case 4: /* (none) */
+            band_color_selection = RES_NONE;
+            break;
+                    }
+    return band_color_selection;
+}
+    
+void display_helpfile(void)
+{
+    rb->splash(HZ/2, "Helpfile");
+    rb->lcd_clear_display();
+    /* some information obtained from wikipedia */
+    static char * helpfile_text[] = {
+        "Resistor Calculator Helpfile", "", "",
+        "About resistors:", "", /* 7 */
+        /* -- */
+        "A", "resistor", "is", "a ", "two-terminal", "electronic", 
+        "component", "that", "produces", "a", "voltage", "across", "its", 
+        "terminals", "that", "is", "proportional", "to", "the", "electric",
+        "current", "passing", "through", "it", "in", "accordance", "to",
+        "Ohm's", "Law:", "", /* 29 */
+        /* -- */
+        "", "V = IR",
+        "", "I = V/R",
+        "", "and",
+        "", "R = I/V", "", "",
+        "Where", "V", "=", "voltage", "I", "=", "current", "(in", "amps)", 
+        "and", "R", "=", "resistance", "(measured", "in", "Ohms)", "", "",
+         /* 28 */
+        /* -- */
+        "The", "primary", "characteristics", "of", "a", "resistor", "are",
+        "the", "resistance,", "the", "tolerance,", "and", "the", "maximum",
+        "working", "voltage", "and", "the", "power", "rating.", "At", 
+        "this", "time,", "this", "calculator", "only", "utilizes", "the",
+        "resistance", "and", "tolerance.", "", "", /* 33 */
+        /* -- */
+        "The", "Ohm", "is", "the", "SI", "unit", "of", "resistance,", "and",
+        "common", "multiples", "of", "that", "include", "the", "kiliohm", 
+        "(KOhm", "-", "1x10^3)", "and", "the", "megaohm", "(MOhm",
+        "-", "1x10^6),", "both", "of", "which", "are", "supported", "by",
+        "this", "calculator.", "", "", /* 34 */
+        /* -- */
+        "Resistors", "in", "parallel:", "", /* 4 */
+        /* -- */
+        "1/Rtotal", "=", "1/R1", "+", "1/R2", "...", "+", "1/Rn", "", /* 9*/
+        /* -- */
+        "", "Resistors", "in", "series:", "", /* 5 */
+        /* -- */
+        "Rtotal", "=", "R1", "+", "R2", "...", "+", "Rn", "", /* 9 */
+        /* -- */
+        "", "How to use this calculator", "", /* 3 */
+        /* -- */
+        "This", "calculator", "has", "two", "modes:", "",
+        "Resistance", "to", "coulor", "codes", "", "and", "",
+        "Color", "codes", "to", "resistance", "(although", "this", "part",
+        "is", "not", "yet", "completed.)","", "",
+        /* -- */
+        "*At", "this", "time,", "there", "is", "only", "support", "for", 
+        "5,", "10,", "and", "20%","tolerances,", "and", "4", "bands.","","",
+        /* -- */
+        "In", "Colour", "to", "Resistance", "mode", "use", "the", "menus",
+        "to", "input", "(in", "order)", "the", "bands", "of", "the",
+        "resistor", "for", "which", "you", "would", "like", "to", "know",
+        "the", "resistance.", "", "",
+        /* -- */
+        "In", "Resistance", "to", "Colour", "mode,", "use", "the", "menus", 
+        "to", "select", "which", "unit", "to", "use", "(choose", "from", "Ohms,",
+        "KiliOhms", "and", "MegaOhms)", "and", "the", "on-screen", "keyboard",
+        "to", "input", "the", "value", "of", "the", "resistor", "that", "you",
+        "would", "like", "to", "know", "the", "value", "of.", "Output", "will",
+        "be", "both", "graphical", "(with", "bands", "of", "the", "resistor",
+        "shown", "in", "their", "corresponding", "colours", "-", "colour",
+        "targets", "only)", "and", "textually." };
+    static struct style_text formatting[] = {
+        { 0, TEXT_CENTER|TEXT_UNDERLINE },
+        { 3, TEXT_UNDERLINE },
+        { 159, TEXT_UNDERLINE },
+        LAST_STYLE_ITEM
+        };
+            
+    display_text(ARRAYLEN(helpfile_text), helpfile_text, formatting,
+                 NULL, true);
+            
+    return;
+}
+        
+void resistance_to_color(void) 
+{
+    int menu_selection;
+    int menu_selection_tol;
+    int button_press;
+    int i;
+    bool quit = false;
+    char kbd_buffer [10];
+    int kbd_input_int;
+    int in_resistance_int;
+    
+    int power_ten;
+    int first_band_int = 0;
+    int second_band_int = 0;
+    
+    enum color first_band;
+    enum color second_band;
+    enum color multiplier;
+    enum color fourth_band;
+    enum color units_used;
+    
+    char out_str[20];
+    
+    for(i=0; i<=10; i++) { kbd_buffer[i] = 0; }
+    /* This cleans out the mysterious garbage that appears */
+    rb->lcd_clear_display();
+    rb->splash(HZ/2, "Resistance to Colour");
+    MENUITEM_STRINGLIST(r_to_c_menu, "Select unit to use:", NULL, 
+                        "Ohms", "Kiliohms (KOhms)", "Megaohms (MOhms)");
+    MENUITEM_STRINGLIST(r_to_c_menu_tol, "Tolerance to display:", NULL,
+                        "5%", "10%", "1%", "2%", "20%")
+      
+    while(!quit) {
+        menu_selection = rb->do_menu(&r_to_c_menu, &menu_selection,
+                                     NULL, false);
+        
+        rb->kbd_input(kbd_buffer, sizeof(kbd_buffer));
+        /* As stated above somewhere, we (I) need to make a calculator-like
+           keypad, that keyboard isn't all that fun as it is. */
+        menu_selection_tol = rb->do_menu(&r_to_c_menu_tol, &menu_selection_tol,
+                                         NULL, false);
+        switch(menu_selection_tol) {
+            case 0: /* 5% */
+                fourth_band = RES_GOLD;
+                break;
+            case 1: /* 10% */
+                fourth_band = RES_SILVER;
+                break;
+            case 2: /* 1% */
+                fourth_band = RES_BROWN;
+                break;
+            case 3: /* 2% */
+                fourth_band = RES_RED;
+                break;
+            case 4: /* 20% */
+                fourth_band = RES_NONE;
+                break;
+            }
+            
+        kbd_input_int = atoi(kbd_buffer);
+        in_resistance_int = kbd_input_int;
+        
+        switch(menu_selection) {
+            case 0:
+                units_used = RES_BLACK;
+                break;
+            case 1: /* KOhms */
+                units_used = RES_RED;
+                kbd_input_int *= 1000;
+                break;
+            case 2: /* MOhms */
+                units_used = RES_GREEN;
+                kbd_input_int *= 1000000;
+                break;
+            }
+            
+        power_ten = get_power_ten(kbd_input_int);
+        if(kbd_input_int / powi(10, power_ten) == 1) {
+            while(kbd_input_int /powi(10, power_ten) == 1) {
+                power_ten--;
+                }
+            }
+            
+        if(kbd_input_int / powi(10, power_ten) != (int)kbd_input_int) {
+            power_ten--; }
+        kbd_input_int /= powi(10, power_ten);
+        
+        if(kbd_input_int < 10) {
+            first_band_int = kbd_input_int; }
+        else { first_band_int = kbd_input_int /10; }
+        second_band_int += kbd_input_int % 10;
+        
+        if(first_band_int == 10) {
+            first_band_int /= 10;
+            second_band_int = 0;
+            power_ten++;
+            }
+        
+        if(first_band_int > 10) {
+            int temp;
+            temp = first_band_int /10;
+            second_band_int = first_band_int % 10;
+            first_band_int = temp;
+            }
+            
+        first_band = get_band_rtoc(first_band_int);
+        second_band = get_band_rtoc(second_band_int);
+        multiplier = get_band_rtoc(power_ten);
+        
+        rb->lcd_clear_display();
+        draw_resistor(first_band, second_band, multiplier, fourth_band);
+                      
+        #ifdef HAVE_LCD_COLOR /* This seems backwards, but is really only 
+                                necessary on color targets */
+        draw_resistor_text(first_band, second_band,
+                           multiplier, fourth_band);
+        #endif
+        
+        rb->snprintf(out_str, sizeof(out_str), "Input: %d %s", in_resistance_int,
+                     band_data[units_used].unit);
+        rb->lcd_putsxy(r_to_c_out_str_x, r_to_c_out_str_y, out_str);
+        rb->lcd_update();
+        
+        button_press = rb->button_get(true);
+        switch(button_press) {
+            case PLA_SELECT:
+                break;
+            default:
+                quit = true;
+                break;
+            }
+        }
+}
+    
+void color_to_resistance(void) 
+{
+    bool quit = false;
+    int button_input = 0;
+            
+    /* The colors of the bands */
+    enum color first_band = 0;
+    enum color second_band = 0;
+    enum color third_band = 0;
+    enum color fourth_band = 0;
+           
+    int total_resistance_centiunits = 0;
+    char total_resistance_str [35];
+            
+    rb->splash(HZ/2, "Colour to resistance");
+    rb->lcd_clear_display();
+            
+    while(!quit) {
+        first_band = do_first_band_menu();
+        second_band = do_second_band_menu();
+        third_band = do_third_band_menu();
+        fourth_band = do_fourth_band_menu();
+                    
+        total_resistance_centiunits = calculate_resistance(first_band, 
+                                                           second_band,
+                                                           third_band);
+        get_tolerance_str(fourth_band);      
+        draw_resistor(first_band, second_band, third_band, fourth_band);
+        #ifndef USE_TEXT_ONLY
+        rb->lcd_set_foreground(LCD_WHITE);
+        #endif
+        if(total_resistance_centiunits % 100 == 0)
+        {
+            // No decimals
+            rb->snprintf(total_resistance_str, sizeof(total_resistance_str), 
+                         "The resistance is %d %s",
+                         total_resistance_centiunits/100,
+                         unit_abbrev);
+        }
+        else
+        {
+            rb->snprintf(total_resistance_str, sizeof(total_resistance_str), 
+                         "The resistance is %d.%d %s",
+                         total_resistance_centiunits/100,
+                         total_resistance_centiunits%100,
+                         unit_abbrev);
+        }
+        rb->lcd_putsxy(total_resistance_str_x, total_resistance_str_y,
+                       total_resistance_str);
+        rb->lcd_putsxy(tolerance_str_x, tolerance_str_y, tolerance_str);
+        rb->lcd_update();
+                    
+        button_input = rb->button_get(true);
+        switch(button_input) {
+            case PLA_RIGHT:
+                break;
+            case PLA_EXIT:
+            case PLA_SELECT:
+            default:
+                quit = true;
+                break;
+            }                   
+        }
+    return;
+}
+
+enum plugin_status plugin_start(const void* nothing) 
+{
+    (void)nothing;
+    rb->lcd_clear_display();
+    rb->lcd_update();
+    int main_menu_selection = 0;
+    bool menuquit = false;
+        
+    MENUITEM_STRINGLIST(main_menu, "Resistor Code Calculator:", NULL, 
+                        "Colours -> Resistance", "Resistance -> Colours", 
+                        "Help", "Exit");
+    while (!menuquit) {
+        main_menu_selection = rb->do_menu(&main_menu, &main_menu_selection, 
+                                          NULL, false);
+        switch(main_menu_selection) {
+            case 0:
+                color_to_resistance();
+                break;
+            case 1:
+                resistance_to_color();
+                break;
+            case 2:
+                display_helpfile();
+                break;
+            case 3:
+                menuquit = true;
+                break;
+            }
+        }
+    return PLUGIN_OK;
+}
