Lines 45-54
Link Here
|
45 |
#define GET_BIT 2 |
45 |
#define GET_BIT 2 |
46 |
#define INC_BIT 4 |
46 |
#define INC_BIT 4 |
47 |
#define DEC_BIT 8 |
47 |
#define DEC_BIT 8 |
|
|
48 |
#define FAD_BIT 16 |
49 |
#define DEL_BIT 32 |
48 |
|
50 |
|
49 |
static struct option long_opts[] = { |
51 |
static struct option long_opts[] = { |
50 |
{ "get" , no_argument , 0, 'g' }, |
52 |
{ "get" , no_argument , 0, 'g' }, |
51 |
{ "set" , required_argument, 0, 's' }, |
53 |
{ "set" , required_argument, 0, 's' }, |
|
|
54 |
{ "fade" , required_argument, 0, 'f' }, |
55 |
{ "delay" , required_argument, 0, 'e' }, |
52 |
{ "increase", no_argument , 0, 'i' }, |
56 |
{ "increase", no_argument , 0, 'i' }, |
53 |
{ "decrease", no_argument , 0, 'd' }, |
57 |
{ "decrease", no_argument , 0, 'd' }, |
54 |
{ "help" , no_argument , 0, 'h' }, |
58 |
{ "help" , no_argument , 0, 'h' }, |
Lines 62-67
Link Here
|
62 |
printf("Options:\n"); |
66 |
printf("Options:\n"); |
63 |
printf("\t-g --get\t\tQuery brightness level.\n"); |
67 |
printf("\t-g --get\t\tQuery brightness level.\n"); |
64 |
printf("\t-s --set <level>\tSet brightness level (15-100)\n"); |
68 |
printf("\t-s --set <level>\tSet brightness level (15-100)\n"); |
|
|
69 |
printf("\t-f --fade <level>\tFade in/out to brightness level (15-100)\n"); |
70 |
printf("\t-e --delay <level>\tFade cycle delay (usecs)\n"); |
65 |
printf("\t-i --increase\t\tIncrease brightness with one level.\n"); |
71 |
printf("\t-i --increase\t\tIncrease brightness with one level.\n"); |
66 |
printf("\t-d --decrease\t\tDecrease brightness with one level.\n"); |
72 |
printf("\t-d --decrease\t\tDecrease brightness with one level.\n"); |
67 |
printf("\t-h --help\t\tPrints this help text.\n\n"); |
73 |
printf("\t-h --help\t\tPrints this help text.\n\n"); |
Lines 83-88
Link Here
|
83 |
{ |
89 |
{ |
84 |
int optind = 0, options = 0, setvalue = 0; |
90 |
int optind = 0, options = 0, setvalue = 0; |
85 |
int c; |
91 |
int c; |
|
|
92 |
unsigned long delay = 7000; |
86 |
|
93 |
|
87 |
if (argc < 2) |
94 |
if (argc < 2) |
88 |
{ |
95 |
{ |
Lines 90-96
Link Here
|
90 |
return 0; |
97 |
return 0; |
91 |
} |
98 |
} |
92 |
|
99 |
|
93 |
while ((c = getopt_long(argc, argv, "gs:idh", long_opts, &optind)) != -1) |
100 |
while ((c = getopt_long(argc, argv, "gs:f:e:idh", long_opts, &optind)) != -1) |
94 |
{ |
101 |
{ |
95 |
switch (c) |
102 |
switch (c) |
96 |
{ |
103 |
{ |
Lines 113-118
Link Here
|
113 |
return 1; |
120 |
return 1; |
114 |
} |
121 |
} |
115 |
break; |
122 |
break; |
|
|
123 |
case 'f': |
124 |
if (isdigit(*optarg)) { |
125 |
setvalue = atoi(optarg); |
126 |
options |= FAD_BIT; |
127 |
} else { |
128 |
fprintf(stderr, "Illegal option value (-f): " |
129 |
"Value has to be a non-negative number.\n"); |
130 |
return 1; |
131 |
} |
132 |
break; |
133 |
case 'e': |
134 |
if (isdigit(*optarg)) { |
135 |
delay = atoi(optarg); |
136 |
options |= DEL_BIT; |
137 |
} else { |
138 |
fprintf(stderr, "Illegal option value (-d): " |
139 |
"Value has to be a non-negative number.\n"); |
140 |
return 1; |
141 |
} |
142 |
break; |
116 |
case 'i': |
143 |
case 'i': |
117 |
options |= INC_BIT; |
144 |
options |= INC_BIT; |
118 |
break; |
145 |
break; |
Lines 154-159
Link Here
|
154 |
if (options & SET_BIT) |
181 |
if (options & SET_BIT) |
155 |
nv_card->set_smartdimmer(setvalue); |
182 |
nv_card->set_smartdimmer(setvalue); |
156 |
|
183 |
|
|
|
184 |
if (options & FAD_BIT) |
185 |
nv_card->fade_smartdimmer(setvalue, delay); |
186 |
|
157 |
if (options & GET_BIT) |
187 |
if (options & GET_BIT) |
158 |
printf("SmartDimmer level: %d\n", nv_card->get_smartdimmer()); |
188 |
printf("SmartDimmer level: %d\n", nv_card->get_smartdimmer()); |
159 |
|
189 |
|