ESP-IDF: Custom Build Configuration Beispiel

ESP-IDF: Custom Build Configuration Beispiel
Photo by Kevin Ku / Unsplash

Eine Beispielkonfiguration für ein Projekt mit verschiedenen Abhängigkeiten von Auswahl- und Eingabefeldern.

Kconfig.projbuild

menu "Pump Controller Configuration"
    menu "Pump Configuration"
        menu "Primary Pump"
            config PRIMARY_PUMP_ENABLED
                boolean "Use Primary Pump"
                default y

            config PRIMARY_PUMP_SWITCH_PIN
                depends on PRIMARY_PUMP_ENABLED
                int "GPIO Pin for Switch/Relay"
                default 12

            config PRIMARY_PUMP_POWER_ON_DISTANCE
                depends on PRIMARY_PUMP_ENABLED
                int "Power ON Distance"
                default 20

            config PRIMARY_PUMP_POWER_OFF_DISTANCE            
                depends on PRIMARY_PUMP_ENABLED
                int "Power OFF Distance"
                default 40
        endmenu
        
        menu "Secondary Pump"
            config SECONDARY_PUMP_ENABLED
                boolean "Use Secondary Pump"
                default y

            config SECONDARY_PUMP_SWITCH_PIN
                depends on SECONDARY_PUMP_ENABLED
                int "GPIO Pin for Switch/Relay"
                default 13

            config SECONDARY_PUMP_POWER_ON_DISTANCE
                depends on SECONDARY_PUMP_ENABLED
                int "Power ON Distance"
                default 15

            config SECONDARY_PUMP_POWER_OFF_DISTANCE            
                depends on SECONDARY_PUMP_ENABLED
                int "Power OFF Distance"
                default 30
        endmenu
    endmenu

    menu "Distance Sensor Configuration"
        choice DISTANCE_SENSOR_TYPE
            prompt "Distance Sensor Type"
            default DISTANCE_SENSOR_HC_SR04

            config DISTANCE_SENSOR_HC_SR04
                bool "HC-SR04"
            config DISTANCE_SENSOR_JSN_SR04T
                bool "JSN-SR04T"
            config DISTANCE_SENSOR_A02YYUW
                bool "A02YYUW"
        endchoice
        
        choice DISTANCE_SENSOR_JSN_SR04T_MODE
            depends on DISTANCE_SENSOR_JSN_SR04T
            prompt "JSN-SR04T Mode"
            default JSN_SR04T_MODE_0

            config JSN_SR04T_MODE_0
                bool "MODE 0 - Emulated HC-SR04"
            config JSN_SR04T_MODE_1
                bool "MODE 1 - Automatic Serial Data"
            config JSN_SR04T_MODE_2
                bool "MODE 2 - Controlled Serial Data"
            config JSN_SR04T_MODE_3
                bool "MODE 3 - Automatic Trigger"
            config JSN_SR04T_MODE_4
                bool "MODE 4 - Low-power Auto Trigger"
            config JSN_SR04T_MODE_5
                bool "MODE 5 - 1.5 meter Switch"
        endchoice        

        config HC_SR04_TRIGGER_PIN
            depends on DISTANCE_SENSOR_HC_SR04
            int "GPIO Pin for Trigger"
            default 5

        config HC_SR04_ECHO_PIN
            depends on DISTANCE_SENSOR_HC_SR04
            int "GPIO Pin for Echo"
            default 18

        config JSN_SR04T_TRIGGER_PIN
            depends on JSN_SR04T_MODE_0 && DISTANCE_SENSOR_JSN_SR04T
            int "GPIO Pin for Trigger"
            default 5

        config JSN_SR04T_ECHO_PIN
            depends on JSN_SR04T_MODE_0 && DISTANCE_SENSOR_JSN_SR04T
            int "GPIO Pin for Echo"
            default 18

        config JSN_SR04T_RX_PIN
            depends on !JSN_SR04T_MODE_0 && DISTANCE_SENSOR_JSN_SR04T
            int "GPIO Pin for RX"
            default 5

        config JSN_SR04T_TX_PIN
            depends on !JSN_SR04T_MODE_0 && DISTANCE_SENSOR_JSN_SR04T
            int "GPIO Pin for TX"
            default 18

        config A02YYUW_RX_PIN
            depends on DISTANCE_SENSOR_A02YYUW
            int "GPIO Pin for RX"
            default 5

        config A02YYUW_TX_PIN
            depends on DISTANCE_SENSOR_A02YYUW
            int "GPIO Pin for TX"
            default 18
    endmenu

    menu "I2C Configuration"
        config I2C_ENABLED
            boolean "Enable I2C"
            default n

        config I2C_SDA_GPIO
            depends on I2C_ENABLED
            int "I2C SDA GPIO Pin"
            default 21

        config I2C_SCL_GPIO
            depends on I2C_ENABLED
            int "I2C SCL GPIO Pin"
            default 22
    endmenu
    
    menu "WIFI Configuration"
        config WIFI_ENABLED
            boolean "Enable WIFI"
            default n

        config WIFI_SSID
            depends on WIFI_ENABLED
            string "Wifi AP SSID"
            default ""

        config WIFI_PASSWORD            
            depends on WIFI_ENABLED
            string "Wifi AP Password"
            default ""
    endmenu
endmenu