--- /dev/null
+#include <stdio.h>
+#include <stdint.h>
+#include "button.h"
+#include "mg_log.h"
+
+char * btn_name[]={
+ "BUTTON_1",
+ "BUTTON_2",
+ "BUTTON_3",
+ "BUTTON_4",
+ "BUTTON_5",
+ "BUTTON_6",
+ "BUTTON_7",
+ "BUTTON_8",
+};
+
+static char btn_code_str[100];
+static char btn_event_str[100];
+char * btn_code_name( uint32_t btn_code )
+{
+ char *p;
+ p = btn_code_str;
+ *p = 0;
+
+ if( btn_code&BUTTON_1 ){ if( strlen(p)) strcat( p, "+" ); strcat( p, "BUTTON_1" ); }
+ if( btn_code&BUTTON_2 ){ if( strlen(p)) strcat( p, "+" ); strcat( p, "BUTTON_2" ); }
+ if( btn_code&BUTTON_3 ){ if( strlen(p)) strcat( p, "+" ); strcat( p, "BUTTON_3" ); }
+ if( btn_code&BUTTON_4 ){ if( strlen(p)) strcat( p, "+" ); strcat( p, "BUTTON_4" ); }
+ if( btn_code&BUTTON_5 ){ if( strlen(p)) strcat( p, "+" ); strcat( p, "BUTTON_5" ); }
+ if( btn_code&BUTTON_6 ){ if( strlen(p)) strcat( p, "+" ); strcat( p, "BUTTON_6" ); }
+ if( btn_code&BUTTON_7 ){ if( strlen(p)) strcat( p, "+" ); strcat( p, "BUTTON_7" ); }
+ if( btn_code&BUTTON_8 ){ if( strlen(p)) strcat( p, "+" ); strcat( p, "BUTTON_8" ); }
+ return p;
+}
+
+char * btn_event_name( uint32_t btn_event )
+{
+ char *p;
+
+ p = btn_event_str;
+ *p = 0;
+
+ if( btn_event&EVENT_SINGLE_CLICK ){ if( strlen(p)) strcat( p, "+" ); strcat( p, "EVENT_SINGLE_CLICK" ); }
+ if( btn_event&EVENT_DOUBLE_CLICK ){ if( strlen(p)) strcat( p, "+" ); strcat( p, "EVENT_DOUBLE_CLICK" ); }
+ if( btn_event&EVENT_LONG_PRESS ){ if( strlen(p)) strcat( p, "+" ); strcat( p, "EVENT_LONG_PRESS" ); }
+ if( btn_event&EVENT_LONG_PRESS_2S ){ if( strlen(p)) strcat( p, "+" ); strcat( p, "EVENT_LONG_PRESS_2S" ); }
+ if( btn_event&EVENT_LONG_PRESS_5S ){ if( strlen(p)) strcat( p, "+" ); strcat( p, "EVENT_LONG_PRESS_5S" ); }
+ if( btn_event&EVENT_LONG_PRESS_UP ){ if( strlen(p)) strcat( p, "+" ); strcat( p, "EVENT_LONG_PRESS_UP" ); }
+ if( btn_event&EVENT_COMB_PRESS ){ if( strlen(p)) strcat( p, "+" ); strcat( p, "EVENT_COMB_PRESS" ); }
+ if( btn_event&EVENT_COMB_PRESS_2S ){ if( strlen(p)) strcat( p, "+" ); strcat( p, "EVENT_COMB_PRESS_2S" ); }
+ if( btn_event&EVENT_COMB_PRESS_5S ){ if( strlen(p)) strcat( p, "+" ); strcat( p, "EVENT_COMB_PRESS_5S" ); }
+
+ return p;
+}
+
+static void button_single_cb( button_code_t btn_code, button_event_t btn_event, void* value )
+{
+ printf( "Single BTN--code:[%s], event:[%s], value:%p\n", btn_code_name(btn_code), btn_event_name(btn_event), value );
+}
+
+static void button_comb_cb( button_code_t btn_code, button_event_t btn_event, void* value )
+{
+ printf( "COMB BTN--code:%x, event:%x, value:%p\n", btn_code, btn_event, value );
+}
+
+int main( void )
+{
+ btn_ctrl_t btn;
+ btn = mg_button_open("/dev/input/by-path/platform-gpio_keys-event" );
+ if( !btn ){
+ perror( "open button fail!\n" );
+ exit(0);
+ }
+
+ printf( "register all single button event!\n" );
+ mg_button_event_register( btn, 0xFF, EVENT_SINGLE_CLICK|EVENT_DOUBLE_CLICK|EVENT_LONG_PRESS|EVENT_LONG_PRESS_UP, button_single_cb );
+ printf( "register button_7+button_8 event!\n" );
+ mg_button_event_combonation_register( btn, BUTTON_7|BUTTON_8, EVENT_COMB_PRESS_5S, 0, button_comb_cb );
+ printf( "register button_2+button_7 event!\n" );
+ mg_button_event_combonation_register( btn, BUTTON_2|BUTTON_7, EVENT_COMB_PRESS_2S, 0, button_comb_cb );
+
+ while(1){
+ sleep(2);
+ }
+ mg_button_close( btn );
+ exit(0);
+}
+
--- /dev/null
+
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <signal.h>
+#include <time.h>
+#include "led.h"
+#include "mg_log.h"
+#include "pthread.h"
+#include "semaphore.h"
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <getopt.h>
+
+#if 0
+char* usage_str = ""
+"Usage: light_test [option] ...\n"
+"Options:\n"
+"\t -t, --type n -- 0:KEY LED 1:ATMOS LED 2:IR LED 3: RING LED\n"
+"\t -i, --index n -- KEY LED:1-8, ATMOS LED:1-5, IR LED:0 RING LED:0\n"
+"\t -o, --output n -- 0:off, 1:on, 2:flash, 3:breath, 4:slow on, 5slow off\n"
+"\t --on_ms n -- \n"
+"\t --off_ms n -- \n"
+"\t --brightness n -- 0-100 \n"
+"\t -h, --help\n"
+"\n";
+
+
+void disp_usage( void )
+{
+ printf( usage_str );
+}
+
+int lopt;
+struct option opts[] = {
+ {"type", required_argument, 0, 't' },
+ {"help", no_argument, NULL, 'h' },
+ {},
+
+};
+#endif
+
+int main( int argc, char ** argv )
+{
+ light_ctrl_t light = mg_led_open();
+ if( !light ){
+ perror( "open led fail!\n" );
+ exit(0);
+ }
+printf( "open key led 1 ...\n" );
+ key_led_on( light, LED_ID_KEY_1, 0, 100, 1000 );
+ sleep(1);
+printf( "open key led 2 ...\n" );
+ key_led_off( light, LED_ID_KEY_1, 100, 0, 1000 );
+ key_led_on( light, LED_ID_KEY_2, 0, 100, 1000 );
+ sleep(1);
+printf( "open key led 3 ...\n" );
+ key_led_off( light, LED_ID_KEY_2, 100, 0, 1000 );
+ key_led_on( light, LED_ID_KEY_3, 0, 100, 1000 );
+ sleep(1);
+printf( "open key led 4 ...\n" );
+ key_led_off( light, LED_ID_KEY_3, 100, 0, 1000 );
+ key_led_on( light, LED_ID_KEY_4, 0, 100, 1000 );
+ sleep(1);
+printf( "open key led 5 ...\n" );
+ key_led_off( light, LED_ID_KEY_4, 100, 0, 1000 );
+ key_led_on( light, LED_ID_KEY_5, 0, 100, 1000 );
+ sleep(1);
+printf( "open key led 6 ...\n" );
+ key_led_off( light, LED_ID_KEY_5, 100, 0, 1000 );
+ key_led_on( light, LED_ID_KEY_6, 0, 100, 1000 );
+ sleep(1);
+printf( "open key led 7 ...\n" );
+ key_led_off( light, LED_ID_KEY_6, 100, 0, 1000 );
+ key_led_on( light, LED_ID_KEY_7, 0, 100, 1000 );
+ sleep(1);
+printf( "open key led 8 ...\n" );
+ key_led_off( light, LED_ID_KEY_7, 100, 0, 1000 );
+ key_led_on( light, LED_ID_KEY_8, 0, 100, 1000 );
+ sleep(1);
+ key_led_off( light, LED_ID_KEY_8, 100, 0, 1000 );
+
+printf( "open atmos led 1 ...\n" );
+ atmos_led_on( light, LED_ID_ATMOS_1, 0, 100, 1000 );
+ sleep(1);
+printf( "open atmos led 2 ...\n" );
+ atmos_led_off( light, LED_ID_ATMOS_1, 100, 0, 1000 );
+ atmos_led_on( light, LED_ID_ATMOS_2, 0, 100, 1000 );
+ sleep(1);
+printf( "open atmos led 3 ...\n" );
+ atmos_led_off( light, LED_ID_ATMOS_2, 100, 0, 1000 );
+ atmos_led_on( light, LED_ID_ATMOS_3, 0, 100, 1000 );
+ sleep(1);
+printf( "open atmos led 4 ...\n" );
+ atmos_led_off( light, LED_ID_ATMOS_3, 100, 0, 1000 );
+ atmos_led_on( light, LED_ID_ATMOS_4, 0, 100, 1000 );
+ sleep(1);
+printf( "open atmos led 5 ...\n" );
+ atmos_led_off( light, LED_ID_ATMOS_4, 100, 0, 1000 );
+ atmos_led_on( light, LED_ID_ATMOS_5, 0, 100, 1000 );
+ sleep(1);
+ atmos_led_off( light, LED_ID_ATMOS_5, 100, 0, 1000 );
+
+printf( "key led flash period 1s ...\n" );
+ atmos_led_flash( light, LED_ID_KEY_ALL, 1000, 0 );
+
+printf( "atmos led flash period 2s ...\n" );
+ atmos_led_flash( light, LED_ID_ATMOS_ALL, 2000, 0 );
+
+printf( "open ir led ...\n" );
+ ir_led_on( light, 100 );
+ sleep(1);
+ //ir_led_off( light, 100 );
+printf( "ring led flash period 1s ...\n" );
+ ring_led_flash( light, 1000, 5000 );
+ sleep(5);
+printf( "ring led breath period 1s ...\n" );
+ ring_led_breath( light, 1000, 0 );
+
+ while( 1 )
+ sleep(1);
+
+ return 0;
+}
+
+