|
@@ -460,7 +460,6 @@ class MeCoffeeService extends StateNotifier<MachineState> {
|
|
|
pressurePeriod: prefs.getInt('pressurePeriod') ?? 25,
|
|
pressurePeriod: prefs.getInt('pressurePeriod') ?? 25,
|
|
|
valveClosedWhilePaused: prefs.getBool('valveClosedWhilePaused') ?? false,
|
|
valveClosedWhilePaused: prefs.getBool('valveClosedWhilePaused') ?? false,
|
|
|
proActivePercentage: prefs.getInt('proActivePercentage') ?? 33,
|
|
proActivePercentage: prefs.getInt('proActivePercentage') ?? 33,
|
|
|
- temperatureOffset: prefs.getDouble('temperatureOffset') ?? 0.0,
|
|
|
|
|
autoShutoffMinutes: prefs.getInt('autoShutoffMinutes') ?? 60,
|
|
autoShutoffMinutes: prefs.getInt('autoShutoffMinutes') ?? 60,
|
|
|
wakeupEnabled: prefs.getBool('wakeupEnabled') ?? false,
|
|
wakeupEnabled: prefs.getBool('wakeupEnabled') ?? false,
|
|
|
wakeupTime: prefs.getString('wakeupTime') ?? "07:00",
|
|
wakeupTime: prefs.getString('wakeupTime') ?? "07:00",
|
|
@@ -529,14 +528,19 @@ class MeCoffeeService extends StateNotifier<MachineState> {
|
|
|
Future<void> updateProActive(int percentage) =>
|
|
Future<void> updateProActive(int percentage) =>
|
|
|
_updateSettings({'tmppap': percentage});
|
|
_updateSettings({'tmppap': percentage});
|
|
|
|
|
|
|
|
- Future<void> updateOffset(double offset) =>
|
|
|
|
|
- _updateSettings({'tmpoff': offset});
|
|
|
|
|
-
|
|
|
|
|
Future<void> updateAutoShutoff(int minutes) =>
|
|
Future<void> updateAutoShutoff(int minutes) =>
|
|
|
_updateSettings({'tmrosd': minutes});
|
|
_updateSettings({'tmrosd': minutes});
|
|
|
|
|
|
|
|
- Future<void> updateMaxShotTime(int seconds) =>
|
|
|
|
|
- _updateSettings({'shtmx': seconds});
|
|
|
|
|
|
|
+ Future<void> updateMaxShotTime(int seconds) async {
|
|
|
|
|
+ if (seconds < 0 || seconds > MeCoffeeProtocol.maxShotSeconds) {
|
|
|
|
|
+ _reportCommandError(
|
|
|
|
|
+ 'Max shot time must be between 0 and '
|
|
|
|
|
+ '${MeCoffeeProtocol.maxShotSeconds} s.',
|
|
|
|
|
+ );
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ await _updateSettings({'shtmx': seconds});
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
Future<void> updateContinuousMode(bool enabled) =>
|
|
Future<void> updateContinuousMode(bool enabled) =>
|
|
|
_updateSettings({'tmpcntns': enabled});
|
|
_updateSettings({'tmpcntns': enabled});
|
|
@@ -565,18 +569,39 @@ class MeCoffeeService extends StateNotifier<MachineState> {
|
|
|
Future<void> updatePIDSettings({double? p, double? i, double? d}) =>
|
|
Future<void> updatePIDSettings({double? p, double? i, double? d}) =>
|
|
|
_updateSettings({'pd1p': ?p, 'pd1i': ?i, 'pd1d': ?d});
|
|
_updateSettings({'pd1p': ?p, 'pd1i': ?i, 'pd1d': ?d});
|
|
|
|
|
|
|
|
- Future<void> updatePIDLimits(double min, double max, int interval) =>
|
|
|
|
|
- _updateSettings({
|
|
|
|
|
- 'pd1imn': min,
|
|
|
|
|
- 'pd1imx': max,
|
|
|
|
|
- 'pd1sz': interval,
|
|
|
|
|
- }, omitV4Minimum: true);
|
|
|
|
|
|
|
+ bool _pidLimitsOutOfRange(Iterable<double?> percentages) {
|
|
|
|
|
+ if (state.isLegacyV4Firmware) return false;
|
|
|
|
|
+ final outOfRange = percentages.any(
|
|
|
|
|
+ (value) =>
|
|
|
|
|
+ value != null &&
|
|
|
|
|
+ (value < 0 || value > MeCoffeeProtocol.maxPidLimitPercent),
|
|
|
|
|
+ );
|
|
|
|
|
+ if (outOfRange) {
|
|
|
|
|
+ _reportCommandError(
|
|
|
|
|
+ 'I-wind-down limits must be between 0 and '
|
|
|
|
|
+ '${MeCoffeeProtocol.maxPidLimitPercent}%.',
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+ return outOfRange;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Future<void> updatePIDLimits(double min, double max, int interval) async {
|
|
|
|
|
+ if (_pidLimitsOutOfRange([min, max])) return;
|
|
|
|
|
+ await _updateSettings({
|
|
|
|
|
+ 'pd1imn': min,
|
|
|
|
|
+ 'pd1imx': max,
|
|
|
|
|
+ 'pd1sz': interval,
|
|
|
|
|
+ }, omitV4Minimum: true);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
Future<void> updatePIDLimitSettings({
|
|
Future<void> updatePIDLimitSettings({
|
|
|
double? min,
|
|
double? min,
|
|
|
double? max,
|
|
double? max,
|
|
|
int? interval,
|
|
int? interval,
|
|
|
- }) => _updateSettings({'pd1imn': ?min, 'pd1imx': ?max, 'pd1sz': ?interval});
|
|
|
|
|
|
|
+ }) async {
|
|
|
|
|
+ if (_pidLimitsOutOfRange([min, max])) return;
|
|
|
|
|
+ await _updateSettings({'pd1imn': ?min, 'pd1imx': ?max, 'pd1sz': ?interval});
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
Future<void> _incrementShotCount() async {
|
|
Future<void> _incrementShotCount() async {
|
|
|
final prefs = await SharedPreferences.getInstance();
|
|
final prefs = await SharedPreferences.getInstance();
|
|
@@ -644,7 +669,6 @@ class MeCoffeeService extends StateNotifier<MachineState> {
|
|
|
'tmrpwr': 'installedAsTimer',
|
|
'tmrpwr': 'installedAsTimer',
|
|
|
'pwrflp': 'powerButtonFlipsBack',
|
|
'pwrflp': 'powerButtonFlipsBack',
|
|
|
'tmppap': 'proActivePercentage',
|
|
'tmppap': 'proActivePercentage',
|
|
|
- 'tmpoff': 'temperatureOffset',
|
|
|
|
|
'tmrosd': 'autoShutoffMinutes',
|
|
'tmrosd': 'autoShutoffMinutes',
|
|
|
'shtmx': 'maxShotTime',
|
|
'shtmx': 'maxShotTime',
|
|
|
'tmpcntns': 'continuousMode',
|
|
'tmpcntns': 'continuousMode',
|
|
@@ -676,7 +700,6 @@ class MeCoffeeService extends StateNotifier<MachineState> {
|
|
|
'installedAsTimer': value.installedAsTimer,
|
|
'installedAsTimer': value.installedAsTimer,
|
|
|
'powerButtonFlipsBack': value.powerButtonFlipsBack,
|
|
'powerButtonFlipsBack': value.powerButtonFlipsBack,
|
|
|
'proActivePercentage': value.proActivePercentage,
|
|
'proActivePercentage': value.proActivePercentage,
|
|
|
- 'temperatureOffset': value.temperatureOffset,
|
|
|
|
|
'autoShutoffMinutes': value.autoShutoffMinutes,
|
|
'autoShutoffMinutes': value.autoShutoffMinutes,
|
|
|
'maxShotTime': value.maxShotTime,
|
|
'maxShotTime': value.maxShotTime,
|
|
|
'continuousMode': value.continuousMode,
|
|
'continuousMode': value.continuousMode,
|
|
@@ -752,7 +775,6 @@ class MeCoffeeService extends StateNotifier<MachineState> {
|
|
|
'o1',
|
|
'o1',
|
|
|
'o2',
|
|
'o2',
|
|
|
'pwrflp',
|
|
'pwrflp',
|
|
|
- 'tmpoff',
|
|
|
|
|
'tmrosd',
|
|
'tmrosd',
|
|
|
'shtmx',
|
|
'shtmx',
|
|
|
'pd1imn',
|
|
'pd1imn',
|