Rev 2752 Rev 2768
Line 4... Line 4...
4 #include "main.h" 4 #include "main.h"
5 #include <string.h> 5 #include <string.h>
6   6  
7 #CASE // Case sensitive compiler 7 #CASE // Case sensitive compiler
8   8  
9 #define LCD_ENABLE_PIN PIN_E0 //// 9 /*#define LCD_ENABLE_PIN PIN_E0 ////
10 #define LCD_RS_PIN PIN_E1 //// 10 #define LCD_RS_PIN PIN_E1 ////
11 #define LCD_RW_PIN PIN_E2 //// 11 #define LCD_RW_PIN PIN_E2 ////
12 #define LCD_DATA4 PIN_D4 //// 12 #define LCD_DATA4 PIN_D4 ////
13 #define LCD_DATA5 PIN_D5 //// 13 #define LCD_DATA5 PIN_D5 ////
14 #define LCD_DATA6 PIN_D6 //// 14 #define LCD_DATA6 PIN_D6 ////
15 #define LCD_DATA7 PIN_D7 15 #define LCD_DATA7 PIN_D7
16 #include <lcd.c> 16 #include <lcd.c>
17   17 */
18 #define SEND_DELAY 50 // Time between two characters on RS232 18 #define SEND_DELAY 50 // Time between two characters on RS232
19   19  
20 char VER[4]=VERSION; // Buffer for concatenate of a version string 20 char VER[4]=VERSION; // Buffer for concatenate of a version string
21   21  
22 #define ONE_WIRE_PIN PIN_C7 22 #define ONE_WIRE_PIN PIN_C7
23 #include "..\ds1820.c" 23 #include "..\ds1820.c"
24   24  
-   25 #include "..\SHT.c"
-   26  
-   27  
25 void welcome(void) // Welcome message 28 void welcome(void) // Welcome message
26 { 29 {
27 char REV[50]=ID; // Buffer for concatenate of a version string 30 char REV[50]=ID; // Buffer for concatenate of a version string
28   31  
29 if (REV[strlen(REV)-1]=='$') REV[strlen(REV)-1]=0; 32 if (REV[strlen(REV)-1]=='$') REV[strlen(REV)-1]=0;
Line 66... Line 69...
66 lcd_putc("(c) Kaklik 2013"); 69 lcd_putc("(c) Kaklik 2013");
67 lcd_gotoxy(3,2); 70 lcd_gotoxy(3,2);
68 lcd_putc("www.mlab.cz"); 71 lcd_putc("www.mlab.cz");
69 Delay_ms(2000); 72 Delay_ms(2000);
70 */ 73 */
-   74  
-   75 sht_init();
-   76  
71 while (TRUE) 77 while (TRUE)
72 { 78 {
-   79 char output[8]; // Output buffer
-   80 int8 j; // String pointer
-   81 int8 check=0; // Checksum is calculated between '$' and '*'
-   82 float SHT_temp,SHT_hum;
-   83  
-   84  
73 lcd_gotoxy(1,2); 85 // lcd_gotoxy(1,2);
74 // printf(lcd_putc,"T: %f K ",ds1820_read()+273.15); 86 // printf(lcd_putc,"T: %f K ",ds1820_read()+273.15);
75   87  
76 // printf("$T1.0 %f \r\n",ds1820_read()+273.15); 88 // printf("$T1.0 %f \r\n",ds1820_read()+273.15);
77 delay_ms(100); 89 delay_ms(100);
78 { // printf 90 { // printf
-   91  
79 char output[8]; // Output buffer 92 sht_rd(SHT_temp,SHT_hum);
80 int8 j; // String pointer -  
81 int8 check=0; // Checksum is calculated between '$' and '*' -  
82   93  
83 delay_us(SEND_DELAY); 94 delay_us(SEND_DELAY);
84 putc('$'); 95 putc('$');
85 delay_us(SEND_DELAY); 96 delay_us(SEND_DELAY);
86 sprintf(output,"AWS%s \0",VER); 97 sprintf(output,"AWS%s \0",VER);
87 j=0; while(output[j]!=0) { delay_us(SEND_DELAY); putc(output[j]); check^=output[j++]; } 98 j=0; while(output[j]!=0) { delay_us(SEND_DELAY); putc(output[j]); check^=output[j++]; }
88 sprintf(output,"%Lu \0", seq); 99 sprintf(output,"%Lu \0", seq);
89 j=0; while(output[j]!=0) { delay_us(SEND_DELAY); putc(output[j]); check^=output[j++]; } 100 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); 101 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++]; } 102 j=0; while(output[j]!=0) { delay_us(SEND_DELAY); putc(output[j]); check^=output[j++]; }
-   103 sprintf(output,"%f \0", SHT_temp + 273.15);
-   104 j=0; while(output[j]!=0) { delay_us(SEND_DELAY); putc(output[j]); check^=output[j++]; }
-   105 sprintf(output,"%f \0", SHT_hum);
-   106 j=0; while(output[j]!=0) { delay_us(SEND_DELAY); putc(output[j]); check^=output[j++]; }
92 sprintf(output,"*%X\r\n\0", check); 107 sprintf(output,"*%X\r\n\0", check);
93 j=0; while(output[j]!=0) { delay_us(SEND_DELAY); putc(output[j++]); } 108 j=0; while(output[j]!=0) { delay_us(SEND_DELAY); putc(output[j++]); }
94 delay_us(SEND_DELAY); 109 delay_us(SEND_DELAY);
95 } 110 }
96 111