示例#1
0
bool GiGdipImage::save(const wchar_t* filename, ULONG quality)
{
    bool ret = false;
    WCHAR format[20];
    CLSID clsidEncoder;
    
    if (this != NULL && getWidth() > 0
        && getEncoder(filename, format, clsidEncoder))
    {
        if (lstrcmpW(L"image/jpeg", format) == 0)
        {
            G::EncoderParameters encoderParameters;
            
            encoderParameters.Count = 1;
            encoderParameters.Parameter[0].Guid = G::EncoderQuality;
            encoderParameters.Parameter[0].Type = G::EncoderParameterValueTypeLong;
            encoderParameters.Parameter[0].NumberOfValues = 1;
            encoderParameters.Parameter[0].Value = &quality;
            
            ret = (G::Ok == m_impl->bmp->Save(filename, &clsidEncoder, &encoderParameters));
        }
        else
        {
            ret = (G::Ok == m_impl->bmp->Save(filename, &clsidEncoder, NULL));
        }
    }
    
    return ret;
}
示例#2
0
bool teo::CanBusControlboard::getEncoders(double *encs) {
    //CD_INFO("\n");  //-- Too verbose in stream.

    bool ok = true;
    for(unsigned int i=0; i < nodes.size(); i++)
        ok &= getEncoder(i,&(encs[i]));
    return ok;
}
示例#3
0
int Encoder::getAbsolute()

{
  _pos = getEncoder();
  if (_lastPos > 0x0300 && _pos < 0x00FF)_metaPos++;
  if (_lastPos < 0x00FF && _pos > 0x0300)_metaPos--;
  _pos1 = _metaPos << 10;
  _pos1 = _pos1 | _pos;
  _lastPos = _pos;
  return _pos1;
}
示例#4
0
/**
 * Gets the raw value from the encoder.
 *
 * The raw value is the actual count unscaled by the 1x, 2x, or 4x scale
 * factor.
 *
 * @return Current raw count from the encoder
 */
int32_t Encoder::GetRaw() const {
  if (StatusIsFatal()) return 0;
  int32_t value;
  if (m_counter)
    value = m_counter->Get();
  else {
    int32_t status = 0;
    value = getEncoder(m_encoder, &status);
    wpi_setErrorWithContext(status, getHALErrorMessage(status));
  }
  return value;
}
示例#5
0
/*
 * Class:     edu_wpi_first_wpilibj_hal_EncoderJNI
 * Method:    getEncoder
 * Signature: (J)I
 */
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_getEncoder
  (JNIEnv * env, jclass, jlong id)
{
	ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI getEncoder";
	ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << (void*)id;
	int32_t status = 0;
	jint returnValue = getEncoder((void*)id, &status);
	ENCODERJNI_LOG(logDEBUG) << "Status = " << status;
	ENCODERJNI_LOG(logDEBUG) << "getEncoderResult = " <<  returnValue;
	CheckStatus(env, status);
	return returnValue;
}
示例#6
0
/*
 * Class:     edu_wpi_first_wpilibj_hal_EncoderJNI
 * Method:    getEncoder
 * Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)I
 */
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_getEncoder
(JNIEnv * env, jclass, jobject id, jobject status)
{
    ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI getEncoder";
    void ** javaId = (void**)env->GetDirectBufferAddress(id);
    ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << *javaId;
    jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
    ENCODERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
    jint returnValue = getEncoder(*javaId, statusPtr);
    ENCODERJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
    ENCODERJNI_LOG(logDEBUG) << "getEncoderResult = " <<  returnValue;
    return returnValue;
}
uint32_t IntelHWComposerDrm::getCrtcId(int disp)
{
    if (mDrmFd < 0) {
        ALOGE("%s: invalid drm FD\n", __func__);
        return 0;
    }

    drmModeEncoderPtr encoder = NULL;
    drmModeResPtr resources = NULL;
    drmModeCrtcPtr crtc = NULL;
    uint32_t crtc_id = 0;
    int i = 0;

    if ((encoder = getEncoder(disp)) == NULL)
        return 0;

    crtc_id = encoder->crtc_id;
    freeEncoder(encoder);

    if (crtc_id == 0) {
        /* Query an available crtc to use */
        if ((resources = drmModeGetResources(mDrmFd)) == NULL)
            return 0;

        if (!resources->crtcs)
            return 0;

        for (i = 0; i < resources->count_crtcs; i++) {
            crtc = drmModeGetCrtc(mDrmFd, resources->crtcs[i]);
            if (!crtc) {
                ALOGE("%s: Failed to get crtc %d, error is %s",
                        __func__, resources->crtcs[i], strerror(errno));
                continue;
            }
            if (crtc->buffer_id == 0) {
                crtc_id = crtc->crtc_id;
                drmModeFreeCrtc(crtc);
                break;
            }
            drmModeFreeCrtc(crtc);
        }
    }

    return crtc_id;
}
示例#8
0
void receive_task(){

		if(Receive_String_Ready){

			//forward step by step 
			if(received_string[0] == '+'){
				SpeedValue_left += inc;
				SpeedValue_right += inc;
				mMove(SpeedValue_left,SpeedValue_right);
				USART_puts(USART3, "left:");
				USART_putd(USART3, SpeedValue_left);
				USART_puts(USART3, " right:");
				USART_putd(USART3, SpeedValue_right);
				USART_puts(USART3, "\r\n");
			}

			//backward step by step
			else if(received_string[0] == '-'){
				SpeedValue_left -= inc;
				SpeedValue_right -= inc;
				mMove(SpeedValue_left, SpeedValue_right);
				USART_puts(USART3, "left:");
				USART_putd(USART3, SpeedValue_left);
				USART_puts(USART3, " right:");
				USART_putd(USART3, SpeedValue_right);
				USART_puts(USART3, "\r\n");
			}

			//forward
			else if(received_string[0] == 'p'){
				forward();
			}

			//PID
			else if(received_string[0] == 'f'){
				test_PID_forward();
			}

			//backward
			else if(received_string[0] == 'b'){
				test_PID_backward();
			}

			//left
			else if(received_string[0] == 'l'){
				test_PID_left();
			}

			//right
			else if(received_string[0] == 'r'){
				test_PID_right();
			}

			//stop
			else if(received_string[0] == 's'){
				stop();
			}

			//Linear Acturator
			else if(received_string[0] == 'a'){
			    	USART_puts(USART3, "Actu_A_up");
			    	set_linearActuator_A_cmd(LINEAR_ACTU_CW);
			    	USART_puts(USART3, "\r\n");
			    }

			else if(received_string[0] == 'n'){
			    	USART_puts(USART3, "Actu_A_down");
			    	//set_linearActuator_A_cmd(LINEAR_ACTU_CCW);
			    	USART_puts(USART3, "\r\n");
			    	set_linearActuator_A_cmd(LINEAR_ACTU_CCW);
			    }
			else if(received_string[0] == 'd'){
			    	USART_puts(USART3, "Actu_A_stop");
			    	//set_linearActuator_A_cmd(LINEAR_ACTU_CCW);
			    	USART_puts(USART3, "\r\n");
			    	set_linearActuator_A_cmd(LINEAR_ACTU_STOP);
			    }

			else if(received_string[0] == 'u'){
			    	USART_puts(USART3, "Actu_B_up");
			    	set_linearActuator_B_cmd(LINEAR_ACTU_CW);
			    	USART_puts(USART3, "\r\n");
				}

				
			else if(received_string[0] == 'k'){
			    	USART_puts(USART3, "Actu_B_down");
			    	//set_linearActuator_B_cmd(LINEAR_ACTU_CCW);
			    	USART_puts(USART3, "\r\n");
			    	set_linearActuator_B_cmd(LINEAR_ACTU_CCW);
				}

			else if(received_string[0] == 'w'){
			    	USART_puts(USART3, "Actu_B_stop");
			    	//set_linearActuator_B_cmd(LINEAR_ACTU_CCW);
			    	USART_puts(USART3, "\r\n");
			    	set_linearActuator_B_cmd(LINEAR_ACTU_STOP);
				}

			//get encoder
			else if(received_string[0] == 'e'){
				getEncoder();
			}

			//test
			else if(received_string[0] == 't'){
				test_forward();
			}

		}
}
示例#9
0
	VMIME_TEST_LIST_END


	void testBase64()
	{
		static const vmime::string testSuites[] =
		{
			// Test 1
			"",

			"",

			// Test 2
			"A",

			"QQ==",

			// Test 3
			"AB",

			"QUI=",

			// Test 4
			"ABC",

			"QUJD",

			// Test 5
			"foo",

			"Zm9v",

			// Test 6
			"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",

			"QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAx"
			"MjM0NTY3ODk=",

			// Test 7
			vmime::string(
			"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
			"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
			"\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f"
			"\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f"
			"\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f"
			"\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f"
			"\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f"
			"\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"
			"\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
			"\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
			"\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
			"\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
			"\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
			"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
			"\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef"
			"\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
			256),

			"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1"
			"Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWpr"
			"bG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6Ch"
			"oqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX"
			"2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w=="
		};


		for (unsigned int i = 0 ; i < sizeof(testSuites) / sizeof(testSuites[0]) / 2 ; ++i)
		{
			const vmime::string decoded = testSuites[i * 2];
			const vmime::string encoded = testSuites[i * 2 + 1];

			std::ostringstream oss;
			oss << "[Base64] Test " << (i + 1) << ": ";

			// Encoding
			VASSERT_EQ(oss.str() + "encoding", encoded, encode("base64", decoded));

			// Decoding
			VASSERT_EQ(oss.str() + "decoding", decoded, decode("base64", encoded));

			// Multiple and successive encoding/decoding
			VASSERT_EQ(oss.str() + "multiple1", decoded,
				decode("base64",
					encode("base64", decoded)));

			VASSERT_EQ(oss.str() + "multiple2", decoded,
				decode("base64",
					decode("base64",
						encode("base64",
							encode("base64", decoded)))));

			VASSERT_EQ(oss.str() + "multiple3", decoded,
				decode("base64",
					decode("base64",
						decode("base64",
							encode("base64",
								encode("base64",
									encode("base64", decoded)))))));

			VASSERT_EQ(oss.str() + "multiple4", decoded,
				decode("base64",
					decode("base64",
						decode("base64",
							decode("base64",
								encode("base64",
									encode("base64",
										encode("base64",
											encode("base64", decoded)))))))));

			VASSERT(oss.str() + "encoded size",
				getEncoder("base64")->getEncodedSize(decoded.length())
				>= encode("base64", decoded).length());

			VASSERT(oss.str() + "decoded size",
				getEncoder("base64")->getDecodedSize(encoded.length())
				>= decode("base64", encoded).length());
		}
	}
示例#10
0
文件: main.c 项目: WiseLord/volmatrix
int main(void)
{
	int8_t encCnt = 0;
	uint8_t cmd = CMD_END;

	static uint8_t dispPrev = MODE_STANDBY;

	rcInit();
	sndInit();
	matrixInit();
	sei();

	_delay_ms(100);
	powerOff();

	while(1) {
		encCnt = getEncoder();
		cmd = getCmdBuf();

		/* If no command from buttons, try remote control */
		if (cmd == CMD_END)
			cmd = getRcBuf();

		/* Don't handle commands in standby mode except some */
		if (dispMode == MODE_STANDBY) {
			encCnt = 0;
			if (cmd != CMD_RC_STBY && cmd != CMD_BTN_1 && cmd != CMD_BTN_1_2_LONG)
				cmd = CMD_END;
		}
		/* Don't handle buttons in learn mode except some */
		if (dispMode == MODE_LEARN) {
			if (encCnt || cmd != CMD_END)
				displayTime = TIMEOUT_LEARN;
			if (cmd != CMD_BTN_1_LONG && cmd != CMD_BTN_3)
				cmd = CMD_END;
		}

		/* Handle command */
		switch (cmd) {
		case CMD_RC_STBY:
		case CMD_BTN_1:
			if (dispMode == MODE_STANDBY)
				powerOn();
			else
				powerOff();
			break;
		case CMD_RC_MUTE:
		case CMD_BTN_2:
			if (dispMode == MODE_TIME_EDIT) {
				rtcNextEditParam();
				displayTime = TIMEOUT_TIME_EDIT;
			} else {
				if (aproc.mute) {
					sndSetMute(0);
					dispMode = MODE_SND_VOLUME;
				} else {
					sndSetMute(1);
					dispMode = MODE_MUTE;
				}
				displayTime = TIMEOUT_AUDIO;
			}
			break;
		case CMD_RC_MENU:
		case CMD_BTN_3:
			if (dispMode == MODE_LEARN) {
				nextRcCmd();
			} else {
				sndNextParam(&dispMode);
				displayTime = TIMEOUT_AUDIO;
			}
			break;
		case CMD_RC_RED:
		case CMD_RC_GREEN:
		case CMD_RC_YELLOW:
		case CMD_RC_BLUE:
			sndSetInput(cmd - CMD_RC_RED);
			dispMode = MODE_SND_GAIN0 + (cmd - CMD_RC_RED);
			displayTime = TIMEOUT_AUDIO;
			break;
		case CMD_BTN_1_LONG:
			switch (dispMode) {
			case MODE_STANDBY:
			case MODE_LEARN:
				powerOff();
				break;
			default:
				dispMode = MODE_BRIGHTNESS;
				displayTime = TIMEOUT_BR;
				break;
			}
			break;
		case CMD_BTN_2_LONG:
			switch (dispMode) {
			case MODE_TIME_EDIT:
				dispMode = MODE_TIME;
				rtc.etm = RTC_NOEDIT;
				break;
			default:
				dispMode = MODE_TIME_EDIT;
				rtc.etm = RTC_HOUR;
				displayTime = TIMEOUT_TIME_EDIT;
				break;
			}
			break;
		case CMD_RC_NEXT:
		case CMD_BTN_3_LONG:
			if (dispMode >= MODE_SND_GAIN0 && dispMode < MODE_SND_END)
				aproc.input++;
			sndSetInput(aproc.input);
			dispMode = MODE_SND_GAIN0 + aproc.input;
			displayTime = TIMEOUT_AUDIO;
			break;
		case CMD_BTN_1_2_LONG:
			if (dispMode == MODE_STANDBY)
				dispMode = MODE_LEARN;
			switchTestMode(CMD_RC_STBY);
			displayTime = TIMEOUT_LEARN;
			break;
		}

		/* Emulate RC VOL_UP/VOL_DOWN as encoder actions */
		if (cmd == CMD_RC_VOL_UP)
			encCnt++;
		if (cmd == CMD_RC_VOL_DOWN)
			encCnt--;

		/* Handle encoder */
		if (encCnt) {
			switch (dispMode) {
			case MODE_STANDBY:
			case MODE_LEARN:
				break;
			case MODE_TIME_EDIT:
				displayTime = TIMEOUT_TIME_EDIT;
				rtcChangeTime(encCnt);
				break;
			case MODE_BRIGHTNESS:
				changeBrWork(encCnt);
				displayTime = TIMEOUT_BR;
				break;
			case MODE_MUTE:
			case MODE_LOUDNESS:
			case MODE_TIME:
				dispMode = MODE_SND_VOLUME;
			default:
				sndSetMute(0);
				sndChangeParam(dispMode, encCnt);
				displayTime = TIMEOUT_AUDIO;
				break;
			}
		}

		/* Exid to default mode if timer expired */
		if (displayTime == 0) {
			if (dispMode == MODE_LEARN || dispMode == MODE_STANDBY) {
				dispMode = MODE_STANDBY;
			} else {
				rtc.etm = RTC_NOEDIT;
				if (aproc.mute)
					dispMode = MODE_MUTE;
				else
					dispMode = MODE_TIME;
			}
		}

		/* Show things */
		switch (dispMode) {
		case MODE_STANDBY:
			showStby();
			break;
		case MODE_MUTE:
			showMute();
			break;
		case MODE_LOUDNESS:
			showLoudness();
			break;
		case MODE_LEARN:
			showLearn();
			break;
		case MODE_TIME:
		case MODE_TIME_EDIT:
			showTime();
			break;
		case MODE_BRIGHTNESS:
			showBrWork();
			break;
		default:
			showSndParam(dispMode, ICON_NATIVE);
			break;
		}

		if (dispMode == dispPrev)
			updateScreen(EFFECT_NONE, dispMode);
		else
			updateScreen(EFFECT_SPLASH, dispMode);

		dispPrev = dispMode;
	}

	return 0;
}
示例#11
0
int main(void)
{
	int8_t encCnt = 0;
	uint8_t action = ACTION_NOACTION;

	/* Init hardware */
	hwInit();
	#if 0
	if (extFunc == USE_DS18B20) {
		ds18x20ConvertTemp();
		setSensTimer(TEMP_MEASURE_TIME);
	}
	#endif
	while (1) {
		#if 0
		/* Control temperature */
		if (extFunc == USE_DS18B20) {
			if (getSensTimer() == 0) {
				ds18x20GetAllTemps();
				ds18x20ConvertTemp();
				setSensTimer(SENSOR_POLL_INTERVAL);
			}
			tempControlProcess();
		}
		#endif
		/* Emulate poweroff if any of timers expired */
		if (getStbyTimer() == 0 || getSilenceTimer() == 0)
			action = CMD_RC_STBY;

		/* Check alarm and update time */
		if (action == ACTION_NOACTION)
			action = checkAlarmAndTime();

		/* Convert input command to action */
		if (action == ACTION_NOACTION)
			action = getAction();

		/* Handle action */
		handleAction(action);

		/* Handle encoder */
		encCnt = getEncoder();				/* Get value from encoder */
		if (action == CMD_RC_VOL_UP)		/* Emulate VOLUME_UP action as encoder action */
			encCnt++;
		if (action == CMD_RC_VOL_DOWN)	/* Emulate VOLUME_DOWN action as encoder action */
			encCnt--;
		handleEncoder(encCnt);

		/* Reset silence timer on any action */
		if (encCnt || (action != ACTION_NOACTION && action != ACTION_EXIT_STANDBY))
			enableSilenceTimer();

		/* Reset handled action */
		action = ACTION_NOACTION;

		/* Check if we need exit to default mode*/
		handleExitDefaultMode();

		/* Switch to timer mode if it expires */
		handleTimers();

		/* Clear screen if mode has changed */
		handleModeChange();

		/* Show things */
		showScreen();
	}

	return 0;
}