qmk

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.z3bra.org/qmk.git
Log | Files | Refs | Submodules | LICENSE

pearl.c (2178B)


      1 /*
      2 Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com>
      3 
      4 This program is free software: you can redistribute it and/or modify
      5 it under the terms of the GNU General Public License as published by
      6 the Free Software Foundation, either version 2 of the License, or
      7 (at your option) any later version.
      8 
      9 This program is distributed in the hope that it will be useful,
     10 but WITHOUT ANY WARRANTY; without even the implied warranty of
     11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     12 GNU General Public License for more details.
     13 
     14 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/>.
     16 */
     17 
     18 #include "rgblight.h"
     19 #include "i2c_master.h"
     20 #include "quantum.h"
     21 
     22 #ifdef RGBLIGHT_ENABLE
     23 extern rgblight_config_t rgblight_config;
     24 
     25 void rgblight_set(void) {
     26     if (!rgblight_config.enable) {
     27         for (uint8_t i = 0; i < RGBLED_NUM; i++) {
     28             led[i].r = 0;
     29             led[i].g = 0;
     30             led[i].b = 0;
     31         }
     32     }
     33 
     34     i2c_init();
     35     i2c_transmit(0xb0, (uint8_t*)led, 3 * RGBLED_NUM, 100);
     36 }
     37 #endif
     38 
     39 void matrix_init_kb(void) {
     40 #ifdef RGBLIGHT_ENABLE
     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();
     48 }
     49 
     50 void matrix_scan_kb(void) {
     51 #ifdef RGBLIGHT_ENABLE
     52     rgblight_task();
     53 #endif
     54     matrix_scan_user();
     55     /* Nothing else for now. */
     56 }
     57 
     58 __attribute__ ((weak))
     59 void matrix_scan_user(void) {
     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 }