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");
220 //Optimization necessary
221 if (language==OWDC_LANGUAGE_ENGLISH) l.erase(l.begin()+1);
222 if (language==OWDC_LANGUAGE_GERMAN) l.erase(l.begin());
227 double owDeviceConfig::calculateValueFromNumber(int code, int vn, std::vector<int> V) {
229 case 01: return V[vn] / 16.0; break;
230 case 2:return V[vn]/1.6; break;
231 case 3:return V[vn]*0.2 + 700; break;
232 case 4:return exp(V[vn] / 160.0); break;
233 case 5:return V[vn]*62.5 + 55000; break;
234 case 6:return V[vn] / 256.0; break;
235 case 7:return (((double)V[2] / (double)V[1] - 0.16) / 0.0062) / (1.0546 - 0.00216*V[0]/256.0); break;
236 case 8:return V[vn] / 100.0; break;
237 case 9:return V[vn] / 65535.0*5.1; break;
238 case 10:return V[vn] / 65535.0*2.55; break;
239 case 11:return V[vn] / 65535.0*1.1; break;
240 case 12:return V[vn] / 10.0; break;
241 case 13:return V[vn]; break;
242 case 14:return (V[vn] - 32767.0) / 100.0; break;
243 case 15:return exp((V[vn]-32767.0)/1000.0); break;
244 case 16:return V[vn]/32.0; break;
245 case 17:return 5120.0/V[vn]; break; //Current of DS2438 with 0.025 Ohm;
250 std::string owDeviceConfig::getSensorChip(uint8_t ch) {
253 switch(config.sens[ch]) {
254 case 1: s="DS18B20";break;
255 case 2: s="DS2438";break; //Temperatur Sensor
256 case 3: s="DS2438";break; //Spannung
257 case 4: s="DS2438";break; // Spannung / Strom
258 case 5: s="DS2450";break; // Spannung
259 case 6: s="Thermoelement";break; // Hochtemperatur Sensor
260 case 7: s="SHT21";break; // Feuchte/Temperatur Sensor
261 case 8: s="SHT25";break; // Feuchte/Temperatur Präzisionssensor
262 case 9: s="DHT22";break; // Feuchte/Temperatur Sensor
263 case 10: s="HIH9021";break; // Feuchte/Temperatur Präzisionssensor
264 case 11: s="HDC1080";break; // Feuchte/Temperatur Sensor
265 case 12: s="HIH4030";break; // Feuchte/Temperatur Sensor analog
266 case 13: s="HIH5030";break; // Feuchte/Temperatur Sensor analog
267 case 14: s="BMP280";break; // Luftdrucksensor
268 case 15: s="MAX44009";break; // Umgebungslicht-Sensor
269 case 16: s="CDM7160";break; // CO2-Sensor
270 case 17: s="MAX1164/TGS8100";break; // VOC-Sensor
271 case 18: s="TGS8100 direkt";break; // VOC-Sensor
272 case 19: s="DS2423";break; // Counter