int ADS1115::getOneShotNch( uint8_t s_ch, uint8_t e_ch, int16_t *d ) { if( !d || s_ch > 3 || e_ch > 3 || e_ch < s_ch ) { return 0; } static const uint16_t ch_bits[n_ch_max] = { cfg_in_0, cfg_in_1, cfg_in_2, cfg_in_3 }; int n = 0; uint16_t cfg_old = cfg_val; uint16_t cfg_base = cfg_val & ~cfg_in_mask; for( uint8_t ch = s_ch; ch <= e_ch; ++ch ) { uint16_t cvx = cfg_base | ch_bits[ch] | cfg_os; writeReg( reg_cfg, cvx ); delay_mcs( 100 ); for( int i=0; i<2000; ++i ) { // for 8 sps 200 ms is good if( getDeviceCfg() & cfg_os ) { d[n] = getContValue(); ++n; break; } delay_mcs( 100 ); // delay_ms( 1 ); } } setCfg( cfg_old ); return n; }
// ---------------------------------------------------------- cADC::cADC( uint8_t addr ) { a_adc = addr; // address of ADC chip cal_gain = CAL_GAIN; cal_offset = CAL_OFFSET; setCfg( ADC_BITS_18, ADC_GAIN_8, ADC_CONV_1SHOT ); // 18 bit, 8X, 1 shot }
CFactorGraph CompressInterface::compress(CFactorGraph cfg) { setCfg(cfg); execute(); return createCFactorGraph(); }
void Context::loadCfgFile(const UknString& name) { ContextCfg cfg; cfg.render_cfg.width = 800; cfg.render_cfg.height = 600; cfg.render_cfg.top = 0; cfg.render_cfg.left = 0; cfg.render_cfg.color_fmt = EF_RGBA8; cfg.render_cfg.depth_stencil_fmt = EF_D16; cfg.render_cfg.resizable = false; cfg.render_cfg.full_screen = false; cfg.render_cfg.show_mouse = true; cfg.render_cfg.sample_count = 0; cfg.render_cfg.sample_quality = 0; ConfigParserPtr configParser = AssetManager::Instance().load<ConfigParser>(name); if(configParser) { if(configParser->toNode(L"/cfg/graphics")) { cfg.render_cfg.width = configParser->getInt(L"width", cfg.render_cfg.width); cfg.render_cfg.height = configParser->getInt(L"height", cfg.render_cfg.height); cfg.render_cfg.top = configParser->getInt(L"top", cfg.render_cfg.top); cfg.render_cfg.left = configParser->getInt(L"left", cfg.render_cfg.left); cfg.render_cfg.resizable = configParser->getBool(L"resizable", cfg.render_cfg.resizable); cfg.render_cfg.show_mouse = configParser->getBool(L"show_mouse", cfg.render_cfg.show_mouse); cfg.render_cfg.full_screen = configParser->getBool(L"full_screen", cfg.render_cfg.full_screen); cfg.render_cfg.sample_count = configParser->getInt(L"sample_count", cfg.render_cfg.sample_count); cfg.render_cfg.sample_quality = configParser->getInt(L"sample_quality", cfg.render_cfg.sample_quality); UknString fmt_string; int fmt_id; fmt_string = configParser->getString(L"color_fmt", L"EF_ARGB8"); fmt_id = fmt_string_to_element_format(fmt_string); if(fmt_id == -1) { log_warning(format_string("ukn::Context::loadCfgFile: unknown color format %s, using EF_ARGB8", fmt_string.c_str())); cfg.render_cfg.color_fmt = (ElementFormat)fmt_id; } fmt_string = configParser->getString(L"depth_stencil_fmt", L"EF_D16"); fmt_id = fmt_string_to_element_format(fmt_string); if(fmt_id == -1) { log_warning(format_string("ukn::Context::loadCfgFile: unknown depth stencil format %s, using EF_D16", fmt_string.c_str())); cfg.render_cfg.depth_stencil_fmt = (ElementFormat)fmt_id; } } if(configParser->toNode(L"/cfg/plugins")) { cfg.graphic_factory_name = configParser->getString(L"graphic_factory", L""); } } else { log_warning(L"ukn::Context::loadCfgFile: unable to open config file " + name); } setCfg(cfg); if(!configParser) { saveCfgFile(L"config.xml"); } }