From 4c446b5f5832035f095f84cbca7d270978d57fe7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 16 Sep 2025 23:26:57 +0000 Subject: [PATCH 1/7] Initial plan From bf43c9ec88f1841c27fedbc6ca74d153c56961cc Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Tue, 16 Sep 2025 23:34:43 +0000 Subject: [PATCH 2/7] Update changelog for version 25.9.8 --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 78b12051..a8736ba7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Hardware + +## [25.9.8] + +### Added + +### Changed + +### Hardware + ## [25.8.26] ### Added From 8d45fd974755faf7b965ad2bd7e8b483a752c4ba Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 16 Sep 2025 23:38:56 +0000 Subject: [PATCH 3/7] Initial analysis and plan for parameter refactoring Co-authored-by: doudar <17362216+doudar@users.noreply.github.com> --- dependencies.lock | 2 +- sdkconfig.release | 407 +++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 407 insertions(+), 2 deletions(-) diff --git a/dependencies.lock b/dependencies.lock index 17170be1..937a8ec5 100644 --- a/dependencies.lock +++ b/dependencies.lock @@ -96,6 +96,6 @@ direct_dependencies: - espressif/network_provisioning - idf - joltwallet/littlefs -manifest_hash: e871ea1e1aff9421b8e57e1c5a4db8daeef71b071a2a17f239e5feebc4acdfc3 +manifest_hash: e9919b5b28bb7bb038864af176d8e81936400eff14ef44258dd5186bdc427ec2 target: esp32 version: 2.0.0 diff --git a/sdkconfig.release b/sdkconfig.release index 8059f8a4..f6d8d85c 100644 --- a/sdkconfig.release +++ b/sdkconfig.release @@ -2,253 +2,501 @@ # Automatically generated file. DO NOT EDIT. # Espressif IoT Development Framework (ESP-IDF) 5.4.1 Project Configuration # +# default: CONFIG_SOC_BROWNOUT_RESET_SUPPORTED="Not determined" +# default: CONFIG_SOC_TWAI_BRP_DIV_SUPPORTED="Not determined" +# default: CONFIG_SOC_DPORT_WORKAROUND="Not determined" +# default: CONFIG_SOC_CAPS_ECO_VER_MAX=301 +# default: CONFIG_SOC_ADC_SUPPORTED=y +# default: CONFIG_SOC_DAC_SUPPORTED=y +# default: CONFIG_SOC_UART_SUPPORTED=y +# default: CONFIG_SOC_MCPWM_SUPPORTED=y +# default: CONFIG_SOC_GPTIMER_SUPPORTED=y +# default: CONFIG_SOC_SDMMC_HOST_SUPPORTED=y +# default: CONFIG_SOC_BT_SUPPORTED=y +# default: CONFIG_SOC_PCNT_SUPPORTED=y +# default: CONFIG_SOC_PHY_SUPPORTED=y +# default: CONFIG_SOC_WIFI_SUPPORTED=y +# default: CONFIG_SOC_SDIO_SLAVE_SUPPORTED=y +# default: CONFIG_SOC_TWAI_SUPPORTED=y +# default: CONFIG_SOC_EFUSE_SUPPORTED=y +# default: CONFIG_SOC_EMAC_SUPPORTED=y +# default: CONFIG_SOC_ULP_SUPPORTED=y +# default: CONFIG_SOC_CCOMP_TIMER_SUPPORTED=y +# default: CONFIG_SOC_RTC_FAST_MEM_SUPPORTED=y +# default: CONFIG_SOC_RTC_SLOW_MEM_SUPPORTED=y +# default: CONFIG_SOC_RTC_MEM_SUPPORTED=y +# default: CONFIG_SOC_I2S_SUPPORTED=y +# default: CONFIG_SOC_RMT_SUPPORTED=y +# default: CONFIG_SOC_SDM_SUPPORTED=y +# default: CONFIG_SOC_GPSPI_SUPPORTED=y +# default: CONFIG_SOC_LEDC_SUPPORTED=y +# default: CONFIG_SOC_I2C_SUPPORTED=y +# default: CONFIG_SOC_SUPPORT_COEXISTENCE=y +# default: CONFIG_SOC_AES_SUPPORTED=y +# default: CONFIG_SOC_MPI_SUPPORTED=y +# default: CONFIG_SOC_SHA_SUPPORTED=y +# default: CONFIG_SOC_FLASH_ENC_SUPPORTED=y +# default: CONFIG_SOC_SECURE_BOOT_SUPPORTED=y +# default: CONFIG_SOC_TOUCH_SENSOR_SUPPORTED=y +# default: CONFIG_SOC_BOD_SUPPORTED=y +# default: CONFIG_SOC_ULP_FSM_SUPPORTED=y +# default: CONFIG_SOC_CLK_TREE_SUPPORTED=y +# default: CONFIG_SOC_MPU_SUPPORTED=y +# default: CONFIG_SOC_WDT_SUPPORTED=y +# default: CONFIG_SOC_SPI_FLASH_SUPPORTED=y +# default: CONFIG_SOC_RNG_SUPPORTED=y +# default: CONFIG_SOC_LIGHT_SLEEP_SUPPORTED=y +# default: CONFIG_SOC_DEEP_SLEEP_SUPPORTED=y +# default: CONFIG_SOC_LP_PERIPH_SHARE_INTERRUPT=y +# default: CONFIG_SOC_PM_SUPPORTED=y +# default: CONFIG_SOC_DPORT_WORKAROUND_DIS_INTERRUPT_LVL=5 +# default: CONFIG_SOC_XTAL_SUPPORT_26M=y +# default: CONFIG_SOC_XTAL_SUPPORT_40M=y +# default: CONFIG_SOC_XTAL_SUPPORT_AUTO_DETECT=y +# default: CONFIG_SOC_ADC_RTC_CTRL_SUPPORTED=y +# default: CONFIG_SOC_ADC_DIG_CTRL_SUPPORTED=y +# default: CONFIG_SOC_ADC_DMA_SUPPORTED=y +# default: CONFIG_SOC_ADC_PERIPH_NUM=2 +# default: CONFIG_SOC_ADC_MAX_CHANNEL_NUM=10 +# default: CONFIG_SOC_ADC_ATTEN_NUM=4 +# default: CONFIG_SOC_ADC_DIGI_CONTROLLER_NUM=2 +# default: CONFIG_SOC_ADC_PATT_LEN_MAX=16 +# default: CONFIG_SOC_ADC_DIGI_MIN_BITWIDTH=9 +# default: CONFIG_SOC_ADC_DIGI_MAX_BITWIDTH=12 +# default: CONFIG_SOC_ADC_DIGI_RESULT_BYTES=2 +# default: CONFIG_SOC_ADC_DIGI_DATA_BYTES_PER_CONV=4 +# default: CONFIG_SOC_ADC_DIGI_MONITOR_NUM=0 +# default: CONFIG_SOC_ADC_SAMPLE_FREQ_THRES_HIGH=2 +# default: CONFIG_SOC_ADC_SAMPLE_FREQ_THRES_LOW=20 +# default: CONFIG_SOC_ADC_RTC_MIN_BITWIDTH=9 +# default: CONFIG_SOC_ADC_RTC_MAX_BITWIDTH=12 +# default: CONFIG_SOC_ADC_SHARED_POWER=y +# default: CONFIG_SOC_SHARED_IDCACHE_SUPPORTED=y +# default: CONFIG_SOC_IDCACHE_PER_CORE=y +# default: CONFIG_SOC_CPU_CORES_NUM=2 +# default: CONFIG_SOC_CPU_INTR_NUM=32 +# default: CONFIG_SOC_CPU_HAS_FPU=y +# default: CONFIG_SOC_HP_CPU_HAS_MULTIPLE_CORES=y +# default: CONFIG_SOC_CPU_BREAKPOINTS_NUM=2 +# default: CONFIG_SOC_CPU_WATCHPOINTS_NUM=2 +# default: CONFIG_SOC_CPU_WATCHPOINT_MAX_REGION_SIZE=64 +# default: CONFIG_SOC_DAC_CHAN_NUM=2 +# default: CONFIG_SOC_DAC_RESOLUTION=8 +# default: CONFIG_SOC_DAC_DMA_16BIT_ALIGN=y +# default: CONFIG_SOC_GPIO_PORT=1 +# default: CONFIG_SOC_GPIO_PIN_COUNT=40 +# default: CONFIG_SOC_GPIO_VALID_GPIO_MASK=0xFFFFFFFFFF +# default: CONFIG_SOC_GPIO_IN_RANGE_MAX=39 +# default: CONFIG_SOC_GPIO_OUT_RANGE_MAX=33 +# default: CONFIG_SOC_GPIO_VALID_DIGITAL_IO_PAD_MASK=0xEF0FEA +# default: CONFIG_SOC_GPIO_CLOCKOUT_BY_IO_MUX=y +# default: CONFIG_SOC_GPIO_CLOCKOUT_CHANNEL_NUM=3 +# default: CONFIG_SOC_GPIO_SUPPORT_HOLD_IO_IN_DSLP=y +# default: CONFIG_SOC_I2C_NUM=2 +# default: CONFIG_SOC_HP_I2C_NUM=2 +# default: CONFIG_SOC_I2C_FIFO_LEN=32 +# default: CONFIG_SOC_I2C_CMD_REG_NUM=16 +# default: CONFIG_SOC_I2C_SUPPORT_SLAVE=y +# default: CONFIG_SOC_I2C_SUPPORT_APB=y +# default: CONFIG_SOC_I2C_SUPPORT_10BIT_ADDR=y +# default: CONFIG_SOC_I2C_STOP_INDEPENDENT=y +# default: CONFIG_SOC_I2S_NUM=2 +# default: CONFIG_SOC_I2S_HW_VERSION_1=y +# default: CONFIG_SOC_I2S_SUPPORTS_APLL=y +# default: CONFIG_SOC_I2S_SUPPORTS_PLL_F160M=y +# default: CONFIG_SOC_I2S_SUPPORTS_PDM=y +# default: CONFIG_SOC_I2S_SUPPORTS_PDM_TX=y +# default: CONFIG_SOC_I2S_PDM_MAX_TX_LINES=1 +# default: CONFIG_SOC_I2S_SUPPORTS_PDM_RX=y +# default: CONFIG_SOC_I2S_PDM_MAX_RX_LINES=1 +# default: CONFIG_SOC_I2S_SUPPORTS_ADC_DAC=y +# default: CONFIG_SOC_I2S_SUPPORTS_ADC=y +# default: CONFIG_SOC_I2S_SUPPORTS_DAC=y +# default: CONFIG_SOC_I2S_SUPPORTS_LCD_CAMERA=y +# default: CONFIG_SOC_I2S_MAX_DATA_WIDTH=24 +# default: CONFIG_SOC_I2S_TRANS_SIZE_ALIGN_WORD=y +# default: CONFIG_SOC_I2S_LCD_I80_VARIANT=y +# default: CONFIG_SOC_LCD_I80_SUPPORTED=y +# default: CONFIG_SOC_LCD_I80_BUSES=2 +# default: CONFIG_SOC_LCD_I80_BUS_WIDTH=24 +# default: CONFIG_SOC_LEDC_HAS_TIMER_SPECIFIC_MUX=y +# default: CONFIG_SOC_LEDC_SUPPORT_APB_CLOCK=y +# default: CONFIG_SOC_LEDC_SUPPORT_REF_TICK=y +# default: CONFIG_SOC_LEDC_SUPPORT_HS_MODE=y +# default: CONFIG_SOC_LEDC_TIMER_NUM=4 +# default: CONFIG_SOC_LEDC_CHANNEL_NUM=8 +# default: CONFIG_SOC_LEDC_TIMER_BIT_WIDTH=20 +# default: CONFIG_SOC_MCPWM_GROUPS=2 +# default: CONFIG_SOC_MCPWM_TIMERS_PER_GROUP=3 +# default: CONFIG_SOC_MCPWM_OPERATORS_PER_GROUP=3 +# default: CONFIG_SOC_MCPWM_COMPARATORS_PER_OPERATOR=2 +# default: CONFIG_SOC_MCPWM_GENERATORS_PER_OPERATOR=2 +# default: CONFIG_SOC_MCPWM_TRIGGERS_PER_OPERATOR=2 +# default: CONFIG_SOC_MCPWM_GPIO_FAULTS_PER_GROUP=3 +# default: CONFIG_SOC_MCPWM_CAPTURE_TIMERS_PER_GROUP=y +# default: CONFIG_SOC_MCPWM_CAPTURE_CHANNELS_PER_TIMER=3 +# default: CONFIG_SOC_MCPWM_GPIO_SYNCHROS_PER_GROUP=3 +# default: CONFIG_SOC_MMU_PERIPH_NUM=2 +# default: CONFIG_SOC_MMU_LINEAR_ADDRESS_REGION_NUM=3 +# default: CONFIG_SOC_MPU_MIN_REGION_SIZE=0x20000000 +# default: CONFIG_SOC_MPU_REGIONS_MAX_NUM=8 +# default: CONFIG_SOC_PCNT_GROUPS=1 +# default: CONFIG_SOC_PCNT_UNITS_PER_GROUP=8 +# default: CONFIG_SOC_PCNT_CHANNELS_PER_UNIT=2 +# default: CONFIG_SOC_PCNT_THRES_POINT_PER_UNIT=2 +# default: CONFIG_SOC_RMT_GROUPS=1 +# default: CONFIG_SOC_RMT_TX_CANDIDATES_PER_GROUP=8 +# default: CONFIG_SOC_RMT_RX_CANDIDATES_PER_GROUP=8 +# default: CONFIG_SOC_RMT_CHANNELS_PER_GROUP=8 +# default: CONFIG_SOC_RMT_MEM_WORDS_PER_CHANNEL=64 +# default: CONFIG_SOC_RMT_SUPPORT_REF_TICK=y +# default: CONFIG_SOC_RMT_SUPPORT_APB=y +# default: CONFIG_SOC_RMT_CHANNEL_CLK_INDEPENDENT=y +# default: CONFIG_SOC_RTCIO_PIN_COUNT=18 +# default: CONFIG_SOC_RTCIO_INPUT_OUTPUT_SUPPORTED=y +# default: CONFIG_SOC_RTCIO_HOLD_SUPPORTED=y +# default: CONFIG_SOC_RTCIO_WAKE_SUPPORTED=y +# default: CONFIG_SOC_SDM_GROUPS=1 +# default: CONFIG_SOC_SDM_CHANNELS_PER_GROUP=8 +# default: CONFIG_SOC_SDM_CLK_SUPPORT_APB=y +# default: CONFIG_SOC_SPI_HD_BOTH_INOUT_SUPPORTED=y +# default: CONFIG_SOC_SPI_AS_CS_SUPPORTED=y +# default: CONFIG_SOC_SPI_PERIPH_NUM=3 +# default: CONFIG_SOC_SPI_DMA_CHAN_NUM=2 +# default: CONFIG_SOC_SPI_MAX_CS_NUM=3 +# default: CONFIG_SOC_SPI_SUPPORT_CLK_APB=y +# default: CONFIG_SOC_SPI_MAXIMUM_BUFFER_SIZE=64 +# default: CONFIG_SOC_SPI_MAX_PRE_DIVIDER=8192 +# default: CONFIG_SOC_MEMSPI_SRC_FREQ_80M_SUPPORTED=y +# default: CONFIG_SOC_MEMSPI_SRC_FREQ_40M_SUPPORTED=y +# default: CONFIG_SOC_MEMSPI_SRC_FREQ_26M_SUPPORTED=y +# default: CONFIG_SOC_MEMSPI_SRC_FREQ_20M_SUPPORTED=y +# default: CONFIG_SOC_TIMER_GROUPS=2 +# default: CONFIG_SOC_TIMER_GROUP_TIMERS_PER_GROUP=2 +# default: CONFIG_SOC_TIMER_GROUP_COUNTER_BIT_WIDTH=64 +# default: CONFIG_SOC_TIMER_GROUP_TOTAL_TIMERS=4 +# default: CONFIG_SOC_TIMER_GROUP_SUPPORT_APB=y +# default: CONFIG_SOC_LP_TIMER_BIT_WIDTH_LO=32 +# default: CONFIG_SOC_LP_TIMER_BIT_WIDTH_HI=16 +# default: CONFIG_SOC_TOUCH_SENSOR_VERSION=1 +# default: CONFIG_SOC_TOUCH_SENSOR_NUM=10 +# default: CONFIG_SOC_TOUCH_SAMPLE_CFG_NUM=1 +# default: CONFIG_SOC_TWAI_CONTROLLER_NUM=1 +# default: CONFIG_SOC_TWAI_BRP_MIN=2 +# default: CONFIG_SOC_TWAI_CLK_SUPPORT_APB=y +# default: CONFIG_SOC_TWAI_SUPPORT_MULTI_ADDRESS_LAYOUT=y +# default: CONFIG_SOC_UART_NUM=3 +# default: CONFIG_SOC_UART_HP_NUM=3 +# default: CONFIG_SOC_UART_SUPPORT_APB_CLK=y +# default: CONFIG_SOC_UART_SUPPORT_REF_TICK=y +# default: CONFIG_SOC_UART_FIFO_LEN=128 +# default: CONFIG_SOC_UART_BITRATE_MAX=5000000 +# default: CONFIG_SOC_SPIRAM_SUPPORTED=y +# default: CONFIG_SOC_SPI_MEM_SUPPORT_CONFIG_GPIO_BY_EFUSE=y +# default: CONFIG_SOC_SHA_SUPPORT_PARALLEL_ENG=y +# default: CONFIG_SOC_SHA_ENDIANNESS_BE=y +# default: CONFIG_SOC_SHA_SUPPORT_SHA1=y +# default: CONFIG_SOC_SHA_SUPPORT_SHA256=y +# default: CONFIG_SOC_SHA_SUPPORT_SHA384=y +# default: CONFIG_SOC_SHA_SUPPORT_SHA512=y +# default: CONFIG_SOC_MPI_MEM_BLOCKS_NUM=4 +# default: CONFIG_SOC_MPI_OPERATIONS_NUM=y +# default: CONFIG_SOC_RSA_MAX_BIT_LEN=4096 +# default: CONFIG_SOC_AES_SUPPORT_AES_128=y +# default: CONFIG_SOC_AES_SUPPORT_AES_192=y +# default: CONFIG_SOC_AES_SUPPORT_AES_256=y +# default: CONFIG_SOC_SECURE_BOOT_V1=y +# default: CONFIG_SOC_EFUSE_SECURE_BOOT_KEY_DIGESTS=y +# default: CONFIG_SOC_FLASH_ENCRYPTED_XTS_AES_BLOCK_MAX=32 +# default: CONFIG_SOC_PHY_DIG_REGS_MEM_SIZE=21 +# default: CONFIG_SOC_PM_SUPPORT_EXT0_WAKEUP=y +# default: CONFIG_SOC_PM_SUPPORT_EXT1_WAKEUP=y +# default: CONFIG_SOC_PM_SUPPORT_EXT_WAKEUP=y +# default: CONFIG_SOC_PM_SUPPORT_TOUCH_SENSOR_WAKEUP=y +# default: CONFIG_SOC_PM_SUPPORT_RTC_PERIPH_PD=y +# default: CONFIG_SOC_PM_SUPPORT_RTC_FAST_MEM_PD=y +# default: CONFIG_SOC_PM_SUPPORT_RTC_SLOW_MEM_PD=y +# default: CONFIG_SOC_PM_SUPPORT_RC_FAST_PD=y +# default: CONFIG_SOC_PM_SUPPORT_VDDSDIO_PD=y +# default: CONFIG_SOC_PM_SUPPORT_MODEM_PD=y +# default: CONFIG_SOC_CONFIGURABLE_VDDSDIO_SUPPORTED=y +# default: CONFIG_SOC_PM_MODEM_PD_BY_SW=y +# default: CONFIG_SOC_CLK_APLL_SUPPORTED=y +# default: CONFIG_SOC_CLK_RC_FAST_D256_SUPPORTED=y +# default: CONFIG_SOC_RTC_SLOW_CLK_SUPPORT_RC_FAST_D256=y +# default: CONFIG_SOC_CLK_RC_FAST_SUPPORT_CALIBRATION=y +# default: CONFIG_SOC_CLK_XTAL32K_SUPPORTED=y +# default: CONFIG_SOC_SDMMC_USE_IOMUX=y +# default: CONFIG_SOC_SDMMC_NUM_SLOTS=2 +# default: CONFIG_SOC_WIFI_WAPI_SUPPORT=y +# default: CONFIG_SOC_WIFI_CSI_SUPPORT=y +# default: CONFIG_SOC_WIFI_MESH_SUPPORT=y +# default: CONFIG_SOC_WIFI_SUPPORT_VARIABLE_BEACON_WINDOW=y +# default: CONFIG_SOC_WIFI_NAN_SUPPORT=y +# default: CONFIG_SOC_BLE_SUPPORTED=y +# default: CONFIG_SOC_BLE_MESH_SUPPORTED=y +# default: CONFIG_SOC_BT_CLASSIC_SUPPORTED=y +# default: CONFIG_SOC_BLUFI_SUPPORTED=y +# default: CONFIG_SOC_BT_H2C_ENC_KEY_CTRL_ENH_VSC_SUPPORTED=y +# default: CONFIG_SOC_ULP_HAS_ADC=y +# default: CONFIG_SOC_PHY_COMBO_MODULE=y +# default: CONFIG_SOC_EMAC_RMII_CLK_OUT_INTERNAL_LOOPBACK=y +# default: CONFIG_IDF_CMAKE=y +# default: CONFIG_IDF_TOOLCHAIN="gcc" +# default: CONFIG_IDF_TOOLCHAIN_GCC=y +# default: CONFIG_IDF_TARGET_ARCH_XTENSA=y +# default: CONFIG_IDF_TARGET_ARCH="xtensa" +# default: CONFIG_IDF_TARGET="esp32" +# default: CONFIG_IDF_INIT_VERSION="5.4.1" +# default: CONFIG_IDF_TARGET_ESP32=y +# default: CONFIG_IDF_FIRMWARE_CHIP_ID=0x0000 # @@ -256,8 +504,11 @@ CONFIG_IDF_FIRMWARE_CHIP_ID=0x0000 # CONFIG_APP_BUILD_TYPE_APP_2NDBOOT=y # CONFIG_APP_BUILD_TYPE_RAM is not set +# default: CONFIG_APP_BUILD_GENERATE_BINARIES=y +# default: CONFIG_APP_BUILD_BOOTLOADER=y +# default: CONFIG_APP_BUILD_USE_FLASH_SECTIONS=y # default: # CONFIG_APP_REPRODUCIBLE_BUILD is not set @@ -280,6 +531,7 @@ CONFIG_BOOTLOADER_COMPILE_TIME_DATE=y CONFIG_BOOTLOADER_PROJECT_VER=1 # end of Bootloader manager +# default: CONFIG_BOOTLOADER_OFFSET_IN_FLASH=0x1000 CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y # CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_DEBUG is not set @@ -295,6 +547,7 @@ CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y CONFIG_BOOTLOADER_LOG_LEVEL_INFO=y # CONFIG_BOOTLOADER_LOG_LEVEL_DEBUG is not set # CONFIG_BOOTLOADER_LOG_LEVEL_VERBOSE is not set +# default: CONFIG_BOOTLOADER_LOG_LEVEL=3 # @@ -333,6 +586,7 @@ CONFIG_BOOTLOADER_WDT_TIME_MS=9000 # CONFIG_BOOTLOADER_SKIP_VALIDATE_ON_POWER_ON is not set # default: # CONFIG_BOOTLOADER_SKIP_VALIDATE_ALWAYS is not set +# default: CONFIG_BOOTLOADER_RESERVE_RTC_SIZE=0 # default: # CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC is not set @@ -341,6 +595,7 @@ CONFIG_BOOTLOADER_RESERVE_RTC_SIZE=0 # # Security features # +# default: CONFIG_SECURE_BOOT_V1_SUPPORTED=y # default: # CONFIG_SECURE_SIGNED_APPS_NO_SECURE_BOOT is not set @@ -363,19 +618,33 @@ CONFIG_APP_COMPILE_TIME_DATE=y CONFIG_APP_RETRIEVE_LEN_ELF_SHA=9 # end of Application manager +# default: CONFIG_ESP_ROM_HAS_CRC_LE=y +# default: CONFIG_ESP_ROM_HAS_CRC_BE=y +# default: CONFIG_ESP_ROM_HAS_MZ_CRC32=y +# default: CONFIG_ESP_ROM_HAS_JPEG_DECODE=y +# default: CONFIG_ESP_ROM_HAS_UART_BUF_SWITCH=y +# default: CONFIG_ESP_ROM_NEEDS_SWSETUP_WORKAROUND=y +# default: CONFIG_ESP_ROM_HAS_NEWLIB=y +# default: CONFIG_ESP_ROM_HAS_NEWLIB_NANO_FORMAT=y +# default: CONFIG_ESP_ROM_HAS_NEWLIB_32BIT_TIME=y +# default: CONFIG_ESP_ROM_HAS_SW_FLOAT=y +# default: CONFIG_ESP_ROM_USB_OTG_NUM=-1 +# default: CONFIG_ESP_ROM_USB_SERIAL_DEVICE_NUM=-1 +# default: CONFIG_ESP_ROM_SUPPORT_DEEP_SLEEP_WAKEUP_STUB=y +# default: CONFIG_ESP_ROM_HAS_OUTPUT_PUTC_FUNC=y # @@ -388,11 +657,13 @@ CONFIG_ESP_ROM_HAS_OUTPUT_PUTC_FUNC=y CONFIG_ESPTOOLPY_FLASHMODE_DIO=y # CONFIG_ESPTOOLPY_FLASHMODE_DOUT is not set CONFIG_ESPTOOLPY_FLASH_SAMPLE_MODE_STR=y +# default: CONFIG_ESPTOOLPY_FLASHMODE="dio" # CONFIG_ESPTOOLPY_FLASHFREQ_80M is not set CONFIG_ESPTOOLPY_FLASHFREQ_40M=y # CONFIG_ESPTOOLPY_FLASHFREQ_26M is not set # CONFIG_ESPTOOLPY_FLASHFREQ_20M is not set +# default: CONFIG_ESPTOOLPY_FLASHFREQ="40m" # CONFIG_ESPTOOLPY_FLASHSIZE_1MB is not set CONFIG_ESPTOOLPY_FLASHSIZE_2MB=y @@ -402,15 +673,19 @@ CONFIG_ESPTOOLPY_FLASHSIZE_2MB=y # CONFIG_ESPTOOLPY_FLASHSIZE_32MB is not set # CONFIG_ESPTOOLPY_FLASHSIZE_64MB is not set # CONFIG_ESPTOOLPY_FLASHSIZE_128MB is not set +# default: CONFIG_ESPTOOLPY_FLASHSIZE="2MB" # default: # CONFIG_ESPTOOLPY_HEADER_FLASHSIZE_UPDATE is not set CONFIG_ESPTOOLPY_BEFORE_RESET=y # CONFIG_ESPTOOLPY_BEFORE_NORESET is not set +# default: CONFIG_ESPTOOLPY_BEFORE="default_reset" CONFIG_ESPTOOLPY_AFTER_RESET=y # CONFIG_ESPTOOLPY_AFTER_NORESET is not set +# default: CONFIG_ESPTOOLPY_AFTER="hard_reset" +# default: CONFIG_ESPTOOLPY_MONITOR_BAUD=115200 # end of Serial flasher config @@ -423,6 +698,7 @@ CONFIG_PARTITION_TABLE_SINGLE_APP=y # CONFIG_PARTITION_TABLE_TWO_OTA_LARGE is not set # CONFIG_PARTITION_TABLE_CUSTOM is not set CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" +# default: CONFIG_PARTITION_TABLE_FILENAME="partitions_singleapp.csv" CONFIG_PARTITION_TABLE_OFFSET=0x8000 CONFIG_PARTITION_TABLE_MD5=y @@ -432,27 +708,31 @@ CONFIG_PARTITION_TABLE_MD5=y # Arduino Configuration # CONFIG_ARDUINO_VARIANT="esp32" -CONFIG_ENABLE_ARDUINO_DEPENDS=y # default: +CONFIG_ENABLE_ARDUINO_DEPENDS=y # CONFIG_AUTOSTART_ARDUINO is not set # CONFIG_ARDUINO_RUN_CORE0 is not set CONFIG_ARDUINO_RUN_CORE1=y # CONFIG_ARDUINO_RUN_NO_AFFINITY is not set +# default: CONFIG_ARDUINO_RUNNING_CORE=1 CONFIG_ARDUINO_LOOP_STACK_SIZE=8192 # CONFIG_ARDUINO_EVENT_RUN_CORE0 is not set CONFIG_ARDUINO_EVENT_RUN_CORE1=y # CONFIG_ARDUINO_EVENT_RUN_NO_AFFINITY is not set +# default: CONFIG_ARDUINO_EVENT_RUNNING_CORE=1 # CONFIG_ARDUINO_SERIAL_EVENT_RUN_CORE0 is not set # CONFIG_ARDUINO_SERIAL_EVENT_RUN_CORE1 is not set CONFIG_ARDUINO_SERIAL_EVENT_RUN_NO_AFFINITY=y +# default: CONFIG_ARDUINO_SERIAL_EVENT_TASK_RUNNING_CORE=-1 CONFIG_ARDUINO_SERIAL_EVENT_TASK_STACK_SIZE=2048 CONFIG_ARDUINO_SERIAL_EVENT_TASK_PRIORITY=24 CONFIG_ARDUINO_UDP_RUN_CORE0=y # CONFIG_ARDUINO_UDP_RUN_CORE1 is not set # CONFIG_ARDUINO_UDP_RUN_NO_AFFINITY is not set +# default: CONFIG_ARDUINO_UDP_RUNNING_CORE=0 CONFIG_ARDUINO_UDP_TASK_PRIORITY=3 # default: @@ -469,6 +749,7 @@ CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL_NONE=y # CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL_INFO is not set # CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL_DEBUG is not set # CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL_VERBOSE is not set +# default: CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL=0 # default: # CONFIG_ARDUHAL_LOG_COLORS is not set @@ -481,6 +762,7 @@ CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL=0 # CONFIG_ARDUHAL_PARTITION_SCHEME_NO_OTA is not set # CONFIG_ARDUHAL_PARTITION_SCHEME_HUGE_APP is not set CONFIG_ARDUHAL_PARTITION_SCHEME_MIN_SPIFFS=y +# default: CONFIG_ARDUHAL_PARTITION_SCHEME="min_spiffs" CONFIG_ARDUINO_SELECTIVE_COMPILATION=y CONFIG_ARDUINO_SELECTIVE_SPI=y @@ -548,6 +830,7 @@ CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE=y # CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE is not set CONFIG_COMPILER_ASSERT_NDEBUG_EVALUATE=y CONFIG_COMPILER_FLOAT_LIB_FROM_GCCLIB=y +# default: CONFIG_COMPILER_OPTIMIZATION_ASSERTION_LEVEL=2 # default: # CONFIG_COMPILER_OPTIMIZATION_CHECKS_SILENT is not set @@ -574,6 +857,7 @@ CONFIG_COMPILER_DISABLE_DEFAULT_ERRORS=y # default: # CONFIG_COMPILER_DUMP_RTL_FILES is not set CONFIG_COMPILER_RT_LIB_GCCLIB=y +# default: CONFIG_COMPILER_RT_LIB_NAME="gcc" CONFIG_COMPILER_ORPHAN_SECTIONS_WARNING=y # CONFIG_COMPILER_ORPHAN_SECTIONS_PLACE is not set @@ -594,6 +878,7 @@ CONFIG_APPTRACE_DEST_NONE=y # CONFIG_APPTRACE_DEST_UART2 is not set CONFIG_APPTRACE_DEST_UART_NONE=y CONFIG_APPTRACE_UART_TASK_PRIO=1 +# default: CONFIG_APPTRACE_LOCK_ENABLE=y # end of Application Level Tracing @@ -617,6 +902,7 @@ CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_INTERNAL=y # CONFIG_BT_NIMBLE_LOG_LEVEL_WARNING is not set CONFIG_BT_NIMBLE_LOG_LEVEL_INFO=y # CONFIG_BT_NIMBLE_LOG_LEVEL_DEBUG is not set +# default: CONFIG_BT_NIMBLE_LOG_LEVEL=1 CONFIG_BT_NIMBLE_MAX_CONNECTIONS=7 CONFIG_BT_NIMBLE_MAX_BONDS=1 @@ -624,6 +910,7 @@ CONFIG_BT_NIMBLE_MAX_CCCDS=1 CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM=0 CONFIG_BT_NIMBLE_PINNED_TO_CORE_0=y # CONFIG_BT_NIMBLE_PINNED_TO_CORE_1 is not set +# default: CONFIG_BT_NIMBLE_PINNED_TO_CORE=0 CONFIG_BT_NIMBLE_HOST_TASK_STACK_SIZE=4096 CONFIG_BT_NIMBLE_ROLE_CENTRAL=y @@ -680,6 +967,7 @@ CONFIG_BT_NIMBLE_WHITELIST_SIZE=1 # default: # CONFIG_BT_NIMBLE_BLUFI_ENABLE is not set CONFIG_BT_NIMBLE_USE_ESP_TIMER=y +# default: CONFIG_BT_NIMBLE_LEGACY_VHCI_ENABLE=y # default: # CONFIG_BT_NIMBLE_BLE_GATT_BLOB_TRANSFER is not set @@ -695,13 +983,18 @@ CONFIG_BT_NIMBLE_LEGACY_VHCI_ENABLE=y # CONFIG_BT_NIMBLE_SVC_GAP_APPEAR_WRITE is not set # end of GAP Appearance write permissions +# default: CONFIG_BT_NIMBLE_SVC_GAP_APPEAR_WRITE_PERM=0 +# default: CONFIG_BT_NIMBLE_SVC_GAP_APPEAR_WRITE_PERM_ENC=0 +# default: CONFIG_BT_NIMBLE_SVC_GAP_APPEAR_WRITE_PERM_ATHN=0 +# default: CONFIG_BT_NIMBLE_SVC_GAP_APPEAR_WRITE_PERM_ATHR=0 CONFIG_BT_NIMBLE_SVC_GAP_CAR_CHAR_NOT_SUPP=y # CONFIG_BT_NIMBLE_SVC_GAP_CAR_NOT_SUPP is not set # CONFIG_BT_NIMBLE_SVC_GAP_CAR_SUPP is not set +# default: CONFIG_BT_NIMBLE_SVC_GAP_CENT_ADDR_RESOLUTION=-1 # @@ -711,9 +1004,13 @@ CONFIG_BT_NIMBLE_SVC_GAP_CENT_ADDR_RESOLUTION=-1 # CONFIG_BT_NIMBLE_SVC_GAP_NAME_WRITE is not set # end of GAP device name write permissions +# default: CONFIG_BT_NIMBLE_SVC_GAP_NAME_WRITE_PERM=0 +# default: CONFIG_BT_NIMBLE_SVC_GAP_NAME_WRITE_PERM_ENC=0 +# default: CONFIG_BT_NIMBLE_SVC_GAP_NAME_WRITE_PERM_AUTHEN=0 +# default: CONFIG_BT_NIMBLE_SVC_GAP_NAME_WRITE_PERM_AUTHOR=0 CONFIG_BT_NIMBLE_SVC_GAP_PPCP_MAX_CONN_INTERVAL=0 CONFIG_BT_NIMBLE_SVC_GAP_PPCP_MIN_CONN_INTERVAL=0 @@ -769,6 +1066,7 @@ CONFIG_BT_NIMBLE_SVC_GAP_PPCP_SUPERVISION_TMO=0 # CONFIG_UART_HW_FLOWCTRL_DISABLE=y # CONFIG_UART_HW_FLOWCTRL_CTS_RTS is not set +# default: CONFIG_BT_NIMBLE_HCI_UART_FLOW_CTRL=0 CONFIG_BT_NIMBLE_HCI_UART_RTS_PIN=19 CONFIG_BT_NIMBLE_HCI_UART_CTS_PIN=23 @@ -786,16 +1084,25 @@ CONFIG_BTDM_CTRL_MODE_BLE_ONLY=y # CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY is not set # CONFIG_BTDM_CTRL_MODE_BTDM is not set CONFIG_BTDM_CTRL_BLE_MAX_CONN=7 +# default: CONFIG_BTDM_CTRL_BR_EDR_SCO_DATA_PATH_EFF=0 +# default: CONFIG_BTDM_CTRL_PCM_ROLE_EFF=0 +# default: CONFIG_BTDM_CTRL_PCM_POLAR_EFF=0 +# default: CONFIG_BTDM_CTRL_PCM_FSYNCSHP_EFF=0 +# default: CONFIG_BTDM_CTRL_BLE_MAX_CONN_EFF=7 +# default: CONFIG_BTDM_CTRL_BR_EDR_MIN_ENC_KEY_SZ_DFT_EFF=0 +# default: CONFIG_BTDM_CTRL_BR_EDR_MAX_ACL_CONN_EFF=0 +# default: CONFIG_BTDM_CTRL_BR_EDR_MAX_SYNC_CONN_EFF=0 CONFIG_BTDM_CTRL_PINNED_TO_CORE_0=y # CONFIG_BTDM_CTRL_PINNED_TO_CORE_1 is not set +# default: CONFIG_BTDM_CTRL_PINNED_TO_CORE=0 CONFIG_BTDM_CTRL_HCI_MODE_VHCI=y # CONFIG_BTDM_CTRL_HCI_MODE_UART_H4 is not set @@ -810,11 +1117,13 @@ CONFIG_BTDM_CTRL_LPCLK_SEL_MAIN_XTAL=y # end of MODEM SLEEP Options CONFIG_BTDM_BLE_DEFAULT_SCA_250PPM=y +# default: CONFIG_BTDM_BLE_SLEEP_CLOCK_ACCURACY_INDEX_EFF=1 CONFIG_BTDM_BLE_SCAN_DUPL=y CONFIG_BTDM_SCAN_DUPL_TYPE_DEVICE=y # CONFIG_BTDM_SCAN_DUPL_TYPE_DATA is not set # CONFIG_BTDM_SCAN_DUPL_TYPE_DATA_DEVICE is not set +# default: CONFIG_BTDM_SCAN_DUPL_TYPE=0 CONFIG_BTDM_SCAN_DUPL_CACHE_SIZE=100 CONFIG_BTDM_SCAN_DUPL_CACHE_REFRESH_PERIOD=0 @@ -842,6 +1151,7 @@ CONFIG_BTDM_BLE_CHAN_ASS_EN=y CONFIG_BTDM_BLE_PING_EN=y # default: # CONFIG_BTDM_CTRL_CONTROLLER_DEBUG_MODE_1 is not set +# default: CONFIG_BTDM_RESERVE_DRAM=0xdb5c CONFIG_BTDM_CTRL_HLI=y # end of Controller Options @@ -978,6 +1288,7 @@ CONFIG_ADC_CAL_LUT_ENABLE=y # CONFIG_EFUSE_CODE_SCHEME_COMPAT_NONE is not set CONFIG_EFUSE_CODE_SCHEME_COMPAT_3_4=y # CONFIG_EFUSE_CODE_SCHEME_COMPAT_REPEAT is not set +# default: CONFIG_EFUSE_MAX_BLK_LEN=192 # end of eFuse Bit Manager @@ -1025,6 +1336,7 @@ CONFIG_ADC_DISABLE_DAC_OUTPUT=y # # Wireless Coexistence # +# default: CONFIG_ESP_COEX_ENABLED=y CONFIG_ESP_COEX_SW_COEXIST_ENABLE=y # default: @@ -1193,6 +1505,7 @@ CONFIG_ESP_EVENT_POST_FROM_IRAM_ISR=y # # GDB Stub # +# default: CONFIG_ESP_GDBSTUB_ENABLED=y # default: # CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME is not set @@ -1267,16 +1580,22 @@ CONFIG_ESP32_REV_MIN_0=y # CONFIG_ESP32_REV_MIN_2 is not set # CONFIG_ESP32_REV_MIN_3 is not set # CONFIG_ESP32_REV_MIN_3_1 is not set +# default: CONFIG_ESP32_REV_MIN=0 +# default: CONFIG_ESP32_REV_MIN_FULL=0 +# default: CONFIG_ESP_REV_MIN_FULL=0 # # Maximum Supported ESP32 Revision (Rev v3.99) # +# default: CONFIG_ESP32_REV_MAX_FULL=399 +# default: CONFIG_ESP_REV_MAX_FULL=399 CONFIG_ESP_EFUSE_BLOCK_REV_MIN_FULL=0 +# default: CONFIG_ESP_EFUSE_BLOCK_REV_MAX_FULL=99 # @@ -1287,14 +1606,21 @@ CONFIG_ESP_EFUSE_BLOCK_REV_MAX_FULL=99 # # MAC Config # +# default: CONFIG_ESP_MAC_ADDR_UNIVERSE_WIFI_STA=y +# default: CONFIG_ESP_MAC_ADDR_UNIVERSE_WIFI_AP=y +# default: CONFIG_ESP_MAC_ADDR_UNIVERSE_BT=y +# default: CONFIG_ESP_MAC_ADDR_UNIVERSE_ETH=y +# default: CONFIG_ESP_MAC_UNIVERSAL_MAC_ADDRESSES_FOUR=y +# default: CONFIG_ESP_MAC_UNIVERSAL_MAC_ADDRESSES=4 # CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES_TWO is not set CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES_FOUR=y +# default: CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES=4 # default: # CONFIG_ESP_MAC_IGNORE_MAC_CRC_ERROR is not set @@ -1310,6 +1636,7 @@ CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES=4 CONFIG_ESP_SLEEP_FLASH_LEAKAGE_WORKAROUND=y # default: # CONFIG_ESP_SLEEP_MSPI_NEED_ALL_IO_PU is not set +# default: CONFIG_ESP_SLEEP_RTC_BUS_ISO_WORKAROUND=y # default: # CONFIG_ESP_SLEEP_GPIO_RESET_WORKAROUND is not set @@ -1344,9 +1671,11 @@ CONFIG_PERIPH_CTRL_FUNC_IN_IRAM=y # CONFIG_XTAL_FREQ_32 is not set CONFIG_XTAL_FREQ_40=y # CONFIG_XTAL_FREQ_AUTO is not set +# default: CONFIG_XTAL_FREQ=40 # end of Main XTAL Config +# default: CONFIG_ESP_SPI_BUS_LOCK_ISR_FUNCS_IN_IRAM=y # end of Hardware Settings @@ -1370,6 +1699,7 @@ CONFIG_ESP_NETIF_IP_LOST_TIMER_INTERVAL=120 # CONFIG_ESP_NETIF_PROVIDE_CUSTOM_IMPLEMENTATION is not set CONFIG_ESP_NETIF_TCPIP_LWIP=y # CONFIG_ESP_NETIF_LOOPBACK is not set +# default: CONFIG_ESP_NETIF_USES_TCPIP_WITH_BSD_API=y CONFIG_ESP_NETIF_REPORT_DATA_TRAFFIC=y # default: @@ -1390,11 +1720,13 @@ CONFIG_ESP_NETIF_REPORT_DATA_TRAFFIC=y # # PHY # +# default: CONFIG_ESP_PHY_ENABLED=y CONFIG_ESP_PHY_CALIBRATION_AND_DATA_STORAGE=y # default: # CONFIG_ESP_PHY_INIT_DATA_IN_PARTITION is not set CONFIG_ESP_PHY_MAX_WIFI_TX_POWER=20 +# default: CONFIG_ESP_PHY_MAX_TX_POWER=20 # default: # CONFIG_ESP_PHY_REDUCE_TX_POWER is not set @@ -1403,6 +1735,7 @@ CONFIG_ESP_PHY_MAX_TX_POWER=20 CONFIG_ESP_PHY_RF_CAL_PARTIAL=y # CONFIG_ESP_PHY_RF_CAL_NONE is not set # CONFIG_ESP_PHY_RF_CAL_FULL is not set +# default: CONFIG_ESP_PHY_CALIBRATION_MODE=0 # default: # CONFIG_ESP_PHY_PLL_TRACK_DEBUG is not set @@ -1444,6 +1777,7 @@ CONFIG_ESP_PHY_CALIBRATION_MODE=0 # CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_80 is not set CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_160=y # CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240 is not set +# default: CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ=160 # @@ -1465,6 +1799,7 @@ CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ=160 # # default: # CONFIG_ESP32_TRAX is not set +# default: CONFIG_ESP32_TRACEMEM_RESERVE_DRAM=0x0 # end of Trace memory @@ -1485,13 +1820,17 @@ CONFIG_ESP_MAIN_TASK_STACK_SIZE=3584 CONFIG_ESP_MAIN_TASK_AFFINITY_CPU0=y # CONFIG_ESP_MAIN_TASK_AFFINITY_CPU1 is not set # CONFIG_ESP_MAIN_TASK_AFFINITY_NO_AFFINITY is not set +# default: CONFIG_ESP_MAIN_TASK_AFFINITY=0x0 CONFIG_ESP_MINIMAL_SHARED_STACK_SIZE=2048 CONFIG_ESP_CONSOLE_UART_DEFAULT=y # CONFIG_ESP_CONSOLE_UART_CUSTOM is not set # CONFIG_ESP_CONSOLE_NONE is not set +# default: CONFIG_ESP_CONSOLE_UART=y +# default: CONFIG_ESP_CONSOLE_UART_NUM=0 +# default: CONFIG_ESP_CONSOLE_ROM_SERIAL_PORT_NUM=0 CONFIG_ESP_CONSOLE_UART_BAUDRATE=115200 CONFIG_ESP_INT_WDT=y @@ -1523,11 +1862,13 @@ CONFIG_ESP_BROWNOUT_DET_LVL_SEL_0=y # CONFIG_ESP_BROWNOUT_DET_LVL_SEL_5 is not set # CONFIG_ESP_BROWNOUT_DET_LVL_SEL_6 is not set # CONFIG_ESP_BROWNOUT_DET_LVL_SEL_7 is not set +# default: CONFIG_ESP_BROWNOUT_DET_LVL=0 # end of Brownout Detector # default: # CONFIG_ESP32_DISABLE_BASIC_ROM_CONSOLE is not set +# default: CONFIG_ESP_SYSTEM_BROWNOUT_INTR=y # end of ESP System Settings @@ -1536,6 +1877,7 @@ CONFIG_ESP_SYSTEM_BROWNOUT_INTR=y # CONFIG_ESP_IPC_TASK_STACK_SIZE=1024 CONFIG_ESP_IPC_USES_CALLERS_PRIORITY=y +# default: CONFIG_ESP_IPC_ISR_ENABLE=y # end of IPC (Inter-Processor Call) @@ -1544,32 +1886,39 @@ CONFIG_ESP_IPC_ISR_ENABLE=y # # default: # CONFIG_ESP_TIMER_PROFILING is not set +# default: CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER=y +# default: CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER=y CONFIG_ESP_TIMER_TASK_STACK_SIZE=3584 CONFIG_ESP_TIMER_INTERRUPT_LEVEL=1 # default: # CONFIG_ESP_TIMER_SHOW_EXPERIMENTAL is not set +# default: CONFIG_ESP_TIMER_TASK_AFFINITY=0x0 CONFIG_ESP_TIMER_TASK_AFFINITY_CPU0=y CONFIG_ESP_TIMER_ISR_AFFINITY_CPU0=y # default: # CONFIG_ESP_TIMER_SUPPORTS_ISR_DISPATCH_METHOD is not set +# default: CONFIG_ESP_TIMER_IMPL_TG0_LAC=y # end of ESP Timer (High Resolution Timer) # # Wi-Fi # +# default: CONFIG_ESP_WIFI_ENABLED=y CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM=10 CONFIG_ESP_WIFI_DYNAMIC_RX_BUFFER_NUM=32 # CONFIG_ESP_WIFI_STATIC_TX_BUFFER is not set CONFIG_ESP_WIFI_DYNAMIC_TX_BUFFER=y +# default: CONFIG_ESP_WIFI_TX_BUFFER_TYPE=1 CONFIG_ESP_WIFI_DYNAMIC_TX_BUFFER_NUM=32 CONFIG_ESP_WIFI_STATIC_RX_MGMT_BUFFER=y # CONFIG_ESP_WIFI_DYNAMIC_RX_MGMT_BUFFER is not set +# default: CONFIG_ESP_WIFI_DYNAMIC_RX_MGMT_BUF=0 CONFIG_ESP_WIFI_RX_MGMT_BUF_NUM_DEF=5 # default: @@ -1678,6 +2027,7 @@ CONFIG_FATFS_CODEPAGE_437=y # CONFIG_FATFS_CODEPAGE_936 is not set # CONFIG_FATFS_CODEPAGE_949 is not set # CONFIG_FATFS_CODEPAGE_950 is not set +# default: CONFIG_FATFS_CODEPAGE=437 CONFIG_FATFS_FS_LOCK=0 CONFIG_FATFS_TIMEOUT_MS=10000 @@ -1724,6 +2074,7 @@ CONFIG_FREERTOS_TIMER_SERVICE_TASK_NAME="Tmr Svc" # CONFIG_FREERTOS_TIMER_TASK_AFFINITY_CPU0 is not set # CONFIG_FREERTOS_TIMER_TASK_AFFINITY_CPU1 is not set CONFIG_FREERTOS_TIMER_TASK_NO_AFFINITY=y +# default: CONFIG_FREERTOS_TIMER_SERVICE_TASK_CORE_AFFINITY=0x7FFFFFFF CONFIG_FREERTOS_TIMER_TASK_PRIORITY=1 CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=2048 @@ -1755,9 +2106,11 @@ CONFIG_FREERTOS_ISR_STACKSIZE=1536 CONFIG_FREERTOS_INTERRUPT_BACKTRACE=y # default: # CONFIG_FREERTOS_FPU_IN_ISR is not set +# default: CONFIG_FREERTOS_TICK_SUPPORT_CORETIMER=y CONFIG_FREERTOS_CORETIMER_0=y # CONFIG_FREERTOS_CORETIMER_1 is not set +# default: CONFIG_FREERTOS_SYSTICK_USES_CCOUNT=y # default: # CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH is not set @@ -1770,12 +2123,19 @@ CONFIG_FREERTOS_SYSTICK_USES_CCOUNT=y # # end of Extra +# default: CONFIG_FREERTOS_PORT=y +# default: CONFIG_FREERTOS_NO_AFFINITY=0x7FFFFFFF +# default: CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION=y +# default: CONFIG_FREERTOS_DEBUG_OCDAWARE=y +# default: CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT=y +# default: CONFIG_FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH=y +# default: CONFIG_FREERTOS_NUMBER_OF_CORES=2 # end of FreeRTOS @@ -1786,8 +2146,11 @@ CONFIG_HAL_ASSERTION_EQUALS_SYSTEM=y # CONFIG_HAL_ASSERTION_DISABLE is not set # CONFIG_HAL_ASSERTION_SILENT is not set # CONFIG_HAL_ASSERTION_ENABLE is not set +# default: CONFIG_HAL_DEFAULT_ASSERTION_LEVEL=2 +# default: CONFIG_HAL_SPI_MASTER_FUNC_IN_IRAM=y +# default: CONFIG_HAL_SPI_SLAVE_FUNC_IN_IRAM=y # end of Hardware Abstraction Layer (HAL) and Low Level (LL) @@ -1823,6 +2186,7 @@ CONFIG_LOG_DEFAULT_LEVEL_NONE=y # CONFIG_LOG_DEFAULT_LEVEL_INFO is not set # CONFIG_LOG_DEFAULT_LEVEL_DEBUG is not set # CONFIG_LOG_DEFAULT_LEVEL_VERBOSE is not set +# default: CONFIG_LOG_DEFAULT_LEVEL=0 CONFIG_LOG_MAXIMUM_EQUALS_DEFAULT=y # CONFIG_LOG_MAXIMUM_LEVEL_ERROR is not set @@ -1830,6 +2194,7 @@ CONFIG_LOG_MAXIMUM_EQUALS_DEFAULT=y # CONFIG_LOG_MAXIMUM_LEVEL_INFO is not set # CONFIG_LOG_MAXIMUM_LEVEL_DEBUG is not set # CONFIG_LOG_MAXIMUM_LEVEL_VERBOSE is not set +# default: CONFIG_LOG_MAXIMUM_LEVEL=0 # @@ -1991,6 +2356,7 @@ CONFIG_LWIP_TCPIP_TASK_STACK_SIZE=3072 CONFIG_LWIP_TCPIP_TASK_AFFINITY_NO_AFFINITY=y # CONFIG_LWIP_TCPIP_TASK_AFFINITY_CPU0 is not set # CONFIG_LWIP_TCPIP_TASK_AFFINITY_CPU1 is not set +# default: CONFIG_LWIP_TCPIP_TASK_AFFINITY=0x7FFFFFFF CONFIG_LWIP_IPV6_MEMP_NUM_ND6_QUEUE=3 CONFIG_LWIP_IPV6_ND6_NUM_NEIGHBORS=5 @@ -2142,8 +2508,11 @@ CONFIG_MBEDTLS_TLS_SERVER_AND_CLIENT=y # CONFIG_MBEDTLS_TLS_SERVER_ONLY is not set # CONFIG_MBEDTLS_TLS_CLIENT_ONLY is not set # CONFIG_MBEDTLS_TLS_DISABLED is not set +# default: CONFIG_MBEDTLS_TLS_SERVER=y +# default: CONFIG_MBEDTLS_TLS_CLIENT=y +# default: CONFIG_MBEDTLS_TLS_ENABLED=y # @@ -2308,6 +2677,7 @@ CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC_HRT=y CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_0=y CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_1=y CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_2=y +# default: CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_PATCH_VERSION=y # end of Protocomm @@ -2320,6 +2690,7 @@ CONFIG_PTHREAD_STACK_MIN=768 CONFIG_PTHREAD_DEFAULT_CORE_NO_AFFINITY=y # CONFIG_PTHREAD_DEFAULT_CORE_0 is not set # CONFIG_PTHREAD_DEFAULT_CORE_1 is not set +# default: CONFIG_PTHREAD_TASK_CORE_DEFAULT=-1 CONFIG_PTHREAD_TASK_NAME_DEFAULT="pthread" # end of PThreads @@ -2327,8 +2698,11 @@ CONFIG_PTHREAD_TASK_NAME_DEFAULT="pthread" # # MMU Config # +# default: CONFIG_MMU_PAGE_SIZE_64KB=y +# default: CONFIG_MMU_PAGE_MODE="64KB" +# default: CONFIG_MMU_PAGE_SIZE=0x10000 # end of MMU Config @@ -2340,6 +2714,7 @@ CONFIG_MMU_PAGE_SIZE=0x10000 # SPI Flash behavior when brownout # CONFIG_SPI_FLASH_BROWNOUT_RESET_XMC=y +# default: CONFIG_SPI_FLASH_BROWNOUT_RESET=y # end of SPI Flash behavior when brownout @@ -2385,10 +2760,15 @@ CONFIG_SPI_FLASH_WRITE_CHUNK_SIZE=8192 # # Auto-detect flash chips # +# default: CONFIG_SPI_FLASH_VENDOR_XMC_SUPPORTED=y +# default: CONFIG_SPI_FLASH_VENDOR_GD_SUPPORTED=y +# default: CONFIG_SPI_FLASH_VENDOR_ISSI_SUPPORTED=y +# default: CONFIG_SPI_FLASH_VENDOR_MXIC_SUPPORTED=y +# default: CONFIG_SPI_FLASH_VENDOR_WINBOND_SUPPORTED=y CONFIG_SPI_FLASH_SUPPORT_ISSI_CHIP=y CONFIG_SPI_FLASH_SUPPORT_MXIC_CHIP=y @@ -2516,6 +2896,7 @@ CONFIG_VFS_INITIALIZE_DEV_NULL=y # # CONFIG_WL_SECTOR_SIZE_512 is not set CONFIG_WL_SECTOR_SIZE_4096=y +# default: CONFIG_WL_SECTOR_SIZE=4096 # end of Wear Levelling @@ -2578,6 +2959,7 @@ CONFIG_MDNS_TASK_STACK_SIZE=4096 # CONFIG_MDNS_TASK_AFFINITY_NO_AFFINITY is not set CONFIG_MDNS_TASK_AFFINITY_CPU0=y # CONFIG_MDNS_TASK_AFFINITY_CPU1 is not set +# default: CONFIG_MDNS_TASK_AFFINITY=0x0 # @@ -2683,6 +3065,7 @@ CONFIG_LITTLEFS_ASSERTS=y CONFIG_LOG_BOOTLOADER_LEVEL_INFO=y # CONFIG_LOG_BOOTLOADER_LEVEL_DEBUG is not set # CONFIG_LOG_BOOTLOADER_LEVEL_VERBOSE is not set +# default: CONFIG_LOG_BOOTLOADER_LEVEL=3 # default: # CONFIG_APP_ROLLBACK_ENABLE is not set @@ -2692,6 +3075,7 @@ CONFIG_LOG_BOOTLOADER_LEVEL=3 # CONFIG_FLASHMODE_QOUT is not set CONFIG_FLASHMODE_DIO=y # CONFIG_FLASHMODE_DOUT is not set +# default: CONFIG_MONITOR_BAUD=115200 # CONFIG_OPTIMIZATION_LEVEL_DEBUG is not set # CONFIG_COMPILER_OPTIMIZATION_LEVEL_DEBUG is not set @@ -2701,6 +3085,7 @@ CONFIG_COMPILER_OPTIMIZATION_LEVEL_RELEASE=y CONFIG_OPTIMIZATION_ASSERTIONS_ENABLED=y # CONFIG_OPTIMIZATION_ASSERTIONS_SILENT is not set # CONFIG_OPTIMIZATION_ASSERTIONS_DISABLED is not set +# default: CONFIG_OPTIMIZATION_ASSERTION_LEVEL=2 # default: # CONFIG_CXX_EXCEPTIONS is not set @@ -2712,6 +3097,7 @@ CONFIG_STACK_CHECK_NONE=y # CONFIG_WARN_WRITE_STRINGS is not set # CONFIG_ESP32_APPTRACE_DEST_TRAX is not set CONFIG_ESP32_APPTRACE_DEST_NONE=y +# default: CONFIG_ESP32_APPTRACE_LOCK_ENABLE=y # CONFIG_BLUEDROID_ENABLED is not set CONFIG_NIMBLE_ENABLED=y @@ -2723,6 +3109,7 @@ CONFIG_NIMBLE_MAX_CCCDS=1 CONFIG_NIMBLE_L2CAP_COC_MAX_NUM=0 CONFIG_NIMBLE_PINNED_TO_CORE_0=y # CONFIG_NIMBLE_PINNED_TO_CORE_1 is not set +# default: CONFIG_NIMBLE_PINNED_TO_CORE=0 CONFIG_NIMBLE_TASK_STACK_SIZE=4096 CONFIG_BT_NIMBLE_TASK_STACK_SIZE=4096 @@ -2756,9 +3143,13 @@ CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY=y # CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY is not set # CONFIG_BTDM_CONTROLLER_MODE_BTDM is not set CONFIG_BTDM_CONTROLLER_BLE_MAX_CONN=7 +# default: CONFIG_BTDM_CONTROLLER_BLE_MAX_CONN_EFF=7 +# default: CONFIG_BTDM_CONTROLLER_BR_EDR_MAX_ACL_CONN_EFF=0 +# default: CONFIG_BTDM_CONTROLLER_BR_EDR_MAX_SYNC_CONN_EFF=0 +# default: CONFIG_BTDM_CONTROLLER_PINNED_TO_CORE=0 CONFIG_BTDM_CONTROLLER_HCI_MODE_VHCI=y # CONFIG_BTDM_CONTROLLER_HCI_MODE_UART_H4 is not set @@ -2767,6 +3158,7 @@ CONFIG_BLE_SCAN_DUPLICATE=y CONFIG_SCAN_DUPLICATE_BY_DEVICE_ADDR=y # CONFIG_SCAN_DUPLICATE_BY_ADV_DATA is not set # CONFIG_SCAN_DUPLICATE_BY_ADV_DATA_AND_DEVICE_ADDR is not set +# default: CONFIG_SCAN_DUPLICATE_TYPE=0 CONFIG_DUPLICATE_SCAN_CACHE_SIZE=100 # default: @@ -2791,6 +3183,7 @@ CONFIG_GDBSTUB_MAX_TASKS=32 # CONFIG_OTA_ALLOW_HTTP is not set # CONFIG_TWO_UNIVERSAL_MAC_ADDRESS is not set CONFIG_FOUR_UNIVERSAL_MAC_ADDRESS=y +# default: CONFIG_NUMBER_OF_UNIVERSAL_MAC_ADDRESS=4 # default: # CONFIG_ESP_SYSTEM_PD_FLASH is not set @@ -2808,11 +3201,13 @@ CONFIG_ESP32_RTC_CLK_CAL_CYCLES=1024 # CONFIG_ESP32_XTAL_FREQ_26 is not set CONFIG_ESP32_XTAL_FREQ_40=y # CONFIG_ESP32_XTAL_FREQ_AUTO is not set +# default: CONFIG_ESP32_XTAL_FREQ=40 CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE=y # default: # CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION is not set CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER=20 +# default: CONFIG_ESP32_PHY_MAX_TX_POWER=20 # default: # CONFIG_REDUCE_PHY_TX_POWER is not set @@ -2825,7 +3220,9 @@ CONFIG_ESP32_PHY_MAX_TX_POWER=20 # CONFIG_ESP32_DEFAULT_CPU_FREQ_80 is not set CONFIG_ESP32_DEFAULT_CPU_FREQ_160=y # CONFIG_ESP32_DEFAULT_CPU_FREQ_240 is not set +# default: CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ=160 +# default: CONFIG_TRACEMEM_RESERVE_DRAM=0x0 # CONFIG_ESP32_PANIC_PRINT_HALT is not set CONFIG_ESP32_PANIC_PRINT_REBOOT=y @@ -2838,7 +3235,9 @@ CONFIG_CONSOLE_UART_DEFAULT=y # CONFIG_CONSOLE_UART_CUSTOM is not set # CONFIG_CONSOLE_UART_NONE is not set # CONFIG_ESP_CONSOLE_UART_NONE is not set +# default: CONFIG_CONSOLE_UART=y +# default: CONFIG_CONSOLE_UART_NUM=0 CONFIG_CONSOLE_UART_BAUDRATE=115200 CONFIG_INT_WDT=y @@ -2872,17 +3271,21 @@ CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_0=y # CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_6 is not set # CONFIG_BROWNOUT_DET_LVL_SEL_7 is not set # CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_7 is not set +# default: CONFIG_BROWNOUT_DET_LVL=0 +# default: CONFIG_ESP32_BROWNOUT_DET_LVL=0 # default: # CONFIG_DISABLE_BASIC_ROM_CONSOLE is not set CONFIG_IPC_TASK_STACK_SIZE=1024 CONFIG_TIMER_TASK_STACK_SIZE=3584 +# default: CONFIG_ESP32_WIFI_ENABLED=y CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=10 CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=32 # CONFIG_ESP32_WIFI_STATIC_TX_BUFFER is not set CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER=y +# default: CONFIG_ESP32_WIFI_TX_BUFFER_TYPE=1 CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM=32 # default: @@ -2952,6 +3355,7 @@ CONFIG_TCPIP_TASK_STACK_SIZE=3072 CONFIG_TCPIP_TASK_AFFINITY_NO_AFFINITY=y # CONFIG_TCPIP_TASK_AFFINITY_CPU0 is not set # CONFIG_TCPIP_TASK_AFFINITY_CPU1 is not set +# default: CONFIG_TCPIP_TASK_AFFINITY=0x7FFFFFFF # default: # CONFIG_PPP_SUPPORT is not set @@ -2967,6 +3371,7 @@ CONFIG_ESP32_PTHREAD_STACK_MIN=768 CONFIG_ESP32_DEFAULT_PTHREAD_CORE_NO_AFFINITY=y # CONFIG_ESP32_DEFAULT_PTHREAD_CORE_0 is not set # CONFIG_ESP32_DEFAULT_PTHREAD_CORE_1 is not set +# default: CONFIG_ESP32_PTHREAD_TASK_CORE_DEFAULT=-1 CONFIG_ESP32_PTHREAD_TASK_NAME_DEFAULT="pthread" CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ABORTS=y From 627e708c235fe7699542bdf605bd257249737c29 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 16 Sep 2025 23:44:49 +0000 Subject: [PATCH 4/7] Implement Parameter template and convert first 3 parameters Co-authored-by: doudar <17362216+doudar@users.noreply.github.com> --- include/SmartSpin_parameters.h | 44 +++++++++++++++++++++++++++------- src/SmartSpin_parameters.cpp | 12 +++++----- 2 files changed, 41 insertions(+), 15 deletions(-) diff --git a/include/SmartSpin_parameters.h b/include/SmartSpin_parameters.h index cef1dc4e..d2e449d1 100644 --- a/include/SmartSpin_parameters.h +++ b/include/SmartSpin_parameters.h @@ -14,9 +14,35 @@ #endif #include "settings.h" +#include #define CONFIG_LOG_TAG "Config" +// Generic parameter class for simple set/get operations +template +class Parameter { + private: + T value; + + public: + void set(const T& val) { value = val; } + T get() const { return value; } + + // Overload for String types to return const char* + template + typename std::enable_if::value, const char*>::type + getCStr() const { return value.c_str(); } + + Parameter() : value{} {} + Parameter(const T& defaultValue) : value(defaultValue) {} + + // Assignment operator for convenience + Parameter& operator=(const T& val) { value = val; return *this; } + + // Conversion operator for convenience + operator T() const { return value; } +}; + class Measurement { private: bool simulate; @@ -111,8 +137,8 @@ class userParameters { private: String firmwareUpdateURL; String deviceName; - int shiftStep; - bool stealthChop; + Parameter shiftStep; + Parameter stealthChop; float inclineMultiplier; float powerCorrectionFactor; float ERGSensitivity; @@ -127,7 +153,7 @@ class userParameters { bool udpLogEnabled = false; int32_t hMin = INT32_MIN; int32_t hMax = INT32_MIN; - bool FTMSControlPointWrite = false; + Parameter FTMSControlPointWrite; int homingSensitivity = DEFAULT_HOMING_SENSITIVITY; // Use default from settings.h String ssid; String password; @@ -143,14 +169,14 @@ class userParameters { void setDeviceName(String dvn) { deviceName = dvn; } const char* getDeviceName() { return deviceName.c_str(); } - void setShiftStep(int ss) { shiftStep = ss; } - int getShiftStep() { return shiftStep; } + void setShiftStep(int ss) { shiftStep.set(ss); } + int getShiftStep() { return shiftStep.get(); } - void setStealthChop(bool sc) { stealthChop = sc; } - bool getStealthChop() { return stealthChop; } + void setStealthChop(bool sc) { stealthChop.set(sc); } + bool getStealthChop() { return stealthChop.get(); } - void setFTMSControlPointWrite(bool cpw) { FTMSControlPointWrite = cpw; } - bool getFTMSControlPointWrite() { return FTMSControlPointWrite; } + void setFTMSControlPointWrite(bool cpw) { FTMSControlPointWrite.set(cpw); } + bool getFTMSControlPointWrite() { return FTMSControlPointWrite.get(); } void setInclineMultiplier(float im) { inclineMultiplier = im; } float getInclineMultiplier() { return inclineMultiplier; } diff --git a/src/SmartSpin_parameters.cpp b/src/SmartSpin_parameters.cpp index 25fe1c68..0cc4ddc3 100644 --- a/src/SmartSpin_parameters.cpp +++ b/src/SmartSpin_parameters.cpp @@ -48,8 +48,8 @@ JsonDocument doc; void userParameters::setDefaults() { firmwareUpdateURL = FW_UPDATEURL; deviceName = DEVICE_NAME; - shiftStep = DEFAULT_SHIFT_STEP; - stealthChop = STEALTHCHOP; + shiftStep.set(DEFAULT_SHIFT_STEP); + stealthChop.set(STEALTHCHOP); stepperPower = DEFAULT_STEPPER_POWER; stepperSpeed = DEFAULT_STEPPER_SPEED; inclineMultiplier = INCLINE_MULTIPLIER; @@ -85,10 +85,10 @@ String userParameters::returnJSON() { doc["firmwareUpdateURL"] = firmwareUpdateURL; doc["firmwareVersion"] = FIRMWARE_VERSION; doc["deviceName"] = deviceName; - doc["shiftStep"] = shiftStep; + doc["shiftStep"] = shiftStep.get(); doc["stepperPower"] = stepperPower; doc["stepperSpeed"] = stepperSpeed; - doc["stealthChop"] = stealthChop; + doc["stealthChop"] = stealthChop.get(); doc["inclineMultiplier"] = inclineMultiplier; doc["powerCorrectionFactor"] = powerCorrectionFactor; doc["ERGSensitivity"] = ERGSensitivity; @@ -137,10 +137,10 @@ void userParameters::saveToLittleFS() { doc["firmwareUpdateURL"] = firmwareUpdateURL; doc["deviceName"] = deviceName; - doc["shiftStep"] = shiftStep; + doc["shiftStep"] = shiftStep.get(); doc["stepperPower"] = stepperPower; doc["stepperSpeed"] = stepperSpeed; - doc["stealthChop"] = stealthChop; + doc["stealthChop"] = stealthChop.get(); doc["inclineMultiplier"] = inclineMultiplier; doc["powerCorrectionFactor"] = powerCorrectionFactor; doc["ERGSensitivity"] = ERGSensitivity; From 4ff9292916f6c7f0840ae730082cc643c4b03eaf Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 16 Sep 2025 23:55:52 +0000 Subject: [PATCH 5/7] Complete userParameters class refactoring to use Parameter template Co-authored-by: doudar <17362216+doudar@users.noreply.github.com> --- include/SmartSpin_parameters.h | 138 ++++++++++++++++----------------- src/SmartSpin_parameters.cpp | 138 ++++++++++++++++----------------- 2 files changed, 138 insertions(+), 138 deletions(-) diff --git a/include/SmartSpin_parameters.h b/include/SmartSpin_parameters.h index d2e449d1..cd764a7d 100644 --- a/include/SmartSpin_parameters.h +++ b/include/SmartSpin_parameters.h @@ -135,39 +135,39 @@ class RuntimeParameters { class userParameters { private: - String firmwareUpdateURL; - String deviceName; + Parameter firmwareUpdateURL; + Parameter deviceName; Parameter shiftStep; Parameter stealthChop; - float inclineMultiplier; - float powerCorrectionFactor; - float ERGSensitivity; - bool autoUpdate; - int stepperPower; - int maxWatts; - int minWatts; - int stepperSpeed; - bool stepperDir; - bool shifterDir; - bool pTab4Pwr = false; - bool udpLogEnabled = false; - int32_t hMin = INT32_MIN; - int32_t hMax = INT32_MIN; + Parameter inclineMultiplier; + Parameter powerCorrectionFactor; + Parameter ERGSensitivity; + Parameter autoUpdate; + Parameter stepperPower; + Parameter maxWatts; + Parameter minWatts; + Parameter stepperSpeed; + Parameter stepperDir; + Parameter shifterDir; + Parameter pTab4Pwr; + Parameter udpLogEnabled; + Parameter hMin; + Parameter hMax; Parameter FTMSControlPointWrite; - int homingSensitivity = DEFAULT_HOMING_SENSITIVITY; // Use default from settings.h - String ssid; - String password; - String connectedPowerMeter = CONNECTED_POWER_METER; - String connectedHeartMonitor = CONNECTED_HEART_MONITOR; - String connectedRemote = CONNECTED_REMOTE; - String foundDevices = ""; + Parameter homingSensitivity; + Parameter ssid; + Parameter password; + Parameter connectedPowerMeter; + Parameter connectedHeartMonitor; + Parameter connectedRemote; + Parameter foundDevices; public: - void setFirmwareUpdateURL(String fURL) { firmwareUpdateURL = fURL; } - const char* getFirmwareUpdateURL() { return firmwareUpdateURL.c_str(); } + void setFirmwareUpdateURL(String fURL) { firmwareUpdateURL.set(fURL); } + const char* getFirmwareUpdateURL() { return firmwareUpdateURL.getCStr(); } - void setDeviceName(String dvn) { deviceName = dvn; } - const char* getDeviceName() { return deviceName.c_str(); } + void setDeviceName(String dvn) { deviceName.set(dvn); } + const char* getDeviceName() { return deviceName.getCStr(); } void setShiftStep(int ss) { shiftStep.set(ss); } int getShiftStep() { return shiftStep.get(); } @@ -178,68 +178,68 @@ class userParameters { void setFTMSControlPointWrite(bool cpw) { FTMSControlPointWrite.set(cpw); } bool getFTMSControlPointWrite() { return FTMSControlPointWrite.get(); } - void setInclineMultiplier(float im) { inclineMultiplier = im; } - float getInclineMultiplier() { return inclineMultiplier; } + void setInclineMultiplier(float im) { inclineMultiplier.set(im); } + float getInclineMultiplier() { return inclineMultiplier.get(); } - void setPowerCorrectionFactor(float pcf) { powerCorrectionFactor = pcf; } - float getPowerCorrectionFactor() { return powerCorrectionFactor; } + void setPowerCorrectionFactor(float pcf) { powerCorrectionFactor.set(pcf); } + float getPowerCorrectionFactor() { return powerCorrectionFactor.get(); } - float getERGSensitivity() { return ERGSensitivity; } - void setERGSensitivity(float ergS) { ERGSensitivity = ergS; } + float getERGSensitivity() { return ERGSensitivity.get(); } + void setERGSensitivity(float ergS) { ERGSensitivity.set(ergS); } - void setAutoUpdate(bool atd) { autoUpdate = atd; } - bool getAutoUpdate() { return autoUpdate; } + void setAutoUpdate(bool atd) { autoUpdate.set(atd); } + bool getAutoUpdate() { return autoUpdate.get(); } - void setSsid(String sid) { ssid = sid; } - const char* getSsid() { return ssid.c_str(); } + void setSsid(String sid) { ssid.set(sid); } + const char* getSsid() { return ssid.getCStr(); } - void setPassword(String pwd) { password = pwd; } - const char* getPassword() { return password.c_str(); } + void setPassword(String pwd) { password.set(pwd); } + const char* getPassword() { return password.getCStr(); } - void setConnectedPowerMeter(String cpm) { connectedPowerMeter = cpm; } - const char* getConnectedPowerMeter() { return connectedPowerMeter.c_str(); } + void setConnectedPowerMeter(String cpm) { connectedPowerMeter.set(cpm); } + const char* getConnectedPowerMeter() { return connectedPowerMeter.getCStr(); } - void setConnectedHeartMonitor(String cHr) { connectedHeartMonitor = cHr; } - const char* getConnectedHeartMonitor() { return connectedHeartMonitor.c_str(); } + void setConnectedHeartMonitor(String cHr) { connectedHeartMonitor.set(cHr); } + const char* getConnectedHeartMonitor() { return connectedHeartMonitor.getCStr(); } - void setConnectedRemote(String cRemote) { connectedRemote = cRemote; } - const char* getConnectedRemote() { return connectedRemote.c_str(); } + void setConnectedRemote(String cRemote) { connectedRemote.set(cRemote); } + const char* getConnectedRemote() { return connectedRemote.getCStr(); } - void setStepperPower(int sp) { stepperPower = sp; } - int getStepperPower() { return stepperPower; } + void setStepperPower(int sp) { stepperPower.set(sp); } + int getStepperPower() { return stepperPower.get(); } - void setStepperSpeed(int sp) { stepperSpeed = sp; } - int getStepperSpeed() { return stepperSpeed; } + void setStepperSpeed(int sp) { stepperSpeed.set(sp); } + int getStepperSpeed() { return stepperSpeed.get(); } - void setMaxWatts(int maxW) { maxWatts = maxW; } - int getMaxWatts() { return maxWatts; } + void setMaxWatts(int maxW) { maxWatts.set(maxW); } + int getMaxWatts() { return maxWatts.get(); } - void setMinWatts(int minW) { minWatts = minW; } - int getMinWatts() { return minWatts; } + void setMinWatts(int minW) { minWatts.set(minW); } + int getMinWatts() { return minWatts.get(); } - void setStepperDir(bool sd) { stepperDir = sd; } - bool getStepperDir() { return stepperDir; } + void setStepperDir(bool sd) { stepperDir.set(sd); } + bool getStepperDir() { return stepperDir.get(); } - void setShifterDir(bool shd) { shifterDir = shd; } - bool getShifterDir() { return shifterDir; } + void setShifterDir(bool shd) { shifterDir.set(shd); } + bool getShifterDir() { return shifterDir.get(); } - void setUdpLogEnabled(bool enabled) { udpLogEnabled = enabled; } - bool getUdpLogEnabled() { return udpLogEnabled; } + void setUdpLogEnabled(bool enabled) { udpLogEnabled.set(enabled); } + bool getUdpLogEnabled() { return udpLogEnabled.get(); } - void setPTab4Pwr(bool pTab) { pTab4Pwr = pTab; } - bool getPTab4Pwr() { return pTab4Pwr; } + void setPTab4Pwr(bool pTab) { pTab4Pwr.set(pTab); } + bool getPTab4Pwr() { return pTab4Pwr.get(); } - void setFoundDevices(String fdv) { foundDevices = fdv; } - const char* getFoundDevices() { return foundDevices.c_str(); } + void setFoundDevices(String fdv) { foundDevices.set(fdv); } + const char* getFoundDevices() { return foundDevices.getCStr(); } - void setHMin(int32_t min) { hMin = min; } - int32_t getHMin() { return hMin; } + void setHMin(int32_t min) { hMin.set(min); } + int32_t getHMin() { return hMin.get(); } - void setHMax(int32_t max) { hMax = max; } - int32_t getHMax() { return hMax; } + void setHMax(int32_t max) { hMax.set(max); } + int32_t getHMax() { return hMax.get(); } - void setHomingSensitivity(int sensitivity) { homingSensitivity = sensitivity; } - int getHomingSensitivity() { return homingSensitivity; } + void setHomingSensitivity(int sensitivity) { homingSensitivity.set(sensitivity); } + int getHomingSensitivity() { return homingSensitivity.get(); } void setDefaults(); String returnJSON(); diff --git a/src/SmartSpin_parameters.cpp b/src/SmartSpin_parameters.cpp index 0cc4ddc3..c9d868c7 100644 --- a/src/SmartSpin_parameters.cpp +++ b/src/SmartSpin_parameters.cpp @@ -46,31 +46,31 @@ JsonDocument doc; // Default Values void userParameters::setDefaults() { - firmwareUpdateURL = FW_UPDATEURL; - deviceName = DEVICE_NAME; + firmwareUpdateURL.set(FW_UPDATEURL); + deviceName.set(DEVICE_NAME); shiftStep.set(DEFAULT_SHIFT_STEP); stealthChop.set(STEALTHCHOP); - stepperPower = DEFAULT_STEPPER_POWER; - stepperSpeed = DEFAULT_STEPPER_SPEED; - inclineMultiplier = INCLINE_MULTIPLIER; - powerCorrectionFactor = 1.0; - ERGSensitivity = ERG_SENSITIVITY; - autoUpdate = AUTO_FIRMWARE_UPDATE; - ssid = DEVICE_NAME; - password = DEFAULT_PASSWORD; - connectedPowerMeter = CONNECTED_POWER_METER; - connectedHeartMonitor = CONNECTED_HEART_MONITOR; - connectedRemote = CONNECTED_REMOTE; - foundDevices = " "; - maxWatts = DEFAULT_MAX_WATTS; - minWatts = DEFAULT_MIN_WATTS; - stepperDir = true; - shifterDir = true; - udpLogEnabled = false; - pTab4Pwr = false; - hMin = INT32_MIN; - hMax = INT32_MIN; - homingSensitivity = DEFAULT_HOMING_SENSITIVITY; + stepperPower.set(DEFAULT_STEPPER_POWER); + stepperSpeed.set(DEFAULT_STEPPER_SPEED); + inclineMultiplier.set(INCLINE_MULTIPLIER); + powerCorrectionFactor.set(1.0); + ERGSensitivity.set(ERG_SENSITIVITY); + autoUpdate.set(AUTO_FIRMWARE_UPDATE); + ssid.set(DEVICE_NAME); + password.set(DEFAULT_PASSWORD); + connectedPowerMeter.set(CONNECTED_POWER_METER); + connectedHeartMonitor.set(CONNECTED_HEART_MONITOR); + connectedRemote.set(CONNECTED_REMOTE); + foundDevices.set(" "); + maxWatts.set(DEFAULT_MAX_WATTS); + minWatts.set(DEFAULT_MIN_WATTS); + stepperDir.set(true); + shifterDir.set(true); + udpLogEnabled.set(false); + pTab4Pwr.set(false); + hMin.set(INT32_MIN); + hMax.set(INT32_MIN); + homingSensitivity.set(DEFAULT_HOMING_SENSITIVITY); } //--------------------------------------------------------------------------------- @@ -82,32 +82,32 @@ String userParameters::returnJSON() { JsonDocument doc; // Set the values in the document - doc["firmwareUpdateURL"] = firmwareUpdateURL; + doc["firmwareUpdateURL"] = firmwareUpdateURL.get(); doc["firmwareVersion"] = FIRMWARE_VERSION; - doc["deviceName"] = deviceName; + doc["deviceName"] = deviceName.get(); doc["shiftStep"] = shiftStep.get(); - doc["stepperPower"] = stepperPower; - doc["stepperSpeed"] = stepperSpeed; + doc["stepperPower"] = stepperPower.get(); + doc["stepperSpeed"] = stepperSpeed.get(); doc["stealthChop"] = stealthChop.get(); - doc["inclineMultiplier"] = inclineMultiplier; - doc["powerCorrectionFactor"] = powerCorrectionFactor; - doc["ERGSensitivity"] = ERGSensitivity; - doc["autoUpdate"] = autoUpdate; - doc["ssid"] = ssid; - doc["password"] = password; - doc["connectedPowerMeter"] = connectedPowerMeter; - doc["connectedHeartMonitor"] = connectedHeartMonitor; - doc["connectedRemote"] = connectedRemote; - doc["foundDevices"] = foundDevices; - doc["maxWatts"] = maxWatts; - doc["minWatts"] = minWatts; - doc["shifterDir"] = shifterDir; - doc["stepperDir"] = stepperDir; - doc["udpLogEnabled"] = udpLogEnabled; - doc["pTab4Pwr"] = pTab4Pwr; - doc["hMin"] = hMin; - doc["hMax"] = hMax; - doc["homingSensitivity"] = homingSensitivity; + doc["inclineMultiplier"] = inclineMultiplier.get(); + doc["powerCorrectionFactor"] = powerCorrectionFactor.get(); + doc["ERGSensitivity"] = ERGSensitivity.get(); + doc["autoUpdate"] = autoUpdate.get(); + doc["ssid"] = ssid.get(); + doc["password"] = password.get(); + doc["connectedPowerMeter"] = connectedPowerMeter.get(); + doc["connectedHeartMonitor"] = connectedHeartMonitor.get(); + doc["connectedRemote"] = connectedRemote.get(); + doc["foundDevices"] = foundDevices.get(); + doc["maxWatts"] = maxWatts.get(); + doc["minWatts"] = minWatts.get(); + doc["shifterDir"] = shifterDir.get(); + doc["stepperDir"] = stepperDir.get(); + doc["udpLogEnabled"] = udpLogEnabled.get(); + doc["pTab4Pwr"] = pTab4Pwr.get(); + doc["hMin"] = hMin.get(); + doc["hMax"] = hMax.get(); + doc["homingSensitivity"] = homingSensitivity.get(); String output; serializeJson(doc, output); @@ -135,31 +135,31 @@ void userParameters::saveToLittleFS() { // Set the values in the document // commented items are not needed in save file - doc["firmwareUpdateURL"] = firmwareUpdateURL; - doc["deviceName"] = deviceName; + doc["firmwareUpdateURL"] = firmwareUpdateURL.get(); + doc["deviceName"] = deviceName.get(); doc["shiftStep"] = shiftStep.get(); - doc["stepperPower"] = stepperPower; - doc["stepperSpeed"] = stepperSpeed; + doc["stepperPower"] = stepperPower.get(); + doc["stepperSpeed"] = stepperSpeed.get(); doc["stealthChop"] = stealthChop.get(); - doc["inclineMultiplier"] = inclineMultiplier; - doc["powerCorrectionFactor"] = powerCorrectionFactor; - doc["ERGSensitivity"] = ERGSensitivity; - doc["autoUpdate"] = autoUpdate; - doc["ssid"] = ssid; - doc["password"] = password; - doc["connectedPowerMeter"] = connectedPowerMeter; - doc["connectedHeartMonitor"] = connectedHeartMonitor; - doc["connectedRemote"] = connectedRemote; - // doc["foundDevices"] = foundDevices; - doc["maxWatts"] = maxWatts; - doc["minWatts"] = minWatts; - doc["shifterDir"] = shifterDir; - doc["stepperDir"] = stepperDir; - doc["udpLogEnabled"] = udpLogEnabled; - doc["pTab4Pwr"] = pTab4Pwr; - doc["hMin"] = hMin; - doc["hMax"] = hMax; - doc["homingSensitivity"] = homingSensitivity; + doc["inclineMultiplier"] = inclineMultiplier.get(); + doc["powerCorrectionFactor"] = powerCorrectionFactor.get(); + doc["ERGSensitivity"] = ERGSensitivity.get(); + doc["autoUpdate"] = autoUpdate.get(); + doc["ssid"] = ssid.get(); + doc["password"] = password.get(); + doc["connectedPowerMeter"] = connectedPowerMeter.get(); + doc["connectedHeartMonitor"] = connectedHeartMonitor.get(); + doc["connectedRemote"] = connectedRemote.get(); + // doc["foundDevices"] = foundDevices.get(); + doc["maxWatts"] = maxWatts.get(); + doc["minWatts"] = minWatts.get(); + doc["shifterDir"] = shifterDir.get(); + doc["stepperDir"] = stepperDir.get(); + doc["udpLogEnabled"] = udpLogEnabled.get(); + doc["pTab4Pwr"] = pTab4Pwr.get(); + doc["hMin"] = hMin.get(); + doc["hMax"] = hMax.get(); + doc["homingSensitivity"] = homingSensitivity.get(); // Serialize JSON to file if (serializeJson(doc, file) == 0) { From edcd2f0be2e2052ba88852714a518908ef8bc646 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 17 Sep 2025 00:01:29 +0000 Subject: [PATCH 6/7] Complete RuntimeParameters class refactoring and finalize Parameter template implementation Co-authored-by: doudar <17362216+doudar@users.noreply.github.com> --- include/SmartSpin_parameters.h | 74 ++++++++++++++++++++-------------- src/SmartSpin_parameters.cpp | 20 ++++----- 2 files changed, 54 insertions(+), 40 deletions(-) diff --git a/include/SmartSpin_parameters.h b/include/SmartSpin_parameters.h index cd764a7d..471e0cfc 100644 --- a/include/SmartSpin_parameters.h +++ b/include/SmartSpin_parameters.h @@ -81,16 +81,16 @@ class Measurement { class RuntimeParameters { private: - double targetIncline = 0.0; - float simulatedSpeed = 0.0; - uint8_t FTMSMode = 0x00; - int shifterPosition = 0; - bool homed = false; - int32_t minStep = -DEFAULT_STEPPER_TRAVEL; - int32_t maxStep = DEFAULT_STEPPER_TRAVEL; - int minResistance = -DEFAULT_RESISTANCE_RANGE; - int maxResistance = DEFAULT_RESISTANCE_RANGE; - bool simTargetWatts = false; + Parameter targetIncline; + Parameter simulatedSpeed; + Parameter FTMSMode; + Parameter shifterPosition; + Parameter homed; + Parameter minStep; + Parameter maxStep; + Parameter minResistance; + Parameter maxResistance; + Parameter simTargetWatts; public: Measurement watts; @@ -100,35 +100,49 @@ class RuntimeParameters { Measurement cad; Measurement resistance; - void setTargetIncline(float inc) { targetIncline = inc; } - float getTargetIncline() { return targetIncline; } + // Constructor to set default values + RuntimeParameters() { + targetIncline.set(0.0); + simulatedSpeed.set(0.0); + FTMSMode.set(0x00); + shifterPosition.set(0); + homed.set(false); + minStep.set(-DEFAULT_STEPPER_TRAVEL); + maxStep.set(DEFAULT_STEPPER_TRAVEL); + minResistance.set(-DEFAULT_RESISTANCE_RANGE); + maxResistance.set(DEFAULT_RESISTANCE_RANGE); + simTargetWatts.set(false); + } + + void setTargetIncline(float inc) { targetIncline.set(inc); } + float getTargetIncline() { return targetIncline.get(); } - void setSimulatedSpeed(float spd) { simulatedSpeed = spd; } - float getSimulatedSpeed() { return simulatedSpeed; } + void setSimulatedSpeed(float spd) { simulatedSpeed.set(spd); } + float getSimulatedSpeed() { return simulatedSpeed.get(); } - void setFTMSMode(uint8_t mde) { FTMSMode = mde; } - uint8_t getFTMSMode() { return FTMSMode; } + void setFTMSMode(uint8_t mde) { FTMSMode.set(mde); } + uint8_t getFTMSMode() { return FTMSMode.get(); } - void setShifterPosition(int sp) { shifterPosition = sp; } - int getShifterPosition() { return shifterPosition; } + void setShifterPosition(int sp) { shifterPosition.set(sp); } + int getShifterPosition() { return shifterPosition.get(); } - void setHomed(bool hmd) { homed = hmd; } - int getHomed() { return homed; } + void setHomed(bool hmd) { homed.set(hmd); } + bool getHomed() { return homed.get(); } - void setMinStep(int32_t ms) { ms != INT32_MIN ? minStep = ms : minStep = -DEFAULT_STEPPER_TRAVEL; } - int32_t getMinStep() { return minStep; } + void setMinStep(int32_t ms) { ms != INT32_MIN ? minStep.set(ms) : minStep.set(-DEFAULT_STEPPER_TRAVEL); } + int32_t getMinStep() { return minStep.get(); } - void setMaxStep(int32_t ms) { ms != INT32_MIN ? maxStep = ms : maxStep = DEFAULT_STEPPER_TRAVEL; } - int32_t getMaxStep() { return maxStep; } + void setMaxStep(int32_t ms) { ms != INT32_MIN ? maxStep.set(ms) : maxStep.set(DEFAULT_STEPPER_TRAVEL); } + int32_t getMaxStep() { return maxStep.get(); } - void setSimTargetWatts(int tgt) { simTargetWatts = tgt; } - bool getSimTargetWatts() { return simTargetWatts; } + void setSimTargetWatts(int tgt) { simTargetWatts.set(tgt); } + bool getSimTargetWatts() { return simTargetWatts.get(); } - void setMinResistance(int min) { minResistance = min; } - int getMinResistance() { return minResistance; } + void setMinResistance(int min) { minResistance.set(min); } + int getMinResistance() { return minResistance.get(); } - void setMaxResistance(int max) { maxResistance = max; } - int getMaxResistance() { return maxResistance; } + void setMaxResistance(int max) { maxResistance.set(max); } + int getMaxResistance() { return maxResistance.get(); } String returnJSON(); }; diff --git a/src/SmartSpin_parameters.cpp b/src/SmartSpin_parameters.cpp index c9d868c7..5f6d2e4d 100644 --- a/src/SmartSpin_parameters.cpp +++ b/src/SmartSpin_parameters.cpp @@ -28,16 +28,16 @@ JsonDocument doc; doc["simCad"] = this->cad.getSimulate(); doc["resistance"] = this->resistance.getValue(); doc["targetResistance"] = this->resistance.getTarget(); - doc["homed"] = this->homed; - doc["targetIncline"] = this->targetIncline; - doc["speed"] = this->simulatedSpeed; - doc["simTargetWatts"] = this->simTargetWatts; - doc["FTMSMode"] = this->FTMSMode; - doc["shifterPosition"] = this->shifterPosition; - doc["minStep"] = this->minStep; - doc["maxStep"] = this->maxStep; - doc["minResistance"] = this->minResistance; - doc["maxResistance"] = this->maxResistance; + doc["homed"] = this->homed.get(); + doc["targetIncline"] = this->targetIncline.get(); + doc["speed"] = this->simulatedSpeed.get(); + doc["simTargetWatts"] = this->simTargetWatts.get(); + doc["FTMSMode"] = this->FTMSMode.get(); + doc["shifterPosition"] = this->shifterPosition.get(); + doc["minStep"] = this->minStep.get(); + doc["maxStep"] = this->maxStep.get(); + doc["minResistance"] = this->minResistance.get(); + doc["maxResistance"] = this->maxResistance.get(); String output; serializeJson(doc, output); From 0b6dd4e2d9d648b80ef22532baa171f4b6c83954 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 17 Sep 2025 00:39:31 +0000 Subject: [PATCH 7/7] Remove old getter/setter methods and replace all calls with direct Parameter template access Co-authored-by: doudar <17362216+doudar@users.noreply.github.com> --- include/SmartSpin_parameters.h | 120 ++----------- include/settings.h | 2 +- src/BLE_Client.cpp | 20 +-- src/BLE_Common.cpp | 2 +- src/BLE_Custom_Characteristic.cpp | 250 ++++++++++++++-------------- src/BLE_Fitness_Machine_Service.cpp | 40 ++--- src/BLE_SB20_Service.cpp | 2 +- src/BLE_Server.cpp | 4 +- src/BLE_Wattbike_Service.cpp | 4 +- src/ERG_Mode.cpp | 32 ++-- src/HTTP_Server_Basic.cpp | 72 ++++---- src/Main.cpp | 186 ++++++++++----------- src/Power_Table.cpp | 36 ++-- src/SensorCollector.cpp | 8 +- src/SmartSpin_parameters.cpp | 52 +++--- src/UdpAppender.cpp | 2 +- 16 files changed, 369 insertions(+), 463 deletions(-) diff --git a/include/SmartSpin_parameters.h b/include/SmartSpin_parameters.h index 471e0cfc..d453d11e 100644 --- a/include/SmartSpin_parameters.h +++ b/include/SmartSpin_parameters.h @@ -80,7 +80,15 @@ class Measurement { }; class RuntimeParameters { - private: + public: + Measurement watts; + Measurement pm_batt; + Measurement hr; + Measurement hr_batt; + Measurement cad; + Measurement resistance; + + // Parameter template members - made public for direct access Parameter targetIncline; Parameter simulatedSpeed; Parameter FTMSMode; @@ -92,14 +100,6 @@ class RuntimeParameters { Parameter maxResistance; Parameter simTargetWatts; - public: - Measurement watts; - Measurement pm_batt; - Measurement hr; - Measurement hr_batt; - Measurement cad; - Measurement resistance; - // Constructor to set default values RuntimeParameters() { targetIncline.set(0.0); @@ -114,41 +114,16 @@ class RuntimeParameters { simTargetWatts.set(false); } - void setTargetIncline(float inc) { targetIncline.set(inc); } - float getTargetIncline() { return targetIncline.get(); } - - void setSimulatedSpeed(float spd) { simulatedSpeed.set(spd); } - float getSimulatedSpeed() { return simulatedSpeed.get(); } - - void setFTMSMode(uint8_t mde) { FTMSMode.set(mde); } - uint8_t getFTMSMode() { return FTMSMode.get(); } - - void setShifterPosition(int sp) { shifterPosition.set(sp); } - int getShifterPosition() { return shifterPosition.get(); } - - void setHomed(bool hmd) { homed.set(hmd); } - bool getHomed() { return homed.get(); } - + // Special setter for MinStep and MaxStep with validation logic void setMinStep(int32_t ms) { ms != INT32_MIN ? minStep.set(ms) : minStep.set(-DEFAULT_STEPPER_TRAVEL); } - int32_t getMinStep() { return minStep.get(); } - void setMaxStep(int32_t ms) { ms != INT32_MIN ? maxStep.set(ms) : maxStep.set(DEFAULT_STEPPER_TRAVEL); } - int32_t getMaxStep() { return maxStep.get(); } - - void setSimTargetWatts(int tgt) { simTargetWatts.set(tgt); } - bool getSimTargetWatts() { return simTargetWatts.get(); } - - void setMinResistance(int min) { minResistance.set(min); } - int getMinResistance() { return minResistance.get(); } - - void setMaxResistance(int max) { maxResistance.set(max); } - int getMaxResistance() { return maxResistance.get(); } String returnJSON(); }; class userParameters { - private: + public: + // Parameter template members - made public for direct access Parameter firmwareUpdateURL; Parameter deviceName; Parameter shiftStep; @@ -176,85 +151,16 @@ class userParameters { Parameter connectedRemote; Parameter foundDevices; - public: - void setFirmwareUpdateURL(String fURL) { firmwareUpdateURL.set(fURL); } + // String parameter getters that provide const char* interface for compatibility const char* getFirmwareUpdateURL() { return firmwareUpdateURL.getCStr(); } - - void setDeviceName(String dvn) { deviceName.set(dvn); } const char* getDeviceName() { return deviceName.getCStr(); } - - void setShiftStep(int ss) { shiftStep.set(ss); } - int getShiftStep() { return shiftStep.get(); } - - void setStealthChop(bool sc) { stealthChop.set(sc); } - bool getStealthChop() { return stealthChop.get(); } - - void setFTMSControlPointWrite(bool cpw) { FTMSControlPointWrite.set(cpw); } - bool getFTMSControlPointWrite() { return FTMSControlPointWrite.get(); } - - void setInclineMultiplier(float im) { inclineMultiplier.set(im); } - float getInclineMultiplier() { return inclineMultiplier.get(); } - - void setPowerCorrectionFactor(float pcf) { powerCorrectionFactor.set(pcf); } - float getPowerCorrectionFactor() { return powerCorrectionFactor.get(); } - - float getERGSensitivity() { return ERGSensitivity.get(); } - void setERGSensitivity(float ergS) { ERGSensitivity.set(ergS); } - - void setAutoUpdate(bool atd) { autoUpdate.set(atd); } - bool getAutoUpdate() { return autoUpdate.get(); } - - void setSsid(String sid) { ssid.set(sid); } const char* getSsid() { return ssid.getCStr(); } - - void setPassword(String pwd) { password.set(pwd); } const char* getPassword() { return password.getCStr(); } - - void setConnectedPowerMeter(String cpm) { connectedPowerMeter.set(cpm); } const char* getConnectedPowerMeter() { return connectedPowerMeter.getCStr(); } - - void setConnectedHeartMonitor(String cHr) { connectedHeartMonitor.set(cHr); } const char* getConnectedHeartMonitor() { return connectedHeartMonitor.getCStr(); } - - void setConnectedRemote(String cRemote) { connectedRemote.set(cRemote); } const char* getConnectedRemote() { return connectedRemote.getCStr(); } - - void setStepperPower(int sp) { stepperPower.set(sp); } - int getStepperPower() { return stepperPower.get(); } - - void setStepperSpeed(int sp) { stepperSpeed.set(sp); } - int getStepperSpeed() { return stepperSpeed.get(); } - - void setMaxWatts(int maxW) { maxWatts.set(maxW); } - int getMaxWatts() { return maxWatts.get(); } - - void setMinWatts(int minW) { minWatts.set(minW); } - int getMinWatts() { return minWatts.get(); } - - void setStepperDir(bool sd) { stepperDir.set(sd); } - bool getStepperDir() { return stepperDir.get(); } - - void setShifterDir(bool shd) { shifterDir.set(shd); } - bool getShifterDir() { return shifterDir.get(); } - - void setUdpLogEnabled(bool enabled) { udpLogEnabled.set(enabled); } - bool getUdpLogEnabled() { return udpLogEnabled.get(); } - - void setPTab4Pwr(bool pTab) { pTab4Pwr.set(pTab); } - bool getPTab4Pwr() { return pTab4Pwr.get(); } - - void setFoundDevices(String fdv) { foundDevices.set(fdv); } const char* getFoundDevices() { return foundDevices.getCStr(); } - void setHMin(int32_t min) { hMin.set(min); } - int32_t getHMin() { return hMin.get(); } - - void setHMax(int32_t max) { hMax.set(max); } - int32_t getHMax() { return hMax.get(); } - - void setHomingSensitivity(int sensitivity) { homingSensitivity.set(sensitivity); } - int getHomingSensitivity() { return homingSensitivity.get(); } - void setDefaults(); String returnJSON(); void saveToLittleFS(); diff --git a/include/settings.h b/include/settings.h index c8492c08..9a681a2b 100644 --- a/include/settings.h +++ b/include/settings.h @@ -275,7 +275,7 @@ constexpr const char* ANY = "any"; /* Number of entries in the ERG Power Lookup Table This is currently maintained as to keep memory usage lower and reduce the print output of the table. It can be depreciated in the future should we decide to remove logging of the torque table. Then it should be calculated in ERG_Mode.cpp - by dividing userConfig->getMaxWatts() by POWERTABLE_INCREMENT. */ + by dividing userConfig->maxWatts.get() by POWERTABLE_INCREMENT. */ #define POWERTABLE_WATT_SIZE 30 // Size of the second dimension of the table. The base (starting point) is calculated off of MINUMUM_TABLE_CAD diff --git a/src/BLE_Client.cpp b/src/BLE_Client.cpp index a353ac96..8f4201d4 100644 --- a/src/BLE_Client.cpp +++ b/src/BLE_Client.cpp @@ -62,10 +62,10 @@ static void notifyCB(NimBLERemoteCharacteristic *pBLERemoteCharacteristic, uint8 if (pBLERemoteCharacteristic->getRemoteService()->getUUID() == HID_SERVICE_UUID) { Serial.print(pData[0], HEX); if (pData[0] == 0x04) { - rtConfig->setShifterPosition(rtConfig->getShifterPosition() + 1); + rtConfig->shifterPosition.set(rtConfig->shifterPosition.get() + 1); } if (pData[0] == 0x08) { - rtConfig->setShifterPosition(rtConfig->getShifterPosition() - 1); + rtConfig->shifterPosition.set(rtConfig->shifterPosition.get() - 1); } } // Enqueue sensor data @@ -589,7 +589,7 @@ void ScanCallbacks::onScanEnd(const NimBLEScanResults &results, int reason) { String output; serializeJson(devices, output); SS2K_LOG(BLE_CLIENT_LOG_TAG, "Found Devices: %s", output.c_str()); - userConfig->setFoundDevices(output); // Save the updated JSON document + userConfig->foundDevices.set(output); // Save the updated JSON document } // remove the last connected BLE Power Meter @@ -633,7 +633,7 @@ void SpinBLEClient::resetDevices(NimBLEClient *pClient) { // Control a connected FTMS trainer. If no args are passed, treat it like an external stepper motor. void SpinBLEClient::FTMSControlPointWrite(const uint8_t *pData, int length) { - if (userConfig->getFTMSControlPointWrite()) { + if (userConfig->FTMSControlPointWrite.get()) { NimBLEClient *pClient = nullptr; uint8_t modData[7]; for (int i = 0; i < length; i++) { @@ -654,16 +654,16 @@ void SpinBLEClient::FTMSControlPointWrite(const uint8_t *pData, int length) { const int kLogBufCapacity = length + 40; char logBuf[kLogBufCapacity]; if (modData[0] == FitnessMachineControlPointProcedure::SetIndoorBikeSimulationParameters) { // use virtual Shifting - int incline = ss2k->getTargetPosition() / userConfig->getInclineMultiplier(); + int incline = ss2k->getTargetPosition() / userConfig->inclineMultiplier.get(); modData[3] = (uint8_t)(incline & 0xff); modData[4] = (uint8_t)(incline >> 8); writeCharacteristic->writeValue(modData, length); logBufLength = ss2k_log_hex_to_buffer(modData, length, logBuf, 0, kLogBufCapacity); - logBufLength += snprintf(logBuf + logBufLength, kLogBufCapacity - logBufLength, "-> Shifted Sim Data: %d", rtConfig->getShifterPosition()); + logBufLength += snprintf(logBuf + logBufLength, kLogBufCapacity - logBufLength, "-> Shifted Sim Data: %d", rtConfig->shifterPosition.get()); } else { writeCharacteristic->writeValue(modData, length); logBufLength = ss2k_log_hex_to_buffer(modData, length, logBuf, 0, kLogBufCapacity); - logBufLength += snprintf(logBuf + logBufLength, kLogBufCapacity - logBufLength, "-> Shifted ERG Data: %d", rtConfig->getShifterPosition()); + logBufLength += snprintf(logBuf + logBufLength, kLogBufCapacity - logBufLength, "-> Shifted ERG Data: %d", rtConfig->shifterPosition.get()); } SS2K_LOG(BLE_CLIENT_LOG_TAG, "%s", logBuf); } @@ -696,8 +696,8 @@ void SpinBLEClient::postConnect() { byte message[] = {0xF0, 0xB0, 0x01, 0x01, 0xA2}; writeCharacteristic->writeValue(message, 5); SS2K_LOG(BLE_CLIENT_LOG_TAG, "Activated Echelon callbacks."); - rtConfig->setMinResistance(MIN_ECHELON_RESISTANCE); - rtConfig->setMaxResistance(MAX_ECHELON_RESISTANCE); + rtConfig->minResistance.set(MIN_ECHELON_RESISTANCE); + rtConfig->maxResistance.set(MAX_ECHELON_RESISTANCE); } if ((_BLEd.charUUID == FITNESSMACHINEINDOORBIKEDATA_UUID)) { @@ -733,7 +733,7 @@ void SpinBLEClient::postConnect() { // If we would like to control an external FTMS trainer. With most spin bikes we would want this off, but it's useful if you want to use the SmartSpin2k as an // appliance. - if (userConfig->getFTMSControlPointWrite()) { + if (userConfig->FTMSControlPointWrite.get()) { writeCharacteristic->writeValue(FitnessMachineControlPointProcedure::RequestControl, 1); delay(BLE_NOTIFY_DELAY); SS2K_LOG(BLE_CLIENT_LOG_TAG, "Activated FTMS Training."); diff --git a/src/BLE_Common.cpp b/src/BLE_Common.cpp index 96d51af8..d414d67e 100644 --- a/src/BLE_Common.cpp +++ b/src/BLE_Common.cpp @@ -108,7 +108,7 @@ void BLECommunications() { #endif // DEBUG_HR_TO_PWR // Set outputs to zero if we're not simulating or have connected devices. - if (!spinBLEClient.connectedPM && !rtConfig->watts.getSimulate() && !rtConfig->cad.getSimulate() && !userConfig->getPTab4Pwr()) { + if (!spinBLEClient.connectedPM && !rtConfig->watts.getSimulate() && !rtConfig->cad.getSimulate() && !userConfig->pTab4Pwr.get()) { rtConfig->cad.setValue(0); rtConfig->watts.setValue(0); } diff --git a/src/BLE_Custom_Characteristic.cpp b/src/BLE_Custom_Characteristic.cpp index e74c1b45..2906ce95 100644 --- a/src/BLE_Custom_Characteristic.cpp +++ b/src/BLE_Custom_Characteristic.cpp @@ -169,7 +169,7 @@ void BLE_ss2kCustomCharacteristic::process(std::string rxValue) { returnValue[0] = cc_success; String str = (char *)pData; str.remove(0, 2); - userConfig->setFirmwareUpdateURL(str); + userConfig->firmwareUpdateURL.set(str); LOG_BUF_APPEND("(%s)", userConfig->getFirmwareUpdateURL()); } break; @@ -178,15 +178,15 @@ void BLE_ss2kCustomCharacteristic::process(std::string rxValue) { LOG_BUF_APPEND("<-incline"); if (rxValue[0] == cc_read) { returnValue[0] = cc_success; - int inc = rtConfig->getTargetIncline() * 10; + int inc = rtConfig->targetIncline.get() * 10; returnValue[2] = (uint8_t)(inc & 0xff); returnValue[3] = (uint8_t)(inc >> 8); returnLength += 2; } if (rxValue[0] == cc_write) { returnValue[0] = cc_success; - rtConfig->setTargetIncline(bytes_to_u16(rxValue[3], rxValue[2]) / 10); - LOG_BUF_APPEND("(%f)", rtConfig->getTargetIncline()); + rtConfig->targetIncline.set(bytes_to_u16(rxValue[3], rxValue[2]) / 10); + LOG_BUF_APPEND("(%f)", rtConfig->targetIncline.get()); } } break; @@ -237,7 +237,7 @@ void BLE_ss2kCustomCharacteristic::process(std::string rxValue) { case BLE_simulatedSpeed: { // 0x06 LOG_BUF_APPEND("<-simulatedSpeed"); - int spd = rtConfig->getSimulatedSpeed() * 10; + int spd = rtConfig->simulatedSpeed.get() * 10; if (rxValue[0] == cc_read) { returnValue[0] = cc_success; returnValue[2] = (uint8_t)(spd & 0xff); @@ -246,8 +246,8 @@ void BLE_ss2kCustomCharacteristic::process(std::string rxValue) { } if (rxValue[0] == cc_write) { returnValue[0] = cc_success; - rtConfig->setSimulatedSpeed(bytes_to_u16(rxValue[3], rxValue[2]) / 10); - LOG_BUF_APPEND("(%d)", rtConfig->getSimulatedSpeed()); + rtConfig->simulatedSpeed.set(bytes_to_u16(rxValue[3], rxValue[2]) / 10); + LOG_BUF_APPEND("(%d)", rtConfig->simulatedSpeed.get()); } } break; @@ -260,7 +260,7 @@ void BLE_ss2kCustomCharacteristic::process(std::string rxValue) { returnValue[0] = cc_success; String str = (char *)pData; str.remove(0, 2); - userConfig->setDeviceName(str); + userConfig->deviceName.set(str); LOG_BUF_APPEND("(%s)", userConfig->getDeviceName()); } break; @@ -269,14 +269,14 @@ void BLE_ss2kCustomCharacteristic::process(std::string rxValue) { LOG_BUF_APPEND("<-shiftStep"); if (rxValue[0] == cc_read) { returnValue[0] = cc_success; - returnValue[2] = (uint8_t)(userConfig->getShiftStep() & 0xff); - returnValue[3] = (uint8_t)(userConfig->getShiftStep() >> 8); + returnValue[2] = (uint8_t)(userConfig->shiftStep.get() & 0xff); + returnValue[3] = (uint8_t)(userConfig->shiftStep.get() >> 8); returnLength += 2; } if (rxValue[0] == cc_write) { returnValue[0] = cc_success; - userConfig->setShiftStep(bytes_to_u16(rxValue[3], rxValue[2])); - LOG_BUF_APPEND("(%d)", userConfig->getShiftStep()); + userConfig->shiftStep.set(bytes_to_u16(rxValue[3], rxValue[2])); + LOG_BUF_APPEND("(%d)", userConfig->shiftStep.get()); } break; @@ -284,15 +284,15 @@ void BLE_ss2kCustomCharacteristic::process(std::string rxValue) { LOG_BUF_APPEND("<-stepperPower"); if (rxValue[0] == cc_read) { returnValue[0] = cc_success; - returnValue[2] = (uint8_t)(userConfig->getStepperPower() & 0xff); - returnValue[3] = (uint8_t)(userConfig->getStepperPower() >> 8); + returnValue[2] = (uint8_t)(userConfig->stepperPower.get() & 0xff); + returnValue[3] = (uint8_t)(userConfig->stepperPower.get() >> 8); returnLength += 2; } if (rxValue[0] == cc_write) { returnValue[0] = cc_success; - userConfig->setStepperPower(bytes_to_u16(rxValue[3], rxValue[2])); + userConfig->stepperPower.set(bytes_to_u16(rxValue[3], rxValue[2])); ss2k->updateStepperPower(); - LOG_BUF_APPEND("(%d)", userConfig->getStepperPower()); + LOG_BUF_APPEND("(%d)", userConfig->stepperPower.get()); } break; @@ -300,20 +300,20 @@ void BLE_ss2kCustomCharacteristic::process(std::string rxValue) { LOG_BUF_APPEND("<-stealthChop"); if (rxValue[0] == cc_read) { returnValue[0] = cc_success; - returnValue[2] = (uint8_t)(userConfig->getStealthChop()); + returnValue[2] = (uint8_t)(userConfig->stealthChop.get()); returnLength += 1; } if (rxValue[0] == cc_write) { returnValue[0] = cc_success; - userConfig->setStealthChop(rxValue[2]); + userConfig->stealthChop.set(rxValue[2]); ss2k->updateStealthChop(); - LOG_BUF_APPEND("(%s)", userConfig->getStealthChop() ? "true" : "false"); + LOG_BUF_APPEND("(%s)", userConfig->stealthChop.get() ? "true" : "false"); } break; case BLE_inclineMultiplier: { // 0x0B LOG_BUF_APPEND("<-inclineMultiplier"); - int inc = userConfig->getInclineMultiplier() * 10; + int inc = userConfig->inclineMultiplier.get() * 10; if (rxValue[0] == cc_read) { returnValue[0] = cc_success; returnValue[2] = (uint8_t)(inc & 0xff); @@ -322,14 +322,14 @@ void BLE_ss2kCustomCharacteristic::process(std::string rxValue) { } if (rxValue[0] == cc_write) { returnValue[0] = cc_success; - userConfig->setInclineMultiplier((bytes_to_u16(rxValue[3], rxValue[2])) / 10.0); - LOG_BUF_APPEND("(%f)", userConfig->getInclineMultiplier()); + userConfig->inclineMultiplier.set((bytes_to_u16(rxValue[3], rxValue[2])) / 10.0); + LOG_BUF_APPEND("(%f)", userConfig->inclineMultiplier.get()); } } break; case BLE_powerCorrectionFactor: { // 0x0C LOG_BUF_APPEND("<-powerCorrectionFactor"); - int pcf = userConfig->getPowerCorrectionFactor() * 10; + int pcf = userConfig->powerCorrectionFactor.get() * 10; if (rxValue[0] == cc_read) { returnValue[0] = cc_success; returnValue[2] = (uint8_t)(pcf & 0xff); @@ -338,8 +338,8 @@ void BLE_ss2kCustomCharacteristic::process(std::string rxValue) { } if (rxValue[0] == cc_write) { returnValue[0] = cc_success; - userConfig->setPowerCorrectionFactor((bytes_to_u16(rxValue[3], rxValue[2])) / 10.0); - LOG_BUF_APPEND("(%f)", userConfig->getPowerCorrectionFactor()); + userConfig->powerCorrectionFactor.set((bytes_to_u16(rxValue[3], rxValue[2])) / 10.0); + LOG_BUF_APPEND("(%f)", userConfig->powerCorrectionFactor.get()); } } break; @@ -389,14 +389,14 @@ void BLE_ss2kCustomCharacteristic::process(std::string rxValue) { LOG_BUF_APPEND("<-FTMSMode"); if (rxValue[0] == cc_read) { returnValue[0] = cc_success; - returnValue[2] = (uint8_t)(rtConfig->getFTMSMode() & 0xff); - returnValue[3] = (uint8_t)(rtConfig->getFTMSMode() >> 8); + returnValue[2] = (uint8_t)(rtConfig->FTMSMode.get() & 0xff); + returnValue[3] = (uint8_t)(rtConfig->FTMSMode.get() >> 8); returnLength += 2; } if (rxValue[0] == cc_write) { returnValue[0] = cc_success; - rtConfig->setFTMSMode(bytes_to_u16(rxValue[3], rxValue[2])); - LOG_BUF_APPEND("(%hhu)", rtConfig->getFTMSMode()); + rtConfig->FTMSMode.set(bytes_to_u16(rxValue[3], rxValue[2])); + LOG_BUF_APPEND("(%hhu)", rtConfig->FTMSMode.get()); } break; @@ -404,13 +404,13 @@ void BLE_ss2kCustomCharacteristic::process(std::string rxValue) { LOG_BUF_APPEND("<-autoUpdate"); if (rxValue[0] == cc_read) { returnValue[0] = cc_success; - returnValue[2] = (uint8_t)(userConfig->getAutoUpdate()); + returnValue[2] = (uint8_t)(userConfig->autoUpdate.get()); returnLength += 1; } if (rxValue[0] == cc_write) { returnValue[0] = cc_success; - userConfig->setAutoUpdate(rxValue[2]); - LOG_BUF_APPEND("(%s)", userConfig->getAutoUpdate() ? "true" : "false"); + userConfig->autoUpdate.set(rxValue[2]); + LOG_BUF_APPEND("(%s)", userConfig->autoUpdate.get() ? "true" : "false"); } break; @@ -423,7 +423,7 @@ void BLE_ss2kCustomCharacteristic::process(std::string rxValue) { returnValue[0] = cc_success; String str = (char *)pData; str.remove(0, 2); - userConfig->setSsid(str); + userConfig->ssid.set(str); LOG_BUF_APPEND("(%s)", userConfig->getSsid()); } break; @@ -437,7 +437,7 @@ void BLE_ss2kCustomCharacteristic::process(std::string rxValue) { returnValue[0] = cc_success; String str = (char *)pData; str.remove(0, 2); - userConfig->setPassword(str); + userConfig->password.set(str); LOG_BUF_APPEND("(%s)", "******"); } break; @@ -451,7 +451,7 @@ void BLE_ss2kCustomCharacteristic::process(std::string rxValue) { returnValue[0] = cc_success; String str = (char *)pData; str.remove(0, 2); - userConfig->setFoundDevices(str); + userConfig->foundDevices.set(str); LOG_BUF_APPEND("(%s)", userConfig->getFoundDevices()); } break; @@ -465,7 +465,7 @@ void BLE_ss2kCustomCharacteristic::process(std::string rxValue) { returnValue[0] = cc_success; String str = (char *)pData; str.remove(0, 2); - userConfig->setConnectedPowerMeter(str); + userConfig->connectedPowerMeter.set(str); LOG_BUF_APPEND("(%s)", userConfig->getConnectedPowerMeter()); } break; @@ -479,7 +479,7 @@ void BLE_ss2kCustomCharacteristic::process(std::string rxValue) { returnValue[0] = cc_success; String str = (char *)pData; str.remove(0, 2); - userConfig->setConnectedHeartMonitor(str); + userConfig->connectedHeartMonitor.set(str); LOG_BUF_APPEND("(%s)", userConfig->getConnectedHeartMonitor()); } break; @@ -488,14 +488,14 @@ void BLE_ss2kCustomCharacteristic::process(std::string rxValue) { LOG_BUF_APPEND("<-shifterPosition"); if (rxValue[0] == cc_read) { returnValue[0] = cc_success; - returnValue[2] = (uint8_t)(rtConfig->getShifterPosition() & 0xff); - returnValue[3] = (uint8_t)(rtConfig->getShifterPosition() >> 8); + returnValue[2] = (uint8_t)(rtConfig->shifterPosition.get() & 0xff); + returnValue[3] = (uint8_t)(rtConfig->shifterPosition.get() >> 8); returnLength += 2; } if (rxValue[0] == cc_write) { returnValue[0] = cc_success; - rtConfig->setShifterPosition(bytes_to_u16(rxValue[3], rxValue[2])); - LOG_BUF_APPEND("(%d)", rtConfig->getShifterPosition()); + rtConfig->shifterPosition.set(bytes_to_u16(rxValue[3], rxValue[2])); + LOG_BUF_APPEND("(%d)", rtConfig->shifterPosition.get()); #ifdef CUSTOM_CHAR_DEBUG SS2K_LOG(CUSTOM_CHAR_LOG_TAG, "%s", logBuf); #endif @@ -577,14 +577,14 @@ void BLE_ss2kCustomCharacteristic::process(std::string rxValue) { LOG_BUF_APPEND("<-stepperSpeed"); if (rxValue[0] == cc_read) { returnValue[0] = cc_success; - returnValue[2] = (uint8_t)(userConfig->getStepperSpeed() & 0xff); - returnValue[3] = (uint8_t)(userConfig->getStepperSpeed() >> 8); + returnValue[2] = (uint8_t)(userConfig->stepperSpeed.get() & 0xff); + returnValue[3] = (uint8_t)(userConfig->stepperSpeed.get() >> 8); returnLength += 2; } if (rxValue[0] == cc_write) { returnValue[0] = cc_success; - userConfig->setStepperSpeed(bytes_to_u16(rxValue[3], rxValue[2])); - LOG_BUF_APPEND("(%d)", userConfig->getStepperSpeed()); + userConfig->stepperSpeed.set(bytes_to_u16(rxValue[3], rxValue[2])); + LOG_BUF_APPEND("(%d)", userConfig->stepperSpeed.get()); ss2k->updateStepperSpeed(); #ifdef CUSTOM_CHAR_DEBUG SS2K_LOG(CUSTOM_CHAR_LOG_TAG, "%s", logBuf); @@ -594,7 +594,7 @@ void BLE_ss2kCustomCharacteristic::process(std::string rxValue) { case BLE_ERGSensitivity: { // 0x1F LOG_BUF_APPEND("<-ERGSensitivity"); - int pcf = userConfig->getERGSensitivity() * 10; + int pcf = userConfig->ERGSensitivity.get() * 10; if (rxValue[0] == cc_read) { returnValue[0] = cc_success; returnValue[2] = (uint8_t)(pcf & 0xff); @@ -603,8 +603,8 @@ void BLE_ss2kCustomCharacteristic::process(std::string rxValue) { } if (rxValue[0] == cc_write) { returnValue[0] = cc_success; - userConfig->setERGSensitivity((bytes_to_u16(rxValue[3], rxValue[2])) / 10); - LOG_BUF_APPEND("(%f)", userConfig->getERGSensitivity()); + userConfig->ERGSensitivity.set((bytes_to_u16(rxValue[3], rxValue[2])) / 10); + LOG_BUF_APPEND("(%f)", userConfig->ERGSensitivity.get()); } } break; @@ -612,13 +612,13 @@ void BLE_ss2kCustomCharacteristic::process(std::string rxValue) { LOG_BUF_APPEND("<-ShiftDir"); if (rxValue[0] == cc_read) { returnValue[0] = cc_success; - returnValue[2] = (uint8_t)(userConfig->getShifterDir()); + returnValue[2] = (uint8_t)(userConfig->shifterDir.get()); returnLength += 1; } if (rxValue[0] == cc_write) { returnValue[0] = cc_success; - userConfig->setShifterDir(static_cast(rxValue[2])); - LOG_BUF_APPEND("(%s)", userConfig->getShifterDir() ? "Normal" : "Reverse"); + userConfig->shifterDir.set(static_cast(rxValue[2])); + LOG_BUF_APPEND("(%s)", userConfig->shifterDir.get() ? "Normal" : "Reverse"); } break; /////////////// @@ -626,14 +626,14 @@ void BLE_ss2kCustomCharacteristic::process(std::string rxValue) { LOG_BUF_APPEND("<-MinWatts"); if (rxValue[0] == cc_read) { returnValue[0] = cc_success; - returnValue[2] = (uint8_t)(userConfig->getMinWatts() & 0xff); - returnValue[3] = (uint8_t)(userConfig->getMinWatts() >> 8); + returnValue[2] = (uint8_t)(userConfig->minWatts.get() & 0xff); + returnValue[3] = (uint8_t)(userConfig->minWatts.get() >> 8); returnLength += 2; } if (rxValue[0] == cc_write) { returnValue[0] = cc_success; - userConfig->setMinWatts(bytes_to_u16(rxValue[3], rxValue[2])); - LOG_BUF_APPEND("(%d)", userConfig->getMinWatts()); + userConfig->minWatts.set(bytes_to_u16(rxValue[3], rxValue[2])); + LOG_BUF_APPEND("(%d)", userConfig->minWatts.get()); #ifdef CUSTOM_CHAR_DEBUG SS2K_LOG(CUSTOM_CHAR_LOG_TAG, "%s", logBuf); #endif @@ -643,14 +643,14 @@ void BLE_ss2kCustomCharacteristic::process(std::string rxValue) { LOG_BUF_APPEND("<-MaxWatts"); if (rxValue[0] == cc_read) { returnValue[0] = cc_success; - returnValue[2] = (uint8_t)(userConfig->getMaxWatts() & 0xff); - returnValue[3] = (uint8_t)(userConfig->getMaxWatts() >> 8); + returnValue[2] = (uint8_t)(userConfig->maxWatts.get() & 0xff); + returnValue[3] = (uint8_t)(userConfig->maxWatts.get() >> 8); returnLength += 2; } if (rxValue[0] == cc_write) { returnValue[0] = cc_success; - userConfig->setMaxWatts(bytes_to_u16(rxValue[3], rxValue[2])); - LOG_BUF_APPEND("(%d)", userConfig->getMaxWatts()); + userConfig->maxWatts.set(bytes_to_u16(rxValue[3], rxValue[2])); + LOG_BUF_APPEND("(%d)", userConfig->maxWatts.get()); #ifdef CUSTOM_CHAR_DEBUG SS2K_LOG(CUSTOM_CHAR_LOG_TAG, "%s", logBuf); #endif @@ -713,7 +713,7 @@ void BLE_ss2kCustomCharacteristic::process(std::string rxValue) { powerTable->_hasBeenLoadedThisSession = true; // Prevent reload attempts powerTable->saveFlag = true; // Saved tables all use hMin of Zero and this is not set by the app. - userConfig->setHMin(0); + userConfig->hMin.set(0); } else { // SS2K_LOG(CUSTOM_CHAR_LOG_TAG, "Table row invalid"); // Logging causes crashes in ISR @@ -738,29 +738,29 @@ void BLE_ss2kCustomCharacteristic::process(std::string rxValue) { LOG_BUF_APPEND("<-simulatetargetwatts"); if (rxValue[0] == cc_read) { returnValue[0] = cc_success; - returnValue[2] = (uint8_t)(rtConfig->getSimTargetWatts()); + returnValue[2] = (uint8_t)(rtConfig->simTargetWatts.get()); returnLength += 1; } if (rxValue[0] == cc_write) { returnValue[0] = cc_success; - rtConfig->setSimTargetWatts(rxValue[2]); - LOG_BUF_APPEND("(%s)", rtConfig->getSimTargetWatts() ? "true" : "false"); + rtConfig->simTargetWatts.set(rxValue[2]); + LOG_BUF_APPEND("(%s)", rtConfig->simTargetWatts.get() ? "true" : "false"); } break; case BLE_hMin: // 0x2A LOG_BUF_APPEND("<-hMin"); if (rxValue[0] == cc_read) { returnValue[0] = cc_success; - returnValue[2] = (uint8_t)(userConfig->getHMin() & 0xff); - returnValue[3] = (uint8_t)(userConfig->getHMin() >> 8); - returnValue[4] = (uint8_t)(userConfig->getHMin() >> 16); - returnValue[5] = (uint8_t)(userConfig->getHMin() >> 24); + returnValue[2] = (uint8_t)(userConfig->hMin.get() & 0xff); + returnValue[3] = (uint8_t)(userConfig->hMin.get() >> 8); + returnValue[4] = (uint8_t)(userConfig->hMin.get() >> 16); + returnValue[5] = (uint8_t)(userConfig->hMin.get() >> 24); returnLength += 4; } if (rxValue[0] == cc_write) { returnValue[0] = cc_success; int32_t hMin = int32_t((uint8_t)(rxValue[2]) << 0 | (uint8_t)(rxValue[3]) << 8 | (uint8_t)(rxValue[4]) << 16 | (uint8_t)(rxValue[5]) << 24); - userConfig->setHMin(hMin); + userConfig->hMin.set(hMin); rtConfig->setMinStep(hMin); LOG_BUF_APPEND(" (%d)", hMin); } @@ -770,19 +770,19 @@ void BLE_ss2kCustomCharacteristic::process(std::string rxValue) { LOG_BUF_APPEND("<-hMax"); if (rxValue[0] == cc_read) { returnValue[0] = cc_success; - returnValue[2] = (uint8_t)(userConfig->getHMax() & 0xff); - returnValue[3] = (uint8_t)(userConfig->getHMax() >> 8); - returnValue[4] = (uint8_t)(userConfig->getHMax() >> 16); - returnValue[5] = (uint8_t)(userConfig->getHMax() >> 24); + returnValue[2] = (uint8_t)(userConfig->hMax.get() & 0xff); + returnValue[3] = (uint8_t)(userConfig->hMax.get() >> 8); + returnValue[4] = (uint8_t)(userConfig->hMax.get() >> 16); + returnValue[5] = (uint8_t)(userConfig->hMax.get() >> 24); returnLength += 4; } if (rxValue[0] == cc_write) { returnValue[0] = cc_success; int32_t hMax = int32_t((uint8_t)(rxValue[2]) << 0 | (uint8_t)(rxValue[3]) << 8 | (uint8_t)(rxValue[4]) << 16 | (uint8_t)(rxValue[5]) << 24); Serial.printf("hMax: %d\n <--------------------------------------------", hMax); - userConfig->setHMax(hMax); + userConfig->hMax.set(hMax); rtConfig->setMaxStep(hMax); - LOG_BUF_APPEND(" (%d)", userConfig->getHMax()); + LOG_BUF_APPEND(" (%d)", userConfig->hMax.get()); } break; @@ -790,14 +790,14 @@ void BLE_ss2kCustomCharacteristic::process(std::string rxValue) { LOG_BUF_APPEND("<-homingSensitivity"); if (rxValue[0] == cc_read) { returnValue[0] = cc_success; - returnValue[2] = (uint8_t)(userConfig->getHomingSensitivity() & 0xff); - returnValue[3] = (uint8_t)(userConfig->getHomingSensitivity() >> 8); + returnValue[2] = (uint8_t)(userConfig->homingSensitivity.get() & 0xff); + returnValue[3] = (uint8_t)(userConfig->homingSensitivity.get() >> 8); returnLength += 2; } if (rxValue[0] == cc_write) { returnValue[0] = cc_success; - userConfig->setHomingSensitivity(bytes_to_u16(rxValue[3], rxValue[2])); - LOG_BUF_APPEND("(%d)", userConfig->getHomingSensitivity()); + userConfig->homingSensitivity.set(bytes_to_u16(rxValue[3], rxValue[2])); + LOG_BUF_APPEND("(%d)", userConfig->homingSensitivity.get()); } break; @@ -805,13 +805,13 @@ void BLE_ss2kCustomCharacteristic::process(std::string rxValue) { LOG_BUF_APPEND("<-pTab4Pwr"); if (rxValue[0] == cc_read) { returnValue[0] = cc_success; - returnValue[2] = (uint8_t)(userConfig->getPTab4Pwr()); + returnValue[2] = (uint8_t)(userConfig->pTab4Pwr.get()); returnLength += 1; } if (rxValue[0] == cc_write) { returnValue[0] = cc_success; - userConfig->setPTab4Pwr(rxValue[2]); - LOG_BUF_APPEND("(%s)", userConfig->getPTab4Pwr() ? "true" : "false"); + userConfig->pTab4Pwr.set(rxValue[2]); + LOG_BUF_APPEND("(%s)", userConfig->pTab4Pwr.get() ? "true" : "false"); } break; @@ -844,120 +844,120 @@ void BLE_ss2kCustomCharacteristic::parseNemit() { static userParameters _oldParams; static RuntimeParameters _oldRTParams; - if (userConfig->getAutoUpdate() != _oldParams.getAutoUpdate()) { - _oldParams.setAutoUpdate(userConfig->getAutoUpdate()); + if (userConfig->autoUpdate.get() != _oldParams.autoUpdate.get()) { + _oldParams.autoUpdate.set(userConfig->autoUpdate.get()); BLE_ss2kCustomCharacteristic::notify(BLE_autoUpdate); return; // only do one at a time because immediate update isn't super important for these values } if (strcmp(userConfig->getFirmwareUpdateURL(), _oldParams.getFirmwareUpdateURL()) != 0) { - _oldParams.setFirmwareUpdateURL(userConfig->getFirmwareUpdateURL()); + _oldParams.firmwareUpdateURL.set(userConfig->getFirmwareUpdateURL()); BLE_ss2kCustomCharacteristic::notify(BLE_firmwareUpdateURL); return; } if (strcmp(userConfig->getDeviceName(), _oldParams.getDeviceName()) != 0) { - _oldParams.setDeviceName(userConfig->getDeviceName()); + _oldParams.deviceName.set(userConfig->getDeviceName()); BLE_ss2kCustomCharacteristic::notify(BLE_deviceName); return; } - if (userConfig->getShiftStep() != _oldParams.getShiftStep()) { - _oldParams.setShiftStep(userConfig->getShiftStep()); + if (userConfig->shiftStep.get() != _oldParams.shiftStep.get()) { + _oldParams.shiftStep.set(userConfig->shiftStep.get()); BLE_ss2kCustomCharacteristic::notify(BLE_shiftStep); return; } - if (userConfig->getStealthChop() != _oldParams.getStealthChop()) { - _oldParams.setStealthChop(userConfig->getStealthChop()); + if (userConfig->stealthChop.get() != _oldParams.stealthChop.get()) { + _oldParams.stealthChop.set(userConfig->stealthChop.get()); BLE_ss2kCustomCharacteristic::notify(BLE_stealthChop); return; } - if (userConfig->getInclineMultiplier() != _oldParams.getInclineMultiplier()) { - _oldParams.setInclineMultiplier(userConfig->getInclineMultiplier()); + if (userConfig->inclineMultiplier.get() != _oldParams.inclineMultiplier.get()) { + _oldParams.inclineMultiplier.set(userConfig->inclineMultiplier.get()); BLE_ss2kCustomCharacteristic::notify(BLE_inclineMultiplier); return; } - if (userConfig->getPowerCorrectionFactor() != _oldParams.getPowerCorrectionFactor()) { - _oldParams.setPowerCorrectionFactor(userConfig->getPowerCorrectionFactor()); + if (userConfig->powerCorrectionFactor.get() != _oldParams.powerCorrectionFactor.get()) { + _oldParams.powerCorrectionFactor.set(userConfig->powerCorrectionFactor.get()); BLE_ss2kCustomCharacteristic::notify(BLE_powerCorrectionFactor); return; } if (strcmp(userConfig->getSsid(), _oldParams.getSsid()) != 0) { - _oldParams.setSsid(userConfig->getSsid()); + _oldParams.ssid.set(userConfig->getSsid()); BLE_ss2kCustomCharacteristic::notify(BLE_ssid); return; } if (strcmp(userConfig->getPassword(), _oldParams.getPassword()) != 0) { - _oldParams.setPassword(userConfig->getPassword()); + _oldParams.password.set(userConfig->getPassword()); BLE_ss2kCustomCharacteristic::notify(BLE_password); return; } if (strcmp(userConfig->getConnectedPowerMeter(), _oldParams.getConnectedPowerMeter()) != 0) { - _oldParams.setConnectedPowerMeter(userConfig->getConnectedPowerMeter()); + _oldParams.connectedPowerMeter.set(userConfig->getConnectedPowerMeter()); BLE_ss2kCustomCharacteristic::notify(BLE_connectedPowerMeter); return; } if (strcmp(userConfig->getConnectedHeartMonitor(), _oldParams.getConnectedHeartMonitor()) != 0) { - _oldParams.setConnectedHeartMonitor(userConfig->getConnectedHeartMonitor()); + _oldParams.connectedHeartMonitor.set(userConfig->getConnectedHeartMonitor()); BLE_ss2kCustomCharacteristic::notify(BLE_connectedHeartMonitor); return; } - if (userConfig->getStepperPower() != _oldParams.getStepperPower()) { - _oldParams.setStepperPower(userConfig->getStepperPower()); + if (userConfig->stepperPower.get() != _oldParams.stepperPower.get()) { + _oldParams.stepperPower.set(userConfig->stepperPower.get()); BLE_ss2kCustomCharacteristic::notify(BLE_stepperPower); return; } - if (userConfig->getStepperSpeed() != _oldParams.getStepperSpeed()) { - _oldParams.setStepperSpeed(userConfig->getStepperSpeed()); + if (userConfig->stepperSpeed.get() != _oldParams.stepperSpeed.get()) { + _oldParams.stepperSpeed.set(userConfig->stepperSpeed.get()); BLE_ss2kCustomCharacteristic::notify(BLE_stepperSpeed); return; } - if (userConfig->getERGSensitivity() != _oldParams.getERGSensitivity()) { - _oldParams.setERGSensitivity(userConfig->getERGSensitivity()); + if (userConfig->ERGSensitivity.get() != _oldParams.ERGSensitivity.get()) { + _oldParams.ERGSensitivity.set(userConfig->ERGSensitivity.get()); BLE_ss2kCustomCharacteristic::notify(BLE_ERGSensitivity); return; } - if (userConfig->getStepperDir() != _oldParams.getStepperDir()) { - _oldParams.setStepperDir(userConfig->getStepperDir()); + if (userConfig->stepperDir.get() != _oldParams.stepperDir.get()) { + _oldParams.stepperDir.set(userConfig->stepperDir.get()); BLE_ss2kCustomCharacteristic::notify(BLE_shiftDir); return; } if (strcmp(userConfig->getFoundDevices(), _oldParams.getFoundDevices()) != 0) { - _oldParams.setFoundDevices(userConfig->getFoundDevices()); + _oldParams.foundDevices.set(userConfig->getFoundDevices()); BLE_ss2kCustomCharacteristic::notify(BLE_foundDevices); return; } - if (userConfig->getMinWatts() != _oldParams.getMinWatts()) { - _oldParams.setMinWatts(userConfig->getMinWatts()); + if (userConfig->minWatts.get() != _oldParams.minWatts.get()) { + _oldParams.minWatts.set(userConfig->minWatts.get()); BLE_ss2kCustomCharacteristic::notify(BLE_minBrakeWatts); return; } - if (userConfig->getMaxWatts() != _oldParams.getMaxWatts()) { - _oldParams.setMaxWatts(userConfig->getMaxWatts()); + if (userConfig->maxWatts.get() != _oldParams.maxWatts.get()) { + _oldParams.maxWatts.set(userConfig->maxWatts.get()); BLE_ss2kCustomCharacteristic::notify(BLE_maxBrakeWatts); return; } - if (userConfig->getShifterDir() != _oldParams.getShifterDir()) { - _oldParams.setShifterDir(userConfig->getShifterDir()); + if (userConfig->shifterDir.get() != _oldParams.shifterDir.get()) { + _oldParams.shifterDir.set(userConfig->shifterDir.get()); BLE_ss2kCustomCharacteristic::notify(BLE_shiftDir); return; } - if (rtConfig->getFTMSMode() != _oldRTParams.getFTMSMode()) { - _oldRTParams.setFTMSMode(rtConfig->getFTMSMode()); + if (rtConfig->FTMSMode.get() != _oldRTParams.FTMSMode.get()) { + _oldRTParams.FTMSMode.set(rtConfig->FTMSMode.get()); BLE_ss2kCustomCharacteristic::notify(BLE_FTMSMode); return; } @@ -966,33 +966,33 @@ void BLE_ss2kCustomCharacteristic::parseNemit() { BLE_ss2kCustomCharacteristic::notify(BLE_simulatedTargetWatts); return; } - if (rtConfig->getSimTargetWatts() != _oldRTParams.getSimTargetWatts()) { - _oldRTParams.setSimTargetWatts(rtConfig->getSimTargetWatts()); + if (rtConfig->simTargetWatts.get() != _oldRTParams.simTargetWatts.get()) { + _oldRTParams.simTargetWatts.set(rtConfig->simTargetWatts.get()); BLE_ss2kCustomCharacteristic::notify(BLE_simulateTargetWatts); return; } - if (userConfig->getHMin() != _oldParams.getHMin()) { - _oldParams.setHMin(userConfig->getHMin()); + if (userConfig->hMin.get() != _oldParams.hMin.get()) { + _oldParams.hMin.set(userConfig->hMin.get()); BLE_ss2kCustomCharacteristic::notify(BLE_hMin); userConfig->saveToLittleFS(); return; } - if (userConfig->getHMax() != _oldParams.getHMax()) { - _oldParams.setHMax(userConfig->getHMax()); + if (userConfig->hMax.get() != _oldParams.hMax.get()) { + _oldParams.hMax.set(userConfig->hMax.get()); BLE_ss2kCustomCharacteristic::notify(BLE_hMax); userConfig->saveToLittleFS(); return; } - if (userConfig->getHomingSensitivity() != _oldParams.getHomingSensitivity()) { - _oldParams.setHomingSensitivity(userConfig->getHomingSensitivity()); + if (userConfig->homingSensitivity.get() != _oldParams.homingSensitivity.get()) { + _oldParams.homingSensitivity.set(userConfig->homingSensitivity.get()); BLE_ss2kCustomCharacteristic::notify(BLE_homingSensitivity); return; } - if (userConfig->getPTab4Pwr() != _oldParams.getPTab4Pwr()) { - _oldParams.setPTab4Pwr(userConfig->getPTab4Pwr()); + if (userConfig->pTab4Pwr.get() != _oldParams.pTab4Pwr.get()) { + _oldParams.pTab4Pwr.set(userConfig->pTab4Pwr.get()); BLE_ss2kCustomCharacteristic::notify(BLE_pTab4Pwr); // Home whenever this value is flipped true - if (userConfig->getPTab4Pwr()) { + if (userConfig->pTab4Pwr.get()) { spinBLEServer.spinDownFlag = 1; } return; diff --git a/src/BLE_Fitness_Machine_Service.cpp b/src/BLE_Fitness_Machine_Service.cpp index efe14cd0..b8a7e670 100644 --- a/src/BLE_Fitness_Machine_Service.cpp +++ b/src/BLE_Fitness_Machine_Service.cpp @@ -67,8 +67,8 @@ void BLE_Fitness_Machine_Service::update() { // Calculate Speed for FTMS int speedFtmsUnit = 0; - if (rtConfig->getSimulatedSpeed() > 5) { - speedFtmsUnit = rtConfig->getSimulatedSpeed() * 100; + if (rtConfig->simulatedSpeed.get() > 5) { + speedFtmsUnit = rtConfig->simulatedSpeed.get() * 100; } else { speedFtmsUnit = spinBLEServer.calculateSpeed() * 100; } @@ -150,7 +150,7 @@ void BLE_Fitness_Machine_Service::processFTMSWrite() { case FitnessMachineControlPointProcedure::RequestControl: returnValue[2] = FitnessMachineControlPointResultCode::Success; rtConfig->watts.setTarget(0); - rtConfig->setSimTargetWatts(false); + rtConfig->simTargetWatts.set(false); logBufLength += snprintf(logBuf + logBufLength, kLogBufCapacity - logBufLength, "-> Control Request"); break; @@ -162,30 +162,30 @@ void BLE_Fitness_Machine_Service::processFTMSWrite() { } break; case FitnessMachineControlPointProcedure::SetTargetInclination: { - rtConfig->setFTMSMode((uint8_t)rxValue[0]); + rtConfig->FTMSMode.set((uint8_t)rxValue[0]); returnValue[2] = FitnessMachineControlPointResultCode::Success; port = (rxValue[2] << 8) + rxValue[1]; port *= 10; - rtConfig->setTargetIncline(port); - logBufLength += snprintf(logBuf + logBufLength, kLogBufCapacity - logBufLength, "-> Incline Mode: %2f", rtConfig->getTargetIncline() / 100); + rtConfig->targetIncline.set(port); + logBufLength += snprintf(logBuf + logBufLength, kLogBufCapacity - logBufLength, "-> Incline Mode: %2f", rtConfig->targetIncline.get() / 100); ftmsStatus = {FitnessMachineStatus::TargetInclineChanged, (uint8_t)rxValue[1], (uint8_t)rxValue[2]}; ftmsTrainingStatus[1] = FitnessMachineTrainingStatus::ManualMode; } break; case FitnessMachineControlPointProcedure::SetTargetResistanceLevel: { - rtConfig->setFTMSMode((uint8_t)rxValue[0]); + rtConfig->FTMSMode.set((uint8_t)rxValue[0]); int16_t requestedResistance = (int16_t)rxValue[1]; - if (requestedResistance >= rtConfig->getMinResistance() && requestedResistance <= rtConfig->getMaxResistance()) { + if (requestedResistance >= rtConfig->minResistance.get() && requestedResistance <= rtConfig->maxResistance.get()) { rtConfig->resistance.setTarget(requestedResistance); returnValue[2] = FitnessMachineControlPointResultCode::Success; logBufLength += snprintf(logBuf + logBufLength, kLogBufCapacity - logBufLength, "-> Resistance Mode: %d", rtConfig->resistance.getTarget()); } else { // Clamp the value if it's out of bounds - if (requestedResistance > rtConfig->getMaxResistance()) { - rtConfig->resistance.setTarget(rtConfig->getMaxResistance()); - } else { // requestedResistance < rtConfig->getMinResistance() - rtConfig->resistance.setTarget(rtConfig->getMinResistance()); + if (requestedResistance > rtConfig->maxResistance.get()) { + rtConfig->resistance.setTarget(rtConfig->maxResistance.get()); + } else { // requestedResistance < rtConfig->minResistance.get() + rtConfig->resistance.setTarget(rtConfig->minResistance.get()); } returnValue[2] = FitnessMachineControlPointResultCode::InvalidParameter; logBufLength += snprintf(logBuf + logBufLength, kLogBufCapacity - logBufLength, "-> Resistance Request %d beyond limits", requestedResistance); @@ -197,16 +197,16 @@ void BLE_Fitness_Machine_Service::processFTMSWrite() { } break; case FitnessMachineControlPointProcedure::SetTargetPower: { - rtConfig->setFTMSMode((uint8_t)rxValue[0]); + rtConfig->FTMSMode.set((uint8_t)rxValue[0]); if (spinBLEClient.connectedPM || rtConfig->watts.getSimulate() || spinBLEClient.connectedCD) { returnValue[2] = FitnessMachineControlPointResultCode::Success; // 0x01; rtConfig->watts.setTarget(bytes_to_u16(rxValue[2], rxValue[1])); logBufLength += snprintf(logBuf + logBufLength, kLogBufCapacity - logBufLength, "-> ERG Mode Target: %d Current: %d Incline: %2f", rtConfig->watts.getTarget(), - rtConfig->watts.getValue(), rtConfig->getTargetIncline() / 100); + rtConfig->watts.getValue(), rtConfig->targetIncline.get() / 100); ftmsStatus = {FitnessMachineStatus::TargetPowerChanged, (uint8_t)rxValue[1], (uint8_t)rxValue[2]}; ftmsTrainingStatus[1] = FitnessMachineTrainingStatus::WattControl; // 0x0C; // Adjust set point for powerCorrectionFactor and send to FTMS server (if connected) - int adjustedTarget = rtConfig->watts.getTarget() / userConfig->getPowerCorrectionFactor(); + int adjustedTarget = rtConfig->watts.getTarget() / userConfig->powerCorrectionFactor.get(); const uint8_t translated[] = {FitnessMachineControlPointProcedure::SetTargetPower, (uint8_t)(adjustedTarget % 256), (uint8_t)(adjustedTarget / 256)}; spinBLEClient.FTMSControlPointWrite(translated, 3); } else { @@ -238,7 +238,7 @@ void BLE_Fitness_Machine_Service::processFTMSWrite() { } break; case FitnessMachineControlPointProcedure::SetIndoorBikeSimulationParameters: { // sim mode - rtConfig->setFTMSMode((uint8_t)rxValue[0]); + rtConfig->FTMSMode.set((uint8_t)rxValue[0]); returnValue[2] = FitnessMachineControlPointResultCode::Success; // 0x01; signed char buf[2]; // int16_t windSpeed = (rxValue[2] << 8) + rxValue[1]; @@ -247,8 +247,8 @@ void BLE_Fitness_Machine_Service::processFTMSWrite() { // int8_t rollingResistance = rxValue[5]; // int8_t windResistance = rxValue[6]; port = bytes_to_u16(buf[1], buf[0]); - rtConfig->setTargetIncline(port); - logBufLength += snprintf(logBuf + logBufLength, kLogBufCapacity - logBufLength, "-> Sim Mode Incline %2f", rtConfig->getTargetIncline() / 100); + rtConfig->targetIncline.set(port); + logBufLength += snprintf(logBuf + logBufLength, kLogBufCapacity - logBufLength, "-> Sim Mode Incline %2f", rtConfig->targetIncline.get() / 100); ftmsStatus = {FitnessMachineStatus::IndoorBikeSimulationParametersChanged, (uint8_t)rxValue[1], (uint8_t)rxValue[2], @@ -262,7 +262,7 @@ void BLE_Fitness_Machine_Service::processFTMSWrite() { } break; case FitnessMachineControlPointProcedure::SpinDownControl: { - rtConfig->setFTMSMode((uint8_t)rxValue[0]); + rtConfig->FTMSMode.set((uint8_t)rxValue[0]); // The response parameter for a successful spin down command. // Values are Target Speed Low and Target Speed High in km/h with a resolution of 0.01. @@ -282,7 +282,7 @@ void BLE_Fitness_Machine_Service::processFTMSWrite() { } break; case FitnessMachineControlPointProcedure::SetTargetedCadence: { - rtConfig->setFTMSMode((uint8_t)rxValue[0]); + rtConfig->FTMSMode.set((uint8_t)rxValue[0]); returnValue[2] = FitnessMachineControlPointResultCode::Success; // 0x01; int targetCadence = bytes_to_u16(rxValue[2], rxValue[1]); // rtConfig->setTargetCadence(targetCadence); diff --git a/src/BLE_SB20_Service.cpp b/src/BLE_SB20_Service.cpp index c738e26c..70d288ff 100644 --- a/src/BLE_SB20_Service.cpp +++ b/src/BLE_SB20_Service.cpp @@ -30,7 +30,7 @@ void BLE_SB20_Service::notify() { } // Get current values and populate data struct - int shifterPosition = rtConfig->getShifterPosition(); + int shifterPosition = rtConfig->shifterPosition.get(); shifterPosition = constrain(shifterPosition, 1, 22); // Clamp to 1-22 currentData.gear = shifterPosition; diff --git a/src/BLE_Server.cpp b/src/BLE_Server.cpp index ffd987b6..6b07eb58 100644 --- a/src/BLE_Server.cpp +++ b/src/BLE_Server.cpp @@ -99,8 +99,8 @@ double SpinBLEServer::calculateSpeed() { void SpinBLEServer::updateWheelAndCrankRev() { float wheelSize = 2.127; // 700cX28 circumference, typical in meters float wheelSpeedMps = 0.0; - if (rtConfig->getSimulatedSpeed() > 5) { - wheelSpeedMps = rtConfig->getSimulatedSpeed() / 3.6; + if (rtConfig->simulatedSpeed.get() > 5) { + wheelSpeedMps = rtConfig->simulatedSpeed.get() / 3.6; } else { wheelSpeedMps = this->calculateSpeed() / 3.6; // covert km/h to m/s } diff --git a/src/BLE_Wattbike_Service.cpp b/src/BLE_Wattbike_Service.cpp index 46adfdcf..896c83eb 100644 --- a/src/BLE_Wattbike_Service.cpp +++ b/src/BLE_Wattbike_Service.cpp @@ -33,7 +33,7 @@ void BLE_Wattbike_Service::parseNemit() { const unsigned long NOTIFY_INTERVAL = 30000; // 30 seconds in milliseconds // Get current shifter position - int currentGear = rtConfig->getShifterPosition(); + int currentGear = rtConfig->shifterPosition.get(); if (currentGear < 1) { // Ensure gear is at least 1 currentGear = 1; } @@ -52,7 +52,7 @@ void BLE_Wattbike_Service::parseNemit() { void BLE_Wattbike_Service::update() { // Get current shifter position - int currentGear = rtConfig->getShifterPosition(); + int currentGear = rtConfig->shifterPosition.get(); if (currentGear < 1) { // Ensure gear is at least 1 currentGear = 1; } diff --git a/src/ERG_Mode.cpp b/src/ERG_Mode.cpp index 5f168871..3e4a8580 100644 --- a/src/ERG_Mode.cpp +++ b/src/ERG_Mode.cpp @@ -52,18 +52,18 @@ void ErgMode::runERG() { simulationRunning = rtConfig->watts.getSimulate(); } - if (!userConfig->getPTab4Pwr()) { + if (!userConfig->pTab4Pwr.get()) { // add values to Power table powerTable->processPowerValue(powerBuffer, rtConfig->cad.getValue(), rtConfig->watts); } // compute ERG - if ((rtConfig->getFTMSMode() == FitnessMachineControlPointProcedure::SetTargetPower) && (hasConnectedPowerMeter || simulationRunning)) { + if ((rtConfig->FTMSMode.get() == FitnessMachineControlPointProcedure::SetTargetPower) && (hasConnectedPowerMeter || simulationRunning)) { ergMode.computeErg(); } // resistance mode - if ((rtConfig->getFTMSMode() == FitnessMachineControlPointProcedure::SetTargetResistanceLevel) && (rtConfig->getMaxResistance() != DEFAULT_RESISTANCE_RANGE)) { + if ((rtConfig->FTMSMode.get() == FitnessMachineControlPointProcedure::SetTargetResistanceLevel) && (rtConfig->maxResistance.get() != DEFAULT_RESISTANCE_RANGE)) { ergMode.computeResistance(); } @@ -77,16 +77,16 @@ void ErgMode::runERG() { if (ss2k->resetPowerTableFlag) { LittleFS.remove(POWER_TABLE_FILENAME); powerTable->reset(); - userConfig->setHMin(INT32_MIN); - userConfig->setHMax(INT32_MIN); + userConfig->hMin.set(INT32_MIN); + userConfig->hMax.set(INT32_MIN); spinBLEServer.spinDownFlag = 0; - rtConfig->setHomed(false); + rtConfig->homed.set(false); userConfig->saveToLittleFS(); } loopCounter++; } - if (userConfig->getPTab4Pwr()) { + if (userConfig->pTab4Pwr.get()) { // only do this twice as often as ERG_MODE_DELAY static float previousPower = 0; static unsigned long int pTab4pwrTimer = millis(); @@ -127,9 +127,9 @@ void ErgMode::computeResistance() { int actualDelta = rtConfig->resistance.getTarget() - rtConfig->resistance.getValue(); if (actualDelta != 0) { - rtConfig->setTargetIncline(rtConfig->getTargetIncline() + (TABLE_DIVISOR * actualDelta)); + rtConfig->targetIncline.set(rtConfig->targetIncline.get() + (TABLE_DIVISOR * actualDelta)); } else { - rtConfig->setTargetIncline(ss2k->getCurrentPosition()); + rtConfig->targetIncline.set(ss2k->getCurrentPosition()); } oldResistance = rtConfig->resistance; } @@ -146,9 +146,9 @@ void ErgMode::computeErg() { } // set minimum set point to minimum bike watts if app sends set point lower than minimum bike watts. - if (newWatts.getTarget() < userConfig->getMinWatts()) { + if (newWatts.getTarget() < userConfig->minWatts.get()) { SS2K_LOG(ERG_MODE_LOG_TAG, "ERG Target Below Minumum Value."); - newWatts.setTarget(userConfig->getMinWatts()); + newWatts.setTarget(userConfig->minWatts.get()); } bool isUserSpinning = this->_userIsSpinning(newCadence, ss2k->getCurrentPosition()); @@ -200,8 +200,8 @@ void ErgMode::_setPointChangeState(int newCadence, Measurement& newWatts) { SS2K_LOG(ERG_MODE_LOG_TAG, "SetPoint changed:%dw PowerTable Result: %d", newWatts.getTarget(), tableResult); _updateValues(newCadence, newWatts, tableResult); - if (rtConfig->getTargetIncline() != ss2k->getCurrentPosition()) { // add some time to wait while the knob moves to target position. - int timeToAdd = abs(ss2k->getCurrentPosition() - rtConfig->getTargetIncline()); + if (rtConfig->targetIncline.get() != ss2k->getCurrentPosition()) { // add some time to wait while the knob moves to target position. + int timeToAdd = abs(ss2k->getCurrentPosition() - rtConfig->targetIncline.get()); if (timeToAdd > 4000) { // 4 seconds SS2K_LOG(ERG_MODE_LOG_TAG, "Capping ERG seek time to 5 seconds"); timeToAdd = 4000; @@ -221,7 +221,7 @@ void ErgMode::_setPointChangeState(int newCadence, Measurement& newWatts) { // PrevError void ErgMode::_inSetpointState(int newCadence, Measurement& newWatts) { // Setting Gains For PID Loop - float Kp = userConfig->getERGSensitivity(); + float Kp = userConfig->ERGSensitivity.get(); float Ki = 0.1; float Kd = 0.1; @@ -276,7 +276,7 @@ void ErgMode::_inSetpointState(int newCadence, Measurement& newWatts) { } void ErgMode::_updateValues(int newCadence, Measurement& newWatts, float newIncline) { - rtConfig->setTargetIncline(newIncline); + rtConfig->targetIncline.set(newIncline); _writeLog(ss2k->getCurrentPosition(), newIncline, this->setPoint, newWatts.getTarget(), this->watts.getValue(), newWatts.getValue(), this->cadence, newCadence); this->watts = newWatts; @@ -287,7 +287,7 @@ void ErgMode::_updateValues(int newCadence, Measurement& newWatts, float newIncl bool ErgMode::_userIsSpinning(int cadence, float incline) { if (cadence <= MIN_ERG_CADENCE) { if (!this->engineStopped) { // Test so motor stop command only happens once. // release tension - rtConfig->setTargetIncline(0); // release incline + rtConfig->targetIncline.set(0); // release incline this->engineStopped = true; } return false; // Cadence too low, nothing to do here diff --git a/src/HTTP_Server_Basic.cpp b/src/HTTP_Server_Basic.cpp index b492d928..b600287f 100644 --- a/src/HTTP_Server_Basic.cpp +++ b/src/HTTP_Server_Basic.cpp @@ -246,11 +246,11 @@ void HTTP_Server::start() { server.on("/ergmode", []() { String value = server.arg("value"); if (value == "enable") { - rtConfig->setFTMSMode(FitnessMachineControlPointProcedure::SetTargetPower); + rtConfig->FTMSMode.set(FitnessMachineControlPointProcedure::SetTargetPower); server.send(200, "text/plain", "OK"); SS2K_LOG(HTTP_SERVER_LOG_TAG, "ERG Mode turned on"); } else { - rtConfig->setFTMSMode(FitnessMachineControlPointProcedure::RequestControl); + rtConfig->FTMSMode.set(FitnessMachineControlPointProcedure::RequestControl); server.send(200, "text/plain", "OK"); SS2K_LOG(HTTP_SERVER_LOG_TAG, "ERG Mode turned off"); } @@ -259,11 +259,11 @@ void HTTP_Server::start() { server.on("/targetwattsslider", []() { String value = server.arg("value"); if (value == "enable") { - rtConfig->setSimTargetWatts(true); + rtConfig->simTargetWatts.set(true); server.send(200, "text/plain", "OK"); SS2K_LOG(HTTP_SERVER_LOG_TAG, "Target Watts Simulator turned on"); } else if (value == "disable") { - rtConfig->setSimTargetWatts(false); + rtConfig->simTargetWatts.set(false); server.send(200, "text/plain", "OK"); SS2K_LOG(HTTP_SERVER_LOG_TAG, "Target Watts Simulator turned off"); } else { @@ -276,11 +276,11 @@ void HTTP_Server::start() { server.on("/shift", []() { int value = server.arg("value").toInt(); if ((value > -10) && (value < 10)) { - rtConfig->setShifterPosition(rtConfig->getShifterPosition() + value); + rtConfig->shifterPosition.set(rtConfig->shifterPosition.get() + value); server.send(200, "text/plain", "OK"); SS2K_LOG(HTTP_SERVER_LOG_TAG, "Shift From HTML"); } else { - rtConfig->setShifterPosition(value); + rtConfig->shifterPosition.set(value); SS2K_LOG(HTTP_SERVER_LOG_TAG, "Invalid HTML Shift"); server.send(200, "text/plain", "OK"); } @@ -477,94 +477,94 @@ void HTTP_Server::settingsProcessor() { if (!server.arg("ssid").isEmpty()) { tString = server.arg("ssid"); tString.trim(); - userConfig->setSsid(tString); + userConfig->ssid.set(tString); } if (!server.arg("password").isEmpty()) { tString = server.arg("password"); tString.trim(); - userConfig->setPassword(tString); + userConfig->password.set(tString); } if (!server.arg("deviceName").isEmpty()) { tString = server.arg("deviceName"); tString.trim(); - userConfig->setDeviceName(tString); + userConfig->deviceName.set(tString); } if (!server.arg("shiftStep").isEmpty()) { uint64_t shiftStep = server.arg("shiftStep").toInt(); if (shiftStep >= 10 && shiftStep <= 6000) { - userConfig->setShiftStep(shiftStep); + userConfig->shiftStep.set(shiftStep); } wasSettingsUpdate = true; } if (!server.arg("stepperPower").isEmpty()) { uint64_t stepperPower = server.arg("stepperPower").toInt(); if (stepperPower >= 100 && stepperPower <= 2000) { - userConfig->setStepperPower(stepperPower); + userConfig->stepperPower.set(stepperPower); ss2k->updateStepperPower(); } } if (!server.arg("maxWatts").isEmpty()) { uint64_t maxWatts = server.arg("maxWatts").toInt(); if (maxWatts >= 0 && maxWatts <= 2000) { - userConfig->setMaxWatts(maxWatts); + userConfig->maxWatts.set(maxWatts); } } if (!server.arg("minWatts").isEmpty()) { uint64_t minWatts = server.arg("minWatts").toInt(); if (minWatts >= 0 && minWatts <= 200) { - userConfig->setMinWatts(minWatts); + userConfig->minWatts.set(minWatts); } } if (!server.arg("ERGSensitivity").isEmpty()) { float ERGSensitivity = server.arg("ERGSensitivity").toFloat(); if (ERGSensitivity >= .1 && ERGSensitivity <= 20) { - userConfig->setERGSensitivity(ERGSensitivity); + userConfig->ERGSensitivity.set(ERGSensitivity); } } // checkboxes don't report off, so need to check using another parameter // that's always present on that page if (!server.arg("autoUpdate").isEmpty()) { - userConfig->setAutoUpdate(true); + userConfig->autoUpdate.set(true); } else if (wasSettingsUpdate) { - userConfig->setAutoUpdate(false); + userConfig->autoUpdate.set(false); } if (!server.arg("stepperDir").isEmpty()) { - userConfig->setStepperDir(true); + userConfig->stepperDir.set(true); } else if (wasSettingsUpdate) { - userConfig->setStepperDir(false); + userConfig->stepperDir.set(false); } if (!server.arg("shifterDir").isEmpty()) { - userConfig->setShifterDir(true); + userConfig->shifterDir.set(true); } else if (wasSettingsUpdate) { - userConfig->setShifterDir(false); + userConfig->shifterDir.set(false); } if (!server.arg("udpLogEnabled").isEmpty()) { - userConfig->setUdpLogEnabled(true); + userConfig->udpLogEnabled.set(true); } else if (wasSettingsUpdate) { - userConfig->setUdpLogEnabled(false); + userConfig->udpLogEnabled.set(false); } if (!server.arg("pTab4Pwr").isEmpty()) { - userConfig->setPTab4Pwr(true); + userConfig->pTab4Pwr.set(true); } else if (wasSettingsUpdate) { - userConfig->setPTab4Pwr(false); + userConfig->pTab4Pwr.set(false); } if (!server.arg("stealthChop").isEmpty()) { - userConfig->setStealthChop(true); + userConfig->stealthChop.set(true); ss2k->updateStealthChop(); } else if (wasSettingsUpdate) { - userConfig->setStealthChop(false); + userConfig->stealthChop.set(false); ss2k->updateStealthChop(); } if (!server.arg("inclineMultiplier").isEmpty()) { float inclineMultiplier = server.arg("inclineMultiplier").toFloat(); if (inclineMultiplier >= 0 && inclineMultiplier <= 10) { - userConfig->setInclineMultiplier(inclineMultiplier); + userConfig->inclineMultiplier.set(inclineMultiplier); } } if (!server.arg("powerCorrectionFactor").isEmpty()) { float powerCorrectionFactor = server.arg("powerCorrectionFactor").toFloat(); if (powerCorrectionFactor >= MIN_PCF && powerCorrectionFactor <= MAX_PCF) { - userConfig->setPowerCorrectionFactor(powerCorrectionFactor); + userConfig->powerCorrectionFactor.set(powerCorrectionFactor); } } if (!server.arg("blePMDropdown").isEmpty()) { @@ -572,11 +572,11 @@ void HTTP_Server::settingsProcessor() { if (server.arg("blePMDropdown")) { tString = server.arg("blePMDropdown"); if (tString != userConfig->getConnectedPowerMeter()) { - userConfig->setConnectedPowerMeter(tString); + userConfig->connectedPowerMeter.set(tString); spinBLEClient.reconnectAllDevices(); } } else { - userConfig->setConnectedPowerMeter(String(ANY)); + userConfig->connectedPowerMeter.set(String(ANY)); } } if (!server.arg("bleHRDropdown").isEmpty()) { @@ -586,9 +586,9 @@ void HTTP_Server::settingsProcessor() { if (tString != userConfig->getConnectedHeartMonitor()) { spinBLEClient.reconnectAllDevices(); } - userConfig->setConnectedHeartMonitor(server.arg("bleHRDropdown")); + userConfig->connectedHeartMonitor.set(server.arg("bleHRDropdown")); } else { - userConfig->setConnectedHeartMonitor(String(NONE)); + userConfig->connectedHeartMonitor.set(String(NONE)); } } if (!server.arg("bleRemoteDropdown").isEmpty()) { @@ -598,9 +598,9 @@ void HTTP_Server::settingsProcessor() { if (tString != userConfig->getConnectedRemote()) { spinBLEClient.reconnectAllDevices(); } - userConfig->setConnectedRemote(server.arg("bleRemoteDropdown")); + userConfig->connectedRemote.set(server.arg("bleRemoteDropdown")); } else { - userConfig->setConnectedRemote(String(NONE)); + userConfig->connectedRemote.set(String(NONE)); } } @@ -678,7 +678,7 @@ void HTTP_Server::FirmwareUpdate() { Version availableVer(payload.c_str()); Version currentVer(FIRMWARE_VERSION); - if (((availableVer > currentVer) && (userConfig->getAutoUpdate())) || (!LittleFS.exists("/index.html"))) { + if (((availableVer > currentVer) && (userConfig->autoUpdate.get())) || (!LittleFS.exists("/index.html"))) { //////////////// Update LittleFS////////////// SS2K_LOG(HTTP_SERVER_LOG_TAG, "Updating FileSystem"); http.begin(DATA_UPDATEURL DATA_FILELIST, rootCACertificate); // check version URL @@ -736,7 +736,7 @@ void HTTP_Server::FirmwareUpdate() { } //////// Update Firmware ///////// - if (((availableVer > currentVer) || updateAnyway) && (userConfig->getAutoUpdate())) { + if (((availableVer > currentVer) || updateAnyway) && (userConfig->autoUpdate.get())) { SS2K_LOG(HTTP_SERVER_LOG_TAG, "New firmware detected!"); SS2K_LOG(HTTP_SERVER_LOG_TAG, "Upgrading from %s to %s", FIRMWARE_VERSION, payload.c_str()); t_httpUpdate_return ret = httpUpdate.update(localClient, userConfig->getFirmwareUpdateURL() + String(FW_BINFILE)); diff --git a/src/Main.cpp b/src/Main.cpp index 9cf225e5..0d61915a 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -104,7 +104,7 @@ extern "C" void app_main() { userConfig->saveToLittleFS(); // if we have homing data, use that instead. - if (userConfig->getHMax() != INT32_MIN && userConfig->getHMin() != INT32_MIN) { + if (userConfig->hMax.get() != INT32_MIN && userConfig->hMin.get() != INT32_MIN) { SS2K_LOG(MAIN_LOG_TAG, "Using homing data from config file."); spinBLEServer.spinDownFlag = 1; } @@ -154,12 +154,12 @@ extern "C" void app_main() { } #ifdef TEST_PTAB4PWR - userConfig->setHMin(0); - userConfig->setHMax(27000); - rtConfig->setMaxStep(userConfig->getHMax()); - rtConfig->setMinStep(userConfig->getHMin()); - rtConfig->setHomed(true); - userConfig->setPTab4Pwr(true); + userConfig->hMin.set(0); + userConfig->hMax.set(27000); + rtConfig->setMaxStep(userConfig->hMax.get()); + rtConfig->setMinStep(userConfig->hMin.get()); + rtConfig->homed.set(true); + userConfig->pTab4Pwr.set(true); spinBLEServer.spinDownFlag = 0; #endif @@ -228,32 +228,32 @@ void SS2K::maintenanceLoop(void *pvParameters) { // If we're in ERG mode, modify shift commands to inc/dec the target watts instead. // If we have a resistance bike attached, slow down when we're close to the limits. - if (ss2k->pelotonIsConnected && !rtConfig->getHomed() && !spinBLEServer.spinDownFlag) { - int speed = userConfig->getStepperSpeed(); + if (ss2k->pelotonIsConnected && !rtConfig->homed.get() && !spinBLEServer.spinDownFlag) { + int speed = userConfig->stepperSpeed.get(); float resistance = rtConfig->resistance.getValue(); - float maxResistance = rtConfig->getMaxResistance(); + float maxResistance = rtConfig->maxResistance.get(); // Slow down when resistance is within 20% of the lower limit if (resistance < (maxResistance * 0.2)) { float factor = resistance / (maxResistance * 0.2); - speed = static_cast(factor * userConfig->getStepperSpeed()); + speed = static_cast(factor * userConfig->stepperSpeed.get()); if (speed < 500) { speed = 500; } if (ss2k->targetPosition > stepper->getCurrentPosition()) { - speed = userConfig->getStepperSpeed(); + speed = userConfig->stepperSpeed.get(); } } // Slow down when resistance is within 20% of the upper limit if (resistance > (maxResistance * 0.8)) { float factor = (maxResistance - resistance) / (maxResistance * 0.2); - speed = static_cast(factor * userConfig->getStepperSpeed()); + speed = static_cast(factor * userConfig->stepperSpeed.get()); if (speed < 500) { speed = 500; } if (ss2k->targetPosition < stepper->getCurrentPosition()) { - speed = userConfig->getStepperSpeed(); + speed = userConfig->stepperSpeed.get(); } } ss2k->updateStepperSpeed(speed); @@ -294,7 +294,7 @@ void SS2K::maintenanceLoop(void *pvParameters) { static int _oldHR = 0; static int _oldWatts = 0; static double _oldTargetIncline = 0; - if (_oldHR == rtConfig->hr.getValue() && _oldWatts == rtConfig->watts.getValue() && _oldTargetIncline == rtConfig->getTargetIncline() && + if (_oldHR == rtConfig->hr.getValue() && _oldWatts == rtConfig->watts.getValue() && _oldTargetIncline == rtConfig->targetIncline.get() && NimBLEDevice::getServer()->getConnectedCount() == 0) { // Inactivity detected if (((millis() - rebootTimer) > 1800000)) { @@ -309,7 +309,7 @@ void SS2K::maintenanceLoop(void *pvParameters) { // We have activity, update monitored values _oldHR = rtConfig->hr.getValue(); _oldWatts = rtConfig->watts.getValue(); - _oldTargetIncline = rtConfig->getTargetIncline(); + _oldTargetIncline = rtConfig->targetIncline.get(); rebootTimer = millis(); } @@ -324,7 +324,7 @@ void SS2K::maintenanceLoop(void *pvParameters) { #endif // DEBUG_STACK // Log userParameters SS2K_LOG(MAIN_LOG_TAG, "PM Con %d, CAD con %d, HRM Con %d, W %d, Cad %d, HR %d, Gear %d, Target Position %d", spinBLEClient.connectedPM, spinBLEClient.connectedCD, - spinBLEClient.connectedHRM, rtConfig->watts.getValue(), rtConfig->cad.getValue(), rtConfig->hr.getValue(), rtConfig->getShifterPosition(), ss2k->targetPosition); + spinBLEClient.connectedHRM, rtConfig->watts.getValue(), rtConfig->cad.getValue(), rtConfig->hr.getValue(), rtConfig->shifterPosition.get(), ss2k->targetPosition); intervalTimer2 = millis(); } @@ -334,14 +334,14 @@ void SS2K::maintenanceLoop(void *pvParameters) { #endif // UNIT_TEST void SS2K::FTMSModeShiftModifier() { - int shiftDelta = rtConfig->getShifterPosition() - ss2k->lastShifterPosition; + int shiftDelta = rtConfig->shifterPosition.get() - ss2k->lastShifterPosition; if (shiftDelta) { // Shift detected - switch (rtConfig->getFTMSMode()) { + switch (rtConfig->FTMSMode.get()) { case FitnessMachineControlPointProcedure::SetTargetPower: // ERG Mode { - rtConfig->setShifterPosition(ss2k->lastShifterPosition); // reset shifter position because we're remapping it to ERG target - if ((rtConfig->watts.getTarget() + (shiftDelta * ERG_PER_SHIFT) < userConfig->getMinWatts()) || - (rtConfig->watts.getTarget() + (shiftDelta * ERG_PER_SHIFT) > userConfig->getMaxWatts())) { + rtConfig->shifterPosition.set(ss2k->lastShifterPosition); // reset shifter position because we're remapping it to ERG target + if ((rtConfig->watts.getTarget() + (shiftDelta * ERG_PER_SHIFT) < userConfig->minWatts.get()) || + (rtConfig->watts.getTarget() + (shiftDelta * ERG_PER_SHIFT) > userConfig->maxWatts.get())) { SS2K_LOG(MAIN_LOG_TAG, "Shift to %dw blocked", rtConfig->watts.getTarget() + shiftDelta); break; } @@ -349,7 +349,7 @@ void SS2K::FTMSModeShiftModifier() { SS2K_LOG(MAIN_LOG_TAG, "ERG Shift. New Target: %dw", rtConfig->watts.getTarget()); // Format output for FTMS passthrough #ifndef INTERNAL_ERG_4EXT_FTMS - int adjustedTarget = rtConfig->watts.getTarget() / userConfig->getPowerCorrectionFactor(); + int adjustedTarget = rtConfig->watts.getTarget() / userConfig->powerCorrectionFactor.get(); const uint8_t translated[] = {FitnessMachineControlPointProcedure::SetTargetPower, (uint8_t)(adjustedTarget & 0xff), (uint8_t)(adjustedTarget >> 8)}; spinBLEClient.FTMSControlPointWrite(translated, 3); #endif @@ -358,15 +358,15 @@ void SS2K::FTMSModeShiftModifier() { case FitnessMachineControlPointProcedure::SetTargetResistanceLevel: // Resistance Mode { - rtConfig->setShifterPosition(ss2k->lastShifterPosition); // reset shifter position because we're remapping it to resistance target + rtConfig->shifterPosition.set(ss2k->lastShifterPosition); // reset shifter position because we're remapping it to resistance target if (pelotonIsConnected) { - if (rtConfig->resistance.getTarget() + shiftDelta < rtConfig->getMinResistance()) { - rtConfig->resistance.setTarget(rtConfig->getMinResistance()); - SS2K_LOG(MAIN_LOG_TAG, "Resistance shift less than min %d", rtConfig->getMinResistance()); + if (rtConfig->resistance.getTarget() + shiftDelta < rtConfig->minResistance.get()) { + rtConfig->resistance.setTarget(rtConfig->minResistance.get()); + SS2K_LOG(MAIN_LOG_TAG, "Resistance shift less than min %d", rtConfig->minResistance.get()); break; - } else if (rtConfig->resistance.getTarget() + shiftDelta > rtConfig->getMaxResistance()) { - rtConfig->resistance.setTarget(rtConfig->getMaxResistance()); - SS2K_LOG(MAIN_LOG_TAG, "Resistance shift exceeded max %d", rtConfig->getMaxResistance()); + } else if (rtConfig->resistance.getTarget() + shiftDelta > rtConfig->maxResistance.get()) { + rtConfig->resistance.setTarget(rtConfig->maxResistance.get()); + SS2K_LOG(MAIN_LOG_TAG, "Resistance shift exceeded max %d", rtConfig->maxResistance.get()); break; } rtConfig->resistance.setTarget(rtConfig->resistance.getTarget() + shiftDelta); @@ -377,33 +377,33 @@ void SS2K::FTMSModeShiftModifier() { default: // Sim Mode { - SS2K_LOG(MAIN_LOG_TAG, "Shift %+d pos %d tgt %d min %d max %d r_min %d r_max %d", shiftDelta, rtConfig->getShifterPosition(), ss2k->targetPosition, rtConfig->getMinStep(), - rtConfig->getMaxStep(), rtConfig->getMinResistance(), rtConfig->getMaxResistance()); + SS2K_LOG(MAIN_LOG_TAG, "Shift %+d pos %d tgt %d min %d max %d r_min %d r_max %d", shiftDelta, rtConfig->shifterPosition.get(), ss2k->targetPosition, rtConfig->minStep.get(), + rtConfig->maxStep.get(), rtConfig->minResistance.get(), rtConfig->maxResistance.get()); // Block Shifts further out of bounds - if (((ss2k->targetPosition + shiftDelta * userConfig->getShiftStep()) < rtConfig->getMinStep()) && (shiftDelta < 0)) { + if (((ss2k->targetPosition + shiftDelta * userConfig->shiftStep.get()) < rtConfig->minStep.get()) && (shiftDelta < 0)) { SS2K_LOG(MAIN_LOG_TAG, "Shift Blocked by stepper limits."); - rtConfig->setShifterPosition(ss2k->lastShifterPosition); - } else if ((ss2k->targetPosition + shiftDelta * userConfig->getShiftStep()) > rtConfig->getMaxStep() && (shiftDelta > 0)) { + rtConfig->shifterPosition.set(ss2k->lastShifterPosition); + } else if ((ss2k->targetPosition + shiftDelta * userConfig->shiftStep.get()) > rtConfig->maxStep.get() && (shiftDelta > 0)) { SS2K_LOG(MAIN_LOG_TAG, "Shift Blocked by stepper limits."); - rtConfig->setShifterPosition(ss2k->lastShifterPosition); - } else if (rtConfig->getHomed()) { + rtConfig->shifterPosition.set(ss2k->lastShifterPosition); + } else if (rtConfig->homed.get()) { // was homed. Allow because previous test would have failed if out of bounds. - } else if ((rtConfig->resistance.getValue() <= rtConfig->getMinResistance()) && (shiftDelta > 0)) { + } else if ((rtConfig->resistance.getValue() <= rtConfig->minResistance.get()) && (shiftDelta > 0)) { // User Shifted in the proper direction - allow - } else if ((rtConfig->resistance.getValue() >= rtConfig->getMaxResistance()) && (shiftDelta < 0)) { + } else if ((rtConfig->resistance.getValue() >= rtConfig->maxResistance.get()) && (shiftDelta < 0)) { // User Shifted in the proper direction - allow - } else if ((rtConfig->resistance.getValue() > rtConfig->getMinResistance()) && (rtConfig->resistance.getValue() < rtConfig->getMaxResistance())) { + } else if ((rtConfig->resistance.getValue() > rtConfig->minResistance.get()) && (rtConfig->resistance.getValue() < rtConfig->maxResistance.get())) { // User Shifted in bounds - allow } else { // User tried shifting further into the limit - block. SS2K_LOG(MAIN_LOG_TAG, "Shift Blocked by resistance limit."); - rtConfig->setShifterPosition(ss2k->lastShifterPosition); + rtConfig->shifterPosition.set(ss2k->lastShifterPosition); } uint8_t _controlData[] = {FitnessMachineControlPointProcedure::SetIndoorBikeSimulationParameters, 0x00, 0x00, 0x00, 0x00, 0x28, 0x33}; spinBLEClient.FTMSControlPointWrite(_controlData, 7); } } - ss2k->lastShifterPosition = rtConfig->getShifterPosition(); + ss2k->lastShifterPosition = rtConfig->shifterPosition.get(); BLE_ss2kCustomCharacteristic::notify(BLE_shifterPosition); } } @@ -418,30 +418,30 @@ void SS2K::restartWifi() { } void SS2K::moveStepper() { - bool _stepperDir = userConfig->getStepperDir(); + bool _stepperDir = userConfig->stepperDir.get(); if (stepper) { ss2k->stepperIsRunning = stepper->isRunning(); ss2k->currentPosition = stepper->getCurrentPosition(); if (!ss2k->externalControl) { - if ((rtConfig->getFTMSMode() == FitnessMachineControlPointProcedure::SetTargetPower)) { + if ((rtConfig->FTMSMode.get() == FitnessMachineControlPointProcedure::SetTargetPower)) { #ifdef ERG_GUARDRAILS // don't drive lower out of bounds. This is a final test that should never happen. - if ((stepper->getCurrentPosition() > rtConfig->getTargetIncline()) && (rtConfig->watts.getValue() < rtConfig->watts.getTarget())) { - rtConfig->setTargetIncline(stepper->getCurrentPosition() + 1); + if ((stepper->getCurrentPosition() > rtConfig->targetIncline.get()) && (rtConfig->watts.getValue() < rtConfig->watts.getTarget())) { + rtConfig->targetIncline.set(stepper->getCurrentPosition() + 1); } // don't drive higher out of bounds. This is a final test that should never happen. - if ((stepper->getCurrentPosition() < rtConfig->getTargetIncline()) && (rtConfig->watts.getValue() > rtConfig->watts.getTarget())) { - rtConfig->setTargetIncline(stepper->getCurrentPosition() - 1); + if ((stepper->getCurrentPosition() < rtConfig->targetIncline.get()) && (rtConfig->watts.getValue() > rtConfig->watts.getTarget())) { + rtConfig->targetIncline.set(stepper->getCurrentPosition() - 1); } #endif - ss2k->targetPosition = rtConfig->getTargetIncline(); - } else if (rtConfig->getFTMSMode() == FitnessMachineControlPointProcedure::SetTargetResistanceLevel) { - rtConfig->setTargetIncline(ss2k->currentPosition + ((rtConfig->resistance.getTarget() - rtConfig->resistance.getValue()) * 20)); - ss2k->targetPosition = rtConfig->getTargetIncline(); + ss2k->targetPosition = rtConfig->targetIncline.get(); + } else if (rtConfig->FTMSMode.get() == FitnessMachineControlPointProcedure::SetTargetResistanceLevel) { + rtConfig->targetIncline.set(ss2k->currentPosition + ((rtConfig->resistance.getTarget() - rtConfig->resistance.getValue()) * 20)); + ss2k->targetPosition = rtConfig->targetIncline.get(); } else { // Simulation Mode - ss2k->targetPosition = rtConfig->getShifterPosition() * userConfig->getShiftStep(); - ss2k->targetPosition += rtConfig->getTargetIncline() * userConfig->getInclineMultiplier(); + ss2k->targetPosition = rtConfig->shifterPosition.get() * userConfig->shiftStep.get(); + ss2k->targetPosition += rtConfig->targetIncline.get() * userConfig->inclineMultiplier.get(); } } else { // periodically log external control message @@ -459,11 +459,11 @@ void SS2K::moveStepper() { ss2k->syncMode = false; } - if (ss2k->pelotonIsConnected && !rtConfig->getHomed()) { - if ((rtConfig->resistance.getValue() > rtConfig->getMinResistance()) && (rtConfig->resistance.getValue() < rtConfig->getMaxResistance())) { + if (ss2k->pelotonIsConnected && !rtConfig->homed.get()) { + if ((rtConfig->resistance.getValue() > rtConfig->minResistance.get()) && (rtConfig->resistance.getValue() < rtConfig->maxResistance.get())) { stepper->moveTo(ss2k->targetPosition); - } else if (rtConfig->resistance.getValue() <= rtConfig->getMinResistance()) { // Limit Stepper to Min Resistance - if (rtConfig->resistance.getValue() != rtConfig->getMinResistance()) { + } else if (rtConfig->resistance.getValue() <= rtConfig->minResistance.get()) { // Limit Stepper to Min Resistance + if (rtConfig->resistance.getValue() != rtConfig->minResistance.get()) { stepper->moveTo(stepper->getCurrentPosition() + 20); } // Let the user Shift Out of this Position @@ -471,7 +471,7 @@ void SS2K::moveStepper() { stepper->moveTo(ss2k->targetPosition); } } else { // Limit Stepper to Max Resistance - if (rtConfig->resistance.getValue() != rtConfig->getMaxResistance()) { + if (rtConfig->resistance.getValue() != rtConfig->maxResistance.get()) { stepper->moveTo(stepper->getCurrentPosition() - 20); } // Let the user Shift Out of this Position @@ -480,12 +480,12 @@ void SS2K::moveStepper() { } } } else { // Normal move code for non-Peloton - if ((ss2k->targetPosition >= rtConfig->getMinStep()) && (ss2k->targetPosition <= rtConfig->getMaxStep())) { + if ((ss2k->targetPosition >= rtConfig->minStep.get()) && (ss2k->targetPosition <= rtConfig->maxStep.get())) { stepper->moveTo(ss2k->targetPosition); - } else if (ss2k->targetPosition <= rtConfig->getMinStep()) { // Limit Stepper to Min Position - stepper->moveTo(rtConfig->getMinStep() + 1); + } else if (ss2k->targetPosition <= rtConfig->minStep.get()) { // Limit Stepper to Min Position + stepper->moveTo(rtConfig->minStep.get() + 1); } else { // Limit Stepper to Max Position - stepper->moveTo(rtConfig->getMaxStep() - 1); + stepper->moveTo(rtConfig->maxStep.get() - 1); } } @@ -496,8 +496,8 @@ void SS2K::moveStepper() { stepper->setAutoEnable(true); } - if (_stepperDir != userConfig->getStepperDir()) { // User changed the config direction of the stepper wires - _stepperDir = userConfig->getStepperDir(); + if (_stepperDir != userConfig->stepperDir.get()) { // User changed the config direction of the stepper wires + _stepperDir = userConfig->stepperDir.get(); while (stepper->isRunning()) { // Wait until the motor stops running delay(100); } @@ -514,7 +514,7 @@ void SS2K::handleShiftButtons() { if (upButtonIsPressed && ss2k->upButtonState == RELEASED) { if (millis() - ss2k->lastDebounceTime > DEBOUNCE_DELAY) { // It's a valid press, take action! - rtConfig->setShifterPosition(rtConfig->getShifterPosition() - 1 + userConfig->getShifterDir() * 2); + rtConfig->shifterPosition.set(rtConfig->shifterPosition.get() - 1 + userConfig->shifterDir.get() * 2); ss2k->lastDebounceTime = millis(); } ss2k->upButtonState = PRESSED; @@ -527,7 +527,7 @@ void SS2K::handleShiftButtons() { // --- DOWN Button State Machine --- if (downButtonIsPressed && ss2k->downButtonState == RELEASED) { if (millis() - ss2k->lastDebounceTime > DEBOUNCE_DELAY) { - rtConfig->setShifterPosition(rtConfig->getShifterPosition() + 1 - userConfig->getShifterDir() * 2); + rtConfig->shifterPosition.set(rtConfig->shifterPosition.get() + 1 - userConfig->shifterDir.get() * 2); ss2k->lastDebounceTime = millis(); } ss2k->downButtonState = PRESSED; @@ -561,7 +561,7 @@ void SS2K::setupTMCStepperDriver(bool reset) { if (!reset) { engine.init(); stepper = engine.stepperConnectToPin(currentBoard.stepPin); - stepper->setDirectionPin(currentBoard.dirPin, userConfig->getStepperDir()); + stepper->setDirectionPin(currentBoard.dirPin, userConfig->stepperDir.get()); stepper->setEnablePin(currentBoard.enablePin); stepper->setAutoEnable(true); stepper->setSpeedInHz(DEFAULT_STEPPER_SPEED); @@ -614,12 +614,12 @@ void SS2K::_findEndStop(bool moveForward) { } threshold = totalSgResult / SAMPLES_TO_AVERAGE; - SS2K_LOG(MAIN_LOG_TAG, "Homing %s. Stable Threshold: %d, Sensitivity: %d", moveForward ? "forward (max)" : "backward (min)", threshold, userConfig->getHomingSensitivity()); + SS2K_LOG(MAIN_LOG_TAG, "Homing %s. Stable Threshold: %d, Sensitivity: %d", moveForward ? "forward (max)" : "backward (min)", threshold, userConfig->homingSensitivity.get()); unsigned long lastLogTime = millis() - LOG_INTERVAL; // Initialize last log time while ((millis() - timeoutTimer) < HOME_TIMEOUT) { // Allow user to abort the homing process with a shift - if (abs(rtConfig->getShifterPosition() - ss2k->lastShifterPosition)) { + if (abs(rtConfig->shifterPosition.get() - ss2k->lastShifterPosition)) { SS2K_LOG(MAIN_LOG_TAG, "Homing aborted by user."); stepper->forceStop(); return; @@ -629,12 +629,12 @@ void SS2K::_findEndStop(bool moveForward) { // Periodically log the status for tuning if (millis() - lastLogTime > LOG_INTERVAL) { - Serial.printf("Homing... Current SG: %d, Baseline: %d, Target: < %d\n", currentSgResult, threshold, threshold - userConfig->getHomingSensitivity()); + Serial.printf("Homing... Current SG: %d, Baseline: %d, Target: < %d\n", currentSgResult, threshold, threshold - userConfig->homingSensitivity.get()); lastLogTime = millis(); } // Check for the stall condition - if (currentSgResult < (threshold - userConfig->getHomingSensitivity())) { + if (currentSgResult < (threshold - userConfig->homingSensitivity.get())) { stepper->forceStop(); SS2K_LOG(MAIN_LOG_TAG, "Stall detected! SG dropped to %d.", currentSgResult); delay(100); // Let motor settle @@ -658,16 +658,16 @@ void SS2K::goHome(bool bothDirections) { // --- SETUP DRIVER FOR SENSORLESS HOMING --- // Use very low power for sensitive stall detection - updateStepperPower(userConfig->getStepperPower() * 0.2); // Use a fraction of normal power + updateStepperPower(userConfig->stepperPower.get() * 0.2); // Use a fraction of normal power driver.irun(2); // Set run current very low (2 out of 31) driver.ihold(1); // Set hold current very low updateStepperSpeed(1500); // Use a slow-medium speed for homing // --- FIND MIN END STOP (Mandatory) --- // First, back off the limit in case we are already there - stepper->move(userConfig->getShiftStep(), true); // Move away from the min-stop + stepper->move(userConfig->shiftStep.get(), true); // Move away from the min-stop ss2k->_findEndStop(false); - stepper->move(userConfig->getShiftStep(), true); // Back off the end stop slightly + stepper->move(userConfig->shiftStep.get(), true); // Back off the end stop slightly stepper->setCurrentPosition(0); ss2k->setTargetPosition(0); rtConfig->setMinStep(0); @@ -676,22 +676,22 @@ void SS2K::goHome(bool bothDirections) { // --- FIND MAX END STOP (Optional) --- if (bothDirections) { ss2k->_findEndStop(true); - rtConfig->setMaxStep(stepper->getCurrentPosition() - userConfig->getShiftStep()); // Set max with a safety margin - userConfig->setHMax(rtConfig->getMaxStep()); - SS2K_LOG(MAIN_LOG_TAG, "Max Position found: %d", rtConfig->getMaxStep()); + rtConfig->setMaxStep(stepper->getCurrentPosition() - userConfig->shiftStep.get()); // Set max with a safety margin + userConfig->hMax.set(rtConfig->maxStep.get()); + SS2K_LOG(MAIN_LOG_TAG, "Max Position found: %d", rtConfig->maxStep.get()); } // --- FINALIZE AND SAVE --- - rtConfig->setMaxStep(userConfig->getHMax()); // Ensure max step is set from config if not found - if (bothDirections && rtConfig->getMaxStep() > rtConfig->getMinStep()) { - userConfig->setHMin(rtConfig->getMinStep()); - userConfig->setHMax(rtConfig->getMaxStep()); + rtConfig->setMaxStep(userConfig->hMax.get()); // Ensure max step is set from config if not found + if (bothDirections && rtConfig->maxStep.get() > rtConfig->minStep.get()) { + userConfig->hMin.set(rtConfig->minStep.get()); + userConfig->hMax.set(rtConfig->maxStep.get()); userConfig->saveToLittleFS(); } - rtConfig->setHomed(true); + rtConfig->homed.set(true); setupTMCStepperDriver(true); // Restore normal driver settings - rtConfig->setShifterPosition(0); + rtConfig->shifterPosition.set(0); ss2k->setTargetPosition(0); stepper->moveTo(0); fitnessMachineService.spinDown(FitnessMachineStatus::SpinDown_Success); @@ -700,7 +700,7 @@ void SS2K::goHome(bool bothDirections) { // Applies current power to driver void SS2K::updateStepperPower(int pwr) { - uint16_t rmsPwr = (pwr == 0) ? userConfig->getStepperPower() : pwr; + uint16_t rmsPwr = (pwr == 0) ? userConfig->stepperPower.get() : pwr; driver.rms_current(rmsPwr); uint16_t current = driver.cs_actual(); SS2K_LOG(MAIN_LOG_TAG, "Stepper power is now %d. read:cs=%U", rmsPwr, current); @@ -708,7 +708,7 @@ void SS2K::updateStepperPower(int pwr) { // Applies current StealthChop to driver void SS2K::updateStealthChop() { - bool t_bool = userConfig->getStealthChop(); + bool t_bool = userConfig->stealthChop.get(); driver.en_spreadCycle(!t_bool); driver.pwm_autoscale(t_bool); driver.pwm_autograd(t_bool); @@ -728,7 +728,7 @@ void SS2K::updateStealthChop() { */ void SS2K::updateStepperSpeed(int speed) { if (speed == 0) { - speed = userConfig->getStepperSpeed(); + speed = userConfig->stepperSpeed.get(); } int s = stepper->getSpeedInMilliHz() / 1000; // Because the conversion to/from the TMC driver is not perfect, we need to allow a little bit of slop. @@ -771,8 +771,8 @@ void SS2K::txSerial() { // Serial.printf(" Before TX "); txCheck = 1; } pelotonIsConnected = false; - rtConfig->setMinResistance(-DEFAULT_RESISTANCE_RANGE); - rtConfig->setMaxResistance(DEFAULT_RESISTANCE_RANGE); + rtConfig->minResistance.set(-DEFAULT_RESISTANCE_RANGE); + rtConfig->maxResistance.set(DEFAULT_RESISTANCE_RANGE); txCheck++; } } @@ -780,11 +780,11 @@ void SS2K::txSerial() { // Serial.printf(" Before TX "); void SS2K::pelotonConnected() { txCheck = TX_CHECK_INTERVAL; if (rtConfig->resistance.getValue() > 0) { - rtConfig->setMinResistance(MIN_PELOTON_RESISTANCE); - rtConfig->setMaxResistance(MAX_PELOTON_RESISTANCE); + rtConfig->minResistance.set(MIN_PELOTON_RESISTANCE); + rtConfig->maxResistance.set(MAX_PELOTON_RESISTANCE); } else { - rtConfig->setMinResistance(-DEFAULT_RESISTANCE_RANGE); - rtConfig->setMaxResistance(DEFAULT_RESISTANCE_RANGE); + rtConfig->minResistance.set(-DEFAULT_RESISTANCE_RANGE); + rtConfig->maxResistance.set(DEFAULT_RESISTANCE_RANGE); } } diff --git a/src/Power_Table.cpp b/src/Power_Table.cpp index ac31f816..ca35b737 100644 --- a/src/Power_Table.cpp +++ b/src/Power_Table.cpp @@ -58,7 +58,7 @@ void PowerTable::processPowerValue(PowerBuffer& powerBuffer, int cadence, Measur int currentPos = ss2k->getCurrentPosition() / TABLE_DIVISOR; int targetPos = powerBuffer.powerEntry[0].targetPosition; - int range = (userConfig->getShiftStep() * 2) / TABLE_DIVISOR; + int range = (userConfig->shiftStep.get() * 2) / TABLE_DIVISOR; if (currentPos >= (targetPos - range) && currentPos <= (targetPos + range)) { for (int i = 1; i < POWER_SAMPLES; i++) { @@ -85,12 +85,12 @@ void PowerTable::setStepperMinMax() { int32_t _return = RETURN_ERROR; // if Homing was preformed, skip estimating min_max - if (rtConfig->getHomed() && (userConfig->getHMin() != INT32_MIN) || (userConfig->getHMax() != INT32_MIN)) { + if (rtConfig->homed.get() && (userConfig->hMin.get() != INT32_MIN) || (userConfig->hMax.get() != INT32_MIN)) { SS2K_LOG(POWERTABLE_LOG_TAG, "Using detected travel limits during homing"); - rtConfig->setMinStep(userConfig->getHMin()); - rtConfig->setMaxStep(userConfig->getHMax()); + rtConfig->setMinStep(userConfig->hMin.get()); + rtConfig->setMaxStep(userConfig->hMax.get()); return; - } else if (rtConfig->getHomed()){ + } else if (rtConfig->homed.get()){ SS2K_LOG(POWERTABLE_LOG_TAG, "HOMING VALUES NOT FOUND"); } @@ -102,18 +102,18 @@ void PowerTable::setStepperMinMax() { return; } - int minBreakWatts = userConfig->getMinWatts(); + int minBreakWatts = userConfig->minWatts.get(); if (minBreakWatts > 1) { _return = this->lookup(minBreakWatts, NORMAL_CAD); if (_return != RETURN_ERROR) { // never set less than one shift below current incline. - if ((_return >= ss2k->getCurrentPosition()) && (rtConfig->watts.getValue() > userConfig->getMinWatts())) { - _return = ss2k->getCurrentPosition() - userConfig->getShiftStep(); + if ((_return >= ss2k->getCurrentPosition()) && (rtConfig->watts.getValue() > userConfig->minWatts.get())) { + _return = ss2k->getCurrentPosition() - userConfig->shiftStep.get(); SS2K_LOG(POWERTABLE_LOG_TAG, "Min Position too close to current incline: %d", _return); } // never set above max step. - if (_return >= rtConfig->getMaxStep()) { - _return = ss2k->getCurrentPosition() - userConfig->getShiftStep() * 2; + if (_return >= rtConfig->maxStep.get()) { + _return = ss2k->getCurrentPosition() - userConfig->shiftStep.get() * 2; SS2K_LOG(POWERTABLE_LOG_TAG, "Min Position above max!: %d", _return); } rtConfig->setMinStep(_return); @@ -121,18 +121,18 @@ void PowerTable::setStepperMinMax() { } } - int maxBreakWatts = userConfig->getMaxWatts(); + int maxBreakWatts = userConfig->maxWatts.get(); if (maxBreakWatts > 1) { _return = this->lookup(maxBreakWatts, NORMAL_CAD); if (_return != RETURN_ERROR) { // never set less than one shift above current incline. - if ((_return <= ss2k->getCurrentPosition()) && (rtConfig->watts.getValue() < userConfig->getMaxWatts())) { - _return = ss2k->getCurrentPosition() + userConfig->getShiftStep(); + if ((_return <= ss2k->getCurrentPosition()) && (rtConfig->watts.getValue() < userConfig->maxWatts.get())) { + _return = ss2k->getCurrentPosition() + userConfig->shiftStep.get(); SS2K_LOG(POWERTABLE_LOG_TAG, "Max Position too close to current incline: %d", _return); } // never set below min step. - if (_return <= rtConfig->getMinStep()) { - _return = ss2k->getCurrentPosition() + userConfig->getShiftStep() * 2; + if (_return <= rtConfig->minStep.get()) { + _return = ss2k->getCurrentPosition() + userConfig->shiftStep.get() * 2; SS2K_LOG(POWERTABLE_LOG_TAG, "Max Position below min!: %d", _return); } rtConfig->setMaxStep(_return); @@ -192,7 +192,7 @@ void PowerTable::newEntry(PowerBuffer& powerBuffer) { bool PowerTable::_manageSaveState(bool canSkipReliabilityChecks) { // Homing is now a prerequisite for loading and saving the powertable. - if (!rtConfig->getHomed()) { + if (!rtConfig->homed.get()) { return false; } // Check if the table has been loaded in this session @@ -276,7 +276,7 @@ bool PowerTable::_manageSaveState(bool canSkipReliabilityChecks) { } bool PowerTable::_save() { - if (!rtConfig->getHomed()) { + if (!rtConfig->homed.get()) { SS2K_LOG(POWERTABLE_LOG_TAG, "Power Table not saved because homing was not performed."); return false; // do not save if homing was not performed. } @@ -319,7 +319,7 @@ bool PowerTable::_save() { } // Write homing state - bool isHomed = rtConfig->getHomed(); + bool isHomed = rtConfig->homed.get(); if (file.write((uint8_t*)&isHomed, sizeof(isHomed)) != sizeof(isHomed)) { SS2K_LOG(POWERTABLE_LOG_TAG, "Failed to write homing state"); file.close(); diff --git a/src/SensorCollector.cpp b/src/SensorCollector.cpp index 4f1bda5c..33a7efb2 100644 --- a/src/SensorCollector.cpp +++ b/src/SensorCollector.cpp @@ -56,11 +56,11 @@ void collectAndSet(NimBLEUUID charUUID, NimBLEUUID serviceUUID, NimBLEAddress ad } } - if (sensorData->hasPower() && !rtConfig->watts.getSimulate() && !userConfig->getPTab4Pwr()) { + if (sensorData->hasPower() && !rtConfig->watts.getSimulate() && !userConfig->pTab4Pwr.get()) { if ((charUUID == PELOTON_DATA_UUID) && !((strcmp(userConfig->getConnectedPowerMeter(), NONE) == 0) || (strcmp(userConfig->getConnectedPowerMeter(), ANY) == 0))) { // Peloton connected but using BLE Power Meter. So skip power for Peloton UUID. } else { - int power = sensorData->getPower() * userConfig->getPowerCorrectionFactor(); + int power = sensorData->getPower() * userConfig->powerCorrectionFactor.get(); rtConfig->watts.setValue(power); spinBLEClient.connectedPM = true; logBufLength += snprintf(logBuf + logBufLength, kLogBufMaxLength - logBufLength, " PW(%d)", power % 10000); @@ -69,13 +69,13 @@ void collectAndSet(NimBLEUUID charUUID, NimBLEUUID serviceUUID, NimBLEAddress ad if (sensorData->hasSpeed()) { float speed = sensorData->getSpeed(); - rtConfig->setSimulatedSpeed(speed); + rtConfig->simulatedSpeed.set(speed); spinBLEClient.connectedSpeed = true; logBufLength += snprintf(logBuf + logBufLength, kLogBufMaxLength - logBufLength, " SD(%.2f)", fmodf(speed, 1000.0)); } if (sensorData->hasResistance()) { - if ((rtConfig->getMaxResistance() == MAX_PELOTON_RESISTANCE) && (charUUID != PELOTON_DATA_UUID)) { + if ((rtConfig->maxResistance.get() == MAX_PELOTON_RESISTANCE) && (charUUID != PELOTON_DATA_UUID)) { // Peloton connected but using BLE Power Meter. So skip resistance for UUID's that aren't Peloton. } else { int resistance = sensorData->getResistance(); diff --git a/src/SmartSpin_parameters.cpp b/src/SmartSpin_parameters.cpp index 5f6d2e4d..65ed1c0a 100644 --- a/src/SmartSpin_parameters.cpp +++ b/src/SmartSpin_parameters.cpp @@ -194,61 +194,61 @@ JsonDocument doc; } // Copy values from the JsonDocument to the Config - setFirmwareUpdateURL(doc["firmwareUpdateURL"]); - setDeviceName(doc["deviceName"]); - setShiftStep(doc["shiftStep"]); - setStepperPower(doc["stepperPower"]); - setStealthChop(doc["stealthChop"]); - setInclineMultiplier(doc["inclineMultiplier"]); - setAutoUpdate(doc["autoUpdate"]); - setSsid(doc["ssid"]); - setPassword(doc["password"]); - setConnectedPowerMeter(doc["connectedPowerMeter"]); - setConnectedHeartMonitor(doc["connectedHeartMonitor"]); + firmwareUpdateURL.set(doc["firmwareUpdateURL"]); + deviceName.set(doc["deviceName"]); + shiftStep.set(doc["shiftStep"]); + stepperPower.set(doc["stepperPower"]); + stealthChop.set(doc["stealthChop"]); + inclineMultiplier.set(doc["inclineMultiplier"]); + autoUpdate.set(doc["autoUpdate"]); + ssid.set(doc["ssid"]); + password.set(doc["password"]); + connectedPowerMeter.set(doc["connectedPowerMeter"]); + connectedHeartMonitor.set(doc["connectedHeartMonitor"]); // setFoundDevices(doc["foundDevices"]); // If statements to upgrade old versions of config.txt that didn't include these if (doc["ERGSensitivity"]) { - setERGSensitivity(doc["ERGSensitivity"]); + ERGSensitivity.set(doc["ERGSensitivity"]); } if (doc["maxWatts"]) { - setMaxWatts(doc["maxWatts"]); + maxWatts.set(doc["maxWatts"]); } if (doc["stepperSpeed"]) { - setStepperSpeed(doc["stepperSpeed"]); + stepperSpeed.set(doc["stepperSpeed"]); } if (doc["minWatts"]) { - setMinWatts(doc["minWatts"]); + minWatts.set(doc["minWatts"]); } if (!doc["stepperDir"].isNull()) { - setStepperDir(doc["stepperDir"]); + stepperDir.set(doc["stepperDir"]); } if (!doc["shifterDir"].isNull()) { - setShifterDir(doc["shifterDir"]); + shifterDir.set(doc["shifterDir"]); } if (!doc["udpLogEnabled"].isNull()) { - setUdpLogEnabled(doc["udpLogEnabled"]); + udpLogEnabled.set(doc["udpLogEnabled"]); } if (!doc["pTab4Pwr"].isNull()) { - setPTab4Pwr(doc["pTab4Pwr"]); + pTab4Pwr.set(doc["pTab4Pwr"]); } if (doc["powerCorrectionFactor"]) { - setPowerCorrectionFactor(doc["powerCorrectionFactor"]); - if ((getPowerCorrectionFactor() < MIN_PCF) || (getPowerCorrectionFactor() > MAX_PCF)) { - setPowerCorrectionFactor(1); + powerCorrectionFactor.set(doc["powerCorrectionFactor"]); + if ((powerCorrectionFactor.get() < MIN_PCF) || (powerCorrectionFactor.get() > MAX_PCF)) { + powerCorrectionFactor.set(1); } } if (doc["connectedRemote"]) { - setConnectedRemote(doc["connectedRemote"]); + connectedRemote.set(doc["connectedRemote"]); } if (!doc["hMin"].isNull()) { - setHMin(doc["hMin"]); + hMin.set(doc["hMin"]); } if (!doc["hMax"].isNull()) { - setHMax(doc["hMax"]); + hMax.set(doc["hMax"]); } if (!doc["homingSensitivity"].isNull()) { - setHomingSensitivity(doc["homingSensitivity"]); + homingSensitivity.set(doc["homingSensitivity"]); } SS2K_LOG(CONFIG_LOG_TAG, "Config File Loaded: %s", configFILENAME); diff --git a/src/UdpAppender.cpp b/src/UdpAppender.cpp index c27fe31f..66321fd4 100644 --- a/src/UdpAppender.cpp +++ b/src/UdpAppender.cpp @@ -11,7 +11,7 @@ void UdpAppender::Initialize() {} void UdpAppender::Log(const char *message) { - if (WiFi.status() == WL_CONNECTED && userConfig->getUdpLogEnabled()) { + if (WiFi.status() == WL_CONNECTED && userConfig->udpLogEnabled.get()) { this->udp.beginPacket("255.255.255.255", this->port); this->udp.write((uint8_t *)message, strlen(message)); this->udp.endPacket();