/*----------------------------------------------------------------------------*/
void set_alm_sec(void)
{

    if (alm_sw)	enable_alm();
    else   disable_alm();
    fond_alm_clk();
    write_info(MEM_ALM_HOUR,curr_alm.hour);
    write_info(MEM_ALM_MIN,curr_alm.minutes);
}
void save_radio_freq(u16 radio_freq,u8 ch)
{
	xd_u8 freq_reg=0;

	freq_reg =(u8)radio_freq&(0x00FF);
	write_info(ch, freq_reg);

	freq_reg =(u8)(radio_freq>>8);
	write_info(ch+1, freq_reg);
}
Beispiel #3
0
void save_radio_freq(u16 radio_freq,u8 ch)
{
	xd_u8 freq_reg=0;
	
	ch=ch<<1;
	freq_reg =(u8)radio_freq&(0x00FF);
	write_info(MEM_FM_CHANNL +ch , freq_reg);

	freq_reg =(u8)(radio_freq>>8);
	write_info(MEM_FM_CHANNL +ch+1, freq_reg);
}
void fm_scan_flag(bool flag)
{
    if (flag)
    {
        write_info(MEM_CHAN,fre_channel|0x80);
    }
    else
    {
        write_info(MEM_CHAN,fre_channel&0x7f);
    }
}
/*----------------------------------------------------------------------------*/
void get_channl(u8 flag)
{
    frequency = fre_point[flag-1] + MIN_FRE;
    if ( frequency > MAX_FRE)
    {
        frequency = MIN_FRE;
    }
    else if (frequency < MIN_FRE)
    {
        frequency = MAX_FRE;
    }
   // set_fre_rda5807(frequency,1);
    write_info(MEM_FRE_CHANNL,fre_channl);
    write_info(MEM_FRE,frequency - MIN_FRE);
}
/*----------------------------------------------------------------------------*/
void save_fre(u16 fre)
{
    if (all_channl < MAX_CHANNL)
    {
        fre_point[all_channl] = fre - MIN_FRE;
        write_info(MEM_CHANNL + all_channl , fre - MIN_FRE);
        all_channl++;
    }
    write_info(MEM_ALL_CHANNL , all_channl);
    //delay_10ms(3);

    //delay_10ms(3);
    fre_channl = all_channl;
    get_channl(fre_channl);
}
Beispiel #7
0
int request_usr(simple_person ** arr, int * size, int id,char * conect, tOPC opc)
{

	char opOK=0,qty_people=0;
	int full_size;
	clsvbuff buff;

	initConnection(TYPE_MSG_Q);

	buff.opc=opc;
	buff.id_client=id;
	write_info(&buff);
	read_info(&opOK,sizeof(char),buff.id_client);
	if(opOK==NOTOK)
	{
		return NOTOK;
	}
	read_info((char*)&qty_people,sizeof(char),buff.id_client);
	*size=qty_people;
	full_size=sizeof(simple_person) * (*size);

	if(full_size>0)
	{
		*arr=malloc(full_size);
		if(*arr==NULL)
			return NOTOK;
		read_info((char*) (*arr),full_size,buff.id_client);
	}

	return OK;
}
Beispiel #8
0
void
Config::save()
{
    if (isModified()) {
        write_info(path, props);
    }
}
Beispiel #9
0
void
InfoEditor::save(const std::string& fileName)
{
  std::ofstream output(fileName);
  write_info(output, m_info);
  output.close();
}
/*----------------------------------------------------------------------------*/
void clear_all_fm_point(void)
{
    u8 i;

    for (i = MEM_CHANNL; i <= (MEM_CHANNL + MEM_FM_LEN); i++)
    {
        write_info(i ,0);
    }
}
/*----------------------------------------------------------------------------*/
void save_fm_point(u8 fre)
{
    u8 i,j, k;

    i = fre / 8;
    k = fre % 8;

    j = read_info(MEM_CHANNL + i) | BIT(k);
    write_info(MEM_CHANNL + i, j);
}
Beispiel #12
0
/*
 * Function name: get_nline
 * Description  : Get new line. This function waits until the player pressed
 *                'return' when the script wants him to.
 * Arguments    : string str - the newline.
 */
static void
get_nline(string str)
{
    if (str == "quit")
    {
	quit();
	return;
    }

    write_info();
}
Beispiel #13
0
/**
 * @brief Start operations to retrieve data from the data file and make the new
 * hosts file for the current operating system.
 */
void MakeHosts::make()
{
    RetrieveData::Instance()->connect_db();
    make_time = QDateTime::currentDateTime();
    hosts_file->open(QIODevice::WriteOnly);
    write_head();
    write_info();
    get_hosts(make_cfg);
    hosts_file->close();
    RetrieveData::Instance()->disconnect_db();
}
Beispiel #14
0
/*
 * Function name: get_sline
 * Description  : Get single line. This function is called when the player
 *                may enter a single line of text based on a question.
 * Arguments    : string str - the answer of the player.
 */
static void
get_sline(string str)
{
    if (str == "quit")
    {
	quit();
	return;
    }

    result += str + "\n";
    write_info();
}
Beispiel #15
0
void write_file_info(u8 cmd)
{
    u16 id;
    u8 i;
//    u8 encode_cnt;
//    u8 mem_addr;
    if(0 == cmd)
    {
        id = 0;
    }
    else
    {
        id = read_file_id(&fat_ptr1);
    }

    write_info(MEM_ACTIVE_DEV, device_active);

    get_rec_mem_info();
    if ((device_active & (~VIRTUAL_DEVICE)) == DEVICE_SDMMC0)
    {
        disk_mus_point[0+encode_cnt].id0 = id;
        disk_mus_point[0+encode_cnt].id1 = 0;
        disk_mus_point[0+encode_cnt].id2 = 0;
        for (i = 9;i != (-1);i--)
        {
            write_info(MEM_SD_PLAYPOINT_ID0+i+mem_addr,((u8 *)(&(disk_mus_point[0+encode_cnt].id0)))[i]);
        }
    }
    else if ((device_active & (~VIRTUAL_DEVICE)) == DEVICE_UDISK)
    {
        disk_mus_point[1 + encode_cnt].id0 = id;
        disk_mus_point[1 + encode_cnt].id1 = 0;
        disk_mus_point[1 + encode_cnt].id2 = 0;
        for (i = 9;i != (-1);i--)
        {
            write_info(MEM_USB_PLAYPOINT_ID0+i+mem_addr,((u8 *)(&(disk_mus_point[1 + encode_cnt].id0)))[i]);
        }
    }
}
Beispiel #16
0
void write_file_info(u8 cmd)
{
    u16 id;
    //u8 i;
//    u8 encode_cnt;
//    u8 mem_addr;
    if(0 == cmd)
    {
        id = 0;
    }
    else
    {
        id = read_file_id(&fat_ptr1);
    }

    write_info(MEM_ACTIVE_DEV, device_active);

   // get_rec_mem_info();
    if ((device_active & (~VIRTUAL_DEVICE)) == DEVICE_SDMMC0)
    {

#if 1
	write_info(MEM_SD_PLAYPOINT_ID0+1 , (u8)(id&(0x00FF)));
	write_info(MEM_SD_PLAYPOINT_ID0, (u8)((id>>8)&(0x00FF)));

	//sd_music_bp = id;
	//write_info(MEM_SD_PLAYPOINT_ID0,(((u8 *)(&sd_music_bp))[0]));
	//write_info(MEM_SD_PLAYPOINT_ID0+1,(((u8 *)(&sd_music_bp))[1]));
#else
        disk_mus_point[0+encode_cnt].id0 = id;
        disk_mus_point[0+encode_cnt].id1 = 0;
        disk_mus_point[0+encode_cnt].id2 = 0;
        for (i = 9;i != (-1);i--)
        {
            write_info(MEM_SD_PLAYPOINT_ID0+i+mem_addr,((u8 *)(&(disk_mus_point[0+encode_cnt].id0)))[i]);
        }
#endif
    }
Beispiel #17
0
/** Create a new project /name/ from existing template
 * /template_name/ */
bool
Project::create ( const char *name, const char *template_name )
{
    if ( exists( name ) )
    {
        WARNING( "Project already exists" );
        return false;
    }

    close();

    if ( mkdir( name, 0777 ) )
    {
        WARNING( "Cannot create project directory" );
        return false;
    }

    if ( chdir( name ) )
        FATAL( "WTF? Cannot change to new project directory" );

    mkdir( "sources", 0777 );
    creat( "history", 0666 );

    if ( ! engine )
        make_engine();

    /* TODO: copy template */

    write_info();

    if ( open( name ) == 0 )
    {
        /* add the bare essentials */
        timeline->beats_per_minute( 0, 120 );
        timeline->time( 0, 4, 4 );

        MESSAGE( "Created project \"%s\" from template \"%s\"", name, template_name );
        return true;
    }
    else
    {
        WARNING( "Failed to open newly created project" );
        return false;
    }
}
Beispiel #18
0
void dpsx(SRC_NODE *node)
{
     int  retVal;

     start_node = node;
     close_fds();
     if (start_node == NULL)
         return;
     set_times();
     retVal = outputSeq();
     close_fds();
     if (retVal) {
         write_info();
         sprintf(tmpStr, "%s/.dpsViewInfo", curexpdir);
         unixPathToWin(tmpStr, tmpPath, MAXPATH);
         writelineToVnmrJ("dps scopewindow ", tmpPath);
     }
}
Beispiel #19
0
int get_person(person *p,int person_id,int src_id,char * conect)
{
	char opOK=0;
	clsvbuff buff;

	initConnection(TYPE_MSG_Q);

	buff.opc=GET_INFO;
	buff.id_client=src_id;
	buff.data.clsv_get_info.id=person_id;

	write_info(&buff);

	read_info(&opOK, sizeof(char), buff.id_client);
	read_info((char *)p, sizeof(person), buff.id_client);

	return opOK;
}
Beispiel #20
0
int
b_uname()
{
	FILE *fp;
	int ret;

	if ((fp = fopen(UNAMEFILE, "w")) == NULL)
		goto file_err;

	ret = write_info(fp);

	if (fclose(fp) != 0) {
file_err:	fprintf(stderr,
		    "%s: %s: %s\n", progname, UNAMEFILE, strerror(errno));
		return (1);
	}

	return (ret);
}
Beispiel #21
0
/*
 * Function name: get_mline
 * Description  : Get multi line. Get input from the player when (s)he is
 *                writing the comment part of the request.
 * Arguments    : string str - the input from the player.
 */
static void
get_mline(string str)
{
    if (str == "quit")
    {
	quit();
	return;
    }

    if (str == "**")
    {
	write_info();
	return;
    }

    result += str + "\n\t\t";
    write_socket("Application entry> ");
    input_to(get_mline);
}
Beispiel #22
0
Datei: x.c Projekt: knusbaum/Wily
int
main(int argc, char *argv[])
{
	char *p, *re;
	size_t len;
	Subrange *r;
	void (*fn)(ulong p0, ulong p1);

	/* This isn't wonderful: assume that the regexp is delimited by // */
	if (argc < 2 || *(re = argv[1]) != '/'  || (len = strlen(re)) < 2) {
		fprintf(stderr,"Usage: x /regexp/\n");
		exit(1);
	}
	if (re[--len] == '/')
		re[len] = 0;
	re++;		/* skip / */
	if (len == 0) {
		fprintf(stderr,"null regexp\n");
		exit(1);
	}
	if (init_regexp(re)) {
		fprintf(stderr,"Invalid regexp\n");
		exit(1);
	}
	p = strrchr(argv[0], '/');
	p = p? p+1 : argv[0];
	switch (*p) {
		case 'x' :	fn = fn_x;	break;
		case 'y' :	fn = fn_y;	break;
		case 'g' :	fn = fn_g;	break;
		case 'v' :	fn = fn_v;	break;
		default:
			fprintf(stderr,"Uknown program name!\n");
			exit(1);
	}
	read_info(0);		/* Don't reverse ranges */
	Finit(&runefile, tmpfilename);
	write_info();
	while (r = next_range())
		(*fn)(r->p0, r->p1);
	exit(0);
}
Beispiel #23
0
int evaluate(boolean * match,boolean opinion,int person_id, int src_id,char * conect)
{
	char opOK=0;
	clsvbuff buff;

	initConnection(TYPE_MSG_Q);

	buff.id_client=src_id;
	buff.opc=EVALUATION;
	buff.data.clsv_evaluation.id=person_id;
	buff.data.clsv_evaluation.like=opinion;

	write_info(&buff);

	read_info(&opOK, sizeof(char), buff.id_client);
	read_info((char *)match, sizeof(boolean), buff.id_client);
	if(opOK==NOTOK)
		return NOTOK;
	return OK;
}
Beispiel #24
0
/*
 * Function name: enter_game
 * Description  : This function is called from the login object and enables
 *                the player to connect. It takes care of the necessary
 *                initialization before the player is allowed to file his
 *                request.
 */
void
enter_game()
{
    string data;
    int bl;

    set_screen_width(80);

    bl = SECURITY->check_newplayer(query_ip_number(this_object()));
    if (bl == 0)
    {
	write_socket("Your site isn't blocked. Log in as usual.\n");

	destruct();
	return;
    }
    else if (bl == 1)
    {
	write_socket("Your site has been banned, not just simply blocked.\n" +
	    "No one will be admitted from your site.\n");

	destruct();
	return;
    }

    data = read_file(APPLICATION_INFO);
    if (!strlen(data))
    {
	write_socket("Panic! Couldn't read: " + APPLICATION_INFO + ".\n");

	destruct();
	return;
    }

    info = explode(data, "##");

    enable_commands();
    write_info();
}
Beispiel #25
0
// Writes to the given file. Returns false in case of error.
bool FontInfo::Serialize(FILE* fp) const {
  if (!write_info(fp, *this)) return false;
  if (!write_spacing_info(fp, *this)) return false;
  return true;
}
Beispiel #26
0
void getsets()
{
  FILE *fp3,*fp4;
  int end_seq,elm,end,trains,i;


  fp3=fopen("lstmtrain.txt","r");
  end=0;
  trains=0;
  while (end==0)
    {
      end_seq=0;
      elm=0;
      while (end_seq==0)
	{
	  for (i=0;i<in_mod;i++)
	    {
	      fscanf(fp3,"%lf ",&inp[trains][elm][i]);
	    }
	  for (i=0;i<out_mod;i++)
	    {
	      fscanf(fp3,"%lf ",&tar[trains][elm][i]);
	    }
	  fscanf(fp3,"\n");
	  /* sequence ends with first input component greater 10.0 */
	  if (fabs(inp[trains][elm][0])>10.0)
	    {
	      /* if 2 successive sequences have a first input component greater
		 than 10.0, then training set is finished */ 
	      if (elm==0)
		{
		  end=1;
		}
	      else
		{
		  elm--;
		}
	      end_seq=1;
	    }
	  elm++;
	  if (elm>max_sequence_length)
	    {
	      printf("Program terminated!\n");
	      printf("You have to set the constant max_sequence_length at begin\n");
	      printf("of the program file greater or equal maximal sequence\n");
	      printf("length (>= %d) and then compile the program again.\n",elm);
	      exit(0);
	    }
	}
      length[trains]=elm;
      trains++;
      if (end==1)
	trains--;
    }
  fclose(fp3);
  if (trains!=training_size)
    {
      printf("Training set size in parameter file: %d.\n",training_size);
      printf("Training set size detected: %d.\n",trains);
      write_info();
      exit(0);
    }

  fp4=fopen("lstmtest.txt","r");
  end=0;
  trains=0;
  while (end==0)
    {
      end_seq=0;
      elm=0;
      while (end_seq==0)
	{
	  for (i=0;i<in_mod;i++)
	    {
	      fscanf(fp4,"%lf ",&inp_t[trains][elm][i]);
	    }
	  for (i=0;i<out_mod;i++)
	    {
	      fscanf(fp4,"%lf ",&tar_t[trains][elm][i]);
	    }
	  fscanf(fp3,"\n");
	  if (fabs(inp_t[trains][elm][0])>10.0)
	    {
	      if (elm==0)
		{
		  end=1;
		}
	      else
		{
		  elm--;
		}
	      end_seq=1;
	    }
	  elm++;

	  if (elm>max_sequence_length)
	    {
	      printf("Program terminated!\n");
	      printf("You have to set the constant max_sequence_length at begin\n");
	      printf("of the program file greater or equal maximal sequence\n");
	      printf("length (>= %d) and then compile the program again.\n",elm);
	      exit(0);
	    }
	}
      length_t[trains]=elm;
      trains++;
      if (end==1)
	trains--;
    }
  fclose(fp4);
  if (trains!=test_size)
    {
      printf("Test set size in parameter file: %d.\n",test_size);
      printf("Test set size detected: %d.\n",trains);
      write_info();
      exit(0);
    }
}
Beispiel #27
0
void Channel::add_data_internal(const std::vector<DataSample<T> > &data, DataRanges *channel_ranges) {
  if (!data.size()) return;
  // Sanity check
  if (data[0].time < 0) throw std::runtime_error("Unimplemented feature: adding data with negative time");
  for (unsigned i = 0; i < data.size()-1; i++) {
    if (data[i].time > data[i+1].time) throw std::runtime_error("Attempt to add data that is not sorted by ascending time");
  }

  //	regenerate = empty set
  Locker lock(*this);  // Lock self and hold lock until exiting this method
  std::set<TileIndex> to_regenerate;

  ChannelInfo info;
  bool success = read_info(info);
  if (!success) {
    // New channel
    info.magic = ChannelInfo::MAGIC;
    info.version = 0x00010000;
    info.times = Range(data[0].time, data.back().time);
    info.nonnegative_root_tile_index = TileIndex::nonnegative_all();
    create_tile(TileIndex::nonnegative_all());
    info.negative_root_tile_index = TileIndex::null();
  } else {
    info.times.add(Range(data[0].time, data.back().time));
    // If we're not the all-tile, see if we need to move the root upwards
    if (info.nonnegative_root_tile_index != TileIndex::nonnegative_all()) {
      TileIndex new_nonnegative_root_tile_index = TileIndex::index_containing(info.times);
      if (new_nonnegative_root_tile_index.level > info.nonnegative_root_tile_index.level) {
	// Root index changed.  Confirm new root is parent or more distant ancestor of old root
	assert(new_nonnegative_root_tile_index.is_ancestor_of(info.nonnegative_root_tile_index));
	// Trigger regeneration from old root's parent, up through new root
	to_regenerate.insert(info.nonnegative_root_tile_index.parent());
	move_root_upwards(new_nonnegative_root_tile_index, info.nonnegative_root_tile_index);
	info.nonnegative_root_tile_index = new_nonnegative_root_tile_index;
      }
    }
  }

  unsigned i=0;

  while (i < data.size()) {
    TileIndex ti= find_lowest_child_overlapping_time(info.nonnegative_root_tile_index, data[i].time);
    assert(!ti.is_null());

    Tile tile;
    assert(read_tile(ti, tile));
    const DataSample<T> *begin = &data[i];
    while (i < data.size() && ti.contains_time(data[i].time)) i++;
    const DataSample<T> *end = &data[i];
    tile.insert_samples(begin, end);
    
    TileIndex new_root = split_tile_if_needed(ti, tile);
    if (new_root != TileIndex::null()) {
      assert(ti == TileIndex::nonnegative_all());
      if (verbosity) log_f("Channel: %s changing root from %s to %s",
                           descriptor().c_str(), ti.to_string().c_str(),
                           new_root.to_string().c_str());
      info.nonnegative_root_tile_index = new_root;
      delete_tile(ti); // Delete old root
      ti = new_root;
    }
    write_tile(ti, tile);
    if (ti == info.nonnegative_root_tile_index && channel_ranges) { *channel_ranges = tile.ranges; }
    if (ti != info.nonnegative_root_tile_index) to_regenerate.insert(ti.parent());
  }
  
  // Regenerate from lowest level to highest
  while (!to_regenerate.empty()) {
    TileIndex ti = *to_regenerate.begin();
    to_regenerate.erase(to_regenerate.begin());
    Tile regenerated, children[2];
    assert(read_tile(ti.left_child(), children[0]));
    assert(read_tile(ti.right_child(), children[1]));
    create_parent_tile_from_children(ti, regenerated, children);
    write_tile(ti, regenerated);
    if (ti == info.nonnegative_root_tile_index && channel_ranges) { *channel_ranges = regenerated.ranges; }
    if (ti != info.nonnegative_root_tile_index) to_regenerate.insert(ti.parent());
  }
  write_info(info);
}
/*----------------------------------------------------------------------------*/
void fm_rev( void )
{
    u8 key;

#if defined(SPECTRUM_FUNC_ENABLE)
    set_spectrum_lock(UNLOCK);
#endif		  

#if defined(FM_PAUSE_LED_INDICATOR)
    set_play_flash(LED_FLASH_NOR);
#endif

    my_main_vol(my_music_vol);	
	
    while (1)
    {
        key = get_msg();
#if defined(KEY_PRESS_LED_INDICATOR)
	key_press_led_indicator(key);
#elif defined(CUSTOM_KEY_FEATURE_USE)
		custom_key_hdlr(key);
#endif

#if defined(KPL_MSG_COMPATIBLE)
	kpl_msg_hdlr(key);
#endif

#if 0
	if(key!=0xff)
	printf(" music_play get_msg %x \r\n",(u16)key);
#endif
	dac_sw_check();

#ifndef FM_BY_PASS
       dac_out_select(aux_ch_reg);
#endif

        switch (key)
        {

#if defined(K000_HG_898_V001)||defined(USE_STOP_KEY_SHORT_CH_DOWN)
	case INFO_STOP |KEY_SHORT_UP :
		goto __CH_DOWN;
		break;
#endif
#ifdef USE_STOP_KEY_SHORT_SCAN
    	case INFO_STOP| KEY_SHORT_UP :
	goto __SCAN_FREQ;
#endif

#ifdef IR_INFO_EQ_DOWN_SCAN
        case INFO_EQ_DOWN| KEY_SHORT_UP :
		if(IR_KEY_Detect){
			IR_KEY_Detect = 0;
			goto __SCAN_FREQ;
		}
		break;
#endif

#ifdef USE_MODE_KEY_LONG_SCAN
    	case INFO_MODE | KEY_LONG :
	goto __SCAN_FREQ;
#endif
#ifdef RADIO_MODE_HOT_KEY_ENABLE	
#ifdef RADIO_MODE_HOT_KEY_LONG_SCAN
    	case INFO_FM_MOD| KEY_LONG :
	goto __SCAN_FREQ;
#endif	
#endif
#ifdef USE_EQ_KEY_SHORT_SCAN
    	case INFO_EQ_UP| KEY_SHORT_UP :
	goto __SCAN_FREQ;
#endif
#ifdef USE_EQ_KEY_SHORT_CH_UP
    case INFO_EQ_UP | KEY_SHORT_UP :
	goto __CH_DOWN;
		break;
#endif
#if 1//def USE_POWER_KEY
#ifdef USE_POWER_KEY_SHORT_SCAN
    	case INFO_POWER | KEY_SHORT_UP :
#ifdef USE_IR_POWER_KEY_TO_POWER_OFF
		if(IR_KEY_Detect){
			IR_KEY_Detect =0;
			goto _HOT_KEY_HDLR;	
		}
#endif		
	goto __SCAN_FREQ;

#endif
#endif  
#if defined(VOL_TUNE_VOL_DEFAULT_TUNE_FREQ_POP)
    	 case INFO_CUS_KEY_1 | KEY_SHORT_UP :

		radio_freq_tune_pop=~radio_freq_tune_pop;
		radio_tune_timer=12;
		
		if(radio_freq_tune_pop){

                     Disp_Con(DISP_FREQ);
		}
		break;
#endif

#ifdef RADIO_MODE_HOT_KEY_ENABLE	

#ifdef RADIO_AM_WM_SEL_IN_ONE_KEY
#ifdef RADIO_AM_WM_ENABLE
    case INFO_FM_MOD | KEY_SHORT_UP:
        if (work_mode == SYS_AMREV){
		Set_Curr_Func(SYS_FMREV);			
	     	FMAM_Mode_Switch_Profile(SYS_FMREV);
	}
	else if(work_mode == SYS_FMREV){
		Set_Curr_Func(SYS_AMREV);			
	     	FMAM_Mode_Switch_Profile(SYS_AMREV);
	}
		break;
#endif		
#endif
#endif		
#if defined(USE_POWER_KEY_FOR_FM_PLAY)
    	 case INFO_POWER | KEY_SHORT_UP :
#if defined(USE_IR_LONG_POWER_KEY_TO_FAKE_POWER_OFF)
		if(IR_KEY_Detect){
			IR_KEY_Detect = 0;
			break;
		}
#endif			
#ifdef USE_IR_POWER_KEY_TO_POWER_OFF
		if(IR_KEY_Detect){
			IR_KEY_Detect = 0;
			break;
		}
#endif
#elif defined(USE_MODE_LONG_FOR_FM_PLAY)
    	 case INFO_MODE| KEY_LONG:
#endif
        case INFO_PLAY | KEY_SHORT_UP :
#if defined(FM_PLAY_KEY_PAUSE)        
#if defined(K722_YJH_722_V001)
		if(IR_KEY_Detect){
			IR_KEY_Detect = 0;
			break;
		}
#endif	
#if defined(IR_PLAY_KEY_SCAN_FREQ_ALL)
		if(IR_KEY_Detect){
			IR_KEY_Detect = 0;
			goto __SCAN_FREQ;
		}
#endif
            play_status = !play_status;

            if (play_status)
            {
		  my_main_vol(my_music_vol);
  		  Mute_Ext_PA(UNMUTE);
#if defined(FM_PAUSE_LED_INDICATOR)
		 set_play_flash(LED_FLASH_ON);
#endif
            }
	     else{
  		Mute_Ext_PA(MUTE);		 	
		my_main_vol(0);	

#if defined(USE_SPECTRUM_PARTTERN)		  		
		set_lcd_flash_lock(LOCK);
#endif

#if defined(FM_PAUSE_LED_INDICATOR)
    		set_play_flash(LED_FLASH_NOR);
#endif		
	     }

#if defined(PAUSE_FLASH_WHOLE_SCREEN)
            if (play_status == MUSIC_PAUSE)
			set_led_flash_tpye(2);
	     else{
			set_led_flash_tpye(0);
	     }
#endif
          Disp_Con(DISP_FREQ);		 
		
	   break;        
#endif	   
		if(IR_KEY_Detect){
			IR_KEY_Detect =0;
#if defined(IR_PLAY_KEY_SCAN_FREQ_DISABLE)
			break;
#elif defined(IR_PLAY_SHORT_CH_UP)
			goto __CH_UP;
#else
			goto __SCAN_FREQ;
#endif
		}
		else{
			
#if defined(ADKEY_PLAY_SHORT_SCAN_FRE_DISABLE)		
		break;
#endif			
		#ifdef ADKEY_PLAY_SHORT_SCAN_FRE
			goto __SCAN_FREQ;	
		#else
			#if defined( ADKEY_NEXT_ADJST_FREQ)
			goto __CH_UP;
			#endif
			#if defined(ADKEY_PLAY_SHORT_ADJ_CH)
			goto __CH_UP;
			#endif
		#endif
		}
            break;
#if defined(K120_YJH_120_V001)||defined(K000_HG_898_V001)||defined(EQ_DOWN_SCAN_ALL)
        case INFO_EQ_DOWN| KEY_SHORT_UP :
#if 1//defined(EQ_DOWN_SCAN_ALL)	
		goto __SCAN_FREQ;
#endif
#ifndef K722_YJH_722_V001		
		goto __FRE_DOWN;
#endif
#endif			
        case INFO_PLAY | KEY_LONG :

		if(IR_KEY_Detect){
			IR_KEY_Detect =0;
#if defined(IR_PLAY_KEY_LONG_SCAN_FREQ)
		goto __SCAN_FREQ;
#else
		break;
#endif
		}
#ifdef USE_LONG_PLAY_KEY_TO_SWITCH_MODE		
		goto _HOT_KEY_HDLR;
#endif

#ifdef AUX_MODE_HOT_KEY_USE_PLAY_LONG		
		goto _HOT_KEY_HDLR;
#endif

#ifdef USE_EQ_KEY_SHORT_SCAN
		break;
#endif
#ifdef ADKEY_PLAY_SHORT_SCAN_FRE
		break;
#endif
__SCAN_FREQ:

#if defined(USE_SPECTRUM_PARTTERN)		  
	     set_lcd_flash_lock(LOCK);
#endif

#ifdef DISP_SCH_AT_FM_SCAN	
            Disp_Con(DISP_SCH);
	     delay_10ms(60);
#endif
            scan_fre();

#if defined(USE_SPECTRUM_PARTTERN)		  
	     set_lcd_flash_lock(UNLOCK);
#endif

	     if(IR_KEY_Detect){
			IR_KEY_Detect =0;
			//break;
	     }			
            //flush_low_msg();
            fre_channl = 1;
            get_channl(fre_channl);
            //Disp_Con(DISP_FREQ);
            break;
#if RTC_ENABLE 
		case INFO_ALM_BELL :				///<闹钟响消息,进入闹钟循环
            		sys_clock_pll();
			dac_out_select(DAC_DECODE);
			if(alm_bell_mode())
			{
				dac_out_select(DAC_AMUX0);
				return;
			}
			dac_out_select(DAC_AMUX0);
			break;
#endif
        case INFO_HALF_SECOND :
			
#if ((USE_DEVICE == MEMORY_STYLE)&&(FAT_MEMORY))          
             updata_fat_memory();
#endif
			
#if defined(AD_MEASURE_TEMP_FUNC)
		adc_diode_temp_measure_hdlr();
#endif
#ifdef DISP_BACKLIGHT_AUTO_SAVE_POWER
	 	Disp_BL_time_out();
#endif

#ifdef USE_USB_HOTPLUG_FUNC
		usb_hotplug_hdlr();
#endif
#ifdef MUTE_EXAMP_AT_FM_NEXT_PREV_IMPROVE
		if(mute_release_timer>0)
			mute_release_timer--;

		 if(mute_release_timer==0){
			my_main_vol(my_music_vol);	
			Mute_Ext_PA(UNMUTE);
		 }
#endif

#if defined(VOL_TUNE_VOL_DEFAULT_TUNE_FREQ_POP)
		if(radio_tune_timer>0){
			radio_tune_timer--;
			
			if(radio_tune_timer==0){
				radio_freq_tune_pop=0;
	                    Disp_Con(DISP_FREQ);
			}

			if(radio_freq_tune_pop){

			      pop_spark=~pop_spark;

			     if(pop_spark){
	                    		Disp_Con(DISP_PWR_OFF);
			     }
			     else{				
	                    		Disp_Con(DISP_FREQ);
			    }
			}
		}
#endif
#ifdef VOL_ADJ_SPARK_LED
		if(vol_adj_spark_bit){
			vol_adj_spark_bit=0;
			restore_led_flash_mod(last_led_play_mod);		
		}
#endif	 
            if (return_cnt < RETURN_TIME)
            {
                return_cnt++;
            }

#if defined(TIME_FORCE_SHOW_ON_SCREEN)

            if (DISP_FREQ == curr_menu){
				
	            if (time_show_return_cnt>RETURN_TIME_SHOW_TIME){
	                    get_curr_date();
	                    Disp_Con(DISP_RTC_POINT);
				break;
		    }	
		     else{
#if defined(MANUAL_SWITCH_TIME_DISPLAY)
	                    Disp_Con(DISP_FREQ);
#else
	                if(DISP_RTC != curr_menu){
				time_show_return_cnt++;
	                }
#endif				
		     }
	     }
#endif
            if (RETURN_TIME == return_cnt)
            {
#ifdef SUPPORT_PT2313
		  clr_aud_effect_state();
#endif			
#if defined(LED_DRV_USE_SM1628)
		led_spark_protect=0;
#endif

                if (DISP_DWORD_NUMBER == curr_menu)
                {
                    goto _PICK_CH;
                }
                else if (DISP_FREQ != curr_menu)
                    Disp_Con(DISP_FREQ);
#if defined(NEW_VOLUME_KEY_FEATURE)||defined(VOL_TUNE_NEW_VOLUME_KEY_FEATURE)
		if(new_vol_feature){
			new_vol_feature =0;
			if(last_disp_menu!=DISP_NULL)			
                     Disp_Con(last_disp_menu);
		}
#endif								
            }
#if defined(USE_BAT_MANAGEMENT)
		bmt_hdlr();
#endif
	     Disp_Update();			
            break;

        case INFO_PICK_FRE | KEY_LONG:
            save_fre(frequency);
            Disp_Con(DISP_FREQ);
            break;

        case INFO_PICK_FRE | KEY_SHORT_UP:
_PICK_CH:
            if (DISP_DWORD_NUMBER != curr_menu)
            {
                break;
            }

            if (( cfilenum <= MAX_FRE) && (cfilenum >= MIN_FRE))
            {

                frequency = cfilenum;
                cfilenum = 0;
                set_fre(frequency, 1);
            }
            else if ((cfilenum) && (cfilenum<=all_channl))
            {
                fre_channl = cfilenum;
                get_channl(fre_channl);
            }
            cfilenum = 0;
            Disp_Con(DISP_FREQ);
            write_info(MEM_FRE,frequency - MIN_FRE);
            break;

#if defined(VOL_TUNE_FREQ_VOL)||defined(VOL_TUNE_FREQ_ONLY)||defined(VOL_TUNE_NEW_VOLUME_KEY_FEATURE)||defined(VOL_TUNE_VOL_DEFAULT_TUNE_FREQ_POP)
        case INFO_PLUS:	
      	     frequency += 2;
            goto __FRE_DOWN;			
			
        case INFO_MINUS:			 
		goto __FRE_DOWN;			
		break;
#endif
        case INFO_NEXT_FIL | KEY_SHORT_UP:

#if defined(NEW_VOLUME_KEY_FEATURE)
		break;
        case INFO_NEXT_FIL :
        case INFO_NEXT_FIL | KEY_HOLD:

		if(new_vol_feature){
			goto _HOT_KEY_HDLR;
		}
#endif				
		if(IR_KEY_Detect){
			IR_KEY_Detect =0;
#if defined(IR_NEXT_PREV_SHORT_ADJ_CH)
			     goto __CH_UP;
#elif defined( IR_NEXT_PREV_DO_NOTHING)
			break;
#elif defined( IR_NEXT_PREV_SHORT_AUTO_SCAN)
			     goto __SCAN_UP;	
#else
 	     	      		frequency += 2;
		            goto __FRE_DOWN;
#endif
		}
		else{
#if defined(K722_YJH_722_V001)
		if(fre_channl==1){
 	     	      		frequency += 2;
		            goto __FRE_DOWN;
		}
		else{
			     goto __CH_UP;
		}
#endif

#if defined( ADKEY_NEXT_ADJST_FREQ)
 	     	      		frequency += 2;
		            goto __FRE_DOWN;
#elif defined(ADKEY_NEXT_PREV_SHORT_AUTO_SCAN)
			     goto __SCAN_UP;	
#else
			     goto __CH_UP;
#endif
		}

	case INFO_PREV_FIL | KEY_SHORT_UP:
		
#if defined(NEW_VOLUME_KEY_FEATURE)
		break;
	case INFO_PREV_FIL :
	case INFO_PREV_FIL | KEY_HOLD:

		if(new_vol_feature){
			goto _HOT_KEY_HDLR;
		}
#endif				
		if(IR_KEY_Detect){
			IR_KEY_Detect =0;
#if defined(IR_NEXT_PREV_SHORT_ADJ_CH)
			     goto __CH_DOWN;
#elif defined( IR_NEXT_PREV_DO_NOTHING)
			break;
#elif defined(IR_NEXT_PREV_SHORT_AUTO_SCAN)
			     goto __SCAN_DOWN;
#else
		            goto __FRE_DOWN;
#endif
		}
		else{
#if defined(K722_YJH_722_V001)
		if(fre_channl==1){
		            goto __FRE_DOWN;
		}
		else{
			     goto __CH_DOWN;
		}
#endif
				
#if defined( ADKEY_NEXT_ADJST_FREQ)
				goto __FRE_DOWN;
#elif defined(ADKEY_NEXT_PREV_SHORT_AUTO_SCAN)
				goto __SCAN_DOWN;		
#else				
				goto __CH_DOWN;
#endif
		}
		
__FRE_DOWN:
            frequency--;
#ifdef MUTE_EXAMP_AT_FM_NEXT_PREV

#ifdef MUTE_EXAMP_AT_FM_NEXT_PREV_IMPROVE
		 if(mute_release_timer==0)
#endif
		{
			Mute_Ext_PA(MUTE);
			my_main_vol(0);		
		}
#endif

#ifdef RADIO_AM_WM_ENABLE			
	    if(work_mode==SYS_FMREV){
			
	            if ( frequency > MAX_FRE)
	            {
	                frequency = MIN_FRE;
	            }
	            else if (frequency < MIN_FRE)
	            {
	                frequency = MAX_FRE;
	            }
	            set_fre(frequency, 1);
	            write_info(MEM_FRE,frequency - MIN_FRE);
	    	}
		else	{

		     if ( frequency > AM_MAX_FRE)
	            {
	                frequency = AM_MIN_FRE;
	            }
	            else if (frequency < AM_MIN_FRE)
	            {
	                frequency = AM_MAX_FRE;
	            }
	            set_fre(frequency, 1);
	            Save_AM_Freq((frequency - AM_MIN_FRE),(AM_FREQ_MAGIC_NUM));
		}
#else
	            if ( frequency > MAX_FRE)
	            {
	                frequency = MIN_FRE;
	            }
	            else if (frequency < MIN_FRE)
	            {
	                frequency = MAX_FRE;
	            }
	            set_fre(frequency, 1);
	            write_info(MEM_FRE,frequency - MIN_FRE);
#endif
            Disp_Con(DISP_FREQ);
#ifdef MUTE_EXAMP_AT_FM_NEXT_PREV
#ifdef MUTE_EXAMP_AT_FM_NEXT_PREV_IMPROVE
		 mute_release_timer=2;
#else
		my_main_vol(my_music_vol);	
		Mute_Ext_PA(UNMUTE);
#endif
#endif

            //delay_ms(20);
            break;

#if defined(USE_MODE_LONG_FOR_FM_CH_UP)
    	 case INFO_MODE| KEY_LONG:
#endif		 	
        case INFO_CH_NEXT | KEY_SHORT_UP:
        case INFO_CH_UP| KEY_SHORT_UP:
	__CH_UP:
			fre_channl += 2;
        case INFO_CH_PREV | KEY_SHORT_UP:
        case INFO_CH_DOWN| KEY_SHORT_UP:
	__CH_DOWN:
            fre_channl--;
            if (fre_channl > all_channl)
            {
                fre_channl = 1;
            }
            else if (!fre_channl)
            {
                fre_channl = all_channl;
            }
            get_channl(fre_channl);
            Disp_Con(DISP_FREQ);
            flush_low_msg();
			
            break;

#ifdef SEMI_AUTO_SCAN_FREQ

#if defined(K722_YJH_722_V001)
        case INFO_PLAY_MODE | KEY_SHORT_UP:
		frequency += 2;
		goto __FRE_DOWN;					
#endif		
        case INFO_CH_UP| KEY_HOLD:

        case INFO_NEXT_FIL | KEY_HOLD:
	 if(IR_KEY_Detect){
		IR_KEY_Detect =0;
#if defined(IR_NEXT_PREV_HOLD_AUTO_SCAN)

#elif defined(IR_NEXT_PREV_KEY_HOLD_DO_NOTHING)
	break;
#else
	break;
#endif
		
	 }
	 else{
#if defined(ADKEY_NEXT_PREV_HOLD_AUTO_SCAN)
	//goto __SCAN_UP;
#elif defined(ADKEY_NEXT_PREV_HOLD_FREQ_ADJ)
      		frequency += 2;
		goto __FRE_DOWN;			
#elif defined(ADKEY_NEXT_PREV_HOLD_CH_SEL)
	goto __CH_UP;
#else
	goto _HOT_KEY_HDLR;
#endif
        }
        case INFO_PLUS | KEY_SHORT_UP:
#if defined(INDEPENDENT_KEY_TUNE_FREQ)
	frequency += 2;
	goto __FRE_DOWN;
#endif
        case INFO_PLUS | KEY_HOLD:
 #if defined(INDEPENDENT_KEY_FAST_TUNE_FREQ)			
 	frequency += 2;
	goto __FRE_DOWN;
#endif

__SCAN_UP:			
		auto_scan(SEARCH_UP);
            break;
#if defined(K722_YJH_722_V001)
        case INFO_EQ_UP | KEY_SHORT_UP:
		goto __FRE_DOWN;			
#endif
        case INFO_CH_DOWN| KEY_HOLD:
        case INFO_PREV_FIL | KEY_HOLD:

	 if(IR_KEY_Detect){
		IR_KEY_Detect =0;
#if defined(IR_NEXT_PREV_HOLD_AUTO_SCAN)

#elif defined(IR_NEXT_PREV_KEY_HOLD_DO_NOTHING)
	break;
#else
	break;
#endif	
	 }
	 else{
 	
#if defined(ADKEY_NEXT_PREV_HOLD_AUTO_SCAN)
	//goto __SCAN_DOWN;
#elif defined(ADKEY_NEXT_PREV_HOLD_FREQ_ADJ)
		goto __FRE_DOWN;			
#elif defined(ADKEY_NEXT_PREV_HOLD_CH_SEL)
	goto __CH_DOWN;
#else
	goto _HOT_KEY_HDLR;
#endif
        }
        case INFO_MINUS|KEY_SHORT_UP:			 

#if defined(INDEPENDENT_KEY_TUNE_FREQ)			
	goto __FRE_DOWN;
#endif

        case INFO_MINUS| KEY_HOLD:
#if defined(INDEPENDENT_KEY_FAST_TUNE_FREQ)			
	goto __FRE_DOWN;
#endif
			
__SCAN_DOWN:			
		auto_scan(SEARCH_DN);			
            break;
#endif

        default :
_HOT_KEY_HDLR:			
            if (!ap_handle_hotkey(key))
                return;
        }
    }
}
void main(void)
{

    amp_mute(1);
    clock_in = T0CNT;									//输入时钟,define in clock.h

    sys_init();
    power_key_hdlr(SYS_PWR_ON);
    AMUX_P2IE_SET(AMUX0_IE&AMUX1_IE);
    sys_info_init();
    clear_all_event();
    flush_all_msg();
	
    enter_fm_rev();

    PT2313_Init();
	
    work_mode=RTC_MODE;
#ifdef IR_DEBUG
	IR_Debug_func();
#endif

    while (1)
    {
        switch (work_mode)
        {
        case MUSIC_MODE:
            music_decode();
            break;
#if USB_DEVICE_ENABLE
        case USB_DEVICE_MODE:
            usb_audio_massstorage();
            break;
#endif     

#if 1//FM_MODULE                     
        case FM_RADIO_MODE:
            fm_radio();
            break;
#endif

        case AUX_MODE:
            aux_fun();
            break;

#if 1//RTC_ENABLE
        case RTC_MODE:
            rtc_fun();
            break;        
#endif
        case REC_MIC_MODE:
            rec_mic_fun();
            break;			
        case IDLE_MODE:
	     //power_key_hdlr(SYS_PWR_OFF);
            break;			

	     default:
            	work_mode = MUSIC_MODE;
            break;
        }
        write_info(MEM_SYSMODE ,work_mode);
    }
    //*/
}
Beispiel #30
0
/*----------------------------------------------------------------------------*/
void main(void)
{
     xd_u8 sys_timer=0;

      sys_power_up();
      Mute_Ext_PA(MUTE);
      sys_clock_pll();//(MAIN_CLK_PLL);
	 
#ifdef PWR_CTRL_IN_IDLE_MODE

#if defined(PWR_CTRL_WKUP)
	wkup_pin_ctrl(0);
#else
	PWR_CTRL_GPIO_INIT();
	PWR_CTRL_DIS();
#endif

#endif

#ifdef ALARM_USE_MULTI_SOURCE_FUNC
	alarm_power_on_protect=0;
#endif
#ifdef ADKEY_SELECT_MODE
   	mode_switch_protect_bit=1;
#endif
#ifdef USE_POWER_KEY
	//waiting_power_key();
      sys_power_up();	
#endif	
	//Disp_Con(DISP_HELLO);
	sys_init();
    	sys_info_init();
	Init_Func_List();
	flush_all_msg();
#if FILE_ENCRYPTION
    	password_init(0xaa);  //输入加密文件的密码
#endif  

#ifdef ADKEY_DEBUG
	AD_Debug_func();
#endif
#if 0
	while(1){
		keyScan();
		delay_10ms(1);
		sys_timer = get_msg();
#if 1
	if(sys_timer!= 0xff){

	    	printf("------->-get_msg   %x \r\n",(u16)sys_timer);
	}
#endif

	}
#endif	
#ifdef SYS_POWER_ON_DEFAULT_IN_RADIO
	Set_Curr_Func(SYS_FMREV);
#elif defined(SYS_POWER_ON_DEFAULT_IN_CD)
	Set_Curr_Func(SYS_MCU_CD);
#endif
       if((work_mode==SYS_MP3DECODE_USB)||(work_mode==SYS_MP3DECODE_SD)){

		Set_Curr_Func(SYS_FMREV);
	}
	radio_force_preset=6;
#ifdef UART_ENABLE
    	printf("------->- SYS INIT   work_mode:%d   \r\n",(u16)work_mode);
#endif
	while (1)
       {
		Set_Curr_Func(work_mode);
        	switch (work_mode)
	       {
#ifdef USE_USB_SD_DECODE_FUNC	       
	 		case SYS_MP3DECODE_USB:
	 		case SYS_MP3DECODE_SD:	 
	 			decode_play();
	            	break;
#endif					
#ifdef USE_CD_MCU_MASTER_FUNC
		    	case SYS_MCU_CD:
#ifdef UART_ENABLE
			sys_printf(" SYS_MCU_CD");
#endif
					
				mcu_main_hdlr();
			break;
#endif			
#ifdef USE_RADIO_FUNC
	        	case SYS_FMREV:
#ifdef AM_RADIO_FUNC
	        	case SYS_AMREV:
#endif			

#ifdef UART_ENABLE
			sys_printf(" SYS_RADIO_FUNC");
#endif

	            		fm_radio();
	            	break;
#endif					
#ifdef USE_AUX_FUNC			
	        	case SYS_AUX:

#ifdef UART_ENABLE
			sys_printf(" SYS_AUX");
#endif
					
	            		aux_function();
	            	break;
#endif			

#ifdef USE_BLUE_TOOTH_FUNC			
    	        	case SYS_BLUE_TOOTH:

#ifdef UART_ENABLE
			sys_printf(" SYS_BLUE_TOOTH");
#endif
						
	            		Blue_tooth_main();
	            	break;
#endif

#ifdef USE_RTC_FUNC
	        	case SYS_RTC:
	            		rtc_function();
	            	break;
#endif
#ifdef USE_SYS_IDEL_FUNC
	        	case SYS_IDLE:
		            idle_mode();
#ifdef ADKEY_SELECT_MODE				
		   	     mode_switch_protect_bit=1;			
#endif
		   	     sys_restore_mode();
			     dac_mute_control(0,1);
			     flush_all_msg();	
			     my_music_vol = 26;
			     set_max_vol(MAX_ANALOG_VOL, MAX_DIGITAL_VOL);
			     set_sys_vol(my_music_vol);
		     	break;
#endif			 
	        	default:

#ifdef USE_USB_SD_DECODE_FUNC	               	
	            		//work_mode = SYS_MP3DECODE_USB;
#else
	            		//work_mode = SYS_MCU_CD;
#endif
			Set_Curr_Func(SYS_FMREV);

	            	break;
	        }
#ifdef USE_SYS_MODE_RECOVER
	if(work_mode !=SYS_IDLE){
              write_info(MEM_SYSMODE,work_mode);
    	}
#endif	
			
    }

}