Skip to content

Commit a480f5e

Browse files
authored
Merge pull request #204 from MaxKellermann/apidocs
libs: add some API documentation
2 parents 1d3cd43 + 14ae5d6 commit a480f5e

File tree

96 files changed

+183
-12
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+183
-12
lines changed

aat-android/src/main/kotlin/ch/bailu/aat/services/sensor/Connector.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ import ch.bailu.aat_lib.gpx.information.InfoID
77
import ch.bailu.aat_lib.service.sensor.SensorState
88
import java.io.Closeable
99

10+
/**
11+
* Manages the connected/disconnected state of a single sensor [InfoID].
12+
*
13+
* On [connect], updates global [SensorState] and broadcasts
14+
* [AppBroadcaster.SENSOR_CHANGED]. On [close], marks the sensor as
15+
* disconnected and broadcasts [AppBroadcaster.SENSOR_DISCONNECTED] to
16+
* trigger reconnection attempts.
17+
*/
1018
class Connector(private val context: Context, private val iid: Int) : Closeable {
1119
private var isConnected = false
1220

aat-android/src/main/kotlin/ch/bailu/aat/services/sensor/bluetooth_le/Broadcaster.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ import android.content.Context
44
import ch.bailu.aat.broadcaster.AndroidBroadcaster
55
import ch.bailu.aat_lib.broadcaster.AppBroadcaster
66

7+
/**
8+
* Throttled Android-broadcast emitter for sensor updates.
9+
*
10+
* Sends an [AppBroadcaster.SENSOR_CHANGED] intent keyed by InfoID.
11+
* [timeout] returns true when at least [BROADCAST_TIMEOUT] ms have elapsed,
12+
* allowing callers to suppress zero-value broadcasts until the timeout expires.
13+
* Downstream [SensorSource] instances listen for these intents to push data
14+
* into the [Dispatcher] chain.
15+
*/
716
class Broadcaster(private val context: Context, iid: Int) {
817
companion object {
918
private const val BROADCAST_TIMEOUT: Long = 2000

aat-android/src/main/kotlin/ch/bailu/aat/services/sensor/bluetooth_le/CyclingPower.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@ import ch.bailu.aat_lib.gpx.attributes.CadenceSpeedAttributes
1010
import ch.bailu.aat_lib.gpx.attributes.GpxAttributes
1111
import ch.bailu.aat_lib.gpx.attributes.PowerAttributes
1212

13+
/**
14+
* BLE Cycling Power sensor.
15+
*
16+
* Parses Bluetooth GATT Cycling Power Measurement characteristics and extracts
17+
* power (watts), wheel speed, and crank cadence. Each measurement type is
18+
* broadcast independently through its own [Broadcaster]/[Connector] pair so
19+
* that downstream [SensorSource] instances (one per [InfoID]) can pick up
20+
* changes and forward them into the [Dispatcher] chain.
21+
*
22+
* Data flow: BLE characteristic -> [Attributes] -> [Information] -> [Broadcaster.broadcast]
23+
*/
1324
class CyclingPower(c: ServiceContext) : CyclingPowerID(), ServiceInterface {
1425
private var location = CadenceSpeedAttributes.SENSOR_LOCATION[0]
1526
private var isSpeedSensor = false

aat-android/src/main/kotlin/ch/bailu/aat/services/sensor/bluetooth_le/ServiceInterface.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ package ch.bailu.aat.services.sensor.bluetooth_le
33
import android.bluetooth.BluetoothGattCharacteristic
44
import ch.bailu.aat_lib.gpx.information.GpxInformation
55

6+
/**
7+
* Contract for a BLE GATT sensor service (e.g. Cycling Power, Heart Rate).
8+
*
9+
* Lifecycle: [discovered] registers characteristics -> [read] captures static
10+
* features -> [changed] delivers live measurements -> [getInformation] lets
11+
* callers query the latest [GpxInformation] by [InfoID].
12+
*/
613
interface ServiceInterface {
714
fun close()
815
fun changed(c: BluetoothGattCharacteristic)

aat-android/src/main/kotlin/ch/bailu/aat/views/description/CockpitView.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ import ch.bailu.aat_lib.gpx.information.InfoID
1515
import ch.bailu.aat_lib.preferences.StorageInterface
1616
import ch.bailu.aat_lib.view.cockpit.Layouter
1717

18+
/**
19+
* Grid of [NumberView] cells displaying live sensor and tracker data.
20+
*
21+
* Each [add]/[addPower]/[addCadence]/... call creates a [NumberView], wraps a
22+
* [ContentDescription], and registers it with the [DispatcherInterface] for the
23+
* appropriate [InfoID]. Layout is handled by [Layouter] which tiles cells based
24+
* on the number of descriptions and available space.
25+
*/
1826
class CockpitView(context: Context, private val theme: UiTheme) : ViewGroup(context) {
1927
private val layouter: Layouter
2028
private val storage: StorageInterface = Storage(context)

aat-android/src/main/kotlin/ch/bailu/aat/views/description/NumberView.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ import ch.bailu.aat_lib.logger.AppLog
2323

2424
import kotlin.math.roundToInt
2525

26+
/**
27+
* Single cockpit cell showing label, numeric value, and unit.
28+
*
29+
* Implements [TargetInterface]: when [onContentUpdated] is called by the
30+
* [Dispatcher], it delegates to its [ContentDescription] to extract and
31+
* format the value, then refreshes the three [TextView]s. Tapping the view
32+
* can trigger a sensor-reconnect broadcast via [requestOnClickSensorReconnect].
33+
*/
2634
open class NumberView(context: Context, data: ContentDescription, private val theme: UiTheme) :
2735
ViewGroup(context), TargetInterface {
2836
private val label: TextView

aat-lib/src/main/java/ch/bailu/aat_lib/coordinates/BoundingBoxE6.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import java.io.IOException
1010
import kotlin.math.abs
1111

1212

13+
/** Axis-aligned bounding box in microdegree (E6) coordinates, growable via [add]. */
1314
class BoundingBoxE6 {
1415
var latNorthE6 = MIN_LA
1516
private set

aat-lib/src/main/java/ch/bailu/aat_lib/coordinates/CH1903Coordinates.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import ch.bailu.aat_lib.logger.AppLog
77
import org.mapsforge.core.model.LatLong
88
import kotlin.math.roundToInt
99

10+
/** Swiss CH1903 (LV03) projected coordinates, convertible to/from WGS84. */
1011
class CH1903Coordinates : MeterCoordinates {
1112
override var easting = 0
1213
private set

aat-lib/src/main/java/ch/bailu/aat_lib/coordinates/Coordinates.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package ch.bailu.aat_lib.coordinates
22

33
import org.mapsforge.core.model.LatLong
44

5+
/** Base class for coordinate systems that can be converted to WGS84 [LatLong]. */
56
abstract class Coordinates {
67
abstract fun toLatLong(): LatLong
78
}

aat-lib/src/main/java/ch/bailu/aat_lib/coordinates/LatLongE6.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package ch.bailu.aat_lib.coordinates
33
import org.mapsforge.core.model.LatLong
44
import org.mapsforge.core.util.LatLongUtils
55

6+
/** Latitude/longitude pair stored as microdegrees (E6 integers). */
67
class LatLongE6 : LatLongInterface {
78
private val latitudeE6: Int
89
private val longitudeE6: Int

0 commit comments

Comments
 (0)