Site Tools


Hotfix release available: 2024-02-06a "Kaos". upgrade now! [55.1] (what's this?)
New release available: 2024-02-06 "Kaos". upgrade now! [55] (what's this?)
Hotfix release available: 2023-04-04a "Jack Jackrum". upgrade now! [54.1] (what's this?)
New release available: 2023-04-04 "Jack Jackrum". upgrade now! [54] (what's this?)
Hotfix release available: 2022-07-31b "Igor". upgrade now! [53.1] (what's this?)
Hotfix release available: 2022-07-31a "Igor". upgrade now! [53] (what's this?)
New release available: 2022-07-31 "Igor". upgrade now! [52.2] (what's this?)
New release candidate 2 available: rc2022-06-26 "Igor". upgrade now! [52.1] (what's this?)
New release candidate available: 2022-06-26 "Igor". upgrade now! [52] (what's this?)
Hotfix release available: 2020-07-29a "Hogfather". upgrade now! [51.4] (what's this?)
New release available: 2020-07-29 "Hogfather". upgrade now! [51.3] (what's this?)
New release candidate 3 available: 2020-06-09 "Hogfather". upgrade now! [51.2] (what's this?)
New release candidate 2 available: 2020-06-01 "Hogfather". upgrade now! [51.1] (what's this?)
New release candidate available: 2020-06-01 "Hogfather". upgrade now! [51] (what's this?)
Hotfix release available: 2018-04-22c "Greebo". upgrade now! [50.3] (what's this?)
Hotfix release available: 2018-04-22b "Greebo". upgrade now! [50.2] (what's this?)
Hotfix release available: 2018-04-22a "Greebo". upgrade now! [50.1] (what's this?)
New release available: 2018-04-22 "Greebo". upgrade now! [50] (what's this?)
Hotfix release available: 2017-02-19g "Frusterick Manners". upgrade now! [49.7] (what's this?)
Hotfix release available: 2017-02-19f "Frusterick Manners". upgrade now! [49.6] (what's this?)
Hotfix release available: 2017-02-19e "Frusterick Manners". upgrade now! [49.5] (what's this?)
Hotfix release available fixing CVE-2017-12979 and CVE-2017-12980: 2017-02-19d "Frusterick Manners". upgrade now! [49.4] (what's this?)
Hotfix release available fixing CVE-2017-12583: 2017-02-19c "Frusterick Manners". upgrade now! [49.3] (what's this?)
key_back_light_api

API Application Example

API Header file

#ifndef	__KEY_BACK_LIGHT_H__
#define	__KEY_BACK_LIGHT_H__

#include	<stdint.h>		/* uint??_t */
#include	<stdbool.h>		/* Bool */
/***************************************************************************/
/*	For Key Pad Back Light
*/
/***************************************************************************/
//	#define	DEVICE_KEY_BACK_LIGHT_DEBUG_MESSAGE

#define	DEVICE_LED_KEY_BACK_LIGHT	"/sys/class/leds/key_light/brightness"


/*	Key Back Light On/Off
Input
	true = Key Back Light On
	false= Key Back Light Off
Return
	0	= Ok to control(On/Off)
	-1	= Input Parameter Error
	-2	= Fail to Access Device
	-3	= Fail to Operation
*/
extern	int	key_back_light(bool Switch/*true=on, false=Off*/);

/*	get Key Back Light state
Return
	0	= Ok to read state
	-1	= Input Parameter Error
	-2	= Fail to Access Device
	-3	= Fail to Operation

*pIsOn	: true = Key Back Light is On, false = Key Back Light is Off
*/
extern	int key_back_light_is_on(bool *pIsOn);

#endif	/* __KEY_BACK_LIGHT_H__ */

API Source File

#include	<stdio.h>
#include	<stdint.h>		/* uint??_t */
#include	<stdbool.h>		/* bool */
#include	<stdlib.h>		/* strtoul */
#include	<string.h>		/* for memset */
#include	<unistd.h>		/* for open/close .. */
#include	<fcntl.h>		/* for O_RDWR */
#include	<sys/ioctl.h>	/* for ioctl */
#include	<sys/fcntl.h>	/* for O_RDWR */

#include	"KeyBackLight.h"

/*	Key Back Light On/Off
Input
	true = Key Back Light On
	false= Key Back Light Off
Return
	0	= Opened
	-1	= Input Parameter Error
	-2	= Fail to Access Device
	-3	= Fail to Operation
*/
int	key_back_light(bool Switch/*true=on, false=Off*/)
{
	FILE *	pDeviceFile;
	char	pString[2] = { 0, 0 };
	int		StringLength;

	pDeviceFile = fopen ( DEVICE_LED_KEY_BACK_LIGHT, "w+");
	if ( pDeviceFile == (FILE *)0 )
	{
#ifdef	DEVICE_KEY_BACK_LIGHT_DEBUG_MESSAGE
		printf ( "Failed To Access Key Pad Back Light Device : %s\n", DEVICE_LED_KEY_BACK_LIGHT );
#endif	/* DEVICE_KEY_BACK_LIGHT_DEBUG_MESSAGE */
		return	-2;
	}

	if ( Switch == true )
	{
		pString[0] = '1';
	}
	else
	{
		pString[0] = '0';
	}
	StringLength = (int)strlen(pString);
	if ( fwrite ( pString, StringLength, 1, pDeviceFile ) < 0 )
	{
#ifdef	DEVICE_KEY_BACK_LIGHT_DEBUG_MESSAGE
		printf ( "Failed To Control Key Pad Back Light\n" );
#endif	/* DEVICE_KEY_BACK_LIGHT_DEBUG_MESSAGE */
		return	-3;
	}

	fclose ( pDeviceFile );

	return	0;
}


/*	get Key Back Light state
Return
	0	= Opened
	-1	= Input Parameter Error
	-2	= Fail to Access Device
	-3	= Fail to Operation

*pIsOn	: true = Key Back Light is On, false = Key Back Light is Off
*/
int key_back_light_is_on(bool *pIsOn)
{
	FILE *	pDeviceFile;
	char	pCommand[128] = {0};
	char	pString[10] = {0};
	int		Value;

	if ( pIsOn == (bool *)0 )
	{
#ifdef	DEVICE_KEY_BACK_LIGHT_DEBUG_MESSAGE
		printf( "key_back_light_is_on() : Input Parameter Error\n" );
#endif	/* DEVICE_KEY_BACK_LIGHT_DEBUG_MESSAGE */
		return	-1;
	}

	sprintf(pCommand, "cat %s", DEVICE_LED_KEY_BACK_LIGHT);
	pDeviceFile = popen(pCommand, "r");
	if ( pDeviceFile == (FILE *)0 )
	{
#ifdef	DEVICE_KEY_BACK_LIGHT_DEBUG_MESSAGE
		printf ( "Failed To Access Key Pad Back Light Device : %s\n", DEVICE_LED_KEY_BACK_LIGHT );
#endif	/* DEVICE_KEY_BACK_LIGHT_DEBUG_MESSAGE */
		return	-2;
	}

	while( fgets (pString, 10, pDeviceFile) );
	Value = (uint32_t) strtoul( pString, NULL, 10 );
	fclose (pDeviceFile);

	*pIsOn = ((Value == 0) ? false:true);

	return	0;
}
key_back_light_api.txt · Last modified: 2017/09/25 22:47 by 1.241.172.144