예제 #1
0
void LCD216s::init( int address ) {

  // OK. It appears that these units don't start up well. Maybe they require better power smoothing?
  
	_address = deviceAddress ( dtLCD216s, address );
  
  // digitalWrite ( 13, HIGH );
  // Serial.begin ( 115200 );
  // Serial.print ( "LCD216s init address: 0x" ); Serial.println ( _address, HEX );

  for ( int i = 0; i < 1; i++ ) {
    // Force the Command protocol to be P1 ( 0xFE 0xFE 0x55 0xAA < protocol>)
    // page 7 of PDF
    // delay ( 1000 );
    // digitalWrite ( 12, 1 - digitalRead ( 12 ) );
    send ( (unsigned char *) "\xfe\xfe\x55\xaa\x01", 5 );
    // send ( (unsigned char *) "\xfe\xfe\x55\xaa\x02", 5 );
    
    // delay ( 1000 );
    // digitalWrite ( 11, digitalRead ( 12 ) );
    clear ( );
    // command ( 0x01, (unsigned char *) "", 0 );
  }
  command ( BLOn, (unsigned char *) "", 0 );
  command ( CrOff, (unsigned char *) "", 0 );
  command ( WrapOff, (unsigned char *) "", 0 );
  command ( ScrlOff, (unsigned char *) "", 0 );
  
  // clear ( );
}
예제 #2
0
favorites::favorites( QWidget * parent ) :
	QDialog( parent ),
	m_ui( new Ui::favorites )
{
	m_ui->setupUi( this ) ;
	this->setWindowFlags( Qt::Window | Qt::Dialog ) ;
	this->setFont( parent->font() ) ;

	this->setFixedSize( this->size() ) ;

	connect( m_ui->pbDeviceAddress,SIGNAL( clicked() ),this,SLOT( deviceAddress() ) ) ;
	connect( m_ui->pbAdd,SIGNAL( clicked() ),this,SLOT( add() ) ) ;
	connect( m_ui->pbFileAddress,SIGNAL( clicked() ),this,SLOT( fileAddress() ) ) ;
	connect( m_ui->pbCancel,SIGNAL( clicked() ),this,SLOT( cancel() ) ) ;
	connect( m_ui->tableWidget,SIGNAL( currentItemChanged( QTableWidgetItem *,QTableWidgetItem * ) ),this,
		SLOT( currentItemChanged( QTableWidgetItem *,QTableWidgetItem * ) ) ) ;
	connect( m_ui->tableWidget,SIGNAL( itemClicked( QTableWidgetItem * ) ),this,
		SLOT( itemClicked( QTableWidgetItem * ) ) ) ;
	connect( m_ui->lineEditDeviceAddress,SIGNAL( textChanged( QString ) ),this,SLOT( devicePathTextChange( QString ) ) ) ;

	m_ui->pbFileAddress->setIcon( QIcon( ":/file.png" ) ) ;
	m_ui->pbDeviceAddress->setIcon( QIcon( ":/partition.png" ) ) ;

	m_ac = new QAction( this ) ;
	QList<QKeySequence> keys ;
	keys.append( Qt::Key_Enter ) ;
	keys.append( Qt::Key_Return ) ;
	keys.append( Qt::Key_Menu ) ;
	m_ac->setShortcuts( keys ) ;
	connect( m_ac,SIGNAL( triggered() ),this,SLOT( shortcutPressed() ) ) ;
	this->addAction( m_ac ) ;

	this->installEventFilter( this ) ;
}
예제 #3
0
uint8_t SHA204I2C::receive_bytes(uint8_t count, uint8_t *data) {
	if (DEBUG()>=DEBUG_INFO)  {Serial.println(F("* DEBUG * receive_bytes()")); Serial.flush();}
	if (DEBUG()>=DEBUG_TRACE) {Serial.print(F("* DEBUG * count = "));Serial.println(count);Serial.flush();}
	uint8_t i;

	int available_bytes = Wire.requestFrom(deviceAddress(), count);
	if (DEBUG()>=DEBUG_TRACE) {Serial.print(F("* DEBUG * available_bytes = "));Serial.println(available_bytes);Serial.flush();}

	if (available_bytes > count) {
		if (DEBUG()>=DEBUG_WARN)  {Serial.print(F("* DEBUG * receive_bytes() FAIL available_bytes > count, available_bytes = "));Serial.println(available_bytes); Serial.flush();}
		return I2C_FUNCTION_RETCODE_COMM_FAIL;
	}

  for (i = 0; i < available_bytes; i++) {
		while (!Wire.available()); // Wait for byte that is going to be read next
		*data++ = Wire.read(); // Store read value
	}

  if (available_bytes < count) {
		if (DEBUG()>=DEBUG_WARN)  {Serial.print(F("* DEBUG * receive_bytes() WARNING available_bytes < count, available_bytes = "));Serial.println(available_bytes); Serial.flush();}
		reset_io();
		if (DEBUG()>=DEBUG_WARN)  {Serial.print(F("* DEBUG * receive_bytes() TRY to read bytes = "));Serial.println(count-available_bytes); Serial.flush();}
			uint8_t d;
			uint8_t *pd;
			pd = &d;
			for (i=0; i <(count-available_bytes); i++){
				d = 0xFF;
				receive_byte(pd);
				if (DEBUG()>=DEBUG_WARN)  {Serial.print(F("* DEBUG * receive_bytes() TRY receive_byte() = 0x"));Serial.println(d,HEX); Serial.flush();}
				*data++ = *pd;
			}
   }

	return I2C_FUNCTION_RETCODE_SUCCESS;
}
예제 #4
0
uint8_t SHA204I2C::resync(uint8_t size, uint8_t *response) {
	if (DEBUG()>=DEBUG_INFO)  {Serial.println(F("* DEBUG * resync()")); Serial.flush();}

	// Try to re-synchronize without sending a Wake token
	// (step 1 of the re-synchronization process).
	uint8_t nine_clocks = 0xFF;
	send_bytes(1, &nine_clocks);
	Wire.beginTransmission(deviceAddress());
	Wire.endTransmission();

	// Try to send a Reset IO command if re-sync succeeded.
	int ret_code = reset_io();
	if (ret_code == SHA204_SUCCESS) {
		return ret_code;
	}

	// We lost communication. Send a Wake pulse and try
	// to receive a response (steps 2 and 3 of the
	// re-synchronization process).
	sleep();
	ret_code = wakeup(response);

	// Translate a return value of success into one
	// that indicates that the device had to be woken up
	// and might have lost its TempKey.
	return (ret_code == SHA204_SUCCESS ? SHA204_RESYNC_WITH_WAKEUP : ret_code);
}
예제 #5
0
uint8_t SHA204I2C::send(uint8_t word_address, uint8_t count, uint8_t *buffer) {
	if (DEBUG()>=DEBUG_INFO)  {Serial.println(F("* DEBUG * send()")); Serial.flush();}
	uint8_t i2c_status;

	Wire.beginTransmission(deviceAddress());

	start_operation(I2C_WRITE);

	i2c_status = send_bytes(1, &word_address);
	if (DEBUG()>=DEBUG_TRACE) {Serial.print(F("* DEBUG * i2c_status{1} = "));Serial.println(i2c_status,HEX);Serial.flush();}
	if (i2c_status != I2C_FUNCTION_RETCODE_SUCCESS) {
		 if (DEBUG()>=DEBUG_WARN)  {Serial.print(F("* DEBUG * send() fail 1, i2c_status{1} = "));Serial.println(i2c_status,HEX);Serial.flush();}
		return SHA204_COMM_FAIL;
	}

	if (count == 0) {
		return SHA204_SUCCESS;
	}

	i2c_status = send_bytes(count, buffer);
  if (DEBUG()>=DEBUG_TRACE) {Serial.print(F("* DEBUG * i2c_status{2} = "));Serial.println(i2c_status,HEX);Serial.flush();}
	if (i2c_status != I2C_FUNCTION_RETCODE_SUCCESS) {
		if (DEBUG()>=DEBUG_WARN)  {Serial.print(F("* DEBUG * send() fail 2, i2c_status{2} = "));Serial.println(i2c_status,HEX);Serial.flush();}
		return SHA204_COMM_FAIL;
	}

	Wire.endTransmission();

	return SHA204_SUCCESS;
}
void QBluetoothTransferReplySymbian::startTransfer()
{
    TObexBluetoothProtocolInfo protocolInfo;
    TBTDevAddr deviceAddress(m_address.toUInt64());

    protocolInfo.iTransport.Copy(KBTSProtocol);
    protocolInfo.iAddr.SetBTAddr(deviceAddress);
    protocolInfo.iAddr.SetPort(m_port); // TODO: set port if needed

    if ( m_client ) {
        delete m_client;
        m_client = NULL;
    }

    TRAPD( err, m_client = CObexClient::NewL(protocolInfo));
    if (err) {
        qDebug() << "Error in" << __FUNCTION__ << err;
        m_error = err == KErrNotFound ? HostNotFoundError: UnknownError;
        return;
    }

    m_state = EConnecting;
    m_client->Connect( iStatus );

    SetActive();
}
예제 #7
0
uint8_t SHA204I2C::chip_wakeup() {
	if (DEBUG()>=DEBUG_INFO)  {Serial.println(F("* DEBUG * chip_wakeup()")); Serial.flush();}
	// This was the only way short of manually adjusting the SDA pin to wake up the device
	Wire.beginTransmission(deviceAddress());
	int i2c_status = Wire.endTransmission();
	if (i2c_status != 0) {
		if (DEBUG()>=DEBUG_WARN)  {Serial.print(F("* DEBUG * chip_wakeup() FAIL i2c_status = "));Serial.println(i2c_status,HEX); Serial.flush();}
		return SHA204_COMM_FAIL;
	}

	return SHA204_SUCCESS;
}
예제 #8
0
uint8_t SHA204I2C::receive_byte(uint8_t *data) {
	if (DEBUG()>=DEBUG_INFO)  {Serial.println(F("* DEBUG * receive_byte()")); Serial.flush();}

	int available_bytes = Wire.requestFrom(deviceAddress(), (uint8_t)1);

	if (available_bytes != 1) {
		if (DEBUG()>=DEBUG_WARN)  {Serial.print(F("* DEBUG * receive_byte() FAIL available_bytes!=1, available_bytes = "));Serial.println(available_bytes); Serial.flush();}
		return I2C_FUNCTION_RETCODE_COMM_FAIL;
	}
	while (!Wire.available()); // Wait for byte that is going to be read next
	*data++ = Wire.read(); // Store read value

	return I2C_FUNCTION_RETCODE_SUCCESS;
}
예제 #9
0
LCD216s::LCD216s ( int address ) {
	_address = deviceAddress ( dtLCD216s, address );
}