//##############################################################################################
// Title	:	NOKIA_3310.c
// Version	:	v1.4
// Date		:	Januar 2010
// Info		:	Nokia 3310 Lcd Ansteuerung
// Author	:	Martin Junghans
// Compiler	:	AVR-GCC - WinAVR
//##############################################################################################

#include <avr/io.h>
#include <avr/pgmspace.h>
#include <inttypes.h>
#include "Nokia_3310.h"
#include <util/delay.h>

#include <avr/interrupt.h>


#include "Bmp_Apple.h"
#include "Bmp_Nokia.h"

//	#include "f8x11.h"
//	#include "f15x22.h"
#include "f3x5.h"
#include "f5x7.h"
#include "f8x8.h" 			//schrift und zahl

#define sbi(ADDRESS,BIT) ((ADDRESS) |= (1<<(BIT)))
#define cbi(ADDRESS,BIT) ((ADDRESS) &= ~(1<<(BIT)))

int main(void)
{
	int x =0;
	N3310_spiInit();
	N3310_SetBackLightInit(0);
	N3310_InitDisplay();

	N3310_clipping_off	( );	// on =
	N3310_SetRot		(0);	// on =
	N3310_SetTextFormat	(0); 	// on =
	N3310_SetTextTyp	(0);	// on =
	N3310_SetFNull		(0);	// on =
	N3310_SetTextColor	(1);	// on =
	N3310_SetFont(&f8x8[0]);

	while(1)
	{

		N3310_ClearLcd();
		if (x<100) 	{x+=10; N3310_SetBackLight(x);}
		N3310_goto(20, 20);	N3310_PutStr(PSTR("Helligkeit %"));
		N3310_goto(60, 20);	N3310_PutInt(x);
		_delay_ms(2000);

		N3310_ClearLcd();
		N3310_DrawLine(0,0	,N3310_B_X,N3310_H_Y	,1); //vertikal x
		N3310_DrawLine(N3310_B_X,	0,0,N3310_H_Y	,1); //waagerecht y
		N3310_RoundRect(10,10	,40,20 ,7, 7, 1, 2);
		N3310_Circle		( 20,  35,  5,  1,  2);
		N3310_Circle		( 50,  35,  10,  1,  1);
		_delay_ms(2000);
		
		N3310_ClearLcd();
		N3310_PutRawBmp16(0,0, Bmp_Nokia, 84, 48);		// N3310_PutRawBmp16(x0,page0, bild, breite,höhe);
		_delay_ms(2000);

		
		N3310_ClearLcd();
		N3310_PutRawBmp16(5,1, Bmp_Apple, 24,24);		// N3310_PutRawBmp16(x0,page0, bild, breite,höhe);

		N3310_goto(40, 10);	N3310_PutStr(PSTR("Das"));
		N3310_goto(40, 20);	N3310_PutStr(PSTR("Apple"));
		N3310_goto(40, 30);	N3310_PutStr(PSTR("Logo"));
		_delay_ms(2000);

	}
}
