Exemplo n.º 1
0
/*
    MAINLINE
*/
int main(int argc, const char *argv[]){
  printf("MakeTreeSpawn - Gareth Bradshaw Feb 2003\n");

  /*
     parse command line
  */
  decodeIntParam(argc, argv, intParams);
  decodeBoolParam(argc, argv, boolParams);
  printf("Options : \n");
  writeParam(stdout, intParams);
  writeParam(stdout, boolParams);

  /*
     look for filenames and construct trees
  */
  int numFiles = 0;
  for (int i = 1; i < argc; i++){
    if (argv[i] != NULL){
      constructTree(argv[i], yaml);
      numFiles++;
      }
    }

  /*
     check we had a file name
  */
  if (numFiles == 0)
    error("no files given :(");

  waitForKey();
}
Exemplo n.º 2
0
// Write VIS Mode
void Adafruit_SI1145::writeVisSen(boolean high)
{
	if (high)
	{
		writeParam(SI1145_PARAM_ALSIRADCMISC, 0x00);
	} else {
		writeParam(SI1145_PARAM_ALSIRADCMISC, SI1145_PARAM_ALSIRADCMISC_RANGE);
	}
}
Exemplo n.º 3
0
void imageGLWidget::setYTParam(int value)
{
    //value is 0 to 1000, map onto range 0.25,0.35
    yTParam=0.0001*(value+2500);
    functionParam.coordinate[1].x = yTParam;
    emit writeParam((char *)&functionParam);
    
}
Exemplo n.º 4
0
void imageGLWidget::setZTParam(int value)
{
    //value is 0 to 1000, map onto range 0.2,0.3
    zTParam=0.0001*(value+2000);
    functionParam.coordinate[2].x = zTParam;
    emit writeParam((char *)&functionParam);
    
}
Exemplo n.º 5
0
void imageGLWidget::setPParam(int value)
{
    //value is 0 to 1000, map onto range 0.25,0.75
    PParam=0.0005*(value+500);
    functionParam.coordinate[3].x = PParam;
    emit writeParam((char *)&functionParam);
    
}
Exemplo n.º 6
0
void imageGLWidget::setXTParam(int value)
{
    //value is 0 to 1000, map onto range 0.45,0.55
    xTParam=0.0001*(value+4500);
    functionParam.coordinate[0].x = xTParam;
    emit writeParam((char *)&functionParam);
    
}
Exemplo n.º 7
0
xml::Element& operator<<(xml::Element& elemFields, const Field& field)
{
    if (field.name.size() != 0 && field.dataType.name != "void") {
        xml::Element& elemField = elemFields.createElement("field", "");
        writeParam(elemFields, elemField, field);
    }

    return elemFields;
}
Exemplo n.º 8
0
xml::Element& operator<<(xml::Element& elemParams, const Param& param)
{
    if (param.name.size() != 0 && param.dataType.name != "void") {
        xml::Element& elemParam = elemParams.createElement("param", "");
        writeParam(elemParams, elemParam, param);
    }

    return elemParams;
}
Exemplo n.º 9
0
void PulsePlug::initSensor()
{
    PulsePlug::setReg(PulsePlug::HW_KEY, 0x17);
    // pulsePlug.setReg(PulsePlug::COMMAND, PulsePlug::RESET_Cmd);
    //
    setReg(PulsePlug::INT_CFG, 0x03);       // turn on interrupts
    setReg(PulsePlug::IRQ_ENABLE, 0x10);    // turn on interrupt on PS3
    setReg(PulsePlug::IRQ_MODE2, 0x01);     // interrupt on ps3 measurement
    setReg(PulsePlug::MEAS_RATE, 0x84);     // 10ms measurement rate
    setReg(PulsePlug::ALS_RATE, 0x08);      // ALS 1:1 with MEAS
    setReg(PulsePlug::PS_RATE, 0x08);       // PS 1:1 with MEAS

    // Current setting for LEDs pulsed while taking readings
    // PS_LED21  Setting for LEDs 1 & 2. LED 2 is high nibble
    // each LED has 16 possible (0-F in hex) possible settings
    // see the SI114x datasheet.

    // These settings should really be automated with feedback from output
    // On my todo list but your patch is appreciated :)
    // support at moderndevice dot com.
    setReg(PulsePlug::PS_LED21, 0x39);      // LED current for 2 (IR1 - high nibble) & LEDs 1 (red - low nibble)
    setReg(PulsePlug::PS_LED3, 0x02);       // LED current for LED 3 (IR2)

    writeParam(PulsePlug::PARAM_CH_LIST, 0x77);         // all measurements on

    // increasing PARAM_PS_ADC_GAIN will increase the LED on time and ADC window
    // you will see increase in brightness of visible LED's, ADC output, & noise
    // datasheet warns not to go beyond 4 because chip or LEDs may be damaged
    writeParam(PulsePlug::PARAM_PS_ADC_GAIN, 0x00);

    // You can select which LEDs are energized for each reading.
    // The settings below (in the comments)
    // turn on only the LED that "normally" would be read
    // ie LED1 is pulsed and read first, then LED2 & LED3.
    writeParam(PulsePlug::PARAM_PSLED12_SELECT, 0x21);  // 21 select LEDs 2 & 1 (red) only
    writeParam(PulsePlug::PARAM_PSLED3_SELECT, 0x04);   // 4 = LED 3 only

    // Sensors for reading the three LEDs
    // 0x03: Large IR Photodiode
    // 0x02: Visible Photodiode - cannot be read with LEDs on - just for ambient measurement
    // 0x00: Small IR Photodiode
    writeParam(PulsePlug::PARAM_PS1_ADCMUX, 0x03);      // PS1 photodiode select
    writeParam(PulsePlug::PARAM_PS2_ADCMUX, 0x03);      // PS2 photodiode select
    writeParam(PulsePlug::PARAM_PS3_ADCMUX, 0x03);      // PS3 photodiode select 


    writeParam(PulsePlug::PARAM_PS_ADC_COUNTER, B01110000);    // B01110000 is default
    setReg(PulsePlug::COMMAND, PulsePlug::PSALS_AUTO_Cmd);     // starts an autonomous read loop
}
Exemplo n.º 10
0
boolean FOXFIRE_Si1132::begin(void)
{
	//Initialize the I2C bus if not already enabled
	if (!Wire.isEnabled()) {
		Wire.begin();
	}
	reset();

	// enable UVindex measurement coefficients!
	//write8(Si1132_REG_UCOEF0, 0x29);
	//write8(Si1132_REG_UCOEF1, 0x89);
	//write8(Si1132_REG_UCOEF2, 0x02);
	//write8(Si1132_REG_UCOEF3, 0x00);
	write8(Si1132_REG_UCOEF0, 0x7B);
	write8(Si1132_REG_UCOEF1, 0x6B);
	write8(Si1132_REG_UCOEF2, 0x01);
	write8(Si1132_REG_UCOEF3, 0x00);

	// enable UV, IR and Visible light sensors
	writeParam(Si1132_PARAM_CHLIST, Si1132_PARAM_CHLIST_ENUV | Si1132_PARAM_CHLIST_ENALSIR | Si1132_PARAM_CHLIST_ENALSVIS);

	write8(Si1132_REG_INTCFG, Si1132_REG_INTCFG_INTOE);
	write8(Si1132_REG_IRQEN, Si1132_REG_IRQEN_ALSEVERYSAMPLE);

  	writeParam(Si1132_PARAM_ALSIRADCMUX, Si1132_PARAM_ADCMUX_SMALLIR);  
	// fastest clocks, clock div 1
  	writeParam(Si1132_PARAM_ALSIRADCGAIN, 0x00);
	// take 511 clocks to measure
  	writeParam(Si1132_PARAM_ALSIRADCCOUNTER, Si1132_PARAM_ADCCOUNTER_511CLK);
	// in high range mode
  	writeParam(Si1132_PARAM_ALSIRADCMISC, Si1132_PARAM_ALSIRADCMISC_RANGE);

	// fastest clocks
  	writeParam(Si1132_PARAM_ALSVISADCGAIN, 0x00);
	// take 511 clocks to measure
  	writeParam(Si1132_PARAM_ALSVISADCCOUNTER, Si1132_PARAM_ADCCOUNTER_511CLK);
	// in high range mode (not normal signal)
  	writeParam(Si1132_PARAM_ALSVISADCMISC, Si1132_PARAM_ALSVISADCMISC_VISRANGE);

	// measure rate for auto, 32 * 31.25us = 1000us = 1ms
	write8(Si1132_REG_MEASRATE0, 0xFF);
	//write8(Si1132_REG_MEASRATE1, 0xFF);
	write8(Si1132_REG_COMMAND, Si1132_ALS_AUTO);

	return true;
}
// allow sensor to be initialised with a specific I2c address
boolean Adafruit_SI1145::begin( uint8_t addr ) {
  boolean begun;

  Wire.begin();

  if ( !_reset ) reset();
  _reset = true;

  writeParam( 0x00, addr );
  write8( SI1145_REG_COMMAND, SI1145_BUSADDR );
  _addr = addr;

  begun = begin();

  _reset = false;

  return begun;
}
Exemplo n.º 12
0
   /*
   * Output results to file after simulation is completed.
   */
   void ClusterHistogram::output() 
   {
      // Write parameter file
      fileMaster().openOutputFile(outputFileName(".prm"), outputFile_);
      writeParam(outputFile_);
      outputFile_.close();

      // Write histogram output
      fileMaster().openOutputFile(outputFileName(".hist"), outputFile_);
      // hist_.output(outputFile_);
      int min = hist_.min();
      int nBin = hist_.nBin();
      for (int i = 0; i < nBin; ++i) {
         outputFile_ << Int(i + min) << "  " 
                     <<  Dbl(double(hist_.data()[i])/double(nSample_)) << "\n";
      }
      outputFile_.close();
   }
Exemplo n.º 13
0
   /*
   * Output results to file after simulation is completed.
   */
   void McMuExchange::output()
   {

      fileMaster().openOutputFile(outputFileName(".prm"), outputFile_);
      writeParam(outputFile_);
      outputFile_.close();

      double ave, err;
      double sumAve = 0.0;
      double sumAveSq = 0.0;
      double sumErrSq = 0.0;
      for (int iMol=0; iMol < nMolecule_; ++iMol) {
         ave = accumulators_[iMol].average();
         err = accumulators_[iMol].blockingError();
         sumAve += ave;
         sumAveSq += ave*ave;
         sumErrSq += err*err;
      }
      double rMol = double(nMolecule_);
      ave = sumAve/rMol;
      err = sqrt(sumErrSq/rMol);
      double dev = sqrt((sumAveSq/rMol) - ave*ave);

      fileMaster().openOutputFile(outputFileName(".ave"), outputFile_);
      outputFile_ << "Average = " << ave << " +- " 
                  << dev/sqrt(rMol) << std::endl;
      outputFile_ << "Error via molecule variance    = " 
                  << dev/sqrt(rMol) << std::endl;
      outputFile_ << "Error via time series analysis = " 
                  << err/sqrt(rMol) << std::endl;
      outputFile_ << std::endl;
      //for (int iMol=0; iMol < nMolecule_; ++iMol) {
      //   accumulators_[iMol].output(outputFile_);
      //}
      outputFile_.close();
   }
Exemplo n.º 14
0
void ConfigChannel::writeParam(cvg_int id, cvg_float value) {
	float_hton(&value);
	writeParam(id, (cvg_char *)&value, sizeof(cvg_float));
}
Exemplo n.º 15
0
void RecordWorkThread::run()
{
    recorderFlag = false;
    anares.clear();
    CurrentStaus cstatus;


    workbook *wb = new workbook();
    xf_t* xf = wb->xformat();
    worksheet* ws;
    ws = wb->sheet("sheet1");
    setTitle(ws,xf);
    int cnt = 1;
    int sheetNUM = 1;
    overflow = false;
    bool first = true;

    Util::SysLogD("charge type : %d %f %f %f\n ",charge_type,power_charge_normal,power_charge_peak,power_charge_valley);
    Util::SysLogD("normal : %d %d %d %d %d %d\n ",normal_period[0],normal_period[1],normal_period[2],normal_period[3],normal_period[4],normal_period[5]);
    Util::SysLogD("peak : %d %d %d %d %d %d\n ",peak_period[0],peak_period[1],peak_period[2],peak_period[3],peak_period[4],peak_period[5]);
    Util::SysLogD("valley : %d %d %d %d %d %d\n ",valley_period[0],valley_period[1],valley_period[2],valley_period[3],valley_period[4],valley_period[5]);
    while(!recorderFlag)
    {
        if(overflow)
        {
            usleep(300000);
        }
        usleep(300000);
        EnergyParam param = dataWoker->getEnergyParam();
        if(first)
        {
            anares.start_measure_time = param.time;
            first = false;
            mutex.lock();
            initStatus(&cstatus,&param);
            anares.vsp_cnt = cstatus.acc_vsp_cnt;
            mutex.unlock();
            writeParam(ws,xf,param,cnt);

        }
        if(cstatus.lastTime < param.time)
        {
            cnt++;
            mutex.lock();
            updateResult(&cstatus,&param);
            anares.vsp_cnt = cstatus.acc_vsp_cnt;
            mutex.unlock();
            writeParam(ws,xf,param,cnt);
        }

        acc_flow = anares.acc_flow;
        acc_power = anares.acc_power;
        load_radio = ((float)anares.load_time/(float)(anares.load_time + anares.unload_time))*100.0;
        if(cnt>SHEET_MAX_LINE)
        {
            if(sheetNUM < SHEET_MAX_INDEX)
            {
                char temp[10];
                sprintf(temp,"sheet%d",sheetNUM+1);
                ws = wb->sheet(temp);
                setTitle(ws,xf);
                sheetNUM++;
            }else {
                emit recordoverflow(1);
                overflow = true;
            }
            cnt = 0;
        }

    }

    if(cstatus.state == STAGE_LOAD )
    {
//        anares.load_cnt++;
//        anares.load_time += cstatus.duration;
        if(anares.max_load_time < cstatus.duration)
        {
            anares.max_load_time = cstatus.duration;
        }
    }else if(cstatus.state == STAGE_UNLOAD )
    {
//        anares.unload_cnt++;
//        anares.unload_time += cstatus.duration;
        if(anares.max_unload_time < cstatus.duration)
        {
            anares.max_unload_time = cstatus.duration;
        }
    }
    if(cstatus.acc_vsp_cnt>0)
        anares.ave_vsp = anares.ave_vsp/(float)cstatus.acc_vsp_cnt;
    anares.end_measure_time = cstatus.lastTime;

    anares.worktime = anares.load_time + anares.unload_time;
    anares.stanby_time = anares.end_measure_time - anares.start_measure_time - anares.worktime;

    Util::SysLogD("start and end time  : %d %d\n",anares.start_measure_time,anares.end_measure_time);
    Util::SysLogD("load and unload time  : %d %d\n",anares.load_time,anares.unload_time);
    Util::SysLogD("acc_flow : %f\n",anares.acc_flow);
    Util::SysLogD("cur : %d %d\n",max_cur_standby,max_cur_unload);
    Util::SysLogD("max time : %d %d\n",anares.max_load_time,anares.max_unload_time);
    Util::SysLogD("max time : %d %d\n",anares.max_load_time,anares.max_unload_time);
    Util::SysLogD("vas : %f %d\n",anares.ave_vsp,cstatus.acc_vsp_cnt);

    if(anares.worktime != 0)
    {
        anares.load_radio = ((float)anares.load_time)/(float)anares.worktime*100.0;
        anares.unload_radio = ((float)anares.unload_time)/(float)anares.worktime*100.0;
    }

    anares.acc_flow = anares.acc_flow/60;//m3/min
    anares.acc_power = anares.acc_power/3600;//kwh
    anares.load_power /= 3600;
    anares.unload_power /= 3600;

    if(charge_type == 1)
    {
        anares.acc_charge_normal =  anares.acc_charge_normal*power_charge_normal/3600;
        anares.acc_charge_peak =  anares.acc_charge_peak*power_charge_peak/3600;
        anares.acc_charge_valley =  anares.acc_charge_valley*power_charge_valley/3600;
        anares.acc_charge = anares.acc_charge_normal+anares.acc_charge_peak+anares.acc_charge_valley;
        anares.load_charge /= 3600;
        anares.unload_chargd /= 3600;

    }else if(charge_type == 0)
    {
        anares.acc_charge = anares.acc_power*power_charge;
        anares.load_charge = anares.load_power*power_charge;
        anares.unload_chargd = anares.unload_power*power_charge;
    }

    anares.permanent_magnet_frequency_conversion = anares.unload_power+anares.load_power*0.1;
    anares.first_order_energy_efficiency = -7.2*anares.acc_flow/60 + anares.acc_power;

    anares.permanent_magnet_frequency_conversion_day = anares.permanent_magnet_frequency_conversion * 12 / anares.worktime *3600;
    anares.permanent_magnet_frequency_conversion_month = anares.permanent_magnet_frequency_conversion * 30 * 12 / anares.worktime *3600;
    anares.permanent_magnet_frequency_conversion_year = anares.permanent_magnet_frequency_conversion * 365 * 30 * 12 / anares.worktime *3600;

    if(anares.first_order_energy_efficiency <0.00001)
    {
        anares.first_order_energy_efficiency = 0;
        anares.first_order_energy_efficiency_day = 0;
        anares.first_order_energy_efficiency_month = 0;
        anares.first_order_energy_efficiency_year = 0;
    }else
    {
        anares.first_order_energy_efficiency_day = anares.first_order_energy_efficiency * 12 / anares.worktime *3600;
        anares.first_order_energy_efficiency_month = anares.first_order_energy_efficiency * 30 * 12 / anares.worktime *3600;
        anares.first_order_energy_efficiency_year = anares.first_order_energy_efficiency * 365 * 30 * 12 / anares.worktime *3600;
    }

    anares.load_charge_radio = anares.load_charge/ anares.acc_charge *100.0;
    anares.unload_charge_radio = anares.unload_chargd/ anares.acc_charge *100.0;
    anares.ave_cost = anares.acc_charge / anares.acc_flow;
    anares.ave_power_cost = anares.acc_power / anares.acc_flow;

//    char temp[10];
//    sprintf(temp,"sheet%d",sheetNUM+1);
    ws = wb->sheet("分析结果");
    Util::writeResultWithFormat(ws,xf,anares);

    string path_post = title.toStdString();
    string path = path_pre + path_post; 
    wb->Dump(path);
    delete wb;
    Util::fileSync(path.c_str());
    Util::SysLogD("save file : %s\n",path.c_str());
    emit recordoverflow(2);
}
Exemplo n.º 16
0
void ConfigChannel::writeParam(cvg_int id, cvg_int value) {
	value = htonl(value);
	writeParam(id, (cvg_char *)&value, sizeof(cvg_int));
}
Exemplo n.º 17
0
void ConfigChannel::writeParam(cvg_int id, const cvgString &value) {
	writeParam(id, value.c_str(), value.length());
}
Exemplo n.º 18
0
/*
    construct sphere-tree for the model
*/
bool constructTree(const boost::filesystem::path& input_file,
                   bool toYAML)
{
  boost::filesystem::path output_file
    = input_file.parent_path () / boost::filesystem::basename (input_file);

  if (toYAML)
    output_file += "-spawn.yml";
  else
    output_file += "-spawn.sph";

  printf("Input file: %s\n", input_file.c_str ());
  printf("Output file: %s\n\n", output_file.c_str ());


  /*
      load the surface model
  */
  Surface sur;

  bool loaded = false;
  std::string extension = boost::algorithm::to_lower_copy (input_file.extension ().string ());
  if (extension == ".obj")
    loaded = loadOBJ(&sur, input_file.c_str ());
  else
    loaded = sur.loadSurface(input_file.c_str ());

  if (!loaded){
    printf("ERROR : Unable to load input file (%s)\n\n", input_file.c_str ());
    return false;
    }

  /*
      scale box
  */
  // FIXME: Disable scaling for now (wrong result if a transformation is applied after)
  //float boxScale = sur.fitIntoBox(1000);
  float boxScale = 1.;

  /*
      make medial tester
  */
  MedialTester mt;
  mt.setSurface(sur);
  mt.useLargeCover = true;

  /*
      setup evaluator
  */
  SEConvex convEval;
  convEval.setTester(mt);
  SEBase *eval = &convEval;

  Array<Point3D> sphPts;
  SESphPt sphEval;
  if (testerLevels > 0){   //  <= 0 will use convex tester
    SSIsohedron::generateSamples(&sphPts, testerLevels-1);
    sphEval.setup(mt, sphPts);
    eval = &sphEval;
    printf("Using concave tester (%d)\n\n", sphPts.getSize());
    }

  /*
      verify model
  */
  if (verify){
    bool ok = verifyModel(sur);
    if (!ok){
      printf("ERROR : model is not usable\n\n");
      return false;
      }
    }

  /*
      setup for the set of cover points
  */
  Array<Surface::Point> coverPts;
  MSGrid::generateSamples(&coverPts, numCoverPts, sur, TRUE, minCoverPts);
  printf("%d cover points\n", coverPts.getSize());

  /*
      setup SPAWN algorithm
  */
  SRSpawn spawn;
  spawn.setup(mt);
  spawn.useIterativeSelect = false;
  spawn.eval = eval;

  /*
      setup SphereTree constructor - using dynamic construction
  */
  STGGeneric treegen;
  treegen.eval = eval;
  treegen.useRefit = true;
  treegen.setSamples(coverPts);
  treegen.reducer = &spawn;

  /*
      make sphere-tree
  */
  SphereTree tree;
  tree.setupTree(branch, depth+1);

  waitForKey();
  treegen.constructTree(&tree);

  /*
     save sphere-tree
  */
  if (tree.saveSphereTree(output_file, 1.0f/boxScale)){
    Array<LevelEval> evals;
    if (eval){
      evaluateTree(&evals, tree, eval);
      writeEvaluation(stdout, evals);
      }

    if (!yaml)
    {
      FILE *f = fopen(output_file.c_str (), "a");
      if (f){
        fprintf(f, "\n\n");
        fprintf(f, "Options : \n");
        writeParam(stdout, intParams);
        writeParam(stdout, boolParams);
        fprintf(f, "\n\n");
        writeEvaluation(f, evals);
        fclose(f);
      }
    }

    return true;
    }
  else{
    return false;
    }
}
Exemplo n.º 19
0
// Write Vis ADC Counter
void Adafruit_SI1145::writeVisAdcCnt(uint8_t cnt)
{
	cnt = cnt & 0x7;
	cnt = cnt << 4;
	writeParam(SI1145_PARAM_ALSVISADCOUNTER, cnt);
}
Exemplo n.º 20
0
// Write Vis ADC Gain
void Adafruit_SI1145::writeVisAdcGain(uint8_t gain)
{
	gain = gain & 0x07;
	writeParam(SI1145_PARAM_ALSVISADCGAIN, gain);
}
Exemplo n.º 21
0
void pfPrcHelper::writeParam(const char* name, const char* value) {
    writeParam(name, ST::string(value));
}
Exemplo n.º 22
0
boolean Adafruit_SI1145::begin(void) {
  Wire.begin();
 
  uint8_t id = read8(SI1145_REG_PARTID);
  if (id != 0x45) return false; // look for SI1145
  
  reset();
  

    /***********************************/
  // enable UVindex measurement coefficients!
  write8(SI1145_REG_UCOEFF0, 0x29);
  write8(SI1145_REG_UCOEFF1, 0x89);
  write8(SI1145_REG_UCOEFF2, 0x02);
  write8(SI1145_REG_UCOEFF3, 0x00);

  // enable UV sensor
  writeParam(SI1145_PARAM_CHLIST, SI1145_PARAM_CHLIST_ENUV |
  SI1145_PARAM_CHLIST_ENALSIR | SI1145_PARAM_CHLIST_ENALSVIS |
  SI1145_PARAM_CHLIST_ENPS1);
  // enable interrupt on every sample
  write8(SI1145_REG_INTCFG, SI1145_REG_INTCFG_INTOE);  
  write8(SI1145_REG_IRQEN, SI1145_REG_IRQEN_ALSEVERYSAMPLE);  

/****************************** Prox Sense 1 */

  // program LED current
  write8(SI1145_REG_PSLED21, 0x03); // 20mA for LED 1 only
  writeParam(SI1145_PARAM_PS1ADCMUX, SI1145_PARAM_ADCMUX_LARGEIR);
  // prox sensor #1 uses LED #1
  writeParam(SI1145_PARAM_PSLED12SEL, SI1145_PARAM_PSLED12SEL_PS1LED1);
  // fastest clocks, clock div 1
  writeParam(SI1145_PARAM_PSADCGAIN, 0);
  // take 511 clocks to measure
  writeParam(SI1145_PARAM_PSADCOUNTER, SI1145_PARAM_ADCCOUNTER_511CLK);
  // in prox mode, high range
  writeParam(SI1145_PARAM_PSADCMISC, SI1145_PARAM_PSADCMISC_RANGE|
    SI1145_PARAM_PSADCMISC_PSMODE);

  writeParam(SI1145_PARAM_ALSIRADCMUX, SI1145_PARAM_ADCMUX_SMALLIR);  
  // fastest clocks, clock div 1
  writeParam(SI1145_PARAM_ALSIRADCGAIN, 0);
  // take 511 clocks to measure
  writeParam(SI1145_PARAM_ALSIRADCOUNTER, SI1145_PARAM_ADCCOUNTER_511CLK);
  // in high range mode
  writeParam(SI1145_PARAM_ALSIRADCMISC, SI1145_PARAM_ALSIRADCMISC_RANGE);



  // fastest clocks, clock div 1
  writeParam(SI1145_PARAM_ALSVISADCGAIN, SI1145_PARAM_ADCGAIN_128);
  // take 511 clocks to measure
  writeParam(SI1145_PARAM_ALSVISADCOUNTER, SI1145_PARAM_ADCCOUNTER_511CLK);
  // in normal range mode (normal signal)
  writeParam(SI1145_PARAM_ALSVISADCMISC, SI1145_PARAM_ALSVISADCMISC_VISLRANGE);


/************************/

  // measurement rate for auto
  write8(SI1145_REG_MEASRATE0, 0xFF); // 255 * 31.25uS = 8ms
  
  // auto run
  write8(SI1145_REG_COMMAND, SI1145_PSALS_AUTO);

  return true;
}
Exemplo n.º 23
0
void pfPrcHelper::writeParam(const char* name, float value) {
    writeParam(name, (double)value);
}