Exemplo n.º 1
0
void displayNextLine() {
  // First things first: latch in the values we clocked in
  // last time.

  PORTC |= SH_BIT_OE; // Turn off the LED drivers (inverted)
  PORTC |= SH_BIT_LE;  // latch the shift register
  PORTC &= ~SH_BIT_LE; // un-latch

  // Pick our line
  select_line();

  PORTC &= ~SH_BIT_OE; // Turn the LED drivers back on.


  // Great, that's done, now we can prepare the next line

  // interlace lines, probably looks better.

  g_line+=2;

  if(g_line==LED_LINES) {
    g_line=1;
  }

  // on to the next brightness level.

  if(g_line>LED_LINES) {
    g_line=0;
    g_level++;

    if (g_level>=BRIGHTNESS_LEVELS) {
      g_level=0;
    }

    // Change the timer frequency to give us a better range of brightness
    // When it's linear the brightness levels got more same-y toward the top

    if (g_level < 6)
      OCR1A = 100;
    else if (g_level < 11)
      OCR1A = 200;
    else
      OCR1A = 300;
  }

  g_circle++;

  if (g_circle == CIRCLE) {
    // It appears we've completed a whole frame! Now's the time to decide
    // if we're going to switch buffers.

    buffer_status[g_bufCurr] = BUFFER_CLEAN;
    buffer_status[g_bufNext] = BUFFER_BUSY;
    g_bufCurr = g_bufNext;
  }

  // Send stuff out the shift register.
  shift_24_bit();
}
Exemplo n.º 2
0
//sweep the specific line,used in the Timer1 ISR
void flash_line(unsigned char line,unsigned char level)
{
  disable_oe;
  close_all_line;
  shift_24_bit(line,level);
  open_line(line);
  enable_oe;
}