main.c 3.85 KB
Newer Older
Petter Breedveld's avatar
Petter Breedveld committed
1
2
3
4
//
//LF Session 3 Task 2: OLED
//main.c
//
Petter Breedveld's avatar
Petter Breedveld committed
5
6
7

#define F_CPU 3333333UL

Petter Breedveld's avatar
Petter Breedveld committed
8

Petter Breedveld's avatar
Petter Breedveld committed
9
10
11
12
13
#include <avr/io.h>
#include <avr/pgmspace.h>

#include "display.h"

Petter Breedveld's avatar
Petter Breedveld committed
14
/*
Petter Breedveld's avatar
Petter Breedveld committed
15
	In this exercise you will write a driver for the SPI module. You will connect the OLED screen to the EXT3 header
Petter Breedveld's avatar
Petter Breedveld committed
16
17
18
19
	and use your SPI driver to write bitmaps and text to the screen.
	A finished driver for the screen is provided (display.c), as as a font for it. These build uppon the SPI driver.
	You can read display.h to see what functions you can use with the screen.
	No help beyond the function headers is provided. To start, it's recommend you: 
Petter Breedveld's avatar
Petter Breedveld committed
20

Petter Breedveld's avatar
Petter Breedveld committed
21
22
	a) glance over the chapter on SPI in the ATtiny817 datasheet
	b) find out what pins of the ATtiny the screen is connected to 
Petter Breedveld's avatar
Petter Breedveld committed
23
24


Petter Breedveld's avatar
Petter Breedveld committed
25
*/
Petter Breedveld's avatar
Petter Breedveld committed
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64

const uint8_t bitmap[512] PROGMEM =
{
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0xE0, 0xFF, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x70, 0x38, 0xDE, 0x3F, 0x3E, 0x18, 0x00, 0x00,
	0x00, 0xF0, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0xD8, 0x78, 0xDE, 0x3B, 0x33, 0x1C, 0x00, 0x00,
	0x00, 0xFC, 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x8C, 0x79, 0x8E, 0x21, 0x23, 0x1C, 0x00, 0x00,
	0x00, 0xFE, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x8C, 0x79, 0x8E, 0xA9, 0x23, 0x3C, 0x00, 0x00,
	0x00, 0x3F, 0x00, 0xF8, 0x01, 0x00, 0x00, 0x00, 0x8C, 0x79, 0x8F, 0x89, 0x03, 0x3C, 0x00, 0x00,
	0x00, 0x1F, 0x00, 0xF0, 0x01, 0x00, 0x00, 0x00, 0x8C, 0x79, 0x8D, 0x8F, 0x03, 0x36, 0x00, 0x00,
	0x80, 0x0F, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x8C, 0xF9, 0x8D, 0x8B, 0x7B, 0x32, 0x00, 0x00,
	0xC0, 0x07, 0x00, 0xC0, 0x07, 0x00, 0x00, 0x00, 0x8C, 0xD9, 0x8D, 0x89, 0x33, 0x3E, 0x00, 0x00,
	0xC0, 0x03, 0x00, 0x80, 0x07, 0x00, 0x00, 0x00, 0x8C, 0xD9, 0x8D, 0xA1, 0x33, 0x72, 0x00, 0x00,
	0xE0, 0x03, 0x00, 0x80, 0x0F, 0x00, 0x00, 0x00, 0x8C, 0xD9, 0x8D, 0xA1, 0x33, 0x72, 0x00, 0x00,
	0xE0, 0xFF, 0xC7, 0xFF, 0x0F, 0x00, 0x00, 0x00, 0xD8, 0xD9, 0x8D, 0x31, 0x33, 0x63, 0x00, 0x00,
	0xE0, 0xFF, 0xC7, 0xFF, 0x0F, 0x00, 0x00, 0x00, 0xF8, 0xFC, 0xDE, 0x3F, 0x3F, 0xF7, 0x00, 0x00,
	0xE0, 0xFF, 0xC7, 0xFF, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0xE0, 0xFF, 0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 0xC3, 0x60, 0xC8, 0x1C,
	0xFE, 0x7F, 0xFE, 0xFD, 0xFF, 0x00, 0x00, 0x0E, 0x47, 0x66, 0x98, 0x1B, 0xC2, 0x60, 0xC8, 0x0C,
	0xFE, 0x7F, 0xFE, 0xFD, 0xFF, 0x00, 0x00, 0x0E, 0x47, 0x6E, 0x99, 0x1B, 0xC3, 0x61, 0xCC, 0x0C,
	0xFE, 0x7F, 0xFE, 0xFD, 0xFF, 0x00, 0x00, 0x8E, 0x7F, 0xFF, 0xBD, 0xFF, 0xE3, 0xF3, 0xEF, 0x07,
	0xFE, 0x7F, 0xFE, 0xFD, 0xFF, 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
};

int main(void)
{
Petter Breedveld's avatar
Petter Breedveld committed
65
66
67
68
	
	//Code here
	
	
Petter Breedveld's avatar
Petter Breedveld committed
69
70
    while (1) 
     {
Petter Breedveld's avatar
Petter Breedveld committed
71
		 
Petter Breedveld's avatar
Petter Breedveld committed
72
73
     }
}