📄 headset_configmanager.c
字号:
{
pattern.LED_A = config[n].led_a;
pattern.LED_B = config[n].led_b;
pattern.OnTime = config[n].on_time * 10;
pattern.OffTime = config[n].off_time * 10;
pattern.RepeatTime = config[n].repeat_time * 50;
pattern.NumFlashes = config[n].number_flashes;
pattern.TimeOut = config[n].timeout;
pattern.DimTime = config[n].dim_time;
pattern.Colour = config[n].colour;
pattern.OverideDisable = config[n].overide_disable;
switch(type)
{
case led_state_pattern:
LEDManagerAddLEDStatePattern(&theHeadset->theLEDTask , config[n].state, config[n].a2dp_state , &pattern);
break;
case led_event_pattern:
LEDManagerAddLEDEventPattern(&theHeadset->theLEDTask , EVENTS_EVENT_BASE + config[n].state, &pattern);
break;
}
}
success = TRUE;
}
else
{
CONF_DEBUG(("Co: !LedLen\n")) ;
}
/* Free up memory */
free(config);
}
}
return success;
}
/****************************************************************************
NAME
config_led_filter
DESCRIPTION
Read the LED filter configuration from persistent store and configure the
LED filters.
RETURNS
TRUE or FALSE
*/
static bool config_filter( hsTaskData * theHeadset , uint16 pskey_no, uint16 pskey_filter, uint16 max)
{
bool success = FALSE;
uint16 no_filters = 0;
/* First read the number of filters configured */
if(ConfigRetrieve(pskey_no, &no_filters, sizeof(uint16)))
{
/* Providing there are states to configure */
if((no_filters > 0) && (no_filters <= max))
{
/* Allocate enough memory to hold filter configuration */
led_filter_config_type* config = (led_filter_config_type*) PanicUnlessMalloc(no_filters * sizeof(led_filter_config_type));
/* Now read in configuration */
if(ConfigRetrieve(pskey_filter, config, no_filters * sizeof(led_filter_config_type)))
{
uint16 n;
LEDFilter_t filter;
/* Now we have the configuration, map to system states/events */
for(n = 0; n < no_filters; n++)
{
filter.Event = EVENTS_EVENT_BASE + config[n].event;
filter.Speed = config[n].speed;
filter.IsFilterActive = config[n].active;
filter.SpeedAction = config[n].speed_action;
filter.Colour = config[n].colour;
filter.FilterToCancel = config[n].filter_to_cancel ;
filter.OverideLED = config[n].overide_led ;
filter.OverideLEDActive = config[n].overide_led_active ;
filter.FollowerLEDActive = config[n].follower_led_active ;
filter.FollowerLEDDelay = config[n].follower_led_delay_50ms ;
filter.OverideDisable = config[n].overide_disable;
/*add the filter*/
LEDManagerAddLEDFilter(&theHeadset->theLEDTask , &filter);
}
}
else
{
CONF_DEBUG(("Co :!FilLen\n")) ;
}
/* Free up memory */
free(config);
success = TRUE;
}
}
return success;
}
/****************************************************************************
NAME
configManagerLEDS
DESCRIPTION
Read the system LED configuration from persistent store and configure
the LEDS.
*/
static void configManagerLEDS(hsTaskData* theHeadset)
{
/* 1. LED state configuration */
config(theHeadset , led_state_pattern, PSKEY_NO_LED_STATES_A, PSKEY_LED_STATES_A, MAX_LED_STATES/2);
config(theHeadset , led_state_pattern, PSKEY_NO_LED_STATES_B, PSKEY_LED_STATES_B, MAX_LED_STATES/2);
/* 2. LED event configuration */
config(theHeadset , led_event_pattern, PSKEY_NO_LED_EVENTS, PSKEY_LED_EVENTS, MAX_LED_EVENTS);
/* 3. LED event filter configuration */
config_filter(theHeadset , PSKEY_NO_LED_FILTERS, PSKEY_LED_FILTERS, MAX_LED_FILTERS);
/*tri colour behaviour*/
/*ConfigRetrieve(PSKEY_TRI_COL_LEDS, &theHeadset->theLEDTask.gTriColLeds, sizeof(uint16)) ;*/
}
/****************************************************************************
NAME
configManagerButtonDurations
DESCRIPTION
Read the button configuration from persistent store and configure
the button durations.
*/
static uint16 configManagerButtonDurations(hsTaskData* theHeadset)
{
button_config_type buttons;
if(ConfigRetrieve(PSKEY_BUTTON_CONFIG, &buttons, sizeof(button_config_type)))
{
buttonManagerConfigDurations (buttons.long_press_time,
buttons.very_long_press_time,
buttons.double_press_time,
buttons.repeat_time ,
buttons.very_very_long_press_time);
return buttons.debounce;
}
return 0;
}
/****************************************************************************
NAME
configManagerEventTone
DESCRIPTION
Configure an event tone only if one is defined.
*/
static void configManagerEventTones ( hsTaskData* theHeadset)
{
uint16 no_tones = 0;
uint16 ret_len = 0;
uint32 data;
/* First read the number of events configured */
if(ConfigRetrieve(PSKEY_NO_TONES, &no_tones, sizeof(uint16)))
{
/* Allocate enough memory to hold event configuration */
tone_config_type * config = (tone_config_type *) PanicUnlessMalloc(no_tones * sizeof(tone_config_type));
/* Now read in tones configuration */
if(ConfigRetrieve(PSKEY_TONES, config, no_tones * sizeof(tone_config_type)))
{
uint16 n;
/* Now we have the event configuration, map required events to system events */
for(n = 0; n < no_tones; n++)
{
CONF_DEBUG(("CO: Ev[%x]Tone[%x] \n" , config[n].event, config[n].tone )) ;
TonesConfigureEvent ( theHeadset , (config[n].event + EVENTS_EVENT_BASE), config[n].tone ) ;
}
}
free ( config ) ;
}
/* Read the mixed A2DP tone volume */
ret_len = PsRetrieve(PSKEY_A2DP_TONE_VOLUME, &data, sizeof(uint32));
/* If no key exists then set to a default value */
if(!ret_len)
{
data = 0x3fff3fff;
PsStore(PSKEY_A2DP_TONE_VOLUME, &data, sizeof(uint32));
}
}
/****************************************************************************
NAME
configManagerPower
DESCRIPTION
Read the Power Manager configuration.
*/
static void configManagerPower(hsTaskData* theHeadset)
{
power_config_type config;
memset(&config, 0, sizeof(power_config_type));
/* Read in the battery monitoring configuration */
ConfigRetrieve(PSKEY_BATTERY_CONFIG, &config.battery, sizeof(battery_config_type));
/* Setup the power manager */
powerManagerConfig(theHeadset->power, &config);
}
/****************************************************************************
NAME
configManagerTimeouts
DESCRIPTION
Read and configure the timeouts.
*/
static void configManagerTimeouts ( hsTaskData* theHeadset)
{
/* Get the timeout values */
ConfigRetrieve(PSKEY_TIMEOUTS, &theHeadset->Timeouts, sizeof(Timeouts_t) ) ;
CONF_DEBUG(("Co : Pairing Timeout[%d]\n" , theHeadset->Timeouts.PairModeTimeout_s )) ;
}
/****************************************************************************
NAME
configManagerAmp
DESCRIPTION
Read and configure the amp control.
*/
static void configManagerAmp ( hsTaskData* theHeadset)
{
Amp_t amp;
/* Get the timeout values */
ConfigRetrieve(PSKEY_AMP, &, sizeof(Amp_t) ) ;
theHeadset->ampAutoOff = amp.ampAutoOff;
theHeadset->ampPio = amp.ampPio;
theHeadset->ampOffDelay = amp.ampOffDelay;
CONF_DEBUG(("Co : Amp config: Auto off[%d] Pio[0x%lx] Off delay[%d secs]\n" , theHeadset->ampAutoOff,theHeadset->ampPio,theHeadset->ampOffDelay )) ;
/* Configure the amp then turn it on */
AmpSetOffDelay(theHeadset, theHeadset->ampOffDelay);
AmpSetPio(theHeadset, theHeadset->ampPio);
}
/****************************************************************************
NAME
configManagerFeatures
DESCRIPTION
Read and configure the features block.
*/
static void configManagerFeatures ( hsTaskData* theHeadset)
{
Features_t features;
/* Get the timeout values */
ConfigRetrieve(PSKEY_FEATURES, &features, sizeof(Features_t) ) ;
theHeadset->autoSendAvrcp = features.autoSendAvrcp;
theHeadset->cvcEnabled = features.cvcEnabled;
CONF_DEBUG(("Co : Features config: Auto AVRCP[%d] CVC[%d]\n" , theHeadset->autoSendAvrcp , theHeadset->cvcEnabled )) ;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -