|
@@ -23,6 +23,7 @@ void light_defaultConfig()
|
23
|
23
|
LIGHT_BOOL light_parseArguments(int argc, char** argv)
|
24
|
24
|
{
|
25
|
25
|
int currFlag;
|
|
26
|
+ int verbosity;
|
26
|
27
|
|
27
|
28
|
LIGHT_BOOL opSet = FALSE;
|
28
|
29
|
LIGHT_BOOL targetSet = FALSE;
|
|
@@ -133,18 +134,19 @@ LIGHT_BOOL light_parseArguments(int argc, char** argv)
|
133
|
134
|
light_printHelp();
|
134
|
135
|
return FALSE;
|
135
|
136
|
}
|
136
|
|
- if(sscanf(optarg, "%i", &light_verbosity) != 1)
|
|
137
|
+ if(sscanf(optarg, "%i", &verbosity) != 1)
|
137
|
138
|
{
|
138
|
139
|
printf("-v Verbosity is not specified in a recognizable format.\n\n");
|
139
|
140
|
light_printHelp();
|
140
|
141
|
return FALSE;
|
141
|
142
|
}
|
142
|
|
- if(light_verbosity < 0 || light_verbosity > 3)
|
|
143
|
+ if(verbosity < 0 || verbosity > 3)
|
143
|
144
|
{
|
144
|
145
|
printf("-v Verbosity has to be between 0 and 3.\n\n");
|
145
|
146
|
light_printHelp();
|
146
|
147
|
return FALSE;
|
147
|
148
|
}
|
|
149
|
+ light_verbosity = (LIGHT_LOG_LEVEL)verbosity;
|
148
|
150
|
break;
|
149
|
151
|
}
|
150
|
152
|
}
|
|
@@ -283,11 +285,11 @@ LIGHT_BOOL light_initialize(int argc, char** argv)
|
283
|
285
|
}
|
284
|
286
|
else if(!light_controllerAccessible(light_Configuration.specifiedController))
|
285
|
287
|
{
|
286
|
|
- LIGHT_ERR("selected controller is not valid, make sure this application is run as root.");
|
|
288
|
+ LIGHT_ERR_FMT("selected controller '%s' is not valid",
|
|
289
|
+ light_Configuration.specifiedController);
|
287
|
290
|
return FALSE;
|
288
|
291
|
}
|
289
|
292
|
|
290
|
|
-
|
291
|
293
|
return TRUE;
|
292
|
294
|
}
|
293
|
295
|
|
|
@@ -334,6 +336,7 @@ LIGHT_BOOL light_execute()
|
334
|
336
|
}
|
335
|
337
|
|
336
|
338
|
/* Prepare variables */
|
|
339
|
+ LIGHT_NOTE_FMT("Executing light on '%s' controller", light_Configuration.specifiedController);
|
337
|
340
|
|
338
|
341
|
/* -- First, get the current, min and max values directly from controller/configuration (raw values) */
|
339
|
342
|
if(!light_getBrightness(light_Configuration.specifiedController, &rawCurr))
|
|
@@ -356,7 +359,8 @@ LIGHT_BOOL light_execute()
|
356
|
359
|
|
357
|
360
|
if( hasMinCap && minCap > rawMax )
|
358
|
361
|
{
|
359
|
|
- LIGHT_WARN("invalid minimum cap for controller, ignoring and using 0");
|
|
362
|
+ LIGHT_WARN_FMT("invalid minimum cap (raw) value of '%lu' for controller, ignoring and using 0", minCap);
|
|
363
|
+ LIGHT_WARN_FMT("minimum cap must be inferior to '%lu'", rawMax);
|
360
|
364
|
minCap = 0;
|
361
|
365
|
}
|
362
|
366
|
|
|
@@ -428,7 +432,7 @@ LIGHT_BOOL light_execute()
|
428
|
432
|
/* If we are not attempting to set, fail! */
|
429
|
433
|
if(light_Configuration.operationMode != LIGHT_SET)
|
430
|
434
|
{
|
431
|
|
- printf("Minimum cap can only be used with get/set operations.\n");
|
|
435
|
+ fprintf(stderr, "Minimum cap can only be used with get/set operations.\n");
|
432
|
436
|
return FALSE;
|
433
|
437
|
}
|
434
|
438
|
|
|
@@ -483,7 +487,7 @@ LIGHT_BOOL light_execute()
|
483
|
487
|
|
484
|
488
|
}else{
|
485
|
489
|
/* If we didn't provide a valid target for write operations, fail. */
|
486
|
|
- printf("set/add/subtract operations are only available for brightness and minimum cap files.\n");
|
|
490
|
+ fprintf(stderr, "set/add/subtract operations are only available for brightness and minimum cap files.\n");
|
487
|
491
|
return FALSE;
|
488
|
492
|
}
|
489
|
493
|
}
|
|
@@ -508,9 +512,9 @@ LIGHT_BOOL light_execute()
|
508
|
512
|
return TRUE;
|
509
|
513
|
}
|
510
|
514
|
|
511
|
|
- printf("Controller: %s\nValueRaw: %lu\nValuePercent: %.2f\nOpMode: %u\nValMode: %u\nTarget: %u\n\n", light_Configuration.specifiedController, light_Configuration.specifiedValueRaw, light_Configuration.specifiedValuePercent, light_Configuration.operationMode, light_Configuration.valueMode, light_Configuration.target);
|
|
515
|
+ fprintf(stderr, "Controller: %s\nValueRaw: %lu\nValuePercent: %.2f\nOpMode: %u\nValMode: %u\nTarget: %u\n\n", light_Configuration.specifiedController, light_Configuration.specifiedValueRaw, light_Configuration.specifiedValuePercent, light_Configuration.operationMode, light_Configuration.valueMode, light_Configuration.target);
|
512
|
516
|
|
513
|
|
- printf("You did not specify a valid combination of commandline arguments. Have some help: \n");
|
|
517
|
+ fprintf(stderr, "You did not specify a valid combination of commandline arguments. Have some help: \n");
|
514
|
518
|
light_printHelp();
|
515
|
519
|
return FALSE;
|
516
|
520
|
}
|
|
@@ -599,7 +603,7 @@ LIGHT_BOOL light_getBrightness(char const *controller, unsigned long *v)
|
599
|
603
|
{
|
600
|
604
|
return FALSE;
|
601
|
605
|
}
|
602
|
|
- LIGHT_NOTE(brightnessPath)
|
|
606
|
+
|
603
|
607
|
readVal = light_readULong( brightnessPath , v);
|
604
|
608
|
free(brightnessPath);
|
605
|
609
|
|
|
@@ -744,7 +748,7 @@ LIGHT_BOOL light_iterateControllers()
|
744
|
748
|
}
|
745
|
749
|
if(light_iteratorDir == NULL)
|
746
|
750
|
{
|
747
|
|
- LIGHT_ERR("could not open backlight or leds directory");
|
|
751
|
+ LIGHT_ERR("could not open backlight or leds directory in /sys/class");
|
748
|
752
|
return FALSE;
|
749
|
753
|
}
|
750
|
754
|
}
|
|
@@ -785,6 +789,7 @@ LIGHT_BOOL light_getBestController(char *controller)
|
785
|
789
|
{
|
786
|
790
|
unsigned long currVal = 0;
|
787
|
791
|
|
|
792
|
+ LIGHT_NOTE_FMT("found '%s' controller", light_currentController);
|
788
|
793
|
if(light_controllerAccessible(light_currentController))
|
789
|
794
|
{
|
790
|
795
|
|