Rev Author Line No. Line
3275 kaklik 1 #include "main.h"
2  
3 #define LCD_ENABLE_PIN PIN_E0 ////
4 #define LCD_RS_PIN PIN_E1 ////
5 #define LCD_RW_PIN PIN_E2 ////
6 #define LCD_DATA4 PIN_D4 ////
7 #define LCD_DATA5 PIN_D5 ////
8 #define LCD_DATA6 PIN_D6 ////
9 #define LCD_DATA7 PIN_D7
10 #include <lcd.c>
11  
12 #include "../SHT25.h"
13 #include "../LTS01.h"
3283 kakl 14 #include "./HMC5883L.h"
15 #include <math.h>
3275 kaklik 16  
3286 kaklik 17 #define MPL3115_ADDR_R 0xC1 //addresa pro cteni
18 #define MPL3115_ADDR_W 0xC0
3283 kakl 19  
3286 kaklik 20 #include "../MPL3115.h"
21  
22  
3275 kaklik 23 void main()
24 {
3286 kaklik 25 float temp1, temp2, temp3, humidity, preasure;
3275 kaklik 26 int16 i=0;
27  
28 setup_adc_ports(NO_ANALOGS|VSS_VDD);
29 setup_adc(ADC_CLOCK_DIV_2);
30 setup_spi(SPI_SS_DISABLED);
31 setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
32 setup_timer_1(T1_DISABLED);
33 setup_timer_2(T2_DISABLED,0,1);
34 setup_ccp1(CCP_OFF);
35 setup_comparator(NC_NC_NC_NC); // This device COMP currently not supported by the PICWizard
36 setup_oscillator(OSC_8MHZ);
37  
38  
3283 kakl 39 printf("GeoMet01A\r\n");
3275 kaklik 40 printf("(c) Kaklik 2013\r\n");
41 printf("www.mlab.cz\r\n");
3283 kakl 42  
43 // Init the HMC5883L. Set Mode register for
44 // continuous measurements.
45 hmc5883l_write_reg(HMC5883L_CFG_A_REG, 0x18); // no average, maximal update range
46 hmc5883l_write_reg(HMC5883L_CFG_B_REG, 0x00); // minimal range
47 hmc5883l_write_reg(HMC5883L_MODE_REG, 0x00);
3275 kaklik 48  
49 lcd_init();
50 lcd_putc("(c) Kaklik 2013");
51 lcd_gotoxy(3,2);
52 lcd_putc("www.mlab.cz");
53 Delay_ms(2000);
54 lcd_init();
55  
56 while (TRUE)
57 {
58 lcd_gotoxy(1,1);
59 temp1 = SHT25_get_temp();
60 humidity = SHT25_get_hum();
61 temp2= LTS01_get_temp();
3283 kakl 62 hmc5883l_read_data();
3286 kaklik 63  
64 temp3=mpl3115_T();
65 preasure=mpl3115_P();
66 mpl3115_setP(); //nastaveni pro tlak a teplotu
67  
68 printf(lcd_putc,"%2.2f%cC %2.2f\%%",temp1, 0xb2, humidity);
3275 kaklik 69 lcd_gotoxy(1,2);
3286 kaklik 70 printf(lcd_putc,"%2.2f%cC %6.0fPa ",temp2, 0xb2, preasure);
71  
72 printf("%ld %f %f %f %6.2f %3.2f %Ld %Ld %Ld \n\r",i, temp1, humidity, temp2, preasure, temp3, compass.x, compass.y, compass.z);
3275 kaklik 73 i++;
3286 kaklik 74  
3275 kaklik 75 Delay_ms(100);
76 }
77  
78 }