Takashi Asano
/
linearMirrorMotion1017
sotsuron
Fork of linearMirrorMotion1017 by
Diff: renderclass.cpp
- Revision:
- 19:8e9fe7d25b9c
- Parent:
- 18:6f86abfae754
- Child:
- 20:8475768fc2f7
--- a/renderclass.cpp Mon May 20 09:31:29 2013 +0000 +++ b/renderclass.cpp Fri May 24 06:37:58 2013 +0000 @@ -9,7 +9,6 @@ inline void render::shearing(point2dl& dataBefore) { - point2dl dataAfter; dataBefore.x = dataBefore.x ;//+ speed * cos(angle) * timer_v.read_us()/st/1000; dataBefore.y = dataBefore.y ;//+ speed * sin(angle) * timer_v.read_us()/st/1000; @@ -25,60 +24,83 @@ void render::startRender() { - //void (render::*fpdraw)() = draw; // I can't solve the error.......I tried a few days.......... - renderTimer.attach_us(this, &render::draw,RENDER_INTERVAL); // ???????how to set menber function??????? + renderTimer.attach_us(this, &render::draw,RENDER_INTERVAL); + pc.printf("render started!\n"); } void render::stopRender() { renderTimer.detach(); + translated.clear(); + currentLetters=0; + currentPoints=0; } void render::setRender(vector<letter> *p) { ptext = p; - + pc.printf("Size of text to render: %d/n", (*ptext).size() ); //for(int i=0; i!=(*ptext).size(); i++){ for(std::vector<letter>::iterator itr = (*ptext).begin(); itr != (*ptext).end(); ++itr) { translated.push_back(*itr); + pc.printf("moving...." ); } //copy the liblary to the buffer. - + + currentLetters=0; currentPoints=0; } -void render::updateSpeed(float vx, float vy){ - speed=sqrt(vx*vx+vy*vy);//*factorSpeed; - angle=atan2(vy,vx); +void render::updateSpeed(float gspeed, float gangle){ + speed = gspeed; + angle = gangle; + + //speed=sqrt(vx*vx+vy*vy);//*factorSpeed; + //angle=atan2(vy,vx); } - +float t=0; void render::draw() { - + if(translated.size()>0){ point2dl drawPoint=translated[currentLetters].letpoints[currentPoints]; transform(drawPoint); // transform it with the current speed and angle - - IO.writeOutXY(drawPoint.x , drawPoint.y); - IO.setRedPower(translated[currentLetters].letpoints[currentPoints].laserSwitch); + pc.printf("%d, %d, %d \n" , (int)drawPoint.x, (int)drawPoint.y, (int)drawPoint.laserSwitch); + //IO.setRedPower(drawPoint.laserSwitch); + IO.writeOutXY(CENTER_AD_MIRROR_X+ 4*(int)drawPoint.x , CENTER_AD_MIRROR_Y - 4*(int)drawPoint.y); + + + if(currentPoints>0) IO.setRedPower(translated[currentLetters].letpoints[currentPoints-1].laserSwitch); + else IO.setRedPower(0); ///laserswitch txt library needs to rewrite..........?\(>o<)/? currentPoints++; - if(currentPoints > translated[currentLetters].letpoints.size() ) { + + if(currentPoints >= translated[currentLetters].letpoints.size() ) { currentLetters++; currentPoints = 0; + + renderTimer.detach(); + wait_us(RENDER_INTERVAL); + IO.setRedPower(0); + wait_us(RENDER_INTERVAL*40); + renderTimer.attach_us(this, &render::draw,RENDER_INTERVAL); } - if(currentLetters > translated.size()) { + 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); + } } } void render::transform(point2dl& mypoint) { - rotation(mypoint); shearing(mypoint); - } /*