2 #include <stdio.h> /* for FILE etc */
3 #include <stdlib.h> /* for malloc */
6 #include <sys/types.h> /* for open */
11 #include "pnd_device.h"
13 unsigned char pnd_device_open_write_close ( char *name, char *v ) {
16 if ( ( f = open ( PND_DEVICE_PROC_CLOCK, O_WRONLY /*O_RDONLY*/ ) ) < 0 ) {
20 if ( write ( f, buffer, strlen ( buffer ) ) < strlen ( buffer ) ) {
29 unsigned char pnd_device_open_read_close ( char *name, char *r_buffer, unsigned int buffer_len ) {
32 f = fopen ( name, "r" );
38 if ( ! fgets ( r_buffer, buffer_len, f ) ) {
48 unsigned char pnd_device_set_clock ( unsigned int c ) {
51 sprint ( buffer, "%u", c );
53 return ( pnd_device_open_write_close ( PND_DEVICE_PROC_CLOCK, buffer ) );
56 unsigned int pnd_device_get_clock ( void ) {
59 if ( pnd_device_open_read_close ( PND_DEVICE_PROC_CLOCK, buffer, 100 ) ) {
60 return ( atoi ( buffer ) );
66 unsigned char pnd_device_set_backlight ( unsigned int c ) {
69 sprint ( buffer, "%u", c );
71 return ( pnd_device_open_write_close ( PND_DEVICE_SYS_BACKLIGHT_BRIGHTNESS, buffer ) );
74 unsigned int pnd_device_get_backlight ( void ) {
77 if ( pnd_device_open_read_close ( PND_DEVICE_SYS_BACKLIGHT_BRIGHTNESS, buffer, 100 ) ) {
78 return ( atoi ( buffer ) );