1 /* LED simulation support -- print them in tabbed columns
3 * This file is part of 0cpm Firmerware.
5 * 0cpm Firmerware is Copyright (c)2011 Rick van Rein, OpenFortress.
7 * 0cpm Firmerware is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation, version 3.
11 * 0cpm Firmerware is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with 0cpm Firmerware. If not, see <http://www.gnu.org/licenses/>.
22 /* Descriptions below are all restricted to 7 chars or less, so they
23 * can be printed with a '\t' in between.
25 * From: Rick van Rein <rick@openfortress.nl>
35 #include <0cpm/cons.h>
38 char *led_colours_2 [] = { "off", "green" };
39 char *led_colours_3 [] = { "off", "green", "red" };
48 * LED descriptive structure, following the structure of led.h
50 struct led_descript num2descr [] = {
52 # if NUM_LINEKEYS >= 1
53 { "line1", led_colours_3, NULL, },
55 # if NUM_LINEKEYS >= 2
56 { "line2", led_colours_3, NULL, },
58 # if NUM_LINEKEYS >= 3
59 { "line3", led_colours_3, NULL, },
61 # if NUM_LINEKEYS >= 4
62 { "line4", led_colours_3, NULL, },
64 # if NUM_LINEKEYS >= 5
65 { "line5", led_colours_3, NULL, },
67 # if NUM_LINEKEYS >= 6
68 { "line6", led_colours_3, NULL, },
70 # if NUM_LINEKEYS >= 7
71 # error "Please define additional line LEDs in ledsimu.c"
75 # error "Please define generic LEDs in ledsimu.c"
78 { "vmail", led_colours_2, NULL, },
81 { "mute", led_colours_2, NULL, },
84 { "handset", led_colours_2, NULL, },
87 { "headset", led_colours_2, NULL, },
89 #if HAVE_LED_SPEAKERPHONE
90 { "speaker", led_colours_2, NULL, },
92 #if HAVE_LED_BACKLIGHT
93 { "display", led_colours_2, NULL, },
98 void bottom_led_set (led_idx_t lednum, led_colour_t col) {
101 gettimeofday (&tv, NULL);
103 if (headctr++ % 20 == 0) {
104 for (i = 0; i < LED_IDX_COUNT; i++) {
105 bottom_printf ("\t%s", num2descr [i].name);
107 bottom_printf ("\n");
109 bottom_printf ("%3d.%03d", tv.tv_sec, tv.tv_usec / 1000);
111 char *colnm = num2descr [lednum].states [col];
112 for (i = 0; i < 7; i++) {
113 if (colnm [i] == 0) {
116 capscol [i] = toupper (colnm [i]);
119 for (i = 0; i < LED_IDX_COUNT; i++) {
122 } else if (num2descr [lednum].current != NULL) {
123 colnm = num2descr [lednum].current;
127 bottom_printf ("\t%s", colnm);
129 bottom_printf ("\n");