示例#1
0
// set spi_flash_info struction content
void set_flash_info(unsigned char ucChip, unsigned int chip_id, unsigned int device_cap, unsigned int block_size, unsigned int sector_size, unsigned int page_size, char* chip_name, FUNC_ERASE pfErase, FUNC_READ pfRead, FUNC_SETQEBIT pfQeBit, FUNC_PAGEWRITE pfPageWrite, unsigned int chipClock)
{
	unsigned int ui = 1 << device_cap;
	spi_flash_info[ucChip].chip_id = chip_id;
	spi_flash_info[ucChip].mfr_id = (chip_id >> 16) & 0xff;
	spi_flash_info[ucChip].dev_id = (chip_id >> 8) & 0xff;
	spi_flash_info[ucChip].capacity_id = (chip_id) & 0xff;
	spi_flash_info[ucChip].size_shift = calShift(spi_flash_info[ucChip].capacity_id, device_cap);
	spi_flash_info[ucChip].device_size = device_cap;			// 2 ^ N (bytes)
	spi_flash_info[ucChip].chip_size =  ui;
	spi_flash_info[ucChip].block_size = block_size;
	spi_flash_info[ucChip].block_cnt = ui / block_size;
	spi_flash_info[ucChip].sector_size = sector_size;
	spi_flash_info[ucChip].sector_cnt = ui / sector_size;
	spi_flash_info[ucChip].page_size = page_size;
	spi_flash_info[ucChip].page_cnt = sector_size / page_size;
	spi_flash_info[ucChip].chip_name = chip_name;
	spi_flash_info[ucChip].pfErase = pfErase;
	spi_flash_info[ucChip].pfWrite = ComSrlCmd_ComWriteData;
	spi_flash_info[ucChip].pfRead = pfRead;
	spi_flash_info[ucChip].pfQeBit = pfQeBit;
	spi_flash_info[ucChip].pfPageWrite = pfPageWrite;
	spi_flash_info[ucChip].chipClock = chipClock;
	//SPI_REG_LOAD(SFCR2, 0x0bb08000);
	LDEBUG("set_flash_info: ucChip=%x; chip_id=%x; device_cap=%x; block_size=%x; sector_size=%x; page_size=%x; chip_name=%s\n", ucChip, chip_id, device_cap, block_size, sector_size, page_size, chip_name);
}
示例#2
0
void DetectingStage::drawGameplay(){

	//get guage
	Rectf gaugeRect = Rectf(0.0f, 0.0f, getWindowWidth(), getWindowHeight());
	//Texture guageTexture = guageVid_.getTexture();


	/////calculate phub time
	//int phubH = timePhub_ / 3600;
	//int phubM = (timePhub_ / 60) % 60;
	//int phubS = timePhub_ % 60;

	//
	//string phubHS,phubMS, phubSS,phubString;
	//if (phubH < 10) phubHS = "0" + toString(phubH);
	//else phubHS = toString(phubH);

	//if (phubM < 10) phubMS = "0" + toString(phubM);
	//else phubMS = toString(phubM);

	//if (phubS < 10) phubSS = "0" + toString(phubS);
	//else phubSS = toString(phubS);

	//phubString = phubHS + ":" + phubMS + ":" + phubSS;

	/////calculate talk string
	//int talkH = timeTalk_ / 3600;
	//int talkM = (timeTalk_ / 60) % 60;
	//int talkS = timeTalk_ % 60;

	//string talkHS, talkMS, talkSS, talkString;
	//if (talkH < 10) talkHS = "0" + toString(talkH);
	//else talkHS = toString(talkH);

	//if (talkM < 10) talkMS = "0" + toString(talkM);
	//else talkMS = toString(talkM);

	//if (talkS < 10) talkSS = "0" + toString(talkS);
	//else talkSS = toString(talkS);

	//talkString = talkHS + ":" + talkMS + ":" + talkSS;

	////draw red green rect
	//Rectf greenRect = Rectf(0.0f, 0.0f, getWindowWidth(), getWindowHeight()*0.15f);
	//Rectf redRect = Rectf(0.0f, 0.0f, (getWindowWidth()*currentRatio_), getWindowHeight()*0.15f);
	//gl::color(67.f/255.f, 193.f/255.f, 30.f/255.f);
	////drawSolidRect(greenRect);
	//gl::color(255.f/255.f, 54.f/255.f, 54.f/255.f);
	////drawSolidRect(redRect);
	//gl::color(1, 1, 1);
	
	
	//draw sticker
	for (int i = 0; i < persons_.size(); i++){
		if (persons_[i].unDetectFrame <= 180){
			if (!isDebugMode) gl::color(Color(CM_HSV, facesColor_[persons_[i].id], 0.77f, 0.96f));
			else gl::color(1, 1, 1, 0.5);
			//choose correct texture for each person
			Texture stickerTexture;

			if (persons_[i].getLook() == LOOKUP) {
				if (persons_[i].segtion == LEFT) {
					if (persons_[i].gender == MALE) stickerTexture = smileLeftMaleTexture_;
					else if (persons_[i].gender == FEMALE) stickerTexture = smileLeftFemaleTexture_;
					else stickerTexture = smileLeftTexture_;
				}
				else if (persons_[i].segtion == CENTER) {
					if (persons_[i].gender == MALE) stickerTexture = smileMaleTexture_;
					else if (persons_[i].gender == FEMALE) stickerTexture = smileFemaleTexture_;
					else stickerTexture = smileTexture_;
				}
				else if (persons_[i].segtion == RIGHT) {
					if (persons_[i].gender == MALE) stickerTexture = smileRightMaleTexture_;
					else if (persons_[i].gender == FEMALE) stickerTexture = smileRightFemaleTexture_;
					else stickerTexture = smileRightTexture_;
				}
			}
			else if (persons_[i].getLook() == LOOKDOWN) {
				if (persons_[i].segtion == LEFT) {
					if (persons_[i].gender == MALE) stickerTexture = seriousLeftMaleTexture_;
					else if (persons_[i].gender == FEMALE) stickerTexture = seriousLeftFemaleTexture_;
					else stickerTexture = seriousLeftTexture_;
				}
				else if (persons_[i].segtion == CENTER) {
					if (persons_[i].gender == MALE) stickerTexture = seriousMaleTexture_;
					else if (persons_[i].gender == FEMALE) stickerTexture = seriousFemaleTexture_;
					else stickerTexture = seriousTexture_;
				}
				else if (persons_[i].segtion == RIGHT) {
					if (persons_[i].gender == MALE) stickerTexture = seriousRightMaleTexture_;
					else if (persons_[i].gender == FEMALE) stickerTexture = seriousRightFemaleTexture_;
					else stickerTexture = seriousRightTexture_;
				}
			}
			else if (persons_[i].getLook() == TURNLEFT) {
				if (persons_[i].gender == MALE) stickerTexture = turnLeftMaleTexture_;
				else if (persons_[i].gender == FEMALE) stickerTexture = turnLeftFemaleTexture_;
				else stickerTexture = turnLeftTexture_;
			}
			else if (persons_[i].getLook() == TURNRIGHT) {
				if (persons_[i].gender == MALE) stickerTexture = turnRightMaleTexture_;
				else if (persons_[i].gender == FEMALE) stickerTexture = turnRightFemaleTexture_;
				else stickerTexture = turnRightTexture_;
			}

			//adjust position and size
			float frameSize = 120.f / (persons_[i].depth / 1000.f);
			float ratio = frameSize / 60.f;

			Vec2f shift(param_shiftX_, param_shiftY_);
			Vec2f scale(param_scale_ * ratio, param_scale_ * ratio);

			//calibrate position for each segment
			Vec2f calShift(0, 0);
			if (persons_[i].segtion == LEFT) calShift.x = -param_calShift_;
			else if (persons_[i].segtion == RIGHT) calShift.x = param_calShift_;
			else calShift.x = 0;

			Rectf stickerRect = Rectf(persons_[i].center - scale + shift + calShift,
				persons_[i].center + scale + shift + calShift);
			if (stickerTexture){
				glEnable(GL_BLEND);
				glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
				displayArea_.draw(stickerTexture, stickerRect);
				ci::gl::disableAlphaBlending();
				glDisable(GL_BLEND);
			}
		}
	}
	gl::color(1, 1, 1);

	//draw guage
	if (gaugeTexture_){
		glEnable(GL_BLEND);
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
		displayArea_.draw(gaugeTexture_, gaugeRect);
		//draw rect
		float gaugeRatio = gaugeValue_ / gaugeMax_;
		Rectf blackRect = Rectf(getWindowWidth()*0.287f, getWindowHeight()*0.1485f, (getWindowWidth()*0.287f) + (getWindowWidth()*0.475f*gaugeRatio), getWindowHeight()*0.171f);
		gl::color(0, 0, 0);
		drawSolidRect(blackRect);
		gl::color(1, 1, 1);

		float hurtRatio = hurtValue_ / hurtMax_;
		float fade = 0;
		float maxStage = 30.0;
		if (bloodStage_ > 100) bloodStage_ = 0;
		if (bloodStage_ < maxStage) fade = bloodStage_ * (100.f / maxStage);
		else {
			int diff = bloodStage_ - maxStage;
			fade = 100 - (diff * (100.f / (100.f - maxStage)));
		}
		bloodStage_++;

		gl::color(1, 1, 1, (fade / 100.f)*hurtRatio);

		int second = getElapsedSeconds();
		int result = second % 2;
		if (bloodTexture_ && status_ == PHUB){
			Rectf bloodRect = Rectf(0, 0, getWindowWidth(), getWindowHeight());
			displayArea_.draw(bloodTexture_, bloodRect);
			timeStamp_ = second;
		}

		glDisable(GL_BLEND);
	}

	gl::color(1, 1, 1);
}