Alvaro Cassinelli
/
laserScannerControl_FRDMK64F
Example controlling galvanomirrors (X and Y) using the spi DAC MCP4922 and the new platform FRDM_K64F
Diff: laserProjectorHardware/laserProjectorHardware.cpp
- Revision:
- 2:383b2acec6e4
- Parent:
- 1:4be6abc4ed43
- Child:
- 3:89f592efbe84
diff -r 4be6abc4ed43 -r 383b2acec6e4 laserProjectorHardware/laserProjectorHardware.cpp --- a/laserProjectorHardware/laserProjectorHardware.cpp Sun May 25 12:24:21 2014 +0000 +++ b/laserProjectorHardware/laserProjectorHardware.cpp Mon May 26 08:37:38 2014 +0000 @@ -91,41 +91,52 @@ Laser_Blue =color&0x01; } -void HardwareIO::showLimitsMirrors(int times) { +void HardwareIO::drawCircle(int X, int Y, int R, int numPoints) { + float alpha=2*3.141592/numPoints; + float theta=0; + for (int i=0; i<numPoints; i++) { + writeOutX(X+1.0*R*cos(theta)); + writeOutY(Y+1.0*R*sin(theta)); + theta+=alpha; + } + } + +void HardwareIO::showLimitsMirrors(int seconds) { unsigned short pointsPerLine=150; int shiftX = (MAX_AD_MIRRORS - MIN_AD_MIRRORS) / pointsPerLine; int shiftY = (MAX_AD_MIRRORS - MIN_AD_MIRRORS) / pointsPerLine; Laser_Green=1; + Laser_Red=1; //for (int repeat=0; repeat<times; repeat++) { Timer t; t.start(); - while(t.read_ms()<times*1000) { + while(t.read_ms()<seconds*1000) { writeOutX(MIN_AD_MIRRORS);writeOutY(MIN_AD_MIRRORS); for(int j=0; j<pointsPerLine; j++){ - wait_us(200);//delay between each points + wait_us(50);//delay between each points writeOutY(j*shiftY + MIN_AD_MIRRORS); } writeOutX(MIN_AD_MIRRORS);writeOutY(MAX_AD_MIRRORS); for(int j=0; j<pointsPerLine; j++) { - wait_us(200);//delay between each points + wait_us(50);//delay between each points writeOutX(j*shiftX + MIN_AD_MIRRORS); } writeOutX(MAX_AD_MIRRORS);writeOutY(MAX_AD_MIRRORS); for(int j=0; j<pointsPerLine; j++) { - wait_us(200);//delay between each points + wait_us(50);//delay between each points writeOutY(-j*shiftX + MAX_AD_MIRRORS); } writeOutX(MAX_AD_MIRRORS);writeOutY(MIN_AD_MIRRORS); for(int j=0; j<pointsPerLine; j++) { - wait_us(200);//delay between each points + wait_us(50);//delay between each points writeOutX(-j*shiftX + MAX_AD_MIRRORS); }