From: Caisking <3449750381@qq.com> Date: Wed, 17 Jan 2024 12:24:17 +0000 (+0800) Subject: 更新表盘卡片,血氧卡片,训练卡片 X-Git-Tag: release_V1.2.70_20241020_135402~1371 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=95daa49c6d8e0076943a2680dac93b405ab42217;p=mirrors%2FFD230.git 更新表盘卡片,血氧卡片,训练卡片 --- diff --git a/code/sdk/application/battery/CMakeLists.txt b/code/sdk/application/battery/CMakeLists.txt index bb96fc619..94abd93d9 100644 --- a/code/sdk/application/battery/CMakeLists.txt +++ b/code/sdk/application/battery/CMakeLists.txt @@ -5,12 +5,18 @@ set(COMPONENT_NAME "batterry_service") +set(PUBLIC_HEADER +${CMAKE_CURRENT_SOURCE_DIR}/hal +${CMAKE_CURRENT_SOURCE_DIR}/test +${CMAKE_CURRENT_SOURCE_DIR}/service +) set(PRIVATE_HEADER -${CMAKE_CURRENT_SOURCE_DIR}/include ) set(SOURCES -${CMAKE_CURRENT_SOURCE_DIR}/battery.c +${CMAKE_CURRENT_SOURCE_DIR}/service/battery_service.c +${CMAKE_CURRENT_SOURCE_DIR}/test/battery_at_cmd.c +${CMAKE_CURRENT_SOURCE_DIR}/hal/battery_hal.c ) set(COMPONENT_PUBLIC_CCFLAGS @@ -29,6 +35,7 @@ set(MAIN_COMPONENT set(PUBLIC_DEFINES SUPPORT_BATTERY_SERVICE +SUPPORT_AT_BATTERY ) set(PRIVATE_DEFINES diff --git a/code/sdk/application/battery/battery.c b/code/sdk/application/battery/battery.c deleted file mode 100644 index 93b157a37..000000000 --- a/code/sdk/application/battery/battery.c +++ /dev/null @@ -1,216 +0,0 @@ -/** - * Copyright (c) @CompanyNameMagicTag 2022-2022. All rights reserved. \n - * - * Description: Test adc source \n - * Author: @CompanyNameTag \n - * History: \n - * 2022-08-16, Create file. \n - */ - -#include "adc.h" -#define TEST_PARAM_ARGC_1 1 -#define TEST_PARAM_ARGC_2 2 -#define TEST_PARAM_ARGC_3 3 -#define TEST_PARAM_ARGC_4 4 -#define TEST_PARAM_ARGC_5 5 -#define TEST_PARAM_ARGC_6 6 -#define TEST_PARAM_ARGC_7 7 -#define TEST_PARAM_4_BYTES 4 -#define TEST_PARAM_8_BYTES 8 -typedef enum { - SUITE_OK = 0, - SUITE_UNKNOWN_FUNCTION = -1, - SUITE_ERROR_TIMED_OUT = -2, - SUITE_ERROR_BAD_PARAMS = -3, - SUITE_ERROR_PIN_ALLOCATION = -4, - SUITE_ERROR_PIN_DEALLOCATION = -5, - SUITE_ERROR_UNEXPECTED_INTERRUPT = -6, - SUITE_ALLOC_FAILED = -7, - SUITE_CONFIG_FAILED = -8, - SUITE_TEST_FAILED = -254, -} battery_error_e; - -#if defined(CONFIG_ADC_SUPPORT_AFE) - -#error CONFIG_ADC_SUPPORT_AFE - -#include "hal_adc_v152.h" -#include "hal_adc_v152_regs_op.h" -#else -#include "hal_adc_v151.h" -#include "hal_adc_v151_regs_op.h" -#endif -#include "adc_porting.h" - -#include "pinctrl.h" - -#include "debug_print.h" -#include "soc_osal.h" -#include "tcxo.h" -#include "irmalloc.h" -#include "errcode.h" -#include "common_def.h" - -#include "battery.h" - -#define HAL_ADC_SAMPLE_NUMBER_CONFIG_0 10 /* Channel with buffer manual sample average number. */ -#define HAL_ADC_SAMPLE_NUMBER_CONFIG_1 10 /* Channel without buffer manual sample average number. */ -#define HAL_ADC_DISCARD_NUMBER_CONFIG_0 8 /* Channel with buffer manual sample discard number. */ -#define HAL_ADC_DISCARD_NUMBER_CONFIG_1 8 /* Channel without buffer manual sample discard number. */ - -#define adc_trans_sytick_to_voltage(x) ((float)(((float)(x) * 17) / 40960)) -#define adc_trans_sytick_to_voltage_diff(x) ((float)(((float)((x) - 2048) * 17) / 20480)) -// #define adc_trans_sytick_to_voltage_without_auto_scan(x) ((float)(((float)(x) * 18) / 40960)) -#define adc_trans_sytick_to_voltage_without_auto_scan(x) ((float)((float)(x) / 749.75838433852f)) -#define BATTERY_VOLTAGE_MAX (4.2f) -#define BATTERY_VOLTAGE_MIN (3.2f) - -static uint32_t g_adc_sample_times = 0; -static uint32_t g_adc_sample_discard = 0; -static uint32_t g_adc_sample_stick = 0; - -#define TESTADC_DISACRD_DELAY_MS 3 -#define MINIMUM_VOLTAGE_RANGE 2 -#define MAXIMUM_VOLTAGE_RANGE 17 - -static uint32_t adc_get_sample_times(void) -{ - return g_adc_sample_times; -} - -static uint32_t adc_get_sample_discard(void) -{ - return g_adc_sample_discard; -} - -static void adc_set_sample_stick(uint32_t stick) -{ - g_adc_sample_stick = stick; -} - -static uint32_t adc_get_sample_stick(void) -{ - return g_adc_sample_stick; -} - -static float adc_stick_transfer_voltage(uint16_t stick, adc_channel_t channel) -{ - - UNUSED(channel); - return adc_trans_sytick_to_voltage_without_auto_scan(stick); -} - -static bool adc_get_sample_result(float *voltage, uint8_t channel) -{ - uint32_t sample_number = 0; - uint32_t discard_number = 0; - uint32_t stick = 0; - uint32_t sample_zero_count = 0; - - if (channel >= ADC_CHANNEL_4) { - sample_number = HAL_ADC_SAMPLE_NUMBER_CONFIG_1; - discard_number = HAL_ADC_DISCARD_NUMBER_CONFIG_1; - } else { - sample_number = HAL_ADC_SAMPLE_NUMBER_CONFIG_0; - discard_number = HAL_ADC_DISCARD_NUMBER_CONFIG_0; - } - - if (g_adc_sample_times != 0) { - sample_number = adc_get_sample_times(); - } - - if (g_adc_sample_discard != 0) { - discard_number = adc_get_sample_discard(); - } - - /* after channel is enabled, sample result is error in previous samplings, need to be discarded */ - for (uint32_t i = 0; i < discard_number; i++) { - uapi_adc_manual_sample(ADC_CHANNEL_NONE); - uapi_tcxo_delay_ms((uint64_t)TESTADC_DISACRD_DELAY_MS); - } - - for (uint32_t i = 0; i < sample_number; i++) { - uint32_t irq_sts = osal_irq_lock(); - uint32_t sample_result = (uint32_t)uapi_adc_manual_sample(ADC_CHANNEL_NONE); - // osal_printk("sample_result = %d.\r\n", sample_result); - if (sample_result == 0) { sample_zero_count++; } - stick += sample_result; - osal_irq_restore(irq_sts); - } - sample_number -= sample_zero_count; - if (sample_number > 0) { - stick = (stick / sample_number); - } else { - *voltage = 0; - return false; - } - - adc_set_sample_stick(stick); - *voltage = adc_trans_sytick_to_voltage_without_auto_scan(stick); - - UNUSED(discard_number); - return true; -} - -/** - * @brief Get voltage by the channel. Available voltage rang is 0V ~ 1.7V. - * @param voltage The sample result of voltage. - * @param channel The adc channel. - * @return true when select channel success, false when seclect channel failed. - */ -static bool adc_get_voltage_by_channel(float *voltage, uint8_t channel) -{ - bool ret = false; - - uapi_adc_power_en(AFE_SCAN_MODE_MAX_NUM, true); - ret = uapi_adc_open_channel(channel); - if (ret == ERRCODE_SUCC) { - ret = adc_get_sample_result(voltage, channel); - if (ret) { - uapi_adc_close_channel(channel); - uapi_adc_power_en(AFE_SCAN_MODE_MAX_NUM, false); - return true; - } - } else { - osal_printk("uapi_adc_open_channel failed : %d\r\n", ret); - } - - *voltage = 0; - uapi_adc_close_channel(channel); - uapi_adc_power_en(AFE_SCAN_MODE_MAX_NUM, false); - return false; -} - -bool battery_get_voltage_by_channel(float *voltage, uint8_t channel) -{ - - uapi_adc_init(ADC_CLOCK_500KHZ); - uint64_t time1, time2; - uint32_t param_index = 0; - // osal_printk("channel: %d\r\n", channel); - time1 = uapi_tcxo_get_us(); - if (!adc_get_voltage_by_channel(voltage, channel)) { - osal_printk("adc get sample result failed.\r\n"); - return SUITE_TEST_FAILED; - } - time2 = uapi_tcxo_get_us(); - // osal_printk("tick: %d, Sample time: %d. \r\n", adc_get_sample_stick(), - // (uint64_t)(time2 - time1)); - // osal_printk("voltage: %.4f.\r\n", voltage); - uapi_adc_deinit(); - return true; -} - - -uint8_t battery_get_voltage(float *voltage) -{ - battery_get_voltage_by_channel(voltage,2); - uint8_t percent = 0; - - if (*voltage <= BATTERY_VOLTAGE_MIN) - return 0; - if (*voltage >= BATTERY_VOLTAGE_MAX) - return 100; - percent = (*voltage - BATTERY_VOLTAGE_MIN)*100/(BATTERY_VOLTAGE_MAX - BATTERY_VOLTAGE_MIN) ; - return percent; -} \ No newline at end of file diff --git a/code/sdk/application/battery/battery.c.txt b/code/sdk/application/battery/battery.c.txt deleted file mode 100644 index 638a40e07..000000000 --- a/code/sdk/application/battery/battery.c.txt +++ /dev/null @@ -1,463 +0,0 @@ -/** - * Copyright (c) @CompanyNameMagicTag 2022-2022. All rights reserved. \n - * - * Description: Test adc source \n - * Author: @CompanyNameTag \n - * History: \n - * 2022-08-16, Create file. \n - */ - -#include "adc.h" -#define TEST_PARAM_ARGC_1 1 -#define TEST_PARAM_ARGC_2 2 -#define TEST_PARAM_ARGC_3 3 -#define TEST_PARAM_ARGC_4 4 -#define TEST_PARAM_ARGC_5 5 -#define TEST_PARAM_ARGC_6 6 -#define TEST_PARAM_ARGC_7 7 -#define TEST_PARAM_4_BYTES 4 -#define TEST_PARAM_8_BYTES 8 -typedef enum { - SUITE_OK = 0, - SUITE_UNKNOWN_FUNCTION = -1, - SUITE_ERROR_TIMED_OUT = -2, - SUITE_ERROR_BAD_PARAMS = -3, - SUITE_ERROR_PIN_ALLOCATION = -4, - SUITE_ERROR_PIN_DEALLOCATION = -5, - SUITE_ERROR_UNEXPECTED_INTERRUPT = -6, - SUITE_ALLOC_FAILED = -7, - SUITE_CONFIG_FAILED = -8, - SUITE_TEST_FAILED = -254, -} battery_error_e; - -#if defined(CONFIG_ADC_SUPPORT_AFE) - -#error CONFIG_ADC_SUPPORT_AFE - -#include "hal_adc_v152.h" -#include "hal_adc_v152_regs_op.h" -#else -#include "hal_adc_v151.h" -#include "hal_adc_v151_regs_op.h" -#endif -#include "adc_porting.h" - -#include "pinctrl.h" - -#include "debug_print.h" -#include "soc_osal.h" -#include "tcxo.h" -#include "irmalloc.h" -#include "errcode.h" -#include "common_def.h" - -#include "battery.h" - -#if defined(CONFIG_ADC_SUPPORT_AFE) - - -#define ADC_AUTO_SAMPLE_TEST_TIMES 1000 -#define HADC_DEFAULT_CALI \ -{ \ - .hadc_os_code = 0x68, \ - .hadc_wt_b22 = 0x75fdd, \ - .hadc_wt_b21 = 0x3ef67, \ - .hadc_wt_b20 = 0x1f7ae, \ - .hadc_wt_b19 = 0xfc3d, \ - .hadc_wt_b18 = 0x7e22, \ - .hadc_wt_b17 = 0x7dc9, \ - .hadc_wt_b16 = 0x3f01, \ - .hadc_wt_b15 = 0x1f80, \ - .hadc_wt_b14 = 0xfc5, \ - .hadc_wt_b13 = 0x800, \ - .hadc_wt_b12 = 0x800, \ - .hadc_wt_b11 = 0x400, \ - .hadc_wt_b10 = 0x200, \ - .hadc_wt_b9 = 0x100, \ - .dac_code1 = 0x200, \ - .dac_code2 = 0x1d5, \ -} - -afe_config_t g_afe_config = HADC_DEFAULT_CALI; -static bool g_afe_open_flag = false; - -static int gadc_open_test(int argc, char *argv[]) -{ - if (argc < 1) { - return SUITE_ERROR_BAD_PARAMS; - } - adc_v152_gadc_channel_sel_t gadc_channel = (adc_v152_gadc_channel_sel_t)strtol(argv[0], NULL, 0); - if (gadc_channel > SINGLE_END_AINN4) { - return SUITE_ERROR_BAD_PARAMS; - } - errcode_t ret = uapi_adc_init(ADC_CLOCK_NONE); - if (ret != ERRCODE_SUCC) { - return ret; - } - uapi_adc_open_channel(gadc_channel); - uapi_adc_power_en(AFE_GADC_MODE, true); - adc_calibration(AFE_GADC_MODE, true, false, false); - hadc_gain_set(PGA_GAIN_EIGHT, IA_GAIN_SIXTEEN); - uapi_adc_manual_sample((adc_channel_t)AFE_GADC_MODE); - g_afe_open_flag = true; - return SUITE_OK; -} - -static int hadc_open_test(int argc, char *argv[]) -{ - UNUSED(argc); - UNUSED(argv); - bool cali_en = (bool)strtol(argv[0], NULL, 0); - errcode_t ret = uapi_adc_init(ADC_CLOCK_NONE); - if (ret != ERRCODE_SUCC) { - return ret; - } - uapi_adc_power_en(AFE_HADC_MODE, true); - if (cali_en) { - adc_calibration(AFE_HADC_MODE, true, true, true); - g_afe_config.hadc_os_code = reg32(0x57036244); // hadc_os_code - g_afe_config.hadc_wt_b22 = reg32(0x570361B0); // hadc_wt_b22 - g_afe_config.hadc_wt_b21 = reg32(0x570361B4); // hadc_wt_b21 - g_afe_config.hadc_wt_b20 = reg32(0x570361B8); // hadc_wt_b20 - g_afe_config.hadc_wt_b19 = reg32(0x570361BC); // hadc_wt_b19 - g_afe_config.hadc_wt_b18 = reg32(0x570361C0); // hadc_wt_b18 - g_afe_config.hadc_wt_b17 = reg32(0x570361C4); // hadc_wt_b17 - g_afe_config.hadc_wt_b16 = reg32(0x570361C8); // hadc_wt_b16 - g_afe_config.hadc_wt_b15 = reg32(0x570361CC); // hadc_wt_b15 - g_afe_config.hadc_wt_b14 = reg32(0x570361D0); // hadc_wt_b14 - g_afe_config.hadc_wt_b13 = reg32(0x570361D4); // hadc_wt_b13 - g_afe_config.hadc_wt_b12 = reg32(0x570361D8); // hadc_wt_b12 - g_afe_config.hadc_wt_b11 = reg32(0x570361DC); // hadc_wt_b11 - g_afe_config.hadc_wt_b10 = reg32(0x570361E0); // hadc_wt_b10 - g_afe_config.hadc_wt_b9 = reg32(0x570361E4); // hadc_wt_b9 - g_afe_config.dac_code1 = reg32(0x570363D4); // dac_code1 - g_afe_config.dac_code2 = reg32(0x570363D8); // dac_code2 - } else { - afe_config_t afe_config = g_afe_config; - adc_set_cali_code(AFE_HADC_MODE, &afe_config); - } - uapi_adc_manual_sample(HADC_CHANNEL_0); - g_afe_open_flag = true; - return SUITE_OK; -} - -static int adc_auto_sample_test(int argc, char *argv[]) -{ - if (argc < 1) { - return SUITE_ERROR_BAD_PARAMS; - } - if (!g_afe_open_flag) { - return SUITE_TEST_FAILED; - } - adc_v152_gadc_channel_sel_t channel = (adc_v152_gadc_channel_sel_t)strtol(argv[0], NULL, 0); - uapi_adc_open_channel(channel); - int adc_value = 0; - adc_channel_t ch = channel <= SINGLE_END_AINN4 ? (adc_channel_t)AFE_GADC_MODE : HADC_CHANNEL_0; - uint32_t irq_sts = osal_irq_lock(); - for (int i = 0; i < ADC_AUTO_SAMPLE_TEST_TIMES; i++) { - adc_value = uapi_adc_auto_sample(ch); - suite_log_stringf("adc: 0x%x = %d\n", adc_value, adc_value); - } - UNUSED(adc_value); - osal_irq_restore(irq_sts); - return SUITE_OK; -} - -static int hadc_power_on(int argc, char *argv[]) -{ - UNUSED(argc); - UNUSED(argv); - uapi_adc_power_en(AFE_HADC_MODE, true); - adc_set_cali_code(AFE_HADC_MODE, &g_afe_config); - return SUITE_OK; -} - -static int hadc_power_off(int argc, char *argv[]) -{ - UNUSED(argc); - UNUSED(argv); - uapi_adc_power_en(AFE_HADC_MODE, false); - return SUITE_OK; -} - -#else -#define HAL_ADC_SAMPLE_NUMBER_CONFIG_0 10 /* Channel with buffer manual sample average number. */ -#define HAL_ADC_SAMPLE_NUMBER_CONFIG_1 10 /* Channel without buffer manual sample average number. */ -#define HAL_ADC_DISCARD_NUMBER_CONFIG_0 8 /* Channel with buffer manual sample discard number. */ -#define HAL_ADC_DISCARD_NUMBER_CONFIG_1 8 /* Channel without buffer manual sample discard number. */ - -#define adc_trans_sytick_to_voltage(x) ((float)(((float)(x) * 17) / 40960)) -#define adc_trans_sytick_to_voltage_diff(x) ((float)(((float)((x) - 2048) * 17) / 20480)) -// #define adc_trans_sytick_to_voltage_without_auto_scan(x) ((float)(((float)(x) * 18) / 40960)) -#define adc_trans_sytick_to_voltage_without_auto_scan(x) ((float)(((float)(x) * 18) / 40960)) - -static uint32_t g_adc_sample_times = 0; -static uint32_t g_adc_sample_discard = 0; -static uint32_t g_adc_sample_stick = 0; - -#define TESTADC_DISACRD_DELAY_MS 3 -#define MINIMUM_VOLTAGE_RANGE 2 -#define MAXIMUM_VOLTAGE_RANGE 17 - -static uint32_t adc_get_sample_times(void) -{ - return g_adc_sample_times; -} - -static uint32_t adc_get_sample_discard(void) -{ - return g_adc_sample_discard; -} - -static void adc_set_sample_stick(uint32_t stick) -{ - g_adc_sample_stick = stick; -} - -static uint32_t adc_get_sample_stick(void) -{ - return g_adc_sample_stick; -} - -static float adc_stick_transfer_voltage(uint16_t stick, adc_channel_t channel) -{ -#if defined(CONFIG_ADC_SUPPORT_AUTO_SCAN) - hal_adc_type_info_t *adc_cfg_info = NULL; - adc_cfg_info = adc_port_get_cfg(); - /* diff channel: (stick - 2048)/ 2048 * 1.8 ; */ - if (adc_cfg_info != NULL && adc_cfg_info[channel].channel_type == HAL_ADC_CHANNEL_TYPE_DIF_BUF) { - return adc_trans_sytick_to_voltage_diff(stick); - } else { - return adc_trans_sytick_to_voltage(stick); - } -#else - UNUSED(channel); - return adc_trans_sytick_to_voltage_without_auto_scan(stick); -#endif -} - -static bool adc_get_sample_result(float *voltage, uint8_t channel) -{ - uint32_t sample_number = 0; - uint32_t discard_number = 0; - uint32_t stick = 0; - uint32_t sample_zero_count = 0; - -#if defined(CONFIG_ADC_SUPPORT_AUTO_SCAN) - if (uapi_adc_auto_scan_is_enabled()) { return false; } -#endif /* CONFIG_ADC_SUPPORT_AUTO_SCAN */ - - if (channel >= ADC_CHANNEL_4) { - sample_number = HAL_ADC_SAMPLE_NUMBER_CONFIG_1; - discard_number = HAL_ADC_DISCARD_NUMBER_CONFIG_1; - } else { - sample_number = HAL_ADC_SAMPLE_NUMBER_CONFIG_0; - discard_number = HAL_ADC_DISCARD_NUMBER_CONFIG_0; - } - - if (g_adc_sample_times != 0) { - sample_number = adc_get_sample_times(); - } - - if (g_adc_sample_discard != 0) { - discard_number = adc_get_sample_discard(); - } - - /* after channel is enabled, sample result is error in previous samplings, need to be discarded */ - for (uint32_t i = 0; i < discard_number; i++) { - uapi_adc_manual_sample(ADC_CHANNEL_NONE); - uapi_tcxo_delay_ms((uint64_t)TESTADC_DISACRD_DELAY_MS); - } - - for (uint32_t i = 0; i < sample_number; i++) { - uint32_t irq_sts = osal_irq_lock(); - uint32_t sample_result = (uint32_t)uapi_adc_manual_sample(ADC_CHANNEL_NONE); - osal_printk("sample_result = %d.\r\n", sample_result); - if (sample_result == 0) { sample_zero_count++; } - stick += sample_result; - osal_irq_restore(irq_sts); - } - sample_number -= sample_zero_count; - if (sample_number > 0) { - stick = (stick / sample_number); - } else { - *voltage = 0; - return false; - } - - adc_set_sample_stick(stick); - *voltage = adc_stick_transfer_voltage((uint16_t)stick, channel); - - UNUSED(discard_number); - return true; -} - -/** - * @brief Get voltage by the channel. Available voltage rang is 0V ~ 1.7V. - * @param voltage The sample result of voltage. - * @param channel The adc channel. - * @return true when select channel success, false when seclect channel failed. - */ -static bool adc_get_voltage_by_channel(float *voltage, uint8_t channel) -{ - bool ret = false; - - uapi_adc_power_en(AFE_SCAN_MODE_MAX_NUM, true); - ret = uapi_adc_open_channel(channel); - if (ret == ERRCODE_SUCC) { - ret = adc_get_sample_result(voltage, channel); - if (ret) { - uapi_adc_close_channel(channel); - uapi_adc_power_en(AFE_SCAN_MODE_MAX_NUM, false); - return true; - } - } else { - osal_printk("uapi_adc_open_channel failed : %d\r\n", ret); - } - - *voltage = 0; - uapi_adc_close_channel(channel); - uapi_adc_power_en(AFE_SCAN_MODE_MAX_NUM, false); - return false; -} - - - -#if defined(CONFIG_ADC_SUPPORT_AUTO_SCAN) -static bool g_adc_scan_continue = false; -static void adc_callback(uint8_t ch, uint32_t *buffer, uint32_t length, bool *next) -{ - osal_printk("[IRQ]channel: %d, buffer:0x%x, len: %d. \r\n", ch, buffer, length); - uint64_t data = 0; -#if defined(CONFIG_ADC_SUPPORT_LONG_SAMPLE) - osal_printk("sample data head: %d %d %d %d\r\n", buffer[0], buffer[TEST_PARAM_ARGC_1], - buffer[TEST_PARAM_ARGC_2], buffer[TEST_PARAM_ARGC_3]); - osal_printk("sample data tail: %d %d %d %d\r\n", buffer[length - TEST_PARAM_ARGC_4], - buffer[length - TEST_PARAM_ARGC_3], buffer[length - TEST_PARAM_ARGC_2], buffer[length - TEST_PARAM_ARGC_1]); -#else - for (uint32_t i = 0; i < length; i++) { - osal_printk("[%d]data: %d\r\n", i, buffer[i]); - data += buffer[i]; - } - - if (length != 0) { - data = data / length; - } - osal_printk("average data: %d\r\n", (uint32_t)data); -#endif - *next = g_adc_scan_continue; - UNUSED(ch); - UNUSED(buffer); - UNUSED(length); - UNUSED(next); -} - -static int adc_stop_auto_scan(int argc, char *argv[]) -{ - adc_channel_t channel; - if (argc != 1) { /* 1: Indicates the number of input parameters */ - return SUITE_ERROR_BAD_PARAMS; - } - channel = (adc_channel_t)strtol(argv[0], NULL, 0); - if (uapi_adc_auto_scan_ch_disable((uint8_t)channel) == ERRCODE_SUCC) { - return SUITE_OK; - } else { - return SUITE_TEST_FAILED; - } -} - -static int adc_start_auto_scan(int argc, char *argv[]) -{ - pin_t pin; - pin_mode_t mode; -#if defined(CONFIG_ADC_SUPPORT_LONG_SAMPLE) - if (argc != 7) { /* 7: Indicates the number of input parameters */ - return SUITE_ERROR_BAD_PARAMS; - } -#else - if (argc != 6) { /* 6: Indicates the number of input parameters */ - return SUITE_ERROR_BAD_PARAMS; - } -#endif - adc_channel_t channel; - channel = (adc_channel_t)strtol(argv[0], NULL, 0); - g_adc_scan_continue = (bool)strtol(argv[TEST_PARAM_ARGC_1], NULL, 0); - pin = (pin_t)strtol(argv[TEST_PARAM_ARGC_2], NULL, 0); - mode = (pin_mode_t)strtol(argv[TEST_PARAM_ARGC_3], NULL, 0); - adc_scan_config_t config = { - .type = (uint8_t)strtol(argv[TEST_PARAM_ARGC_4], NULL, 0), - .threshold_l = 0.5, /* 0.5: Threshold scan volatage(v) lower limit. */ - .threshold_h = 1.5, /* 1.5: Threshold scan volatage(v) upper limit. */ - .freq = (uint8_t)strtol(argv[TEST_PARAM_ARGC_5], NULL, 0), -#if defined(CONFIG_ADC_SUPPORT_LONG_SAMPLE) - .long_sample_time = (uint32_t)strtol(argv[TEST_PARAM_ARGC_6], NULL, 0), -#endif - }; - osal_printk("chan: %d, freq: %d\r\n", channel, config.freq); -#if defined(CONFIG_ADC_SUPPORT_LONG_SAMPLE) - osal_printk("long_sample_time = %d\n", config.long_sample_time); -#endif - - uapi_pin_set_mode(pin, mode); - uapi_adc_power_en(AFE_SCAN_MODE_MAX_NUM, true); - if (uapi_adc_auto_scan_ch_enable((uint8_t)channel, config, adc_callback) == ERRCODE_SUCC) { - return SUITE_OK; - } else { - return SUITE_TEST_FAILED; - } -} -#endif /* CONFIG_ADC_SUPPORT_AUTO_SCAN */ -#endif /* CONFIG_ADC_SUPPORT_AFE */ -bool battery_get_voltage_by_channel(float *voltage, uint8_t channel) -{ - -#if defined(CONFIG_ADC_SUPPORT_AFE) - // uapi_suite_add_function("gadc_open_test", "GAFE init & enable test ", gadc_open_test); - // uapi_suite_add_function("hadc_open_test", "HAFE init & enable test ", hadc_open_test); - // uapi_suite_add_function("auto_sample_test", "AFE auto sample test Params: ", - // adc_auto_sample_test); - // uapi_suite_add_function("hadc_power_off", "HAFE low power test, power off hafe", hadc_power_off); - // uapi_suite_add_function("hadc_power_on", "HAFE low power test, power on hafe ", hadc_power_on); -#else - uapi_adc_init(ADC_CLOCK_500KHZ); - // uapi_adc_power_en(AFE_SCAN_MODE_MAX_NUM, true); - // uapi_suite_add_function("adc_manual_test", "Params: , , ," - // ", ", adc_manual_test); - // adc_channel_t channel; - - uint64_t time1, time2; - uint32_t param_index = 0; - // channel = (adc_channel_t)strtol(argv[param_index++], NULL, 0); - // g_adc_sample_times = (uint32_t)strtol(argv[param_index++], NULL, 0); - // g_adc_sample_discard = (uint32_t)strtol(argv[param_index++], NULL, 0); - // pin = (pin_t)strtol(argv[param_index++], NULL, 0); - // mode = (pin_mode_t)strtol(argv[param_index++], NULL, 0); - osal_printk("channel: %d, sample times: %d, discard: %d.\r\n", channel, g_adc_sample_times, g_adc_sample_discard); - - // uapi_pin_set_mode(pin, mode); -#if defined(CONFIG_ADC_SUPPORT_AUTO_SCAN) - uapi_adc_auto_scan_disable(); -#endif /* CONFIG_ADC_SUPPORT_AUTO_SCAN */ - // osal_printk("PINMUX SET DONE\r\n"); - - time1 = uapi_tcxo_get_us(); - - if (!adc_get_voltage_by_channel(voltage, channel)) { - osal_printk("adc get sample result failed.\r\n"); - return SUITE_TEST_FAILED; - } - time2 = uapi_tcxo_get_us(); - - osal_printk("tick: %d, Sample time: %d. \r\n", adc_get_sample_stick(), - (uint64_t)(time2 - time1)); - osal_printk("voltage: %.4f.\r\n", voltage); - - -#if defined(CONFIG_ADC_SUPPORT_AUTO_SCAN) - // uapi_suite_add_function("adc_start_auto_scan", "Params: , , , ," - // ", ", adc_start_auto_scan); - // uapi_suite_add_function("adc_stop_auto_scan", "Params: ", adc_stop_auto_scan); -#endif /* CONFIG_ADC_SUPPORT_AUTO_SCAN */ -#endif /* CONFIG_ADC_SUPPORT_AFE */ - return true; -} diff --git a/code/sdk/application/battery/hal/battery_hal.c b/code/sdk/application/battery/hal/battery_hal.c new file mode 100644 index 000000000..85452d894 --- /dev/null +++ b/code/sdk/application/battery/hal/battery_hal.c @@ -0,0 +1,25 @@ +/** + * Copyright (c) @CompanyNameMagicTag 2022-2022. All rights reserved. \n + * + * Description: Test adc source \n + * Author: @CompanyNameTag \n + * History: \n + * 2022-08-16, Create file. \n + */ +#include "battery_service.h" +#include "battery_hal.h" + +uint8_t battery_get_battery_temp(float *temp) +{ + return batteryservice_get_battery_temp(temp); +} +uint8_t battery_get_pcb_temp(float *temp) +{ + + return batteryservice_get_pcb_temp(temp); +} +uint8_t battery_get_voltage(float *voltage) +{ + return batteryservice_get_voltage(voltage); +} + diff --git a/code/sdk/application/battery/battery.h b/code/sdk/application/battery/hal/battery_hal.h similarity index 64% rename from code/sdk/application/battery/battery.h rename to code/sdk/application/battery/hal/battery_hal.h index 927e436db..bb53cda80 100644 --- a/code/sdk/application/battery/battery.h +++ b/code/sdk/application/battery/hal/battery_hal.h @@ -7,8 +7,8 @@ * 2022-08-16, Create file. \n */ -#ifndef BATTERY_H__ -#define BATTERY_H__ +#ifndef BATTERY_HAL_H__ +#define BATTERY_HAL_H__ #ifdef __cplusplus #if __cplusplus @@ -16,27 +16,19 @@ extern "C" { #endif /* __cplusplus */ #endif /* __cplusplus */ -/** - * @defgroup testcase_adc ADC - * @ingroup testcase - * @{ - */ - -/** - * @if Eng - * @brief Add the testcase of adc. - * @else - * @brief 添加ADC测试用例 - * @endif - */ -bool battery_get_voltage_by_channel(float *voltage, uint8_t channel); - +uint8_t battery_get_battery_temp(float *temp); +uint8_t battery_get_pcb_temp(float *temp); /** * return 电池百分比 0~100 * 参数指针返回 真实电压 voltage */ uint8_t battery_get_voltage(float *voltage); +/** + * return 0 not charged, 1 charging +*/ +uint8_t get_charge_stat(void); + #ifdef __cplusplus #if __cplusplus } diff --git a/code/sdk/application/battery/service/battery_service.c b/code/sdk/application/battery/service/battery_service.c new file mode 100644 index 000000000..7c9065a9e --- /dev/null +++ b/code/sdk/application/battery/service/battery_service.c @@ -0,0 +1,546 @@ +/** + * Copyright (c) @CompanyNameMagicTag 2022-2022. All rights reserved. \n + * + * Description: Test adc source \n + * Author: @CompanyNameTag \n + * History: \n + * 2022-08-16, Create file. \n + */ + +#include "adc.h" +#define TEST_PARAM_ARGC_1 1 +#define TEST_PARAM_ARGC_2 2 +#define TEST_PARAM_ARGC_3 3 +#define TEST_PARAM_ARGC_4 4 +#define TEST_PARAM_ARGC_5 5 +#define TEST_PARAM_ARGC_6 6 +#define TEST_PARAM_ARGC_7 7 +#define TEST_PARAM_4_BYTES 4 +#define TEST_PARAM_8_BYTES 8 +typedef enum { + SUITE_OK = 0, + SUITE_UNKNOWN_FUNCTION = -1, + SUITE_ERROR_TIMED_OUT = -2, + SUITE_ERROR_BAD_PARAMS = -3, + SUITE_ERROR_PIN_ALLOCATION = -4, + SUITE_ERROR_PIN_DEALLOCATION = -5, + SUITE_ERROR_UNEXPECTED_INTERRUPT = -6, + SUITE_ALLOC_FAILED = -7, + SUITE_CONFIG_FAILED = -8, + SUITE_TEST_FAILED = -254, +} batteryservice_error_e; + +#if defined(CONFIG_ADC_SUPPORT_AFE) + +#error CONFIG_ADC_SUPPORT_AFE + +#include "hal_adc_v152.h" +#include "hal_adc_v152_regs_op.h" +#else +#include "hal_adc_v151.h" +#include "hal_adc_v151_regs_op.h" +#endif + +#include "adc_porting.h" +#include "pinctrl.h" +#include "debug_print.h" +#include "soc_osal.h" +#include "tcxo.h" +#include "irmalloc.h" +#include "errcode.h" +#include "common_def.h" + +#include "chip_core_irq.h" +#include "chip_io.h" +#include "gpio.h" +#include "pm_veto.h" + +#include "rtc.h" +#include "timer.h" +#include "systick.h" + +#include "battery_hal.h" + +#define HAL_ADC_SAMPLE_NUMBER_CONFIG_0 10 /* Channel with buffer manual sample average number. */ +#define HAL_ADC_SAMPLE_NUMBER_CONFIG_1 10 /* Channel without buffer manual sample average number. */ +#define HAL_ADC_DISCARD_NUMBER_CONFIG_0 8 /* Channel with buffer manual sample discard number. */ +#define HAL_ADC_DISCARD_NUMBER_CONFIG_1 8 /* Channel without buffer manual sample discard number. */ + +#define adc_trans_sytick_to_voltage(x) ((float)(((float)(x) * 17) / 40960)) +#define adc_trans_sytick_to_voltage_diff(x) ((float)(((float)((x) - 2048) * 17) / 20480)) +#define adc_trans_systick_to_battery_ntc(x) ((float)(((float)(x) * 18) / 40960)) +#define adc_trans_systick_to_pcb_ntc(x) ((float)(((float)(x) * 17) / 40960)) +#define adc_trans_systick_to_battery_voltage(x) ((float)((float)(x) / 749.75838433852f)) +#define batteryservice_VOLTAGE_MAX (4.2f) +#define batteryservice_VOLTAGE_MIN (3.2f) + +#define ADC_CHANNEL_BAT_VOLTAGE ADC_CHANNEL_2 +#define ADC_CHANNEL_BAT_TEMP ADC_CHANNEL_0 +#define ADC_CHANNEL_PCB_TEMP ADC_CHANNEL_5 + +static uint32_t g_adc_sample_times = 0; +static uint32_t g_adc_sample_discard = 0; +static uint32_t g_adc_sample_stick = 0; + +#define TESTADC_DISACRD_DELAY_MS 3 +#define MINIMUM_VOLTAGE_RANGE 2 +#define MAXIMUM_VOLTAGE_RANGE 17 + + +typedef struct { + float battery_voltage; + float battery_ntc_temp; + float pcb_ntc_temp; + bool usb_plugged; +} battery_info_t; + + +static battery_info_t current_battery_info={0}; +static uint32_t adc_get_sample_times(void) +{ + return g_adc_sample_times; +} + +static uint32_t adc_get_sample_discard(void) +{ + return g_adc_sample_discard; +} + +static void adc_set_sample_stick(uint32_t stick) +{ + g_adc_sample_stick = stick; +} + +static uint32_t adc_get_sample_stick(void) +{ + return g_adc_sample_stick; +} + +static float adc_stick_transfer_voltage(uint16_t stick, adc_channel_t channel) +{ + + UNUSED(channel); + return adc_trans_sytick_to_voltage_without_auto_scan(stick); +} + +static bool adc_get_sample_result(float *voltage, uint8_t channel) +{ + uint32_t sample_number = 0; + uint32_t discard_number = 0; + uint32_t stick = 0; + uint32_t sample_zero_count = 0; + + if (channel >= ADC_CHANNEL_4) { + sample_number = HAL_ADC_SAMPLE_NUMBER_CONFIG_1; + discard_number = HAL_ADC_DISCARD_NUMBER_CONFIG_1; + } else { + sample_number = HAL_ADC_SAMPLE_NUMBER_CONFIG_0; + discard_number = HAL_ADC_DISCARD_NUMBER_CONFIG_0; + } + + if (g_adc_sample_times != 0) { + sample_number = adc_get_sample_times(); + } + + if (g_adc_sample_discard != 0) { + discard_number = adc_get_sample_discard(); + } + + /* after channel is enabled, sample result is error in previous samplings, need to be discarded */ + for (uint32_t i = 0; i < discard_number; i++) { + uapi_adc_manual_sample(ADC_CHANNEL_NONE); + uapi_tcxo_delay_ms((uint64_t)TESTADC_DISACRD_DELAY_MS); + } + + for (uint32_t i = 0; i < sample_number; i++) { + uint32_t irq_sts = osal_irq_lock(); + uint32_t sample_result = (uint32_t)uapi_adc_manual_sample(ADC_CHANNEL_NONE); + // osal_printk("sample_result = %d.\r\n", sample_result); + if (sample_result == 0) { sample_zero_count++; } + stick += sample_result; + osal_irq_restore(irq_sts); + } + sample_number -= sample_zero_count; + if (sample_number > 0) { + stick = (stick / sample_number); + } else { + *voltage = 0; + return false; + } + + adc_set_sample_stick(stick); + + + if(channel == 2) + *voltage = adc_trans_systick_to_battery_voltage(stick); + else if (channel == 0) + *voltage = adc_trans_systick_to_battery_ntc(stick); + else if (channel == 5) + *voltage = adc_trans_systick_to_pcb_ntc(stick); + ///osal_printk("channel = %d , tick = %d , voltage = %.04f.\r\n", channel,stick,*voltage); + + UNUSED(discard_number); + return true; +} + +/** + * @brief Get voltage by the channel. Available voltage rang is 0V ~ 1.7V. + * @param voltage The sample result of voltage. + * @param channel The adc channel. + * @return true when select channel success, false when seclect channel failed. + */ +static bool adc_get_voltage_by_channel(float *voltage, uint8_t channel) +{ + bool ret = false; + + uapi_adc_power_en(AFE_SCAN_MODE_MAX_NUM, true); + ret = uapi_adc_open_channel(channel); + if (ret == ERRCODE_SUCC) { + ret = adc_get_sample_result(voltage, channel); + if (ret) { + uapi_adc_close_channel(channel); + uapi_adc_power_en(AFE_SCAN_MODE_MAX_NUM, false); + return true; + } + } else { + osal_printk("uapi_adc_open_channel failed : %d\r\n", ret); + } + + *voltage = 0; + uapi_adc_close_channel(channel); + uapi_adc_power_en(AFE_SCAN_MODE_MAX_NUM, false); + return false; +} + +bool batteryservice_get_voltage_by_channel(float *voltage, uint8_t channel) +{ + + uapi_adc_init(ADC_CLOCK_500KHZ); + uint64_t time1, time2; + uint32_t param_index = 0; + // osal_printk("channel: %d\r\n", channel); + time1 = uapi_tcxo_get_us(); + if (!adc_get_voltage_by_channel(voltage, channel)) { + osal_printk("adc get sample result failed.\r\n"); + return SUITE_TEST_FAILED; + } + time2 = uapi_tcxo_get_us(); + // osal_printk("tick: %d, Sample time: %d. \r\n", adc_get_sample_stick(), + // (uint64_t)(time2 - time1)); + // osal_printk("voltage: %.4f.\r\n", voltage); + // osal_printk("channel %d, voltage: %.4f.\r\n", channel,*voltage); + uapi_adc_deinit(); + return true; +} + + + + +/***** + * AGPIO_R9 输出低停止充电,AGPIO_L29 输入低充电中,AGPIO_L20输出高 0.2C充电 +*/ +#include "hal_gpio.h" +#include "gpio.h" +#define GPIO_PIN_ENABLE_CHARGE S_AGPIO_R9 +#define GPIO_PIN_ENABLE_CHARGE_0_2C S_AGPIO_L20 //低电流充电 +#define GPIO_PIN_CHARGE_STAT S_AGPIO_L29 +void disable_charge(void) +{ + // PRINT("disable_charge\r\n"); + uapi_pin_set_mode(GPIO_PIN_ENABLE_CHARGE, (pin_mode_t)HAL_PIO_FUNC_GPIO); + uapi_gpio_set_dir(GPIO_PIN_ENABLE_CHARGE, GPIO_DIRECTION_OUTPUT); + uapi_tcxo_delay_ms(20); + uapi_gpio_set_val(GPIO_PIN_ENABLE_CHARGE, GPIO_LEVEL_HIGH); + uint8_t level = uapi_gpio_get_output_val(GPIO_PIN_ENABLE_CHARGE); + // PRINT("GPIO_PIN_ENABLE_CHARGE uapi_gpio_get_output_val %d\r\n",level); +} + +void enable_charge(void) +{ + // PRINT("enable_charge\r\n"); + uapi_pin_set_mode(GPIO_PIN_ENABLE_CHARGE, (pin_mode_t)HAL_PIO_FUNC_GPIO); + uapi_gpio_set_dir(GPIO_PIN_ENABLE_CHARGE, GPIO_DIRECTION_OUTPUT); + uapi_tcxo_delay_ms(20); + uapi_gpio_set_val(GPIO_PIN_ENABLE_CHARGE, GPIO_LEVEL_LOW); + uint8_t level = uapi_gpio_get_output_val(GPIO_PIN_ENABLE_CHARGE); + // PRINT("GPIO_PIN_ENABLE_CHARGE uapi_gpio_get_output_val %d\r\n",level); + +} + + +void enable_02c(void) +{ + // PRINT("enable_charge_02c\r\n"); + uapi_pin_set_mode(GPIO_PIN_ENABLE_CHARGE_0_2C, (pin_mode_t)HAL_PIO_FUNC_GPIO); + uapi_gpio_set_dir(GPIO_PIN_ENABLE_CHARGE_0_2C, GPIO_DIRECTION_OUTPUT); + uapi_tcxo_delay_ms(20); + uapi_gpio_set_val(GPIO_PIN_ENABLE_CHARGE_0_2C, GPIO_LEVEL_LOW); //拉低低电流充电 + uint8_t level = uapi_gpio_get_output_val(GPIO_PIN_ENABLE_CHARGE_0_2C); + // PRINT("GPIO_PIN_ENABLE_CHARGE_0_2C uapi_gpio_get_output_val %d\r\n",level); +} + + +void disable_02c(void) +{ + // PRINT("disable_charge_02c\r\n"); + uapi_pin_set_mode(GPIO_PIN_ENABLE_CHARGE_0_2C, (pin_mode_t)HAL_PIO_FUNC_GPIO); + uapi_gpio_set_dir(GPIO_PIN_ENABLE_CHARGE_0_2C, GPIO_DIRECTION_OUTPUT); + uapi_tcxo_delay_ms(20); + uapi_gpio_set_val(GPIO_PIN_ENABLE_CHARGE_0_2C, GPIO_LEVEL_HIGH); //拉高正常电流充电 + uint8_t level = uapi_gpio_get_output_val(GPIO_PIN_ENABLE_CHARGE_0_2C); + // PRINT("GPIO_PIN_ENABLE_CHARGE_0_2C uapi_gpio_get_output_val %d\r\n",level); + +} + +#define ULP_WKUP_INT_STS 0x5702C1E0 +/** + * return 0 not charged, 1 charging +*/ +uint8_t get_charge_stat(void) +{ + uint16_t vbus_status = reg32_getbit(ULP_WKUP_INT_STS, 0x4); + uint16_t g_ulp_wkup_flag = readw(ULP_WKUP_INT_STS); + PRINT("get_charge_stat %02X %02X\r\n",vbus_status,g_ulp_wkup_flag); + if (vbus_status == 1) { + return 1; + } + + return 0; +} +static bool g_batter_service_initialled = false; +errcode_t uapi_battery_init(void); +#include "tcxo.h" +uint8_t batteryservice_get_voltage(float *voltage) +{ + + // if (g_batter_service_initialled == false) + // { + // uapi_battery_init(); + // g_batter_service_initialled = true; + // *voltage = 0; + // return 0; + // } + uint8_t percent = 0; + *voltage = current_battery_info.battery_voltage; + if (*voltage <= batteryservice_VOLTAGE_MIN) + return 0; + if (*voltage >= batteryservice_VOLTAGE_MAX) + return 100; + percent = (*voltage - batteryservice_VOLTAGE_MIN)*100/(batteryservice_VOLTAGE_MAX - batteryservice_VOLTAGE_MIN) ; + return percent; +} +uint8_t batteryservice_get_battery_temp(float *temp) +{ + + // if (g_batter_service_initialled == false) + // { + // uapi_battery_init(); + // g_batter_service_initialled = true; + // *temp = 0; + // return 0; + // } + + *temp = current_battery_info.battery_ntc_temp; + + return 0; +} +uint8_t batteryservice_get_pcb_temp(float *temp) +{ + + // if (g_batter_service_initialled == false) + // { + // uapi_battery_init(); + // g_batter_service_initialled = true; + // *temp = 0; + // return 0; + // } + *temp = current_battery_info.pcb_ntc_temp; + return 0; +} +/**************************Battery Check Timer***********************/ +/** + * 电池电压读取逻辑: + * 充电10秒,停止充电1秒,并读取电压。之后再开始充电10秒,再停止充电一秒,读取电压,然后再开始充电。。。。依此类推。 + * **/ +#define USE_APP_TIMER 1 + +#include "cmsis_os2.h" +#include "input_app.h" +#if USE_APP_TIMER +osTimerId_t g_battery_timer = NULL; +#else +timer_handle_t g_battery_timer = {0}; +#endif +static bool g_bat_timer_is_running = false; +#define DISABLE_CHARGE_CHECK_MS 1000 +#define ENABLE_CHARGE_TIMEOUT_MS 10000 +bool last_battery_charge_enable_status=false; // true上次刚设置在充电状态,false 上次设置不在充电状态。注意这个是充电IC的充电开关设置,并非真正处于充电状态的标识。 +static unsigned long g_app_queue; +#define BATTERY_CMD_CHECK_VOLTAGE 0x11 +#define BATTERY_CMD_DISABLE_CHARGE 0x12 + +#if USE_APP_TIMER +static void battery_check_timer_callback(void* data); +#else +static void battery_check_timer_callback(uint32_t data); +#endif +static void battery_timer_start_check_released(uint32_t rtc_ms) +{ + // bool start = false; + // if (!g_bat_timer_is_running) { + // g_bat_timer_is_running = true; + // start = true; + // } + + +#if USE_APP_TIMER + if (g_bat_timer_is_running) osTimerStop(g_battery_timer); + osTimerStart(g_battery_timer, rtc_ms); +#else + if (g_bat_timer_is_running) uapi_rtc_stop(g_battery_timer); + uapi_rtc_start(g_battery_timer, rtc_ms, battery_check_timer_callback, 1); +#endif + g_bat_timer_is_running = true; +} +void do_battery_check_msg(int cmd); +static void battery_check_and_enable_charge(void); +#if USE_APP_TIMER +static void battery_check_timer_callback(void * data) +#else +static void battery_check_timer_callback(uint32_t data) +#endif +{ + unused(data); + + g_bat_timer_is_running = false; + if(last_battery_charge_enable_status == true){ + // do_battery_check_msg(BATTERY_CMD_DISABLE_CHARGE); + disable_charge(); + uapi_tcxo_delay_ms(20); + battery_timer_start_check_released(DISABLE_CHARGE_CHECK_MS); + last_battery_charge_enable_status = false; + }else{ + + // do_battery_check_msg(BATTERY_CMD_CHECK_VOLTAGE); + battery_check_and_enable_charge(); + uapi_tcxo_delay_ms(20); + battery_timer_start_check_released(ENABLE_CHARGE_TIMEOUT_MS); + last_battery_charge_enable_status = true; + } + +} +void uapi_battery_deinit(void) +{ + /* Stop the time and clear the pin map */ +#if USE_APP_TIMER + osTimerStop(g_battery_timer); + osTimerDelete(g_battery_timer); +#else + uapi_rtc_stop(g_battery_timer); + uapi_rtc_delete(g_battery_timer); +#endif + g_bat_timer_is_running = false; + g_battery_timer = NULL; +} + + + +void do_battery_check_msg(int cmd) +{ + int ret; + + common_notify_mail_t mail = {0}; + mail.comm.app = cmd; + ret = osal_msg_queue_write_copy(g_app_queue, (void *)&mail, + sizeof(common_notify_mail_t), 0); + if (ret != OSAL_SUCCESS) { + PRINT("Error battery Check MSG 0x%02X send failed! err=0x%x! \r\n",cmd, ret); + } + +} + +static void battery_check_and_enable_charge(void) +{ + batteryservice_get_voltage_by_channel(¤t_battery_info.battery_voltage,ADC_CHANNEL_BAT_VOLTAGE); + uapi_tcxo_delay_ms(20); + batteryservice_get_voltage_by_channel(¤t_battery_info.battery_ntc_temp,ADC_CHANNEL_BAT_TEMP); + uapi_tcxo_delay_ms(20); + batteryservice_get_voltage_by_channel(¤t_battery_info.pcb_ntc_temp,ADC_CHANNEL_PCB_TEMP); + uapi_tcxo_delay_ms(20); + enable_charge(); +} +static void battery_check_task(void const *arg) +{ + unused(arg); + int32_t ret; + common_notify_mail_t mail; + uint32_t msgsize = (uint32_t)sizeof(common_notify_mail_t); + +#if USE_APP_TIMER + g_battery_timer = osTimerNew((osTimerFunc_t)battery_check_timer_callback, osTimerPeriodic, NULL, NULL); +#else + // ret = uapi_rtc_init(); + + // ret |= uapi_rtc_adapter(0, RTC_0_IRQN, irq_prio(RTC_0_IRQN)); /* 1: using timer1 */ + // if (ret != ERRCODE_SUCC) { + // PRINT("uapi_rtc_init FAILED 0x%x", ret); + // return ; + // } + ret = uapi_rtc_create(RTC_1, &g_battery_timer); /* 1: using timer1 */ + if (ret != ERRCODE_SUCC) { + PRINT("uapi_rtc_create FAILED 0x%x", ret); + return ; + } + +#endif + + //开始timer + battery_timer_start_check_released(ENABLE_CHARGE_TIMEOUT_MS); + + while (1) { + ret = osal_msg_queue_read_copy(g_app_queue, (void *)&mail, &msgsize, + OSAL_MSGQ_WAIT_FOREVER); + if (ret != OSAL_SUCCESS) { + continue; + } + + if (mail.comm.app == BATTERY_CMD_CHECK_VOLTAGE) { + battery_check_and_enable_charge(); + uapi_tcxo_delay_ms(20); + }else if (mail.comm.app == BATTERY_CMD_DISABLE_CHARGE) { + disable_charge(); + uapi_tcxo_delay_ms(20); + } + } +} + +errcode_t uapi_battery_init(void) +{ + if (osal_msg_queue_create("battery_queue", APP_BOARD_MSG_COUNT, &g_app_queue, + 0, sizeof(common_notify_mail_t)) != ERRCODE_SUCC) { + PRINT("[battery][service] app create mail fail\n"); + return ERRCODE_FAIL; + } + + + osal_task *task_handle = osal_kthread_create((osal_kthread_handler)battery_check_task, NULL, + "battery_service", APP_BOARD_TASK_SIZE); + if (task_handle == NULL) { + osal_msg_queue_is_full(g_app_queue); + PRINT("create battery service thread fail!\r\n"); + return ERRCODE_FAIL; + } + + osal_kthread_set_priority(task_handle, APP_BOARD_TASK_PRIO); + return ERRCODE_SUCC; +} + +void battery_service_resume(void) +{ + PRINT("battery_service resume!\r\n"); + battery_check_timer_callback(0); +} +void battery_service_suspend(void) +{ + PRINT("battery_service suspend!\r\n"); +} \ No newline at end of file diff --git a/code/sdk/application/battery/service/battery_service.h b/code/sdk/application/battery/service/battery_service.h new file mode 100644 index 000000000..5e64cc8da --- /dev/null +++ b/code/sdk/application/battery/service/battery_service.h @@ -0,0 +1,35 @@ +/** + * Copyright (c) @CompanyNameMagicTag 2022-2022. All rights reserved. \n + * + * Description: Test adc header \n + * Author: @CompanyNameTag \n + * History: \n + * 2022-08-16, Create file. \n + */ + +#ifndef BATTERY_H__ +#define BATTERY_H__ + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cplusplus */ +#endif /* __cplusplus */ + +#include "stdint.h" +#include "errcode.h" + +uint8_t batteryservice_get_battery_temp(float *temp); +uint8_t batteryservice_get_pcb_temp(float *temp); +uint8_t batteryservice_get_voltage(float *voltage); +errcode_t uapi_battery_init(void); +void uapi_battery_deinit(void); +void battery_service_resume(void); +void battery_service_suspend(void); +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cplusplus */ +#endif /* __cplusplus */ + +#endif \ No newline at end of file diff --git a/code/sdk/application/battery/test/battery_at_cmd.c b/code/sdk/application/battery/test/battery_at_cmd.c new file mode 100644 index 000000000..2024e9aa2 --- /dev/null +++ b/code/sdk/application/battery/test/battery_at_cmd.c @@ -0,0 +1,77 @@ +#include "at_cmd_api.h" +#include "pm_control.h" +#include "debug_print.h" +#include "battery_hal.h" +#define ARRAY_COUNT(array) (sizeof(array) / sizeof(array[0])) +#define BATTERY_MAX_ARGC 8 +#define BATTERY_MAX_ARGV_LEN 64 + +#define BATTERY_SUCCESS 0 +#define BATTERY_FAILED (-1) +static int ConvertCmdToParam(uint8_t *para, uint32_t paraLen, + uint8_t argv[BATTERY_MAX_ARGC][BATTERY_MAX_ARGV_LEN], uint32_t* argc) +{ + uint32_t pos = 0; + *argc = 0; + + for (uint32_t i = 0; i < paraLen; i++) { + if ((para[i] == ' ' || para[i] == '\n') && pos != 0) { + argv[*argc][pos] = '\0'; + *argc += 1; + pos = 0; + if (*argc >= BATTERY_MAX_ARGC) { + return BATTERY_FAILED; + } + } else { + argv[*argc][pos] = para[i]; + pos++; + if (pos >= BATTERY_MAX_ARGV_LEN) { + return BATTERY_FAILED; + } + } + } + if (pos != 0) { + *argc += 1; + } + + return BATTERY_SUCCESS; +} + +static uint32_t battery_do_test(uint8_t *para, uint32_t paraLen, char *strCommonCmd) +{ + UNUSED(strCommonCmd); + uint8_t argv[BATTERY_MAX_ARGC][BATTERY_MAX_ARGV_LEN] = { 0 }; + uint32_t argc = 0; + + int ret = ConvertCmdToParam(para, paraLen, argv, &argc); + if (ret != BATTERY_SUCCESS) { + PRINT("BATTERYTEST ATCMD Convert Command Failed\n"); + return ERRCODE_FAIL; + } + + if (argc != 1) { + PRINT("BATTERYTEST ATCMD Set Parameter Failed\n"); + return ERRCODE_FAIL; + } + char *mode = (char*)argv[0]; + if (strcmp(mode, "enable") == 0) { + enable_charge(); + } else if (strcmp(mode, "disable") == 0) { + disable_charge(); + } else if (strcmp(mode, "en02c") == 0) { + enable_02c(); + } else if (strcmp(mode, "dis02c") == 0) { + disable_02c(); + } + return ERRCODE_SUCC; +} + +static const at_cmd_table_t g_battery_cmd[] = { + { (char *)"AT^CHARGETEST", battery_do_test, (char *)"enable" }, +}; + +at_cmd_table_t *get_battery_cmd_table(uint32_t *cmd_count) +{ + *cmd_count = ARRAY_COUNT(g_battery_cmd); + return (at_cmd_table_t *)g_battery_cmd; +} diff --git a/code/sdk/application/battery/test/battery_at_cmd.h b/code/sdk/application/battery/test/battery_at_cmd.h new file mode 100644 index 000000000..d2b1c29d3 --- /dev/null +++ b/code/sdk/application/battery/test/battery_at_cmd.h @@ -0,0 +1,32 @@ +/** + * Copyright (c) @CompanyNameMagicTag 2022-2022. All rights reserved. \n + * + * Description: Provides at cmd register func \n + * Author: @CompanyNameTag \n + * History: \n + * 2022-07-20, Create file. \n + */ +#ifndef BATTERY_AT_PROCESS_H +#define BATTERY_AT_PROCESS_H + +#include +#include +#include "errcode.h" +#include "soc_osal.h" +#include "at_cmd_api.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cplusplus */ +#endif /* __cplusplus */ + +at_cmd_table_t *get_battery_cmd_table(uint32_t *cmd_count); + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cplusplus */ +#endif /* __cplusplus */ + +#endif diff --git a/code/sdk/application/wearable/nativeapp/CMakeLists.txt b/code/sdk/application/wearable/nativeapp/CMakeLists.txt index a5eda243a..5bb4508cd 100755 --- a/code/sdk/application/wearable/nativeapp/CMakeLists.txt +++ b/code/sdk/application/wearable/nativeapp/CMakeLists.txt @@ -9,6 +9,8 @@ set(PUBLIC_HEADER ) set(PRIVATE_HEADER + ${ROOT_DIR}/open_source/openharmony/foundation/ace/ace_engine_lite/interfaces/base + ${ROOT_DIR}/open_source/openharmony/third_party/cJSON ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/main/include ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/clock/include ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bloodoxygen/include @@ -35,16 +37,23 @@ set(PRIVATE_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/screensetting/include ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/uiservice/include ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/uisample/include + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/ + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/UIInitializer/ + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/InitComponent/include ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/uisample/uitest/framework/include ${UI_SAMPLE_ROOT}/components ${CMAKE_CURRENT_SOURCE_DIR}/../service/smart_voice/smart_voice_service/interfaces/innerkits/native_c/include ${CMAKE_CURRENT_SOURCE_DIR}/../service/smart_voice/voice_engine_hal/interfaces/innerkits/native_c/include ${CMAKE_CURRENT_SOURCE_DIR}/../ohos_deps ${CMAKE_CURRENT_SOURCE_DIR}/../../battery - + ${CMAKE_CURRENT_SOURCE_DIR}/../../../drivers/drivers/driver/rtc_unified + ${CMAKE_CURRENT_SOURCE_DIR}/../../../kernel/liteos/liteos_v207.1.0/Huawei_LiteOS/compat/linux/include/uapi/linux/ + ${ROOT_DIR}/middleware/services/gui/uikit/proprietary/src/utils/innerkits ${ROOT_DIR}/middleware/services/gui/uikit/proprietary/include ${ROOT_DIR}/middleware/services/gui/uikit/proprietary/src/ui/frameworks + ${ROOT_DIR}/middleware/services/gui/uikit/proprietary/include/service + ${ROOT_DIR}/middleware/services/gui/uikit/ui/interfaces/innerkits ${ROOT_DIR}/open_source/openharmony/foundation/graphic/ui/interfaces/kits/events ${ROOT_DIR}/open_source/openharmony/foundation/graphic/ui/interfaces/kits @@ -71,6 +80,7 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativelauncher/src/slices/main/MainView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/main/src/MainViewSample.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/main/src/MainPresenterSample.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/main/src/ModelListenerSample.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/main/src/PresenterTask.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/main/src/HealthModel.cpp @@ -180,6 +190,15 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/settings/src/SettingModel.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/settings/src/SettingItemView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/key/src/KeyInputListener.cpp + + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/blood/src/BloodView.cpp + + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/dial/src/Digital_clockView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/dial/src/DialView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/dial/src/DialPresenter.cpp + + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/CompassControlView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/CompassCalibrationView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/CompassModel.cpp diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h b/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h index 698decade..bacf7b3f3 100755 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h @@ -45,6 +45,8 @@ typedef enum : uint16_t { VIEW_INDOORWALK, VIEW_REBOOT, VIEW_UISAMPLE, + VIEW_DIAL,//切换表盘 + VIEW_MAX_INTER_APP, // 在此之前添加native应用ID. VIEW_EXTERN_APP = 0xFFFE, // 三方应用 VIEW_INVALIDE_APP = 0xFFFF, diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h b/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h index 7b07cbf76..93cb6f5fd 100755 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h @@ -1,54 +1,55 @@ -/* - * Copyright (c) 2020-2021 CompanyNameMagicTag. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. +/*** + * @Author: Caisking 3449750381@qq.com + * @Date: 2023-12-13 19:33:14 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-01-17 20:04:22 + * @FilePath: /FD230/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h + * @Description: + * @ + * @Copyright (c) 2024 by Caisking , All Rights Reserved. */ + #ifndef NATIVE_LAUNCHER_H #define NATIVE_LAUNCHER_H #include "AppViewIDs.h" -namespace OHOS { -class NativeLauncher { -public: - static NativeLauncher &GetInstance(void); - void InitNativeLauncher(void); - void InitMainSlice(void); - void InitMainSampleSlice(void); - void InitSettingSlice(void); - void InitApplistSlice(void); - void InitMainAlarmSlice(void); - void InitAlarmPopUpSlice(void); - void InitActivitySlice(void); - void InitWeekStepSlice(void); - void InitBluetoothSlice(void); - void InitWifiView(void); - void InitMainBloodOxyView(void); - void InitMainCallerLogView(void); - void InitMainMakePhoneView(void); - void InitCompassSlice(void); - void InitOfflineVoice(void); - void InitConnectPhoneSlice(void); - void InitMainTempSlice(void); - void InitIndoorWalkSlice(void); - void InitRebootSlice(void); - void InitUISampleSlice(void); -private: - void InitAllNativeSlices(void); +namespace OHOS +{ + class NativeLauncher + { + public: + static NativeLauncher &GetInstance(void); + void InitNativeLauncher(void); + void InitMainSlice(void); + void InitMainSampleSlice(void); + void InitSettingSlice(void); + void InitApplistSlice(void); + void InitMainAlarmSlice(void); + void InitAlarmPopUpSlice(void); + void InitActivitySlice(void); + void InitWeekStepSlice(void); + void InitBluetoothSlice(void); + void InitWifiView(void); + void InitMainBloodOxyView(void); + void InitMainCallerLogView(void); + void InitMainMakePhoneView(void); + void InitCompassSlice(void); + void InitOfflineVoice(void); + void InitConnectPhoneSlice(void); + void InitMainTempSlice(void); + void InitIndoorWalkSlice(void); + void InitRebootSlice(void); + void InitUISampleSlice(void); + void InitDialSlice(void); + + private: + void InitAllNativeSlices(void); - NativeLauncher(); - NativeLauncher(const NativeLauncher &); - NativeLauncher &operator=(const NativeLauncher &); - ~NativeLauncher(); -}; + NativeLauncher(); + NativeLauncher(const NativeLauncher &); + NativeLauncher &operator=(const NativeLauncher &); + ~NativeLauncher(); + }; } #endif // NATIVE_LAUNCHER_H diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/include/UiConfig.h b/code/sdk/application/wearable/nativeapp/nativelauncher/include/UiConfig.h index dd1cfaeda..ed306b143 100755 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/include/UiConfig.h +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/include/UiConfig.h @@ -12,311 +12,319 @@ #include "ohos_types.h" #include "graphic_config.h" -namespace OHOS { - #ifndef UNUSED - #define UNUSED(x) ((void)(x)) - #endif +namespace OHOS +{ +#ifndef UNUSED +#define UNUSED(x) ((void)(x)) +#endif - #define LA_HORIZONTAL_RESOLUTION 400 // watch width - #define LA_VERTICAL_RESOLUTION 400 // watch height - #define NORMAL_BUTTON_WIDTH 100 // normal button width - #define NORMAL_BUTTON_HEIGHT 50 // normal button height - #define NORMAL_MARGIN 5 // normal margin - #define DIAL_SQUARE 250 // watch plate sauqre - #define SETTING_ITEM_HEIGHT 100 // setting item height - #define UN_OPACITY 255 // UN_OPACITY +#define LA_HORIZONTAL_RESOLUTION 400 // watch width +#define LA_VERTICAL_RESOLUTION 400 // watch height +#define NORMAL_BUTTON_WIDTH 100 // normal button width +#define NORMAL_BUTTON_HEIGHT 50 // normal button height +#define NORMAL_MARGIN 5 // normal margin +#define DIAL_SQUARE 250 // watch plate sauqre +#define SETTING_ITEM_HEIGHT 100 // setting item height +#define UN_OPACITY 255 // UN_OPACITY - #define MILLESECOND 1 - #define SECOND 1000 // 1s 1000ms - #define MINUTE (60 * SECOND) // 1min 60s - #define HOUR (60 * MINUTE) // 1hour 60min +#define MILLESECOND 1 +#define SECOND 1000 // 1s 1000ms +#define MINUTE (60 * SECOND) // 1min 60s +#define HOUR (60 * MINUTE) // 1hour 60min - #define FONT_COMMON 20 // 20px - #define X_DRAG_OFFSET 20 - #define DOUBLES 2 +#define FONT_COMMON 20 // 20px +#define X_DRAG_OFFSET 20 +#define DOUBLES 2 - #define APP_RES_PATH "/user/res" - #define APP_MUSIC_PATH "/user/music" - #define APP_VIDEO_PATH "/user/video" +#define APP_RES_PATH "/user/res" +#define APP_MUSIC_PATH "/user/music" +#define APP_VIDEO_PATH "/user/video" static constexpr const char *CARD_CONFIG_PATH = "/user/cardconfig.bin"; - static constexpr const char *CLOCK_IAMGES = APP_RES_PATH"/clock/clock.bin"; - static constexpr const char *PLAYER_IAMGES = APP_RES_PATH"/player/player.bin"; - static constexpr const char *COMPASS_IAMGES = APP_RES_PATH"/compass/compass.bin"; - static constexpr const char *DROPDOWN_IAMGES = APP_RES_PATH"/dropdown/dropdown.bin"; - static constexpr const char *HEART_IAMGES = APP_RES_PATH"/heart/heart.bin"; - static constexpr const char *PNG_BLUETOOTH_HINTS_PATH = APP_RES_PATH"/BLUETOOTH_HINTS.bin"; - static constexpr const char *PNG_BLOODOXYGEN_IMAGE_PATH = APP_RES_PATH"/BLOODOXYGEN_VIEW.bin"; + static constexpr const char *CLOCK_IAMGES = APP_RES_PATH "/clock/clock.bin"; + static constexpr const char *PLAYER_IAMGES = APP_RES_PATH "/player/player.bin"; + static constexpr const char *COMPASS_IAMGES = APP_RES_PATH "/compass/compass.bin"; + static constexpr const char *DROPDOWN_IAMGES = APP_RES_PATH "/dropdown/dropdown.bin"; + static constexpr const char *HEART_IAMGES = APP_RES_PATH "/heart/heart.bin"; + static constexpr const char *PNG_BLUETOOTH_HINTS_PATH = APP_RES_PATH "/BLUETOOTH_HINTS.bin"; + static constexpr const char *PNG_BLOODOXYGEN_IMAGE_PATH = APP_RES_PATH "/BLOODOXYGEN_VIEW.bin"; - static constexpr const char *PNG_BLOOD_ICON_ENTER = APP_RES_PATH"/BLOOD_ICON_ENTER.bin"; + static constexpr const char *PNG_BLOOD_ICON_ENTER = APP_RES_PATH "/BLOOD_ICON_ENTER.bin"; - static constexpr const char *PNG_AGREEING_IMAGE_PATH = APP_RES_PATH"/AGREEING.bin"; - static constexpr const char *PNG_DISSGREE_IMAGE_PATH = APP_RES_PATH"/DISSGREE.bin"; - static constexpr const char *PNG_MICROPHONE_OPEN_IMAGE_PATH = APP_RES_PATH"/MICRO_PHONE_OPEN.bin"; - static constexpr const char *PNG_MICROPHONE_CLOSE_IMAGE_PATH = APP_RES_PATH"/MICRO_PHONE_CLOSE.bin"; - static constexpr const char *PNG_HANDUP_IMAGE_PATH = APP_RES_PATH"/HANDUP.bin"; - static constexpr const char *PNG_ANSWER_TMAGE_PATH = APP_RES_PATH"/ANSWER_PHONE.bin"; - static constexpr const char *PNG_CALLING_TMAGE_PATH = APP_RES_PATH"/CALLING_PHONE.bin"; - static constexpr const char *PNG_CALLER_TMAGE_PATH = APP_RES_PATH"/CALLER_LOG_IMAGE.bin"; - static constexpr const char *PNG_NO_CALLER_LOG_IMAGE = APP_RES_PATH"/NO_CALLER_LOG_IMAGE.bin"; - static constexpr const char *PNG_APPLIST_CALLER_IMAGE = APP_RES_PATH"/APPLIST_CALLER_IMAGE.bin"; - static constexpr const char *PNG_APPLIST_COMPASS_IMAGE = APP_RES_PATH"/APPLIST_COMPASS_IMAGE.bin"; + static constexpr const char *PNG_AGREEING_IMAGE_PATH = APP_RES_PATH "/AGREEING.bin"; + static constexpr const char *PNG_DISSGREE_IMAGE_PATH = APP_RES_PATH "/DISSGREE.bin"; + static constexpr const char *PNG_MICROPHONE_OPEN_IMAGE_PATH = APP_RES_PATH "/MICRO_PHONE_OPEN.bin"; + static constexpr const char *PNG_MICROPHONE_CLOSE_IMAGE_PATH = APP_RES_PATH "/MICRO_PHONE_CLOSE.bin"; + static constexpr const char *PNG_HANDUP_IMAGE_PATH = APP_RES_PATH "/HANDUP.bin"; + static constexpr const char *PNG_ANSWER_TMAGE_PATH = APP_RES_PATH "/ANSWER_PHONE.bin"; + static constexpr const char *PNG_CALLING_TMAGE_PATH = APP_RES_PATH "/CALLING_PHONE.bin"; + static constexpr const char *PNG_CALLER_TMAGE_PATH = APP_RES_PATH "/CALLER_LOG_IMAGE.bin"; + static constexpr const char *PNG_NO_CALLER_LOG_IMAGE = APP_RES_PATH "/NO_CALLER_LOG_IMAGE.bin"; + static constexpr const char *PNG_APPLIST_CALLER_IMAGE = APP_RES_PATH "/APPLIST_CALLER_IMAGE.bin"; + static constexpr const char *PNG_APPLIST_COMPASS_IMAGE = APP_RES_PATH "/APPLIST_COMPASS_IMAGE.bin"; - static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_0 = APP_RES_PATH"/COUNTDOWN_IMAGE_01.bin"; - static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_1 = APP_RES_PATH"/COUNTDOWN_IMAGE_02.bin"; - static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_2 = APP_RES_PATH"/COUNTDOWN_IMAGE_03.bin"; - static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_3 = APP_RES_PATH"/COUNTDOWN_IMAGE_04.bin"; - static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_4 = APP_RES_PATH"/COUNTDOWN_IMAGE_05.bin"; - static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_5 = APP_RES_PATH"/COUNTDOWN_IMAGE_06.bin"; - static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_6 = APP_RES_PATH"/COUNTDOWN_IMAGE_07.bin"; - static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_7 = APP_RES_PATH"/COUNTDOWN_IMAGE_08.bin"; - static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_8 = APP_RES_PATH"/COUNTDOWN_IMAGE_09.bin"; - static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_9 = APP_RES_PATH"/COUNTDOWN_IMAGE_10.bin"; - static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_10 = APP_RES_PATH"/COUNTDOWN_IMAGE_11.bin"; - static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_11 = APP_RES_PATH"/COUNTDOWN_IMAGE_12.bin"; - static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_12 = APP_RES_PATH"/COUNTDOWN_IMAGE_13.bin"; - static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_13 = APP_RES_PATH"/COUNTDOWN_IMAGE_14.bin"; - static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_14 = APP_RES_PATH"/COUNTDOWN_IMAGE_15.bin"; - static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_15 = APP_RES_PATH"/COUNTDOWN_IMAGE_16.bin"; - static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_16 = APP_RES_PATH"/COUNTDOWN_IMAGE_17.bin"; - static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_17 = APP_RES_PATH"/COUNTDOWN_IMAGE_18.bin"; - static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_18 = APP_RES_PATH"/COUNTDOWN_IMAGE_19.bin"; - static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_19 = APP_RES_PATH"/COUNTDOWN_IMAGE_20.bin"; - static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_20 = APP_RES_PATH"/COUNTDOWN_IMAGE_21.bin"; - static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_21 = APP_RES_PATH"/COUNTDOWN_IMAGE_22.bin"; - static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_22 = APP_RES_PATH"/COUNTDOWN_IMAGE_23.bin"; - static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_23 = APP_RES_PATH"/COUNTDOWN_IMAGE_24.bin"; + static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_0 = APP_RES_PATH "/COUNTDOWN_IMAGE_01.bin"; + static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_1 = APP_RES_PATH "/COUNTDOWN_IMAGE_02.bin"; + static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_2 = APP_RES_PATH "/COUNTDOWN_IMAGE_03.bin"; + static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_3 = APP_RES_PATH "/COUNTDOWN_IMAGE_04.bin"; + static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_4 = APP_RES_PATH "/COUNTDOWN_IMAGE_05.bin"; + static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_5 = APP_RES_PATH "/COUNTDOWN_IMAGE_06.bin"; + static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_6 = APP_RES_PATH "/COUNTDOWN_IMAGE_07.bin"; + static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_7 = APP_RES_PATH "/COUNTDOWN_IMAGE_08.bin"; + static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_8 = APP_RES_PATH "/COUNTDOWN_IMAGE_09.bin"; + static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_9 = APP_RES_PATH "/COUNTDOWN_IMAGE_10.bin"; + static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_10 = APP_RES_PATH "/COUNTDOWN_IMAGE_11.bin"; + static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_11 = APP_RES_PATH "/COUNTDOWN_IMAGE_12.bin"; + static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_12 = APP_RES_PATH "/COUNTDOWN_IMAGE_13.bin"; + static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_13 = APP_RES_PATH "/COUNTDOWN_IMAGE_14.bin"; + static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_14 = APP_RES_PATH "/COUNTDOWN_IMAGE_15.bin"; + static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_15 = APP_RES_PATH "/COUNTDOWN_IMAGE_16.bin"; + static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_16 = APP_RES_PATH "/COUNTDOWN_IMAGE_17.bin"; + static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_17 = APP_RES_PATH "/COUNTDOWN_IMAGE_18.bin"; + static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_18 = APP_RES_PATH "/COUNTDOWN_IMAGE_19.bin"; + static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_19 = APP_RES_PATH "/COUNTDOWN_IMAGE_20.bin"; + static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_20 = APP_RES_PATH "/COUNTDOWN_IMAGE_21.bin"; + static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_21 = APP_RES_PATH "/COUNTDOWN_IMAGE_22.bin"; + static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_22 = APP_RES_PATH "/COUNTDOWN_IMAGE_23.bin"; + static constexpr const char *PNG_COUNTDOWN_TIME_IMAGE_23 = APP_RES_PATH "/COUNTDOWN_IMAGE_24.bin"; - static constexpr const char *PNG_PROGRESS_BAR_TMAGE = APP_RES_PATH"/PROGRESS_BAR_TMAGE.bin"; - static constexpr const char *TEMP_WAITING = APP_RES_PATH"/TEMP_WAITING.bin"; - static constexpr const char *TEMP_REPORT = APP_RES_PATH"/TEMP_REPORT.bin"; - static constexpr const char *TEMP_POINT = APP_RES_PATH"/TEMP_POINT.bin"; - static constexpr const char *TEMP_REV_POINTER = APP_RES_PATH"/TEMP_REV_POINTER.bin"; + static constexpr const char *PNG_PROGRESS_BAR_TMAGE = APP_RES_PATH "/PROGRESS_BAR_TMAGE.bin"; + static constexpr const char *TEMP_WAITING = APP_RES_PATH "/TEMP_WAITING.bin"; + static constexpr const char *TEMP_REPORT = APP_RES_PATH "/TEMP_REPORT.bin"; + static constexpr const char *TEMP_POINT = APP_RES_PATH "/TEMP_POINT.bin"; + static constexpr const char *TEMP_REV_POINTER = APP_RES_PATH "/TEMP_REV_POINTER.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_0 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_02.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_1 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_03.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_2 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_04.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_3 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_05.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_4 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_06.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_5 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_07.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_6 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_08.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_7 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_09.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_8 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_10.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_9 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_11.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_10 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_12.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_11 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_13.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_12 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_14.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_13 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_15.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_14 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_16.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_15 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_17.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_16 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_18.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_17 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_19.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_18 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_20.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_19 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_21.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_20 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_22.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_21 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_23.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_22 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_24.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_23 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_25.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_24 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_26.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_25 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_27.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_26 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_28.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_27 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_29.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_28 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_30.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_29 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_31.bin"; - static constexpr const char *PNG_BLOOD_FLOW_IMAGE_30 = APP_RES_PATH"/BLOOD_FLOW_IMAGE_32.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_0 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_02.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_1 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_03.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_2 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_04.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_3 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_05.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_4 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_06.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_5 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_07.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_6 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_08.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_7 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_09.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_8 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_10.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_9 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_11.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_10 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_12.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_11 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_13.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_12 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_14.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_13 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_15.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_14 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_16.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_15 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_17.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_16 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_18.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_17 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_19.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_18 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_20.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_19 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_21.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_20 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_22.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_21 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_23.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_22 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_24.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_23 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_25.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_24 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_26.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_25 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_27.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_26 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_28.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_27 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_29.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_28 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_30.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_29 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_31.bin"; + static constexpr const char *PNG_BLOOD_FLOW_IMAGE_30 = APP_RES_PATH "/BLOOD_FLOW_IMAGE_32.bin"; - static constexpr const char *PNG_SOUNDBUTTON2 = APP_RES_PATH"/SOUND_IMAGE.bin"; - static constexpr const char *PNG_PULLBUTTON_FACE_IMAGE = APP_RES_PATH"/BLOOD_FLOW_IMAGE_01.bin"; - static constexpr const char *MUSIC_2 = APP_RES_PATH"/mp3_48k_caiqing.mp3"; - static constexpr const char *MUSIC_1 = APP_RES_PATH"/one.mp3"; + static constexpr const char *PNG_SOUNDBUTTON2 = APP_RES_PATH "/SOUND_IMAGE.bin"; + static constexpr const char *PNG_PULLBUTTON_FACE_IMAGE = APP_RES_PATH "/BLOOD_FLOW_IMAGE_01.bin"; + static constexpr const char *MUSIC_2 = APP_RES_PATH "/mp3_48k_caiqing.mp3"; + static constexpr const char *MUSIC_1 = APP_RES_PATH "/one.mp3"; - static constexpr const char *PNG_SETTTING_BUTTON_IMAGE = APP_RES_PATH"/SETTTING_BUTTON.bin"; - static constexpr const char *PNG_BLUETOOTH_IMAGE = APP_RES_PATH"/BLUETOOTH_IMAGE.bin"; - static constexpr const char *PNG_WATCH_IMAGE = APP_RES_PATH"/WATCH_IMAGE.bin"; - static constexpr const char *PNG_PHONE_IMAGE = APP_RES_PATH"/PHONE_IMAGE.bin"; - static constexpr const char *PNG_REBOOT_BUTTON_IMAGE = APP_RES_PATH"/REBOOT_BUTTON.bin"; - static constexpr const char *PNG_SHUTDOWN_BUTTON_IMAGE = APP_RES_PATH"/SHUTDOWN_BUTTON.bin"; - static constexpr const char *PNG_SETTTING_REBOOT_IMAGE = APP_RES_PATH"/SETTTING_REBOOT.bin"; - static constexpr const char *PNG_SETTTING_SHUTDOWN_IMAGE = APP_RES_PATH"/SETTTING_SHUTDOWN.bin"; + static constexpr const char *PNG_SETTTING_BUTTON_IMAGE = APP_RES_PATH "/SETTTING_BUTTON.bin"; + static constexpr const char *PNG_BLUETOOTH_IMAGE = APP_RES_PATH "/BLUETOOTH_IMAGE.bin"; + static constexpr const char *PNG_WATCH_IMAGE = APP_RES_PATH "/WATCH_IMAGE.bin"; + static constexpr const char *PNG_PHONE_IMAGE = APP_RES_PATH "/PHONE_IMAGE.bin"; + static constexpr const char *PNG_REBOOT_BUTTON_IMAGE = APP_RES_PATH "/REBOOT_BUTTON.bin"; + static constexpr const char *PNG_SHUTDOWN_BUTTON_IMAGE = APP_RES_PATH "/SHUTDOWN_BUTTON.bin"; + static constexpr const char *PNG_SETTTING_REBOOT_IMAGE = APP_RES_PATH "/SETTTING_REBOOT.bin"; + static constexpr const char *PNG_SETTTING_SHUTDOWN_IMAGE = APP_RES_PATH "/SETTTING_SHUTDOWN.bin"; - static constexpr const char *PNG_CONNECT_PHONE_IMAGE = APP_RES_PATH"/CONNECT_PHONE.bin"; - static constexpr const char *PNG_BLUETOOTH_STITLE = APP_RES_PATH"/BLUETOOTH_TITLE.bin"; + static constexpr const char *PNG_CONNECT_PHONE_IMAGE = APP_RES_PATH "/CONNECT_PHONE.bin"; + static constexpr const char *PNG_BLUETOOTH_STITLE = APP_RES_PATH "/BLUETOOTH_TITLE.bin"; - static constexpr const char *PNG_NEW_DEVICE = APP_RES_PATH"/NEW_DEVICE.bin"; - static constexpr const char *PNG_BT_LIST = APP_RES_PATH"/BT_LIST.bin"; - static constexpr const char *PNG_SELECTION_BOX = APP_RES_PATH"/SELECTION_BOX.bin"; - static constexpr const char *PNG_GANTAN = APP_RES_PATH"/GANTAN.bin"; - static constexpr const char *PNG_RIGHT = APP_RES_PATH"/RIGHT.bin"; + static constexpr const char *PNG_NEW_DEVICE = APP_RES_PATH "/NEW_DEVICE.bin"; + static constexpr const char *PNG_BT_LIST = APP_RES_PATH "/BT_LIST.bin"; + static constexpr const char *PNG_SELECTION_BOX = APP_RES_PATH "/SELECTION_BOX.bin"; + static constexpr const char *PNG_GANTAN = APP_RES_PATH "/GANTAN.bin"; + static constexpr const char *PNG_RIGHT = APP_RES_PATH "/RIGHT.bin"; - static constexpr const char *PNG_NEW_WLAN_WIFI = APP_RES_PATH"/FULL_SIGNAL_OPEN.bin"; - static constexpr const char *FULL_SIGNAL_ENCRYPTION = APP_RES_PATH"/FULL_SIGNAL_ENCRYPTION.bin"; + static constexpr const char *PNG_NEW_WLAN_WIFI = APP_RES_PATH "/FULL_SIGNAL_OPEN.bin"; + static constexpr const char *FULL_SIGNAL_ENCRYPTION = APP_RES_PATH "/FULL_SIGNAL_ENCRYPTION.bin"; - static constexpr const char *PNG_MAIN_FACE_IMAGE = APP_RES_PATH"/MAIN_FACE_IMAGE.bin"; - static constexpr const char *B024_009_IMAGE_PATH = APP_RES_PATH"/HOURHAND.bin"; - static constexpr const char *B024_010_IMAGE_PATH = APP_RES_PATH"/SECONDHAND.bin"; - static constexpr const char *B024_011_IMAGE_PATH = APP_RES_PATH"/MINUTEHAND.bin"; - static constexpr const char *ALARM_ADD_BUTTON_PATH = APP_RES_PATH"/BLUE_ADD.bin"; - static constexpr const char *ALARM_CLOCK_CLOSE_ADD_PATH = APP_RES_PATH"/CLOSE_RING_CLOCK.bin"; - static constexpr const char *ALARM_CLOCK_ADD_PATH = APP_RES_PATH"/POP_UP_CLOCK.bin"; - static constexpr const char *ALARM_CLOCK_POP_ADD_PATH = APP_RES_PATH"/RING_CLOCK.bin"; - static constexpr const char *ALARM_DELETE_ADD_PATH = APP_RES_PATH"/DELETE.bin"; - static constexpr const char *ALARM_TRUE_ADD_PATH = APP_RES_PATH"/TRUE_ADD.bin"; - static constexpr const char *TEMP_MEASURE = APP_RES_PATH"/TEMP_MEASURE.bin"; - static constexpr const char *TEMP_UP_DROP = APP_RES_PATH"/TEMP_UP_DROP.bin"; - static constexpr const char *TEMP_EXIT = APP_RES_PATH"/TEMP_EXIT.bin"; - static constexpr const char *TEMP_ROTATE = APP_RES_PATH"/TEMP_ROTATE.bin"; - static constexpr const char *TEMP_ICON_ENTER = APP_RES_PATH"/TEMP_ICON_ENTER.bin"; - static constexpr const char *TEMP_BACKGROUND = APP_RES_PATH"/TEMP_BACKGROUND.bin"; - static constexpr const char *TEMP_WARN = APP_RES_PATH"/TEMP_WARN.bin"; - static constexpr const char *TEMP_LITTLE_MEASURE = APP_RES_PATH"/TEMP_LITTLE_MEASURE.bin"; - static constexpr const char *TEMP_HOT = APP_RES_PATH"/TEMP_HOT.bin"; - static constexpr const char *TEMP_COLD = APP_RES_PATH"/TEMP_COLD.bin"; - static constexpr const char *TEMP_LIT_TIP = APP_RES_PATH"/TEMP_LIT_TIP.bin"; - static constexpr const char *TEMP_ABOUT_STUDY = APP_RES_PATH"/TEMP_ABOUT_STUDY.bin"; - static constexpr const char *TEMP_TRUE = APP_RES_PATH"/TEMP_TRUE.bin"; - static constexpr const char *TEMP_DELETE = APP_RES_PATH"/TEMP_DELETE.bin"; + static constexpr const char *PNG_MAIN_FACE_IMAGE = APP_RES_PATH "/MAIN_FACE_IMAGE.bin"; + static constexpr const char *B024_009_IMAGE_PATH = APP_RES_PATH "/HOURHAND.bin"; + static constexpr const char *B024_010_IMAGE_PATH = APP_RES_PATH "/SECONDHAND.bin"; + static constexpr const char *B024_011_IMAGE_PATH = APP_RES_PATH "/MINUTEHAND.bin"; + static constexpr const char *ALARM_ADD_BUTTON_PATH = APP_RES_PATH "/BLUE_ADD.bin"; + static constexpr const char *ALARM_CLOCK_CLOSE_ADD_PATH = APP_RES_PATH "/CLOSE_RING_CLOCK.bin"; + static constexpr const char *ALARM_CLOCK_ADD_PATH = APP_RES_PATH "/POP_UP_CLOCK.bin"; + static constexpr const char *ALARM_CLOCK_POP_ADD_PATH = APP_RES_PATH "/RING_CLOCK.bin"; + static constexpr const char *ALARM_DELETE_ADD_PATH = APP_RES_PATH "/DELETE.bin"; + static constexpr const char *ALARM_TRUE_ADD_PATH = APP_RES_PATH "/TRUE_ADD.bin"; + static constexpr const char *TEMP_MEASURE = APP_RES_PATH "/TEMP_MEASURE.bin"; + static constexpr const char *TEMP_UP_DROP = APP_RES_PATH "/TEMP_UP_DROP.bin"; + static constexpr const char *TEMP_EXIT = APP_RES_PATH "/TEMP_EXIT.bin"; + static constexpr const char *TEMP_ROTATE = APP_RES_PATH "/TEMP_ROTATE.bin"; + static constexpr const char *TEMP_ICON_ENTER = APP_RES_PATH "/TEMP_ICON_ENTER.bin"; + static constexpr const char *TEMP_BACKGROUND = APP_RES_PATH "/TEMP_BACKGROUND.bin"; + static constexpr const char *TEMP_WARN = APP_RES_PATH "/TEMP_WARN.bin"; + static constexpr const char *TEMP_LITTLE_MEASURE = APP_RES_PATH "/TEMP_LITTLE_MEASURE.bin"; + static constexpr const char *TEMP_HOT = APP_RES_PATH "/TEMP_HOT.bin"; + static constexpr const char *TEMP_COLD = APP_RES_PATH "/TEMP_COLD.bin"; + static constexpr const char *TEMP_LIT_TIP = APP_RES_PATH "/TEMP_LIT_TIP.bin"; + static constexpr const char *TEMP_ABOUT_STUDY = APP_RES_PATH "/TEMP_ABOUT_STUDY.bin"; + static constexpr const char *TEMP_TRUE = APP_RES_PATH "/TEMP_TRUE.bin"; + static constexpr const char *TEMP_DELETE = APP_RES_PATH "/TEMP_DELETE.bin"; - static constexpr const char *COMPASS_CALIBRATE_IMAGE = APP_RES_PATH"/COMPASS_CALIBRATE_IMAGE.bin"; - static constexpr const char *PNG_SETTING_NEXT_IMAGE = APP_RES_PATH"/SETTING_NEXT.bin"; + static constexpr const char *COMPASS_CALIBRATE_IMAGE = APP_RES_PATH "/COMPASS_CALIBRATE_IMAGE.bin"; + static constexpr const char *PNG_SETTING_NEXT_IMAGE = APP_RES_PATH "/SETTING_NEXT.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE01 = APP_RES_PATH"/VOICE_ASSISTANT_01.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE02 = APP_RES_PATH"/VOICE_ASSISTANT_02.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE03 = APP_RES_PATH"/VOICE_ASSISTANT_03.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE04 = APP_RES_PATH"/VOICE_ASSISTANT_04.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE05 = APP_RES_PATH"/VOICE_ASSISTANT_05.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE06 = APP_RES_PATH"/VOICE_ASSISTANT_06.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE07 = APP_RES_PATH"/VOICE_ASSISTANT_07.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE08 = APP_RES_PATH"/VOICE_ASSISTANT_08.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE09 = APP_RES_PATH"/VOICE_ASSISTANT_09.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE10 = APP_RES_PATH"/VOICE_ASSISTANT_10.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE11 = APP_RES_PATH"/VOICE_ASSISTANT_11.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE12 = APP_RES_PATH"/VOICE_ASSISTANT_12.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE13 = APP_RES_PATH"/VOICE_ASSISTANT_13.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE14 = APP_RES_PATH"/VOICE_ASSISTANT_14.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE15 = APP_RES_PATH"/VOICE_ASSISTANT_15.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE16 = APP_RES_PATH"/VOICE_ASSISTANT_16.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE17 = APP_RES_PATH"/VOICE_ASSISTANT_17.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE18 = APP_RES_PATH"/VOICE_ASSISTANT_18.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE19 = APP_RES_PATH"/VOICE_ASSISTANT_19.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE20 = APP_RES_PATH"/VOICE_ASSISTANT_20.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE21 = APP_RES_PATH"/VOICE_ASSISTANT_21.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE22 = APP_RES_PATH"/VOICE_ASSISTANT_22.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE23 = APP_RES_PATH"/VOICE_ASSISTANT_23.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE24 = APP_RES_PATH"/VOICE_ASSISTANT_24.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE25 = APP_RES_PATH"/VOICE_ASSISTANT_25.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE26 = APP_RES_PATH"/VOICE_ASSISTANT_26.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE27 = APP_RES_PATH"/VOICE_ASSISTANT_27.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE28 = APP_RES_PATH"/VOICE_ASSISTANT_28.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE29 = APP_RES_PATH"/VOICE_ASSISTANT_29.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE30 = APP_RES_PATH"/VOICE_ASSISTANT_30.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE31 = APP_RES_PATH"/VOICE_ASSISTANT_31.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE32 = APP_RES_PATH"/VOICE_ASSISTANT_32.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE33 = APP_RES_PATH"/VOICE_ASSISTANT_33.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE34 = APP_RES_PATH"/VOICE_ASSISTANT_34.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE35 = APP_RES_PATH"/VOICE_ASSISTANT_35.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE36 = APP_RES_PATH"/VOICE_ASSISTANT_36.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE37 = APP_RES_PATH"/VOICE_ASSISTANT_37.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE38 = APP_RES_PATH"/VOICE_ASSISTANT_38.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE39 = APP_RES_PATH"/VOICE_ASSISTANT_39.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE40 = APP_RES_PATH"/VOICE_ASSISTANT_40.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE41 = APP_RES_PATH"/VOICE_ASSISTANT_41.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE42 = APP_RES_PATH"/VOICE_ASSISTANT_42.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE43 = APP_RES_PATH"/VOICE_ASSISTANT_43.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE44 = APP_RES_PATH"/VOICE_ASSISTANT_44.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE45 = APP_RES_PATH"/VOICE_ASSISTANT_45.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE46 = APP_RES_PATH"/VOICE_ASSISTANT_46.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE47 = APP_RES_PATH"/VOICE_ASSISTANT_47.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE48 = APP_RES_PATH"/VOICE_ASSISTANT_48.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE49 = APP_RES_PATH"/VOICE_ASSISTANT_49.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE50 = APP_RES_PATH"/VOICE_ASSISTANT_50.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE51 = APP_RES_PATH"/VOICE_ASSISTANT_51.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE52 = APP_RES_PATH"/VOICE_ASSISTANT_52.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE53 = APP_RES_PATH"/VOICE_ASSISTANT_53.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE54 = APP_RES_PATH"/VOICE_ASSISTANT_54.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE55 = APP_RES_PATH"/VOICE_ASSISTANT_55.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE56 = APP_RES_PATH"/VOICE_ASSISTANT_56.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE57 = APP_RES_PATH"/VOICE_ASSISTANT_57.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE58 = APP_RES_PATH"/VOICE_ASSISTANT_58.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE59 = APP_RES_PATH"/VOICE_ASSISTANT_59.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE60 = APP_RES_PATH"/VOICE_ASSISTANT_60.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE61 = APP_RES_PATH"/VOICE_ASSISTANT_61.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE62 = APP_RES_PATH"/VOICE_ASSISTANT_62.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE63 = APP_RES_PATH"/VOICE_ASSISTANT_63.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE64 = APP_RES_PATH"/VOICE_ASSISTANT_64.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE65 = APP_RES_PATH"/VOICE_ASSISTANT_65.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE66 = APP_RES_PATH"/VOICE_ASSISTANT_66.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE67 = APP_RES_PATH"/VOICE_ASSISTANT_67.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE68 = APP_RES_PATH"/VOICE_ASSISTANT_68.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE69 = APP_RES_PATH"/VOICE_ASSISTANT_69.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE70 = APP_RES_PATH"/VOICE_ASSISTANT_70.bin"; - static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE71 = APP_RES_PATH"/VOICE_ASSISTANT_71.bin"; - static constexpr const char *PNG_APPLIST_VOCASSIST_IMAGE = APP_RES_PATH"/APPLIST_VOCASSIST_IMAGE.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE01 = APP_RES_PATH "/VOICE_ASSISTANT_01.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE02 = APP_RES_PATH "/VOICE_ASSISTANT_02.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE03 = APP_RES_PATH "/VOICE_ASSISTANT_03.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE04 = APP_RES_PATH "/VOICE_ASSISTANT_04.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE05 = APP_RES_PATH "/VOICE_ASSISTANT_05.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE06 = APP_RES_PATH "/VOICE_ASSISTANT_06.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE07 = APP_RES_PATH "/VOICE_ASSISTANT_07.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE08 = APP_RES_PATH "/VOICE_ASSISTANT_08.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE09 = APP_RES_PATH "/VOICE_ASSISTANT_09.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE10 = APP_RES_PATH "/VOICE_ASSISTANT_10.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE11 = APP_RES_PATH "/VOICE_ASSISTANT_11.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE12 = APP_RES_PATH "/VOICE_ASSISTANT_12.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE13 = APP_RES_PATH "/VOICE_ASSISTANT_13.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE14 = APP_RES_PATH "/VOICE_ASSISTANT_14.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE15 = APP_RES_PATH "/VOICE_ASSISTANT_15.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE16 = APP_RES_PATH "/VOICE_ASSISTANT_16.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE17 = APP_RES_PATH "/VOICE_ASSISTANT_17.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE18 = APP_RES_PATH "/VOICE_ASSISTANT_18.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE19 = APP_RES_PATH "/VOICE_ASSISTANT_19.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE20 = APP_RES_PATH "/VOICE_ASSISTANT_20.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE21 = APP_RES_PATH "/VOICE_ASSISTANT_21.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE22 = APP_RES_PATH "/VOICE_ASSISTANT_22.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE23 = APP_RES_PATH "/VOICE_ASSISTANT_23.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE24 = APP_RES_PATH "/VOICE_ASSISTANT_24.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE25 = APP_RES_PATH "/VOICE_ASSISTANT_25.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE26 = APP_RES_PATH "/VOICE_ASSISTANT_26.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE27 = APP_RES_PATH "/VOICE_ASSISTANT_27.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE28 = APP_RES_PATH "/VOICE_ASSISTANT_28.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE29 = APP_RES_PATH "/VOICE_ASSISTANT_29.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE30 = APP_RES_PATH "/VOICE_ASSISTANT_30.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE31 = APP_RES_PATH "/VOICE_ASSISTANT_31.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE32 = APP_RES_PATH "/VOICE_ASSISTANT_32.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE33 = APP_RES_PATH "/VOICE_ASSISTANT_33.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE34 = APP_RES_PATH "/VOICE_ASSISTANT_34.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE35 = APP_RES_PATH "/VOICE_ASSISTANT_35.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE36 = APP_RES_PATH "/VOICE_ASSISTANT_36.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE37 = APP_RES_PATH "/VOICE_ASSISTANT_37.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE38 = APP_RES_PATH "/VOICE_ASSISTANT_38.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE39 = APP_RES_PATH "/VOICE_ASSISTANT_39.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE40 = APP_RES_PATH "/VOICE_ASSISTANT_40.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE41 = APP_RES_PATH "/VOICE_ASSISTANT_41.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE42 = APP_RES_PATH "/VOICE_ASSISTANT_42.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE43 = APP_RES_PATH "/VOICE_ASSISTANT_43.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE44 = APP_RES_PATH "/VOICE_ASSISTANT_44.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE45 = APP_RES_PATH "/VOICE_ASSISTANT_45.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE46 = APP_RES_PATH "/VOICE_ASSISTANT_46.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE47 = APP_RES_PATH "/VOICE_ASSISTANT_47.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE48 = APP_RES_PATH "/VOICE_ASSISTANT_48.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE49 = APP_RES_PATH "/VOICE_ASSISTANT_49.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE50 = APP_RES_PATH "/VOICE_ASSISTANT_50.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE51 = APP_RES_PATH "/VOICE_ASSISTANT_51.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE52 = APP_RES_PATH "/VOICE_ASSISTANT_52.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE53 = APP_RES_PATH "/VOICE_ASSISTANT_53.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE54 = APP_RES_PATH "/VOICE_ASSISTANT_54.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE55 = APP_RES_PATH "/VOICE_ASSISTANT_55.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE56 = APP_RES_PATH "/VOICE_ASSISTANT_56.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE57 = APP_RES_PATH "/VOICE_ASSISTANT_57.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE58 = APP_RES_PATH "/VOICE_ASSISTANT_58.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE59 = APP_RES_PATH "/VOICE_ASSISTANT_59.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE60 = APP_RES_PATH "/VOICE_ASSISTANT_60.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE61 = APP_RES_PATH "/VOICE_ASSISTANT_61.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE62 = APP_RES_PATH "/VOICE_ASSISTANT_62.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE63 = APP_RES_PATH "/VOICE_ASSISTANT_63.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE64 = APP_RES_PATH "/VOICE_ASSISTANT_64.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE65 = APP_RES_PATH "/VOICE_ASSISTANT_65.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE66 = APP_RES_PATH "/VOICE_ASSISTANT_66.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE67 = APP_RES_PATH "/VOICE_ASSISTANT_67.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE68 = APP_RES_PATH "/VOICE_ASSISTANT_68.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE69 = APP_RES_PATH "/VOICE_ASSISTANT_69.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE70 = APP_RES_PATH "/VOICE_ASSISTANT_70.bin"; + static constexpr const char *PNG_VOICE_ASSISTANT_IMAGE71 = APP_RES_PATH "/VOICE_ASSISTANT_71.bin"; + static constexpr const char *PNG_APPLIST_VOCASSIST_IMAGE = APP_RES_PATH "/APPLIST_VOCASSIST_IMAGE.bin"; - static constexpr const char *PNG_STEP_SHOE_IMAGE_PATH = APP_RES_PATH"/SHOE_IMAGE.bin"; + static constexpr const char *PNG_STEP_SHOE_IMAGE_PATH = APP_RES_PATH "/SHOE_IMAGE.bin"; - static constexpr const char *PNG_A004_070_IMAGE_PATH = APP_RES_PATH"/HEARTBEAT_IMAGE_01.bin"; - static constexpr const char *PNG_A004_071_IMAGE_PATH = APP_RES_PATH"/HEARTBEAT_IMAGE_02.bin"; - static constexpr const char *PNG_A004_072_IMAGE_PATH = APP_RES_PATH"/HEARTBEAT_IMAGE_03.bin"; - static constexpr const char *PNG_A004_073_IMAGE_PATH = APP_RES_PATH"/HEARTBEAT_IMAGE_04.bin"; - static constexpr const char *PNG_A004_074_IMAGE_PATH = APP_RES_PATH"/HEARTBEAT_IMAGE_05.bin"; - static constexpr const char *PNG_A004_075_IMAGE_PATH = APP_RES_PATH"/HEARTBEAT_IMAGE_06.bin"; - static constexpr const char *PNG_A004_076_IMAGE_PATH = APP_RES_PATH"/HEARTBEAT_IMAGE_07.bin"; - static constexpr const char *PNG_A004_077_IMAGE_PATH = APP_RES_PATH"/HEARTBEAT_IMAGE_08.bin"; - static constexpr const char *PNG_A004_078_IMAGE_PATH = APP_RES_PATH"/HEARTBEAT_IMAGE_09.bin"; - static constexpr const char *PNG_A004_079_IMAGE_PATH = APP_RES_PATH"/HEARTBEAT_IMAGE_10.bin"; - static constexpr const char *PNG_A004_080_IMAGE_PATH = APP_RES_PATH"/HEARTBEAT_IMAGE_11.bin"; - static constexpr const char *PNG_A004_081_IMAGE_PATH = APP_RES_PATH"/HEARTBEAT_IMAGE_12.bin"; - static constexpr const char *PNG_A004_082_IMAGE_PATH = APP_RES_PATH"/HEARTBEAT_IMAGE_13.bin"; - static constexpr const char *PNG_A004_083_IMAGE_PATH = APP_RES_PATH"/HEARTBEAT_IMAGE_14.bin"; - static constexpr const char *PNG_A004_084_IMAGE_PATH = APP_RES_PATH"/HEARTBEAT_IMAGE_15.bin"; - static constexpr const char *PNG_A004_085_IMAGE_PATH = APP_RES_PATH"/HEARTBEAT_IMAGE_16.bin"; - static constexpr const char *PNG_A004_086_IMAGE_PATH = APP_RES_PATH"/HEARTBEAT_IMAGE_17.bin"; - static constexpr const char *PNG_A004_087_IMAGE_PATH = APP_RES_PATH"/HEARTBEAT_IMAGE_18.bin"; - static constexpr const char *PNG_A004_088_IMAGE_PATH = APP_RES_PATH"/HEARTBEAT_IMAGE_19.bin"; + static constexpr const char *PNG_A004_070_IMAGE_PATH = APP_RES_PATH "/HEARTBEAT_IMAGE_01.bin"; + static constexpr const char *PNG_A004_071_IMAGE_PATH = APP_RES_PATH "/HEARTBEAT_IMAGE_02.bin"; + static constexpr const char *PNG_A004_072_IMAGE_PATH = APP_RES_PATH "/HEARTBEAT_IMAGE_03.bin"; + static constexpr const char *PNG_A004_073_IMAGE_PATH = APP_RES_PATH "/HEARTBEAT_IMAGE_04.bin"; + static constexpr const char *PNG_A004_074_IMAGE_PATH = APP_RES_PATH "/HEARTBEAT_IMAGE_05.bin"; + static constexpr const char *PNG_A004_075_IMAGE_PATH = APP_RES_PATH "/HEARTBEAT_IMAGE_06.bin"; + static constexpr const char *PNG_A004_076_IMAGE_PATH = APP_RES_PATH "/HEARTBEAT_IMAGE_07.bin"; + static constexpr const char *PNG_A004_077_IMAGE_PATH = APP_RES_PATH "/HEARTBEAT_IMAGE_08.bin"; + static constexpr const char *PNG_A004_078_IMAGE_PATH = APP_RES_PATH "/HEARTBEAT_IMAGE_09.bin"; + static constexpr const char *PNG_A004_079_IMAGE_PATH = APP_RES_PATH "/HEARTBEAT_IMAGE_10.bin"; + static constexpr const char *PNG_A004_080_IMAGE_PATH = APP_RES_PATH "/HEARTBEAT_IMAGE_11.bin"; + static constexpr const char *PNG_A004_081_IMAGE_PATH = APP_RES_PATH "/HEARTBEAT_IMAGE_12.bin"; + static constexpr const char *PNG_A004_082_IMAGE_PATH = APP_RES_PATH "/HEARTBEAT_IMAGE_13.bin"; + static constexpr const char *PNG_A004_083_IMAGE_PATH = APP_RES_PATH "/HEARTBEAT_IMAGE_14.bin"; + static constexpr const char *PNG_A004_084_IMAGE_PATH = APP_RES_PATH "/HEARTBEAT_IMAGE_15.bin"; + static constexpr const char *PNG_A004_085_IMAGE_PATH = APP_RES_PATH "/HEARTBEAT_IMAGE_16.bin"; + static constexpr const char *PNG_A004_086_IMAGE_PATH = APP_RES_PATH "/HEARTBEAT_IMAGE_17.bin"; + static constexpr const char *PNG_A004_087_IMAGE_PATH = APP_RES_PATH "/HEARTBEAT_IMAGE_18.bin"; + static constexpr const char *PNG_A004_088_IMAGE_PATH = APP_RES_PATH "/HEARTBEAT_IMAGE_19.bin"; - static constexpr const char *PNG_A019_080_IMAGE_PATH = APP_RES_PATH"/BLUETOOTH_IMAGE_01.bin"; - static constexpr const char *PNG_A019_081_IMAGE_PATH = APP_RES_PATH"/BLUETOOTH_IMAGE_02.bin"; - static constexpr const char *PNG_A019_082_IMAGE_PATH = APP_RES_PATH"/BLUETOOTH_IMAGE_03.bin"; - static constexpr const char *PNG_A019_083_IMAGE_PATH = APP_RES_PATH"/BLUETOOTH_IMAGE_04.bin"; - static constexpr const char *PNG_A019_084_IMAGE_PATH = APP_RES_PATH"/BLUETOOTH_IMAGE_05.bin"; - static constexpr const char *PNG_A019_085_IMAGE_PATH = APP_RES_PATH"/BLUETOOTH_IMAGE_06.bin"; - static constexpr const char *PNG_A019_086_IMAGE_PATH = APP_RES_PATH"/BLUETOOTH_IMAGE_07.bin"; - static constexpr const char *PNG_A019_087_IMAGE_PATH = APP_RES_PATH"/BLUETOOTH_IMAGE_08.bin"; + static constexpr const char *PNG_A019_080_IMAGE_PATH = APP_RES_PATH "/BLUETOOTH_IMAGE_01.bin"; + static constexpr const char *PNG_A019_081_IMAGE_PATH = APP_RES_PATH "/BLUETOOTH_IMAGE_02.bin"; + static constexpr const char *PNG_A019_082_IMAGE_PATH = APP_RES_PATH "/BLUETOOTH_IMAGE_03.bin"; + static constexpr const char *PNG_A019_083_IMAGE_PATH = APP_RES_PATH "/BLUETOOTH_IMAGE_04.bin"; + static constexpr const char *PNG_A019_084_IMAGE_PATH = APP_RES_PATH "/BLUETOOTH_IMAGE_05.bin"; + static constexpr const char *PNG_A019_085_IMAGE_PATH = APP_RES_PATH "/BLUETOOTH_IMAGE_06.bin"; + static constexpr const char *PNG_A019_086_IMAGE_PATH = APP_RES_PATH "/BLUETOOTH_IMAGE_07.bin"; + static constexpr const char *PNG_A019_087_IMAGE_PATH = APP_RES_PATH "/BLUETOOTH_IMAGE_08.bin"; - static constexpr const char *PNG_A019_088_IMAGE_PATH = APP_RES_PATH"/BLUETOOTH_IMAGE_09.bin"; - static constexpr const char *PNG_A019_089_IMAGE_PATH = APP_RES_PATH"/BLUETOOTH_IMAGE_10.bin"; - static constexpr const char *PNG_A019_090_IMAGE_PATH = APP_RES_PATH"/BLUETOOTH_IMAGE_11.bin"; - static constexpr const char *PNG_A019_091_IMAGE_PATH = APP_RES_PATH"/BLUETOOTH_IMAGE_12.bin"; - static constexpr const char *PNG_A019_092_IMAGE_PATH = APP_RES_PATH"/BLUETOOTH_IMAGE_13.bin"; - static constexpr const char *PNG_A019_093_IMAGE_PATH = APP_RES_PATH"/BLUETOOTH_IMAGE_14.bin"; - static constexpr const char *PNG_A019_094_IMAGE_PATH = APP_RES_PATH"/BLUETOOTH_IMAGE_15.bin"; - static constexpr const char *PNG_A019_095_IMAGE_PATH = APP_RES_PATH"/BLUETOOTH_IMAGE_16.bin"; - static constexpr const char *PNG_BLUETOOTHEAR = APP_RES_PATH"/BLUETOOTHEAR.bin"; + static constexpr const char *PNG_A019_088_IMAGE_PATH = APP_RES_PATH "/BLUETOOTH_IMAGE_09.bin"; + static constexpr const char *PNG_A019_089_IMAGE_PATH = APP_RES_PATH "/BLUETOOTH_IMAGE_10.bin"; + static constexpr const char *PNG_A019_090_IMAGE_PATH = APP_RES_PATH "/BLUETOOTH_IMAGE_11.bin"; + static constexpr const char *PNG_A019_091_IMAGE_PATH = APP_RES_PATH "/BLUETOOTH_IMAGE_12.bin"; + static constexpr const char *PNG_A019_092_IMAGE_PATH = APP_RES_PATH "/BLUETOOTH_IMAGE_13.bin"; + static constexpr const char *PNG_A019_093_IMAGE_PATH = APP_RES_PATH "/BLUETOOTH_IMAGE_14.bin"; + static constexpr const char *PNG_A019_094_IMAGE_PATH = APP_RES_PATH "/BLUETOOTH_IMAGE_15.bin"; + static constexpr const char *PNG_A019_095_IMAGE_PATH = APP_RES_PATH "/BLUETOOTH_IMAGE_16.bin"; + static constexpr const char *PNG_BLUETOOTHEAR = APP_RES_PATH "/BLUETOOTHEAR.bin"; // AppList - static constexpr const char *PNG_APPLIST_ALARM_IMAGE = APP_RES_PATH"/APPLIST_ALARM.bin"; // 闹钟 - static constexpr const char *PNG_APPLIST_SPO2_IMAGE = APP_RES_PATH"/APPLIST_SPO2.bin"; // 血氧 - static constexpr const char *PNG_APPLIST_SETTING_IMAGE = APP_RES_PATH"/APPLIST_SETTING.bin"; // 设置 - static constexpr const char *PNG_APPLIST_TEMP_IMAGE = APP_RES_PATH"/TEMP_IMAGE.bin"; // 体温 + static constexpr const char *PNG_APPLIST_ALARM_IMAGE = APP_RES_PATH "/APPLIST_ALARM.bin"; // 闹钟 + static constexpr const char *PNG_APPLIST_SPO2_IMAGE = APP_RES_PATH "/APPLIST_SPO2.bin"; // 血氧 + static constexpr const char *PNG_APPLIST_SETTING_IMAGE = APP_RES_PATH "/APPLIST_SETTING.bin"; // 设置 + static constexpr const char *PNG_APPLIST_TEMP_IMAGE = APP_RES_PATH "/TEMP_IMAGE.bin"; // 体温 + // 快速训练 + static constexpr const char *PNG_TRAING_BOUTTONMORE_IMAGE = APP_RES_PATH "/Training/More.bin"; + static constexpr const char *PNG_TRAING_BUTTONGRONG_IMAGE = APP_RES_PATH "/Training/Bouttonground.bin"; + static constexpr const char *PNG_TRAING_BUTTONGRONG2_IMAGE = APP_RES_PATH "/Training/Buttonground2.bin"; + static constexpr const char *PNG_TRAING_RIDINGBIG_IMAGE = APP_RES_PATH "/Training/riding-big2.bin"; + static constexpr const char *PNG_TRAING_RUNNINGBIG_IMAGE = APP_RES_PATH "/Training/running-big.bin"; + static constexpr const char *PNG_TRAING_WALKINGBIG_IMAGE = APP_RES_PATH "/Training/walking-big.bin"; // 室内步行 - static constexpr const char *PNG_APPLIST_WALK_IMAGE = APP_RES_PATH"/APPLIST_WALK.bin"; // Applist图标 - static constexpr const char *PNG_WALK_BACK_GROUND = APP_RES_PATH"/WALK_BACK_GROUND.bin"; - static constexpr const char *PNG_WALK_IMAGE = APP_RES_PATH"/INDOORWALK.bin"; - static constexpr const char *PNG_AEROBIC_IMAGE = APP_RES_PATH"/AEROBIC.bin"; - static constexpr const char *PNG_ANAEROBIC_IMAGE = APP_RES_PATH"/ANAEROBIC.bin"; - static constexpr const char *PNG_OPTIONS_BOX1_IMAGE = APP_RES_PATH"/OPTIONS_BOX1.bin"; - static constexpr const char *PNG_OPTIONS_BOX2_IMAGE = APP_RES_PATH"/OPTIONS_BOX2.bin"; - static constexpr const char *PNG_OPTIONS_BOX3_IMAGE = APP_RES_PATH"/OPTIONS_BOX3.bin"; - static constexpr const char *PNG_OPTIONS_BOX4_IMAGE = APP_RES_PATH"/OPTIONS_BOX4.bin"; - static constexpr const char *PNG_WALK_TIME_IMAGE = APP_RES_PATH"/TIME_IMAGE.bin"; - static constexpr const char *PNG_WALK_DISTANCES_IMAGE = APP_RES_PATH"/DISTANCES_IMAGE.bin"; - static constexpr const char *PNG_WALK_HEART_IMAGE = APP_RES_PATH"/HEART_IMAGE.bin"; - static constexpr const char *PNG_WALK_SPEED_IMAGE = APP_RES_PATH"/SPEED_IMAGE.bin"; - static constexpr const char *PNG_WALK_STEPS_IMAGE = APP_RES_PATH"/STEPS_IMAGE.bin"; + static constexpr const char *PNG_APPLIST_WALK_IMAGE = APP_RES_PATH "/APPLIST_WALK.bin"; // Applist图标 + static constexpr const char *PNG_WALK_BACK_GROUND = APP_RES_PATH "/WALK_BACK_GROUND.bin"; + static constexpr const char *PNG_WALK_IMAGE = APP_RES_PATH "/INDOORWALK.bin"; + static constexpr const char *PNG_AEROBIC_IMAGE = APP_RES_PATH "/AEROBIC.bin"; + static constexpr const char *PNG_ANAEROBIC_IMAGE = APP_RES_PATH "/ANAEROBIC.bin"; + static constexpr const char *PNG_OPTIONS_BOX1_IMAGE = APP_RES_PATH "/OPTIONS_BOX1.bin"; + static constexpr const char *PNG_OPTIONS_BOX2_IMAGE = APP_RES_PATH "/OPTIONS_BOX2.bin"; + static constexpr const char *PNG_OPTIONS_BOX3_IMAGE = APP_RES_PATH "/OPTIONS_BOX3.bin"; + static constexpr const char *PNG_OPTIONS_BOX4_IMAGE = APP_RES_PATH "/OPTIONS_BOX4.bin"; + static constexpr const char *PNG_WALK_TIME_IMAGE = APP_RES_PATH "/TIME_IMAGE.bin"; + static constexpr const char *PNG_WALK_DISTANCES_IMAGE = APP_RES_PATH "/DISTANCES_IMAGE.bin"; + static constexpr const char *PNG_WALK_HEART_IMAGE = APP_RES_PATH "/HEART_IMAGE.bin"; + static constexpr const char *PNG_WALK_SPEED_IMAGE = APP_RES_PATH "/SPEED_IMAGE.bin"; + static constexpr const char *PNG_WALK_STEPS_IMAGE = APP_RES_PATH "/STEPS_IMAGE.bin"; - static constexpr const char *PNG_APPLIST_UI_SAMPLE_IMAGE = APP_RES_PATH"/APPLIST_UI_SAMPLE.bin"; // Applist图标 + static constexpr const char *PNG_APPLIST_UI_SAMPLE_IMAGE = APP_RES_PATH "/APPLIST_UI_SAMPLE.bin"; // Applist图标 } #endif // UI_CONFIG_H diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp b/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp index e6075716e..166278f68 100755 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp @@ -58,299 +58,336 @@ #include "RebootPresenter.h" #include "UISampleView.h" #include "UISamplePresenter.h" + +#include "dial/include/DialPresenter.h" +#include "dial/include/DialView.h" + #include "BluetoothHeadsetEvent.h" #include "graphic_hardware_config.h" #include "graphic_service.h" #include "common/graphic_startup.h" -namespace OHOS { -struct AppViewMapper +namespace OHOS { - AppViewId id; - void (NativeLauncher::*func)(void); -}; + struct AppViewMapper + { + AppViewId id; + void (NativeLauncher::*func)(void); + }; -struct ViewIdToString -{ - AppViewId id; - char idForUikit[256]; -}; + struct ViewIdToString + { + AppViewId id; + char idForUikit[256]; + }; -static const AppViewMapper SLICE_MAPPER[] = { - {VIEW_MAIN, &NativeLauncher::InitMainSlice}, - {VIEW_SETTING, &NativeLauncher::InitSettingSlice}, - {VIEW_APPLIST, &NativeLauncher::InitApplistSlice}, - {VIEW_MAIN_SAMPLE, &NativeLauncher::InitMainSampleSlice}, - {VIEW_MAIN_ALARM, &NativeLauncher::InitMainAlarmSlice}, - {VIEW_ALARM_POP_UP, &NativeLauncher::InitAlarmPopUpSlice}, - {VIEW_BLOODOXY_SAMPLE, &NativeLauncher::InitMainBloodOxyView}, - {VIEW_MAIN_ACTIVITY, &NativeLauncher::InitActivitySlice}, - {VIEW_CALLER_SAMPLE,&NativeLauncher::InitMainCallerLogView}, - {VIEW_MAEKPHONE_SAMPLE,&NativeLauncher::InitMainMakePhoneView}, - {VIEW_BLUETOOTH_EARPHONE, &NativeLauncher::InitBluetoothSlice}, - {VIEW_COMPASS, &NativeLauncher::InitCompassSlice}, - {VIEW_OFFLINEVOICE, &NativeLauncher::InitOfflineVoice}, - {VIEW_CONNECT_PHONE, &NativeLauncher::InitConnectPhoneSlice}, - {VIEW_MAIN_TEMP, &NativeLauncher::InitMainTempSlice}, - {VIEW_INDOORWALK, &NativeLauncher::InitIndoorWalkSlice}, - {VIEW_REBOOT, &NativeLauncher::InitRebootSlice}, - {VIEW_UISAMPLE, &NativeLauncher::InitUISampleSlice} -}; + static const AppViewMapper SLICE_MAPPER[] = { + {VIEW_MAIN, &NativeLauncher::InitMainSlice}, + {VIEW_SETTING, &NativeLauncher::InitSettingSlice}, + {VIEW_APPLIST, &NativeLauncher::InitApplistSlice}, + {VIEW_MAIN_SAMPLE, &NativeLauncher::InitMainSampleSlice}, + {VIEW_MAIN_ALARM, &NativeLauncher::InitMainAlarmSlice}, + {VIEW_ALARM_POP_UP, &NativeLauncher::InitAlarmPopUpSlice}, + {VIEW_BLOODOXY_SAMPLE, &NativeLauncher::InitMainBloodOxyView}, + {VIEW_MAIN_ACTIVITY, &NativeLauncher::InitActivitySlice}, + {VIEW_CALLER_SAMPLE, &NativeLauncher::InitMainCallerLogView}, + {VIEW_MAEKPHONE_SAMPLE, &NativeLauncher::InitMainMakePhoneView}, + {VIEW_BLUETOOTH_EARPHONE, &NativeLauncher::InitBluetoothSlice}, + {VIEW_COMPASS, &NativeLauncher::InitCompassSlice}, + {VIEW_OFFLINEVOICE, &NativeLauncher::InitOfflineVoice}, + {VIEW_CONNECT_PHONE, &NativeLauncher::InitConnectPhoneSlice}, + {VIEW_MAIN_TEMP, &NativeLauncher::InitMainTempSlice}, + {VIEW_INDOORWALK, &NativeLauncher::InitIndoorWalkSlice}, + {VIEW_REBOOT, &NativeLauncher::InitRebootSlice}, -static const ViewIdToString VIEW_MAPPER[] = { - {VIEW_MAIN, "main"}, - {VIEW_SETTING, "setting"}, - {VIEW_APPLIST, "applist"}, - {VIEW_MAIN_SAMPLE, "mainViewSample"}, - {VIEW_MAIN_ALARM, "mainAlarmView"}, - {VIEW_ALARM_POP_UP, "alarmPopUpView"}, - {VIEW_BLOODOXY_SAMPLE, "bloodOxygenView"}, - {VIEW_MAIN_ACTIVITY, "mainActivityView"}, - {VIEW_CALLER_SAMPLE, "callerLogView"}, - {VIEW_MAEKPHONE_SAMPLE, "makePhoneView"}, - {VIEW_BLUETOOTH_EARPHONE, "mainBluetoothView"}, - {VIEW_COMPASS, "mainCompassView"}, - {VIEW_OFFLINEVOICE, "offlineVoiceView"}, - {VIEW_CONNECT_PHONE, "ConnectPhoneView"}, - {VIEW_MAIN_TEMP, "mianTempView"}, - {VIEW_INDOORWALK, "IndoorWalkView"}, - {VIEW_REBOOT, "RebootView"}, - {VIEW_UISAMPLE, "UISample"} -}; + {VIEW_DIAL, &NativeLauncher::InitDialSlice}, + {VIEW_UISAMPLE, &NativeLauncher::InitUISampleSlice}}; -NativeLauncher::NativeLauncher() {} -NativeLauncher::~NativeLauncher() {} + static const ViewIdToString VIEW_MAPPER[] = { + {VIEW_MAIN, "main"}, + {VIEW_SETTING, "setting"}, + {VIEW_APPLIST, "applist"}, + {VIEW_MAIN_SAMPLE, "mainViewSample"}, + {VIEW_MAIN_ALARM, "mainAlarmView"}, + {VIEW_ALARM_POP_UP, "alarmPopUpView"}, + {VIEW_BLOODOXY_SAMPLE, "bloodOxygenView"}, + {VIEW_MAIN_ACTIVITY, "mainActivityView"}, + {VIEW_CALLER_SAMPLE, "callerLogView"}, + {VIEW_MAEKPHONE_SAMPLE, "makePhoneView"}, + {VIEW_BLUETOOTH_EARPHONE, "mainBluetoothView"}, + {VIEW_COMPASS, "mainCompassView"}, + {VIEW_OFFLINEVOICE, "offlineVoiceView"}, + {VIEW_CONNECT_PHONE, "ConnectPhoneView"}, + {VIEW_MAIN_TEMP, "mianTempView"}, + {VIEW_INDOORWALK, "IndoorWalkView"}, + {VIEW_REBOOT, "RebootView"}, + {VIEW_UISAMPLE, "UISample"}}; -NativeLauncher &NativeLauncher::GetInstance(void) -{ - static NativeLauncher instance; - return instance; -} + NativeLauncher::NativeLauncher() {} + NativeLauncher::~NativeLauncher() {} -void NativeLauncher::InitNativeLauncher() { - GraphicStartUp::InitFontEngine(MEM_POOL_UI_FONT, MEM_POOL_UI_FONT_SIZE, OHOS::VECTOR_FONT_DIR, DEFAULT_VECTOR_FONT_FILENAME); - WEARABLE_LOGI(WEARABLE_LOG_MODULE_LAUNCHER_FWK, "NativeLauncher::InitNativeLauncher"); - // 初始化所有预加载slice - InitBtHeadsetEvent(); // 蓝牙ct和tg适配初始化 - InitAllNativeSlices(); - CallerLogModel::GetInstance()->InitPhoneService(); - PresenterTask::GetInstance()->Init(); - PlayersModel::GetInstance()->AudioInit(); - ActivityModel::GetInstance()->Init(); - ScreenModels::GetInstance()->InitCardConfig(); - VocassistModel::GetInstance()->Init(); - HeartModel::GetInstance()->Init(); - BluetoothModel::GetInstance()->Init(); - // 初始化默认首页 - ScreenModels::GetInstance()->PreLoadAppimages(); - NativeAbility::GetInstance().SetDefaultSliceId(VIEW_MAIN_SAMPLE); -} + NativeLauncher &NativeLauncher::GetInstance(void) + { + static NativeLauncher instance; + return instance; + } -void NativeLauncher::InitAllNativeSlices(void) -{ - uint16_t size = sizeof(SLICE_MAPPER) / sizeof(SLICE_MAPPER[0]); - for (int index = 0; index < size; index++) { - if ((SLICE_MAPPER[index].id >= VIEW_MAX_INTER_APP)) { - continue; - } - (this->*(SLICE_MAPPER[index].func))(); + void NativeLauncher::InitNativeLauncher() + { + GraphicStartUp::InitFontEngine(MEM_POOL_UI_FONT, MEM_POOL_UI_FONT_SIZE, OHOS::VECTOR_FONT_DIR, DEFAULT_VECTOR_FONT_FILENAME); + WEARABLE_LOGI(WEARABLE_LOG_MODULE_LAUNCHER_FWK, "NativeLauncher::InitNativeLauncher"); + // 初始化所有预加载slice + InitBtHeadsetEvent(); // 蓝牙ct和tg适配初始化 + InitAllNativeSlices(); + CallerLogModel::GetInstance()->InitPhoneService(); + PresenterTask::GetInstance()->Init(); + PlayersModel::GetInstance()->AudioInit(); + ActivityModel::GetInstance()->Init(); + ScreenModels::GetInstance()->InitCardConfig(); + VocassistModel::GetInstance()->Init(); + HeartModel::GetInstance()->Init(); + BluetoothModel::GetInstance()->Init(); + // 初始化默认首页 + ScreenModels::GetInstance()->PreLoadAppimages(); + NativeAbility::GetInstance().SetDefaultSliceId(VIEW_MAIN_SAMPLE); } - return; -} -void NativeLauncher::InitMainSlice(void) -{ - SliceProxy *mainSlice = new AbilitySliceProxy; - if (mainSlice != nullptr) { - NativeAbility::GetInstance().AddSliceProxy(VIEW_MAIN, mainSlice); + void NativeLauncher::InitAllNativeSlices(void) + { + uint16_t size = sizeof(SLICE_MAPPER) / sizeof(SLICE_MAPPER[0]); + for (int index = 0; index < size; index++) + { + if ((SLICE_MAPPER[index].id >= VIEW_MAX_INTER_APP)) + { + continue; + } + (this->*(SLICE_MAPPER[index].func))(); + } + return; } -} + void NativeLauncher::InitMainSlice(void) + { + SliceProxy *mainSlice = new AbilitySliceProxy; + if (mainSlice != nullptr) + { + NativeAbility::GetInstance().AddSliceProxy(VIEW_MAIN, mainSlice); + } + } -void NativeLauncher::InitMainSampleSlice(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitMainSampleSlice"); - SliceProxy *mainViewSample = new AbilitySliceProxy; - if (mainViewSample == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mainViewSample is nullptr"); - return; + void NativeLauncher::InitMainSampleSlice(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitMainSampleSlice"); + SliceProxy *mainViewSample = new AbilitySliceProxy; + if (mainViewSample == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mainViewSample is nullptr"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_MAIN_SAMPLE, mainViewSample); } - NativeAbility::GetInstance().AddSliceProxy(VIEW_MAIN_SAMPLE, mainViewSample); -} -void NativeLauncher::InitMainAlarmSlice(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitMainAlarmSlice"); - SliceProxy *mainAlarmView = new AbilitySliceProxy; - if (mainAlarmView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mainAlarmView is nullptr"); - return; + void NativeLauncher::InitMainAlarmSlice(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitMainAlarmSlice"); + SliceProxy *mainAlarmView = new AbilitySliceProxy; + if (mainAlarmView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mainAlarmView is nullptr"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_MAIN_ALARM, mainAlarmView); } - NativeAbility::GetInstance().AddSliceProxy(VIEW_MAIN_ALARM, mainAlarmView); -} -void NativeLauncher::InitMainTempSlice(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitMainTempSlice"); - SliceProxy *mainTempView = new AbilitySliceProxy; - if (mainTempView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mainTempView is nullptr"); - return; + void NativeLauncher::InitMainTempSlice(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitMainTempSlice"); + SliceProxy *mainTempView = new AbilitySliceProxy; + if (mainTempView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mainTempView is nullptr"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_MAIN_TEMP, mainTempView); } - NativeAbility::GetInstance().AddSliceProxy(VIEW_MAIN_TEMP, mainTempView); -} -void NativeLauncher::InitCompassSlice(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::MainCompassView"); - SliceProxy *mainCompassView = new AbilitySliceProxy; - if (mainCompassView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mainCompassView is nullptr"); - return; + void NativeLauncher::InitCompassSlice(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::MainCompassView"); + SliceProxy *mainCompassView = new AbilitySliceProxy; + if (mainCompassView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mainCompassView is nullptr"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_COMPASS, mainCompassView); } - NativeAbility::GetInstance().AddSliceProxy(VIEW_COMPASS, mainCompassView); -} -void NativeLauncher::InitIndoorWalkSlice(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::IndoorWalkView"); - SliceProxy *indoorWalkView = new AbilitySliceProxy; - if (indoorWalkView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "indoorWalkView is nullptr"); - return; + void NativeLauncher::InitIndoorWalkSlice(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::IndoorWalkView"); + SliceProxy *indoorWalkView = new AbilitySliceProxy; + if (indoorWalkView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "indoorWalkView is nullptr"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_INDOORWALK, indoorWalkView); } - NativeAbility::GetInstance().AddSliceProxy(VIEW_INDOORWALK, indoorWalkView); -} -void NativeLauncher::InitRebootSlice(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::RebootView"); - SliceProxy *rebootView = new AbilitySliceProxy; - if (rebootView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "rebootView is nullptr"); - return; + void NativeLauncher::InitRebootSlice(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::RebootView"); + SliceProxy *rebootView = new AbilitySliceProxy; + if (rebootView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "rebootView is nullptr"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_REBOOT, rebootView); } - NativeAbility::GetInstance().AddSliceProxy(VIEW_REBOOT, rebootView); -} -void NativeLauncher::InitConnectPhoneSlice(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::ConnectPhoneView"); - SliceProxy *connectPhoneView = new AbilitySliceProxy; - if (connectPhoneView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "connectPhoneView is nullptr"); - return; + void NativeLauncher::InitConnectPhoneSlice(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::ConnectPhoneView"); + SliceProxy *connectPhoneView = new AbilitySliceProxy; + if (connectPhoneView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "connectPhoneView is nullptr"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_CONNECT_PHONE, connectPhoneView); } - NativeAbility::GetInstance().AddSliceProxy(VIEW_CONNECT_PHONE, connectPhoneView); -} -void NativeLauncher::InitAlarmPopUpSlice(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitAlarmPopUpSlice"); - SliceProxy *alarmPopUpView = new AbilitySliceProxy; - if (alarmPopUpView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mainAlarmView is nullptr"); - return; + void NativeLauncher::InitAlarmPopUpSlice(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitAlarmPopUpSlice"); + SliceProxy *alarmPopUpView = new AbilitySliceProxy; + if (alarmPopUpView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mainAlarmView is nullptr"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_ALARM_POP_UP, alarmPopUpView); } - NativeAbility::GetInstance().AddSliceProxy(VIEW_ALARM_POP_UP, alarmPopUpView); -} -void NativeLauncher::InitMainBloodOxyView(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitMainBloodOxyView"); - SliceProxy *bloodOxygenView = new AbilitySliceProxy; - if (bloodOxygenView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bloodOxygenView is nullptr"); - return; + void NativeLauncher::InitMainBloodOxyView(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitMainBloodOxyView"); + SliceProxy *bloodOxygenView = new AbilitySliceProxy; + if (bloodOxygenView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bloodOxygenView is nullptr"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_BLOODOXY_SAMPLE, bloodOxygenView); } - NativeAbility::GetInstance().AddSliceProxy(VIEW_BLOODOXY_SAMPLE, bloodOxygenView); -} -void NativeLauncher::InitMainMakePhoneView(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitMainMakePhoneView"); - SliceProxy *makePhoneView = new AbilitySliceProxy; - if (makePhoneView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "makePhoneView is nullptr"); - return; + void NativeLauncher::InitMainMakePhoneView(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitMainMakePhoneView"); + SliceProxy *makePhoneView = new AbilitySliceProxy; + if (makePhoneView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "makePhoneView is nullptr"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_MAEKPHONE_SAMPLE, makePhoneView); } - NativeAbility::GetInstance().AddSliceProxy(VIEW_MAEKPHONE_SAMPLE, makePhoneView); -} -void NativeLauncher::InitMainCallerLogView(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitMainCallerLogView"); - SliceProxy *callerLogView = new AbilitySliceProxy; - if (callerLogView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "callerLogView is nullptr"); - return; + void NativeLauncher::InitMainCallerLogView(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitMainCallerLogView"); + SliceProxy *callerLogView = new AbilitySliceProxy; + if (callerLogView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "callerLogView is nullptr"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_CALLER_SAMPLE, callerLogView); } - NativeAbility::GetInstance().AddSliceProxy(VIEW_CALLER_SAMPLE, callerLogView); -} -void NativeLauncher::InitActivitySlice(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitWeekStepSlice"); - SliceProxy *mainActivityView = new AbilitySliceProxy; - if (mainActivityView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mainActivityView is nullptr"); - return; + void NativeLauncher::InitActivitySlice(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitWeekStepSlice"); + SliceProxy *mainActivityView = new AbilitySliceProxy; + if (mainActivityView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mainActivityView is nullptr"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_MAIN_ACTIVITY, mainActivityView); } - NativeAbility::GetInstance().AddSliceProxy(VIEW_MAIN_ACTIVITY, mainActivityView); -} -void NativeLauncher::InitBluetoothSlice(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeAbility::InitBluetoothSlice"); - SliceProxy *mainBluetoothView = new AbilitySliceProxy; - if (mainBluetoothView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mainBluetoothView is nullptr"); - return; + void NativeLauncher::InitBluetoothSlice(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeAbility::InitBluetoothSlice"); + SliceProxy *mainBluetoothView = new AbilitySliceProxy; + if (mainBluetoothView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mainBluetoothView is nullptr"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_BLUETOOTH_EARPHONE, mainBluetoothView); } - NativeAbility::GetInstance().AddSliceProxy(VIEW_BLUETOOTH_EARPHONE, mainBluetoothView); -} -void NativeLauncher::InitSettingSlice(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitSettingSlice"); - SliceProxy *settingView = new AbilitySliceProxy; - if (settingView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "settingView is nullptr"); - return; + void NativeLauncher::InitSettingSlice(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitSettingSlice"); + SliceProxy *settingView = new AbilitySliceProxy; + if (settingView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "settingView is nullptr"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_SETTING, settingView); } - NativeAbility::GetInstance().AddSliceProxy(VIEW_SETTING, settingView); -} -void NativeLauncher::InitApplistSlice(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitApplistSlice"); - SliceProxy *applistView = new AbilitySliceProxy; - if (applistView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "applistView is nullptr"); - return; + void NativeLauncher::InitApplistSlice(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitApplistSlice"); + SliceProxy *applistView = new AbilitySliceProxy; + if (applistView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "applistView is nullptr"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_APPLIST, applistView); } - NativeAbility::GetInstance().AddSliceProxy(VIEW_APPLIST, applistView); -} -void NativeLauncher::InitOfflineVoice(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitOfflineVoice"); - SliceProxy *offlineVoiceView = new AbilitySliceProxy; - if (offlineVoiceView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "offlineVoiceView is nullptr"); - return; + void NativeLauncher::InitOfflineVoice(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitOfflineVoice"); + SliceProxy *offlineVoiceView = new AbilitySliceProxy; + if (offlineVoiceView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "offlineVoiceView is nullptr"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_OFFLINEVOICE, offlineVoiceView); } - NativeAbility::GetInstance().AddSliceProxy(VIEW_OFFLINEVOICE, offlineVoiceView); -} -void NativeLauncher::InitUISampleSlice(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitUISampleSlice"); - SliceProxy *uisampleView = new AbilitySliceProxy; - if (uisampleView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "uisampleView"); - return; + void NativeLauncher::InitUISampleSlice(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitUISampleSlice"); + SliceProxy *uisampleView = new AbilitySliceProxy; + if (uisampleView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "uisampleView"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_UISAMPLE, uisampleView); } - NativeAbility::GetInstance().AddSliceProxy(VIEW_UISAMPLE, uisampleView); -} + void NativeLauncher::InitDialSlice(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitBloodSlice"); + SliceProxy *dialview = new AbilitySliceProxy; + if (dialview == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dialview"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_DIAL, dialview); + } + } diff --git a/code/sdk/application/wearable/nativeapp/nativeui/blood/include/BloodView.h b/code/sdk/application/wearable/nativeapp/nativeui/blood/include/BloodView.h new file mode 100644 index 000000000..3a40c122a --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/blood/include/BloodView.h @@ -0,0 +1,65 @@ +/*** + * @Author: Caisking 3449750381@qq.com + * @Date: 2023-12-12 16:55:23 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-01-15 17:21:42 + * @FilePath: /1.FD230/FD230/code/sdk/application/wearable/nativeapp/nativeui/blood/include/BloodView.h + * @Description: + * @ + * @Copyright (c) 2024 by Caisking , All Rights Reserved. + */ +#ifndef _Blood_VIEW_H +#define _Blood_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include +#include "components/ui_view_group.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" +#include "components/ui_image_animator.h" +#include "components/ui_label_button_ext.h" +#include "components/ui_card_page.h" + + + +namespace OHOS +{ + +#define WARNING "button1" +#define CHECK "button2" + + class BloodView : public UICardPage + { + + public: + BloodView(); + virtual ~BloodView(); + static BloodView *GetInstance(void); + + bool InitView(); + void DeInit(); + + bool AddButton(); + bool InitLable(); + bool Initbackground(); + + void PreLoad(void) override; + void UnLoad(void) override; + + private: + UIView::OnDragListener *draglistener{nullptr}; + BloodView(BloodView &&) = delete; + BloodView &operator=(BloodView &&) = delete; + + UIImageView *background = nullptr; + UIButton *warnButton = nullptr; + UILabelButtonExt *monitorButton = nullptr; + UILabel *titleLabel = nullptr; + UILabel *bloodLabel = nullptr; + UILabel *timeLabel = nullptr; + bool viewiInitStatus{false}; + }; +} // namespace OHOS +#endif // Blood_PRESENTER_H diff --git a/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodView.cpp new file mode 100644 index 000000000..55a47120e --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodView.cpp @@ -0,0 +1,254 @@ +/*** + * @Author: Caisking 3449750381@qq.com + * @Date: 2023-12-12 16:55:23 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-01-15 17:31:26 + * @FilePath: /1.FD230/FD230/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodView.cpp + * @Description: + * @ + * @Copyright (c) 2024 by Caisking , All Rights Reserved. + */ + +#include "blood/include/BloodView.h" + +#include "common/image_cache_manager.h" +#include "UiConfig.h" +#include "ui_resource_image.h" +#include +#include "components/ui_button.h" +#include "MainViewSample.h" +#include "components/ui_view_group.h" + +namespace OHOS +{ + static BloodView *g_pBloodView{nullptr}; + + BloodView::BloodView() + { + SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); + g_pBloodView = this; + } + + BloodView::~BloodView() + { + DeInit(); + g_pBloodView = nullptr; + } + + BloodView *BloodView::GetInstance() + { + return g_pBloodView; + } + /*** + * @description: + * @return 添加按键是否成功 + */ + bool BloodView::AddButton() + { + // Add Button to App + if (warnButton == nullptr) + { + warnButton = new UIButton(); + } + warnButton->SetPosition(300, 57); // widget's left position and top position + warnButton->Resize(26, 26); // widget's width and height + warnButton->SetViewId(WARNING); // Set style + warnButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + warnButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + + // Set additional property + char *button1defaultImgSrc = "/user/res/Blood/Vector.bin"; + char *button1triggeredImgSrc = nullptr; + warnButton->SetImageSrc(button1defaultImgSrc, button1triggeredImgSrc); + warnButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + // UIView::OnClickListener *button1Click = static_cast(BloodPresenter::GetInstance()); + // warnButton->SetOnClickListener(button1Click); + // Add to rootView + Add(warnButton); + + // Add LabelButtonExt to App + if (monitorButton == nullptr) + { + monitorButton = new UILabelButtonExt(); + } + monitorButton->SetPosition(118, 336); // widget's left position and top position + monitorButton->Resize(230, 80); // widget's width and height + monitorButton->SetViewId(CHECK); // Set style + monitorButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xffcd492c); + + // Set additional property + monitorButton->SetText("检测"); + monitorButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); + monitorButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // UIView::OnClickListener *labelButton1Click = static_cast(BloodPresenter::GetInstance()); + // monitorButton->SetOnClickListener(labelButton1Click); + Add(monitorButton); + return true; + } + /*** + * @description: + * @return 初始化标签是否成功 + */ + bool BloodView::InitLable() + { + // Add Label to App + if (bloodLabel == nullptr) + { + bloodLabel = new UILabel(); + } + bloodLabel->SetPosition(157, 105); // widget's left position and top position + bloodLabel->Resize(200, 60); // widget's width and height + bloodLabel->SetViewId("label2"); // Set style + bloodLabel->SetStyle(STYLE_TEXT_FONT, 140); + + // Set additional property + int bloodoxygen = 98; + bloodLabel->SetText(std::to_string(bloodoxygen).c_str()); + bloodLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + bloodLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + bloodLabel->SetRollSpeed(0); + bloodLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 140); + + // Add to rootView + Add(bloodLabel); + + // Add Label to App + if (timeLabel == nullptr) + { + timeLabel = new UILabel(); + } + timeLabel->SetPosition(141, 263); // widget's left position and top position + timeLabel->Resize(185, 35); // widget's width and height + timeLabel->SetViewId("label1"); // Set style + timeLabel->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + timeLabel->SetText("20分钟前检测"); + timeLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + timeLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + timeLabel->SetRollSpeed(0); + timeLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + Add(timeLabel); + + // Add Label to App + if (titleLabel == nullptr) + { + titleLabel = new UILabel(); + } + titleLabel->SetPosition(143, 52); // widget's left position and top position + titleLabel->Resize(200, 60); // widget's width and height + titleLabel->SetViewId("label3"); // Set style + titleLabel->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + titleLabel->SetText("血氧饱和度"); + titleLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + titleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + titleLabel->SetRollSpeed(0); + titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + Add(titleLabel); + return true; + } + /*** + * @description: + * @return 初始化背景是否成功 + */ + bool BloodView::Initbackground() + { + // Add ImageView to App + if (background == nullptr) + { + background = new UIImageView(); + } + background->SetPosition(0, 0); // widget's left position and top position + background->Resize(466, 466); // widget's width and height + background->SetViewId("image1"); // Set style + // Set additional property + char *image1imagesPath = "/user/res/Blood/beijing.bin"; + background->SetSrc(image1imagesPath); + + // Add to rootView + Add(background); + return true; + } + /*** + * @description: + * @return 是否初始化成功 + */ + bool BloodView::InitView() + { + printf("Function: %s, Line: %d\n", __PRETTY_FUNCTION__, __LINE__); + if (!Initbackground()) + { + printf("Initbackground error!\n"); + }; + if (!InitLable()) + { + printf("InitLable error!\n"); + }; + if (!AddButton()) + { + printf("AddButton error!\n"); + }; + SetCoverable(true); + return true; + } + /*** + * @description: + * @return 删除组件 + */ + void BloodView::DeInit() + { + + if (background != nullptr) + { + delete background; + background = nullptr; + } + if (warnButton != nullptr) + { + delete warnButton; + warnButton = nullptr; + } + if (monitorButton != nullptr) + { + delete monitorButton; + monitorButton = nullptr; + } + if (bloodLabel != nullptr) + { + delete bloodLabel; + bloodLabel = nullptr; + } + if (timeLabel != nullptr) + { + delete timeLabel; + timeLabel = nullptr; + } + if (titleLabel != nullptr) + { + delete titleLabel; + titleLabel = nullptr; + } + } + void BloodView::PreLoad(void) + { + //printf("Function: %s, Line: %d\n", __PRETTY_FUNCTION__, __LINE__); + if (InitView()) + { + viewiInitStatus = true; + } + } + + void BloodView::UnLoad(void) + { + } + +} diff --git a/code/sdk/application/wearable/nativeapp/nativeui/clock/include/MainClockView.h b/code/sdk/application/wearable/nativeapp/nativeui/clock/include/MainClockView.h index deac61eb2..b43fe8920 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/clock/include/MainClockView.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/clock/include/MainClockView.h @@ -36,7 +36,7 @@ #include "components/ui_box_progress.h" #include "components/ui_image_view.h" #include "components/ui_label.h" -#include "battery.h" +#include "battery_hal.h" #include "hal_tick.h" diff --git a/code/sdk/application/wearable/nativeapp/nativeui/dial/include/DialPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/dial/include/DialPresenter.h new file mode 100644 index 000000000..09b2bc01c --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/dial/include/DialPresenter.h @@ -0,0 +1,35 @@ +#ifndef _Dial_PRESENTER_H +#define _Dial_PRESENTER_H + +#include "Presenter.h" +#include "DialView.h" +#include "dial/include/Digital_clockView.h" + +namespace OHOS +{ + class DialView; + + class DialPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + DialPresenter(); + virtual ~DialPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static DialPresenter *GetInstance(); + + private: + Digital_clockView *g_pDigital_clockView{nullptr}; + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} // namespace OHOS + +#endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/dial/include/DialSetupView.h b/code/sdk/application/wearable/nativeapp/nativeui/dial/include/DialSetupView.h new file mode 100644 index 000000000..ebd9bccd0 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/dial/include/DialSetupView.h @@ -0,0 +1,45 @@ +#ifndef _DIALSETUP_VIEW_H +#define _DIALSETUP_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include +#include "components/ui_view_group.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" + +// #include "DialSetupPresenter.h" +namespace OHOS +{ + class DialSetupPresenter; + class DialSetupView : public View + { + + public: + DialSetupView(); + virtual ~DialSetupView(); + static DialSetupView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + void Init(); + void DeInit(); + UIView *GetView(); + + private: + UIView::OnDragListener *draglistener{nullptr}; + // 以下控件属性通过new实例化后,add到对应root属性上; + DialSetupView(DialSetupView &&) = delete; + DialSetupView &operator=(DialSetupView &&) = delete; + + UIViewGroup *container_ = nullptr; + UILabel *label1_ = nullptr; + UIImageView *image2_ = nullptr; + UILabel *label2_ = nullptr; + UIImageView *image1_ = nullptr; + }; +} // namespace OHOS +#endif // DialSetup_PRESENTER_H diff --git a/code/sdk/application/wearable/nativeapp/nativeui/dial/include/DialSuccesView.h b/code/sdk/application/wearable/nativeapp/nativeui/dial/include/DialSuccesView.h new file mode 100644 index 000000000..8839f427d --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/dial/include/DialSuccesView.h @@ -0,0 +1,44 @@ +#ifndef _DIALSUCCES_VIEW_H +#define _DIALSUCCES_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include +#include "components/ui_view_group.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" + +// #include "DialSuccesPresenter.h" +namespace OHOS +{ + class DialSuccesPresenter; + class DialSuccesView : public View + { + + public: + DialSuccesView(); + virtual ~DialSuccesView(); + static DialSuccesView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + void Init(); + void DeInit(); + UIView *GetView(); + + private: + UIView::OnDragListener *draglistener{nullptr}; + // 以下控件属性通过new实例化后,add到对应root属性上; + DialSuccesView(DialSuccesView &&) = delete; + DialSuccesView &operator=(DialSuccesView &&) = delete; + + UIViewGroup *container_ = nullptr; + UILabel *label1_ = nullptr; + UIImageView *image1_ = nullptr; + UILabel *label2_ = nullptr; + }; +} // namespace OHOS +#endif // DialSucces_PRESENTER_H diff --git a/code/sdk/application/wearable/nativeapp/nativeui/dial/include/DialView.h b/code/sdk/application/wearable/nativeapp/nativeui/dial/include/DialView.h new file mode 100644 index 000000000..8dd700d89 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/dial/include/DialView.h @@ -0,0 +1,61 @@ +/*** + * @Author: Caisking 3449750381@qq.com + * @Date: 2024-01-11 18:56:47 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-01-12 15:12:59 + * @FilePath: /1.FD230/FD230/code/sdk/application/wearable/nativeapp/nativeui/dial/include/DialView.h + * @Description: + * @ + * @Copyright (c) 2024 by Caisking , All Rights Reserved. + */ +#ifndef _Dial_VIEW_H +#define _Dial_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include +#include "components/ui_view_group.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" +#include "components/ui_image_animator.h" +#include "components/ui_label_button_ext.h" + +#include "DialPresenter.h" +namespace OHOS +{ + + class DialPresenter; + class DialView : public View + { + + public: + DialView(); + virtual ~DialView(); + static DialView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + void Init(); + void DeInit(); + + UIView *GetView(); + + private: + UIView::OnDragListener *draglistener{nullptr}; + DialView(DialView &&) = delete; + DialView &operator=(DialView &&) = delete; + + UIViewGroup *container_ = nullptr; + UIScrollView *scrollView1_ = nullptr; + + UIButton *button5_ = nullptr; + UIButton *button4_ = nullptr; + UIButton *button3_ = nullptr; + UIButton *button2_ = nullptr; + UIButton *button1_ = nullptr; + }; +} // namespace OHOS +#endif // Dial_PRESENTER_H diff --git a/code/sdk/application/wearable/nativeapp/nativeui/dial/include/Digital_clockView.h b/code/sdk/application/wearable/nativeapp/nativeui/dial/include/Digital_clockView.h new file mode 100644 index 000000000..a94714094 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/dial/include/Digital_clockView.h @@ -0,0 +1,280 @@ +/*** + * @Author: Caisking 3449750381@qq.com + * @Date: 2024-01-16 16:17:50 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-01-17 16:50:57 + * @FilePath: /1.FD230/FD230/code/sdk/application/wearable/nativeapp/nativeui/dial/include/Digital_clockView.h + * @Description: + * @ + * @Copyright (c) 2024 by Caisking , All Rights Reserved. + */ +#ifndef _Digital_clock_VIEW_H +#define _Digital_clock_VIEW_H + +#include "BaseView.h" +#include +#include +#include "View.h" +#include +#include "components/ui_image_animator.h" +#include "components/ui_button.h" +#include "components/ui_view_group.h" +#include "components/ui_label_button_ext.h" +#include "components/ui_chart.h" +#include "components/ui_list.h" +#include "components/icon_adapter.h" +#include "wearable_log.h" +#include "ohos_types.h" +#include "components/ui_card_page.h" +#include "components/ui_box_progress.h" +#include "components/ui_image_view.h" +#include "components/ui_label.h" +#include "components/ui_sweep_clock.h" +#include +#include +#include +#include "battery_hal.h" +#include "cJSON.h" +#include "sys/time.h" + +extern uint8_t battery_get_voltage(float *voltage); + +namespace OHOS +{ + +#define CHANGEBUTTON "changebutton" // 切换表盘按键 + class SweepClockCallback : public AnimatorCallback + { + public: + explicit SweepClockCallback(UISweepClock *clock) : sweepClock(clock) {} + ~SweepClockCallback() {} + + virtual void Callback(UIView *view) + { + // UNUSED(view); + struct timeval tv; + gettimeofday(&tv, NULL); + uint64_t second = tv.tv_sec; + uint64_t uSecond = tv.tv_usec; + uint64_t minute = second / MIN_TO_HOUR; + uint64_t hour = minute / MIN_TO_HOUR; + uint8_t realHour = static_cast(hour % HOURLY_SYSTEM); + uint8_t realMinute = static_cast(minute % MIN_TO_HOUR); + uint16_t realMilliSecond = static_cast((second % MIN_TO_HOUR) * + SEC_TO_MILLI + + uSecond / USEC_TO_MILLI); + sweepClock->SetSweepTime12Hour(realHour, realMinute, realMilliSecond, 1); + } + + private: + static constexpr int16_t SEC_TO_MILLI = 1000; + static constexpr int16_t USEC_TO_MILLI = 1000; + static constexpr int16_t MIN_TO_HOUR = 60; + static constexpr int16_t HOURLY_SYSTEM = 24; + static constexpr int16_t INTERVAL = 30; + UISweepClock *sweepClock{nullptr}; + }; + /* -------------------------------------------------------------------------- */ + class timeLableCallback : public AnimatorCallback + { + private: + UILabel *timeLable{nullptr}; + std::string stringtime; + + public: + explicit timeLableCallback(UILabel *timeLable, std::string stringtime) : timeLable(timeLable), stringtime(stringtime) {} + ~timeLableCallback() {} + // 时钟更新的回调函数 + virtual void Callback(UIView *view) override + { + /* --------------------------------- 模拟更新时间 --------------------------------- */ + // 从字符串中解析小时和分钟 + int hour = std::stoi(stringtime.substr(0, 2)); + int minute = std::stoi(stringtime.substr(3, 2)); + // 进位处理 + minute++; + if (minute >= 60) + { + minute = 0; + hour = (hour + 1) % 24; // 修复进位时的处理 + } + // 将小时和分钟转换为字符串,并更新 stringtime + stringtime = (hour < 10 ? "0" : "") + std::to_string(hour) + ":" + (minute < 10 ? "0" : "") + std::to_string(minute); + timeLable->SetText(stringtime.c_str()); + } + }; + /* -------------------------------------------------------------------------- */ + class myProgressCallback : public AnimatorCallback + { + private: + UIBoxProgress *progress{nullptr}; // 电池进度条控件指针 + UILabel *batterylabel{nullptr}; // 显示电池百分比的文本控件指针 + + public: + explicit myProgressCallback(UIBoxProgress *progress, UILabel *batterylabel) : progress(progress), batterylabel(batterylabel) {} + ~myProgressCallback() {} + + // 电池进度更新的回调函数 + virtual void Callback(UIView *view) override + { + // 获取电池电压值 + float voltage = 0.0F; + uint8_t value = 0; + value = battery_get_voltage(&voltage); + // 设置种子 + // srand(static_cast(time(0))); + // 生成随机数 + // int value = rand() % 101; // 取余操作可以将随机数限制在0到100之间 + printf("value:%d\n", value); + // 根据电池电量值选择相应的进度条前景图片 + char *progress1ForeImageSrc = nullptr; + char *progress1BackImageSrc = nullptr; + if (value <= 10) + { + progress1ForeImageSrc = "/user/res/Battery/Battery_Limit.bin"; // 低电量图片路径 + } + else if (value <= 20) + { + progress1ForeImageSrc = "/user/res/Battery/Battery_Save.bin"; // 中等电量图片路径 + } + else + { + progress1ForeImageSrc = "/user/res/Battery/Battery_Nomoal.bin"; // 正常电量图片路径 + } + + // 设置进度条的前景和背景图片,并更新进度值 + progress->SetImage(progress1ForeImageSrc, progress1BackImageSrc); + progress->SetValue(value); // 更新界面 + batterylabel->SetText((std::to_string(value) + "%").c_str()); // 更新百分比显示 + } + }; + class mytimeimageCallback : public AnimatorCallback + { + private: + UIImageView *hour1{nullptr}; // 时钟小时第一位图像控件指针 + UIImageView *hour2{nullptr}; // 时钟小时第二位图像控件指针 + UIImageView *minute1{nullptr}; // 时钟分钟第一位图像控件指针 + UIImageView *minute2{nullptr}; // 时钟分钟第二位图像控件指针 + std::string stringtime; + std::string imageFolderPath; + + public: + explicit mytimeimageCallback(UIImageView *hour1, UIImageView *hour2, UIImageView *minute1, UIImageView *minute2, std::string imageFolderPath, std::string stringtime) + : hour1(hour1), hour2(hour2), minute1(minute1), minute2(minute2), imageFolderPath(imageFolderPath), stringtime(stringtime) {} + ~mytimeimageCallback() {} + + // 时钟图片更新的回调函数 + virtual void Callback(UIView *view) override + { + // 从字符串中解析小时和分钟 + int hour = std::stoi(stringtime.substr(0, 2)); + int minute = std::stoi(stringtime.substr(3, 2)); + // 进位处理 + minute++; + if (minute >= 60) + { + minute = 0; + hour = (hour + 1) % 24; // 修复进位时的处理 + } + // 将小时和分钟转换为字符串,并更新 stringtime + stringtime = (hour < 10 ? "0" : "") + std::to_string(hour) + ":" + (minute < 10 ? "0" : "") + std::to_string(minute); + printf("Before updating images\n"); + // printf("--%s:%s--\n", imageFolderPath.c_str(), stringtime.c_str()); + updateImage(hour1, imageFolderPath.c_str(), stringtime.substr(0, 1)); + updateImage(hour2, imageFolderPath.c_str(), stringtime.substr(1, 1)); + updateImage(minute1, imageFolderPath.c_str(), stringtime.substr(3, 1)); + updateImage(minute2, imageFolderPath.c_str(), stringtime.substr(4, 1)); + printf("After updating images\n"); + } + + private: + // 更新图片路径 + void updateImage(UIImageView *imageControl, const std::string &folderPath, const std::string &imageName) + { + std::string imagePath = folderPath + imageName + ".bin"; + if (fileExists(imagePath)) + { + printf("File exists: %s\n", imagePath.c_str()); + imageControl->SetSrc(imagePath.c_str()); + printf("File set!\n"); + } + else + { + // 处理文件不存在的情况 + printf("File does not exist: %s\n", imagePath.c_str()); + return; + // 设置一个默认图片或者采取其他容错处理 + // imageControl->SetSrc("/user/res/default_image.bin"); + } + } + // 检查文件是否存在 + bool fileExists(const std::string &filePath) + { + std::ifstream file(filePath); + return file.good(); + } + }; + + class Digital_clockView : public UICardPage + { + + public: + Digital_clockView(); + virtual ~Digital_clockView(); + static Digital_clockView *GetInstance(void); + + bool InitView(); + void DeInit(); + void setJsonFilePath(const std::string &filePath); + void updateClockTime(const std::string &stringtime); + void FreeImagePathsArray(const char **imagePaths); + void InitImageAnimatorSource(UIImageAnimatorView *&imageAnimator, const char **imagePaths, int numFrames, int left, int top, int width, int height, const char *viewId, int time); + const char **CreateImagePathsArray(const char *basePath, const char *fileExtension, int numImages); + void addImageView(int left, int top, const char *imagePath, const char *viewId, int offsetX, int offsetY); + bool Initbackground(); + bool Initpointer(); + bool Initdigit(); + bool Initdata(); + bool Initweek(); + bool Initbattery(); + bool AddButton(); + void PreLoad(void) override; + void UnLoad(void) override; + + private: + UIView::OnDragListener *draglistener{nullptr}; + Digital_clockView(Digital_clockView &&) = delete; + Digital_clockView &operator=(Digital_clockView &&) = delete; + + // UIViewGroup *container_ = nullptr; + UIImageView *background = nullptr; + UIImageView *hour1 = nullptr; + UIImageView *hour2 = nullptr; + UIImageView *colon = nullptr; + UIImageView *minute1 = nullptr; + UIImageView *minute2 = nullptr; + UILabel *timeLable = nullptr; + UILabel *dateLable = nullptr; + UILabel *weekLable = nullptr; + UILabel *batteryLable = nullptr; + UIButton *changebutton = nullptr; + UIBoxProgress *progress = nullptr; + UISweepClock *sweepClock1_ = nullptr; + UIImageAnimatorView *backgroundAnimator = nullptr; + + AnimatorCallback *mytimeimageCallback_ = nullptr; + Animator *timeimageanimator_ = nullptr; + AnimatorCallback *timeLableCallback_ = nullptr; + Animator *timeLableanimator_ = nullptr; + AnimatorCallback *progress1callback_ = nullptr; + Animator *progress1animator_ = nullptr; + AnimatorCallback *sweepClock1callback_ = nullptr; + Animator *sweepClock1animator_ = nullptr; + bool viewiInitStatus{false}; + const char **imagePaths; + std::string digitspath; + std::string stringtime; + std::string JosnfilePath = "/user/res/clocks/default.json"; + }; +} // namespace OHOS +#endif // Digital_clock_PRESENTER_H diff --git a/code/sdk/application/wearable/nativeapp/nativeui/dial/include/dial_resource_image.h b/code/sdk/application/wearable/nativeapp/nativeui/dial/include/dial_resource_image.h new file mode 100644 index 000000000..b61ded772 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/dial/include/dial_resource_image.h @@ -0,0 +1,297 @@ +/*** + * @Author: Caisking 3449750381@qq.com + * @Date: 2024-01-17 10:51:35 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-01-17 10:51:38 + * @FilePath: /1.FD230/FD230/code/sdk/application/wearable/nativeapp/nativeui/dial/include/dial_resource_image.h + * @Description: + * @ + * @Copyright (c) 2024 by Caisking , All Rights Reserved. + */ +#ifndef DIAL_RESOURCE_IMAGE_H +#define DIAL_RESOURCE_IMAGE_H +#include +namespace OHOS +{ + static const int DIR_MASK = 0xfff00000; + static const int PNG_MASK = 0x000fffff; + /* -------------------------------------------------------------------------- */ + static const int FLOWERBUD_0 = 0x100001; + static const int FLOWERBUD_1 = 0x100002; + static const int FLOWERBUD_2 = 0x100003; + static const int FLOWERBUD_3 = 0x100004; + static const int FLOWERBUD_4 = 0x100005; + static const int FLOWERBUD_5 = 0x100006; + static const int FLOWERBUD_6 = 0x100007; + static const int FLOWERBUD_7 = 0x100008; + static const int FLOWERBUD_8 = 0x100009; + static const int FLOWERBUD_9 = 0x10000a; + static const int FLOWERBUD_BACKGROUND = 0x10000b; + static const int FLOWERBUD_EIGHT = 0x10000c; + static const int FLOWERBUD_FIVE = 0x10000d; + static const int FLOWERBUD_FOUR = 0x10000e; + static const int FLOWERBUD_NINE = 0x10000f; + static const int FLOWERBUD_ONE = 0x100010; + static const int FLOWERBUD_POINT = 0x100011; + static const int FLOWERBUD_SEVEN = 0x100012; + static const int FLOWERBUD_SIX = 0x100013; + static const int FLOWERBUD_THREE = 0x100014; + static const int FLOWERBUD_TWO = 0x100015; + static const int FLOWERBUD_ZERO = 0x100016; + /* -------------------------------------------------------------------------- */ + static const int KUMI_0 = 0x200001; + static const int KUMI_1 = 0x200002; + static const int KUMI_2 = 0x200003; + static const int KUMI_3 = 0x200004; + static const int KUMI_4 = 0x200005; + static const int KUMI_5 = 0x200006; + static const int KUMI_6 = 0x200007; + static const int KUMI_7 = 0x200008; + static const int KUMI_8 = 0x200009; + static const int KUMI_9 = 0x20000a; + static const int KUMI_BACKGROUND = 0x20000b; + static const int KUMI_POINT = 0x20000c; + /* -------------------------------------------------------------------------- */ + static const int MALIAO_0 = 0x300001; + static const int MALIAO_1 = 0x300002; + static const int MALIAO_2 = 0x300003; + static const int MALIAO_3 = 0x300004; + static const int MALIAO_4 = 0x300005; + static const int MALIAO_5 = 0x300006; + static const int MALIAO_6 = 0x300007; + static const int MALIAO_7 = 0x300008; + static const int MALIAO_8 = 0x300009; + static const int MALIAO_9 = 0x30000a; + static const int MALIAO_BACKGROUND = 0x30000b; + static const int MALIAO_POINT = 0x30000c; + static const int MAOMAO_0 = 0x400001; + static const int MAOMAO_1 = 0x400002; + static const int MAOMAO_2 = 0x400003; + static const int MAOMAO_3 = 0x400004; + static const int MAOMAO_4 = 0x400005; + static const int MAOMAO_5 = 0x400006; + static const int MAOMAO_6 = 0x400007; + static const int MAOMAO_7 = 0x400008; + static const int MAOMAO_8 = 0x400009; + static const int MAOMAO_9 = 0x40000a; + static const int MAOMAO_POINT = 0x40000b; + /* -------------------------------------------------------------------------- */ + static const int BACKGROUND_1 = 0x500001; + static const int BACKGROUND_10 = 0x500002; + static const int BACKGROUND_100 = 0x500003; + static const int BACKGROUND_101 = 0x500004; + static const int BACKGROUND_102 = 0x500005; + static const int BACKGROUND_103 = 0x500006; + static const int BACKGROUND_104 = 0x500007; + static const int BACKGROUND_105 = 0x500008; + static const int BACKGROUND_106 = 0x500009; + static const int BACKGROUND_107 = 0x50000a; + static const int BACKGROUND_108 = 0x50000b; + static const int BACKGROUND_109 = 0x50000c; + static const int BACKGROUND_11 = 0x50000d; + static const int BACKGROUND_110 = 0x50000e; + static const int BACKGROUND_111 = 0x50000f; + static const int BACKGROUND_112 = 0x500010; + static const int BACKGROUND_113 = 0x500011; + static const int BACKGROUND_114 = 0x500012; + static const int BACKGROUND_115 = 0x500013; + static const int BACKGROUND_116 = 0x500014; + static const int BACKGROUND_117 = 0x500015; + static const int BACKGROUND_118 = 0x500016; + static const int BACKGROUND_119 = 0x500017; + static const int BACKGROUND_12 = 0x500018; + static const int BACKGROUND_120 = 0x500019; + static const int BACKGROUND_121 = 0x50001a; + static const int BACKGROUND_122 = 0x50001b; + static const int BACKGROUND_123 = 0x50001c; + static const int BACKGROUND_124 = 0x50001d; + static const int BACKGROUND_125 = 0x50001e; + static const int BACKGROUND_126 = 0x50001f; + static const int BACKGROUND_127 = 0x500020; + static const int BACKGROUND_128 = 0x500021; + static const int BACKGROUND_129 = 0x500022; + static const int BACKGROUND_13 = 0x500023; + static const int BACKGROUND_130 = 0x500024; + static const int BACKGROUND_131 = 0x500025; + static const int BACKGROUND_132 = 0x500026; + static const int BACKGROUND_133 = 0x500027; + static const int BACKGROUND_134 = 0x500028; + static const int BACKGROUND_135 = 0x500029; + static const int BACKGROUND_136 = 0x50002a; + static const int BACKGROUND_137 = 0x50002b; + static const int BACKGROUND_138 = 0x50002c; + static const int BACKGROUND_139 = 0x50002d; + static const int BACKGROUND_14 = 0x50002e; + static const int BACKGROUND_140 = 0x50002f; + static const int BACKGROUND_141 = 0x500030; + static const int BACKGROUND_142 = 0x500031; + static const int BACKGROUND_143 = 0x500032; + static const int BACKGROUND_144 = 0x500033; + static const int BACKGROUND_145 = 0x500034; + static const int BACKGROUND_146 = 0x500035; + static const int BACKGROUND_147 = 0x500036; + static const int BACKGROUND_148 = 0x500037; + static const int BACKGROUND_149 = 0x500038; + static const int BACKGROUND_15 = 0x500039; + static const int BACKGROUND_150 = 0x50003a; + static const int BACKGROUND_151 = 0x50003b; + static const int BACKGROUND_152 = 0x50003c; + static const int BACKGROUND_153 = 0x50003d; + static const int BACKGROUND_154 = 0x50003e; + static const int BACKGROUND_155 = 0x50003f; + static const int BACKGROUND_156 = 0x500040; + static const int BACKGROUND_157 = 0x500041; + static const int BACKGROUND_158 = 0x500042; + static const int BACKGROUND_159 = 0x500043; + static const int BACKGROUND_16 = 0x500044; + static const int BACKGROUND_160 = 0x500045; + static const int BACKGROUND_161 = 0x500046; + static const int BACKGROUND_162 = 0x500047; + static const int BACKGROUND_163 = 0x500048; + static const int BACKGROUND_164 = 0x500049; + static const int BACKGROUND_165 = 0x50004a; + static const int BACKGROUND_166 = 0x50004b; + static const int BACKGROUND_167 = 0x50004c; + static const int BACKGROUND_168 = 0x50004d; + static const int BACKGROUND_169 = 0x50004e; + static const int BACKGROUND_17 = 0x50004f; + static const int BACKGROUND_170 = 0x500050; + static const int BACKGROUND_171 = 0x500051; + static const int BACKGROUND_172 = 0x500052; + static const int BACKGROUND_173 = 0x500053; + static const int BACKGROUND_174 = 0x500054; + static const int BACKGROUND_175 = 0x500055; + static const int BACKGROUND_176 = 0x500056; + static const int BACKGROUND_177 = 0x500057; + static const int BACKGROUND_178 = 0x500058; + static const int BACKGROUND_179 = 0x500059; + static const int BACKGROUND_18 = 0x50005a; + static const int BACKGROUND_180 = 0x50005b; + static const int BACKGROUND_181 = 0x50005c; + static const int BACKGROUND_182 = 0x50005d; + static const int BACKGROUND_183 = 0x50005e; + static const int BACKGROUND_184 = 0x50005f; + static const int BACKGROUND_185 = 0x500060; + static const int BACKGROUND_186 = 0x500061; + static const int BACKGROUND_187 = 0x500062; + static const int BACKGROUND_188 = 0x500063; + static const int BACKGROUND_189 = 0x500064; + static const int BACKGROUND_19 = 0x500065; + static const int BACKGROUND_190 = 0x500066; + static const int BACKGROUND_191 = 0x500067; + static const int BACKGROUND_192 = 0x500068; + static const int BACKGROUND_193 = 0x500069; + static const int BACKGROUND_194 = 0x50006a; + static const int BACKGROUND_195 = 0x50006b; + static const int BACKGROUND_196 = 0x50006c; + static const int BACKGROUND_197 = 0x50006d; + static const int BACKGROUND_198 = 0x50006e; + static const int BACKGROUND_199 = 0x50006f; + static const int BACKGROUND_2 = 0x500070; + static const int BACKGROUND_20 = 0x500071; + static const int BACKGROUND_200 = 0x500072; + static const int BACKGROUND_201 = 0x500073; + static const int BACKGROUND_202 = 0x500074; + static const int BACKGROUND_203 = 0x500075; + static const int BACKGROUND_204 = 0x500076; + static const int BACKGROUND_205 = 0x500077; + static const int BACKGROUND_21 = 0x500078; + static const int BACKGROUND_22 = 0x500079; + static const int BACKGROUND_23 = 0x50007a; + static const int BACKGROUND_24 = 0x50007b; + static const int BACKGROUND_25 = 0x50007c; + static const int BACKGROUND_26 = 0x50007d; + static const int BACKGROUND_27 = 0x50007e; + static const int BACKGROUND_28 = 0x50007f; + static const int BACKGROUND_29 = 0x500080; + static const int BACKGROUND_3 = 0x500081; + static const int BACKGROUND_30 = 0x500082; + static const int BACKGROUND_31 = 0x500083; + static const int BACKGROUND_32 = 0x500084; + static const int BACKGROUND_33 = 0x500085; + static const int BACKGROUND_34 = 0x500086; + static const int BACKGROUND_35 = 0x500087; + static const int BACKGROUND_36 = 0x500088; + static const int BACKGROUND_37 = 0x500089; + static const int BACKGROUND_38 = 0x50008a; + static const int BACKGROUND_39 = 0x50008b; + static const int BACKGROUND_4 = 0x50008c; + static const int BACKGROUND_40 = 0x50008d; + static const int BACKGROUND_41 = 0x50008e; + static const int BACKGROUND_42 = 0x50008f; + static const int BACKGROUND_43 = 0x500090; + static const int BACKGROUND_44 = 0x500091; + static const int BACKGROUND_45 = 0x500092; + static const int BACKGROUND_46 = 0x500093; + static const int BACKGROUND_47 = 0x500094; + static const int BACKGROUND_48 = 0x500095; + static const int BACKGROUND_49 = 0x500096; + static const int BACKGROUND_5 = 0x500097; + static const int BACKGROUND_50 = 0x500098; + static const int BACKGROUND_51 = 0x500099; + static const int BACKGROUND_52 = 0x50009a; + static const int BACKGROUND_53 = 0x50009b; + static const int BACKGROUND_54 = 0x50009c; + static const int BACKGROUND_55 = 0x50009d; + static const int BACKGROUND_56 = 0x50009e; + static const int BACKGROUND_57 = 0x50009f; + static const int BACKGROUND_58 = 0x5000a0; + static const int BACKGROUND_59 = 0x5000a1; + static const int BACKGROUND_6 = 0x5000a2; + static const int BACKGROUND_60 = 0x5000a3; + static const int BACKGROUND_61 = 0x5000a4; + static const int BACKGROUND_62 = 0x5000a5; + static const int BACKGROUND_63 = 0x5000a6; + static const int BACKGROUND_64 = 0x5000a7; + static const int BACKGROUND_65 = 0x5000a8; + static const int BACKGROUND_66 = 0x5000a9; + static const int BACKGROUND_67 = 0x5000aa; + static const int BACKGROUND_68 = 0x5000ab; + static const int BACKGROUND_69 = 0x5000ac; + static const int BACKGROUND_7 = 0x5000ad; + static const int BACKGROUND_70 = 0x5000ae; + static const int BACKGROUND_71 = 0x5000af; + static const int BACKGROUND_72 = 0x5000b0; + static const int BACKGROUND_73 = 0x5000b1; + static const int BACKGROUND_74 = 0x5000b2; + static const int BACKGROUND_75 = 0x5000b3; + static const int BACKGROUND_76 = 0x5000b4; + static const int BACKGROUND_77 = 0x5000b5; + static const int BACKGROUND_78 = 0x5000b6; + static const int BACKGROUND_79 = 0x5000b7; + static const int BACKGROUND_8 = 0x5000b8; + static const int BACKGROUND_80 = 0x5000b9; + static const int BACKGROUND_81 = 0x5000ba; + static const int BACKGROUND_82 = 0x5000bb; + static const int BACKGROUND_83 = 0x5000bc; + static const int BACKGROUND_84 = 0x5000bd; + static const int BACKGROUND_85 = 0x5000be; + static const int BACKGROUND_86 = 0x5000bf; + static const int BACKGROUND_87 = 0x5000c0; + static const int BACKGROUND_88 = 0x5000c1; + static const int BACKGROUND_89 = 0x5000c2; + static const int BACKGROUND_9 = 0x5000c3; + static const int BACKGROUND_90 = 0x5000c4; + static const int BACKGROUND_91 = 0x5000c5; + static const int BACKGROUND_92 = 0x5000c6; + static const int BACKGROUND_93 = 0x5000c7; + static const int BACKGROUND_94 = 0x5000c8; + static const int BACKGROUND_95 = 0x5000c9; + static const int BACKGROUND_96 = 0x5000ca; + static const int BACKGROUND_97 = 0x5000cb; + static const int BACKGROUND_98 = 0x5000cc; + static const int BACKGROUND_99 = 0x5000cd; + /* -------------------------------------------------------------------------- */ + static const int MOMO_BACKGROUND = 0x600001; + static const int MOMO_HOUR = 0x600002; + static const int MOMO_MINUTE = 0x600003; + static const int MOMO_SECOND = 0x600004; + /* -------------------------------------------------------------------------- */ + static const int REDUCED_GRAPH_FLOWERBUD = 0x700001; + static const int REDUCED_GRAPH_KUMI = 0x700002; + static const int REDUCED_GRAPH_MALIAO = 0x700003; + static const int REDUCED_GRAPH_MAOMAO = 0x700004; + /* -------------------------------------------------------------------------- */ + +} // OHOS +#endif // UI_RESOURCE_IMAGE_H diff --git a/code/sdk/application/wearable/nativeapp/nativeui/dial/src/DialPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/dial/src/DialPresenter.cpp new file mode 100644 index 000000000..0cb192063 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/dial/src/DialPresenter.cpp @@ -0,0 +1,107 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" + +#include "dial/include/DialPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static DialPresenter *g_pDialPresenter = nullptr; + + DialPresenter::DialPresenter() + { + + g_pDialPresenter = this; + } + + DialPresenter::~DialPresenter() + { + + g_pDialPresenter = nullptr; + } + + DialPresenter *DialPresenter::GetInstance() + { + + return g_pDialPresenter; + } + + void DialPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void DialPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void DialPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void DialPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool DialPresenter::OnDrag(UIView &view, const DragEvent &event) + { + + if (event.GetDragDirection() == DragEvent::DIRECTION_BOTTOM_TO_TOP) + { + printf("draglistene is ok!\n"); + NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_SAMPLE); + } + UNUSED(view); + return true; + } + + bool DialPresenter::OnClick(UIView &view, const ClickEvent &event) + { + // 根据控件id查找是哪个控件触发了点击回调 + if (strcmp(view.GetViewId(), "kumibutton") == 0) + { + printf("join click\n"); + const std::string jsonPath = "/user/res/clocks/KUMI.json"; + g_pDigital_clockView->setJsonFilePath(jsonPath); + NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_SAMPLE); + } + if (strcmp(view.GetViewId(), "flowerbudbutton") == 0) + { + printf("join click\n"); + const std::string jsonPath = "/user/res/clocks/flowerbud.json"; + g_pDigital_clockView->setJsonFilePath(jsonPath); + NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_SAMPLE); + } + if (strcmp(view.GetViewId(), "maomaobutton") == 0) + { + printf("join click\n"); + const std::string jsonPath = "/user/res/clocks/maomao.json"; + g_pDigital_clockView->setJsonFilePath(jsonPath); + NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_SAMPLE); + } + if (strcmp(view.GetViewId(), "momobutton") == 0) + { + printf("join click\n"); + const std::string jsonPath = "/user/res/clocks/momo.json"; + g_pDigital_clockView->setJsonFilePath(jsonPath); + NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_SAMPLE); + } + if (strcmp(view.GetViewId(), "maliaobutton") == 0) + { + printf("join click\n"); + const std::string jsonPath = "/user/res/clocks/maliao.json"; + g_pDigital_clockView->setJsonFilePath(jsonPath); + NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_SAMPLE); + } + return true; + } + +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/dial/src/DialSucces.cpp b/code/sdk/application/wearable/nativeapp/nativeui/dial/src/DialSucces.cpp new file mode 100644 index 000000000..056d3af6b --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/dial/src/DialSucces.cpp @@ -0,0 +1,171 @@ +#include "dial/include/DialSuccesView.h" + +#include "common/image_cache_manager.h" +#include "UiConfig.h" +#include "ui_resource_image.h" +#include +#include "components/ui_button.h" +namespace OHOS +{ + + static DialSuccesView *g_pDialSuccesView{nullptr}; + + DialSuccesView::DialSuccesView() + { + + g_pDialSuccesView = this; + } + + DialSuccesView::~DialSuccesView() + { + DeInit(); + g_pDialSuccesView = nullptr; + } + + DialSuccesView *DialSuccesView::GetInstance() + { + + return g_pDialSuccesView; + } + void DialSuccesView::Init() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + + // Add Label to App + if (label1_ == nullptr) + { + label1_ = new UILabel(); + } + label1_->SetPosition(173, 52); // widget's left position and top position + label1_->Resize(220, 35); // widget's width and height + label1_->SetViewId("label1"); // Set style + label1_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label1_->SetText("安装成功"); + label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label1_->SetRollSpeed(0); + label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + container_->Add(label1_); + label1_->SetVisible(true); + + // Add ImageView to App + if (image1_ == nullptr) + { + image1_ = new UIImageView(); + } + image1_->SetPosition(193, 150); // widget's left position and top position + image1_->Resize(100, 100); // widget's width and height + image1_->SetViewId("success"); // Set style + + // Set additional property +#ifdef _WIN32 + char *image1imagesPath = "c:/Users/caiking/project/image_converter_tool/output/DialSucces/Vector.bin"; +#else + char *image1imagesPath = "/user/res/Dial/Vector.bin"; +#endif + image1_->SetSrc(image1imagesPath); + + // Add to rootView + container_->Add(image1_); + image1_->SetVisible(true); + + // Add Label to App + if (label2_ == nullptr) + { + label2_ = new UILabel(); + } + label2_->SetPosition(83, 293); // widget's left position and top position + label2_->Resize(200, 60); // widget's width and height + label2_->SetViewId("label2"); // Set style + label2_->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + label2_->SetText("表盘安装成功\n正在更新表盘,请稍等"); + label2_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label2_->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff)); + label2_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label2_->SetRollSpeed(0); + label2_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + container_->Add(label2_); + label2_->SetVisible(true); + } + + void DialSuccesView::DeInit() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (label1_ != nullptr) + { + delete label1_; + label1_ = nullptr; + } + if (image1_ != nullptr) + { + delete image1_; + image1_ = nullptr; + } + if (label2_ != nullptr) + { + delete label2_; + label2_ = nullptr; + } + } + + UIView *DialSuccesView::GetView() + { + Init(); + return container_; + } + void DialSuccesView::OnStart() + { + container_ = new UIViewGroup(); + if (container_ == nullptr) + { + return; + } + container_->SetPosition(0, 0); + container_->SetWidth(Screen::GetInstance().GetWidth()); + container_->SetHeight(Screen::GetInstance().GetHeight()); + container_->SetTouchable(true); + container_->SetDraggable(true); + + GetView(); + RootView::GetInstance()->Add(container_); + } + + void DialSuccesView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void DialSuccesView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void DialSuccesView::OnStop() + { + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/dial/src/DialView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/dial/src/DialView.cpp new file mode 100644 index 000000000..d8f36a0c5 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/dial/src/DialView.cpp @@ -0,0 +1,268 @@ + + +#include "dial/include/DialView.h" + +#include "common/image_cache_manager.h" +#include "UiConfig.h" +#include "ui_resource_image.h" +#include +#include "components/ui_button.h" +namespace OHOS +{ + static DialView *g_pDialView{nullptr}; + + DialView::DialView() + { + + g_pDialView = this; + } + + DialView::~DialView() + { + DeInit(); + g_pDialView = nullptr; + } + + DialView *DialView::GetInstance() + { + + return g_pDialView; + } + void DialView::Init() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + + // Add ScrollView to App + if (scrollView1_ == nullptr) + { + scrollView1_ = new UIScrollView(); + } + scrollView1_->SetPosition(0, 0); // widget's left position and top position + scrollView1_->Resize(466, 466); // widget's width and height + scrollView1_->SetViewId("scrollView1"); // Set style + scrollView1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + + // Set additional property + + // Add to rootView + container_->Add(scrollView1_); + scrollView1_->SetVisible(true); + + // Add Button to App + if (button5_ == nullptr) + { + button5_ = new UIButton(); + } + button5_->SetPosition(-480, 103); // widget's left position and top position + button5_->Resize(260, 260); // widget's width and height + button5_->SetViewId("maliaobutton"); // Set style + button5_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + button5_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + // Set additional property + char *button5defaultImgSrc = "/user/res/clocks/Reducedgraph/maliao.bin"; + char *button5triggeredImgSrc = nullptr; + button5_->SetImageSrc(button5defaultImgSrc, button5triggeredImgSrc); + button5_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED); + button5_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *button5Click = static_cast(DialPresenter::GetInstance()); + button5_->SetOnClickListener(button5Click); + // Add to scrollView1 + scrollView1_->Add(button5_); + button5_->SetVisible(true); + + // Add Button to App + if (button4_ == nullptr) + { + button4_ = new UIButton(); + } + button4_->SetPosition(680, 103); // widget's left position and top position + button4_->Resize(260, 260); // widget's width and height + button4_->SetViewId("momobutton"); // Set style + button4_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + button4_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + // Set additional property + char *button4defaultImgSrc = "/user/res/clocks/Reducedgraph/momo.bin"; + char *button4triggeredImgSrc = nullptr; + button4_->SetImageSrc(button4defaultImgSrc, button4triggeredImgSrc); + button4_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED); + button4_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *button4Click = static_cast(DialPresenter::GetInstance()); + button4_->SetOnClickListener(button4Click); + // Add to scrollView1 + scrollView1_->Add(button4_); + button4_->SetVisible(true); + + // Add Button to App + if (button3_ == nullptr) + { + button3_ = new UIButton(); + } + button3_->SetPosition(390, 103); // widget's left position and top position + button3_->Resize(260, 260); // widget's width and height + button3_->SetViewId("maomaobutton"); // Set style + button3_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + button3_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + // Set additional property + char *button3defaultImgSrc = "/user/res/clocks/Reducedgraph/maomao.bin"; + char *button3triggeredImgSrc = nullptr; + button3_->SetImageSrc(button3defaultImgSrc, button3triggeredImgSrc); + button3_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED); + button3_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + // Add the CallBack about events + UIView::OnClickListener *button3Click = static_cast(DialPresenter::GetInstance()); + button3_->SetOnClickListener(button3Click); + // Add to scrollView1 + scrollView1_->Add(button3_); + button3_->SetVisible(true); + + // Add Button to App + if (button2_ == nullptr) + { + button2_ = new UIButton(); + } + button2_->SetPosition(-190, 103); // widget's left position and top position + button2_->Resize(260, 260); // widget's width and height + button2_->SetViewId("flowerbudbutton"); // Set style + button2_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + button2_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + + // Set additional property + char *button2defaultImgSrc = "/user/res/clocks/Reducedgraph/flowerbud.bin"; + char *button2triggeredImgSrc = nullptr; + button2_->SetImageSrc(button2defaultImgSrc, button2triggeredImgSrc); + button2_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED); + button2_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + // Add the CallBack about events + UIView::OnClickListener *button2Click = static_cast(DialPresenter::GetInstance()); + button2_->SetOnClickListener(button2Click); + // Add to scrollView1 + scrollView1_->Add(button2_); + button2_->SetVisible(true); + + // Add Button to App + if (button1_ == nullptr) + { + button1_ = new UIButton(); + } + button1_->SetPosition(103, 103); // widget's left position and top position + button1_->Resize(260, 260); // widget's width and height + button1_->SetViewId("kumibutton"); // Set style + button1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + button1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + // Set additional property + char *button1defaultImgSrc = "/user/res/clocks/Reducedgraph/KUMI.bin"; + char *button1triggeredImgSrc = nullptr; + button1_->SetImageSrc(button1defaultImgSrc, button1triggeredImgSrc); + button1_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED); + button1_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *button1Click = static_cast(DialPresenter::GetInstance()); + button1_->SetOnClickListener(button1Click); + // Add to scrollView1 + scrollView1_->Add(button1_); + button1_->SetVisible(true); + } + + void DialView::DeInit() + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (scrollView1_ != nullptr) + { + delete scrollView1_; + scrollView1_ = nullptr; + } + if (button5_ != nullptr) + { + delete button5_; + button5_ = nullptr; + } + if (button4_ != nullptr) + { + delete button4_; + button4_ = nullptr; + } + if (button3_ != nullptr) + { + delete button3_; + button3_ = nullptr; + } + if (button2_ != nullptr) + { + delete button2_; + button2_ = nullptr; + } + if (button1_ != nullptr) + { + delete button1_; + button1_ = nullptr; + } + } + + UIView *DialView::GetView() + { + Init(); + return container_; + } + + void DialView::OnStart() + { + container_ = new UIScrollView(); + if (container_ == nullptr) + { + return; + } + container_->SetPosition(0, 0); + container_->SetWidth(Screen::GetInstance().GetWidth()); + container_->SetHeight(Screen::GetInstance().GetHeight()); + + // 创建 draglistener 实例并设置为拖动监听器 + UIView::OnDragListener *draglistener = static_cast(DialPresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_->SetOnDragListener(draglistener); + + container_->SetTouchable(true); + container_->SetDraggable(true); + + GetView(); + RootView::GetInstance()->Add(container_); + } + + void DialView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void DialView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void DialView::OnStop() + { + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} diff --git a/code/sdk/application/wearable/nativeapp/nativeui/dial/src/Digital_clockView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/dial/src/Digital_clockView.cpp new file mode 100644 index 000000000..a46a64f85 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/dial/src/Digital_clockView.cpp @@ -0,0 +1,825 @@ +/*** + * @Author: Caisking 3449750381@qq.com + * @Date: 2024-01-16 19:07:38 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-01-17 18:25:27 + * @FilePath: /1.FD230/FD230/code/sdk/application/wearable/nativeapp/nativeui/dial/src/Digital_clockView.cpp + * @Description: + * @ + * @Copyright (c) 2024 by Caisking , All Rights Reserved. + */ +/*** + * @Author: Caisking 3449750381@qq.com + * @Date: 2024-01-02 11:23:34 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-01-11 10:48:05 + * @FilePath: /1.FD230/FD230/code/sdk/application/wearable/nativeapp/nativeui/dial/src/Digital_clockView.cpp + * @Description: + * @ + * @Copyright (c) 2024 by Caisking , All Rights Reserved. + */ + +#include "dial/include/Digital_clockView.h" +#include "common/image_cache_manager.h" +#include "components/ui_view_group.h" +#include "UiConfig.h" +#include "ui_resource_image.h" +#include +#include "components/ui_button.h" +#include +#include +#include +#include +#include +#include "cJSON.h" +#include +#include +#include // 用于格式化输出 +#include //异常处理 +#include "timer.h" +#include "uapi/linux/rtc.h" +#include +#include +#include "common/image_cache_manager.h" + +#include "MainViewSample.h" + +#define PRINT_DEBUG_INFO printf("Function: %s, Line: %d\n", __PRETTY_FUNCTION__, __LINE__); +extern "C" +{ + int rtc_tm_to_time(struct rtc_time *tm, unsigned long *time); +} + +namespace OHOS +{ + cJSON *cjson_json = NULL; + /*** + * @description: + * @param {string} &filePath + * @return 设置json文件 + */ + void Digital_clockView::setJsonFilePath(const std::string &filePath) + { + PRINT_DEBUG_INFO + std::string defaultFile = "/user/res/clocks/default.json"; + std::ifstream sourceFile(filePath, std::ios::binary); // 打开源文件 + std::ofstream targetFile(defaultFile, std::ios::binary | std::ios::trunc); // 打开目标文件,使用trunc标志来覆盖目标文件 + printf("%s|%s\n", defaultFile.c_str(), filePath.c_str()); // 使用c_str()将std::string转换为C风格字符串 + if (sourceFile && targetFile) + { + char buffer[1024]; // 缓冲区 + while (sourceFile.read(buffer, sizeof(buffer)) || sourceFile.gcount()) + { + targetFile.write(buffer, sourceFile.gcount()); + } + if (sourceFile.eof()) + { + printf("File overwrite success\n"); // 使用printf打印成功消息 + return; // 返回true表示文件拷贝成功 + } + else + { + fprintf(stderr, "File overwrite failed\n"); // 使用fprintf打印错误消息 + } + } + else + { + fprintf(stderr, "Unable to open file\n"); // 使用fprintf打印错误消息 + } + sourceFile.close(); + targetFile.close(); + } + /** + * @description: 加载json文件 + * @param {string} &filePath + * @return 加载json文件是否成功 + */ + bool loadJsonData(const std::string &filePath) + { + + std::ifstream file(filePath); + if (file.is_open()) + { + std::string json_string((std::istreambuf_iterator(file)), std::istreambuf_iterator()); + file.close(); + // 解析JSON数据 + cjson_json = cJSON_Parse(json_string.c_str()); + return true; + } + else + { + printf("Failed to open JSON file: %s\n", filePath.c_str()); + } + return false; + } + /* -------------------------------------------------------------------------- */ + static Digital_clockView *g_pDigital_clockView{nullptr}; + Digital_clockView::Digital_clockView() + { + SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); + g_pDigital_clockView = this; + } + Digital_clockView::~Digital_clockView() + { + DeInit(); + g_pDigital_clockView = nullptr; + } + Digital_clockView *Digital_clockView::GetInstance() + { + return g_pDigital_clockView; + } + /* -------------------------------------------------------------------------- */ + /** + * @description: 生成动画的资源路径数组 + * @param {char} *basePath + * @param {char} *fileExtension + * @param {int} numImages + * @return 动画的资源路径数组 + */ + const char **Digital_clockView::CreateImagePathsArray(const char *basePath, const char *fileExtension, int numImages) + { + const char **imagePaths = new const char *[numImages + 1]; // 多分配一个元素用于存储数组大小 + char buffer[256]; + int total_len = 0; + for (int i = 0; i < numImages; i++) + { + int filename_len = snprintf(buffer, sizeof(buffer), "%s%d.%s", basePath, i + 1, fileExtension); + imagePaths[i] = strdup(buffer); + total_len += filename_len; + } + imagePaths[numImages] = reinterpret_cast(numImages); // 将数组大小信息存储在最后一个元素中 + return imagePaths; + } + /*** + * @description: 删除动画资源路径数组 + * @param {char} *imagePaths 动画资源路径数组 + * @return + */ + void Digital_clockView::FreeImagePathsArray(const char **imagePaths) + { + int numImages = reinterpret_cast(imagePaths[-1]); // 从最后一个元素中获取数组大小 + for (int i = 0; i < numImages; i++) + { + free((void *)imagePaths[i]); + } + delete[] imagePaths; + } + /** + * @description: 判断路径是否为文件夹 + * @param {string} &path + * @return 路径是否为文件夹 + */ + bool isDirectory(const std::string &path) + { + if (!path.empty() && path.back() == '/') + { + return true; // 路径以斜杠结尾,认为是文件夹 + } + return false; // 其他情况 + } + /** + * @brief 初始化UIImageAnimatorView,并设置为GIF动画。 + * + * 该函数用于使用提供的GIF图像和属性初始化UIImageAnimatorView。 + * + * @param imageAnimator 要初始化的UIImageAnimatorView对象的引用。 + * @param paths GIF图像文件路径的数组。 + * @param numFrames GIF中的帧数。 + * @param left 视图的左侧位置。 + * @param top 视图的顶部位置。 + * @param width 视图的宽度。 + * @param height 视图的高度。 + * @param viewId 视图的ID。 + * @param time 视图的帧速 + * @return 如果初始化成功则返回true,否则返回false。 + */ + void Digital_clockView::InitImageAnimatorSource(UIImageAnimatorView *&imageAnimator, const char **imagePaths, int numFrames, int left, int top, int width, int height, const char *viewId, int time) + { + if (imageAnimator == nullptr) + { + imageAnimator = new UIImageAnimatorView(); + } + imageAnimator->SetPosition(left, top); + imageAnimator->Resize(width, height); + imageAnimator->SetViewId(viewId); + imageAnimator->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + imageAnimator->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + + ImageAnimatorInfo *imageAnimatorInfo = new ImageAnimatorInfo[numFrames]; + for (int i = 0; i < numFrames; i++) + { + imageAnimatorInfo[i].imagePath = imagePaths[i]; + imageAnimatorInfo[i].pos.x = left; + imageAnimatorInfo[i].pos.y = top; + imageAnimatorInfo[i].width = width; + imageAnimatorInfo[i].height = height; + imageAnimatorInfo[i].imageType = IMG_SRC_FILE_PATH; + } + + imageAnimator->SetImageAnimatorSrc(imageAnimatorInfo, numFrames, time); // 200 is the default delay time + imageAnimator->SetTimeOfPause(time); + imageAnimator->SetRepeatTimes(1); + imageAnimator->SetReverse(true); + imageAnimator->SetVisible(true); + } + /** + * @description: 初始化背景 + * @return 初始化背景是否成功 + */ + bool Digital_clockView::Initbackground() + { + // 初始化背景 + if (background == nullptr) + { + background = new UIImageView(); + } + background->SetPosition(0, 0); // widget's left position and top position + background->Resize(466, 466); // widget's width and height + background->SetViewId("imagebackground"); // Set style + cJSON *background_cjson = cJSON_GetObjectItem(cjson_json, "background"); + std::string backgroundimagesPath = cJSON_GetObjectItem(background_cjson, "backgroundimagesPath")->valuestring; + // Check if the path is a directory + if (isDirectory(backgroundimagesPath)) + { + // Handle GIF animation + // Add code to set the background as a GIF animation + cJSON *size = cJSON_GetObjectItem(background_cjson, "size"); + cJSON *coordinates = cJSON_GetObjectItem(background_cjson, "coordinates"); + int background_count = cJSON_GetObjectItem(background_cjson, "background_count")->valueint; + int background_FPS = cJSON_GetObjectItem(background_cjson, "background_FPS")->valueint; + int background_left = cJSON_GetObjectItem(coordinates, "left")->valueint; + int background_top = cJSON_GetObjectItem(coordinates, "top")->valueint; + int background_width = cJSON_GetObjectItem(size, "width")->valueint; + int background_height = cJSON_GetObjectItem(size, "height")->valueint; + imagePaths = CreateImagePathsArray(backgroundimagesPath.c_str(), "bin", background_count); + + InitImageAnimatorSource(backgroundAnimator, imagePaths, background_count, background_left, background_top, + background_width, background_height, "imageAnimator1", background_FPS); + } + else + { + // Get the file extension + std::string backgroundImagePathStr = backgroundimagesPath; + std::string fileExtension = backgroundImagePathStr.substr(backgroundImagePathStr.find_last_of(".") + 1); + if (fileExtension == "bin") + { + // Handle static image + ImageInfo *img = ImageCacheManager::GetInstance().LoadSingleRes(backgroundimagesPath.c_str()); + background->SetSrc(img); + } + else if (fileExtension == "mp4") + { + // Handle dynamic background (video) + // Add code to set the background as a video + } + } + // 增加背景 + Add(background); + return true; + // background->SetVisible(true); + } + + /** + * @description: 初始化数字图片 + * @param {int} left + * @param {int} top + * @param {char} *imagePath + * @param {char} *viewId + * @param {int} offsetX + * @param {int} offsetY + * @return + */ + void Digital_clockView::addImageView(int left, int top, const char *imagePath, const char *viewId, int offsetX, int offsetY) + { + UIImageView *imageView = new UIImageView(); + imageView->SetPosition(left + offsetX, top + offsetY); + imageView->Resize(100, 100); + imageView->SetViewId(viewId); + imageView->SetSrc(imagePath); + Add(imageView); + // imageView->SetVisible(true); + } + /** + * @description: 初始化数字表盘 + * @return 初始化数字表盘是否成功 + */ + bool Digital_clockView ::Initdigit() + { + cJSON *background_cjson = cJSON_GetObjectItem(cjson_json, "background"); + std::string backgroundimagesPath = cJSON_GetObjectItem(background_cjson, "backgroundimagesPath")->valuestring; + if (isDirectory(backgroundimagesPath)) + { + backgroundAnimator->Start(); + Add(backgroundAnimator); + // backgroundAnimator->SetVisible(true); + } + + /* -------------------------------------------------------------------------- */ + struct tm local_time; + time_t seconds; + seconds = time(NULL); + if (localtime_r(&seconds, &local_time) == NULL) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Digital_clockView::Digital_clockView get localtime error!"); + return false; + } + std::ostringstream ostrHour, ostMin; + ostrHour << local_time.tm_hour; + ostMin << local_time.tm_min; + std::string weekStr = ostrHour.str() + ":" + ostMin.str(); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "time = %s!", weekStr.c_str()); + printf("weekStr:%s\n", weekStr.c_str()); + /* -------------------------------------------------------------------------- */ + stringtime = "20:10"; + + // updateClockTime(stringtime); + cJSON *digits = cJSON_GetObjectItem(cjson_json, "digits"); + std::string playformat = cJSON_GetObjectItem(digits, "playformat")->valuestring; + if (playformat == "picturesdisplay") + { + cJSON *picturesdisplay = cJSON_GetObjectItem(digits, "picturesdisplay"); + cJSON *coordinates = cJSON_GetObjectItem(picturesdisplay, "coordinates"); + digitspath = cJSON_GetObjectItem(cjson_json, "digitspath")->valuestring; + int hour1_left = cJSON_GetObjectItem(coordinates, "left")->valueint; + int hour1_top = cJSON_GetObjectItem(coordinates, "top")->valueint; + int digitsize = cJSON_GetObjectItem(digits, "digitsize")->valueint; + + addImageView(hour1_left, hour1_top, (digitspath + stringtime.substr(0, 1) + ".bin").c_str(), "hour1", 0, 0); + addImageView(hour1_left, hour1_top, (digitspath + stringtime.substr(1, 1) + ".bin").c_str(), "hour1", digitsize, 0); + addImageView(hour1_left, hour1_top, (digitspath + "point.bin").c_str(), "colon", digitsize * 2 + 10, 20); + addImageView(hour1_left, hour1_top, (digitspath + stringtime.substr(3, 1) + ".bin").c_str(), "minute1", digitsize * 3, 0); + addImageView(hour1_left, hour1_top, (digitspath + stringtime.substr(4, 1) + ".bin").c_str(), "minute2", digitsize * 4, 0); + printf("--%s--\n", digitspath.c_str()); + if (mytimeimageCallback_ == nullptr) + { + mytimeimageCallback_ = new mytimeimageCallback(hour1, hour2, minute1, minute2, digitspath, stringtime); + timeimageanimator_ = new Animator(mytimeimageCallback_, minute2, 10000, true); + } + // callback.mytimeimageCallback("14:57"); + // timeimageanimator_->Start(); + } + else if (playformat == "textdisplay") + { + cJSON *textdisplay = cJSON_GetObjectItem(digits, "textdisplay"); + cJSON *coordinates = cJSON_GetObjectItem(textdisplay, "coordinates"); + int time_left = cJSON_GetObjectItem(coordinates, "left")->valueint; + int time_top = cJSON_GetObjectItem(coordinates, "top")->valueint; + int digitsize = cJSON_GetObjectItem(digits, "digitsize")->valueint; + // Add Label to App + if (timeLable == nullptr) + { + timeLable = new UILabel(); + } + timeLable->SetPosition(time_left, time_top); // widget's left position and top position + timeLable->Resize(200, 60); // widget's width and height + timeLable->SetViewId("label1"); // Set style + timeLable->SetStyle(STYLE_TEXT_FONT, digitsize); + + // Set additional property + timeLable->SetText(stringtime.c_str()); + timeLable->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + timeLable->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + timeLable->SetRollSpeed(0); + timeLable->SetFont(DEFAULT_VECTOR_FONT_FILENAME, digitsize); + + // Add to rootView + Add(timeLable); + // timeLable->SetVisible(true); + + if (timeLableCallback_ == nullptr) + { + timeLableCallback_ = new timeLableCallback(timeLable, stringtime); + timeLableanimator_ = new Animator(timeLableCallback_, timeLable, 1000, true); + } + timeLableanimator_->Start(); + } + return true; + } + /** + * @description: 初始化指针表盘 + * @return: 初始化指针表盘是否成功 + */ + bool Digital_clockView::Initpointer() + { + cJSON *hands = cJSON_GetObjectItem(cjson_json, "hands"); + cJSON *hourHand = cJSON_GetObjectItem(hands, "hourHand"); + cJSON *minuteHand = cJSON_GetObjectItem(hands, "minuteHand"); + cJSON *secondHand = cJSON_GetObjectItem(hands, "secondHand"); + cJSON *hour_coordinates = cJSON_GetObjectItem(hourHand, "coordinates"); + cJSON *minute_coordinates = cJSON_GetObjectItem(minuteHand, "coordinates"); + cJSON *second_coordinates = cJSON_GetObjectItem(secondHand, "coordinates"); + const char *handspath = cJSON_GetObjectItem(cjson_json, "handspath")->valuestring; + + signed short HOUR_POINT_POSITION_X = static_cast(cJSON_GetObjectItem(hour_coordinates, "HOUR_POINT_POSITION_X")->valueint); + signed short HOUR_POINT_POSITION_Y = static_cast(cJSON_GetObjectItem(hour_coordinates, "HOUR_POINT_POSITION_Y")->valueint); + signed short HOUR_POINT_CENTER_X = static_cast(cJSON_GetObjectItem(hour_coordinates, "HOUR_POINT_CENTER_X")->valueint); + signed short HOUR_POINT_CENTER_Y = static_cast(cJSON_GetObjectItem(hour_coordinates, "HOUR_POINT_CENTER_Y")->valueint); + signed short MINUTE_POINT_POSITION_X = static_cast(cJSON_GetObjectItem(minute_coordinates, "MINUTE_POINT_POSITION_X")->valueint); + signed short MINUTE_POINT_POSITION_Y = static_cast(cJSON_GetObjectItem(minute_coordinates, "MINUTE_POINT_POSITION_Y")->valueint); + signed short MINUTE_POINT_CENTER_X = static_cast(cJSON_GetObjectItem(minute_coordinates, "MINUTE_POINT_CENTER_X")->valueint); + signed short MINUTE_POINT_CENTER_Y = static_cast(cJSON_GetObjectItem(minute_coordinates, "MINUTE_POINT_CENTER_Y")->valueint); + signed short SECOND_POINT_POSITION_X = static_cast(cJSON_GetObjectItem(second_coordinates, "SECOND_POINT_POSITION_X")->valueint); + signed short SECOND_POINT_POSITION_Y = static_cast(cJSON_GetObjectItem(second_coordinates, "SECOND_POINT_POSITION_Y")->valueint); + signed short SECOND_POINT_CENTER_X = static_cast(cJSON_GetObjectItem(second_coordinates, "SECOND_POINT_CENTER_X")->valueint); + signed short SECOND_POINT_CENTER_Y = static_cast(cJSON_GetObjectItem(second_coordinates, "SECOND_POINT_CENTER_Y")->valueint); + + // Add SweepClock to App + if (sweepClock1_ == nullptr) + { + sweepClock1_ = new UISweepClock(); + } + sweepClock1_->SetPosition(0, 0); // widget's left position and top position + sweepClock1_->Resize(466, 466); // widget's width and height + sweepClock1_->SetViewId("sweepClock1"); // Set style + sweepClock1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + sweepClock1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + + // Set additional property + sweepClock1_->SetWorkMode(UISweepClock::WorkMode::NORMAL); + Image *sweepClock1HourImage = new Image(); + std::string HourImagePath = std::string(handspath) + "hour.bin"; + + sweepClock1HourImage->SetSrc(HourImagePath.c_str()); + + sweepClock1_->SetHandImage(UISweepClock::HandType::HOUR_HAND, *sweepClock1HourImage, {HOUR_POINT_POSITION_X, HOUR_POINT_POSITION_Y}, {HOUR_POINT_CENTER_X, HOUR_POINT_CENTER_Y}); + + Image *sweepClock1MinuteImage = new Image(); + std::string MinutePath = std::string(handspath) + "minute.bin"; + sweepClock1MinuteImage->SetSrc(MinutePath.c_str()); + sweepClock1_->SetHandImage(UISweepClock::HandType::MINUTE_HAND, *sweepClock1MinuteImage, {MINUTE_POINT_POSITION_X, MINUTE_POINT_POSITION_Y}, {MINUTE_POINT_CENTER_X, MINUTE_POINT_CENTER_Y}); + + Image *sweepClock1SecondImage = new Image(); + std::string SecondPath = std::string(handspath) + "second.bin"; + sweepClock1SecondImage->SetSrc(SecondPath.c_str()); + sweepClock1_->SetHandImage(UISweepClock::HandType::SECOND_HAND, *sweepClock1SecondImage, {SECOND_POINT_POSITION_X, SECOND_POINT_POSITION_Y}, {SECOND_POINT_CENTER_X, SECOND_POINT_CENTER_Y}); + + uint16_t sweepClock1realMilliSecond = 40 * 1000; + sweepClock1_->SetSweepTime12Hour(10, 20, sweepClock1realMilliSecond, true); + sweepClock1callback_ = new SweepClockCallback(sweepClock1_); + sweepClock1animator_ = new Animator(sweepClock1callback_, sweepClock1_, 0, true); + sweepClock1animator_->Start(); + // Add to rootView + Add(sweepClock1_); + return true; + // sweepClock1_->SetVisible(true); + } + /** + * @description: 获取格式化日期,根据不同的日期格式获取 + * @param {string} &dateStr + * @param {string} &displayformat + * @return 格式化日期 + */ + std::string FormatDate(const std::string &dateStr, const std::string &displayformat) + { + // 定义默认返回值 + std::string formattedDate = "Invalid format"; + // 输出日期字符串和子字符串 + std::cout << "--date: " << dateStr << "--" << dateStr.substr(0, 4) << "--" << dateStr.substr(5, 2) << "--" << dateStr.substr(8, 2) << std::endl; + int year = std::stoi(dateStr.substr(0, 4)); // 从第0个字符开始,提取4个字符作为年份 + int month = std::stoi(dateStr.substr(5, 2)); // 从第5个字符开始,提取2个字符作为月份 + int day = std::stoi(dateStr.substr(8, 2)); // 从第8个字符开始,提取2个字符作为日期 + if (displayformat == "yyyy-mm-dd") + { + formattedDate = std::to_string(year) + "-" + (month < 10 ? "0" : "") + std::to_string(month) + "-" + (day < 10 ? "0" : "") + std::to_string(day); + } + else if (displayformat == "mm月dd日") + { + formattedDate = std::to_string(month) + "月" + (day < 10 ? "0" : "") + std::to_string(day) + "号"; + } + else if (displayformat == "dd") + { + formattedDate = (day < 10 ? "0" : "") + std::to_string(day); + } + + // 添加其他显示格式的处理逻辑 + return formattedDate; + } + /** + * @description: 初始化日期 + * @return 初始化日期是否成功 + */ + bool Digital_clockView ::Initdata() + { + // loadJsonData(JosnfilePath); + cJSON *date = cJSON_GetObjectItem(cjson_json, "date"); + cJSON *textdisplay = cJSON_GetObjectItem(date, "textdisplay"); + cJSON *coordinates = cJSON_GetObjectItem(textdisplay, "coordinates"); + + // const char *font = cJSON_GetObjectItem(textdisplay, "font")->valuestring; + int fontsize = cJSON_GetObjectItem(textdisplay, "fontsize")->valueint; + int date_left = cJSON_GetObjectItem(coordinates, "left")->valueint; + int date_top = cJSON_GetObjectItem(coordinates, "top")->valueint; + + // Add Label to App + if (dateLable == nullptr) + { + dateLable = new UILabel(); + } + dateLable->SetPosition(date_left, date_top); // widget's left position and top position + dateLable->SetViewId("label1"); // Set style + dateLable->SetStyle(STYLE_TEXT_FONT, fontsize); + + std::string dateStr = "2024-02-09"; + + std::string displayformat = cJSON_GetObjectItem(textdisplay, "displayformat")->valuestring; + // 调用日期格式化函数 + std::string formattedDate = FormatDate(dateStr, displayformat); + + dateLable->SetText(formattedDate.c_str()); + dateLable->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + dateLable->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + dateLable->SetRollSpeed(0); + dateLable->SetFont(DEFAULT_VECTOR_FONT_FILENAME, fontsize); + + // Add to rootView + Add(dateLable); + return true; + // dateLable->SetVisible(true); + }; + /** + * @description: 初始化星期 + * @return 初始化星期是否成功 + */ + bool Digital_clockView ::Initweek() + { + // loadJsonData(JosnfilePath); + cJSON *week = cJSON_GetObjectItem(cjson_json, "week"); + cJSON *textdisplay = cJSON_GetObjectItem(week, "textdisplay"); + cJSON *coordinates = cJSON_GetObjectItem(textdisplay, "coordinates"); + cJSON *displayformat = cJSON_GetObjectItem(textdisplay, "displayformat"); + // const char *font = cJSON_GetObjectItem(textdisplay, "font")->valuestring; + int fontsize = cJSON_GetObjectItem(textdisplay, "fontsize")->valueint; + int week_left = cJSON_GetObjectItem(coordinates, "left")->valueint; + int week_top = cJSON_GetObjectItem(coordinates, "top")->valueint; + // Add Label to App + if (weekLable == nullptr) + { + weekLable = new UILabel(); + } + weekLable->SetPosition(week_left, week_top); // widget's left position and top position + // weekLable->Resize(78, 60); // widget's width and height + weekLable->SetViewId("label2"); // Set style + weekLable->SetStyle(STYLE_TEXT_FONT, fontsize); + + // Set additional property + cJSON *weekformat = cJSON_GetObjectItem(displayformat, "weekformat"); + std ::string weekStr; + if (weekformat != nullptr && cJSON_IsArray(weekformat)) + { + cJSON *weekformat1 = cJSON_GetArrayItem(weekformat, 1); + if (weekformat1 != nullptr && cJSON_IsString(weekformat1)) + { + weekStr = weekformat1->valuestring; + } + } + weekLable->SetText(weekStr.c_str()); + weekLable->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + weekLable->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + weekLable->SetRollSpeed(0); + weekLable->SetFont(DEFAULT_VECTOR_FONT_FILENAME, fontsize); + + // Add to rootView + Add(weekLable); + return true; + // weekLable->SetVisible(true); + }; + /** + * @description: 初始化电量 + * @return 初始化电量是否成功 + */ + bool Digital_clockView ::Initbattery() + { + // loadJsonData(JosnfilePath); + cJSON *battery = cJSON_GetObjectItem(cjson_json, "battery"); + cJSON *progress_json = cJSON_GetObjectItem(battery, "progress"); + cJSON *textdisplay = cJSON_GetObjectItem(battery, "textdisplay"); + cJSON *coordinates = cJSON_GetObjectItem(textdisplay, "coordinates"); + cJSON *coordinates_progress = cJSON_GetObjectItem(progress_json, "coordinates"); + cJSON *size_progress = cJSON_GetObjectItem(progress_json, "size"); + // const char *font = cJSON_GetObjectItem(textdisplay, "font")->valuestring; + int fontsize = cJSON_GetObjectItem(textdisplay, "fontsize")->valueint; + int battery_left = cJSON_GetObjectItem(coordinates, "left")->valueint; + int battery_top = cJSON_GetObjectItem(coordinates, "top")->valueint; + int progress_left = cJSON_GetObjectItem(coordinates_progress, "left")->valueint; + int progress_top = cJSON_GetObjectItem(coordinates_progress, "top")->valueint; + int progress_width = cJSON_GetObjectItem(size_progress, "width")->valueint; + int progress_height = cJSON_GetObjectItem(size_progress, "height")->valueint; + + float voltage = 0.0F; + uint8_t value = 0; + value = battery_get_voltage(&voltage); + // Add BoxProgress to App + if (progress == nullptr) + { + progress = new UIBoxProgress(); + } + progress->SetPosition(progress_left, progress_top); // widget's left position and top position + progress->Resize(progress_width, progress_height); // widget's width and height + progress->SetViewId("progress1"); // Set style + progress->SetValidHeight(progress_height); + progress->SetValidWidth(progress_width); + progress->SetValue(value); + // Set BackgroundStyle + progress->SetBackgroundStyle(STYLE_BACKGROUND_OPA, 0x00); + progress->SetBackgroundStyle(STYLE_TEXT_COLOR, 0xff000000); + // Set ForegroundStyle + progress->SetForegroundStyle(STYLE_BACKGROUND_COLOR, 0xff2195F6); + progress->SetForegroundStyle(STYLE_TEXT_COLOR, 0xff000000); + progress->SetForegroundStyle(STYLE_LINE_COLOR, 0xff45A5FF); + char *progress1ForeImageSrc = "/user/res/Battery/Battery_Nomoal.bin"; + char *progress1BackImageSrc = nullptr; + progress->SetImage(progress1ForeImageSrc, progress1BackImageSrc); + // Add to rootView + Add(progress); + // progress->SetVisible(true); + + // Add Label to App + if (batteryLable == nullptr) + { + batteryLable = new UILabel(); + } + batteryLable->SetPosition(battery_left, battery_top); // widget's left position and top position + // batteryLable->Resize(200, 60); // widget's width and height + batteryLable->SetViewId("label3"); // Set style + batteryLable->SetStyle(STYLE_TEXT_FONT, fontsize); + + // Set additional property + batteryLable->SetText((std::to_string(value) + "%").c_str()); + batteryLable->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + batteryLable->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + batteryLable->SetRollSpeed(0); + batteryLable->SetFont(DEFAULT_VECTOR_FONT_FILENAME, fontsize); + + // Add to rootView + Add(batteryLable); + // batteryLable->SetVisible(true); + + progress1callback_ = new myProgressCallback(progress, batteryLable); + progress1animator_ = new Animator(progress1callback_, progress, 10000, true); + progress1animator_->Start(); + return true; + }; + /*** + * @description: 添加切换界面按键 + * @return 添加按键是否成功 + */ + bool Digital_clockView ::AddButton() + { + PRINT_DEBUG_INFO + // Add Button to App + if (changebutton == nullptr) + { + changebutton = new UIButton(); + } + changebutton->SetPosition(0, 0); // widget's left position and top position + changebutton->Resize(466, 466); // widget's width and height + changebutton->SetViewId(CHANGEBUTTON); // Set style + changebutton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + changebutton->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + PRINT_DEBUG_INFO + // Set additional property + changebutton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED); + changebutton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + PRINT_DEBUG_INFO + // Add the CallBack about events + UIView::OnLongPressListener *buttonLongPress = static_cast(MainPresenterSample::GetInstance()); + changebutton->SetOnLongPressListener(buttonLongPress); + // Add to rootView + Add(changebutton); + PRINT_DEBUG_INFO + return true; + } + /** + * @description: 初始化页面 + * @return 初始化页面是否成功 + */ + bool Digital_clockView ::InitView() + { + PRINT_DEBUG_INFO + if (loadJsonData(JosnfilePath)) + { + std::string Dialtype = cJSON_GetObjectItem(cjson_json, "Dialtype")->valuestring; + Initbackground(); + if (Dialtype == "pointer") + { + Initpointer(); + } + else + { + Initdigit(); + } + Initdata(); + Initweek(); + Initbattery(); + AddButton(); + cJSON_Delete(cjson_json); + } + // Add(container_); + SetCoverable(true); + PRINT_DEBUG_INFO + return true; + } + /** + * @description: 删除组件 + * @return {*} + */ + void Digital_clockView::DeInit() + { + /* -------------------------------------------------------------------------- */ + delete background; + background = nullptr; + delete hour1; + hour1 = nullptr; + delete hour2; + hour2 = nullptr; + delete colon; + colon = nullptr; + delete minute1; + minute1 = nullptr; + delete minute2; + minute2 = nullptr; + delete timeLable; + timeLable = nullptr; + delete dateLable; + dateLable = nullptr; + delete weekLable; + weekLable = nullptr; + delete batteryLable; + batteryLable = nullptr; + delete progress; + progress = nullptr; + /* -------------------------------------------------------------------------- */ + if (timeLableanimator_ != nullptr) + { + timeLableanimator_->Stop(); + delete timeLableanimator_; + timeLableanimator_ = nullptr; + } + if (timeLableCallback_ != nullptr) + { + delete timeLableCallback_; + timeLableCallback_ = nullptr; + } + /* -------------------------------------------------------------------------- */ + if (mytimeimageCallback_ != nullptr) + { + delete mytimeimageCallback_; + mytimeimageCallback_ = nullptr; + } + if (timeimageanimator_ != nullptr) + { + timeimageanimator_->Stop(); + delete timeimageanimator_; + timeimageanimator_ = nullptr; + } + /* -------------------------------------------------------------------------- */ + if (progress1callback_ != nullptr) + { + delete progress1callback_; + progress1callback_ = nullptr; + } + if (progress1animator_ != nullptr) + { + progress1animator_->Stop(); + delete progress1animator_; + progress1animator_ = nullptr; + } + /* -------------------------------------------------------------------------- */ + if (sweepClock1callback_ != nullptr) + { + delete sweepClock1callback_; + sweepClock1callback_ = nullptr; + } + if (sweepClock1animator_ != nullptr) + { + sweepClock1animator_->Stop(); + delete sweepClock1animator_; + sweepClock1animator_ = nullptr; + } + /* -------------------------------------------------------------------------- */ + if (backgroundAnimator != nullptr) + { + backgroundAnimator->Stop(); + delete backgroundAnimator; + backgroundAnimator = nullptr; + } + } + + /*** + * @description: 加载 + * @return {*} + */ + void Digital_clockView::PreLoad(void) + { + if (!viewiInitStatus) + { + InitView(); + } + } + + void Digital_clockView::UnLoad(void) + { + // ImageCacheManager::GetInstance().UnloadSingleRes(RES_PATH"breath.bin"); + } + +} diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainPresenterSample.h b/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainPresenterSample.h index 5df6a40f1..46a2747e0 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainPresenterSample.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainPresenterSample.h @@ -1,3 +1,13 @@ +/*** + * @Author: Caisking 3449750381@qq.com + * @Date: 2023-12-13 19:33:14 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-01-17 19:53:31 + * @FilePath: /FD230/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainPresenterSample.h + * @Description: + * @ + * @Copyright (c) 2024 by Caisking , All Rights Reserved. + */ /* * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. * Description: MainPresenterSample @@ -42,7 +52,7 @@ constexpr uint16_t HORIZONTAL_STATUS = 0; class MainViewSample; class MainPresenterSample : public Presenter, public ModelListenerSample, public UIView::OnClickListener, public UISwipeView::OnSwipeListener, - public UISwipeView, public CompassPresenter { + public UISwipeView, public CompassPresenter, public UIView::OnLongPressListener { public: MainPresenterSample(); virtual ~MainPresenterSample(); @@ -54,6 +64,7 @@ public: void OnStop() override; virtual void Notify() override; bool OnClick(UIView& view, const ClickEvent& event) override; + bool OnLongPress(UIView& view, const LongPressEvent& event) override; virtual void OnSwipe(UISwipeView& view) override; void setCallback(ZoomEffect* callback) { diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainViewSample.h b/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainViewSample.h index 5ca62c2d2..a1e044c40 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainViewSample.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainViewSample.h @@ -28,60 +28,73 @@ #include "components/ui_card_page.h" #include "PullUpDownView.h" #include "components/ui_cross_view.h" - -namespace OHOS { -class MainPresenterSample; -class MainViewSample : public View { -public: - MainViewSample(); - virtual ~MainViewSample(); - static MainViewSample *GetInstance(void); - void OnStart() override; - void OnSetUpView() override; - void OnTearDownView() override; - void OnStop() override; - UICardPage *InitWatchFacePage(void); - UICardPage *InitHeartRatePage(void); - UICardPage *InitActivityPage(void); - UICardPage *InitCompassPage(void); - UICardPage *InitMusicPlayerPage(void); - void AnimatorStart(int pageIndex); - void AnimatorStop(void); - uint16_t GetHorCurrentPage() const +#include "dial/include/Digital_clockView.h" +#include "blood/include/BloodView.h" +#include "traing/include/TraingView.h" +namespace OHOS +{ + class MainPresenterSample; + class MainViewSample : public View { - return mainSwipeGroup->GetCurrentPageId(UISwipeView::HORIZONTAL); // 0: horizontal; 1: vertical - } + public: + MainViewSample(); + virtual ~MainViewSample(); + static MainViewSample *GetInstance(void); + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + UICardPage *InitWatchFacePage(void); + UICardPage *InitHeartRatePage(void); + UICardPage *InitActivityPage(void); + UICardPage *InitCompassPage(void); + UICardPage *InitMusicPlayerPage(void); + UICardPage *InitBloodOxygenPage(void); + UICardPage *InitWeatherPage(void); + UICardPage *InitTrainingPage(void); - UIView* GetMainViewGroup(void) const - { - return mainSwipeGroup; - } + void AnimatorStart(int pageIndex); + void AnimatorStop(void); + uint16_t GetHorCurrentPage() const + { + return mainSwipeGroup->GetCurrentPageId(UISwipeView::HORIZONTAL); // 0: horizontal; 1: vertical + } + + UIView *GetMainViewGroup(void) const + { + return mainSwipeGroup; + } + + bool IsMainView(void); + void SetDragFg(bool continFg); + bool GetDragFg(void); - bool IsMainView(void); - void SetDragFg(bool continFg); - bool GetDragFg(void); + private: + int16_t maxPage{0}; + bool continuDragFg{false}; + PullUpDownView *dropDownView{nullptr}; + UICardPage *messageView{nullptr}; + UILabel *messageLable{nullptr}; + Digital_clockView *mainClockView{nullptr}; + ActivityWeekView *activityWeekView{nullptr}; + PlayersView *playersView{nullptr}; + CompassControlView *compassControlView{nullptr}; + HeartRateView *heartRateView{nullptr}; + Digital_clockView *dialView{nullptr}; + BloodView *bloodView{nullptr}; + TraingView *traingView{nullptr}; -private: - int16_t maxPage{0}; - bool continuDragFg{false}; - PullUpDownView *dropDownView{nullptr}; - UICardPage *messageView{nullptr}; - UILabel *messageLable{nullptr}; - MainClockView *mainClockView{nullptr}; - ActivityWeekView *activityWeekView{nullptr}; - PlayersView *playersView{nullptr}; - CompassControlView *compassControlView{nullptr}; - HeartRateView *heartRateView{nullptr}; - UICardPage *recordCard[MAX_CARD]{nullptr}; - bool pageStatus[MAX_CARD]{false}; - UICrossView *mainSwipeGroup{nullptr}; - ZoomEffect* callback{nullptr}; + /* -------------------------------------------------------------------------- */ + UICardPage *recordCard[MAX_CARD]{nullptr}; + bool pageStatus[MAX_CARD]{false}; + UICrossView *mainSwipeGroup{nullptr}; + ZoomEffect *callback{nullptr}; - bool HorizontalViewInit(void); - void VerticalViewInit(void); - void VertViewLoad(void); - void HorViewLoad(void); - UICardPage *CreatePage(int32_t cardId); -}; + bool HorizontalViewInit(void); + void VerticalViewInit(void); + void VertViewLoad(void); + void HorViewLoad(void); + UICardPage *CreatePage(int32_t cardId); + }; } // namespace OHOS #endif // MAIN_VIEW_SAMPLE_H diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainPresenterSample.cpp b/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainPresenterSample.cpp index d9e9f9f87..b4060a2c3 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainPresenterSample.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainPresenterSample.cpp @@ -122,7 +122,19 @@ bool MainPresenterSample::OnClick(UIView &view, const ClickEvent &event) } return true; } - + bool MainPresenterSample::OnLongPress(UIView& view, const LongPressEvent& event) + { + printf("coming LongPress\n"); + UNUSED(event); + string curViewId = view.GetViewId(); + //int page = MainViewSample::GetInstance()->GetHorCurrentPage(); + //callback_->OnSwipe(view); + if(curViewId== CHANGEBUTTON) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_DIAL); + return true; + } + } void MainPresenterSample::OnSwipe(UISwipeView &view) { UNUSED(view); diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainViewSample.cpp b/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainViewSample.cpp index 1b81d2ea5..302608ac7 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainViewSample.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainViewSample.cpp @@ -8,350 +8,401 @@ #include "MainViewSample.h" #include "graphic_service.h" -namespace OHOS { - -static MainViewSample *g_pMainView = nullptr; -static constexpr uint16_t MESLABLE_X_TMP = 177; -static constexpr uint16_t MESLABLE_Y_TMP = 212; -static constexpr uint16_t MESLABLE_WIDTH_TMP = 100; -static constexpr uint16_t MESLABLE_HEIGHT_TMP = 30; -static constexpr uint8_t FONT_SIZE_TMP = 24; -static constexpr uint8_t PULL_MIDDLE_VIEW_OPA = 0; - -struct MainViewMapper { - CardId id; - UICardPage *(MainViewSample::*func)(void); -}; - -static const MainViewMapper PageMapper[] = { - {WATCH_FACE, &MainViewSample::InitWatchFacePage}, - {HEART_RATE, &MainViewSample::InitHeartRatePage}, - {COMPASS, &MainViewSample::InitCompassPage}, - {ACTIVITY, &MainViewSample::InitActivityPage}, - {MUSIC_PLAYER, &MainViewSample::InitMusicPlayerPage}, -}; - -MainViewSample::MainViewSample() +namespace OHOS { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::MainViewSample"); - g_pMainView = this; -} - -MainViewSample::~MainViewSample() -{ - dropDownView->ClearBackgroundBlur(); - messageView->ClearBackgroundBlur(); - for (int32_t i = 0; i < maxPage; i++) { - recordCard[i] = nullptr; - pageStatus[i] = false; + static MainViewSample *g_pMainView = nullptr; + static constexpr uint16_t MESLABLE_X_TMP = 177; + static constexpr uint16_t MESLABLE_Y_TMP = 212; + static constexpr uint16_t MESLABLE_WIDTH_TMP = 100; + static constexpr uint16_t MESLABLE_HEIGHT_TMP = 30; + static constexpr uint8_t FONT_SIZE_TMP = 24; + static constexpr uint8_t PULL_MIDDLE_VIEW_OPA = 0; + + struct MainViewMapper + { + CardId id; + UICardPage *(MainViewSample::*func)(void); + }; + + static const MainViewMapper PageMapper[] = { + {NEW_DAIL, &MainViewSample::InitWatchFacePage}, + {HEART_RATE, &MainViewSample::InitHeartRatePage}, + {COMPASS, &MainViewSample::InitCompassPage}, + {BloodOxygen, &MainViewSample::InitBloodOxygenPage}, + {TRAINING, &MainViewSample::InitTrainingPage}, + }; + + MainViewSample::MainViewSample() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::MainViewSample"); + g_pMainView = this; } - if (mainSwipeGroup != nullptr) { - delete mainSwipeGroup; - mainSwipeGroup = nullptr; - } + MainViewSample::~MainViewSample() + { + dropDownView->ClearBackgroundBlur(); + messageView->ClearBackgroundBlur(); - if (mainClockView != nullptr) { - delete mainClockView; - mainClockView = nullptr; - } + for (int32_t i = 0; i < maxPage; i++) + { + recordCard[i] = nullptr; + pageStatus[i] = false; + } - if (activityWeekView != nullptr) { - delete activityWeekView; - activityWeekView = nullptr; - } + if (mainSwipeGroup != nullptr) + { + delete mainSwipeGroup; + mainSwipeGroup = nullptr; + } - if (playersView != nullptr) { - delete playersView; - playersView = nullptr; - } + if (mainClockView != nullptr) + { + delete mainClockView; + mainClockView = nullptr; + } - if (heartRateView != nullptr) { - delete heartRateView; - heartRateView = nullptr; - } + if (activityWeekView != nullptr) + { + delete activityWeekView; + activityWeekView = nullptr; + } - if (dropDownView != nullptr) { - delete dropDownView; - dropDownView = nullptr; - } + if (playersView != nullptr) + { + delete playersView; + playersView = nullptr; + } - if (messageView != nullptr) { - messageView->RemoveAll(); - delete messageView; - messageView = nullptr; - } + if (heartRateView != nullptr) + { + delete heartRateView; + heartRateView = nullptr; + } - if (messageLable != nullptr) { - delete messageLable; - messageLable = nullptr; - } + if (dropDownView != nullptr) + { + delete dropDownView; + dropDownView = nullptr; + } - if (compassControlView != nullptr) { - delete compassControlView; - compassControlView = nullptr; - } + if (messageView != nullptr) + { + messageView->RemoveAll(); + delete messageView; + messageView = nullptr; + } - g_pMainView = nullptr; -} + if (messageLable != nullptr) + { + delete messageLable; + messageLable = nullptr; + } -MainViewSample *MainViewSample::GetInstance(void) -{ - return g_pMainView; -} + if (compassControlView != nullptr) + { + delete compassControlView; + compassControlView = nullptr; + } -void MainViewSample::OnStart() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::OnStart"); - View::OnStart(); - BaseView::RootView(Color::Black().full); + if (dialView != nullptr) + { + delete dialView; + dialView = nullptr; + } + if (bloodView != nullptr) + { + delete bloodView; + bloodView = nullptr; + } + g_pMainView = nullptr; + } - mainSwipeGroup = new UICrossView(); - if (mainSwipeGroup == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mainSwipeGroup new fail"); - return; + MainViewSample *MainViewSample::GetInstance(void) + { + return g_pMainView; } - if (callback == nullptr) { - callback = new ZoomEffect(); - if (callback == nullptr) { - delete mainSwipeGroup; - mainSwipeGroup = nullptr; - GRAPHIC_LOGE("SwipeCallback new fail\n"); + void MainViewSample::OnStart() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::OnStart"); + View::OnStart(); + BaseView::RootView(Color::Black().full); + + mainSwipeGroup = new UICrossView(); + if (mainSwipeGroup == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mainSwipeGroup new fail"); return; } - } - HorizontalViewInit(); - HorViewLoad(); - VerticalViewInit(); - VertViewLoad(); - mainSwipeGroup->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); - mainSwipeGroup->SetAnimatorTime(50); // 50: animator drag time(ms); - mainSwipeGroup->SetLoopState(true); - mainSwipeGroup->EnableScreenCap(true); - mainSwipeGroup->RegisterSwipeCallback(callback); - //卡片切换 - mainSwipeGroup->SetHorCurrentPage(mainClockView->GetViewIndex()); - SetContainerView(mainSwipeGroup); -} + if (callback == nullptr) + { + callback = new ZoomEffect(); + if (callback == nullptr) + { + delete mainSwipeGroup; + mainSwipeGroup = nullptr; + GRAPHIC_LOGE("SwipeCallback new fail\n"); + return; + } + } -bool MainViewSample::HorizontalViewInit(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::HorizontalViewInit"); - UISwipeView::OnSwipeListener *listener = nullptr; + HorizontalViewInit(); + HorViewLoad(); + VerticalViewInit(); + VertViewLoad(); + mainSwipeGroup->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + mainSwipeGroup->SetAnimatorTime(50); // 50: animator drag time(ms); + mainSwipeGroup->SetLoopState(true); + mainSwipeGroup->EnableScreenCap(true); + mainSwipeGroup->RegisterSwipeCallback(callback); + // 卡片切换 + mainSwipeGroup->SetHorCurrentPage(dialView->GetViewIndex()); + SetContainerView(mainSwipeGroup); + } - maxPage = ScreenModels::GetInstance()->GetMaxCard(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::HorizontalViewInit1"); + bool MainViewSample::HorizontalViewInit(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::HorizontalViewInit"); + UISwipeView::OnSwipeListener *listener = nullptr; + + maxPage = ScreenModels::GetInstance()->GetMaxCard(); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::HorizontalViewInit1"); + + for (int16_t i = 0; i < maxPage; i++) + { + recordCard[i] = CreatePage(i); + if (recordCard[i] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainViewSample:: recordCard %d error", i); + return false; + } + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample:: recordCard[%d]:%p", i, recordCard[i]); + } - for (int16_t i = 0; i < maxPage; i++) { - recordCard[i] = CreatePage(i); - if (recordCard[i] == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainViewSample:: recordCard %d error", i); + listener = static_cast(MainPresenterSample::GetInstance()); + if (listener == nullptr) + { return false; } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample:: recordCard[%d]:%p", i, recordCard[i]); + MainPresenterSample::GetInstance()->setCallback(callback); + mainSwipeGroup->SetOnSwipeListener(listener); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::InitPage over"); + return true; } - listener = static_cast(MainPresenterSample::GetInstance()); - if (listener == nullptr) { - return false; + void MainViewSample::HorViewLoad(void) + { + for (int16_t i = 0; i < maxPage; i++) + { + mainSwipeGroup->HorAdd(recordCard[i]); + } } - MainPresenterSample::GetInstance()->setCallback(callback); - mainSwipeGroup->SetOnSwipeListener(listener); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::InitPage over"); - return true; -} -void MainViewSample::HorViewLoad(void) -{ - for (int16_t i = 0; i < maxPage; i++) { - mainSwipeGroup->HorAdd(recordCard[i]); + void MainViewSample::VerticalViewInit(void) + { + dropDownView = new PullUpDownView(); + if (dropDownView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dropDownView new fail"); + return; + } + dropDownView->PreLoad(); + dropDownView->SetViewId("dropDownView"); + dropDownView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + dropDownView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); + + messageView = new UICardPage(); + if (messageView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "messageView new fail"); + return; + } + messageView->SetPosition(0, 0); + messageView->SetWidth(Screen::GetInstance().GetWidth()); + messageView->SetHeight(Screen::GetInstance().GetHeight()); + messageView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); + messageView->SetViewId("messageView"); + messageView->SetTouchable(true); + messageView->SetIntercept(true); + messageLable = new UILabel(); + if (messageLable == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "messageLable new fail"); + return; + } + messageLable->SetPosition(MESLABLE_X_TMP, MESLABLE_Y_TMP, MESLABLE_WIDTH_TMP, MESLABLE_HEIGHT_TMP); + messageLable->SetText("无消息"); + messageLable->SetAlign(TEXT_ALIGNMENT_CENTER); + messageLable->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_SIZE_TMP); + messageLable->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); + messageView->Add(messageLable); } -} -void MainViewSample::VerticalViewInit(void) -{ - dropDownView = new PullUpDownView(); - if (dropDownView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dropDownView new fail"); - return; + void MainViewSample::VertViewLoad(void) + { + mainSwipeGroup->VerAdd(dropDownView, UICrossView::VPage::UP_PAGE); + mainSwipeGroup->VerAdd(messageView, UICrossView::VPage::DOWN_PAGE); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::PullViewLoad::Pull View Load complete"); } - dropDownView->PreLoad(); - dropDownView->SetViewId("dropDownView"); - dropDownView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); - dropDownView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - - messageView = new UICardPage(); - if (messageView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "messageView new fail"); - return; - } - messageView->SetPosition(0, 0); - messageView->SetWidth(Screen::GetInstance().GetWidth()); - messageView->SetHeight(Screen::GetInstance().GetHeight()); - messageView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - messageView->SetViewId("messageView"); - messageView->SetTouchable(true); - messageView->SetIntercept(true); - messageLable = new UILabel(); - if (messageLable == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "messageLable new fail"); - return; - } - messageLable->SetPosition(MESLABLE_X_TMP, MESLABLE_Y_TMP, MESLABLE_WIDTH_TMP, MESLABLE_HEIGHT_TMP); - messageLable->SetText("无消息"); - messageLable->SetAlign(TEXT_ALIGNMENT_CENTER); - messageLable->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_SIZE_TMP); - messageLable->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - messageView->Add(messageLable); -} -void MainViewSample::VertViewLoad(void) -{ - mainSwipeGroup->VerAdd(dropDownView, UICrossView::VPage::UP_PAGE); - mainSwipeGroup->VerAdd(messageView, UICrossView::VPage::DOWN_PAGE); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::PullViewLoad::Pull View Load complete"); -} - -void MainViewSample::OnSetUpView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::OnSetUpView"); - View::OnSetUpView(); - - // show timerView - Draw(); -} + void MainViewSample::OnSetUpView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::OnSetUpView"); + View::OnSetUpView(); + // show timerView + Draw(); + } -void MainViewSample::OnTearDownView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::OnTearDownView"); - View::OnTearDownView(); - return; -} + void MainViewSample::OnTearDownView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::OnTearDownView"); + View::OnTearDownView(); + return; + } -void MainViewSample::OnStop() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::OnStop"); - View::OnStop(); - container_ = nullptr; - - messageView->RemoveAll(); - RootView::GetInstance()->ClearOnKeyActListener(); - RootView::GetInstance()->RemoveAll(); - return; -} + void MainViewSample::OnStop() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::OnStop"); + View::OnStop(); + container_ = nullptr; -UICardPage *MainViewSample::InitWatchFacePage(void) -{ - mainClockView = new MainClockView(); - if (mainClockView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainClockView new fail"); - return nullptr; + messageView->RemoveAll(); + RootView::GetInstance()->ClearOnKeyActListener(); + RootView::GetInstance()->RemoveAll(); + return; } - return mainClockView; -} -UICardPage *MainViewSample::InitHeartRatePage(void) -{ - heartRateView = new HeartRateView(); - if (heartRateView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "heartRateView new fail"); - return nullptr; + UICardPage *MainViewSample::InitWatchFacePage(void) + { + mainClockView = new Digital_clockView(); + if (mainClockView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainClockView new fail"); + return nullptr; + } + return mainClockView; } - return heartRateView; -} -UICardPage *MainViewSample::InitActivityPage(void) -{ - activityWeekView = new ActivityWeekView(); - if (activityWeekView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "activityWeekView new fail"); - return nullptr; + UICardPage *MainViewSample::InitHeartRatePage(void) + { + heartRateView = new HeartRateView(); + if (heartRateView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "heartRateView new fail"); + return nullptr; + } + return heartRateView; } - return activityWeekView; -} -UICardPage *MainViewSample::InitCompassPage(void) -{ - compassControlView = new CompassControlView(); - if (compassControlView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "compassControlView new fail"); - return nullptr; + UICardPage *MainViewSample::InitActivityPage(void) + { + activityWeekView = new ActivityWeekView(); + if (activityWeekView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "activityWeekView new fail"); + return nullptr; + } + return activityWeekView; } - return compassControlView; -} -UICardPage *MainViewSample::InitMusicPlayerPage(void) -{ - playersView = new PlayersView(); - if (playersView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "playersView new fail"); - return nullptr; + UICardPage *MainViewSample::InitCompassPage(void) + { + compassControlView = new CompassControlView(); + if (compassControlView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "compassControlView new fail"); + return nullptr; + } + return compassControlView; + } + // 主界面血氧卡片 + UICardPage *MainViewSample::InitBloodOxygenPage(void) + { + bloodView = new BloodView(); + if (bloodView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodView new fail"); + return nullptr; + } + return bloodView; + } + // 主界面训练卡片 + UICardPage *MainViewSample::InitTrainingPage(void) + { + traingView = new TraingView(); + if (traingView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "traingView new fail"); + return nullptr; + } + return traingView; } - return playersView; -} -UICardPage *MainViewSample::CreatePage(int32_t StreamId) -{ - uint16_t i; - UICardPage *view = nullptr; - int32_t cardId = ScreenModels::GetInstance()->GetCardPage(StreamId); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CreatePage cardId:%d", cardId); - for (i = 0; i < sizeof(PageMapper) / sizeof(PageMapper[0]); i++) { + UICardPage *MainViewSample::CreatePage(int32_t StreamId) + { + uint16_t i; + UICardPage *view = nullptr; + int32_t cardId = ScreenModels::GetInstance()->GetCardPage(StreamId); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CreatePage cardId:%d", cardId); + for (i = 0; i < sizeof(PageMapper) / sizeof(PageMapper[0]); i++) + { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::CreatePage PageMapper[i].id=%d, cardId=%d, StreamId=%d", PageMapper[i].id, cardId, StreamId); - if (PageMapper[i].id == cardId) { - view = (this->*(PageMapper[i].func))(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CreatePage view:%p", view); - return view; + printf("MainViewSample::CreatePage PageMapper[i].id=%d, cardId=%d, StreamId=%d\n", PageMapper[i].id, cardId, StreamId); + if (PageMapper[i].id == cardId) + { + view = (this->*(PageMapper[i].func))(); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CreatePage view:%p", view); + return view; + } } - } - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreatePage view error!"); - return nullptr; -} -void MainViewSample::AnimatorStart(int pageIndex) -{ - if (heartRateView != nullptr && pageIndex == ScreenModels::GetInstance()->GetCardPage(HEART_RATE)) { - heartRateView->HeartbeatImageAnimatorStart(); - } - if ((mainClockView != nullptr && pageIndex == ScreenModels::GetInstance()->GetCardPage(WATCH_FACE)) && - mainSwipeGroup->GetCurrentPageId(UISwipeView::VERTICAL) == 1) { - mainClockView->ClockAnimatorStart(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreatePage view error!"); + return nullptr; } -} -void MainViewSample::AnimatorStop(void) -{ - if (heartRateView != nullptr) { - heartRateView->HeartbeatImageAnimatorStop(); - } - if (mainClockView != nullptr) { - mainClockView->ClockAnimatorStop(); + void MainViewSample::AnimatorStart(int pageIndex) + { + if (heartRateView != nullptr && pageIndex == ScreenModels::GetInstance()->GetCardPage(HEART_RATE)) + { + heartRateView->HeartbeatImageAnimatorStart(); + } } -} -bool MainViewSample::IsMainView(void) -{ - if (mainSwipeGroup->GetCurrentPageId(0) == ScreenModels::GetInstance()->GetCardPage(WATCH_FACE) && - mainSwipeGroup->GetCurrentPageId(1) == 1) { // 0: horizontal; 1: vertical - return true; - } else { - return false; + void MainViewSample::AnimatorStop(void) + { + if (heartRateView != nullptr) + { + heartRateView->HeartbeatImageAnimatorStop(); + } + // if (mainClockView != nullptr) { + // mainClockView->ClockAnimatorStop(); + // } } -} -void MainViewSample::SetDragFg(bool continFg) -{ - continuDragFg = continFg; -} + bool MainViewSample::IsMainView(void) + { -bool MainViewSample::GetDragFg(void) -{ - return continuDragFg; -} + if (mainSwipeGroup->GetCurrentPageId(0) == ScreenModels::GetInstance()->GetCardPage(NEW_DAIL) && + mainSwipeGroup->GetCurrentPageId(1) == 1) + { // 0: horizontal; 1: vertical + return true; + } + else + { + return false; + } + } + void MainViewSample::SetDragFg(bool continFg) + { + continuDragFg = continFg; + } + bool MainViewSample::GetDragFg(void) + { + return continuDragFg; + } } diff --git a/code/sdk/application/wearable/nativeapp/nativeui/screensetting/include/ScreenModels.h b/code/sdk/application/wearable/nativeapp/nativeui/screensetting/include/ScreenModels.h index 78bab7b61..6a713cd2e 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/screensetting/include/ScreenModels.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/screensetting/include/ScreenModels.h @@ -1,3 +1,13 @@ +/*** + * @Author: Caisking 3449750381@qq.com + * @Date: 2024-01-17 14:36:35 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-01-17 19:47:13 + * @FilePath: /FD230/code/sdk/application/wearable/nativeapp/nativeui/screensetting/include/ScreenModels.h + * @Description: + * @ + * @Copyright (c) 2024 by Caisking , All Rights Reserved. + */ /* * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. * Description: ScreenModels @@ -13,11 +23,11 @@ namespace OHOS { typedef enum { - WATCH_FACE = 0, + NEW_DAIL = 0, HEART_RATE, + TRAINING, + BloodOxygen, COMPASS, - ACTIVITY, - MUSIC_PLAYER, MAX_CARD, } CardId; diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingView.h b/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingView.h new file mode 100644 index 000000000..bc624e90a --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingView.h @@ -0,0 +1,71 @@ +/*** + * @Author: Caisking 3449750381@qq.com + * @Date: 2023-12-12 16:55:27 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-01-16 14:43:12 + * @FilePath: /1.FD230/FD230/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingView.h + * @Description: + * @ + * @Copyright (c) 2024 by Caisking , All Rights Reserved. + */ +#ifndef _Traing_VIEW_H +#define _Traing_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include +#include "components/ui_view_group.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" +#include "components/ui_image_animator.h" +#include "components/ui_label_button_ext.h" +#include "components/ui_chart.h" +#include "wearable_log.h" +#include "ohos_types.h" +#include "components/ui_card_page.h" + +namespace OHOS +{ +#define BUTTON1 "button1" // 按键1 +#define BUTTON2 "button2" // 按键2 +#define BUTTON3 "button3" // 按键3 +#define BUTTONMORE "button4" // 按键 更多 + + class TraingView : public UICardPage + { + + public: + TraingView(); + virtual ~TraingView(); + static TraingView *GetInstance(void); + + bool InitView(); + void DeInit(); + + bool AddButton(); + bool InitImage(); + bool InitLable(); + + void PreLoad(void) override; + void UnLoad(void) override; + + private: + UIView::OnDragListener *draglistener{nullptr}; + TraingView(TraingView &&) = delete; + TraingView &operator=(TraingView &&) = delete; + + UILabelButtonExt *Button1 = nullptr; + UILabelButtonExt *Button2 = nullptr; + UILabelButtonExt *Button3 = nullptr; + UILabelButtonExt *ButtonMore = nullptr; + + UILabel *titleLabel = nullptr; + UIImageView *image1 = nullptr; + UIImageView *image2 = nullptr; + UIImageView *image3 = nullptr; + UIImageView *imagemore = nullptr; + bool viewiInitStatus{false}; + }; +} // namespace OHOS +#endif // Traing_PRESENTER_H diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingView.cpp new file mode 100644 index 000000000..3d43b9f1f --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingView.cpp @@ -0,0 +1,283 @@ + +#include "traing/include/TraingView.h" + +#include "common/image_cache_manager.h" +#include "UiConfig.h" +#include "ui_resource_image.h" +#include +#include "components/ui_button.h" +#include "components/ui_view_group.h" + +namespace OHOS +{ + static TraingView *g_pTraingView{nullptr}; + + TraingView::TraingView() + { + SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); + g_pTraingView = this; + } + + TraingView::~TraingView() + { + DeInit(); + g_pTraingView = nullptr; + } + + TraingView *TraingView::GetInstance() + { + return g_pTraingView; + } + bool TraingView::AddButton() + { + std::string traing1 = "健走"; + std::string traing2 = "骑行"; + std::string traing3 = "跑步"; + std::string traingmore = "更多"; + /* -------------------------------------------------------------------------- */ + if (Button1 == nullptr) + { + Button1 = new UILabelButtonExt(); + } + Button1->SetPosition(86, 118); // widget's left position and top position + Button1->Resize(140, 140); // widget's width and height + Button1->SetViewId(BUTTON1); // Set style + + const char *labelButton1defaultImgSrc = PNG_TRAING_BUTTONGRONG2_IMAGE; + char *labelButton1triggeredImgSrc = nullptr; + Button1->SetImageSrc(labelButton1defaultImgSrc, labelButton1triggeredImgSrc); + Button1->SetText(traing1.c_str()); + Button1->SetLabelPosition(0, 70); + Button1->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); + Button1->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff19ff41, UIButton::PRESSED); + Button1->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // UIView::OnClickListener *labelButton1Click = static_cast(new Labelbutton1OnClickListener()); + // Button1->SetOnClickListener(labelButton1Click); + Add(Button1); + /* -------------------------------------------------------------------------- */ + if (Button2 == nullptr) + { + Button2 = new UILabelButtonExt(); + } + Button2->SetPosition(236, 118); // widget's left position and top position + Button2->Resize(140, 140); // widget's width and height + Button2->SetViewId(BUTTON2); // Set style + + // Set additional property + const char *labelButton2defaultImgSrc = PNG_TRAING_BUTTONGRONG_IMAGE; + char *labelButton2triggeredImgSrc = nullptr; + Button2->SetImageSrc(labelButton2defaultImgSrc, labelButton2triggeredImgSrc); + Button2->SetText(traing2.c_str()); + Button2->SetLabelPosition(0, 70); + Button2->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); + Button2->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff19ff41, UIButton::PRESSED); + Button2->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // UIView::OnClickListener *labelButton2Click = static_cast(new Labelbutton1OnClickListener()); + // Button2->SetOnClickListener(labelButton2Click); + Add(Button2); + /* -------------------------------------------------------------------------- */ + if (Button3 == nullptr) + { + Button3 = new UILabelButtonExt(); + } + Button3->SetPosition(86, 268); // widget's left position and top position + Button3->Resize(140, 140); // widget's width and height + Button3->SetViewId(BUTTON3); // Set style + Button3->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + Button3->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + // Set additional property + const char *button3defaultImgSrc = PNG_TRAING_BUTTONGRONG_IMAGE; + char *button3triggeredImgSrc = nullptr; + Button3->SetImageSrc(button3defaultImgSrc, button3triggeredImgSrc); + Button3->SetText(traing3.c_str()); + Button3->SetLabelPosition(0, 70); + Button3->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); + Button3->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff19ff41, UIButton::PRESSED); + Button3->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // UIView::OnClickListener *button1Click = static_cast(TraingPresenter::GetInstance()); + // Button3->SetOnClickListener(button1Click); + Add(Button3); + /* -------------------------------------------------------------------------- */ + + // Add Button to App + if (ButtonMore == nullptr) + { + ButtonMore = new UILabelButtonExt(); + } + ButtonMore->SetPosition(236, 268); // widget's left position and top position + ButtonMore->Resize(140, 140); // widget's width and height + ButtonMore->SetViewId(BUTTONMORE); // Set style + ButtonMore->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + ButtonMore->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + + // Set additional property + const char *button4defaultImgSrc = PNG_TRAING_BOUTTONMORE_IMAGE; + char *button4triggeredImgSrc = nullptr; + ButtonMore->SetImageSrc(button4defaultImgSrc, button4triggeredImgSrc); + //ButtonMore->SetText(traingmore.c_str()); + ButtonMore->SetLabelPosition(0, 70); + ButtonMore->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); + ButtonMore->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff19ff41, UIButton::PRESSED); + ButtonMore->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // UIView::OnClickListener *button4Click = static_cast(TraingPresenter::GetInstance()); + // ButtonMore->SetOnClickListener(button4Click); + Add(ButtonMore); + + return true; + } + bool TraingView::InitLable() + { + // 检查标签指针是否为空 + if (titleLabel == nullptr) + { + titleLabel = new UILabel(); + } + // 设置标签的位置和大小 + titleLabel->SetPosition(173, 52); + titleLabel->Resize(200, 60); + // 设置标签的视图 ID + titleLabel->SetViewId("titleLabel"); + // 设置标签的样式 + titleLabel->SetStyle(STYLE_TEXT_FONT, 30); + titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + // 设置标签的文本和其他属性 + titleLabel->SetText("快速训练"); + titleLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + titleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + titleLabel->SetRollSpeed(0); + Add(titleLabel); + + return true; + } + bool TraingView::InitImage() + { + // Add ImageView to App + if (image1 == nullptr) + { + image1 = new UIImageView(); + } + image1->SetPosition(126, 298); // widget's left position and top position + image1->Resize(100, 100); // widget's width and height + image1->SetViewId("image3"); // Set style + // Set additional property + const char *image1imagesPath = PNG_TRAING_WALKINGBIG_IMAGE; + image1->SetSrc(image1imagesPath); + // Add to rootView + Add(image1); + + /* -------------------------------------------------------------------------- */ + // Add ImageView to App + if (image2 == nullptr) + { + image2 = new UIImageView(); + } + image2->SetPosition(276, 148); // widget's left position and top position + image2->Resize(100, 100); // widget's width and height + image2->SetViewId("image2"); // Set style + + // Set additional property + const char *image2imagesPath = PNG_TRAING_RIDINGBIG_IMAGE; + image2->SetSrc(image2imagesPath); + + // Add to rootView + Add(image2); + + /* -------------------------------------------------------------------------- */ + // Add ImageView to App + if (image3 == nullptr) + { + image3 = new UIImageView(); + } + image3->SetPosition(126, 148); // widget's left position and top position + image3->Resize(100, 100); // widget's width and height + image3->SetViewId("image1"); // Set style + + // Set additional property + const char *image3imagesPath = PNG_TRAING_RUNNINGBIG_IMAGE; + image3->SetSrc(image3imagesPath); + + // Add to rootView + Add(image3); + + return true; + } + + bool TraingView::InitView() + { + printf("Function: %s, Line: %d\n", __PRETTY_FUNCTION__, __LINE__); + if (!InitLable()) + { + printf("InitLable error!\n"); + }; + if (!AddButton()) + { + printf("AddButton error!\n"); + }; + if (!InitImage()) + { + printf("InitImage error!\n"); + }; + SetCoverable(true); + return true; + } + + void TraingView::DeInit() + { + if (titleLabel != nullptr) + { + delete titleLabel; + titleLabel = nullptr; + } + if (ButtonMore != nullptr) + { + delete ButtonMore; + ButtonMore = nullptr; + } + if (Button1 != nullptr) + { + delete Button1; + Button1 = nullptr; + } + if (Button3 != nullptr) + { + delete Button3; + Button3 = nullptr; + } + if (Button2 != nullptr) + { + delete Button2; + Button2 = nullptr; + } + if (image2 != nullptr) + { + delete image2; + image2 = nullptr; + } + if (image1 != nullptr) + { + delete image1; + image1 = nullptr; + } + if (image3 != nullptr) + { + delete image3; + image3 = nullptr; + } + } + void TraingView::PreLoad(void) + { + printf("Function: %s, Line: %d\n", __PRETTY_FUNCTION__, __LINE__); + if (InitView()) + { + viewiInitStatus = true; + } + } + + void TraingView::UnLoad(void) + { + } +} diff --git a/code/sdk/application/wearable/service/CMakeLists.txt b/code/sdk/application/wearable/service/CMakeLists.txt index a8260d71e..dab7be79e 100755 --- a/code/sdk/application/wearable/service/CMakeLists.txt +++ b/code/sdk/application/wearable/service/CMakeLists.txt @@ -8,3 +8,4 @@ if("CONFIG_SEA_PHS_SUPPORT" IN_LIST DEFINES) add_subdirectory_if_exist(smart_voice) endif() add_subdirectory_if_exist(power_manager) +add_subdirectory_if_exist(timeservice) diff --git a/code/sdk/application/wearable/service/timeservice/CMakeLists.txt b/code/sdk/application/wearable/service/timeservice/CMakeLists.txt new file mode 100644 index 000000000..88742cdbe --- /dev/null +++ b/code/sdk/application/wearable/service/timeservice/CMakeLists.txt @@ -0,0 +1,48 @@ +set(COMPONENT_NAME "timeservice") + +set(PUBLIC_HEADER +) + +set(PRIVATE_HEADER +${CMAKE_CURRENT_SOURCE_DIR}/include +) + +set(SOURCES +${CMAKE_CURRENT_SOURCE_DIR}/src/TimeServiceImpl.c +) + +set(COMPONENT_PUBLIC_CCFLAGS +) + +set(COMPONENT_CCFLAGS + -Wno-error + -Wno-unused-parameter + -fno-exceptions + -fno-unwind-tables + -fno-asynchronous-unwind-tables + -Wno-undef + -Wno-bitwise-op-parentheses + -Wno-shift-op-parentheses + -nostdlibinc + -nostdinc + -nostdlib + -Wno-error=unused-function +) + +set(WHOLE_LINK + true +) + +set(MAIN_COMPONENT + false +) + +set(PUBLIC_DEFINES +) + +set(PRIVATE_DEFINES +) + +build_component() + + diff --git a/code/sdk/application/wearable/service/timeservice/include/TimeService.h b/code/sdk/application/wearable/service/timeservice/include/TimeService.h new file mode 100644 index 000000000..61e46b0e4 --- /dev/null +++ b/code/sdk/application/wearable/service/timeservice/include/TimeService.h @@ -0,0 +1,42 @@ +/*** + * @Author: Caisking 3449750381@qq.com + * @Date: 2024-01-17 16:12:26 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-01-17 16:13:33 + * @FilePath: /FD230/code/sdk/application/wearable/service/timeservice/include/TimeService.h + * @Description: + * @ + * @Copyright (c) 2024 by Caisking , All Rights Reserved. + */ +/*** + * @Author: Caisking 3449750381@qq.com + * @Date: 2024-01-17 16:12:26 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-01-17 16:12:28 + * @FilePath: /FD230/code/sdk/application/wearable/service/timeservice/include/TimeService.h + * @Description: + * @ + * @Copyright (c) 2024 by Caisking , All Rights Reserved. + */ +#ifndef TIMESERVICE_H +#define TIMESERVICE_H + +#include +#include + +class TimeUpdateListener +{ +public: + virtual void onTimeUpdate(const std::string &updatedTime) = 0; + virtual ~TimeUpdateListener() {} +}; + +class TimeService +{ +public: + virtual std::string getCurrentTime() = 0; + virtual void subscribeTimeUpdate(TimeUpdateListener *listener) = 0; + virtual ~TimeService() {} +}; + +#endif // TIMESERVICE_H \ No newline at end of file diff --git a/code/sdk/application/wearable/service/timeservice/include/TimeServiceImpl.h b/code/sdk/application/wearable/service/timeservice/include/TimeServiceImpl.h new file mode 100644 index 000000000..da4bbeb45 --- /dev/null +++ b/code/sdk/application/wearable/service/timeservice/include/TimeServiceImpl.h @@ -0,0 +1,29 @@ +/*** + * @Author: Caisking 3449750381@qq.com + * @Date: 2024-01-17 16:12:44 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-01-17 16:23:51 + * @FilePath: /FD230/code/sdk/application/wearable/service/timeservice/include/TimeServiceImpl.h + * @Description: + * @ + * @Copyright (c) 2024 by Caisking , All Rights Reserved. + */ +// TimeServiceImpl.h +#ifndef TIMESERVICEIMPL_H +#define TIMESERVICEIMPL_H + +#include "TimeService.h" +#include +#include + +class TimeServiceImpl : public TimeService { +private: + std::vector listeners; + +public: + std::string getCurrentTime() override; + void subscribeTimeUpdate(TimeUpdateListener* listener) override; + void updateAndNotify(); +}; + +#endif // TIMESERVICEIMPL_H \ No newline at end of file diff --git a/code/sdk/application/wearable/service/timeservice/src/TimeServiceImpl.cpp b/code/sdk/application/wearable/service/timeservice/src/TimeServiceImpl.cpp new file mode 100644 index 000000000..98f55f07e --- /dev/null +++ b/code/sdk/application/wearable/service/timeservice/src/TimeServiceImpl.cpp @@ -0,0 +1,40 @@ +/*** + * @Author: Caisking 3449750381@qq.com + * @Date: 2024-01-17 16:13:11 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-01-17 16:13:13 + * @FilePath: /FD230/code/sdk/application/wearable/service/timeservice/src/TimeServiceImpl.cpp + * @Description: + * @ + * @Copyright (c) 2024 by Caisking , All Rights Reserved. + */ +// TimeServiceImpl.cpp +#include "TimeServiceImpl.h" +#include + +std::string TimeServiceImpl::getCurrentTime() +{ + time_t now = time(0); + tm *localTime = localtime(&now); + char buffer[80]; + strftime(buffer, 80, "%Y-%m-%d %H:%M:%S", localTime); + return std::string(buffer); +} + +void TimeServiceImpl::subscribeTimeUpdate(TimeUpdateListener *listener) +{ + listeners.push_back(listener); +} + +void TimeServiceImpl::updateAndNotify() +{ + while (true) + { + std::string updatedTime = getCurrentTime(); + for (TimeUpdateListener *listener : listeners) + { + listener->onTimeUpdate(updatedTime); + } + std::this_thread::sleep_for(std::chrono::seconds(1)); + } +} \ No newline at end of file