mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
rgnano: Voltage and current measure support
Battery time estimation works now. This commit also changes the mksquashfs path to FUNKEY_SDK_PATH. Change-Id: Ic0aa4c40011b0716f1c36c014377eaccb486e841
This commit is contained in:
parent
97ebba1fbd
commit
6f107430f4
5 changed files with 61 additions and 3 deletions
|
@ -13,7 +13,7 @@
|
||||||
/* For Rolo and boot loader */
|
/* For Rolo and boot loader */
|
||||||
#define MODEL_NUMBER 100
|
#define MODEL_NUMBER 100
|
||||||
|
|
||||||
#define MODEL_NAME "RG Nano"
|
#define MODEL_NAME "Anbernic RG Nano"
|
||||||
|
|
||||||
#ifndef SIMULATOR
|
#ifndef SIMULATOR
|
||||||
#define USB_NONE
|
#define USB_NONE
|
||||||
|
@ -60,12 +60,17 @@
|
||||||
#define AB_REPEAT_ENABLE
|
#define AB_REPEAT_ENABLE
|
||||||
|
|
||||||
/* Battery stuff */
|
/* Battery stuff */
|
||||||
#define CONFIG_BATTERY_MEASURE PERCENTAGE_MEASURE
|
#define CONFIG_BATTERY_MEASURE (PERCENTAGE_MEASURE|VOLTAGE_MEASURE|CURRENT_MEASURE)
|
||||||
#define CONFIG_CHARGING CHARGING_MONITOR
|
#define CONFIG_CHARGING CHARGING_MONITOR
|
||||||
#define HAVE_POWEROFF_WHILE_CHARGING
|
#define HAVE_POWEROFF_WHILE_CHARGING
|
||||||
#define BATTERY_DEV_NAME "axp20x-battery"
|
#define BATTERY_DEV_NAME "axp20x-battery"
|
||||||
#define POWER_DEV_NAME "axp20x-usb"
|
#define POWER_DEV_NAME "axp20x-usb"
|
||||||
|
|
||||||
|
#define BATTERY_CAPACITY_DEFAULT 1050 /* default battery capacity */
|
||||||
|
#define BATTERY_CAPACITY_MIN 1050 /* min. capacity selectable */
|
||||||
|
#define BATTERY_CAPACITY_MAX 1050 /* max. capacity selectable */
|
||||||
|
#define BATTERY_CAPACITY_INC 0 /* capacity increment */
|
||||||
|
|
||||||
/* Define this for LCD backlight available */
|
/* Define this for LCD backlight available */
|
||||||
#define BACKLIGHT_RG_NANO
|
#define BACKLIGHT_RG_NANO
|
||||||
#define HAVE_BACKLIGHT
|
#define HAVE_BACKLIGHT
|
||||||
|
|
|
@ -29,9 +29,32 @@
|
||||||
#include "panic.h"
|
#include "panic.h"
|
||||||
#include "sysfs.h"
|
#include "sysfs.h"
|
||||||
|
|
||||||
|
const char * const sysfs_bat_voltage =
|
||||||
|
"/sys/class/power_supply/axp20x-battery/voltage_now";
|
||||||
|
|
||||||
|
const char * const sysfs_bat_current =
|
||||||
|
"/sys/class/power_supply/axp20x-battery/current_now";
|
||||||
|
|
||||||
const char * const sysfs_bat_level =
|
const char * const sysfs_bat_level =
|
||||||
"/sys/class/power_supply/axp20x-battery/capacity";
|
"/sys/class/power_supply/axp20x-battery/capacity";
|
||||||
|
|
||||||
|
unsigned int rgnano_power_get_battery_voltage(void)
|
||||||
|
{
|
||||||
|
int battery_voltage;
|
||||||
|
sysfs_get_int(sysfs_bat_voltage, &battery_voltage);
|
||||||
|
|
||||||
|
return battery_voltage;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int rgnano_power_get_battery_current(void)
|
||||||
|
{
|
||||||
|
int battery_current;
|
||||||
|
sysfs_get_int(sysfs_bat_current, &battery_current);
|
||||||
|
|
||||||
|
/* Current is in microamps */
|
||||||
|
return (battery_current / 1000);
|
||||||
|
}
|
||||||
|
|
||||||
unsigned int rgnano_power_get_battery_capacity(void)
|
unsigned int rgnano_power_get_battery_capacity(void)
|
||||||
{
|
{
|
||||||
int battery_level;
|
int battery_level;
|
||||||
|
|
|
@ -23,5 +23,7 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
unsigned int rgnano_power_get_battery_voltage(void);
|
||||||
|
unsigned int rgnano_power_get_battery_current(void);
|
||||||
unsigned int rgnano_power_get_battery_capacity(void);
|
unsigned int rgnano_power_get_battery_capacity(void);
|
||||||
#endif /* _POWER_RGNANO_H_ */
|
#endif /* _POWER_RGNANO_H_ */
|
||||||
|
|
|
@ -22,6 +22,34 @@
|
||||||
#include "power.h"
|
#include "power.h"
|
||||||
#include "power-rgnano.h"
|
#include "power-rgnano.h"
|
||||||
|
|
||||||
|
/* System handles powering off at 2% */
|
||||||
|
unsigned short battery_level_disksafe = 0;
|
||||||
|
unsigned short battery_level_shutoff = 0;
|
||||||
|
|
||||||
|
/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
|
||||||
|
/* read from /sys/class/power_supply/axp20x-battery/voltage_now */
|
||||||
|
/* in 5s intervals and averaged out */
|
||||||
|
unsigned short percent_to_volt_discharge[11] =
|
||||||
|
{
|
||||||
|
3400, 3597, 3665, 3701, 3736, 3777, 3824, 3882, 3944, 4023, 4162
|
||||||
|
};
|
||||||
|
|
||||||
|
/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
|
||||||
|
unsigned short percent_to_volt_charge[11] =
|
||||||
|
{
|
||||||
|
3512, 3729, 3795, 3831, 3865, 3906, 3953, 4010, 4072, 4150, 4186
|
||||||
|
};
|
||||||
|
|
||||||
|
int _battery_voltage(void)
|
||||||
|
{
|
||||||
|
return rgnano_power_get_battery_voltage();
|
||||||
|
}
|
||||||
|
|
||||||
|
int _battery_current(void)
|
||||||
|
{
|
||||||
|
return rgnano_power_get_battery_current();
|
||||||
|
}
|
||||||
|
|
||||||
int _battery_level(void)
|
int _battery_level(void)
|
||||||
{
|
{
|
||||||
return rgnano_power_get_battery_capacity();
|
return rgnano_power_get_battery_capacity();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
RG_NANO_DIR=$(ROOTDIR)/packaging/rgnano
|
RG_NANO_DIR=$(ROOTDIR)/packaging/rgnano
|
||||||
MKSQUASHFS=$(dir $(CPP))mksquashfs
|
MKSQUASHFS=$(FUNKEY_SDK_PATH)/bin/mksquashfs
|
||||||
INSTALL_DIR=$(OPK_BUILD_DIR)/install
|
INSTALL_DIR=$(OPK_BUILD_DIR)/install
|
||||||
OPK_BUILD_DIR=opkdir
|
OPK_BUILD_DIR=opkdir
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue