some basic patters. with bugs included.
This commit is contained in:
		@@ -236,5 +236,4 @@ void ledcontroller_set_channel(uint8_t channel, uint16_t value)
 | 
				
			|||||||
void ledcontroller_clear(void)
 | 
					void ledcontroller_clear(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  memset(ledbuffer, 0x00, sizeof(ledbuffer));
 | 
					  memset(ledbuffer, 0x00, sizeof(ledbuffer));
 | 
				
			||||||
  led_flush();
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										8
									
								
								main.c
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								main.c
									
									
									
									
									
								
							@@ -23,13 +23,17 @@ int main(void)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  timer_init();
 | 
					  timer_init();
 | 
				
			||||||
  //rtc_init(0);
 | 
					  rtc_init(0);
 | 
				
			||||||
  //spi_slave_init();
 | 
					  //spi_slave_init();
 | 
				
			||||||
  ledcontroller_init();
 | 
					  ledcontroller_init();
 | 
				
			||||||
  sei();
 | 
					  sei();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  //lcd_init();
 | 
					  //lcd_init();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  DDRC |= (1<<PC5);
 | 
					  DDRC |= (1<<PC5); // Test LED
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  //DDRD  |= (1<<PD4); // Backlight
 | 
				
			||||||
 | 
					  //PORTD |= (1<<PD4);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /*
 | 
					  /*
 | 
				
			||||||
  while (1) {
 | 
					  while (1) {
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										122
									
								
								rgbyteclock.c
									
									
									
									
									
								
							
							
						
						
									
										122
									
								
								rgbyteclock.c
									
									
									
									
									
								
							@@ -13,11 +13,12 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "rgbyteclock.h"
 | 
					#include "rgbyteclock.h"
 | 
				
			||||||
#include "timer.h"
 | 
					#include "timer.h"
 | 
				
			||||||
 | 
					#include "rtc.h"
 | 
				
			||||||
#include "lcd.h"
 | 
					#include "lcd.h"
 | 
				
			||||||
#include "ledcontroller.h"
 | 
					#include "ledcontroller.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void rgbyteclock(void)
 | 
					void rgbyteclock_rounds(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  ledcontroller_turn_all_on();
 | 
					  ledcontroller_turn_all_on();
 | 
				
			||||||
@@ -25,41 +26,112 @@ void rgbyteclock(void)
 | 
				
			|||||||
  while (1) {
 | 
					  while (1) {
 | 
				
			||||||
    //PORTC ^= (1<<PC5);
 | 
					    //PORTC ^= (1<<PC5);
 | 
				
			||||||
    for (int i=0; i<14; i++) {
 | 
					    for (int i=0; i<14; i++) {
 | 
				
			||||||
      led_set(i, 0x7ff, 0x00, 0x00);
 | 
					      led_set(i, 0x1ff, 0x00, 0x00);
 | 
				
			||||||
      led_flush();
 | 
					      led_flush();
 | 
				
			||||||
      timer_wait(100);
 | 
					      timer_wait(50);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    /* for (int i=0; i<14; i++) { */
 | 
					 | 
				
			||||||
    /*   led_set(i, 0x00, 0x00, 0x00); */
 | 
					 | 
				
			||||||
    /* } */
 | 
					 | 
				
			||||||
    /* led_flush(); */
 | 
					 | 
				
			||||||
    ledcontroller_clear();
 | 
					 | 
				
			||||||
    timer_wait(100);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (int i=0; i<14; i++) {
 | 
					    for (int i=0; i<14; i++) {
 | 
				
			||||||
      led_set(i, 0x00, 0x7ff, 0x00);
 | 
					      led_set(i, 0x00, 0x1ff, 0x00);
 | 
				
			||||||
      led_flush();
 | 
					      led_flush();
 | 
				
			||||||
      timer_wait(100);
 | 
					      timer_wait(50);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    /* for (int i=0; i<14; i++) { */
 | 
					    //timer_wait(100);
 | 
				
			||||||
    /*   led_set(i, 0x00, 0x00, 0x00); */
 | 
					 | 
				
			||||||
    /* } */
 | 
					 | 
				
			||||||
    /* led_flush(); */
 | 
					 | 
				
			||||||
    ledcontroller_clear();
 | 
					 | 
				
			||||||
    timer_wait(100);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (int i=0; i<14; i++) {
 | 
					    for (int i=0; i<14; i++) {
 | 
				
			||||||
      led_set(i, 0x00, 0x00, 0x7ff);
 | 
					      led_set(i, 0x00, 0x00, 0x1ff);
 | 
				
			||||||
      led_flush();
 | 
					      led_flush();
 | 
				
			||||||
      timer_wait(100);
 | 
					      timer_wait(20);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    /* for (int i=0; i<14; i++) { */
 | 
					    //timer_wait(100);
 | 
				
			||||||
    /*   led_set(i, 0x00, 0x00, 0x00); */
 | 
					 | 
				
			||||||
    /* } */
 | 
					 | 
				
			||||||
    /* led_flush(); */
 | 
					 | 
				
			||||||
    ledcontroller_clear();
 | 
					 | 
				
			||||||
    timer_wait(100);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void rgbyteclock_secwatch(void)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  uint8_t hours, mins;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  uint32_t t, t_last=0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  ledcontroller_turn_all_on();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  while (1) {
 | 
				
			||||||
 | 
					    t = timer_get()/1000;
 | 
				
			||||||
 | 
					    if (t != t_last) {
 | 
				
			||||||
 | 
					      t_last = t;
 | 
				
			||||||
 | 
					      mins = t%60;
 | 
				
			||||||
 | 
					      hours = t/60;
 | 
				
			||||||
 | 
					      uint8_t l_mins = mins/5;
 | 
				
			||||||
 | 
					      uint8_t l_hours = hours/5;
 | 
				
			||||||
 | 
					      ledcontroller_clear();
 | 
				
			||||||
 | 
					      if (l_mins != l_hours) {
 | 
				
			||||||
 | 
						led_set(l_mins, 0, 0x7ff, 0);
 | 
				
			||||||
 | 
						led_set(l_hours, 0, 0, 0x7ff);
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      else {
 | 
				
			||||||
 | 
						led_set(l_mins, 0, 0x7ff, 0x7ff);
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      led_flush();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void rgbyteclock_secwatch_glide(void)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  uint8_t hours, mins;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  uint32_t t, t_last=0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  ledcontroller_turn_all_on();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  while (1) {
 | 
				
			||||||
 | 
					    t = rtc_get();
 | 
				
			||||||
 | 
					    if (t != t_last) {
 | 
				
			||||||
 | 
					      t_last = t;
 | 
				
			||||||
 | 
					      mins = t%60;
 | 
				
			||||||
 | 
					      hours = t/60;
 | 
				
			||||||
 | 
					      uint8_t l_mins = mins/5;
 | 
				
			||||||
 | 
					      uint8_t l_hours = hours/5;
 | 
				
			||||||
 | 
					      uint8_t l_mins_next = l_mins+1;
 | 
				
			||||||
 | 
					      uint8_t l_hours_next = l_hours+1;
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      if (l_mins_next > 11) { l_mins_next = 0; }
 | 
				
			||||||
 | 
					      if (l_hours_next > 11) { l_hours_next = 0; }
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      uint16_t d_m1, d_m2;
 | 
				
			||||||
 | 
					      uint16_t d_h1, d_h2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      d_m2 = ((mins%5)*0x7ffUL)/4;
 | 
				
			||||||
 | 
					      d_h2 = ((hours%5)*0xfffUL)/4;
 | 
				
			||||||
 | 
					      d_m1 = ((4-(mins%5))*0x7ffUL)/4;
 | 
				
			||||||
 | 
					      d_h1 = ((4-(hours%5))*0xfffUL)/4;
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      ledcontroller_clear();
 | 
				
			||||||
 | 
					      for (int led=0;led<12;led++) {
 | 
				
			||||||
 | 
						led_set(led, 0x000f, 0, 0);
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      if (l_mins != l_hours) {
 | 
				
			||||||
 | 
						led_set(l_mins, 0xf, d_m1, 0);
 | 
				
			||||||
 | 
						led_set(l_hours, 0xf, 0, d_h1);
 | 
				
			||||||
 | 
						led_set(l_mins_next, 0xf, d_m2, 0);
 | 
				
			||||||
 | 
						led_set(l_hours_next, 0xf, 0, d_h2);
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      else {
 | 
				
			||||||
 | 
						led_set(l_mins, 0xf, d_m1, d_h1);
 | 
				
			||||||
 | 
						led_set(l_mins_next, 0xf, d_m2, d_h2);
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      led_flush();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void rgbyteclock(void)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  //rgbyteclock_rounds();
 | 
				
			||||||
 | 
					  //rgbyteclock_secwatch();
 | 
				
			||||||
 | 
					  rgbyteclock_secwatch_glide();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user