42 }; |
42 }; |
43 |
43 |
44 extern struct lcdDataStruct *lcds [MAX_LCDS]; |
44 extern struct lcdDataStruct *lcds [MAX_LCDS]; |
45 #endif |
45 #endif |
46 extern sys_config Config; |
46 extern sys_config Config; |
47 |
47 extern uint16_t leds; |
48 |
48 |
49 |
49 |
50 /* |
50 /* |
51 * setBacklight: |
51 * setBacklight: |
52 ********************************************************************************* |
52 ********************************************************************************* |
53 */ |
53 */ |
|
54 void setBacklight(int value) |
|
55 { |
54 #ifdef HAVE_WIRINGPI_H |
56 #ifdef HAVE_WIRINGPI_H |
55 void setBacklight (int value) |
57 pinMode (AF_BACKLIGHT, OUTPUT) ; |
56 { |
58 digitalWrite (AF_BACKLIGHT, (value & 1)) ; |
57 pinMode (AF_BACKLIGHT, OUTPUT) ; |
59 #endif |
58 digitalWrite (AF_BACKLIGHT, (value & 1)) ; |
60 if (value) { |
|
61 leds |= SLED_LCD; |
|
62 } else { |
|
63 leds &= ~SLED_LCD; |
|
64 } |
|
65 slcdLEDs(slcdHandle); |
59 } |
66 } |
60 #endif |
|
61 |
67 |
62 |
68 |
63 /* |
69 /* |
64 * initLCD: |
70 * initLCD: |
65 ********************************************************************************* |
71 ********************************************************************************* |
66 */ |
72 */ |
67 |
73 |
68 int initLCD (int cols, int rows) |
74 int initLCD(int cols, int rows) |
69 { |
75 { |
70 if (!((rows == 1) || (rows == 2) || (rows == 4))) { |
76 if (!((rows == 1) || (rows == 2) || (rows == 4))) { |
71 fprintf (stderr, "rows must be 1, 2 or 4\n") ; |
77 fprintf (stderr, "rows must be 1, 2 or 4\n") ; |
72 return EXIT_FAILURE ; |
78 return EXIT_FAILURE ; |
73 } |
79 } |
90 fprintf (stderr, "lcdInit failed\n") ; |
96 fprintf (stderr, "lcdInit failed\n") ; |
91 return -1 ; |
97 return -1 ; |
92 } |
98 } |
93 |
99 |
94 lcdClear (lcdHandle) ; |
100 lcdClear (lcdHandle) ; |
95 setBacklight (1) ; |
|
96 #endif |
101 #endif |
97 |
102 |
98 slcdHandle = slcdInit(0, rows, cols); |
103 slcdHandle = slcdInit(0, rows, cols); |
99 if (slcdHandle < 0) { |
104 if (slcdHandle < 0) { |
100 fprintf (stderr, "slcdInit failed\n") ; |
105 fprintf (stderr, "slcdInit failed\n") ; |
101 return -1; |
106 return -1; |
102 } |
107 } |
103 slcdClear(slcdHandle); |
108 slcdClear(slcdHandle); |
|
109 setBacklight(1); |
104 |
110 |
105 return 0 ; |
111 return 0 ; |
106 } |
112 } |
107 |
113 |
108 |
114 |