/* * Simple ShiftBrite interface code for remoodlamp firmware * Copyright 2012 (C) Johannes Kroll * * 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 #include #include #include "serial.h" /* shiftbrites connected to header labeled as 'aux', setup: PC0 -> CI (clock) PC1 -> LI (latch) PC2 -> DI (data) */ #define SBCI (1<=0; i--) { _delay_us(clkdelay); PORTC&= ~SBCI; /* clock lo */ if((val>>i)&1) PORTC|= SBDI; /* data bit */ else PORTC&= ~SBDI; _delay_us(clkdelay); PORTC|= SBCI; /* clock hi */ } } /* set the color of a shiftbrite. */ void sb_setcolor(uint8_t lamp_index, uint8_t r, uint8_t g, uint8_t b) { if(lamp_index >= MAXSHIFTBRITES) return; if(lamp_index+1 > sb_num_shiftbrites) sb_num_shiftbrites= lamp_index+1; sb_colors[lamp_index].r= (uint16_t)r*r>>6; sb_colors[lamp_index].g= (uint16_t)g*g>>6; sb_colors[lamp_index].b= (uint16_t)b*b>>6; /* updates are now done in sb_tick() sb_update_all_colors(); */ } /* write default values to config registers of all shiftbrites */ static void sb_set_default_config_values(void) { for(int i= 0; i