mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-06-01 22:19:18 +02:00
feat: replace LoRa bandwidth text input with constrained dropdown (#5687)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -143,7 +143,7 @@ configuration settings screen. Constraints are sourced from two layers:
|
||||
| `region` | Enum | Dropdown: `RegionInfo` entries | Regional frequency plans |
|
||||
| `use_preset` | Boolean | Toggle | Controls manual vs preset LoRa settings visibility |
|
||||
| `modem_preset` | Enum | Dropdown: `ChannelOption` entries | Visible only when `use_preset = true` |
|
||||
| `bandwidth` | Integer | Numeric input | Visible only when `use_preset = false` |
|
||||
| `bandwidth` | Integer | Dropdown: valid LoRa bandwidths (7.8–500 kHz) | Visible only when `use_preset = false` |
|
||||
| `spread_factor` | Integer | Numeric input | Visible only when `use_preset = false` |
|
||||
| `coding_rate` | Integer | Numeric input | Visible only when `use_preset = false` |
|
||||
| `hop_limit` | Integer | Dropdown: 0–7 | — |
|
||||
|
||||
+19
-4
@@ -67,6 +67,21 @@ import org.meshtastic.proto.Config
|
||||
private val SPREAD_FACTOR_RANGE = 7..12
|
||||
private val CODING_RATE_RANGE = 5..8
|
||||
|
||||
/** Valid LoRa bandwidth codes mapped to their display labels (kHz). */
|
||||
private val BANDWIDTH_OPTIONS: List<Pair<Int, String>> =
|
||||
listOf(
|
||||
8 to "7.8 kHz",
|
||||
10 to "10.4 kHz",
|
||||
16 to "15.6 kHz",
|
||||
21 to "20.8 kHz",
|
||||
31 to "31.25 kHz",
|
||||
42 to "41.7 kHz",
|
||||
62 to "62.5 kHz",
|
||||
125 to "125 kHz",
|
||||
250 to "250 kHz",
|
||||
500 to "500 kHz",
|
||||
)
|
||||
|
||||
@Composable
|
||||
fun LoRaConfigScreen(viewModel: RadioConfigViewModel, onBack: () -> Unit) {
|
||||
val state by viewModel.radioConfigState.collectAsStateWithLifecycle()
|
||||
@@ -245,12 +260,12 @@ private fun ManualModemSettings(
|
||||
onConfigChange: (Config.LoRaConfig) -> Unit,
|
||||
) {
|
||||
androidx.compose.foundation.layout.Column {
|
||||
EditTextPreference(
|
||||
DropDownPreference(
|
||||
title = stringResource(Res.string.bandwidth),
|
||||
value = config.bandwidth,
|
||||
enabled = enabled,
|
||||
keyboardActions = KeyboardActions(onDone = { focusManager.clearFocus() }),
|
||||
onValueChanged = { onConfigChange(config.copy(bandwidth = it)) },
|
||||
items = BANDWIDTH_OPTIONS,
|
||||
selectedItem = config.bandwidth,
|
||||
onItemSelected = { onConfigChange(config.copy(bandwidth = it)) },
|
||||
)
|
||||
HorizontalDivider()
|
||||
EditTextPreference(
|
||||
|
||||
Reference in New Issue
Block a user