* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <math.h>
-#include <avr/eeprom.h>
-#include <avr/interrupt.h>
-#include <util/delay.h>
+#ifdef __AVR__
+ #include <avr/eeprom.h>
+ #include <avr/interrupt.h>
+#endif
+#include "wait.h"
#include "progmem.h"
#include "timer.h"
#include "rgblight.h"
uint32_t eeconfig_read_rgblight(void) {
- return eeprom_read_dword(EECONFIG_RGBLIGHT);
+ #ifdef __AVR__
+ return eeprom_read_dword(EECONFIG_RGBLIGHT);
+ #else
+ return 0;
+ #endif
}
void eeconfig_update_rgblight(uint32_t val) {
- eeprom_update_dword(EECONFIG_RGBLIGHT, val);
+ #ifdef __AVR__
+ eeprom_update_dword(EECONFIG_RGBLIGHT, val);
+ #endif
}
void eeconfig_update_rgblight_default(void) {
- dprintf("eeconfig_update_rgblight_default\n");
+ //dprintf("eeconfig_update_rgblight_default\n");
rgblight_config.enable = 1;
rgblight_config.mode = 1;
rgblight_config.hue = 0;
rgblight_timer_disable();
#endif
} else if ((rgblight_config.mode >= 2 && rgblight_config.mode <= 24) ||
- rgblight_config.mode == 35 ) {
+ rgblight_config.mode == 35 || rgblight_config.mode == 36) {
// MODE 2-5, breathing
// MODE 6-8, rainbow mood
// MODE 9-14, rainbow swirl
// MODE 21-23, knight
// MODE 24, xmas
// MODE 35 RGB test
+ // MODE 36, alterating
#ifdef RGBLIGHT_ANIMATIONS
rgblight_timer_enable();
#ifdef RGBLIGHT_ANIMATIONS
rgblight_timer_disable();
#endif
- _delay_ms(50);
+ wait_ms(50);
rgblight_set();
}
} else if (rgblight_config.mode == 35) {
// mode = 35, RGB test
rgblight_effect_rgbtest();
+ } else if (rgblight_config.mode == 36){
+ rgblight_effect_alternating();
}
}
}
pos = (pos + 1) % 3;
}
+void rgblight_effect_alternating(void){
+ static uint16_t last_timer = 0;
+ static uint16_t pos = 0;
+ if (timer_elapsed(last_timer) < 500) {
+ return;
+ }
+ last_timer = timer_read();
+
+ for(int i = 0; i<RGBLED_NUM; i++){
+ if(i<RGBLED_NUM/2 && pos){
+ rgblight_sethsv_at(rgblight_config.hue, rgblight_config.sat, rgblight_config.val, i);
+ }else if (i>=RGBLED_NUM/2 && !pos){
+ rgblight_sethsv_at(rgblight_config.hue, rgblight_config.sat, rgblight_config.val, i);
+ }else{
+ rgblight_sethsv_at(rgblight_config.hue, rgblight_config.sat, 0, i);
+ }
+ }
+ rgblight_set();
+ pos = (pos + 1) % 2;
+}
+
#endif /* RGBLIGHT_ANIMATIONS */