Skip to content

Commit 3f3e50a

Browse files
committed
delete old HVAC functions
1 parent 4de138e commit 3f3e50a

10 files changed

Lines changed: 71 additions & 156 deletions

File tree

‎app/src/main/java/com/mg4/control/hardware/MG4Hardware.kt‎

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5491,18 +5491,16 @@ object MG4Hardware {
54915491
* n'ayant pas la même intention.
54925492
*
54935493
* Les `null` valent « ne pas y toucher », comme dans l'automatisation : un profil qui ne se
5494-
* prononce pas sur le dégivrage ne doit pas l'éteindre au passage.
5494+
* prononce pas sur le recyclage ou le sens de l'air ne doit pas les modifier au passage.
54955495
*/
54965496
fun applyProfileClimate(
54975497
power: Boolean,
54985498
ac: Boolean,
54995499
autoMode: Boolean,
55005500
targetTemp: Int,
55015501
fanLevel: Int,
5502-
defrostFront: Boolean?,
5503-
defrostRear: Boolean?,
55045502
loopMode: Int?,
5505-
airFlow: Int? = null
5503+
airFlow: Int?
55065504
): Boolean {
55075505
val state = getClimateState() ?: run {
55085506
AppLogger.w(CLIM_TAG, "Profil : état clim illisible → abandon")
@@ -5528,13 +5526,6 @@ object MG4Hardware {
55285526
ok = setClimateFan(fanLevel.coerceIn(state.fanMin, state.fanMax)) && ok
55295527
}
55305528

5531-
// Deux conditions : que le profil se prononce, ET que le véhicule expose le réglage.
5532-
if (defrostFront != null && state.defrostFront != null) {
5533-
ok = setClimateDefrostFront(defrostFront) && ok
5534-
}
5535-
if (defrostRear != null && state.defrostRear != null) {
5536-
ok = setClimateDefrostRear(defrostRear) && ok
5537-
}
55385529
if (loopMode != null) {
55395530
val mode = when (loopMode) {
55405531
0 -> LoopMode.INNER
@@ -5544,10 +5535,10 @@ object MG4Hardware {
55445535
ok = setClimateLoopMode(mode) && ok
55455536
}
55465537

5547-
// Ligne « Air » (boutons cumulables), APRÈS les anciennes lignes de dégivrage, qui
5548-
// coexistent le temps de valider le lien dégivrage ⇔ pare-brise : si les deux portent
5549-
// sur la lunette arrière, c'est la ligne Air qui l'emporte. Hors « Inchangé », le profil
5550-
// applique ce qui est affiché : lunette arrière non cochée = dégivrage arrière ÉTEINT.
5538+
// Ligne « Air » (boutons cumulables) — elle remplace les anciennes lignes Dég. AV / AR
5539+
// depuis leur validation sur SWI133. « Pare-brise AV » passe par la VALEUR du sens de
5540+
// l'air, la lunette arrière par le dégivrage arrière. Hors « Inchangé », le profil applique
5541+
// ce qui est affiché : lunette arrière non cochée = dégivrage arrière ÉTEINT.
55515542
if (airFlow != null) {
55525543
AirFlow.directionForMask(airFlow)?.let { ok = setClimateAirFlow(it) && ok }
55535544
if (state.defrostRear != null) {
@@ -5557,8 +5548,7 @@ object MG4Hardware {
55575548

55585549
AppLogger.i(CLIM_TAG, "Profil : clim=ON A/C=$ac consigne=$targetTemp " +
55595550
(if (autoMode) "ventilation=AUTO" else "vent=$fanLevel") +
5560-
" dégAV=${defrostFront ?: "inchangé"} dégAR=${defrostRear ?: "inchangé"} " +
5561-
"recyclage=${loopMode ?: "inchangé"} " +
5551+
" recyclage=${loopMode ?: "inchangé"} " +
55625552
"air=${airFlow?.let { "boutons=$it valeur=${AirFlow.directionForMask(it)}" } ?: "inchangé"} → ok=$ok")
55635553
return ok
55645554
}

‎app/src/main/java/com/mg4/control/model/AirFlow.kt‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,17 @@ object AirFlow {
5757
else -> null
5858
}
5959

60+
/**
61+
* Reprise des anciennes lignes « Dég. AV » / « Dég. AR » du profil, retirées le 2026-09-17
62+
* une fois « Pare-brise AV / AR » validés sur véhicule (SWI133) : un dégivrage en marche
63+
* devient le bouton correspondant. Un « Off » n'a pas d'équivalent — un masque vide vaut
64+
* « Inchangé » — et se perd donc : c'est le seul cas où l'ancien profil agissait davantage.
65+
*/
66+
fun fromLegacyDefrost(front: Boolean?, rear: Boolean?): Int? {
67+
val mask = (if (front == true) WINDSHIELD else 0) or (if (rear == true) REAR_DEFROST else 0)
68+
return mask.takeIf { it != 0 }
69+
}
70+
6071
/** Valeur à écrire pour les boutons cochés d'un profil ; la lunette arrière n'y compte pas. */
6172
fun directionForMask(mask: Int): Int? = directionFor(
6273
face = mask and FACE != 0,

‎app/src/main/java/com/mg4/control/model/DrivingProfile.kt‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,11 @@ data class DrivingProfile(
8585
val hvacAuto: Boolean = false,
8686
val hvacTemp: Int = 21,
8787
val hvacFan: Int = 4,
88-
/** `null` = ne pas y toucher. Même convention que l'automatisation A/C. */
88+
/**
89+
* ANCIENNES lignes « Dég. AV / Dég. AR », retirées de l'éditeur le 2026-09-17 au profit de
90+
* [hvacAirFlow]. Conservées pour relire les profils existants : ProfileManager.getAll() les
91+
* reprend dans [hvacAirFlow] puis les remet à `null`. Plus rien ne les applique.
92+
*/
8993
val hvacDefrostFront: Boolean? = null,
9094
val hvacDefrostRear: Boolean? = null,
9195
/** `null` = inchangé, sinon 0=Intérieur, 1=Extérieur, 2=Auto. */

‎app/src/main/java/com/mg4/control/profile/ProfileApplier.kt‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,6 @@ object ProfileApplier {
142142
autoMode = profile.hvacAuto,
143143
targetTemp = profile.hvacTemp,
144144
fanLevel = profile.hvacFan,
145-
defrostFront = profile.hvacDefrostFront,
146-
defrostRear = profile.hvacDefrostRear,
147145
loopMode = profile.hvacLoopMode,
148146
airFlow = profile.hvacAirFlow
149147
)

‎app/src/main/java/com/mg4/control/profile/ProfileManager.kt‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.mg4.control.profile
33
import android.content.Context
44
import com.google.gson.Gson
55
import com.google.gson.reflect.TypeToken
6+
import com.mg4.control.model.AirFlow
67
import com.mg4.control.model.DrivingProfile
78
import kotlinx.coroutines.CoroutineScope
89
import kotlinx.coroutines.Dispatchers
@@ -46,6 +47,17 @@ class ProfileManager(private val context: Context) {
4647
// On les initialise à AEB activé + mode Alerte+Freinage par défaut.
4748
list.map { p ->
4849
if (p.aebMode == 0) p.copy(aebEnabled = true, aebMode = 2) else p
50+
}.map { p ->
51+
// Migration : anciennes lignes « Dég. AV / Dég. AR » (retirées le 2026-09-17) →
52+
// ligne « Air ». Faite à la lecture, comme l'AEB : sans elle, un réglage devenu
53+
// invisible dans l'éditeur continuerait de s'appliquer sans qu'on puisse le changer.
54+
// Une ligne Air déjà renseignée l'emporte : c'est le choix le plus récent.
55+
if (p.hvacDefrostFront == null && p.hvacDefrostRear == null) p
56+
else p.copy(
57+
hvacAirFlow = p.hvacAirFlow ?: AirFlow.fromLegacyDefrost(p.hvacDefrostFront, p.hvacDefrostRear),
58+
hvacDefrostFront = null,
59+
hvacDefrostRear = null
60+
)
4961
}
5062
} catch (_: Exception) { emptyList() }
5163
}

‎app/src/main/java/com/mg4/control/ui/DashboardFragment.kt‎

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,8 +1235,6 @@ class DashboardFragment : Fragment() {
12351235
private var climBtnPower: MaterialButton? = null
12361236
private var climBtnAc: MaterialButton? = null
12371237
private var climBtnAuto: MaterialButton? = null
1238-
private var climBtnDefFront: MaterialButton? = null
1239-
private var climBtnDefRear: MaterialButton? = null
12401238
private var climLoopButtons: Map<Int, MaterialButton?> = emptyMap()
12411239
private var climBtnAirFace: MaterialButton? = null
12421240
private var climBtnAirFeet: MaterialButton? = null
@@ -1276,8 +1274,6 @@ class DashboardFragment : Fragment() {
12761274
climBtnPower = view.findViewById(R.id.clim_btn_power)
12771275
climBtnAc = view.findViewById(R.id.clim_btn_ac)
12781276
climBtnAuto = view.findViewById(R.id.clim_btn_auto)
1279-
climBtnDefFront = view.findViewById(R.id.clim_btn_defrost_front)
1280-
climBtnDefRear = view.findViewById(R.id.clim_btn_defrost_rear)
12811277
climLoopButtons = mapOf(
12821278
MG4Hardware.LoopMode.INNER to view.findViewById<MaterialButton>(R.id.clim_btn_loop_inner),
12831279
MG4Hardware.LoopMode.OUTSIDE to view.findViewById<MaterialButton>(R.id.clim_btn_loop_outside),
@@ -1352,12 +1348,6 @@ class DashboardFragment : Fragment() {
13521348
climBtnAuto?.setOnClickListener {
13531349
climLastState?.autoOn?.let { cur -> climateWrite { MG4Hardware.setClimateAuto(!cur) } }
13541350
}
1355-
climBtnDefFront?.setOnClickListener {
1356-
climLastState?.defrostFront?.let { cur -> climateWrite { MG4Hardware.setClimateDefrostFront(!cur) } }
1357-
}
1358-
climBtnDefRear?.setOnClickListener {
1359-
climLastState?.defrostRear?.let { cur -> climateWrite { MG4Hardware.setClimateDefrostRear(!cur) } }
1360-
}
13611351
climLoopButtons.forEach { (mode, btn) ->
13621352
btn?.setOnClickListener { climateWrite { MG4Hardware.setClimateLoopMode(mode) } }
13631353
}
@@ -1379,14 +1369,21 @@ class DashboardFragment : Fragment() {
13791369
return
13801370
}
13811371
AppLogger.i(CLIM_UI_TAG, "Sens de l'air : appui → $lu ⇒ $cible")
1372+
// Relue par le rafraîchissement qui suit l'écriture ; d'ici là, un second appui
1373+
// rapide doit partir de la combinaison DEMANDÉE. Sans ça, il recomposait depuis
1374+
// l'ancienne valeur et pouvait être ignoré (constaté sur SWI133 le 2026-09-17).
1375+
climLastState = climLastState?.copy(airFlow = cible)
13821376
climateWrite { MG4Hardware.setClimateAirFlow(cible) }
13831377
}
13841378
climBtnAirFace?.setOnClickListener { basculerAir(face = true) }
13851379
climBtnAirFeet?.setOnClickListener { basculerAir(feet = true) }
13861380
climBtnAirWindshield?.setOnClickListener { basculerAir(windshield = true) }
13871381
// Lunette arrière : hors de l'échelle du sens de l'air, c'est le dégivrage arrière.
13881382
climBtnAirRear?.setOnClickListener {
1389-
climLastState?.defrostRear?.let { cur -> climateWrite { MG4Hardware.setClimateDefrostRear(!cur) } }
1383+
climLastState?.defrostRear?.let { cur ->
1384+
climLastState = climLastState?.copy(defrostRear = !cur) // même raison
1385+
climateWrite { MG4Hardware.setClimateDefrostRear(!cur) }
1386+
}
13901387
}
13911388
}
13921389

@@ -1425,8 +1422,6 @@ class DashboardFragment : Fragment() {
14251422
bindClimToggle(climBtnPower, s.powerOn)
14261423
bindClimToggle(climBtnAc, s.acOn)
14271424
bindClimToggle(climBtnAuto, s.autoOn)
1428-
bindClimToggle(climBtnDefFront, s.defrostFront)
1429-
bindClimToggle(climBtnDefRear, s.defrostRear)
14301425

14311426
// Valeur illisible → boutons grisés. Valeur lue mais hors échelle (7 « aucun »)
14321427
// → boutons actifs, aucun allumé : l'utilisateur peut choisir un sens.

‎app/src/main/java/com/mg4/control/ui/ProfileEditFragment.kt‎

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,6 @@ class ProfileEditFragment : Fragment() {
128128
// hors de [valueFrom, valueTo] — l'éditeur planterait à l'ouverture d'un ancien profil.
129129
var hvacTempSel = data.hvacTemp.coerceIn(HVAC_TEMP_MIN, HVAC_TEMP_MAX)
130130
var hvacFanSel = data.hvacFan.coerceIn(HVAC_FAN_MIN, HVAC_FAN_MAX)
131-
var hvacDfSel = data.hvacDefrostFront
132-
var hvacDrSel = data.hvacDefrostRear
133131
var hvacLoopSel = data.hvacLoopMode
134132
var hvacAirSel = data.hvacAirFlow // bits AirFlow, null = inchangé
135133
// Index 0/1/2, ou null quand le profil ne s'est jamais prononcé (créé avant la
@@ -302,16 +300,6 @@ class ProfileEditFragment : Fragment() {
302300
view.findViewById<MaterialButton>(R.id.btn_hvac_loop_auto),
303301
view.findViewById<MaterialButton>(R.id.btn_hvac_loop_none)
304302
)
305-
val dfBtns = listOf(
306-
view.findViewById<MaterialButton>(R.id.btn_hvac_df_off),
307-
view.findViewById<MaterialButton>(R.id.btn_hvac_df_on),
308-
view.findViewById<MaterialButton>(R.id.btn_hvac_df_none)
309-
)
310-
val drBtns = listOf(
311-
view.findViewById<MaterialButton>(R.id.btn_hvac_dr_off),
312-
view.findViewById<MaterialButton>(R.id.btn_hvac_dr_on),
313-
view.findViewById<MaterialButton>(R.id.btn_hvac_dr_none)
314-
)
315303
// Ligne « Air » : bouton → bit du profil. Cumulables, contrairement aux groupes ci-dessus.
316304
val airBtns = listOf(
317305
view.findViewById<MaterialButton>(R.id.btn_hvac_air_face) to AirFlow.FACE,
@@ -333,7 +321,7 @@ class ProfileEditFragment : Fragment() {
333321
val actif = hvacEnabledSel
334322
val allume = actif && hvacPowerSel
335323
setBtnsEnabled(listOf(btnPower), actif)
336-
setBtnsEnabled(listOf(btnAc, btnAuto) + loopBtns + dfBtns + drBtns +
324+
setBtnsEnabled(listOf(btnAc, btnAuto) + loopBtns +
337325
airBtns.map { it.first } + btnAirNone, allume)
338326
listOf(sldTemp, sldFan).forEach { it.isEnabled = allume }
339327
sldFan.isEnabled = allume && !hvacAutoSel
@@ -349,12 +337,6 @@ class ProfileEditFragment : Fragment() {
349337
bindGroup(listOf(
350338
loopBtns[0] to 0, loopBtns[1] to 1, loopBtns[2] to 2, loopBtns[3] to null
351339
), hvacLoopSel) { hvacLoopSel = it }
352-
bindGroup(listOf(
353-
dfBtns[0] to false, dfBtns[1] to true, dfBtns[2] to null
354-
), hvacDfSel) { hvacDfSel = it }
355-
bindGroup(listOf(
356-
drBtns[0] to false, drBtns[1] to true, drBtns[2] to null
357-
), hvacDrSel) { hvacDrSel = it }
358340

359341
/**
360342
* Ligne « Air » : « Inchangé » allumé ⇔ aucun bouton coché (null). Hors « Inchangé », le
@@ -731,8 +713,9 @@ class ProfileEditFragment : Fragment() {
731713
hvacAuto = hvacAutoSel,
732714
hvacTemp = hvacTempSel,
733715
hvacFan = hvacFanSel,
734-
hvacDefrostFront = hvacDfSel,
735-
hvacDefrostRear = hvacDrSel,
716+
// Anciennes lignes Dég. AV / AR : reprises dans hvacAirFlow à la lecture.
717+
hvacDefrostFront = null,
718+
hvacDefrostRear = null,
736719
hvacLoopMode = hvacLoopSel,
737720
hvacAirFlow = hvacAirSel,
738721
btDeviceMac = selectedBtMac // [BT-PROFILES]

‎app/src/main/res/layout/fragment_dashboard.xml‎

Lines changed: 4 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -2177,7 +2177,7 @@
21772177
</LinearLayout>
21782178

21792179
<!-- ══════════════════════════════════════════════════════════════════ -->
2180-
<!-- CARTE : Interrupteurs | Recirculation | Dégivrages -->
2180+
<!-- CARTE : Interrupteurs | Recirculation -->
21812181
<!-- ══════════════════════════════════════════════════════════════════ -->
21822182
<LinearLayout
21832183
android:layout_width="match_parent"
@@ -2281,8 +2281,7 @@
22812281
android:layout_weight="1"
22822282
android:orientation="vertical"
22832283
android:background="@drawable/bg_section_rounded"
2284-
android:padding="9dp"
2285-
android:layout_marginEnd="5dp">
2284+
android:padding="9dp">
22862285

22872286
<TextView
22882287
android:layout_width="match_parent"
@@ -2338,66 +2337,14 @@
23382337

23392338
</LinearLayout>
23402339

2341-
<!-- ── Colonne 3 : Dégivrages ──────────────────────────── -->
2342-
<LinearLayout
2343-
android:layout_width="0dp"
2344-
android:layout_height="match_parent"
2345-
android:layout_weight="1"
2346-
android:orientation="vertical"
2347-
android:background="@drawable/bg_section_rounded"
2348-
android:padding="9dp">
2349-
2350-
<TextView
2351-
android:layout_width="match_parent"
2352-
android:layout_height="wrap_content"
2353-
android:text="@string/clim_section_defrost"
2354-
android:textColor="@color/dash_text_lo"
2355-
android:textSize="13sp"
2356-
android:textStyle="bold"
2357-
android:letterSpacing="0.08"
2358-
android:textAllCaps="true"
2359-
android:layout_marginBottom="6dp" />
2360-
2361-
<com.google.android.material.button.MaterialButton
2362-
android:id="@+id/clim_btn_defrost_front"
2363-
android:layout_width="match_parent"
2364-
android:layout_height="52dp"
2365-
android:layout_marginBottom="4dp"
2366-
android:text="@string/clim_defrost_front"
2367-
android:textColor="@color/text_secondary"
2368-
android:textSize="16sp"
2369-
android:textAllCaps="true"
2370-
app:backgroundTint="@color/dash_btn"
2371-
app:strokeWidth="1dp"
2372-
app:strokeColor="@color/dash_border"
2373-
app:cornerRadius="8dp" />
2374-
2375-
<!-- Dégivrage arrière : commandé par un bouton PHYSIQUE sur le véhicule.
2376-
Reste ici pour vérifier si le service l'expose aussi ; il se grise
2377-
automatiquement si l'état n'est pas lisible. -->
2378-
<com.google.android.material.button.MaterialButton
2379-
android:id="@+id/clim_btn_defrost_rear"
2380-
android:layout_width="match_parent"
2381-
android:layout_height="52dp"
2382-
android:text="@string/clim_defrost_rear"
2383-
android:textColor="@color/text_secondary"
2384-
android:textSize="16sp"
2385-
android:textAllCaps="true"
2386-
app:backgroundTint="@color/dash_btn"
2387-
app:strokeWidth="1dp"
2388-
app:strokeColor="@color/dash_border"
2389-
app:cornerRadius="8dp" />
2390-
2391-
</LinearLayout>
2392-
23932340
</LinearLayout>
23942341

23952342
</LinearLayout>
23962343

23972344
<!-- ══════════════════════════════════════════════════════════════════ -->
23982345
<!-- CARTE : Sens de l'air — boutons CUMULABLES (voir model.AirFlow) -->
2399-
<!-- Les dégivrages de la carte Modes restent, le temps de valider sur -->
2400-
<!-- véhicule que « Pare-brise AV » et le dégivrage avant se recouvrent. -->
2346+
<!-- « Pare-brise AV / AR » remplacent les anciens boutons Dégivrage -->
2347+
<!-- (validé SWI133 le 2026-09-17). -->
24012348
<!-- ══════════════════════════════════════════════════════════════════ -->
24022349
<LinearLayout
24032350
android:id="@+id/clim_airflow_card"

0 commit comments

Comments
 (0)