Rev 2751 Rev 2752
Line -... Line 1...
-   1 /**** Automatic weather station 01A ****/
-   2 #define VERSION "0.1"
-   3 #define ID "$Id: irmrak4.c 2177 2011-09-05 18:56:16Z kaklik $"
1 #include "main.h" 4 #include "main.h"
-   5 #include <string.h>
-   6  
-   7 #CASE // Case sensitive compiler
2   8  
3 #define LCD_ENABLE_PIN PIN_E0 //// 9 #define LCD_ENABLE_PIN PIN_E0 ////
4 #define LCD_RS_PIN PIN_E1 //// 10 #define LCD_RS_PIN PIN_E1 ////
5 #define LCD_RW_PIN PIN_E2 //// 11 #define LCD_RW_PIN PIN_E2 ////
6 #define LCD_DATA4 PIN_D4 //// 12 #define LCD_DATA4 PIN_D4 ////
7 #define LCD_DATA5 PIN_D5 //// 13 #define LCD_DATA5 PIN_D5 ////
8 #define LCD_DATA6 PIN_D6 //// 14 #define LCD_DATA6 PIN_D6 ////
9 #define LCD_DATA7 PIN_D7 15 #define LCD_DATA7 PIN_D7
10 #include <lcd.c> 16 #include <lcd.c>
11   17  
-   18 #define SEND_DELAY 50 // Time between two characters on RS232
-   19  
-   20 char VER[4]=VERSION; // Buffer for concatenate of a version string
-   21  
12 #define ONE_WIRE_PIN PIN_C7 22 #define ONE_WIRE_PIN PIN_C7
13 #include "..\ds1820.c" 23 #include "..\ds1820.c"
14   24  
-   25 void welcome(void) // Welcome message
-   26 {
-   27 char REV[50]=ID; // Buffer for concatenate of a version string
-   28  
-   29 if (REV[strlen(REV)-1]=='$') REV[strlen(REV)-1]=0;
-   30 printf("\r\n\r\n# Mrakomer %s (C) 2011 UST\r\n",VER); // Welcome message
-   31 printf("#%s\r\n",&REV[4]);
-   32 // printf("#\r\n");
-   33 // printf("# commands: h, c, o, l, x, i, r, a, s, u\r\n");
-   34 // printf("# h_eat, c_old, o_pen, l_ock, x_open, ");
-   35 // printf("i_nfo, r_epeat, a_uto, s_single, u_pdate\r\n");
-   36 // printf("#\r\n");
-   37 // printf("# ver seq in[1/100 C] sky[1/100 C] sky[1/100 C] ");
-   38 // printf("out[1/100 C] heat[s] dome[s] check\r\n\r\n");
-   39  
-   40 //---WDT
-   41 restart_wdt();
-   42 }
-   43  
15 void main() 44 void main()
16 { 45 {
-   46 unsigned int16 seq=0;
17   47  
18 setup_adc_ports(NO_ANALOGS|VSS_VDD); 48 setup_adc_ports(NO_ANALOGS|VSS_VDD);
19 setup_adc(ADC_CLOCK_DIV_2); 49 setup_adc(ADC_CLOCK_DIV_2);
20 setup_spi(SPI_SS_DISABLED); 50 setup_spi(SPI_SS_DISABLED);
21 setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); 51 setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
Line 28... Line 58...
28   58  
29 printf("Simple Thermomether\r\n",); 59 printf("Simple Thermomether\r\n",);
30 printf("(c) Kaklik 2013\r\n"); 60 printf("(c) Kaklik 2013\r\n");
31 printf("www.mlab.cz\r\n"); 61 printf("www.mlab.cz\r\n");
32   62  
-   63 welcome();
-   64  
33 /* lcd_init(); 65 /* lcd_init();
34 lcd_putc("(c) Kaklik 2013"); 66 lcd_putc("(c) Kaklik 2013");
35 lcd_gotoxy(3,2); 67 lcd_gotoxy(3,2);
36 lcd_putc("www.mlab.cz"); 68 lcd_putc("www.mlab.cz");
37 Delay_ms(2000); 69 Delay_ms(2000);
38 */ 70 */
39 while (TRUE) 71 while (TRUE)
40 { 72 {
41 lcd_gotoxy(1,2); 73 lcd_gotoxy(1,2);
42 // printf(lcd_putc,"T: %f K ",ds1820_read()+273.15); 74 // printf(lcd_putc,"T: %f K ",ds1820_read()+273.15);
-   75  
43 printf("$T1.0 %f \r\n",ds1820_read()+273.15); 76 // printf("$T1.0 %f \r\n",ds1820_read()+273.15);
44 Delay_ms(100); 77 delay_ms(100);
-   78 { // printf
-   79 char output[8]; // Output buffer
-   80 int8 j; // String pointer
-   81 int8 check=0; // Checksum is calculated between '$' and '*'
-   82  
-   83 delay_us(SEND_DELAY);
-   84 putc('$');
-   85 delay_us(SEND_DELAY);
-   86 sprintf(output,"AWS%s \0",VER);
-   87 j=0; while(output[j]!=0) { delay_us(SEND_DELAY); putc(output[j]); check^=output[j++]; }
-   88 sprintf(output,"%Lu \0", seq);
-   89 j=0; while(output[j]!=0) { delay_us(SEND_DELAY); putc(output[j]); check^=output[j++]; }
-   90 sprintf(output,"%f \0", ds1820_read()+273.15);
-   91 j=0; while(output[j]!=0) { delay_us(SEND_DELAY); putc(output[j]); check^=output[j++]; }
-   92 sprintf(output,"*%X\r\n\0", check);
-   93 j=0; while(output[j]!=0) { delay_us(SEND_DELAY); putc(output[j++]); }
-   94 delay_us(SEND_DELAY);
-   95 }
-   96
-   97 //---WDT
-   98 restart_wdt();
-   99 seq++; // Increment the number of measurement
-   100  
45 } 101 }
46   102  
47 } 103 }
-   104  
-   105 //#include "dbloader.c" // Space reservation for the BootLoader