mirror of
https://github.com/dz0ny/meshcore-sar.git
synced 2026-08-11 08:20:36 +00:00
feat: Add buzzer alerts toggle
This commit is contained in:
@@ -190,6 +190,8 @@ class _DeviceConfigScreenState extends State<DeviceConfigScreen> {
|
||||
bool _repeatEnabled = false;
|
||||
bool? _gpsEnabled; // null = not supported by hardware
|
||||
bool _gpsLoading = false;
|
||||
bool? _buzzerEnabled;
|
||||
bool _buzzerLoading = false;
|
||||
bool? _gpsHasFix;
|
||||
int? _gpsSatelliteCount;
|
||||
int? _gpsLatE6;
|
||||
@@ -823,8 +825,10 @@ class _DeviceConfigScreenState extends State<DeviceConfigScreen> {
|
||||
final gpsLatValue = vars['gps_lat_e6'];
|
||||
final gpsLonValue = vars['gps_lon_e6'];
|
||||
final gpsLastFixAgeValue = vars['gps_last_fix_age_s'];
|
||||
final buzzerValue = vars['buzzer'];
|
||||
setState(() {
|
||||
_gpsEnabled = gpsValue != null ? gpsValue == '1' : null;
|
||||
_buzzerEnabled = buzzerValue != null ? buzzerValue == '1' : null;
|
||||
if (gpsIntervalValue != null) {
|
||||
_gpsIntervalController.text = gpsIntervalValue;
|
||||
}
|
||||
@@ -840,6 +844,25 @@ class _DeviceConfigScreenState extends State<DeviceConfigScreen> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _setBuzzerMode(bool enabled) async {
|
||||
setState(() => _buzzerLoading = true);
|
||||
try {
|
||||
await _connectionProvider.setCustomVar('buzzer', enabled ? '1' : '0');
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_buzzerEnabled = enabled;
|
||||
_buzzerLoading = false;
|
||||
});
|
||||
unawaited(_loadGpsMode());
|
||||
} catch (e) {
|
||||
if (!mounted) return;
|
||||
setState(() => _buzzerLoading = false);
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Failed to set buzzer mode: $e')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _setGpsMode(bool enabled) async {
|
||||
setState(() => _gpsLoading = true);
|
||||
try {
|
||||
@@ -1758,6 +1781,32 @@ class _DeviceConfigScreenState extends State<DeviceConfigScreen> {
|
||||
),
|
||||
),
|
||||
],
|
||||
if (_buzzerEnabled != null) ...[
|
||||
const SizedBox(height: 12),
|
||||
_SettingHighlightCard(
|
||||
icon: _buzzerEnabled!
|
||||
? Icons.volume_up_rounded
|
||||
: Icons.volume_off_rounded,
|
||||
title: 'Buzzer alerts',
|
||||
description:
|
||||
'Enable or mute the onboard buzzer for radio alerts.',
|
||||
accentColor: _buzzerEnabled!
|
||||
? colorScheme.primary
|
||||
: colorScheme.onSurfaceVariant,
|
||||
trailing: _buzzerLoading
|
||||
? const SizedBox(
|
||||
width: 24,
|
||||
height: 24,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
),
|
||||
)
|
||||
: Switch(
|
||||
value: _buzzerEnabled!,
|
||||
onChanged: _setBuzzerMode,
|
||||
),
|
||||
),
|
||||
],
|
||||
const SizedBox(height: 16),
|
||||
TextField(
|
||||
controller: _gpsIntervalController,
|
||||
|
||||
Reference in New Issue
Block a user