Esempio n. 1
0
////////////////////////////////////////////////////////////////
// FunSig
void FunSig::display( int indent, std::ostream& os )
{
	os << "<FunSig " << name->source->s;
	if( name->fresh ) { os << "~" << name->fresh->s; }
	os << " = ( " << dsp( 0, fargs ) << " ): "
	   << dsp( 0, result_type ) << ">" << hdr( h );
}
Esempio n. 2
0
void sh(unsigned char a)
{
char x;
x=a>>4;
dsp(x);
dsp(a&0xf);
}
Esempio n. 3
0
/* initialize P2P discovery */
int bcm_p2p_discovery_initialize(void)
{
	bcm_p2p_discovery_req_t req;

	WL_TRACE(("bcm_p2p_discovery_initialize\n"));

	/* attach handler to dispatcher */
	dspSubscribe(dsp(), 0, bcm_p2p_discovery_process_wlan_event);

	req.handler = initialize_handler;
	return dspRequestSynch(dsp(), 0, sizeof(req), (uint8 *)&req, 0);
}
//performs the business logic on the measurements in order to 
//display them on the LCD screen.
void display_measurement(INT16U measure, INT8U line)
{
INT16U savemeasure;
	measure /= 20;
	savemeasure = measure;
	measure /= 1000;
	measure %= 10;
	measure += 0x30;
	dsp(2,line,9);
	dsp(0,measure,0);
	
	measure = savemeasure;
	measure /= 100;
	measure %= 10;
	measure += 0x30;
	dsp(2,line,10);
	dsp(0,measure,0);
	
	measure = savemeasure;
	measure /= 10;
	measure %= 10;
	measure += 0x30;
	dsp(2,line,12);
	dsp(0,measure,0);
	
	measure = savemeasure;
	measure /= 1;
	measure %= 10;
	measure += 0x30;
	dsp(2,line,13);
	dsp(0,measure,0);
}
Esempio n. 5
0
    void writeScalar(H5File &file, string DSitem, Scalar value){
	hsize_t dim[0];
	DataSpace dsp(0, dim);
	PredType type = getPredType<Scalar>();
	DataSet item = file.createDataSet(DSitem, type, dsp);
	item.write(&value, type);
    }
Esempio n. 6
0
int main(int argc, char *argv[]) {
  int samplerate = 44100;
  int nsamples = samplerate * 240;
  int bytesize = nsamples * 2;

  fprintf(stdout, "RIFF");
  fputi(bytesize + 36, 4, stdout); // ChunkSize
  fprintf(stdout, "WAVE");

  fprintf(stdout, "fmt ");
  fputi(16, 4, stdout); // SubChunkSize
  fputi(1, 2, stdout); // AudioFormat
  fputi(1, 2, stdout); // NumChannels
  fputi(samplerate, 4, stdout); // SampleRate
  fputi(samplerate * 2, 4, stdout); // ByteRate
  fputi(2, 2, stdout); // BlockAlign
  fputi(16, 2, stdout); // BitsPerSample

  fprintf(stdout, "data");
  fputi(bytesize, 4, stdout);

  int maxAmplitude = 0;

  for (int tn = 0; tn < nsamples; tn++) {
    int sample = (int) (32767 * dsp(tn));
    int asample = abs(sample);
    if (asample > maxAmplitude) maxAmplitude = asample;
    fputi(sample, 2, stdout);
  }
  fprintf(stderr, "%d", maxAmplitude);
  return 0;
}
// LCD Display String
void LCDprint(INT8U *sptr)
{
    while( *sptr ){
        dsp(0,*sptr,0);
        ++sptr;
		}
}
Esempio n. 8
0
void display_list( int indent, std::ostream& os, const T& v )
{
	for( typename T::const_iterator i = v.begin() ; i != v.end() ; ++i ) {
		os << std::endl;
		os << idt(indent) << dsp( indent, (*i) );
	}
}
Esempio n. 9
0
//----------------------------------------------------------------------------------------------------------------------
// methode : pour debug
void Tracer::printBufferCmd(){
    dsp(F("Contenu du buffer de commandes :")); dspl( _nbrCommandes );
    for (int i = 0; i< _nbrCommandes; i++){
        sp( F("cmd : ") );sp( _bufferCommandes[i][0] );
        sp( F(", ") );spl(_bufferCommandes[i][1]);
    }
}
//initializes hardware
void initialize_hardware(void)
{
	dsp(99,0,0);
	kp(1);
	TMSK2 = TMSK2 & 0xFC;  //set clock to 2MHz - .5 us period
	TCTL2 = 0x10;  			//set to read rising edge
	TFLG1 = 0x04;				//
}
Esempio n. 11
0
 void dsp(cell * root,vector<string> pre){
     if(root == NULL){
         result.push_back(pre);
         return;
     }
     pre.push_back(root->s);
     for(int i = 0 ; i < root->father.size(); ++i){
         dsp(root->father[i],pre);
     }
 }
Esempio n. 12
0
// DEBUG
void
Body_ext_1part::dump()
{
    cout << "+----------------+----------------" << endl
         << "|         body-ext-1part          " << endl
         << "+----------------+----------------" << endl
         << "| body_fld_md5   |" + md5()		     << endl
         << "| body_fld_dsp   |" + dsp()		     << endl
         << "| body_fld_lang  |" + lang()	     << endl
         << "| body_fld_loc   |" + loc()		     << endl
         << "| body_extension |" + extension()	 << endl;
}
Esempio n. 13
0
bool CWidcommHandler::DoDiscoverWMouseXPThroughDeviceList()
{
			if(iCurDevice < iFoundDevices.GetSize())
			{
				iDiscoveringGUID.Data1 = 0x2bc2b92e;
				iDiscoveringGUID.Data2 = 0x3992;
				iDiscoveringGUID.Data3 = 0x11dc;
				iDiscoveringGUID.Data4[0] = 0x83;
				iDiscoveringGUID.Data4[1] = 0x14;
				iDiscoveringGUID.Data4[2] = 0x08;
				iDiscoveringGUID.Data4[3] = 0x00;
				iDiscoveringGUID.Data4[4] = 0x20;
				iDiscoveringGUID.Data4[5] = 0x0c;
				iDiscoveringGUID.Data4[6] = 0x9a;			
				iDiscoveringGUID.Data4[7] = 0x66;			


				CString dsp("Discovering services on ");

				CWidcommFoundDevice* dev = (CWidcommFoundDevice*) iFoundDevices.GetAt(iCurDevice);
				
				dsp += dev->iName;

				iLabel->SetWindowText(dsp);

				CopyBDADDR(dev->iAddr,iDiscoveringDevice);

				iDiscoverCommandSent = true;

				Sleep(3000);	// L2CAP needs at least 1 sec to clear previous discovery connection
				
				if(	StartDiscovery(dev->iAddr, &iDiscoveringGUID) )
					/*Sleep(2000)*/;
				else
				{
					if(CWMouseXPDlg::curInstance && !(CWMouseXPDlg::curInstance->iAutoConnectCommand))							
						MessageBox(iHwnd,"General discovery fault: Try again soon.","Discovey Fault",MB_OK | MB_ICONASTERISK);

					RevertToIdle(); //add hwnd, icon movement, icon animation rsc numbers, etc...
					return false;	
				}

				
				iCurDevice++;

				return true;
				

			}
			else
				return false;
}
Esempio n. 14
0
int main ()
{
	// Disable the ADC
	disable_adc();

	// Watchdog timer reset safety check
	wdt_reset_safety();
	
	// Initialise watchdog timer
	init_wdt();

	// Identify input and output pins
	init_pins();

	// Buffer for text
	char s[20];

	// Setup direction and port for debug logging
	STX_PORT |= 1<<STX_BIT;
	STX_DDR |= 1<<STX_BIT;

	// Initialise DSP
	int i = 0;
	for (; i < MAX_READINGS; i++) readings[i] = 0;

	for (;;)
	{
		// Go to sleep
		sleep_avr();
		
		// Read VCC and convert to base 10 number
		long vcc = read_vcc();

		dsp(vcc);
		utoa(average, s, 10);

		// Output VCC to soft serial PIN STX_BIT
		sputs(s);
		sputs("\n\r");

		if (average > FULL_CHARGE_MV)
		{
			init_wdt_05s();
			blink();
		}
		else init_wdt();	
	}
}
Esempio n. 15
0
void CGppe::Make_Predictions_New_User(const VectorXd & theta_x, const VectorXd& theta_t, double& sigma, const MatrixXd& train_t, const MatrixXd &x, const TypePair & train_pairs,
                                     const VectorXd & idx_global, const VectorXd& idx_global_1, const VectorXd& idx_global_2,
                                     const VectorXd& ind_t, const VectorXd& ind_x, const MatrixXd & test_t, const MatrixXd& idx_pairs, const VectorXd& ftrue, const VectorXd& ytrue)
{
    int N = x.rows();
    int Mtrain = train_t.rows();
    int Npairs = idx_pairs.rows();
    VectorXd fstar;
    MatrixXd pair;
    VectorXd P = VectorXd::Zero(Npairs);
    VectorXd ypred = VectorXd::Zero(Npairs);
    VectorXd sum = VectorXd::Zero(N);
    VectorXd count = VectorXd::Zero(N);

    Approx_CGppe_Laplace( theta_x, theta_t, sigma,
                         train_t, x, train_pairs, idx_global, idx_global_1, idx_global_2, ind_t, ind_x, Mtrain, N);

    for (int i = 0;i < Npairs;i++)
    {
        pair = idx_pairs.row(i);


        Predict_CGppe_Laplace(sigma, train_t, x, idx_global, ind_t, ind_x,
                             test_t, pair);
        P(i) = p;
        sum(pair(0)) += mustar(0);
        count(pair(0)) += 1;
        sum(pair(1)) += mustar(1);
        count(pair(1)) += 1;

    }

    for (int i = 0;i < P.rows();i++)
    {
        if (P(i) > 0.5000001)
            ypred(i) = 1;
        else
        	ypred(i)=0;
    }

    fstar = sum.array() / count.array();
	dsp(fstar,"fstar");
    cout << endl << endl << "error =  " << (GetDiff(ytrue, ypred)).sum() / ytrue.rows()<<endl;
    // need for a plot function here ?
}
Esempio n. 16
0
void cc_dsp(t_cc *x, t_signal **sp, short *count){
	long (*dsp)(t_object *, char *, short *);
	hashtab_lookup(x->ht, gensym("my_dsp"), (t_object **)&dsp);
	if(dsp){
		x->user_perform = (ccperform_method)dsp((t_object *)x, x->user_obj, count);
	}

	x->blksize = sp[0]->s_n;
	x->sr = sp[0]->s_sr;
	int i;
	for(i = 0; i < x->nsiginlets; i++){
		x->svin[i] = sp[i]->s_vec;
	}
	for(i = 0; i < x->nsigoutlets; i++){
		x->svout[i] = sp[i + x->nsiginlets]->s_vec;
	}
	dsp_add(cc_perform, 1, x);
}
Esempio n. 17
0
/* start P2P discovery */
int bcm_p2p_discovery_start_discovery(bcm_p2p_discovery_t *disc)
{
	bcm_p2p_discovery_req_t req;

	WL_TRACE(("bcm_p2p_discovery_start_discovery\n"));

	if (disc == 0) {
		WL_ERROR(("invalid parameter\n"));
		return 0;
	}

	req.handler = start_discovery_handler;
#ifdef BCM_P2P_DISCOVERY_NO_DISPATCHER
	start_discovery_handler(disc, sizeof(req), &req, 0);
	return 1;
#else
	return dspRequest(dsp(), disc, sizeof(req), (uint8 *)&req);
#endif /* BCM_P2P_DISCOVERY_NO_DISPATCHER */
}
Esempio n. 18
0
void AnimationEditor::settings() {
    QDialog* dialog = new QDialog(this);
    dialog->setWindowTitle(tr("Animation Settings"));
    QVBoxLayout* lay = new QVBoxLayout(dialog);
    QHBoxLayout* buttonLayout = new QHBoxLayout();

    QGroupBox* durationBox = new QGroupBox(dialog);
    durationBox->setTitle("Duration (seconds)");
    QHBoxLayout* durationLayout = new QHBoxLayout(durationBox);
    QSpinBox dsp(dialog);
    dsp.setMinimum(1);
    dsp.setMaximum(200000);
    dsp.setValue(static_cast<int>(duration_/ 30.0f));
    durationLayout->addWidget(&dsp);
    QPushButton ok("Ok", dialog);
    QPushButton cancel("Cancel", dialog);
    connect (&ok, SIGNAL(clicked()), dialog, SLOT(accept()));
    connect (&cancel, SIGNAL(clicked()), dialog, SLOT(reject()));

    QLabel* tsLabel = new QLabel("Time Stretch Factor:");
    QHBoxLayout* timeStretchLayout = new QHBoxLayout();
    DoubleSliderSpinBoxWidget* timeStretchSlider = new DoubleSliderSpinBoxWidget(this);
    timeStretchSlider->setMaxValue(5);
    timeStretchSlider->setSingleStep(0.1f);
    timeStretchSlider->setValue(1.0f);
    timeStretchSlider->setMaximumWidth(100);
    connect(timeStretchSlider, SIGNAL(valueChanged(double)), this, SLOT(timeStretchChanged(double)));
    timeStretchLayout->addWidget(tsLabel);
    timeStretchLayout->addWidget(timeStretchSlider);
    timeStretchLayout->addStretch();
    lay->addLayout(timeStretchLayout);

    buttonLayout->addWidget(&ok);
    buttonLayout->addWidget(&cancel);

    lay->addWidget(durationBox);
    lay->addLayout(buttonLayout);
    if (dialog->exec() == QDialog::Accepted)
        setDuration(static_cast<int>(dsp.value()* 30.0f));
}
Esempio n. 19
0
/* create P2P discovery */
bcm_p2p_discovery_t *bcm_p2p_discovery_create(
	struct bcm_p2p_discovery_wl_drv_hdl *drv, uint16 listenChannel)
{
	bcm_p2p_discovery_req_t req;
	create_rsp_t rsp;

	WL_TRACE(("bcm_p2p_discovery_create\n"));

	req.handler = create_handler;
	req.create.drv = drv;
	req.create.listenChannel = listenChannel;
#ifdef BCM_P2P_DISCOVERY_NO_DISPATCHER
	create_handler(0, sizeof(req), &req, &rsp);
#else
	if (!dspRequestSynch(dsp(), 0, sizeof(req), (uint8 *)&req, (uint8 *)&rsp))
	{
		return 0;
	}
#endif /* BCM_P2P_DISCOVERY_NO_DISPATCHER */

	return rsp.disc;
}
Esempio n. 20
0
/* start P2P extended listen */
int bcm_p2p_discovery_start_ext_listen(bcm_p2p_discovery_t *disc,
	uint16 listenOnTimeout, uint16 listenOffTimeout)
{
	bcm_p2p_discovery_req_t req;

	WL_TRACE(("bcm_p2p_discovery_start_ext_listen\n"));

	if (disc == 0) {
		WL_ERROR(("invalid parameter\n"));
		return 0;
	}

	req.handler = start_ext_listen_handler;
	req.startExtListen.listenOnTimeout = listenOnTimeout;
	req.startExtListen.listenOffTimeout = listenOffTimeout;
#ifdef BCM_P2P_DISCOVERY_NO_DISPATCHER
	start_ext_listen_handler(disc, sizeof(req), &req, 0);
	return 1;
#else
	return dspRequest(dsp(), disc, sizeof(req), (uint8 *)&req);
#endif /* BCM_P2P_DISCOVERY_NO_DISPATCHER */
}
Esempio n. 21
0
////////////////////////////////////////////////////////////////
// FunCall
void FunCall::display( int indent, std::ostream& os )
{
	os << func->source->s << "( " << dsp( 0, aargs ) << " )";
}
Esempio n. 22
0
////////////////////////////////////////////////////////////////
// Parenthized
void Parenthized::display( int indent, std::ostream& os )
{
	os << "<Parenthized " << dsp( 0, exprs ) << " >" << hdr( h );
}
Esempio n. 23
0
////////////////////////////////////////////////////////////////
// IfThenElse
void IfThenElse::display( int indent, std::ostream& os )
{
	os << "<IfThenElse " << dsp( 0, cond ) << ">" << hdr( h ) << std::endl;
	iftrue->display( indent+1, os ); os << std::endl;
	iffalse->display( indent+1, os );
}
Esempio n. 24
0
////////////////////////////////////////////////////////////////
// VarDeclIdentifier
void VarDeclIdentifier::display( int indent, std::ostream& os )
{
	os << name->source->s;
	if( name->fresh ) { os << "~" << name->fresh->s; }
	if( t ) { os << ": " << dsp( 0, t ); }
}
Esempio n. 25
0
////////////////////////////////////////////////////////////////
// VarDecl
void VarDecl::display( int indent, std::ostream& os )
{
	os << "<Var " << dsp( 0, varelems )
	   << " = " << dsp( 0, data ) << ">" << hdr( h );
}
Esempio n. 26
0
////////////////////////////////////////////////////////////////
// FormalArg
void FormalArg::display( int, std::ostream& os )
{
	os << name->source->s << ": " << dsp( 0, t );
}
Esempio n. 27
0
////////////////////////////////////////////////////////////////
// Member
void Member::display( int indent, std::ostream& os )
{
	os << idt(indent) << dsp( 0, farg ) << hdr( h );
}
Esempio n. 28
0
////////////////////////////////////////////////////////////////
// FunDef
void FunDef::display( int indent, std::ostream& os )
{
	os << "<FunDef>" << hdr( h ) << std::endl;
	os << idt(indent+1) << dsp( indent+1, sig ) << std::endl;
	body->display( indent+1, os );
}
void YSE::CHANNEL::implementationObject::run() {
  dsp();
}
Esempio n. 30
0
 vector<vector<string>> findLadders(string start, string end, unordered_set<string> &dict) {
     int min = 2;
     vector<cell*> graph;
     vector<unordered_map<string,cell *>> levelmap;
     unordered_set<string> adj;
     vector<int> levelstart(1,0);
     int currentlevel = 1;
     for(int i = 0 ; i < start.size() ; ++i){
         string tt = start;
         for(char c = 'a' ; c <= 'z' ; ++c){
             tt[i] = c;
             adj.insert(tt);
         }
     }
     if(dict.count(start)>0) dict.erase(start);
     if(dict.count(end)>0) dict.erase(end);
     graph.push_back(new cell(end,1,-1,vector<cell *>(1)));
     unordered_map<string,cell *> dd;
     dd[end] = graph[0];
     levelmap.push_back(dd);
     int j = 0;
     bool flag = true;
     while(j<graph.size()&&flag){
         cell *str = graph[j++];
         string t = str->s;
         for(int i = 0 ; i < t.size()&&flag ; ++i){
             if(i == str->mask) continue;
             for(char c = 'a' ; c <= 'z' ; ++c){
                 if(c == t[i]) continue;
                 string s = t;
                 s[i] = c;
                 if(s == start){
                     min = str->level+1;
                     flag = false;
                     break;
                 }
                 if(dict.find(s)!=dict.end()){
                     graph.push_back(new cell(s,str->level+1,i,vector<cell *>(1,str)));
                     dict.erase(s);
                     if(currentlevel==str->level){
                         ++currentlevel;
                         levelstart.push_back(graph.size()-1);
                         unordered_map<string,cell *> ff;
                         ff[s] = graph.back();
                         levelmap.push_back(ff);
                     }
                     else{
                         unordered_map<string,cell *> ff = levelmap[currentlevel-1];
                         ff[s] = graph.back();
                         levelmap[currentlevel-1] = ff;
                     }
                 }
                 else if(str->level+1==currentlevel&&levelmap[currentlevel-1].count(s)>0){
                     levelmap[currentlevel-1][s]->father.push_back(str);
                 }
             }
         }
     }
     int endlevel;
     if(levelstart.size()>min-1) endlevel = levelstart[min-1];
     else endlevel = graph.size();
     for(int i = levelstart[min-2] ; i < endlevel; ++i){
         if(adj.count(graph[i]->s)>0){
             dsp(graph[i],vector<string>(1,start));
         }
     }
     return result;
 }