summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--flash/bootbox/main.c82
1 files changed, 54 insertions, 28 deletions
diff --git a/flash/bootbox/main.c b/flash/bootbox/main.c
index d4e326025e..ef215c092b 100644
--- a/flash/bootbox/main.c
+++ b/flash/bootbox/main.c
@@ -66,43 +66,72 @@ int show_logo(void)
66} 66}
67 67
68#ifdef HAVE_CHARGING 68#ifdef HAVE_CHARGING
69int charging_screen(void) 69/*
70bool backlight_get_on_when_charging(void)
71{
72 return false;
73}
74*/
75void charging_screen(void)
70{ 76{
71 unsigned int button; 77 unsigned int button;
72 int rc = 0; 78 const char* msg;
73 79
74 ide_power_enable(false); /* power down the disk, else would be spinning */ 80 ide_power_enable(false); /* power down the disk, else would be spinning */
75 81
76 lcd_clear_display(); 82 lcd_clear_display();
77 lcd_puts(0, 0, "charging...");
78#ifdef HAVE_LCD_BITMAP
79 lcd_update();
80#endif
81 83
82 do 84 do
83 { 85 {
86#ifdef HAVE_CHARGE_CTRL
87 if (charge_state == 1)
88 msg = "charging";
89 else if (charge_state == 2)
90 msg = "topoff charge";
91 else if (charge_state == 3)
92 msg = "trickle charge";
93 else
94 msg = "not charging";
95
96#else
97 msg = "charging";
98#endif
99 lcd_puts(0, 0, msg);
100 {
101 char buf[32];
102 int battery_voltage;
103 int batt_int, batt_frac;
104 battery_voltage = (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) / 10000;
105 batt_int = battery_voltage / 100;
106 batt_frac = battery_voltage % 100;
107
108 snprintf(buf, sizeof(buf), "%d.%02dV %d%%",
109 batt_int, batt_frac, battery_level());
110 lcd_puts(0, 1, buf);
111 }
112
113#ifdef HAVE_LCD_BITMAP
114 lcd_update();
115#endif
116
84 button = button_get_w_tmo(HZ/2); 117 button = button_get_w_tmo(HZ/2);
85 if (button == BUTTON_ON) 118#ifdef BUTTON_ON
86 rc = 2; 119 if (button == (BUTTON_ON | BUTTON_REL))
87 else if (usb_detect()) 120#else
88 rc = 3; 121 if (button == (BUTTON_RIGHT | BUTTON_REL))
89 else if (!charger_inserted()) 122#endif
90 rc = 1; 123 break; /* start */
91 } while (!rc); 124 else
92 125 {
93 return rc; 126 if (usb_detect())
127 break;
128 else if (!charger_inserted())
129 power_off(); /* charger removed: power down */
130 }
131 } while (1);
94} 132}
95#endif /* HAVE_CHARGING */ 133#endif /* HAVE_CHARGING */
96 134
97#ifdef HAVE_MMC
98int mmc_remove_request(void)
99{
100 /* A dummy function here, we won't access the card
101 before entering USB mode */
102 return 0;
103}
104#endif /* HAVE_MMC */
105
106/* prompt user to plug USB and fix a problem */ 135/* prompt user to plug USB and fix a problem */
107void prompt_usb(const char* msg1, const char* msg2) 136void prompt_usb(const char* msg1, const char* msg2)
108{ 137{
@@ -150,10 +179,7 @@ void main(void)
150#endif 179#endif
151 ) 180 )
152 { 181 {
153 rc = charging_screen(); /* display a "charging" screen */ 182 charging_screen(); /* display a "charging" screen */
154 if (rc == 1) /* charger removed */
155 power_off();
156 /* "On" pressed or USB connected: proceed */
157 show_logo(); /* again, to provide better visual feedback */ 183 show_logo(); /* again, to provide better visual feedback */
158 } 184 }
159#endif 185#endif