/* Copyright 2017 benlyall, MechMerlin * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "v60_type_r.h" #include "quantum.h" // if we've got an RGB underglow! #ifdef V60_POLESTAR #include "rgblight.h" #include #include "action_layer.h" #define SOFTPWM_LED_TIMER_TOP F_CPU/(256*64) extern rgblight_config_t rgblight_config; static uint8_t softpwm_buff[3] = {0}; void matrix_init_kb(void) { rgb_init(); matrix_init_user(); } bool process_record_kb(uint16_t keycode, keyrecord_t *record) { uint8_t r = led[0].r, g = led[0].g, b = led[0].b; switch(keycode) { case RGB_RI: if (record->event.pressed) { r += RGB_STEP; if (r < led[0].r) { r = 255; } rgblight_setrgb(r, g, b); } return false; case RGB_RD: if (record->event.pressed) { r -= RGB_STEP; if (r > led[0].r) { r = 0; } rgblight_setrgb(r, g, b); } return false; case RGB_BI: if (record->event.pressed) { b += RGB_STEP; if (b < led[0].b) { b = 255; } rgblight_setrgb(r, g, b); } return false; case RGB_BD: if (record->event.pressed) { b -= RGB_STEP; if (b > led[0].b) { b = 0; } rgblight_setrgb(r, g, b); } return false; case RGB_GI: if (record->event.pressed) { g += RGB_STEP; if (g < led[0].g) { g = 255; } rgblight_setrgb(r, g, b); } return false; case RGB_GD: if (record->event.pressed) { g -= RGB_STEP; if (g > led[0].g) { g = 0; } rgblight_setrgb(r, g, b); } return false; } return process_record_user(keycode, record); } void rgb_timer_init(void) { /* Timer1 setup */ /* CTC mode */ TCCR1B |= (1<> 8) & 0xff; OCR1AL = SOFTPWM_LED_TIMER_TOP & 0xff; SREG = sreg; // Enable the compare match interrupt on timer 1 TIMSK1 |= (1<