コード例 #1
0
int main(void)
{
	union uKeyRoster scan;
    init();    

    while (1)
    {
		wait_for_press();
		// Result is stored in prev_keys & keys and hopefully keys2

		SET_LED_1();
		scan = pack_array( keys );
		build_key_list   ( keys );

		if (isConfigured(MODE_SEND_ROSTER)==0)		{
			can_prep_button_roster_msg( &msg1, scan );
			can_send_msg_no_wait( CAN_TRANSMIT_CHANNEL1, &msg1 );
		}
		if (isConfigured(MODE_SEND_PRESSED)==0)		{
			can_prep_button_pressed_msg( &msg2 );
			can_send_msg_no_wait( CAN_TRANSMIT_CHANNEL2, &msg2 );
	    }
		RESET_LED_1();
    }
    return(0);
} 
コード例 #2
0
/* Callback function (from the CAN ISR()).  
	Parse the Msg based on the msg id. 
#define ID_MARK_MOTOR_STOP				0x0040		 1 or 2 in data[0]
		Set Stop 1	(Mark the current motor position as Stop 1 - angle given)
#define ID_MOVE_TO_ANGLE				0x0042		 Instance goes with intended Receiver
#define ID_MOVE_SPEED					0x0043
#define ID_SET_MAX_MOTOR_ACCEL			0x0044		*/
void can_file_message( sCAN* mMsg )
{
	if ( id_match( mMsg->id, create_CAN_eid(ID_MARK_MOTOR_STOP, MyInstance)) )
	{
		can_proc_set_stop_msg( mMsg );
		// Save EEPROM
		save_cal(  );	// defined in pot.c
	}
	else if ( id_match(mMsg->id, create_CAN_eid(ID_MOVE_TO_ANGLE, MyInstance)) )
	{
		// includes a speed
		can_proc_move_to_angle_msg( mMsg );
		// Initiate Motor
	}	
/*	else if ( id_match(mMsg->id, create_CAN_eid(ID_MOVE_SPEED, MyInstance)) )	
	{
		can_proc_move_speed_msg( mMsg );
	} */
	else if ( id_match(mMsg->id, create_CAN_eid(ID_SET_MAX_MOTOR_ACCEL, MyInstance)) )	
	{	
		can_proc_max_acceleration_msg( mMsg );
	}
	else if ( (isConfigured(MODE_TILT_RESPONDER)) && 
			  (id_match(mMsg->id, create_CAN_eid(ID_ACCEL_XYZ, 0)) ) )
	{
		can_proc_tilt_msg( mMsg );
		
	}
}
bool JointControllerManager::startHook()
{
  // Check that component is configured
  if (!isConfigured())
  {
    PAL_ERROR("Failed to start joint controller manager: Component has not yet been configured.");
    return false;
  }

  // Start joint interface
  if (!joint_iface_->start())
  {
    PAL_ERROR("Failed to start joint controller manager: Could not start low level joint access.");
    return false;
  }

  // Update current time
  updateCurrentTime();

  // Update current state
  if (!updateCurrentState())
  {
    PAL_ERROR("Failed to start joint controller manager: Could not update current state.");
    return false;
  }

  // Auto-start controllers
  if (!autoStartComponents())
  {
    return false;
  }

  return true;
}
コード例 #4
0
ファイル: ledmatrix.cpp プロジェクト: neomilium/minotor
void LedMatrix::prepareFramebuffer()
{
    if(isConfigured())
    {
        _framebuffer.resize(size().width()*size().height()*3);
    }
}
コード例 #5
0
ファイル: ledmatrix.cpp プロジェクト: neomilium/minotor
void LedMatrix::computeLookUpTable()
{
    if(isConfigured())
    {
        const unsigned int matrix_panel_width_in_pixels = _panelSize.width();
        const unsigned int matrix_panel_height_in_pixels = _panelSize.height();

        const unsigned int matrix_width_in_panel = _matrixSize.width();
        //const unsigned int matrix_height_in_panel = _matrixSize.height();

        const unsigned int matrix_width_in_pixels = size().width();
        const unsigned int matrix_height_in_pixels = size().height();

        _pixelsLUT.clear();
        _pixelsLUT.resize(matrix_height_in_pixels*matrix_width_in_pixels);

        for (unsigned int y=0;y<matrix_height_in_pixels;y++)
        {
            for (unsigned int x=0;x<matrix_width_in_pixels;x++) {
                const unsigned int x_panel_id = (y%2)
                        ?((matrix_panel_width_in_pixels-1)-(x%matrix_panel_width_in_pixels))
                       :(x%matrix_panel_width_in_pixels);
                const unsigned int y_panel_id = (y%matrix_panel_height_in_pixels);
                const unsigned int panel_id = ((y/matrix_panel_height_in_pixels)%2)
                        ?((matrix_width_in_panel-1)-(x/matrix_panel_width_in_pixels)) + ((y/matrix_panel_height_in_pixels) * matrix_width_in_panel)
                       :(x/matrix_panel_width_in_pixels) + ((y/matrix_panel_height_in_pixels) * matrix_width_in_panel);

                const unsigned int id = x_panel_id + (y_panel_id*matrix_panel_width_in_pixels) + (panel_id*matrix_panel_width_in_pixels*matrix_panel_height_in_pixels);
                const unsigned int i = x+(y*matrix_width_in_pixels);
                Q_ASSERT(i<(unsigned int)_pixelsLUT.size());
                _pixelsLUT.data()[i] = id;
            }
        }
    }
}
コード例 #6
0
ファイル: iotoaster.cpp プロジェクト: brenovit/Radioino
void IOToaster::setup()
{
	// Set the pin configuration
	setupPins();

	// Open serial communication
	Serial.begin(9600);
	Serial.setTimeout(5000);	

	// Load the configuration
	if (isConfigured())
	{
		// Normal mode
		_setupMode = false;
		loadConfiguration();	
		connectServer();
		setActivityLedState(HIGH);		
	}
		
	else {
		// Setup mode
		setActivityLedState(LOW);
		_setupMode = true;		
		createServer();
	}
}
コード例 #7
0
OMX_ERRORTYPE SoftAMR::internalGetParameter(
        OMX_INDEXTYPE index, OMX_PTR params) {
    switch (index) {
        case OMX_IndexParamAudioAmr:
        {
            OMX_AUDIO_PARAM_AMRTYPE *amrParams =
                (OMX_AUDIO_PARAM_AMRTYPE *)params;

            if (amrParams->nPortIndex != 0) {
                return OMX_ErrorUndefined;
            }

            amrParams->nChannels = 1;
            amrParams->eAMRDTXMode = OMX_AUDIO_AMRDTXModeOff;
            amrParams->eAMRFrameFormat = OMX_AUDIO_AMRFrameFormatConformance;

            if (!isConfigured()) {
                amrParams->nBitRate = 0;
                amrParams->eAMRBandMode = OMX_AUDIO_AMRBandModeUnused;
            } else {
                amrParams->nBitRate = 0;
                amrParams->eAMRBandMode =
                    mMode == MODE_NARROW
                        ? OMX_AUDIO_AMRBandModeNB0 : OMX_AUDIO_AMRBandModeWB0;
            }

            return OMX_ErrorNone;
        }

        case OMX_IndexParamAudioPcm:
        {
            OMX_AUDIO_PARAM_PCMMODETYPE *pcmParams =
                (OMX_AUDIO_PARAM_PCMMODETYPE *)params;

            if (pcmParams->nPortIndex != 1) {
                return OMX_ErrorUndefined;
            }

            pcmParams->nChannels = 1;
            pcmParams->eNumData = OMX_NumericalDataSigned;
            pcmParams->eEndian = OMX_EndianBig;
            pcmParams->bInterleaved = OMX_TRUE;
            pcmParams->nBitPerSample = 16;

            pcmParams->nSamplingRate =
                (mMode == MODE_NARROW) ? kSampleRateNB : kSampleRateWB;

            pcmParams->ePCMMode = OMX_AUDIO_PCMModeLinear;
            pcmParams->eChannelMapping[0] = OMX_AUDIO_ChannelLF;
            pcmParams->eChannelMapping[1] = OMX_AUDIO_ChannelRF;

            return OMX_ErrorNone;
        }

        default:
            return SimpleSoftOMXComponent::internalGetParameter(index, params);
    }
}
コード例 #8
0
QByteArray OpAdapterDetailsRequ::marshall()
{
    QByteArray serialized_data;
    QDataStream stream(&serialized_data, QIODevice::WriteOnly);
    stream << opStatus();
    stream << adapterName();
    stream << adapterVersion();
    stream << adapterDescription();
    stream << isConfigured();
    return serialized_data;
}
コード例 #9
0
bool ConfigManager::runConfigureTool()
{
    QString configureToolApp = m_currentConfigPath + CONFIGURE_TOOL_NAME;
    QWidget *parentW = qobject_cast<QWidget *>(parent());
    if(!parentW || isVisible())
        parentW = this;

    if(QFile::exists(configureToolApp))
    {
        PGE_JsEngine js;
        js.bindProxy(new PGE_JS_Common(parentW), "PGE");
        js.bindProxy(new PGE_JS_File(m_currentConfigPath, parentW), "FileIO");
        js.bindProxy(new PGE_JS_INI(parentW), "INI");

        bool successfulLoaded = false;
        js.loadFileByExpcetedResult<void>(configureToolApp, &successfulLoaded);

        if(successfulLoaded)
        {
            setEnabled(false);
            if(!js.call<bool>("onConfigure", nullptr))
            {
                setEnabled(true);
                return false;
            }
            setEnabled(true);
            if(!isConfigured())
                return false;
            return true;
        }
        else
        {
            QMessageBox::critical(parentW,
                                  tr("Configuration script failed"),
                                  tr("Configuring tool encountered an error: %1 at line %2.\n"
                                     "File path: %3")
                                  .arg(js.getLastError())
                                  .arg(js.getLastErrorLine())
                                  .arg(configureToolApp),
                                  QMessageBox::Ok);
            return false;
        }
    }
    else
    {
        QMessageBox::information(parentW,
                                 tr("No configuration needed"),
                                 tr("This config pack has no configuring tool."),
                                 QMessageBox::Ok);
        return false;
    }
}
コード例 #10
0
ファイル: AgentThread.cpp プロジェクト: cvilas/ugv1
//------------------------------------------------------------------------------
void AgentThread::start()
//------------------------------------------------------------------------------
{
    if( !isConfigured() )
    {
        throw AgentException(0, "[AgentThread::start] : Attempted to start without configuring");
    }
    setExitFlag(false);
    QThread::start();
    if( !QThread::isRunning() )
    {
        throw AgentException(0, "[AgentThread::start] : Error starting thread");
    }
}
コード例 #11
0
bool GitVersionControl::supportsOperation(Operation operation) const
{
    if (!isConfigured())
        return false;

    switch (operation) {
    case AddOperation:
    case DeleteOperation:
    case MoveOperation:
    case CreateRepositoryOperation:
    case SnapshotOperations:
    case AnnotateOperation:
        return true;
    }
    return false;
}
コード例 #12
0
bool PerforceVersionControl::supportsOperation(Operation operation) const
{
    bool supported = isConfigured();
    switch (operation) {
    case AddOperation:
    case DeleteOperation:
    case MoveOperation:
    case AnnotateOperation:
        return supported;
    case CreateRepositoryOperation:
    case SnapshotOperations:
    case CheckoutOperation:
    case GetRepositoryRootOperation:
        break;
    }
    return false;
}
コード例 #13
0
bool ConfigManager::checkForConfigureTool()
{
    QString configureToolApp = m_currentConfigPath + CONFIGURE_TOOL_NAME;

    //If configure tool has been detected
    if(QFile::exists(configureToolApp) && (!isConfigured()))
    {
        QMessageBox::StandardButton reply =
            QMessageBox::information(this,
                                     tr("Configuration package is not configured!"),
                                     tr("\"%1\" configuration package is not configured yet.\n"
                                        "Do you want to configure it?")
                                     .arg(m_currentConfig),
                                     QMessageBox::Yes | QMessageBox::No);
        if(reply == QMessageBox::Yes)
            return runConfigureTool();
        else
            return false;
    }

    return true;
}
コード例 #14
0
void can_prep_motor_values_raw( sCAN* mMsg )
{
    mMsg->id 	  = create_CAN_eid( 0x00, ID_MOTOR_VALUE, MyInstance );
	if (isConfigured(MODE_USE_ENCODER))  {
		mMsg->data[0] = hi(EncoderCount);
		mMsg->data[1] = lo(EncoderCount);	
	} else {
		mMsg->data[0] = hi(PotSample[1]);
		mMsg->data[1] = lo(PotSample[1]);
	}
	
	// Also send Currents Raw:
	mMsg->data[2] = hi(LeftCurrentSample[1] );
	mMsg->data[3] = lo(LeftCurrentSample[1] );
	mMsg->data[4] = hi(RightCurrentSample[1]);
	mMsg->data[5] = lo(RightCurrentSample[1]);

	word Duty = MotorDutyRequest * 100;
	mMsg->data[6] = hi(Duty);
	mMsg->data[7] = lo(Duty);	
    mMsg->header.DLC = 8;
    mMsg->header.rtr = 0;
}
コード例 #15
0
ファイル: counterPin.cpp プロジェクト: lxrobotics/arduinoio
/**
 * @brief reads the value of the counter
 * @param val value of the counter
 * @return true in case of success, false in case of failure
 */
bool counterPin::readCounter(unsigned int &val) {

	if (!isConfigured())
		return false;

	// send request string
	unsigned char pinNumber = m_pinVect[0].getPinNumber();
	int const msgSize = 4;

	unsigned char msg[msgSize] = { CT_COUNTER, DT_COUNTER_READ, pinNumber,
			CT_COUNTER + DT_COUNTER_READ + pinNumber };
	m_serial->writeToSerial(msg, msgSize);

	// retrieve answer and evaluate it
	int const replySize = 5;
	boost::shared_ptr<unsigned char> reply = m_serial->readFromSerial(
			replySize);

	if (reply.get()[0] != CT_COUNTER || reply.get()[1] != DT_COUNTER_READ) {
		std::cerr << __FILE__ << ":" << __LINE__ << " Error in request reply message."
				<< std::endl;
		return false;
	}
	if (!isChecksumOk(reply.get(), replySize)) {
		std::cerr << __FILE__ << ":" << __LINE__ << " Error in checksum."
				<< std::endl;
		return false;
	}
	if (reply.get()[2] == COUNTER_NOK) {
		return false;
	}

	val = static_cast<unsigned int>(reply.get()[3]);

	return true;
}
コード例 #16
0
OMX_ERRORTYPE SoftVorbis::internalGetParameter(
        OMX_INDEXTYPE index, OMX_PTR params) {
    switch (index) {
        case OMX_IndexParamAudioVorbis:
        {
            OMX_AUDIO_PARAM_VORBISTYPE *vorbisParams =
                (OMX_AUDIO_PARAM_VORBISTYPE *)params;

            if (vorbisParams->nPortIndex != 0) {
                return OMX_ErrorUndefined;
            }

            vorbisParams->nBitRate = 0;
            vorbisParams->nMinBitRate = 0;
            vorbisParams->nMaxBitRate = 0;
            vorbisParams->nAudioBandWidth = 0;
            vorbisParams->nQuality = 3;
            vorbisParams->bManaged = OMX_FALSE;
            vorbisParams->bDownmix = OMX_FALSE;

            if (!isConfigured()) {
                vorbisParams->nChannels = 1;
                vorbisParams->nSampleRate = 44100;
            } else {
                vorbisParams->nChannels = mVi->channels;
                vorbisParams->nSampleRate = mVi->rate;
                vorbisParams->nBitRate = mVi->bitrate_nominal;
                vorbisParams->nMinBitRate = mVi->bitrate_lower;
                vorbisParams->nMaxBitRate = mVi->bitrate_upper;
            }

            return OMX_ErrorNone;
        }

        case OMX_IndexParamAudioPcm:
        {
            OMX_AUDIO_PARAM_PCMMODETYPE *pcmParams =
                (OMX_AUDIO_PARAM_PCMMODETYPE *)params;

            if (pcmParams->nPortIndex != 1) {
                return OMX_ErrorUndefined;
            }

            pcmParams->eNumData = OMX_NumericalDataSigned;
            pcmParams->eEndian = OMX_EndianBig;
            pcmParams->bInterleaved = OMX_TRUE;
            pcmParams->nBitPerSample = 16;
            pcmParams->ePCMMode = OMX_AUDIO_PCMModeLinear;
            pcmParams->eChannelMapping[0] = OMX_AUDIO_ChannelLF;
            pcmParams->eChannelMapping[1] = OMX_AUDIO_ChannelRF;

            if (!isConfigured()) {
                pcmParams->nChannels = 1;
                pcmParams->nSamplingRate = 44100;
            } else {
                pcmParams->nChannels = mVi->channels;
                pcmParams->nSamplingRate = mVi->rate;
            }

            return OMX_ErrorNone;
        }

        default:
            return SimpleSoftOMXComponent::internalGetParameter(index, params);
    }
}
コード例 #17
0
ファイル: SoftOpus.cpp プロジェクト: MIPS/frameworks-av
OMX_ERRORTYPE SoftOpus::internalGetParameter(
        OMX_INDEXTYPE index, OMX_PTR params) {
    switch ((int)index) {
        case OMX_IndexParamAudioPortFormat:
        {
            OMX_AUDIO_PARAM_PORTFORMATTYPE *formatParams =
                (OMX_AUDIO_PARAM_PORTFORMATTYPE *)params;

            if (!isValidOMXParam(formatParams)) {
                return OMX_ErrorBadParameter;
            }

            if (formatParams->nPortIndex > 1) {
                return OMX_ErrorUndefined;
            }

            if (formatParams->nIndex > 0) {
                return OMX_ErrorNoMore;
            }

            formatParams->eEncoding =
                (formatParams->nPortIndex == 0)
                    ? (OMX_AUDIO_CODINGTYPE)OMX_AUDIO_CodingAndroidOPUS :
                       OMX_AUDIO_CodingPCM;

            return OMX_ErrorNone;
        }

        case OMX_IndexParamAudioAndroidOpus:
        {
            OMX_AUDIO_PARAM_ANDROID_OPUSTYPE *opusParams =
                (OMX_AUDIO_PARAM_ANDROID_OPUSTYPE *)params;

            if (!isValidOMXParam(opusParams)) {
                return OMX_ErrorBadParameter;
            }

            if (opusParams->nPortIndex != 0) {
                return OMX_ErrorUndefined;
            }

            opusParams->nAudioBandWidth = 0;
            opusParams->nSampleRate = kRate;
            opusParams->nBitRate = 0;

            if (!isConfigured()) {
                opusParams->nChannels = 1;
            } else {
                opusParams->nChannels = mHeader->channels;
            }

            return OMX_ErrorNone;
        }

        case OMX_IndexParamAudioPcm:
        {
            OMX_AUDIO_PARAM_PCMMODETYPE *pcmParams =
                (OMX_AUDIO_PARAM_PCMMODETYPE *)params;

            if (!isValidOMXParam(pcmParams)) {
                return OMX_ErrorBadParameter;
            }

            if (pcmParams->nPortIndex != 1) {
                return OMX_ErrorUndefined;
            }

            pcmParams->eNumData = OMX_NumericalDataSigned;
            pcmParams->eEndian = OMX_EndianBig;
            pcmParams->bInterleaved = OMX_TRUE;
            pcmParams->nBitPerSample = 16;
            pcmParams->ePCMMode = OMX_AUDIO_PCMModeLinear;
            pcmParams->eChannelMapping[0] = OMX_AUDIO_ChannelLF;
            pcmParams->eChannelMapping[1] = OMX_AUDIO_ChannelRF;
            pcmParams->nSamplingRate = kRate;

            if (!isConfigured()) {
                pcmParams->nChannels = 1;
            } else {
                pcmParams->nChannels = mHeader->channels;
            }

            return OMX_ErrorNone;
        }

        default:
            return SimpleSoftOMXComponent::internalGetParameter(index, params);
    }
}