1 // Copyright (c) 2017, Tobias Mueller tm(at)tm3d.de
2 // All rights reserved.
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the
14 // * All advertising materials mentioning features or use of this
15 // software must display the following acknowledgement: This product
16 // includes software developed by tm3d.de and its contributors.
17 // * Neither the name of tm3d.de nor the names of its contributors may
18 // be used to endorse or promote products derived from this software
19 // without specific prior written permission.
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #include "owDeviceConfig.h"
37 std::vector<std::string> owDeviceConfig::getFamilyInfo(uint8_t famcode) {
38 std::vector<std::string> l;
41 l.push_back("DS2401,DS2411");
42 l.push_back("DS1990A");
43 l.push_back("silicon serial number");
46 l.push_back("DS1425");
47 l.push_back("DS1991");
48 l.push_back("multikey 1153bit secure");
51 l.push_back("DS2404");
52 l.push_back("DS1994");
53 l.push_back("econoram time chip");
56 l.push_back("DS2405");
58 l.push_back("push_backresable Switch");
61 l.push_back(""); l.push_back("DS1993");
62 l.push_back("4k memory ibutton");
65 l.push_back(""); l.push_back("DS1992");
66 l.push_back("1k memory ibutton");
69 l.push_back("DS2502"); l.push_back("DS1982");
70 l.push_back("1k add - only memory");
72 case 0x0A: l.push_back(""); l.push_back("DS1995");
73 l.push_back("16k memory ibutton"); break;
74 case 0x0B: l.push_back("DS2505"); l.push_back("DS1985");
75 l.push_back("16k add - only memory"); break;
76 case 0x0C: l.push_back(""); l.push_back("DS1996");
77 l.push_back("64k memory ibutton"); break;
78 case 0x0F: l.push_back("DS2506"); l.push_back("1986");
79 l.push_back("64k add - only memory"); break;
80 case 0x10:l.push_back("DS18S20"); l.push_back("DS1920");
81 l.push_back("high precision digital thermometer"); break;
82 case 0x12:l.push_back("DS2406,DS2407"); l.push_back("");
83 l.push_back("dual addressable switch plus 1k memory"); break;
84 case 0x14:l.push_back("DS2430A"); l.push_back("1971");
85 l.push_back("256 eeprom"); break;
86 case 0x1A:l.push_back(""); l.push_back("DS1963L");
87 l.push_back("4k Monetary"); break;
88 case 0x1B:l.push_back("DS2436"); l.push_back("");
89 l.push_back("battery id / monitor chip"); break;
90 case 0x1C:l.push_back("DS28E04-100"); l.push_back("");
91 l.push_back("4k EEPROM with PIO 1C"); break;
92 case 0x1D:l.push_back("DS2423"); l.push_back("");
93 l.push_back("4k ram with counter"); break;
94 case 0x1F:l.push_back("DS2409"); l.push_back("");
95 l.push_back("microlan coupler"); break;
96 case 0x20 : l.push_back("DS2450"); l.push_back("");
97 l.push_back("quad a / d converter"); break;
98 case 0x21: l.push_back(""); l.push_back("DS1921");
99 l.push_back("Thermachron"); break;
100 case 0x22: l.push_back("DS1822"); l.push_back("");
101 l.push_back("Econo Digital Thermometer"); break;
102 case 0x23: l.push_back("DS2433"); l.push_back("");
103 l.push_back("4k eeprom"); break;
104 case 0x24: l.push_back("DS2415"); l.push_back("");
105 l.push_back("time chip"); break;
106 case 0x26: l.push_back("DS2438"); l.push_back("");
107 l.push_back("smart battery monitor"); break;
108 case 0x27:l.push_back("DS2417"); l.push_back("");
109 l.push_back("time chip with interrupt"); break;
110 case 0x28:l.push_back("DS18B20"); l.push_back("");
111 l.push_back("programmable resolution digital thermometer"); break;
112 case 0x29:l.push_back("DS2408"); l.push_back("");
113 l.push_back("8 - channel addressable switch"); break;
114 case 0x2C:l.push_back("DS2890"); l.push_back("");
115 l.push_back("digital potentiometer"); break;
116 case 0x2D:l.push_back("DS2431"); l.push_back("");
117 l.push_back("1k eeprom"); break;
118 case 0x2E:l.push_back("DS2770"); l.push_back("");
119 l.push_back("battery monitor and charge controller"); break;
120 case 0x30:l.push_back("DS2760/61/62"); l.push_back("");
121 l.push_back("high - precision li + battery monitor"); break;
122 case 0x31:l.push_back("DS2720"); l.push_back("");
123 l.push_back("efficient addressable single - cell rechargable lithium protection ic"); break;
124 case 0x33: l.push_back("DS2432"); l.push_back("DS1961S");
125 l.push_back("1k protected eeprom with SHA - 1"); break;
126 case 0x36:l.push_back("DS2740"); l.push_back("");
127 l.push_back("high precision coulomb counter"); break;
128 case 0x37: l.push_back(""); l.push_back("DS1977");
129 l.push_back("Password protected 32k eeprom"); break;
130 case 0x3A:l.push_back("DS2413"); l.push_back("");
131 l.push_back("dual channel addressable switch"); break;
132 case 0x41:l.push_back("DS2422"); l.push_back("DS1922L/DS1922T/DS1923");
133 l.push_back("Temperature Logger 8k mem"); break;
134 case 0x51:l.push_back("DS2751"); l.push_back("");
135 l.push_back("multichemistry battery fuel gauge"); break;
136 case 0x81: l.push_back(""); l.push_back("DS1420");
137 l.push_back("Serial ID Button"); break;
138 case 0x84:l.push_back("DS2404S"); l.push_back("");
139 l.push_back("dual port plus time"); break;
140 case 0x89:l.push_back("DS2502-E48"); l.push_back("DS1982U");
141 l.push_back("48 bit node address chip"); break;
142 case 0x8B:l.push_back("DS2502/DS2505"); l.push_back("DS1985U");
143 l.push_back("16k add - only"); break;
144 case 0x8F:l.push_back("DS2506"); l.push_back("DS1986U");
145 l.push_back("64k add - only uniqueware"); break;
146 case 0xFF:l.push_back("LCD"); l.push_back("");
147 l.push_back("(Swart)"); break;
148 case 0xA3:l.push_back("ATTINY84A"); l.push_back("");
149 l.push_back("1-Wire Flasher"); break;
150 default:l.push_back("unknown"); l.push_back("unknown");
151 l.push_back("Device not int list");
157 std::vector<std::string> owDeviceConfig::getQuantityFromNumber(uint8_t code) {
158 std::vector<std::string> l;
161 l.push_back("temperature");
162 l.push_back("Temperatur");
166 l.push_back("pressure");
167 l.push_back("Druck");
171 l.push_back("illuminance");
172 l.push_back("Beleuchtungsstärke");
176 l.push_back("humidity");
177 l.push_back("Luftfeuchte");
181 l.push_back("constant");
182 l.push_back("Konstante");
186 l.push_back("voltage");
187 l.push_back("Spannung");
191 l.push_back("current");
192 l.push_back("Strom");
200 l.push_back("Counter");
201 l.push_back("Zähler");
210 l.push_back("resistance");
211 l.push_back("Widerstand");
215 l.push_back("wind speed");
216 l.push_back("Windgeschwindigkeit");
220 l.push_back("wind speed max");
221 l.push_back("Maximale Windgeschwindigkeit");
225 l.push_back("wind direction");
226 l.push_back("Windrichtung");
230 l.push_back("wind direction variance");
231 l.push_back("Varianz der Windrichtung");
235 l.push_back("illuminance red");
236 l.push_back("Beleuchtungsstärke Rot");
239 l.push_back("illuminance green");
240 l.push_back("Beleuchtungsstärke Grün");
243 l.push_back("illuminance blue");
244 l.push_back("Beleuchtungsstärke Blau");
248 l.push_back("particulate mass concentration PM1");
249 l.push_back("Feinstaubkonzentration PM1");
250 l.push_back("µg/m³");
252 l.push_back("particulate mass concentration PM2.5");
253 l.push_back("Feinstaubkonzentration PM2.5");
254 l.push_back("µg/m³");
256 l.push_back("particulate mass concentration PM4");
257 l.push_back("Feinstaubkonzentration PM4");
258 l.push_back("µg/m³");
260 l.push_back("particulate mass concentration PM10");
261 l.push_back("Feinstaubkonzentration PM10");
262 l.push_back("µg/m³");
264 l.push_back("number concentration PM0.5");
265 l.push_back("Partikelzahl PM0.5");
266 l.push_back("#/cm³");
268 l.push_back("number concentration PM1");
269 l.push_back("Partikelzahl PM1");
270 l.push_back("#/cm³");
272 l.push_back("number concentration PM2.5");
273 l.push_back("Partikelzahl PM2.5");
274 l.push_back("#/cm³");
276 l.push_back("number concentration PM4");
277 l.push_back("Partikelzahl PM4");
278 l.push_back("#/cm³");
280 l.push_back("number concentration PM10");
281 l.push_back("Partikelzahl PM10");
282 l.push_back("#/cm³");
284 l.push_back("typical particle size");
285 l.push_back("Durchschnittliche Partikelgröße");
297 //Optimization necessary
298 if (language==OWDC_LANGUAGE_ENGLISH) l.erase(l.begin()+1);
299 if (language==OWDC_LANGUAGE_GERMAN) l.erase(l.begin());
304 double owDeviceConfig::calculateValueFromNumber(int code, int vn, std::vector<int> V) {
306 case 01: return V[vn] / 16.0; break;
307 case 2:return V[vn]/1.6; break;
308 case 3:return V[vn]*0.2 + 700; break;
309 case 4:return exp(V[vn] / 160.0); break;
310 case 5:return V[vn]*62.5 + 55000; break;
311 case 6:return V[vn] / 256.0; break;
312 case 7:return (((double)V[2] / (double)V[1] - 0.16) / 0.0062) / (1.0546 - 0.00216*V[0]/256.0); break;
313 case 8:return V[vn] / 100.0; break;
314 case 9:return V[vn] / 65535.0*5.1; break;
315 case 10:return V[vn] / 65535.0*2.55; break;
316 case 11:return V[vn] / 65535.0*1.1; break;
317 case 12:return V[vn] / 10.0; break;
318 case 13:return V[vn]; break;
319 case 14:return (V[vn] - 32767.0) / 100.0; break;
320 case 15:return exp((V[vn]-32767.0)/1000.0); break;
321 case 16:return V[vn]/32.0; break;
322 case 17:return V[vn]*0.2441/1000.0; break; //Vsens DS2438
323 case 18:return V[vn]/8.0;break;
324 case 19:return V[vn]/500.0*14.0;break; //Test
325 case 20:return V[vn]*0.5+700;break;
326 case 21:return V[vn]+1280; break;
327 case 22:return V[vn]*10;break;
328 case 23:return V[vn]*0.025+700.0;break;
329 case 24:return V[vn]*1.1/1024.0;break;
330 case 25:return V[vn]*3.0/1024.0;break;
331 case 26:return V[vn]*5.0/1024.0;break;
332 case 27:return ((double)V[2]+(double)V[1]/1000.0)/8.0;break;
333 case 28:return exp(V[vn]/2560.0);break;
334 case 29:return ((double)V[1]*10.0+(double)V[2]/100.0);break;
335 case 30: return V[vn] / 2.0; break;
336 case 31: return V[vn] / 4.0; break;
337 case 32: return V[vn] / 5.0; break;
338 default:return V[vn];
342 std::string owDeviceConfig::getSensorChip(uint8_t ch) {
345 switch(config.sens[ch]) {
346 case 1: s="DS18B20";break;
347 case 2: s="DS2438";break; //Temperatur Sensor
348 case 3: s="DS2438";break; //Spannung
349 case 4: s="DS2438";break; // Spannung / Strom
350 case 5: s="DS2450";break; // Spannung
351 case 6: s="Thermoelement";break; // Hochtemperatur Sensor
352 case 7: s="SHT21";break; // Feuchte/Temperatur Sensor
353 case 8: s="SHT25";break; // Feuchte/Temperatur Präzisionssensor
354 case 9: s="DHT22";break; // Feuchte/Temperatur Sensor
355 case 10: s="HIH9021";break; // Feuchte/Temperatur Präzisionssensor
356 case 11: s="HDC1080";break; // Feuchte/Temperatur Sensor
357 case 12: s="HIH4030";break; // Feuchte/Temperatur Sensor analog
358 case 13: s="HIH5030";break; // Feuchte/Temperatur Sensor analog
359 case 14: s="BMP280";break; // Luftdrucksensor
360 case 15: s="MAX44009";break; // Umgebungslicht-Sensor
361 case 16: s="CDM7160";break; // CO2-Sensor
362 case 17: s="MAX1164/TGS8100";break; // VOC-Sensor
363 case 18: s="TGS8100 direkt";break; // VOC-Sensor
364 case 19: s="DS2423";break; // Counter
365 case 20: s="Intern ADC";break;
366 case 21: s="SHT35";break; // Feuchte/Temperatur Bester
367 case 22: s="SHT31";break; // Feuchte/Temperautr
368 case 23: s="APDS-9960";break; // Feuchte/Temperautr
369 case 24: s="BMP680";break;
370 case 25: s="SGP30";break;
371 case 26: s="SGPC3";break;
372 case 27: s="iAQ-core C";break;
373 case 28: s="HDC2010";break;
374 case 29: s="LPS225HB";break;
375 case 30: s="SHTC3";break;
376 case 31: s="SPS30";break;
377 case 32: s="DHT11";break;
378 case 33: s="SCD30";break;
379 case 34: s="SCD40";break;