 
 uint8_t *buf_front = buf_a;
 uint8_t *buf_back = buf_b;
+uint8_t col_i = 0;
+uint8_t row_i = 0;
+int buf_i = 0;
 
 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));
	}
	
	// Prepare new data
	col_i++;
	
	// Advance to next row if needed
	if (col_i > 7) {
		col_i = 0;
		row_i++;
		if (row_i > 6) row_i = 0;
	}

	// Pull down latch
	digitalWrite(5, LOW);
	
	// Send new data to SPI. Don't wait it to complete
	SPDR = buf_front[8*row_i+col_i];
}

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

