OK. So for Parallel, this is what I have for pinout.
XMega - OLED
PC0-7 D0-7
PD0 R/W
PD1 ERD
PD2 D/C
PD4 RES
PD5 CS
Then of course Vcc to +3.3 and GND to Ground
On this board, I did not change any of the solder jumpers and I did not solder in any headers to the JP1 and JP2 vias.
I did solder in some headers to BS1 and BS2. For 6800 Parallel mode, I have both BS jumpers in the on position. In other words, they are both jumping 3.3v to the center pin (with the board oriented so that the SparkFun silkscreening at the top is horizontal reading right to left, the jumpers are on the bottom two pins).
Here also is some code. It’s ugly, not well commented and inefficient but it works.
Some notes about it: Basically it prints out two sentences then prints out every character. Next it prints out what it is reading from port F (which happens to have a small joystick attached to it on the green MXega proto board that you see in the pic). In the loop that is reading port F it also draws the cake at the coord that are supplied as arguments to the DrawCake function. The only difference in cake1 and cake2 is the orientation of the flame so, without using any interrupts to draw the cake, the little flame flickers very very quickly. For the text, I just use a 40 bit array for the character (5x8). The color of the font is then controlled within the function itself not the font arrays. And, yes, the PrintChar function could have had two loops in it but I expanded them to save a few cycles. A quick few words about the strings. This has no fancy string handling nor the ability to put number vars in it (%d). It does recognize home (\1), new line and line feed (\n) and tab (\t). All strings should end with a null character (\0) or you will be printing out everything in memory.
#include <avr\io.h>
#include <avr/interrupt.h>
#define CHR_W 5
#define CHR_H 8
#define CHR_S 1
#define LINE_S 1
#define CLR_SHIFT 3
#define TAB_W 4
#define PIN_IN_CTRL 0b00011000
unsigned char font[95][5] =
{
{0b00000000 //(space)
,0b00000000
,0b00000000
,0b00000000
,0b00000000},
{0b00100001 //!
,0b00001000
,0b01000010
,0b00000000
,0b00000100},
{0b01010010 //"
,0b10010100
,0b00000000
,0b00000000
,0b00000000},
{0b01010010 //#
,0b10111110
,0b10100101
,0b01111101
,0b01001010},
{0b00100011 //$
,0b10100010
,0b11000001
,0b01000101
,0b11000100},
{0b11001110 //%
,0b01000100
,0b01000010
,0b00100010
,0b01110011},
{0b01100100 //&
,0b10100101
,0b01000100
,0b01010110
,0b01101111},
{0b00100001 //'
,0b00001000
,0b00000000
,0b00000000
,0b00000000},
{0b00010001 //(
,0b00010000
,0b10000100
,0b00100000
,0b10000010},
{0b01000001 //)
,0b00000100
,0b00100001
,0b00001000
,0b10001000},
{0b00100011 //*
,0b10001000
,0b10100000
,0b00000000
,0b00000000},
{0b00000001 //+
,0b00001001
,0b11110010
,0b00010000
,0b00000000},
{0b00000000 //,
,0b00000000
,0b00000000
,0b00000000
,0b11001100},
{0b00000000 //-
,0b00000001
,0b11110000
,0b00000000
,0b00000000},
{0b00000000 //.
,0b00000000
,0b00000000
,0b00000000
,0b11000110},
{0b00001000 ///
,0b01000100
,0b01000010
,0b00100010
,0b00010000},
{0b01110100 //0
,0b11101011
,0b01011010
,0b11010111
,0b00101110},
{0b00100011 //1
,0b00001000
,0b01000010
,0b00010000
,0b10001110},
{0b01110100 //2
,0b01000010
,0b00010001
,0b00010001
,0b00011111},
{0b01110100 //3
,0b01000010
,0b11100000
,0b10000110
,0b00101110},
{0b10010100 //4
,0b10100101
,0b11110001
,0b00001000
,0b01000010},
{0b11111100 //5
,0b00100001
,0b11100000
,0b10000110
,0b00101110},
{0b01110100 //6
,0b01100001
,0b11101000
,0b11000110
,0b00101110},
{0b11111000 //7
,0b01000100
,0b01000100
,0b00100010
,0b00010000},
{0b01110100 //8
,0b01100010
,0b11101000
,0b11000110
,0b00101110},
{0b01110100 //9
,0b01100011
,0b00010111
,0b10000110
,0b00101110},
{0b00000001 //:
,0b10001100
,0b00000000
,0b00011000
,0b11000000},
{0b00000001 //;
,0b10001100
,0b00000000
,0b00011000
,0b11001100},
{0b00000000 //<
,0b10001000
,0b10001000
,0b00100000
,0b10000010},
{0b00000000 //=
,0b00000001
,0b11110000
,0b01111100
,0b00000000},
{0b00000010 //>
,0b00001000
,0b00100000
,0b10001000
,0b10001000},
{0b01110100 //?
,0b01000010
,0b00100010
,0b00010000
,0b00000100},
{0b01110100 //@
,0b01100111
,0b01011011
,0b01000010
,0b00101110},
{0b00100001 //A
,0b00010100
,0b10100111
,0b01000110
,0b00110001},
{0b11110100 //B
,0b01100011
,0b11101000
,0b11000110
,0b00111110},
{0b01110100 //C
,0b01100001
,0b00001000
,0b01000010
,0b00101110},
{0b11100100 //D
,0b10100011
,0b00011000
,0b11000110
,0b01011100},
{0b11111100 //E
,0b00100001
,0b11101000
,0b01000010
,0b00011111},
{0b11111100 //F
,0b00100001
,0b11101000
,0b01000010
,0b00010000},
{0b01110100 //G
,0b01100001
,0b00001011
,0b01000110
,0b00101110},
{0b10001100 //H
,0b01100011
,0b11111000
,0b11000110
,0b00110001},
{0b11111001 //I
,0b00001000
,0b01000010
,0b00010000
,0b10011111},
{0b01111000 //J
,0b10000100
,0b00100001
,0b00001010
,0b01001100},
{0b10001100 //K
,0b10101001
,0b10001010
,0b01001010
,0b00110001},
{0b10000100 //L
,0b00100001
,0b00001000
,0b01000010
,0b00011111},
{0b10001110 //M
,0b11101011
,0b01011000
,0b11000110
,0b00110001},
{0b10001110 //N
,0b01110011
,0b01011010
,0b11001110
,0b01110001},
{0b01110100 //O
,0b01100011
,0b00011000
,0b11000110
,0b00101110},
{0b11110100 //P
,0b01100011
,0b00011111
,0b01000010
,0b00010000},
{0b01110100 //Q
,0b01100011
,0b00011000
,0b11010110
,0b01001111},
{0b11110100 //R
,0b01100011
,0b00011111
,0b01010010
,0b01010001},
{0b01110100 //S
,0b01100000
,0b11100000
,0b10000110
,0b00101110},
{0b11111001 //T
,0b00001000
,0b01000010
,0b00010000
,0b10000100},
{0b10001100 //U
,0b01100011
,0b00011000
,0b11000110
,0b00101110},
{0b10001100 //V
,0b01100010
,0b10100101
,0b00101000
,0b10000100},
{0b10001100 //W
,0b01100011
,0b00011010
,0b11010111
,0b01110001},
{0b10001010 //X
,0b10010100
,0b01000010
,0b00101001
,0b01010001},
{0b10001100 //Y
,0b01010100
,0b10100010
,0b00010000
,0b10000100},
{0b11111000 //Z
,0b10000100
,0b01000010
,0b00100001
,0b00011111},
{0b01110010 //[
,0b00010000
,0b10000100
,0b00100001
,0b00001110},
{0b10000100 //(\)
,0b00010000
,0b01000010
,0b00001000
,0b00100001},
{0b01110000 //]
,0b10000100
,0b00100001
,0b00001000
,0b01001110},
{0b00100010 //^
,0b10100010
,0b00000000
,0b00000000
,0b00000000},
{0b00000000 //_
,0b00000000
,0b00000000
,0b00000000
,0b00011111},
{0b01000001 //`
,0b00000100
,0b00000000
,0b00000000
,0b00000000},
{0b00000000 //a
,0b00000000
,0b11100000
,0b10111110
,0b00101111},
{0b10000100 //b
,0b00100001
,0b11101000
,0b11000110
,0b00101110},
{0b00000000 //c
,0b00000000
,0b11101000
,0b11000010
,0b00101110},
{0b00001000 //d
,0b01000010
,0b11111000
,0b11000110
,0b00101110},
{0b00000000 //e
,0b00000000
,0b11101000
,0b11111010
,0b00001110},
{0b00000001 //f
,0b10010010
,0b10001111
,0b00100001
,0b00001000},
{0b00000000 //g
,0b00011101
,0b00011000
,0b10111100
,0b00101110},
{0b00000010 //h
,0b00010000
,0b11100100
,0b10100101
,0b00101001},
{0b00000000 //i
,0b00001000
,0b00000010
,0b00010000
,0b10000100},
{0b00000000 //j
,0b00000010
,0b00000000
,0b10000101
,0b00100110},
{0b00000100 //k
,0b00100001
,0b00101010
,0b01100010
,0b10010010},
{0b00000001 //l
,0b00001000
,0b01000010
,0b00010000
,0b10000110},
{0b00000000 //m
,0b00000000
,0b10101010
,0b11010110
,0b00110001},
{0b00000000 //n
,0b00000000
,0b11100100
,0b10100101
,0b00101001},
{0b00000000 //o
,0b00000000
,0b01100100
,0b10100101
,0b00100110},
{0b00000000 //p
,0b00001100
,0b10010100
,0b10111001
,0b00001000},
{0b00000000 //q
,0b00001100
,0b10010100
,0b10011100
,0b00100001},
{0b00000000 //r
,0b00000000
,0b11100100
,0b10100001
,0b00001000},
{0b00000000 //s
,0b00000000
,0b11111000
,0b00111000
,0b00111110},
{0b00000000 //t
,0b00010001
,0b11100100
,0b00100001
,0b00100110},
{0b00000000 //u
,0b00000000
,0b10010100
,0b10100101
,0b00100110},
{0b00000000 //v
,0b00000001
,0b00011000
,0b10101001
,0b01000100},
{0b00000000 //w
,0b00000001
,0b00011000
,0b11010110
,0b10101010},
{0b00000000 //x
,0b00000001
,0b00010101
,0b00010001
,0b01010001},
{0b00000000 //y
,0b00000000
,0b10010100
,0b10011100
,0b00101110},
{0b00000000 //z
,0b00000001
,0b11110001
,0b00010001
,0b00011111},
{0b00010001 //{
,0b00001000
,0b01000100
,0b00010000
,0b10000010},
{0b00100001 //|
,0b00001000
,0b01000010
,0b00010000
,0b10000100},
{0b01000001 //}
,0b00001000
,0b01000001
,0b00010000
,0b10001000},
{0b00000000 //~
,0b00000000
,0b10011011
,0b00000000
,0b00000000}
};
/*
unsigned char cake1[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x66,
0x00, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x66, 0x00, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x66, 0x66, 0x00, 0x66, 0x66, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x66, 0x66, 0x00, 0x66, 0x66, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00};
unsigned char cake2[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x66,
0x00, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x66, 0x00, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x66, 0x66, 0x00, 0x66, 0x66, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x66, 0x66, 0x00, 0x66, 0x66, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00};
*/
unsigned char chrX = 0;
unsigned char chrY = 0;
char vals[6];
int main();
void Init();
void OLEDCmd(unsigned char);
void OLEDData(unsigned char);
void PrintChar(unsigned char);
void PrintS(char[]);
void DrawCake(unsigned char[], unsigned char, unsigned char);
void IntToString(unsigned int);
void InitTimer();
void InitDAC();
int main()
{
char i = 0;
PORTF_DIR = 0;
PORTE_DIR = 0b11111111;
PORTF_PIN0CTRL = PIN_IN_CTRL;
PORTF_PIN1CTRL = PIN_IN_CTRL;
PORTF_PIN2CTRL = PIN_IN_CTRL;
PORTF_PIN3CTRL = PIN_IN_CTRL;
PORTF_PIN4CTRL = PIN_IN_CTRL;
PORTF_PIN5CTRL = PIN_IN_CTRL;
PORTF_PIN6CTRL = PIN_IN_CTRL;
PORTF_PIN7CTRL = PIN_IN_CTRL;
//Enable low priority interrupts
PMIC_CTRL = 0b00000001;
PORTE_OUT = 1;
Init();
PORTE_OUT = 2;
cli(); //disable interrupts
InitDAC();
InitTimer();
sei(); //enable the interrupts
TCC0_CTRLA = 0b00000001; //pre = 1 and starts the timer Using this with a Period of 1000 sould give us a 32K clock.
PrintS("The cake is a lie!\n\0");
PrintS("I am ");
IntToString(PORTE_OUT);
PrintS(vals);
PrintS(" years old\n\0");
for (i = 32; i < 127; i++)
{
PrintChar(i);
}
PrintS("\n\0");
PORTE_OUT = 3;
while(1)
{
DrawCake(cake1, 48, 70);
IntToString(PORTF_IN);
PrintS(vals);
PrintS("\1\0");
DrawCake(cake2, 48, 70);
}
return 0;
}
void InitDAC()
{
//DAC setup
DACA_CTRLA = 0b00000100;
DACA_CTRLB = 0b00000000;
DACA_CTRLC = 0b00001001;
DACA_TIMCTRL = 0b01110000;
DACA_GAINCAL = 0b00000001;
DACA_OFFSETCAL = 0b00000000;
DACA_CTRLA = 0b00000101; //enable DAC
}
void InitTimer()
{
//Timer setup
TCC0_CTRLA = 0; //timer off for now.
TCC0_CTRLB = 0;
TCC0_CTRLC = 0;
TCC0_CTRLD = 0;
TCC0_CTRLE = 0;
TCC0_INTCTRLA = 0b00000001; //Enable overflow int
TCC0_INTCTRLB = 0b00000000;
TCC0_PER = 1016 ; //with no prescaler, 1016 is the number of cycles between each H_BLANK period on a tv screen at 60 FPS (or 60 Hz screen refresh rate)
//at a 32MHz Sys clock
}
void DrawCake(unsigned char cake[], unsigned char x, unsigned char y)
{
unsigned int i;
OLEDCmd(0x15);
OLEDData(x);
OLEDData(x + 31);
OLEDCmd(0x75);
OLEDData(y);
OLEDData(y + 31);
OLEDCmd(0x5C);
for (i = 0; i < 1024; i++)
{
OLEDData(cake[i]);
OLEDData(0);
}
}
void PrintS(char string[])
{
unsigned int i = 0;
while (string[i] != 0 && i < 65535)
{
PrintChar(string[i]);
i++;
}
}
void IntToString(unsigned int value)
{
vals[0] = value / 10000;
value -= vals[0] * 10000;
vals[1] = value / 1000;
value -= vals[1] * 1000;
vals[2] = value / 100;
value -= vals[2] * 100;
vals[3] = value / 10;
value -= vals[3] * 10;
vals[4] = value;
vals[0] += 48;
vals[1] += 48;
vals[2] += 48;
vals[3] += 48;
vals[4] += 48;
vals[5] = 0;
}
void PrintChar(unsigned char chr)
{
unsigned char i = 0;
unsigned char c = 0;
unsigned char cVal = chr - 32;
switch(chr)
{
case 1: //home
chrX = 0;
break;
case 9: //tab
for (i = 0; i < TAB_W; i++)
{
chrX += (CHR_W + CHR_S);
if (chrX > 127)
{
chrY += (CHR_H + LINE_S);
if (chrY > 120)
{
chrY = 0;
}
}
}
break;
case 10: //new line
chrY += (CHR_H + LINE_S);
if (chrY > 120)
{
chrY = 0;
}
chrX = 0;
break;
case 13: //line feed (carriage return)
chrY += (CHR_H + LINE_S);
if (chrY > 120)
{
chrY = 0;
}
break;
default: //all other characters
if (cVal < 95)
{
PORTD_OUT = 0b00010010;
PORTC_OUT = 0x15;
PORTD_OUT = 0b00010000;
PORTD_OUT = 0b00010110;
PORTC_OUT = chrX;
PORTD_OUT = 0b00010100;
PORTD_OUT = 0b00010110;
PORTC_OUT = chrX + (CHR_W - 1);
PORTD_OUT = 0b00010100;
PORTD_OUT = 0b00010010;
PORTC_OUT = 0x75;
PORTD_OUT = 0b00010000;
PORTD_OUT = 0b00010110;
PORTC_OUT = chrY;
PORTD_OUT = 0b00010100;
PORTD_OUT = 0b00010110;
PORTC_OUT = chrY + (CHR_H - 1);
PORTD_OUT = 0b00010100;
PORTD_OUT = 0b00010010;
PORTC_OUT = 0x5C;
PORTD_OUT = 0b00010000;
c = font[cVal][0];
PORTD_OUT = 0b00010110;
PORTC_OUT = (c & 0b10000000);
PORTD_OUT = 0b00010100;
PORTD_OUT = 0b00010110;
PORTC_OUT = 0;
PORTD_OUT = 0b00010100;
c = c << 1;
PORTD_OUT = 0b00010110;
PORTC_OUT = (c & 0b10000000);
PORTD_OUT = 0b00010100;
PORTD_OUT = 0b00010110;
PORTC_OUT = 0;
PORTD_OUT = 0b00010100;
c = c << 1;
PORTD_OUT = 0b00010110;
PORTC_OUT = (c & 0b10000000);
PORTD_OUT = 0b00010100;
PORTD_OUT = 0b00010110;
PORTC_OUT = 0;
PORTD_OUT = 0b00010100;
c = c << 1;
PORTD_OUT = 0b00010110;
PORTC_OUT = (c & 0b10000000);
PORTD_OUT = 0b00010100;
PORTD_OUT = 0b00010110;
PORTC_OUT = 0;
PORTD_OUT = 0b00010100;
c = c << 1;
PORTD_OUT = 0b00010110;
PORTC_OUT = (c & 0b10000000);
PORTD_OUT = 0b00010100;
PORTD_OUT = 0b00010110;
PORTC_OUT = 0;
PORTD_OUT = 0b00010100;
c = c << 1;
PORTD_OUT = 0b00010110;
PORTC_OUT = (c & 0b10000000);
PORTD_OUT = 0b00010100;
PORTD_OUT = 0b00010110;
PORTC_OUT = 0;
PORTD_OUT = 0b00010100;
c = c << 1;
PORTD_OUT = 0b00010110;
PORTC_OUT = (c & 0b10000000);
PORTD_OUT = 0b00010100;
PORTD_OUT = 0b00010110;
PORTC_OUT = 0;
PORTD_OUT = 0b00010100;
c = c << 1;
PORTD_OUT = 0b00010110;
PORTC_OUT = (c & 0b10000000);
PORTD_OUT = 0b00010100;
PORTD_OUT = 0b00010110;
PORTC_OUT = 0;
PORTD_OUT = 0b00010100;
c = font[cVal][1];
PORTD_OUT = 0b00010110;
PORTC_OUT = (c & 0b10000000);
PORTD_OUT = 0b00010100;
PORTD_OUT = 0b00010110;
PORTC_OUT = 0;
PORTD_OUT = 0b00010100;
c = c << 1;
PORTD_OUT = 0b00010110;
PORTC_OUT = (c & 0b10000000);
PORTD_OUT = 0b00010100;
PORTD_OUT = 0b00010110;
PORTC_OUT = 0;
PORTD_OUT = 0b00010100;
c = c << 1;
PORTD_OUT = 0b00010110;
PORTC_OUT = (c & 0b10000000);
PORTD_OUT = 0b00010100;
PORTD_OUT = 0b00010110;
PORTC_OUT = 0;
PORTD_OUT = 0b00010100;
c = c << 1;
PORTD_OUT = 0b00010110;
PORTC_OUT = (c & 0b10000000);
PORTD_OUT = 0b00010100;
PORTD_OUT = 0b00010110;
PORTC_OUT = 0;
PORTD_OUT = 0b00010100;
c = c << 1;
PORTD_OUT = 0b00010110;
PORTC_OUT = (c & 0b10000000);
PORTD_OUT = 0b00010100;
PORTD_OUT = 0b00010110;
PORTC_OUT = 0;
PORTD_OUT = 0b00010100;
c = c << 1;
PORTD_OUT = 0b00010110;
PORTC_OUT = (c & 0b10000000);
PORTD_OUT = 0b00010100;
PORTD_OUT = 0b00010110;
PORTC_OUT = 0;
PORTD_OUT = 0b00010100;
c = c << 1;
PORTD_OUT = 0b00010110;
PORTC_OUT = (c & 0b10000000);
PORTD_OUT = 0b00010100;
PORTD_OUT = 0b00010110;
PORTC_OUT = 0;
PORTD_OUT = 0b00010100;
c = c << 1;
PORTD_OUT = 0b00010110;
PORTC_OUT = (c & 0b10000000);
PORTD_OUT = 0b00010100;
PORTD_OUT = 0b00010110;
PORTC_OUT = 0;
PORTD_OUT = 0b00010100;
c = font[cVal][2];
PORTD_OUT = 0b00010110;
PORTC_OUT = (c & 0b10000000);
PORTD_OUT = 0b00010100;
PORTD_OUT = 0b00010110;
PORTC_OUT = 0;
PORTD_OUT = 0b00010100;
c = c << 1;
PORTD_OUT = 0b00010110;
PORTC_OUT = (c & 0b10000000);
PORTD_OUT = 0b00010100;
PORTD_OUT = 0b00010110;
PORTC_OUT = 0;
PORTD_OUT = 0b00010100;
c = c << 1;
PORTD_OUT = 0b00010110;
PORTC_OUT = (c & 0b10000000);
PORTD_OUT = 0b00010100;
PORTD_OUT = 0b00010110;
PORTC_OUT = 0;
PORTD_OUT = 0b00010100;
c = c << 1;
PORTD_OUT = 0b00010110;
PORTC_OUT = (c & 0b10000000);
PORTD_OUT = 0b00010100;
PORTD_OUT = 0b00010110;
PORTC_OUT = 0;
PORTD_OUT = 0b00010100;
c = c << 1;
PORTD_OUT = 0b00010110;
PORTC_OUT = (c & 0b10000000);
PORTD_OUT = 0b00010100;
PORTD_OUT = 0b00010110;
PORTC_OUT = 0;
PORTD_OUT = 0b00010100;
c = c << 1;
PORTD_OUT = 0b00010110;
PORTC_OUT = (c & 0b10000000);
PORTD_OUT = 0b00010100;
PORTD_OUT = 0b00010110;
PORTC_OUT = 0;
PORTD_OUT = 0b00010100;
c = c << 1;
PORTD_OUT = 0b00010110;
PORTC_OUT = (c & 0b10000000);
PORTD_OUT = 0b00010100;
PORTD_OUT = 0b00010110;
PORTC_OUT = 0;
PORTD_OUT = 0b00010100;
c = c << 1;
PORTD_OUT = 0b00010110;
PORTC_OUT = (c & 0b10000000);
PORTD_OUT = 0b00010100;
PORTD_OUT = 0b00010110;
PORTC_OUT = 0;
PORTD_OUT = 0b00010100;
c = font[cVal][3];
PORTD_OUT = 0b00010110;
PORTC_OUT = (c & 0b10000000);
PORTD_OUT = 0b00010100;
PORTD_OUT = 0b00010110;
PORTC_OUT = 0;
PORTD_OUT = 0b00010100;
c = c << 1;
PORTD_OUT = 0b00010110;
PORTC_OUT = (c & 0b10000000);
PORTD_OUT = 0b00010100;
PORTD_OUT = 0b00010110;
PORTC_OUT = 0;
PORTD_OUT = 0b00010100;
c = c << 1;
PORTD_OUT = 0b00010110;
PORTC_OUT = (c & 0b10000000);
PORTD_OUT = 0b00010100;
PORTD_OUT = 0b00010110;
PORTC_OUT = 0;
PORTD_OUT = 0b00010100;
c = c << 1;
PORTD_OUT = 0b00010110;
PORTC_OUT = (c & 0b10000000);
PORTD_OUT = 0b00010100;
PORTD_OUT = 0b00010110;
PORTC_OUT = 0;
PORTD_OUT = 0b00010100;
c = c << 1;
PORTD_OUT = 0b00010110;
PORTC_OUT = (c & 0b10000000);
PORTD_OUT = 0b00010100;
PORTD_OUT = 0b00010110;
PORTC_OUT = 0;
PORTD_OUT = 0b00010100;
c = c << 1;
PORTD_OUT = 0b00010110;
PORTC_OUT = (c & 0b10000000);
PORTD_OUT = 0b00010100;
PORTD_OUT = 0b00010110;
PORTC_OUT = 0;
PORTD_OUT = 0b00010100;
c = c << 1;
PORTD_OUT = 0b00010110;
PORTC_OUT = (c & 0b10000000);
PORTD_OUT = 0b00010100;
PORTD_OUT = 0b00010110;
PORTC_OUT = 0;
PORTD_OUT = 0b00010100;
c = c << 1;
PORTD_OUT = 0b00010110;
PORTC_OUT = (c & 0b10000000);
PORTD_OUT = 0b00010100;
PORTD_OUT = 0b00010110;
PORTC_OUT = 0;
PORTD_OUT = 0b00010100;
c = font[cVal][4];
PORTD_OUT = 0b00010110;
PORTC_OUT = (c & 0b10000000);
PORTD_OUT = 0b00010100;
PORTD_OUT = 0b00010110;
PORTC_OUT = 0;
PORTD_OUT = 0b00010100;
c = c << 1;
PORTD_OUT = 0b00010110;
PORTC_OUT = (c & 0b10000000);
PORTD_OUT = 0b00010100;
PORTD_OUT = 0b00010110;
PORTC_OUT = 0;
PORTD_OUT = 0b00010100;
c = c << 1;
PORTD_OUT = 0b00010110;
PORTC_OUT = (c & 0b10000000);
PORTD_OUT = 0b00010100;
PORTD_OUT = 0b00010110;
PORTC_OUT = 0;
PORTD_OUT = 0b00010100;
c = c << 1;
PORTD_OUT = 0b00010110;
PORTC_OUT = (c & 0b10000000);
PORTD_OUT = 0b00010100;
PORTD_OUT = 0b00010110;
PORTC_OUT = 0;
PORTD_OUT = 0b00010100;
c = c << 1;
PORTD_OUT = 0b00010110;
PORTC_OUT = (c & 0b10000000);
PORTD_OUT = 0b00010100;
PORTD_OUT = 0b00010110;
PORTC_OUT = 0;
PORTD_OUT = 0b00010100;
c = c << 1;
PORTD_OUT = 0b00010110;
PORTC_OUT = (c & 0b10000000);
PORTD_OUT = 0b00010100;
PORTD_OUT = 0b00010110;
PORTC_OUT = 0;
PORTD_OUT = 0b00010100;
c = c << 1;
PORTD_OUT = 0b00010110;
PORTC_OUT = (c & 0b10000000);
PORTD_OUT = 0b00010100;
PORTD_OUT = 0b00010110;
PORTC_OUT = 0;
PORTD_OUT = 0b00010100;
c = c << 1;
PORTD_OUT = 0b00010110;
PORTC_OUT = (c & 0b10000000);
PORTD_OUT = 0b00010100;
PORTD_OUT = 0b00010110;
PORTC_OUT = 0;
PORTD_OUT = 0b00010100;
chrX += (CHR_W + CHR_S);
if (chrX > 127 - (CHR_W + CHR_S))
{
chrY += (CHR_H + LINE_S);
if (chrY > 120)
{
chrY = 0;
}
chrX = 0;
}
}
break;
}
}
void Init()
{
unsigned int i;
//Port E setup
PORTE_DIR = 0b11111111; //Make E all outputs
PORTE_OUT = 0; //Set them all low
//Port D setuo
PORTD_DIR = 0b11111111; //Set all Port D pins as outputs
PORTD_OUT = 0; //Set all port D pins low
//Port C setup
PORTC_DIR = 0b11111111; //Set all Port C pins as outputs
PORTC_OUT = 0; //Set all port C pins low
OSC_CTRL = 0b00000010; //Enable the 32MHz clock
PORTE_OUT = OSC_STATUS; //Set the LEDs to see the status
while ((OSC_STATUS & 0b00000010) != 0b00000010) //Wait until the clock is stable
{
}
//Set the protection byte and then change the system clock
CCP = 0xD8;
CLK_CTRL = 0b00000001;
PORTD_OUT = 0b00000000; //Reset
for (i = 0; i < 10; i++)
{
asm("nop");
}
PORTD_OUT = 0b00010010; //Normal
OLEDCmd(0xFD);
OLEDData(0xB1);
OLEDCmd(0xA1);
OLEDData(0);
OLEDCmd(0xA2);
OLEDData(0);
OLEDCmd(0xAF); //Wake Up
PORTE_OUT = 1;
OLEDCmd(0xA0);
OLEDData(0b00110000);
OLEDCmd(0x5C);
for (i = 0; i < 16384; i++)
{
OLEDData(0);
OLEDData(0);
}
}
void OLEDCmd(unsigned char cmd)
{
PORTD_OUT = 0b00010010;
PORTC_OUT = cmd;
PORTD_OUT = 0b00010000;
}
void OLEDData(unsigned char data)
{
PORTD_OUT = 0b00010110;
PORTC_OUT = data;
PORTD_OUT = 0b00010100;
}
ISR(TCC0_OVF_vect)
{
}