diff options
Diffstat (limited to 'keyboards/pearl/pearl.c')
-rw-r--r-- | keyboards/pearl/pearl.c | 67 |
1 files changed, 49 insertions, 18 deletions
diff --git a/keyboards/pearl/pearl.c b/keyboards/pearl/pearl.c index 3bbadb0a7..c8cd8a860 100644 --- a/keyboards/pearl/pearl.c +++ b/keyboards/pearl/pearl.c | |||
@@ -15,16 +15,11 @@ You should have received a copy of the GNU General Public License | |||
15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | */ | 16 | */ |
17 | 17 | ||
18 | #include "pearl.h" | ||
19 | #include "rgblight.h" | 18 | #include "rgblight.h" |
20 | #include "backlight.h" | 19 | #include "i2c_master.h" |
21 | |||
22 | #include <avr/pgmspace.h> | ||
23 | |||
24 | #include "action_layer.h" | ||
25 | #include "i2c.h" | ||
26 | #include "quantum.h" | 20 | #include "quantum.h" |
27 | 21 | ||
22 | #ifdef RGBLIGHT_ENABLE | ||
28 | extern rgblight_config_t rgblight_config; | 23 | extern rgblight_config_t rgblight_config; |
29 | 24 | ||
30 | void rgblight_set(void) { | 25 | void rgblight_set(void) { |
@@ -37,23 +32,59 @@ void rgblight_set(void) { | |||
37 | } | 32 | } |
38 | 33 | ||
39 | i2c_init(); | 34 | i2c_init(); |
40 | i2c_send(0xb0, (uint8_t*)led, 3 * RGBLED_NUM); | 35 | i2c_transmit(0xb0, (uint8_t*)led, 3 * RGBLED_NUM, 100); |
41 | } | 36 | } |
37 | #endif | ||
42 | 38 | ||
43 | void backlight_init_ports(void) { | 39 | void matrix_init_kb(void) { |
44 | DDRD |= (1<<4); | 40 | #ifdef RGBLIGHT_ENABLE |
45 | PORTD &= ~(1<<4); | 41 | if (rgblight_config.enable) { |
42 | i2c_init(); | ||
43 | i2c_transmit(0xb0, (uint8_t*)led, 3 * RGBLED_NUM, 100); | ||
44 | } | ||
45 | #endif | ||
46 | // call user level keymaps, if any | ||
47 | matrix_init_user(); | ||
46 | } | 48 | } |
47 | 49 | ||
48 | void backlight_set(uint8_t level) { | 50 | void matrix_scan_kb(void) { |
49 | if (level > 0) { | 51 | #ifdef RGBLIGHT_ENABLE |
50 | PORTD |= (1<<4); | 52 | rgblight_task(); |
51 | } else { | 53 | #endif |
52 | PORTD &= ~(1<<4); | 54 | matrix_scan_user(); |
53 | } | 55 | /* Nothing else for now. */ |
54 | } | 56 | } |
55 | 57 | ||
56 | __attribute__ ((weak)) | 58 | __attribute__ ((weak)) |
57 | void matrix_scan_user(void) { | 59 | void matrix_scan_user(void) { |
58 | rgblight_task(); | ||
59 | } | 60 | } |
61 | |||
62 | void backlight_init_ports(void) { | ||
63 | // initialize pins D0, D1, D4 and D6 as output | ||
64 | setPinOutput(D0); | ||
65 | setPinOutput(D1); | ||
66 | setPinOutput(D4); | ||
67 | setPinOutput(D6); | ||
68 | |||
69 | // turn backlight LEDs on | ||
70 | writePinHigh(D0); | ||
71 | writePinHigh(D1); | ||
72 | writePinHigh(D4); | ||
73 | writePinHigh(D6); | ||
74 | } | ||
75 | |||
76 | void backlight_set(uint8_t level) { | ||
77 | if (level == 0) { | ||
78 | // turn backlight LEDs off | ||
79 | writePinLow(D0); | ||
80 | writePinLow(D1); | ||
81 | writePinLow(D4); | ||
82 | writePinLow(D6); | ||
83 | } else { | ||
84 | // turn backlight LEDs on | ||
85 | writePinHigh(D0); | ||
86 | writePinHigh(D1); | ||
87 | writePinHigh(D4); | ||
88 | writePinHigh(D6); | ||
89 | } | ||
90 | } \ No newline at end of file | ||