Commit 2b902f90 authored by Johan Vaarlid - M19939's avatar Johan Vaarlid - M19939
Browse files

copy is just cus pls. Fungerende 'lf' med adc ut på screen

parent e9aefd6b
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -69,7 +69,9 @@ void oled_reset(){
void oled_clear_line(uint8_t line){ 		
	oled_write_c(0xb0 + line); 		// selects row/page
	for(int byte=0;byte<128;byte++){
		oled_d[byte]=0x00;		// Clear current column
			// Clear current column
		DISP_set_mode(1);
		SPI_MasterTransmit(0x00);
	}
}

+36 −18
Original line number Diff line number Diff line
@@ -52,20 +52,23 @@ const uint8_t OV[512] PROGMEM =
};

#define KLAKK 0x00
#define LED0 5
#define LED0_bm 0x20
#define LED0_PORT PORTF
#define FONTSIZE 5
#define ADC_PRINT_START 82
#define SW0_bm 0x40
#define SW0_PORT PORTF
int main(void)
{
	
	sei();
	_delay_ms(500);
	DISP_init();
	//DISP_init();
	adc_init();
	//DISP_write_bitmap(OV); //Printing Bitmap
	//DISP_print("Hello World!"); //Printing text
	PORTF.DIRSET = (1<<LED0);
	
	LED0_PORT.DIRSET = LED0_bm;
	SW0_PORT.DIRCLR = SW0_bm;
	oled_pos(1,12);
	oled_write_d(0xf8);
	oled_pos(2,12);
@@ -85,6 +88,7 @@ int main(void)
	fprintf(FONT5,"OV-POT read: ");
	
	
	
	uint8_t software_timer_print_adc = 0;
	uint8_t blinkled = 0;
	uint16_t data;
@@ -92,18 +96,7 @@ int main(void)
	
    while (1) 
     {
		 /*
		 for (uint8_t i=0;i<255;i++)
		 {
			 oled_set_brightness(i);
			 _delay_ms(10);
		 }
		 for (uint8_t i=255;i>0;i--)
		 {
			 oled_set_brightness(i);
			 _delay_ms(10);
		 }
		 */

		software_timer_print_adc++;
		blinkled++;
		uint8_t adc_curser_position=82;
@@ -172,7 +165,7 @@ int main(void)
		}
		if (blinkled==15)
		{
			PORTF.OUTTGL = (1<<LED0);
			PORTF.OUTTGL = LED0_bm;
			blinkled=0;
		}
		
@@ -183,6 +176,31 @@ int main(void)
		uint8_t voltage_fraction= (data*323ul%100000ul)/1000;
		fprintf(FONT5,"Voltage: %u.%02u V",voltage_integer,voltage_fraction);
		
		
		if (!(SW0_PORT.IN & (SW0_bm)))
		{
			oled_pos(0,0);
			DISP_write_bitmap(OV);
			while (!(SW0_PORT.IN & (SW0_bm)))
			{
			}
			DISP_clear();
			oled_pos(1,12);
			oled_write_d(0xf8);
			oled_pos(2,12);
			oled_write_d(0x1f);
			oled_pos(1,115);
			oled_write_d(0xf8);
			oled_pos(2,115);
			oled_write_d(0x1f);
			for(uint8_t i=0;i<101;i++)
			{
				oled_pos(1,13+i);
				oled_write_d(0x08);
				oled_pos(2,13+i);
				oled_write_d(0x10);
			}
			oled_pos(0,12);
			fprintf(FONT5,"OV-POT read: ");
		}
     }
}
+2 −2
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@
#define CS_bm (1 << 6) //on port C
#define CS_PORT PORTC //

#define SPI_INTERRUPT_ENABLE_bp 0
#define SPI_IF_ENABLE_bp 0

void SPI_MasterInit()
{
@@ -46,7 +46,7 @@ void SPI_MasterInit()

	//Make sure CS does not disable master mode
	SPI0.CTRLB |= (SPI_SSD_bm);
	SPI0.INTCTRL |= (1<<SPI_INTERRUPT_ENABLE_bp);
	SPI0.INTCTRL |= (1<<SPI_IF_ENABLE_bp);
}


+8 −8
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@
			<Description></Description>
			<Files xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
				<d4p1:anyType i:type="FileInfo">
					<AbsolutePath>C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.209\include</AbsolutePath>
					<AbsolutePath>C:/Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\ATmega_DFP\1.2.272\include</AbsolutePath>
					<Attribute></Attribute>
					<Category>include</Category>
					<Condition>C</Condition>
@@ -26,18 +26,18 @@
					<SourcePath></SourcePath>
				</d4p1:anyType>
				<d4p1:anyType i:type="FileInfo">
					<AbsolutePath>C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.209\include\avr\iom4809.h</AbsolutePath>
					<AbsolutePath>C:/Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\ATmega_DFP\1.2.272\include\avr\iom4809.h</AbsolutePath>
					<Attribute></Attribute>
					<Category>header</Category>
					<Condition>C</Condition>
					<FileContentHash>mWiFIOAGwUPlW0rYsXcjkg==</FileContentHash>
					<FileContentHash>fQaG1DJ4X5qUUwRvErAbNQ==</FileContentHash>
					<FileVersion></FileVersion>
					<Name>include/avr/iom4809.h</Name>
					<SelectString></SelectString>
					<SourcePath></SourcePath>
				</d4p1:anyType>
				<d4p1:anyType i:type="FileInfo">
					<AbsolutePath>C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.209\templates\main.c</AbsolutePath>
					<AbsolutePath>C:/Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\ATmega_DFP\1.2.272\templates\main.c</AbsolutePath>
					<Attribute>template</Attribute>
					<Category>source</Category>
					<Condition>C Exe</Condition>
@@ -48,7 +48,7 @@
					<SourcePath></SourcePath>
				</d4p1:anyType>
				<d4p1:anyType i:type="FileInfo">
					<AbsolutePath>C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.209\templates\main.cpp</AbsolutePath>
					<AbsolutePath>C:/Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\ATmega_DFP\1.2.272\templates\main.cpp</AbsolutePath>
					<Attribute>template</Attribute>
					<Category>source</Category>
					<Condition>C Exe</Condition>
@@ -59,7 +59,7 @@
					<SourcePath></SourcePath>
				</d4p1:anyType>
				<d4p1:anyType i:type="FileInfo">
					<AbsolutePath>C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.209\gcc\dev\atmega4809</AbsolutePath>
					<AbsolutePath>C:/Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\ATmega_DFP\1.2.272\gcc\dev\atmega4809</AbsolutePath>
					<Attribute></Attribute>
					<Category>libraryPrefix</Category>
					<Condition>GCC</Condition>
@@ -71,8 +71,8 @@
				</d4p1:anyType>
			</Files>
			<PackName>ATmega_DFP</PackName>
			<PackPath>C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.209/Atmel.ATmega_DFP.pdsc</PackPath>
			<PackVersion>1.2.209</PackVersion>
			<PackPath>C:/Program Files (x86)/Atmel/Studio/7.0/Packs/Atmel/ATmega_DFP/1.2.272/Atmel.ATmega_DFP.pdsc</PackPath>
			<PackVersion>1.2.272</PackVersion>
			<PresentInProject>true</PresentInProject>
			<ReferenceConditionId>ATmega4809</ReferenceConditionId>
			<RteComponents xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">