1 | u8 zl,zlx,x;
|
2 | u16 y;
|
3 | y=0x4567;
|
4 | u8 zl_sensors_eep;
|
5 | u32 neu_sensors_eep=0;
|
6 | u8 zl_sensors_hw;
|
7 | u8 zl_sensors_hw_found;
|
8 | u32 neu_sensors_hw=0;
|
9 |
|
10 | #define eep_ds1820_adr 20
|
11 |
|
12 | //eeprom_update_word(26,0xffff);
|
13 |
|
14 | //A. eeprom in array einlesen
|
15 | zl_sensors_eep=0;
|
16 | for(zl=0;zl<ds1820_max_sensors;zl++){
|
17 | feld_eep[zl] = eeprom_read_word(eep_ds1820_adr+zl*2);
|
18 | lg(zl%max_zl_y+1,12);lcd_hex16(feld_eep[zl]);
|
19 | if(feld_eep[zl]!=0 && feld_eep[zl]!=0xffff){
|
20 | zl_sensors_eep++;
|
21 | }else{
|
22 | break;}
|
23 | }
|
24 | lgi(2,18,zl_sensors_eep);
|
25 |
|
26 |
|
27 |
|
28 | //B. sensor-ids in array einlesen
|
29 |
|
30 | zl_sensors_hw=0;
|
31 | ds1820_start_meas();
|
32 | wait;wait;wait;
|
33 | read_measkk();
|
34 |
|
35 |
|
36 | while(ds1820_idkk[zl_sensors_hw]){
|
37 | // for(zl=0;zl<4;zl++){
|
38 | lg(zl_sensors_hw%max_zl_y+1,1);lcd_hex16(ds1820_idkk[zl_sensors_hw]);lw(":");li(ds1820_valkk[zl_sensors_hw]);
|
39 | // eeprom_update_word((u16*)(eep_ds1820_adr+zl*2),ds1820_idkk[zl]);
|
40 | x=eep_ds1820_adr;
|
41 | x+=zl*2;
|
42 | lgi(4,1,x);
|
43 | //if(ds1820_idkk[zl]>0)eeprom_update_word(x,ds1820_idkk[zl]);
|
44 | wait;
|
45 |
|
46 | zl_sensors_hw++;
|
47 | }
|
48 | lgi(1,18,zl_sensors_hw);
|
49 | zlx++;
|
50 |
|
51 |
|
52 |
|
53 | //C.feststellen, ob neue Sensoren vorhanden sind
|
54 | u32 neu=0;
|
55 |
|
56 | zl_sensors_hw_found=0;
|
57 | for(i=0;i<zl_sensors_hw;i++){//zl=>anz gefundene Sensoren
|
58 | sbi(neu,i);
|
59 | /**/for(x=0;x<ds1820_max_sensors;x++){
|
60 | //lgi(1,1,ds1820_idkk[i]);lw(" ");
|
61 | //lgi(2,1,feld_eep[x]);lw(" ");
|
62 | //wait;
|
63 | if(ds1820_idkk[i]==feld_eep[x]){
|
64 | cbi(neu,i);
|
65 | zl_sensors_hw_found++;
|
66 | sbi(neu_sensors_eep,x);
|
67 | continue;
|
68 | }
|
69 | }//for x
|
70 |
|
71 | }//for i
|
72 |
|
73 | lgw(4,1,"n.s.:");li(neu);lw("!");
|
74 | li(zl_sensors_hw_found);lw("!");
|
75 | li(zl_sensors_eep);lw("!");
|
76 | li(neu_sensors_eep);lw("!");
|
77 |
|
78 |
|
79 | //D. Auswerten eep
|
80 | zl=0;
|
81 | if(zl_sensors_eep-zl_sensors_hw_found){
|
82 | for(i=0;i<zl_sensors_eep;i++) {
|
83 | if(!gbi(neu_sensors_eep,i)){
|
84 | // lg(1+zl%max_zl_y,1);lcd_hex16(feld_eep[i]);lw(" delete in eep?");wait;
|
85 | lg(1,5);lcd_hex16(feld_eep[i]);lw("del eep?");
|
86 | x=eep_ds1820_adr+i*2;li(x);
|
87 | timeoutx=500;
|
88 | while(timeoutx){
|
89 | if(tast1){
|
90 | eeprom_update_word((u16*)(x),0xffff);
|
91 | lgw(1,1,"done delete");
|
92 | }
|
93 | }
|
94 | zl++;
|
95 | }
|
96 | }
|
97 | }
|
98 |
|
99 |
|
100 |
|
101 | //E. Auswerten hw
|
102 | zl=0;
|
103 | if(zl_sensors_hw-zl_sensors_hw_found){
|
104 | for(i=0;i<zl_sensors_hw;i++) {
|
105 | if(gbi(neu,i)){
|
106 | // lg(1+zl%max_zl_y,1);lcd_hex16(feld_eep[i]);lw(" delete in eep?");wait;
|
107 | x=eep_ds1820_adr+(zl_sensors_eep+i)*2;
|
108 | lg(2,4);lcd_hex16(ds1820_idkk[i]);lw("stor hw?");li(x);
|
109 | timeoutx=500;
|
110 | while(timeoutx){
|
111 | if(tast1){
|
112 | eeprom_update_word(x,ds1820_idkk[i]);
|
113 | lgw(1,1,"done store");
|
114 |
|
115 | }
|
116 | }
|
117 | zl++;
|
118 | }
|
119 | }
|
120 | }
|
121 | lgw(1,4,"end");
|