You are on page 1of 2

void send::run(){

//
int bufferx,buffery;
//
qDebug()<<"sending 1st line";
while(1){
delay(1);
//
qDebug()<<"while 1";
while(sendingNum<drawingNum){
//
qDebug()<<"while cond";
xbinarypoint.push_back(emptybool2);
ybinarypoint.push_back(emptybool2);
switch(drawingColor[sendingNum]){
case 0 :
colorcode[0]=0;
colorcode[1]=0;
colorcode[2]=0;
colorcode[3]=0;
break;
case 1 :
colorcode[0]=0;
colorcode[1]=1;
colorcode[2]=0;
colorcode[3]=0;
break;
case 2 :
colorcode[0]=0;
colorcode[1]=0;
colorcode[2]=1;
colorcode[3]=0;
break;
case 3 :
colorcode[0]=0;
colorcode[1]=1;
colorcode[2]=1;
colorcode[3]=0;
break;
case 4 :
colorcode[0]=0;
colorcode[1]=0;
colorcode[2]=0;
colorcode[3]=1;
break;
case 5 :
colorcode[0]=0;
colorcode[1]=1;
colorcode[2]=0;
colorcode[3]=1;
break;
}
//
qDebug()<<"colorcolorcolorcolorcolorcol
orcolorcolorcolorcolor"<<colorcode[0]<<colorcode[1]<<colorcode[2];
while(digitalRead(TRIGGERIN)==0){};
CHECK=1;
//
qDebug()<<"Sending";
sendData(colorcode);
//
qDebug()<<"Sent color";
//
qDebug()<<colorcode[0]<<colorcode[1]<<colorcode[2];

for(int i=0;i<drawing[sendingNum].size();i++){
xbinarypoint[sendingNum].push_back(emptybool1);
ybinarypoint[sendingNum].push_back(emptybool1);
xpoint=drawing[sendingNum][i].x();
ypoint=drawing[sendingNum][i].y();
//
qDebug()<<"S X = "<<xpoint<<"

S Y

="<<yp

oint;
//convert to bits stream
for(int j=0;j<11;j++){
xbinarypoint[sendingNum][i].push_back(xpoint%2);
ybinarypoint[sendingNum][i].push_back(ypoint%2);
xpoint/=2;
ypoint/=2;
}
sendData(xbinarypoint[sendingNum][i]);
sendData(ybinarypoint[sendingNum][i]);
qDebug()<<"Sent point";

//

//convert back to int , for receive terminal;


//
bufferx=0;
//
buffery=0;
//
for(int j=0;j<11;j++){
//
bufferx+=xbinarypoint[sendingNum][i][j]*po
w(2,j);
//

buffery+=ybinarypoint[sendingNum][i][j]*po

w(2,j);
//
//

}
qDebug()<<bufferx<<"

}
sendingNum++;
qDebug()<<"stop bit is sending";
sendData(stopBit);
qDebug()<<"stop bit is sent";

//
//
}
}
}

void send::sendData(vector<bool> data){


//if receiver ready, send
while(digitalRead(ACK)==1){}
for(int i=0;i<data.size();i++){
digitalWrite(SEND,data[i]);
CheckTriggerout= !CheckTriggerout;
digitalWrite(TRIGGEROUT,CheckTriggerout);
//
TRIGGEROUT=!TRIGGEROUT;
while(digitalRead(TRIGGERIN)==CHECK){}
CHECK=!CHECK;
}
}

"<<buffery<<endl;

You might also like