/* * Copyright 2012 (C) Christian Franke * * 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 3 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 #include #include #include #include "shiftbrite.h" volatile uint16_t value_red = 3072; volatile uint16_t value_green = 2048; volatile uint16_t value_blue = 1024; void pwm_set_rgb(uint8_t r, uint8_t g, uint8_t b) { value_red = (uint16_t)r * r >> 4; value_green = (uint16_t)g * g >> 4; value_blue = (uint16_t)b * b >> 4; } void pwm_tick(void) { for (uint16_t i = 0; i < 4096; i++) { /* this should take about the same time for each iteration, regardless of pulse width */ PORTA= (PORTA & ~((1< i? (1< i? (1< i? (1<