-
-/*
+/* -*- mode: c++; c-file-style: "linux" -*-
   Telepulssi TP-KN10 slave LED screen driver
 */
 


uint8_t *buf_front = buf_a;
uint8_t *buf_back = buf_b;

void buf_swap(void) {
	uint8_t *tmp = buf_front;

		digitalWrite(4, HIGH);
	}
	
	// Main screen turn on!
	if (col_i < 2) {
		PORTD = ~((1 << 6) << col_i);
	} else {
		PORTC = ~(1 << (col_i-2));
	}
	
	// After turning on the screen, we have "plenty" of CPU cycles
	// to spend. Preparing a new segment to display.
	
	// Go to the next column. If reached the end of line, jump to next.
	col_i++;
	if (col_i > 7) {
		col_i = 0;
		row_i++;
		if (row_i > 6) row_i = 0;
	}

	// Column driver latches on rising edge so we can already pull
	// it down.
	digitalWrite(5, LOW);
	
	// Send new data via SPI. Don't need to wait it to complete
	// because it completes before the next timer interrupt.
	SPDR = buf_front[8*row_i+col_i];
}
