@@ -43,8 +43,13 @@ static inline float atmt(float h, float t_atm, float d) {
4343}
4444
4545int InfiFrame::init (int width, int height) {
46- this ->width = width;
47- this ->height = height - 4 ;
46+ if (p2_pro) {
47+ this ->width = 256 ;
48+ this ->height = 192 ; // 384
49+ } else {
50+ this ->width = width;
51+ this ->height = height - 4 ;
52+ }
4853 s1_offset = width * (height - 4 );
4954
5055 cal_00_offset = 390.0 ;
@@ -119,16 +124,8 @@ void InfiFrame::update(uint16_t *frame) {
119124 float cal_03 = read_float (frame + s2_offset, 7 );
120125 float cal_04 = read_float (frame + s2_offset, 9 );
121126 float cal_05 = read_float (frame + s2_offset, 11 );
122- if (!raw_sensor) {
123- temp_max_x = read_u16 (frame + s1_offset, 2 );
124- temp_max_y = read_u16 (frame + s1_offset, 3 );
125- temp_max = read_u16 (frame + s1_offset, 4 );
126- temp_min_x = read_u16 (frame + s1_offset, 5 );
127- temp_min_y = read_u16 (frame + s1_offset, 6 );
128- temp_min = read_u16 (frame + s1_offset, 7 );
129- temp_avg = read_u16 (frame + s1_offset, 8 );
130- temp_center = read_u16 (frame + s1_offset, 12 );
131- }else {
127+
128+ if (raw_sensor) {
132129 temp_max = 0 ;
133130 temp_min = UINT16_MAX;
134131 uint32_t sum = 0 ;
@@ -162,6 +159,17 @@ void InfiFrame::update(uint16_t *frame) {
162159 }
163160
164161 temp_avg = sum / (height * width);
162+ } else if (p2_pro) {
163+ temp_center = frame[96 * width + 128 ]>>2 ;
164+ } else {
165+ temp_max_x = read_u16 (frame + s1_offset, 2 );
166+ temp_max_y = read_u16 (frame + s1_offset, 3 );
167+ temp_max = read_u16 (frame + s1_offset, 4 );
168+ temp_min_x = read_u16 (frame + s1_offset, 5 );
169+ temp_min_y = read_u16 (frame + s1_offset, 6 );
170+ temp_min = read_u16 (frame + s1_offset, 7 );
171+ temp_avg = read_u16 (frame + s1_offset, 8 );
172+ temp_center = read_u16 (frame + s1_offset, 12 );
165173 }
166174 temp_user[0 ] = read_u16 (frame + s1_offset, 13 );
167175 temp_user[1 ] = read_u16 (frame + s1_offset, 14 );
@@ -191,10 +199,15 @@ float InfiFrame::temp_single(uint16_t x) {
191199 /* Temperatures below what we can calculate result in sqrt of a negative number, the absolute
192200 * lowest temperature we can calculate is the one we get if we set n to 0.
193201 */
194- float n = sqrtf (((float ) (x - table_offset) * cal_d + cal_c) / cal_01 + cal_b);
195- float wtot = powf ((isfinite (n) ? n : 0.0 ) - cal_a + zeroc, 4 );
196- float ttot = powf ((wtot - numerator_sub) / denominator, 0.25 ) - zeroc;
197- return ttot + (distance_adjusted * 0.85 - 1.125 ) * (ttot - temp_air) / 100.0 + correction;
202+
203+ if (p2_pro) {
204+ return ((float ) x )/16 .0f -273 .15f ;
205+ } else {
206+ float n = sqrtf (((float ) (x - table_offset) * cal_d + cal_c) / cal_01 + cal_b);
207+ float wtot = powf ((isfinite (n) ? n : 0.0 ) - cal_a + zeroc, 4 );
208+ float ttot = powf ((wtot - numerator_sub) / denominator, 0.25 ) - zeroc;
209+ return ttot + (distance_adjusted * 0.85 - 1.125 ) * (ttot - temp_air) / 100.0 + correction;
210+ }
198211}
199212
200213void InfiFrame::update_table (uint16_t *frame) {
@@ -209,23 +222,33 @@ void InfiFrame::temp(uint16_t *input, float *output) {
209222
210223void InfiFrame::temp (uint16_t *input, float *output, size_t len) {
211224 for (size_t i = 0 ; i < len; ++i)
212- output[i] = temp (input[i]);
225+ output[i] = temp (input[i]>> 2 );
213226}
214227
215228void InfiFrame::read_params (uint16_t *frame) {
216229 /* Presumeably this is just a 128 byte ram+eeprom area. */
217- if (!raw_sensor) {
218- correction = read_float (frame + s2_offset, 127 );
219- /* NOTE Original Infiray software uses a uint16 for distance. */
220- distance = read_float (frame + s2_offset, 137 );
221- }else {
222- // TODO: Handling of theve vraibles and user input should be done within the app because writing to these doesn't work on the T2S+ A2
223- distance = (float )read_u16 (frame + s2_offset, 137 );
230+ if (p2_pro) {
231+ correction = 0 ;
232+ distance = 0 ;
233+ temp_reflected = 0 ;
234+ temp_air = 0 ;
235+ humidity = 0 ;
236+ emissivity = 1.0 ;
237+ } else {
238+ if (!raw_sensor) {
239+ correction = read_float (frame + s2_offset, 127 );
240+ /* NOTE Original Infiray software uses a uint16 for distance. */
241+ distance = read_float (frame + s2_offset, 137 );
242+ } else {
243+ // TODO: Handling of theve vraibles and user input should be done within the app because writing to these doesn't work on the T2S+ A2
244+ distance = (float ) read_u16 (frame + s2_offset, 137 );
245+ }
246+ temp_reflected = read_float (frame + s2_offset, 129 );
247+ temp_air = read_float (frame + s2_offset, 131 );
248+ humidity = read_float (frame + s2_offset, 133 );
249+ emissivity = read_float (frame + s2_offset, 135 );
224250 }
225- temp_reflected = read_float (frame + s2_offset, 129 );
226- temp_air = read_float (frame + s2_offset, 131 );
227- humidity = read_float (frame + s2_offset, 133 );
228- emissivity = read_float (frame + s2_offset, 135 );
251+
229252}
230253
231254void InfiFrame::read_version (uint16_t *frame, char *product, char *serial, char *fw_version) {
@@ -264,7 +287,7 @@ void InfiFrame::palette_appy(float *input, uint32_t *output, size_t len) {
264287 palette_appy (input, output, len, temp (temp_min), temp (temp_max));
265288}
266289
267- void InfiFrame::palette_appy (float *input, uint32_t *output, float min, float max) {
290+ void InfiFrame::palette_appy (float *input, uint32_t *output, float min, float max) { // TODO this palette_appy gets used
268291 palette_appy (input, output, width * height, min, max);
269292}
270293
0 commit comments