|
@@ -531,8 +531,16 @@ class MeCoffeeService extends StateNotifier<MachineState> {
|
|
|
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});
|
|
@@ -561,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();
|