blob: f0320db60ca336256a94bf4fb7b958622dc3dee1 [file] [log] [blame]
#include <errno.h>
#include <common.h>
#include <command.h>
#include <linux/types.h>
#ifdef CONFIG_LCD_DISP
#include <asm/arch/pxa1826fb.h>
#endif
#define MAX_LCD_STAGE 20
__weak void lcd_show_battery_stage(int stage) {}
__weak void lcd_show_log(void) {}
u8 bat_20_stage_array[MAX_LCD_STAGE] = {
5, 10, 15, 20, 25, 30, 35, 40, 45, 50,
55, 60, 65, 70, 75, 80, 85, 90, 95, 100
};
static int get_bat_base_stage(int percent)
{
int i;
for(i = 0; i < MAX_LCD_STAGE; i++) {
if (percent < bat_20_stage_array[i])
return i;
else
continue;
}
return i;
}
void lcd_show_bat_charging(int percent)
{
int current_stage;
static int base_stage, disp_stage = 0xffff;
if (percent >= 100) {
lcd_show_battery_stage(MAX_LCD_STAGE);
return;
}
current_stage = get_bat_base_stage(percent);
if (disp_stage == 0xffff) { /* the 1st entry */
disp_stage = current_stage;
base_stage = current_stage;
} else {
/* update base stage */
if (current_stage != base_stage)
base_stage = current_stage;
/* display stage round back */
if (disp_stage > MAX_LCD_STAGE)
disp_stage = base_stage;
}
debug("current_stage: %d\n", current_stage);
debug("disp_stage: %d\n", disp_stage);
debug("base_stage: %d\n", base_stage);
lcd_show_battery_stage(disp_stage);
disp_stage++;
}
void lcd_show_bat_soc(int percent)
{
int base_stage;
if (percent >= 100) {
lcd_show_battery_stage(MAX_LCD_STAGE);
return;
}
base_stage = get_bat_base_stage(percent);
lcd_show_battery_stage(base_stage);
}
void lcd_show_no_battery(void)
{
lcd_show_battery_stage(-1);
}
void lcd_show_mrvl_log(void)
{
lcd_show_log();
}