Ejemplo n.º 1
0
/**
 * Get the estimated color.
 *
 * Gets a color estimate from the sensor corresponding to the
 * table found with the sensor or at the following site:
 * http://www.hitechnic.com/cgi-bin/commerce.cgi?preadd=action&key=NCO1038
 *
 * @return The estimated color.
 */
UINT8 HiTechnicColorSensor::GetColor()
{
	UINT8 color = 0;
	
	if(m_mode != kActive)
	{
		SetMode(kActive);
	}
	if (m_i2c)
	{
		m_i2c->Read(kColorRegister, sizeof(color), &color);
	}
	return color;
}
Ejemplo n.º 2
0
Log::Log(int mode, int level, LPCTSTR filename, bool append)
{
	m_lastLogTime = 0;
    hlogfile = INVALID_HANDLE_VALUE;
    m_todebug = false;
    m_toconsole = false;
    m_tofile = false;
	InitializeCriticalSection( &m_criLock );
	
	SetLevel( level );
    SetMode(mode);
	if( mode&ToFile && filename )
	  SetFile(filename, append);
}
Ejemplo n.º 3
0
/**
   * Get the Raw Green value.
   *
   * Gets the (0-65536) raw green value from the sensor.
   * 
   * The sensor must be in raw or passive mode to access the regular RGB data
   * if the sensor is not in raw or passive mode, it will be placed into raw
   * mode by this method.
   *
   * @return The Raw Green sensor value.
   */
UINT16 HiTechnicColorSensor::GetRawGreen()
{
	UINT16 rawGreen = 0;
	
	if(m_mode == kActive)
	{
		SetMode(kRaw);
	}
	if (m_i2c)
	{
		m_i2c->Read(kRawGreenRegister, sizeof(rawGreen), (UINT8 *)&rawGreen);
	}
	return rawGreen;
}
Ejemplo n.º 4
0
/**
 * Get the Raw Blue value.
 *
 * Gets the (0-65536) raw blue value from the sensor.
 * 
 * The sensor must be in raw or passive mode to access the regular RGB data
 * if the sensor is not in raw or passive mode, it will be placed into raw
 * mode by this method.
 *
 * @return The Raw Blue sensor value.
 */
UINT16 HiTechnicColorSensor::GetRawBlue()
{
	UINT16 rawBlue = 0;
	
	if(m_mode == kActive)
	{
		SetMode(kRaw);
	}
	if (m_i2c)
	{
		m_i2c->Read(kRawBlueRegister, sizeof(rawBlue), (UINT8 *)&rawBlue);
	}
	return rawBlue;
}
Ejemplo n.º 5
0
/**
 * Get the Green value.
 *
 * Gets the(0-255) green value from the sensor.
 * 
 * The sensor must be in active mode to access the regular RGB data
 * if the sensor is not in active mode, it will be placed into active
 * mode by this method.
 * 
 * @return The Green sensor value.
 */
UINT8 HiTechnicColorSensor::GetGreen()
{
	UINT8 green = 0;
	
	if(m_mode != kActive)
	{
		SetMode(kActive);
	}
	if (m_i2c)
	{
		m_i2c->Read(kGreenRegister, sizeof(green), &green);
	}
	return green;
}
Ejemplo n.º 6
0
/**
 * Get the Blue value.
 *
 * Gets the raw (0-255) blue value from the sensor.
 * 
 * The sensor must be in active mode to access the regular RGB data
 * if the sensor is not in active mode, it will be placed into active
 * mode by this method.
 * 
 * @return The Blue sensor value.
 */
UINT8 HiTechnicColorSensor::GetBlue()
{
	UINT8 blue = 0;
	
	if(m_mode != kActive)
	{
		SetMode(kActive);
	}
	if (m_i2c)
	{
		m_i2c->Read(kBlueRegister, sizeof(blue), &blue);
	}
	return blue;
}
Ejemplo n.º 7
0
/////////// OPERATIONS ////////////////////////////////
int
Lookup::Set(char* mess, float value){

  switch(FindMsg(mess)){

  case 21:
    SetMode((int) value, m_normal);
    return 1;

  case 22:
    SetMode(m_mode, (int) value);
    return 1;

  case 23:
    Offset((int)value);
    return 1;

  default:
    return SndObj::Set(mess, value);

  }

}
Ejemplo n.º 8
0
/**
 * Get the Red value.
 *
 * Gets the (0-255) red value from the sensor.
 * 
 * The sensor must be in active mode to access the regular RGB data
 * if the sensor is not in active mode, it will be placed into active
 * mode by this method.
 *
 * @return The Red sensor value.
 */
UINT8 HiTechnicColorSensor::GetRed()
{
	UINT8 red = 0;
	
	if(m_mode != kActive)
	{
		SetMode(kActive);
	}
	if (m_i2c)
	{
		m_i2c->Read(kRedRegister, sizeof(red), &red);
	}
	return red;
}
/*
 * Set value of given attribute.
 */
int CGXDLMSAutoAnswer::SetValue(int index, CGXDLMSVariant& value)
{
    if (index == 1)
    {
        if (value.vt != DLMS_DATA_TYPE_OCTET_STRING || value.GetSize() != 6)
		{
			return ERROR_CODES_INVALID_PARAMETER;
		}
		memcpy(m_LN, &value.byteArr[0], 6);
		return ERROR_CODES_OK;         
    }
    if (index == 2)
    {
        SetMode((AUTO_CONNECT_MODE) value.lVal);
		return ERROR_CODES_OK;
    }
    if (index == 3)
    {
        m_ListeningWindow.clear();
		for (vector<CGXDLMSVariant>::iterator item = value.Arr.begin(); item != value.Arr.end(); ++item)
        {            
            CGXDLMSVariant start, end;
			CGXDLMSClient::ChangeType((*item).Arr[0].byteArr, DLMS_DATA_TYPE_DATETIME, start);
            CGXDLMSClient::ChangeType((*item).Arr[1].byteArr, DLMS_DATA_TYPE_DATETIME, end);
			m_ListeningWindow.push_back(std::pair< CGXDateTime, CGXDateTime>(start.dateTime, end.dateTime));
        }
		return ERROR_CODES_OK;
    }
    if (index == 4)
    {
        SetStatus((AUTO_ANSWER_STATUS) value.lVal);
		return ERROR_CODES_OK;
    }
    if (index == 5)
    {
        SetNumberOfCalls(value.lVal);
		return ERROR_CODES_OK;
    }
    if (index == 6)
    {          
		m_NumberOfRingsInListeningWindow = m_NumberOfRingsOutListeningWindow = 0;
        if (value.vt != DLMS_DATA_TYPE_NONE)
        {
            m_NumberOfRingsInListeningWindow = value.Arr[0].bVal;
            m_NumberOfRingsOutListeningWindow = value.Arr[1].bVal;
        }           
		return ERROR_CODES_OK;
    }
    return ERROR_CODES_INVALID_PARAMETER;
}
Ejemplo n.º 10
0
void CMDKImplementation::DeleteInput(char const *macname)
{
	for (InputList::iterator i = Inputs.begin(); i != Inputs.end(); i++)
	{
		if ((*i).Name.compare(macname) == 0)
		{

			Inputs.erase(i);

			SetMode();
			return;
		}
	}
}
Ejemplo n.º 11
0
void VirtualMachineGUI::EnterRunMode(bool beeperModeFlag)
{
	if (_mode != MODE_Program) return;
	Reset();
	SetNumLED(0xff);
	RefreshNumLED();
	SetMode(MODE_Run);
	if (beeperModeFlag) {
		_pThread = new Thread_Beeper(*this);
	} else {
		_pThread = new Thread_Simulator(*this);
	}
	_pThread->Create();
	_pThread->Run();
}
int CEMTestnParaRatebyRoom::OnDeleteEMStatisticsGeneralPatientReport(){
 	if(GetMode() != VM_VIEW) 
 		return -1; 
 	CHMSMainFrame *pMF = (CHMSMainFrame *)AfxGetMainWnd(); 
 	CString szSQL; 
 	if(ShowMessage(1, MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2) == IDNO) 
 		return -1; 
 	szSQL.Format(_T("DELETE FROM  WHERE  AND") ); 
 	int ret = pMF->ExecSQL(szSQL); 
 	if(ret >= 0){ 
 		SetMode(VM_NONE); 
 		OnCancelEMStatisticsGeneralPatientReport(); 
 	}
	return 0;
}
Ejemplo n.º 13
0
SourceBuffer::SourceBuffer(MediaSource* aMediaSource, const nsACString& aType)
  : DOMEventTargetHelper(aMediaSource->GetParentObject())
  , mMediaSource(aMediaSource)
  , mUpdating(false)
  , mActive(false)
  , mUpdateID(0)
  , mReportedOffset(0)
  , mType(aType)
{
  MOZ_ASSERT(NS_IsMainThread());
  MOZ_ASSERT(aMediaSource);
  mEvictionThreshold = Preferences::GetUint("media.mediasource.eviction_threshold",
                                            100 * (1 << 20));
  bool generateTimestamps = false;
  if (aType.LowerCaseEqualsLiteral("audio/mpeg") ||
      aType.LowerCaseEqualsLiteral("audio/aac")) {
    generateTimestamps = true;
  }
  mAttributes = new SourceBufferAttributes(generateTimestamps);

  mContentManager =
    SourceBufferContentManager::CreateManager(mAttributes,
                                              aMediaSource->GetDecoder(),
                                              aType);
  MSE_DEBUG("Create mContentManager=%p",
            mContentManager.get());

  ErrorResult dummy;
  if (mAttributes->mGenerateTimestamps) {
    SetMode(SourceBufferAppendMode::Sequence, dummy);
  } else {
    SetMode(SourceBufferAppendMode::Segments, dummy);
  }
  mMediaSource->GetDecoder()->GetDemuxer()->AttachSourceBuffer(
    static_cast<mozilla::TrackBuffersManager*>(mContentManager.get()));
}
Ejemplo n.º 14
0
int main(void) {
	int APMdesc = 0;
	uint8_t data[MAVLINK_MAX_PACKET_LEN] = {0x00};
	uint16_t datalen = 0;
	mavlink_message_t msg;

	APMdesc = OpenAPM();
	
	int i = 0;
	while(1){
		ReadData(APMdesc, &datalen, data);
		if (DetectMAVLink(APMdesc, data, datalen, &msg)) {
			if (i == 40) {
				printf("\tSending data stream request from RC channels...\n");	
				ReqDatastream(APMdesc, MAVLINK_MSG_ID_RC_CHANNELS);
			}
			if (i == 50) {
				printf("\tSending arm command...\n");	
				SetMode(APMdesc, MAV_MODE_STABILIZE_ARMED);
			}
			if (i == 150) {
				printf("\tSending takeoff command...\n");
				TakeOffTest(APMdesc);	
			}
			if (i == 350) {
				printf("\tSending disarm command...\n");
				SetMode(APMdesc, MAV_MODE_STABILIZE_DISARMED);	
				break;
			}
			i++;
		}
	}
	 
	CloseAPM(APMdesc);
	return 0;
}
int CFMDischargedPaidPatientListByDay::OnDeleteFMDischargedPaidPatientListByDay(){
 	if(GetMode() != VM_VIEW)
 		return -1;
 	CHMSMainFrame *pMF = (CHMSMainFrame *)AfxGetMainWnd();
 	CString szSQL;
 	if(ShowMessage(1, MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2) == IDNO)
 		return -1;
 	szSQL.Format(_T("DELETE FROM  WHERE  AND") );
 	int ret = pMF->ExecSQL(szSQL);
 	if(ret >= 0){
 		SetMode(VM_NONE);
 		OnCancelFMDischargedPaidPatientListByDay();
 	}
	return 0;
}
Ejemplo n.º 16
0
static gboolean
ghid_idle_cb (gpointer data)
{
  if (Settings.Mode == NO_MODE)
    SetMode (ARROW_MODE);
  ghid_mode_cursor (Settings.Mode);
  if (ghidgui->settings_mode != Settings.Mode)
    {
      ghid_mode_buttons_update ();
    }
  ghidgui->settings_mode = Settings.Mode;

  ghid_update_toggle_flags ();
  return FALSE;
}
Ejemplo n.º 17
0
void Scene_Shop::UpdateBuySelection() {
	status_window->SetItemId(buy_window->GetItemId());
	party_window->SetItemId(buy_window->GetItemId());

	if (Input::IsTriggered(Input::CANCEL)) {
		Game_System::SePlay(Game_System::GetSystemSE(Game_System::SFX_Cancel));
		if (Game_Temp::shop_sells) {
			SetMode(BuySellLeave2);
		} else {
			Scene::Pop();
		}
	} else if (Input::IsTriggered(Input::DECISION)) {
		int item_id = buy_window->GetItemId();

		// checks the money and number of items possessed before buy
		if (buy_window->CheckEnable(item_id)) {
			Game_System::SePlay(Game_System::GetSystemSE(Game_System::SFX_Decision));

			// Items are guaranteed to be valid
			const RPG::Item* item = ReaderUtil::GetElement(Data::items, item_id);

			int max;
			if (item->price == 0) {
				max = 99;
			} else {
				max = Main_Data::game_party->GetGold() / item->price;
			}
			number_window->SetData(item_id, max, item->price);

			SetMode(BuyHowMany);
		}
		else {
			Game_System::SePlay(Game_System::GetSystemSE(Game_System::SFX_Buzzer));
		}
	}
}
int CPMSExportSheetList::OnDeletePMSExportSheetList(){
 	if(GetMode() != VM_VIEW) 
 		return -1; 
 	CMainFrame_E10 *pMF = (CMainFrame_E10 *)AfxGetMainWnd(); 
 	CString szSQL; 
 	if(ShowMessage(1, MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2) == IDNO) 
 		return -1; 
 	szSQL.Format(_T("DELETE FROM  WHERE  AND") ); 
 	int ret = pMF->ExecSQL(szSQL); 
 	if(ret >= 0){ 
 		SetMode(VM_NONE); 
 		OnCancelPMSExportSheetList(); 
 	}
	return 0;
}
Ejemplo n.º 19
0
void Scene_Shop::Update() {
	buy_window->Update();
	sell_window->Update();
	shop_window->Update();
	number_window->Update();
	party_window->Update();

	switch (mode) {
		case BuySellLeave:
		case BuySellLeave2:
			UpdateCommandSelection();
			break;
		case Buy:
			UpdateBuySelection();
			break;
		case Sell:
			UpdateSellSelection();
			break;
		case BuyHowMany:
		case SellHowMany:
			UpdateNumberInput();
			break;
		case Bought:
			timer--;
			if (timer == 0)
				SetMode(Buy);
			break;
		case Sold:
			timer--;
			if (timer == 0)
				SetMode(Sell);
			break;
		default:
			break;
	}
}
int CEMWeekSynthesisReport::OnDeleteEMWeekSynthesisReport(){
 	if(GetMode() != VM_VIEW) 
 		return -1; 
 	CHMSMainFrame *pMF = (CHMSMainFrame *)AfxGetMainWnd(); 
 	CString szSQL; 
 	if(ShowMessage(1, MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2) == IDNO) 
 		return -1; 
 	szSQL.Format(_T("DELETE FROM  WHERE  AND") ); 
 	int ret = pMF->ExecSQL(szSQL); 
 	if(ret >= 0){ 
 		SetMode(VM_NONE); 
 		OnCancelEMWeekSynthesisReport(); 
 	}
	return 0;
}
Ejemplo n.º 21
0
status_t
Screen::SetMode(uint16 width, uint16 height, uint32 colorSpace,
	const display_timing& timing)
{
	display_mode mode;
	mode.timing = timing;
	mode.space = colorSpace;
	mode.virtual_width = width;
	mode.virtual_height = height;
	mode.h_display_start = 0;
	mode.v_display_start = 0;
	mode.flags = 0;

	return SetMode(mode);
}
//错误0:检查不到wifi芯片  错误1:wifi连接失败  错误2 服务器连接失败
u8 esp8266::ConnectNetwork_client(char *WifiName,char* WifiPassword,char *IP,short port)//连接服务器
{
	if(!kick() )
		return 0; //检查不到wifi芯片
	SetMode(1);
	restart();
	tskmgr.DelayS(3);
	//setEcho(0);
	if ( !JoinAP(WifiName,WifiPassword) )
		return 1; //连接wifi错误
	if( !CreateConnectMode(IP,port))
		return 2; //连接不上服务器
	return 0xff; //连接成功
	
}
Ejemplo n.º 23
0
void Scene_Shop::UpdateSellSelection() {
	if (Input::IsTriggered(Input::CANCEL)) {
		Game_System::SePlay(Data::system.cancel_se);
		if (Game_Temp::shop_buys) {
			SetMode(BuySellLeave2);
		} else {
			Scene::Pop();
		}
	} else if (Input::IsTriggered(Input::DECISION)) {
		int item_id = sell_window->GetItemId();
		status_window->SetItemId(item_id);
		party_window->SetItemId(item_id);

		if (item_id > 0 && Data::items[item_id - 1].price > 0) {
			RPG::Item& item = Data::items[item_id - 1];
			Game_System::SePlay(Data::system.decision_se);
			number_window->SetData(item_id, Game_Party::ItemNumber(item_id), item.price);
			SetMode(SellHowMany);
		}
		else {
			Game_System::SePlay(Data::system.buzzer_se);
		}
	}
}
Ejemplo n.º 24
0
/*======================================================================
	Function:		DisplayMessage
	Input:			pointer to zero terminated message data in EEPROM memory
	Output:			pointer to next message
	Description:	Show a message (i. e. text or animation) on the display.

					Escape characters:

					Character '^' is used to access special characters by 
					shifting the character code of the next character by 96 
					so that e. g. '^A' becomes char(161).
					To enter a '^' character simply double it: '^^'

					Character '~' followed by an upper case letter is used
					to insert (animation) data from flash.
					
					The character 0xFF is used to enter direct mode in which 
					the following bytes are directly written to the display 
					memory without being decoded using the character font.
					Direct mode is ended by 0xFF.
======================================================================*/
uint8_t* DisplayMessage(uint8_t* ee_adr)
{
	uint8_t ch, m;

	m = eeprom_read_byte(ee_adr);
	SetMode(m);
	ee_adr++;
	dmClearDisplay();

	ch = eeprom_read_byte(ee_adr++);
	while (ch) {
		if (ch == '~') {					// animation
			ch = eeprom_read_byte(ee_adr++);
			if (ch != '~') {
				ch -= 'A';
				if (ch < ANIMATION_COUNT) {
					dmDisplayImage((const uint8_t*)pgm_read_word(&animation[ch]));
				}				
			}
			else {
				dmPrintChar('~');
			}
		}
		else if (ch == 0xFF) {				// direct mode
			ch = eeprom_read_byte(ee_adr++);
			while (ch != 0xFF) {
				dmPrintByte(ch);
				ch = eeprom_read_byte(ee_adr++);
			}
		}
		else {								// character
			if (ch == '^') {				// special character
				ch = eeprom_read_byte(ee_adr++);
				if (ch != '^') {
					ch += 63;
				}
			}
			dmPrintChar(ch);
		}
		ch = eeprom_read_byte(ee_adr++);
		if (!(m & MODE_FRAME)) {			// for scrolling texts
			if (ch) { dmPrintByte(0); }		// print a narrow space between characters, except for the last one
		}
	}
	ch = eeprom_read_byte(ee_adr);			// read mode byte of next message
	if (ch)		{ return(ee_adr); }
		else	{ return((uint8_t*) messages); }	// restart all-over if mode byte is 0
}
Ejemplo n.º 25
0
t_gba		*gba_init(const s32 mode, const u8 repeat)
{
  t_gba		*gba;

  if ((gba = malloc(sizeof(*gba))) == NULL)
    return (NULL);
  irqInit();
  irqEnable(IRQ_VBLANK);
  REG_IME = 1;
  gba->screen = (u16*)0x6000000;
  SetMode(mode);
  gba->key = NULL;
  gba->key_param = NULL;
  gba->key_repeat = repeat;
  return (gba);
}
Ejemplo n.º 26
0
void Scene_Shop::UpdateCommandSelection() {
	if (Input::IsTriggered(Input::CANCEL)) {
		Game_System::SePlay(Game_System::GetSystemSE(Game_System::SFX_Cancel));
		Scene::Pop();
	} else if (Input::IsTriggered(Input::DECISION)) {
		switch (shop_window->GetChoice()) {
			case Buy:
			case Sell:
				SetMode(shop_window->GetChoice());
				break;
			case Leave:
				Scene::Pop();
				break;
		}
	}
}
Ejemplo n.º 27
0
void Vid::Init() {
	WNDCLASSEX Wc = { 0 };
	Wc.cbSize = sizeof( Wc );
	Wc.lpfnWndProc = MainWndProc;
	Wc.hInstance = GlobalInstance;
	Wc.hCursor = LoadCursor( nullptr, IDC_ARROW );
	Wc.lpszClassName = "Handmade Quake";

	if ( !RegisterClassEx( &Wc ) )
		exit( EXIT_FAILURE );

	InitWindowedMode();
	InitFullscreenMode();

	SetMode( 0 );
}
Ejemplo n.º 28
0
void setup() {
pinMode(4, INPUT); //set the second encoder channel up
attachInterrupt(0, integrate, RISING);
Serial.begin(9600);
digitalWrite(motorEnablePin, LOW); //safety
digitalWrite(motorDirectionPin, LOW); //safety
digitalWrite(motorDrivePin, HIGH); //safety

//pid setup
SetMode(AUTOMATIC); //auto PID mode
SetTunings(1, 0, 0);
SetOutputLimits(-3, 3); //+-24V maximum
SetSampleTime(5); //something smaller than the loop delay
Setpoint = 12.56;
digitalWrite(motorEnablePin, HIGH); //let it go
}
Ejemplo n.º 29
0
//-----------------------------------------------------------------------------
//!
//-----------------------------------------------------------------------------
void tEditExpandSideBar::Collapse( bool animate )
{
    int offset = 0;
    if( animate )
    {
        AnimateTo( offset );
    }
    else
    {
        MoveTo( offset );
    }
    m_ExpandedView = false;

    UpdateExpandCollapseItem();
    SetMode( eBarMode_Normal );
}
void ExpandedLEDSerialControllerMega::LEDSerialProcess () {
  while (Serial1.available() > 0)
  {
    char c = char(Serial1.read());
    if (c != ';') {
      serialIn += c;
    }
    else {
      Translator (serialIn.c_str(), activeMode, activeState);
      serialIn = "";
    }
  }

  SetMode (activeMode);
  SetState (activeState);
}