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  
3283 kakl 17  
3275 kaklik 18 void main()
19 {
20 float temp1, temp2, humidity;
21 int16 i=0;
22  
23 setup_adc_ports(NO_ANALOGS|VSS_VDD);
24 setup_adc(ADC_CLOCK_DIV_2);
25 setup_spi(SPI_SS_DISABLED);
26 setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
27 setup_timer_1(T1_DISABLED);
28 setup_timer_2(T2_DISABLED,0,1);
29 setup_ccp1(CCP_OFF);
30 setup_comparator(NC_NC_NC_NC); // This device COMP currently not supported by the PICWizard
31 setup_oscillator(OSC_8MHZ);
32  
33  
3283 kakl 34 printf("GeoMet01A\r\n");
3275 kaklik 35 printf("(c) Kaklik 2013\r\n");
36 printf("www.mlab.cz\r\n");
3283 kakl 37  
38 // Init the HMC5883L. Set Mode register for
39 // continuous measurements.
40 hmc5883l_write_reg(HMC5883L_CFG_A_REG, 0x18); // no average, maximal update range
41 hmc5883l_write_reg(HMC5883L_CFG_B_REG, 0x00); // minimal range
42 hmc5883l_write_reg(HMC5883L_MODE_REG, 0x00);
3275 kaklik 43  
44 lcd_init();
45 lcd_putc("(c) Kaklik 2013");
46 lcd_gotoxy(3,2);
47 lcd_putc("www.mlab.cz");
48 Delay_ms(2000);
49 lcd_init();
50  
51 while (TRUE)
52 {
53 lcd_gotoxy(1,1);
54 temp1 = SHT25_get_temp();
55 humidity = SHT25_get_hum();
56 temp2= LTS01_get_temp();
3283 kakl 57 hmc5883l_read_data();
58  
59 printf(lcd_putc,"%f C %f \%%",temp1, humidity);
3275 kaklik 60 lcd_gotoxy(1,2);
61 printf(lcd_putc," %f C",temp2);
3283 kakl 62 printf("%ld %f %f %f ",i, temp1, humidity, temp2);
63 printf("%Ld %Ld %Ld \n\r", compass.x, compass.y, compass.z);
3275 kaklik 64 i++;
65 Delay_ms(100);
66 }
67  
68 }