Commit graph

17 commits

Author SHA1 Message Date
jgromes
9fb427d041 [SX128x] Fix unspecified integer width in ranging calculation 2024-09-10 19:21:05 +02:00
Jorropo
951bfc0625 fix getRangingResult to properly account for signed numbers
I got numbers like this as I approached the slave (raw values before converting to meters):
```
Ranged: 8
Ranged: 6
Ranged: 3
Ranged: 3
Ranged: 5
Ranged: 5
Ranged: 5
Ranged: 6
Ranged: 1
Ranged: 1
Ranged: 800000
Ranged: 800003
Ranged: 800003
```

This is because the ToF becomes smaller than the correction factor resulting in a negative number.

This patch performs Sign Extension from 24bits to 32bits.
This result in returning a negative meter value which makes more sense than an impossibly big one.
2024-09-07 06:25:32 +02:00
Elizabeth Myers
205031550b
Use RadioLibTime_t (aka unsigned long) when dealing with millis() and micros() (#1075)
* Use unsigned long when dealing with millis() and micros().

Although sizeof(uint32_t) == sizeof(unsigned long) on Arduino, this is
not the case on 64-bit Linux, where sizeof(unsigned long) ==
sizeof(uint64_t).

Most timestamp arithmetic and comparisons have been left alone, to
reduce code churn. This is fine, as uint32_t is perfectly wide to store
most timestamp deltas this library will deal with, and C will promote
the integer rather than do a narrowing conversion. The real problem
arises with narrowing conversions being done by assuming timestamps are
32-bit.

No functional changes intended for platforms where sizeof(uint32_t) ==
sizeof(unsigned long) (so most 8/16/32-bit platforms).

Signed-off-by: Elizabeth Myers <elizabeth.jennifer.myers@gmail.com>

* Change most timestamps to use RadioLibTime_t.

This makes it obvious what is and isn't a timestamp.

Not everything has been converted; anything dealing with protocol and
chip-level timestamps has been left alone on purpose, to make it clear
that these functions do require 32-bit timestamps.

No functional changes intended on platforms where sizeof(uint32_t) ==
sizeof(unsigned long).

Signed-off-by: Elizabeth Myers <elizabeth.jennifer.myers@gmail.com>

* Use uint32_t internally in getTimeOnAir.

We need to not overflow the integers with the shifts and
multiplications, so this is correct behaviour.

Signed-off-by: Elizabeth Myers <elizabeth.jennifer.myers@gmail.com>

---------

Signed-off-by: Elizabeth Myers <elizabeth.jennifer.myers@gmail.com>
2024-04-25 21:50:58 +02:00
jgromes
b5d931ec79 [SX128x] Cleanup private/protected members 2024-01-12 19:45:41 +01:00
jgromes
827aac5938 [SX128x] Reworked macro configuration system 2023-11-27 21:15:07 +01:00
jgromes
76c654c0c1 [SX128x] General reformatting 2023-04-23 22:05:18 +02:00
Mestery
ec3d4eaf20 Improve hardware abstraction layer 2023-04-12 23:16:18 +02:00
jgromes
a0884bf120 [SX128x] Added option to set custom ranging calibration (#293) 2023-01-01 18:31:03 +01:00
jgromes
088207df4c [SX1280] Only check ranging address on slave 2023-01-01 18:03:48 +01:00
jgromes
1126e64587 [SX128x] Update to 5.0.0 2021-11-14 11:42:36 +01:00
jgromes
9ac6503bff [SX128x] Fixed ranging calibration table indexing (#293) 2021-05-07 07:28:01 +02:00
jgromes
333aa433d9 [SX128x] Implemented ranging fixes from #293 2021-05-05 20:34:59 +02:00
jgromes
a32950c788 [SX128x] Added ranging calibration and missing readout steps (#293) 2021-04-26 18:26:44 +02:00
jgromes
2aeffd914f [SX128x] Added Module overrides for all Arduino core functions 2020-08-01 16:34:44 +02:00
jgromes
515551e7bc [SX128x] Reworked driver exclusion 2020-06-30 10:44:08 +02:00
jgromes
1592831e0c [SX128x] Implemented ranging 2020-04-12 13:47:56 +02:00
jgromes
55ad72e0e0 [SX128x] Added support for SX128x 2020-04-07 13:30:05 +02:00