Exemplo n.º 1
0
msl::msl(QWidget *parent) :
        QWidget(parent),
        serialConnection("","","",""/*Manufacturer String*/,""/*Product String*/)
{

	ui.setupUi(this);
	//Create QColorDialog
	this->colorDialog = new QColorDialog(this);
	this->colorDialog->setWindowFlags(Qt::Widget);

	//Remove buttons and dialog
	this->colorDialog->setOptions(
			QColorDialog::DontUseNativeDialog | QColorDialog::NoButtons);
	//SetColor
	this->colorDialog->setCurrentColor(QColor(Qt::black));
	this->ui.LayoutForColorSelector->addWidget(colorDialog);

	//Connect the colorChanged signal
	connect(this->colorDialog, SIGNAL(currentColorChanged(QColor)), this,
			SLOT(colorChanged(QColor)));

	//Hide the EEProm settings-box
	this->ui.groupBox_EEProm->hide();

	//Disable the GUI as long as there is no connection to the serial
	this->setDisabled(1);

	//Connect the signals
	connect(&this->serialConnection,
                        SIGNAL(serialAbortedConnect(int)), this,
                        SLOT(serialConnectionAbort(int)));

	connect(&this->serialConnection, SIGNAL(waitingForRetry()), this,
			SLOT(serialWaitingForRetry()));
	connect(&this->serialConnection, SIGNAL(serialConnected()), this,
			SLOT(serialConnected()));
	connect(this, SIGNAL(retry()), &this->serialConnection,
			SLOT(retryConnect()));

	connect(this, SIGNAL(sendArray(QByteArray)),&this->serialConnection,SLOT(sendArray(QByteArray)));

	//Start serial connection thread
	serialConnection.start();
	serialConnection.setStopBits(qUSBSerial::StopBits_2);

	//Connect to Microscope Light
	serialConnection.serialConnect();

}
Exemplo n.º 2
0
Arquivo: main.c Projeto: sphincs/LCD
void main()
{
  lcdInit();
  spiOn();
  spiOff();
  sendByte(out);
  sendArray(array);
  lcdOn();
  lcdOff();
  sendBuffer();
  sendPart(3, 7, LCD_Buffer);
  clear();
  clearPart(5, 76);
  clearPartColor(5, 76, clBLACK);
  setPenColor(clBLACK);
  setBackColor(clWHITE);
  delay_nsek(40);
  scsOn();
  scsOff();
  i =  getValue(LCD_Buffer, 23, 266);
  setValue(LCD_Buffer, 23, 266, 0x3F);
  setCharge();
  resetCharge();
  drawPixel(5, 5, LCD_Buffer);
  drawVLine(5, 5, 5, LCD_Buffer);
  drawHLine(5, 5, 5, LCD_Buffer);
  drawLine(5, 5, 55, 55, LCD_Buffer);
  drawRect(5, 5, 55, 55, LCD_Buffer);
  drawFillRect(5, 5, 55, 55, clWHITE, LCD_Buffer);
  drawCircle(10, 10, 5, LCD_Buffer);
}
Exemplo n.º 3
0
void msl::updateLEDs()
{
    qDebug() << "Updating LEDs!";
	QByteArray array;

    array.push_back(SET_COLOR);
    array.push_back(DIRECT_LED);
	array.push_back((char)this->ui.verticalSlider_uv->value());
	array.push_back((char)this->ui.verticalSlider_white->value());
	array.push_back(this->colorDialog->currentColor().red());
	array.push_back(this->colorDialog->currentColor().green());
	array.push_back(this->colorDialog->currentColor().blue());
	unsigned char checksum=0;
	for(QByteArray::iterator it = array.begin(); it != array.end(); ++it)
	{
        checksum^=*it;
	}
	array.push_back(checksum);

    //Start with AA 55
    array.push_front(0x55);
    array.push_front(0xAA);



	emit sendArray(array);
}
Exemplo n.º 4
0
bool AI::initSpawnEnemies(string scriptName)
{
	spawnScript = lua_open();
	OpenLuaLibs(spawnScript);
	if(luaL_dofile(spawnScript, scriptName.c_str())) //spawning
		return false;
	
	lua_getglobal(spawnScript,"init");

	convertNodesToInt();
	sendArray(nodesInt, mapSize ,spawnScript);

	lua_pushnumber(spawnScript,enemiesPerMin);
	lua_pushnumber(spawnScript,difficulty);


	lua_pcall(spawnScript, 3, 1, 0);
	int a = (int)lua_tonumber(spawnScript, -1);
	
	
	lua_pop(spawnScript, 1);
	cout << "output: " << a << endl;

	return true;
}
Exemplo n.º 5
0
vector<float> AI::findTarget(Waypoint pos, int type)
{
	vector<float> target;

	lua_getglobal(targetScript, "findTarget");
	convertStructuresToInt();
	sendArray(structuresInt, mapSize-1, targetScript);
	lua_pushnumber(targetScript, pos.x/quadSize);
	lua_pushnumber(targetScript, pos.y/quadSize);
	lua_pushnumber(targetScript, type);

	lua_pcall(targetScript, 4, 3, 0); //kalla på funktionen
	
	float targetY = (float)lua_tonumber(targetScript, -1);
	lua_pop(targetScript, 1);
	float targetX = (float)lua_tonumber(targetScript, -1);
	lua_pop(targetScript, 1);
	float nodeID = (float)lua_tonumber(targetScript, -1);
	//hämta värden
	target.push_back(targetX);
	target.push_back(targetY);
	target.push_back(nodeID);
	//cout<< "X = "<<targetX<<" Y = "<<targetY<<endl;

	return target;
}
Exemplo n.º 6
0
void Slave::sendResult(int64_t id, vector<double> &resultArray, int64_t size)
{
	// printf("Slave %d\n Sending...", rank);
	sendID(id);
	sendSize(size);
	sendArray(resultArray, size);
	// system("echo Slave: $(hostname -I)");
	// printf("Slave %d Done.\n", rank);
}
Exemplo n.º 7
0
bool AI::initFindPath(string scriptName)
{
	pathScript = lua_open();
	OpenLuaLibs(pathScript);
	if(luaL_dofile(pathScript, scriptName.c_str()))//pathfinding
		return false;

	lua_getglobal(pathScript, "init");

	convertNodesToInt();
	sendArray(nodesInt, mapSize, pathScript);

	lua_pushnumber(pathScript, mapSize);
	lua_pcall(pathScript, 2, 0, 0);

	return true;
}
Exemplo n.º 8
0
/* -------------------------------------------------------------------- */
void Tserial::sendChar(char data)
{
    sendArray(&data, 1);
}
Exemplo n.º 9
0
/* -------------------------------------------------------------------- */
void Tserial::sendChar(char data)
{
    sendArray(&data, 1);
    if(v==true)printf("\nsent %c",data);
}