X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fpnd_device.c;h=b3cf0c4c6b25f93bbfe09dd0e369decfa4c8d500;hb=5c3c97f377fd3be4ceecf16fba765852d1a9572b;hp=df9e1089af4edb9c98829a9e77a5cb9ee4e4a267;hpb=14fa7e3a9bee2d870cad9aa2046c7a3944e00f03;p=pandora-libraries.git diff --git a/lib/pnd_device.c b/lib/pnd_device.c index df9e108..b3cf0c4 100644 --- a/lib/pnd_device.c +++ b/lib/pnd_device.c @@ -92,6 +92,62 @@ int pnd_device_get_battery_gauge_perc ( void ) { return ( -1 ); } +unsigned char pnd_device_get_charge_current ( int *result ) { + char buffer [ 100 ]; + + if ( pnd_device_open_read_close ( PND_DEVICE_CHARGE_CURRENT, buffer, 100 ) ) { + *result = atoi ( buffer ); + return ( 1 ); + } + + return ( 0 ); +} + +int pnd_device_get_charger_enable ( const char *devices ) { + char fullname [ 100 ]; + char buffer [ 100 ]; + + while ( 1 ) { + if ( sscanf ( devices, "%99s", buffer ) != 1 ) { + break; + } + + while ( isspace ( *devices ) ) + devices++; + devices += strlen ( buffer ); + snprintf ( fullname, sizeof ( fullname ), PND_DEVICE_POWER_BASE "/%s/enable", buffer ); + + /* XXX: only ckecks first good device, but that should be enough for our needs */ + if ( pnd_device_open_read_close ( fullname, buffer, 100 ) ) { + return ( atoi ( buffer ) ); + } + } + + return ( -1 ); +} + +unsigned char pnd_device_set_charger_enable ( const char *devices, unsigned char v ) { + char fullname [ 100 ]; + char buffer [ 100 ]; + int ret = 0; + + while ( 1 ) { + if ( sscanf ( devices, "%99s", buffer ) != 1 ) { + break; + } + + while ( isspace ( *devices ) ) + devices++; + devices += strlen ( buffer ); + snprintf ( fullname, sizeof ( fullname ), PND_DEVICE_POWER_BASE "/%s/enable", buffer ); + + sprintf ( buffer, "%u", v ); + ret |= pnd_device_open_write_close ( fullname, buffer ); + } + + return ( ret ); +} + unsigned char pnd_device_set_led_power_brightness ( unsigned char v ) { char buffer [ 100 ]; @@ -99,3 +155,11 @@ unsigned char pnd_device_set_led_power_brightness ( unsigned char v ) { return ( pnd_device_open_write_close ( PND_DEVICE_LED_POWER PND_DEVICE_LED_SUFFIX_BRIGHTNESS, buffer ) ); } + +unsigned char pnd_device_set_led_charger_brightness ( unsigned char v ) { + char buffer [ 100 ]; + + sprintf ( buffer, "%u", v ); + + return ( pnd_device_open_write_close ( PND_DEVICE_LED_CHARGER PND_DEVICE_LED_SUFFIX_BRIGHTNESS, buffer ) ); +}