Takashi Asano
/
linearMirrorMotion1017
sotsuron
Fork of linearMirrorMotion1017 by
Diff: renderclass.cpp
- Revision:
- 21:4095a071724d
- Parent:
- 20:8475768fc2f7
- Child:
- 22:e86d63dfbbe1
diff -r 8475768fc2f7 -r 4095a071724d renderclass.cpp --- a/renderclass.cpp Fri May 31 06:32:07 2013 +0000 +++ b/renderclass.cpp Fri Jun 07 05:01:40 2013 +0000 @@ -9,15 +9,16 @@ inline void render::shearing(point2dl& dataBefore) { - dataBefore.x = dataBefore.x - speed * cos(angle+PI/2)*speedTimer.read_us()/400; - dataBefore.y = dataBefore.y - speed * sin(angle+PI/2)*speedTimer.read_us()/400; + dataBefore.x = dataBefore.x - speed *speedTimer.read_us()/1000000 ;//- speed * cos(angle+PI/2)*speedTimer.read_us()/800; + dataBefore.y = dataBefore.y ;//- speed * sin(angle+PI/2)*speedTimer.read_us()/800; } inline void render::rotation(point2dl& dataBefore) { int x=dataBefore.x; - dataBefore.x = 1800 * cos(angle) + sin(angle)*x - cos(angle)*dataBefore.y; - dataBefore.y = 1800 * sin(angle) - cos(angle)*x - sin(angle)*dataBefore.y; + dataBefore.x = x + (int)angle % (2 * CENTER_AD_MIRROR_X) + CENTER_AD_MIRROR_X;//1800 * cos(angle) + sin(angle)*x - cos(angle)*dataBefore.y; + dataBefore.y = -dataBefore.y;//1800 * sin(angle) - cos(angle)*x - sin(angle)*dataBefore.y; + } //---------------------------------------------------------------------------------- @@ -44,8 +45,8 @@ for(std::vector<letter>::iterator itr = (*ptext).begin(); itr != (*ptext).end(); ++itr) { translated.push_back(*itr); } //copy the liblary to the buffer. - - + + currentLetters=0; currentPoints=0; shearingSwitch = 1; @@ -53,62 +54,54 @@ } -void render::updateSpeed(float gspeed, float gangle){ +void render::updateSpeed(float gspeed, float gangle) +{ speed = gspeed; angle = gangle; - + //speed=sqrt(vx*vx+vy*vy);//*factorSpeed; //angle=atan2(vy,vx); } -int stopcounter=100; - void render::draw() { - if(translated.size()>0){ - if(stopcounter == 99) speedTimer.reset(); - if(stopcounter==100){ - - point2dl drawPoint=translated[currentLetters].letpoints[currentPoints]; - transform(drawPoint); // transform it with the current speed and angle - //IO.setRedPower(drawPoint.laserSwitch); - IO.writeOutXY(CENTER_AD_MIRROR_X + (int)drawPoint.x , CENTER_AD_MIRROR_Y + (int)drawPoint.y); - - - if(currentPoints>0) IO.setRedPower(translated[currentLetters].letpoints[currentPoints-1].laserSwitch); - else IO.setRedPower(0); + if(translated.size()>0) { + point2dl drawPoint=translated[currentLetters].letpoints[currentPoints]; + transform(drawPoint); // transform it with the current speed and angle + IO.writeOutXY(CENTER_AD_MIRROR_X + (int)drawPoint.x , CENTER_AD_MIRROR_Y + (int)drawPoint.y); + + ////laser switch + if(currentPoints>0) IO.setRedPower(translated[currentLetters].letpoints[currentPoints-1].laserSwitch); + else IO.setRedPower(0); + + currentPoints++; - currentPoints++; - } - else stopcounter++; - - if(currentPoints >= translated[currentLetters].letpoints.size() ) { - if(stopcounter == 100) stopcounter = 0; - else if(stopcounter == 0){ - renderTimer.detach(); + if(currentPoints >= translated[currentLetters].letpoints.size() ) { + currentLetters++; + currentPoints = 0; + //renderTimer.detach(); + + wait_us(RENDER_INTERVAL); + IO.setRedPower(0); + //wait_us(RENDER_INTERVAL); + + //renderTimer.attach_us(this, &render::draw,RENDER_INTERVAL); + speedTimer.reset(); + //} } - //wait_us(RENDER_INTERVAL); - else if(stopcounter == 1){ - IO.setRedPower(0); - //wait_us(RENDER_INTERVAL); - currentLetters++; - currentPoints = 0; - renderTimer.attach_us(this, &render::draw,RENDER_INTERVAL); - speedTimer.reset(); + if(currentLetters >= translated.size()) { + currentLetters = 0; + currentPoints = 0; + renderTimer.detach(); + //wait_us(RENDER_INTERVAL); + IO.setRedPower(0); + //wait_us(RENDER_INTERVAL*20); + renderTimer.attach_us(this, &render::draw,RENDER_INTERVAL); + speedTimer.reset(); + + //stopcounter = -200; } } - if(currentLetters >= translated.size()) { - currentLetters = 0; - currentPoints = 0; - renderTimer.detach(); - //wait_us(RENDER_INTERVAL); - IO.setRedPower(0); - //wait_us(RENDER_INTERVAL*200); - renderTimer.attach_us(this, &render::draw,RENDER_INTERVAL); - speedTimer.reset(); - stopcounter = -200; - } - } } void render::transform(point2dl& mypoint)