Mochis NoticiasTecnologíaAndroid AAOS 14 – Climatización de 4 zonas
Mochis NoticiasTecnologíaAndroid AAOS 14 – Climatización de 4 zonas
Tecnología

Android AAOS 14 – Climatización de 4 zonas

Android AAOS 14 – Climatización de 4 zonas

En este artículo, exploraremos la implementación de un sistema de control de clima de cuatro zonas para vehículos que utilizan el sistema operativo Android Automotive (AAOS) versión 14. Los sistemas de control de clima multizona permiten a los pasajeros individuales ajustar la temperatura para sus áreas específicas, mejorando la comodidad y Personalizando la experiencia en el coche. Analizaremos la arquitectura, los componentes y los pasos de integración necesarios para crear un sistema HVAC de cuatro zonas robusto y eficiente en el entorno AAOS.

Comprender el control climático en cuatro zonas

Un sistema de control de clima de cuatro zonas divide la cabina del vehículo en cuatro zonas distintas: el conductor, el pasajero delantero, el pasajero trasero izquierdo y el pasajero trasero derecho. Cada zona se puede controlar de forma independiente para establecer la temperatura deseada. Este sistema mejora la comodidad de los pasajeros al adaptarse a las preferencias individuales y garantizar un ambiente óptimo para todos los ocupantes.

Modifique SystemUI para cuatro zonas HVAC en Android AAOS14

Para implementar un sistema HVAC de cuatro zonas en Android AAOS14, primero debemos modificar SystemUI, que administra la interfaz de usuario. La aplicación se encuentra en packages/apps/Car/SystemUI. El panel HVAC está definido en el archivo. res/layout/hvac_panel.xml.

A continuación se muestra una definición de ejemplo del panel HVAC con cuatro controles deslizantes para control de temperatura y cuatro botones para calefacción de asientos:

<!--
  ~ Copyright (C) 2022 The Android Open Source Project
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~      http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->
 
<com.android.systemui.car.hvac.HvacPanelView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:systemui="http://schemas.android.com/apk/res-auto"
    android:id="@+id/hvac_panel"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="@dimen/hvac_panel_full_expanded_height"
    android:background="@color/hvac_background_color">
    
    <androidx.constraintlayout.widget.Guideline
        android:id="@+id/top_guideline"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        app:layout_constraintGuide_begin="@dimen/hvac_panel_top_padding"/>
        
    <androidx.constraintlayout.widget.Guideline
        android:id="@+id/bottom_guideline"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        app:layout_constraintGuide_end="@dimen/hvac_panel_bottom_padding"/>
        
    <!-- HVAC property IDs can be found in VehiclePropertyIds.java, and the area IDs depend on each OEM's VHAL implementation. -->
 
<com.android.systemui.car.hvac.referenceui.BackgroundAdjustingTemperatureControlView
        android:id="@+id/driver_hvac"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toTopOf="@+id/row2_driver_hvac"
        systemui:hvacAreaId="1">
        <include layout="@layout/hvac_temperature_bar_overlay"/>

</com.android.systemui.car.hvac.referenceui.BackgroundAdjustingTemperatureControlView>
    
<com.android.systemui.car.hvac.referenceui.BackgroundAdjustingTemperatureControlView
        android:id="@+id/row2_driver_hvac"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/driver_hvac"
        app:layout_constraintBottom_toBottomOf="parent"
        systemui:hvacAreaId="16">
        <include layout="@layout/hvac_temperature_bar_overlay"/>

</com.android.systemui.car.hvac.referenceui.BackgroundAdjustingTemperatureControlView>
 
    <com.android.systemui.car.hvac.SeatTemperatureLevelButton
        android:id="@+id/seat_heat_level_button_left"
        android:background="@drawable/hvac_panel_button_bg"
        style="@style/HvacButton"
        app:layout_constraintTop_toBottomOf="@+id/top_guideline"
        app:layout_constraintLeft_toRightOf="@+id/driver_hvac"
        app:layout_constraintBottom_toTopOf="@+id/recycle_air_button"
        systemui:hvacAreaId="1"
        systemui:seatTemperatureType="heating"

 systemui:seatTemperatureIconDrawableList="@array/hvac_heated_seat_default_icons"/>
        
    <com.android.systemui.car.hvac.toggle.HvacBooleanToggleButton
        android:id="@+id/recycle_air_button"
        android:layout_width="@dimen/hvac_panel_button_dimen"
        android:layout_height="@dimen/hvac_panel_group_height"
        android:background="@drawable/hvac_panel_button_bg"
        app:layout_constraintTop_toBottomOf="@+id/seat_heat_level_button_left"
        app:layout_constraintLeft_toRightOf="@+id/driver_hvac"
        app:layout_constraintBottom_toTopOf="@+id/row2_seat_heat_level_button_left"
        systemui:hvacAreaId="117"
        systemui:hvacPropertyId="354419976"
        systemui:hvacTurnOffIfAutoOn="true"
        systemui:hvacToggleOnButtonDrawable="@drawable/ic_recycle_air_on"
        systemui:hvacToggleOffButtonDrawable="@drawable/ic_recycle_air_off"/>
 
    <com.android.systemui.car.hvac.SeatTemperatureLevelButton
        android:id="@+id/row2_seat_heat_level_button_left"
        android:background="@drawable/hvac_panel_button_bg"
        style="@style/HvacButton"
        app:layout_constraintTop_toBottomOf="@+id/recycle_air_button"
        app:layout_constraintLeft_toRightOf="@+id/row2_driver_hvac"
        app:layout_constraintBottom_toBottomOf="@+id/bottom_guideline"
        systemui:hvacAreaId="16"
        systemui:seatTemperatureType="heating"

systemui:seatTemperatureIconDrawableList="@array/hvac_heated_seat_default_icons"/>
 
    <LinearLayout
        android:id="@+id/fan_control"
        android:background="@drawable/hvac_panel_button_bg"
        android:layout_width="@dimen/hvac_fan_speed_bar_width"
        android:layout_height="@dimen/hvac_panel_group_height"
        app:layout_constraintTop_toBottomOf="@+id/top_guideline"
        app:layout_constraintLeft_toRightOf="@+id/seat_heat_level_button_left"
        app:layout_constraintRight_toLeftOf="@+id/seat_heat_level_button_right"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true"
        android:orientation="vertical">
        <com.android.systemui.car.hvac.referenceui.FanSpeedBar
            android:layout_weight="1"
            android:layout_width="match_parent"
            android:layout_height="0dp"/>
        <com.android.systemui.car.hvac.referenceui.FanDirectionButtons
            android:layout_weight="1"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:orientation="horizontal"
            android:layoutDirection="ltr"/>
    </LinearLayout>
 
    <com.android.systemui.car.hvac.toggle.HvacBooleanToggleButton
        android:id="@+id/ac_master_switch"
        android:background="@drawable/hvac_panel_button_bg"
        android:scaleType="center"
        style="@style/HvacButton"
        app:layout_constraintBottom_toBottomOf="@+id/bottom_guideline"
        app:layout_constraintLeft_toRightOf="@+id/row2_seat_heat_level_button_left"
        systemui:hvacAreaId="117"
        systemui:hvacPropertyId="354419984"
        systemui:hvacTurnOffIfPowerOff="false"
        systemui:hvacToggleOnButtonDrawable="@drawable/ac_master_switch_on"
        systemui:hvacToggleOffButtonDrawable="@drawable/ac_master_switch_off"/>
 
    <com.android.systemui.car.hvac.toggle.HvacBooleanToggleButton
        android:id="@+id/defroster_button"
        android:background="@drawable/hvac_panel_button_bg"
        style="@style/HvacButton"
        app:layout_constraintLeft_toRightOf="@+id/ac_master_switch"
        app:layout_constraintBottom_toBottomOf="@+id/bottom_guideline"
        systemui:hvacAreaId="1"
        systemui:hvacPropertyId="320865540"
        systemui:hvacToggleOnButtonDrawable="@drawable/ic_front_defroster_on"
        systemui:hvacToggleOffButtonDrawable="@drawable/ic_front_defroster_off"/>
 
    <com.android.systemui.car.hvac.toggle.HvacBooleanToggleButton
        android:id="@+id/auto_button"
        android:background="@drawable/hvac_panel_button_bg"
        systemui:hvacAreaId="117"
        systemui:hvacPropertyId="354419978"
        android:scaleType="center"
        android:layout_gravity="center"
        android:layout_width="0dp"
        style="@style/HvacButton"
        app:layout_constraintLeft_toRightOf="@+id/defroster_button"
        app:layout_constraintRight_toLeftOf="@+id/rear_defroster_button"
        app:layout_constraintBottom_toBottomOf="@+id/bottom_guideline"
        systemui:hvacToggleOnButtonDrawable="@drawable/ic_auto_on"
        systemui:hvacToggleOffButtonDrawable="@drawable/ic_auto_off"/>
 
    <com.android.systemui.car.hvac.toggle.HvacBooleanToggleButton
        android:id="@+id/rear_defroster_button"
        android:background="@drawable/hvac_panel_button_bg"
        style="@style/HvacButton"
        app:layout_constraintLeft_toRightOf="@+id/auto_button"
        app:layout_constraintBottom_toBottomOf="@+id/bottom_guideline"
        systemui:hvacAreaId="2"
        systemui:hvacPropertyId="320865540"
        systemui:hvacToggleOnButtonDrawable="@drawable/ic_rear_defroster_on"
        systemui:hvacToggleOffButtonDrawable="@drawable/ic_rear_defroster_off"/>
        
<com.android.systemui.car.hvac.referenceui.BackgroundAdjustingTemperatureControlView
        android:id="@+id/passenger_hvac"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toTopOf="@+id/row2_passenger_hvac"
        systemui:hvacAreaId="2">
        <include layout="@layout/hvac_temperature_bar_overlay"/>

 </com.android.systemui.car.hvac.referenceui.BackgroundAdjustingTemperatureControlView>
    
 <com.android.systemui.car.hvac.referenceui.BackgroundAdjustingTemperatureControlView
        android:id="@+id/row2_passenger_hvac"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/passenger_hvac"
        app:layout_constraintBottom_toBottomOf="parent"
        systemui:hvacAreaId="32">
        <include layout="@layout/hvac_temperature_bar_overlay"/>

 </com.android.systemui.car.hvac.referenceui.BackgroundAdjustingTemperatureControlView>
    
    <com.android.systemui.car.hvac.SeatTemperatureLevelButton
        android:id="@+id/seat_heat_level_button_right"
        android:background="@drawable/hvac_panel_button_bg"
        style="@style/HvacButton"
        app:layout_constraintTop_toBottomOf="@+id/top_guideline"
        app:layout_constraintRight_toLeftOf="@+id/passenger_hvac"
        app:layout_constraintBottom_toTopOf="@+id/row2_seat_heat_level_button_right"
        systemui:hvacAreaId="2"
        systemui:seatTemperatureType="heating"

systemui:seatTemperatureIconDrawableList="@array/hvac_heated_seat_default_icons"/>
        
    <com.android.systemui.car.hvac.SeatTemperatureLevelButton
        android:id="@+id/row2_seat_heat_level_button_right"
        android:background="@drawable/hvac_panel_button_bg"
        style="@style/HvacButton"
        app:layout_constraintTop_toBottomOf="@+id/seat_heat_level_button_right"
        app:layout_constraintRight_toLeftOf="@+id/row2_passenger_hvac"
        app:layout_constraintBottom_toBottomOf="@+id/bottom_guideline"
        systemui:hvacAreaId="32"
        systemui:seatTemperatureType="heating"

systemui:seatTemperatureIconDrawableList="@array/hvac_heated_seat_default_icons"/>
</com.android.systemui.car.hvac.HvacPanelView>

Los principales cambios son:

  • Un aumento BackgroundAdjustingTemperatureControlView para cada zona y sus cambios systemui:hvacAreaId para hacer coincidir los valores de VehicleAreaSeat::ROW_1_LEFT, VehicleAreaSeat::ROW_2_LEFT, VehicleAreaSeat::ROW_1_RIGHTy VehicleAreaSeat::ROW_2_RIGHT.
  • Un aumento SeatTemperatureLevelButton para cada área.

El diseño debe estar adecuadamente organizado para adaptarse al diseño deseado. Puede encontrar información sobre cómo describir el diseño en XML en Desarrolladores de Android – Recurso de diseño.

El diseño presentado también requiere cambiar los valores constantes en el res/values/dimens.xml archivo. A continuación se muestra la diferencia con mis cambios:

diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 11649d4..3f96413 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -73,7 +73,7 @@
     <dimen name="car_primary_icon_size">@*android:dimen/car_primary_icon_size</dimen>

     <dimen name="hvac_container_padding">16dp</dimen>
-    <dimen name="hvac_temperature_bar_margin">32dp</dimen>
+    <dimen name="hvac_temperature_bar_margin">16dp</dimen>
     <dimen name="hvac_temperature_text_size">56sp</dimen>
     <dimen name="hvac_temperature_text_padding">8dp</dimen>
     <dimen name="hvac_temperature_button_size">76dp</dimen>
@@ -295,9 +295,9 @@
     <dimen name="hvac_panel_row_animation_height_shift">0dp</dimen>

     <dimen name="temperature_bar_collapsed_width">96dp</dimen>
-    <dimen name="temperature_bar_expanded_width">96dp</dimen>
+    <dimen name="temperature_bar_expanded_width">128dp</dimen>
     <dimen name="temperature_bar_collapsed_height">96dp</dimen>
-    <dimen name="temperature_bar_expanded_height">356dp</dimen>
+    <dimen name="temperature_bar_expanded_height">200dp</dimen>
     <dimen name="temperature_bar_icon_margin">20dp</dimen>
     <dimen name="temperature_bar_close_icon_dimen">96dp</dimen>

Configuración VHAL

El siguiente paso es agregar zonas adicionales a la configuración de VHAL. El archivo de configuración se encuentra en hardware/interfaces/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h.

En mi ejemplo, modifiqué HVAC_SEAT_TEMPERATURE y HVAC_TEMPERATURE_SET:

{.config = {.prop = toInt(VehicleProperty::HVAC_SEAT_TEMPERATURE),
            .access = VehiclePropertyAccess::READ_WRITE,
            .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
            .areaConfigs = {VehicleAreaConfig{
                                    .areaId = SEAT_1_LEFT,
                                    .minInt32Value = -3,
                                    .maxInt32Value = 3,
                            },
                            VehicleAreaConfig{
                                    .areaId = SEAT_1_RIGHT,
                                    .minInt32Value = -3,
                                    .maxInt32Value = 3,
                            },
                            VehicleAreaConfig{
                                    .areaId = SEAT_2_LEFT,
                                    .minInt32Value = -3,
                                    .maxInt32Value = 3,
                            },
                            VehicleAreaConfig{
                                    .areaId = SEAT_2_RIGHT,
                                    .minInt32Value = -3,
                                    .maxInt32Value = 3,
                            },
                            }},
     .initialValue = {.int32Values = {0}}},  // +ve values for heating and -ve for cooling

{.config = {.prop = toInt(VehicleProperty::HVAC_TEMPERATURE_SET),
            .access = VehiclePropertyAccess::READ_WRITE,
            .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
            .configArray = {160, 280, 5, 605, 825, 10},
            .areaConfigs = {VehicleAreaConfig{
                                    .areaId = (int)(VehicleAreaSeat::ROW_1_LEFT),
                                    .minFloatValue = 16,
                                    .maxFloatValue = 32,
                            },
                            VehicleAreaConfig{
                                    .areaId = (int)(VehicleAreaSeat::ROW_1_RIGHT),
                                    .minFloatValue = 16,
                                    .maxFloatValue = 32,
                            },
                            VehicleAreaConfig{
                                    .areaId = (int)(VehicleAreaSeat::ROW_2_LEFT),
                                    .minFloatValue = 16,
                                    .maxFloatValue = 32,
                            },
                            VehicleAreaConfig{
                                    .areaId = (int)(VehicleAreaSeat::ROW_2_RIGHT),
                                    .minFloatValue = 16,
                                    .maxFloatValue = 32,
                            }
                    }},
     .initialAreaValues = {{(int)(VehicleAreaSeat::ROW_1_LEFT), {.floatValues = {16}}},
                           {(int)(VehicleAreaSeat::ROW_1_RIGHT), {.floatValues = {17}}},
                           {(int)(VehicleAreaSeat::ROW_2_LEFT), {.floatValues = {16}}},
                           {(int)(VehicleAreaSeat::ROW_2_RIGHT), {.floatValues = {19}}},
                        }},

Esta configuración modifica la temperatura del asiento HVAC y las propiedades establecidas de temperatura para incluir las cuatro zonas: delantera izquierda, delantera derecha, trasera izquierda y trasera izquierda-derecha. El ID de área para cada área se especifica en consecuencia. El minInt32Value y el maxInt32Value para la temperatura del asiento se establecen en -3 y 3, respectivamente, mientras que el rango de temperatura se establece entre 16 y 32 grados Celsius.

Después de modificar la configuración de VHAL, los nuevos valores se transmitirán al VendorVehicleHal. Esto garantiza que la configuración de HVAC se refleje y controle con precisión en el sistema. Para obtener información detallada sobre cómo utilizar estas configuraciones y transmitir estos datos a través de la red, consulte nuestros artículos: «Control del módulo HVAC en automóviles con Android: un paso en la integración XIT/IP» e «Integración del control HVAC en Android con DDS» . Estos recursos brindan orientación integral sobre cómo aprovechar protocolos de red como SOME/IP y DDS para un control efectivo de los módulos HVAC en sistemas automotrices.

Construyendo la aplicación

La creación de componentes SystemUI y VHAL requiere comandos y pasos específicos para garantizar que se compilen e implementen correctamente.

mmma packages/apps/Car/SystemUI/
mmma hardware/interfaces/automotive/vehicle/2.0/default/

Carga de Aplicaciones

Después de crear SystemUI y VHAL, debe cargar las aplicaciones compiladas en el dispositivo. Utilice los siguientes comandos:

adb push out/target/product/rpi4/system/system_ext/priv-app/CarSystemUI/CarSystemUI.apk /system/system_ext/priv-app/CarSystemUI/

adb push out/target/product/rpi4/vendor/bin/hw/android.hardware.automotive.vehicle@2.0-default-service /vendor/bin/hw

Conclusión

En esta guía, cubrimos los pasos necesarios para modificar las configuraciones de HVAC actualizando el diseño XML y los archivos de configuración VHAL. También detallamos el proceso de construcción e implementación de los componentes SystemUI y VHAL en su dispositivo de destino.

Si sigue estos pasos, se asegurará de que su sistema refleje los cambios deseados y funcione según lo previsto.

Source link

Hi, I’m Corina Guzman

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *