Real-time aviation flight instruments displayed as overlay on the map, showing live data from DataPad connection. Each instrument is individually draggable and positions are persisted.
- Display: Classic blue/brown horizon with pitch ladder
- Data:
- Pitch angle (up/down)
- Bank angle (roll left/right)
- Features:
- 10-degree pitch ladder markings
- Bank angle scale (-60° to +60°)
- Fixed aircraft symbol (yellow)
- Bank pointer indicator
- Display: Combined turn coordinator and slip ball
- Data:
- Turn rate (degrees/second)
- Slip/skid indicator
- Features:
- Miniature aircraft symbol tilts with turn rate
- Standard rate turn markers (L/R)
- Ball-in-tube slip indicator
- Reference marks for coordinated flight
MapFlightInstruments.kt- Main instrument display and drag systemMapViewer.kt- Integration and data bindingMapViewerState.kt- State managementOverlaySelectionDialog.kt- UI controls
Main composable that manages all instruments:
@Composable
fun MapFlightInstruments(
pitch: Double,
bank: Double,
turnRate: Double,
slip: Double,
enabled: Boolean
)Wrapper that makes any instrument draggable:
- Handles drag gestures
- Persists positions to SharedPreferences
- Constrains movement to screen bounds
AttitudeIndicator()- Pitch and bank displayTurnAndSlipIndicator()- Turn rate and slip display
DataPad (DCS Export)
↓
FlightData State
↓
MapViewer
↓
MapFlightInstruments
↓
Individual Instruments
- Open Map view
- Tap Overlays button (layers icon)
- Toggle "Flight Instruments"
- Drag: Touch and drag any instrument to move it
- Auto-save: Positions saved automatically
- Persistence: Positions restored on app restart
- DataPad connection active
- Valid pitch and bank data from DCS
Positions stored in SharedPreferences:
attitude_x- X position of attitude indicatorattitude_y- Y position of attitude indicatorturnslip_x- X position of turn/slip indicatorturnslip_y- Y position of turn/slip indicatormap_overlay_flight_instruments- Enabled state
- Attitude Indicator: (16dp, 500dp) - Left side, bottom area
- Turn/Slip Indicator: (200dp, 500dp) - Right of attitude indicator
- Create new
@Composablefunction inMapFlightInstruments.kt - Add Canvas-based drawing logic
- Wrap in
DraggableInstrument() - Add position prefs keys
- Add to
MapFlightInstruments()main composable
@Composable
fun NewInstrument(
data: Double,
size: Dp,
modifier: Modifier = Modifier
) {
Column(horizontalAlignment = Alignment.CenterHorizontally) {
Box(modifier = Modifier.size(size).clip(CircleShape).background(Color.Black)) {
Canvas(modifier = Modifier.fillMaxSize()) {
// Draw instrument graphics
}
}
Text("LABEL", fontSize = 10.sp, color = Color.White)
}
}- Altimeter - Altitude display with multiple hands
- Vertical Speed Indicator - Rate of climb/descent
- Airspeed Indicator - IAS with speed tape
- Heading Indicator - Directional gyro
- Mach Meter - Mach number display
- G-Meter - G-force indicator
- Uses Compose Canvas API
- Hardware-accelerated rendering
- 60fps smooth updates
- Minimal memory footprint
- Recomposition only on data changes
- No unnecessary allocations
- Efficient clipping and transforms
- Optimized for mobile devices
- Screen coordinates (dp)
- Origin: Top-left corner
- Y-axis: Down positive
- X-axis: Right positive
- Turn Rate: Currently placeholder (0.0) - needs calculation from heading delta
- Slip Data: Not available in current DataPad protocol
- Screen Size: Fixed default positions may need adjustment on small screens
- Occlusion: Can overlap map controls if positioned poorly
- Auto-layout presets (left panel, bottom panel, etc.)
- Size adjustment per instrument
- Opacity control
- Turn rate calculation from heading changes
- Slip estimation from accelerometer data
- Instrument clustering/grouping
- Lock/unlock individual instruments
- Reset to default positions button
- Import/export layout configurations