📄 demo.c
字号:
if((lStringWidth != 0) && (lIconWidth != 0))
{
lYMax += INCHES(0, 250);
}
//
// Set the horizontal and vertical positions such that the icon and string
// are centered on the page.
//
ulXS = ulX + ((INCHES(5, 250) - lStringWidth) / 2);
ulX = ulX + ((INCHES(5, 250) - lIconWidth) / 2);
ulYS = ulY + ((INCHES(5, 250) - (lYMax - lYMin) - lIconHeight) / 2);
ulY = ulYS + (lYMax - lYMin);
//
// Indicate that a drawing sequence is starting.
//
DrawStart();
//
// Start the tool if required.
//
if(g_ulTool != 0x00)
{
//
// Turn on the tool.
//
ToolOn();
//
// Delay for two seconds while the tool gets up to speed.
//
DemoDelay(2000);
}
//
// Loop over the requested number of iterations.
//
while(ulIterations--)
{
//
// If an icon was requested, then draw it first.
//
if(g_ulIcons & 0x01)
{
//
// Draw the Luminary Micro logo.
//
DrawImage(ulX, ulY, ulZ, g_pusLMI, INCHES(1, 000), ulDepth);
}
else if(g_ulIcons & 0x02)
{
//
// Draw the ARM logo.
//
DrawImage(ulX, ulY, ulZ, g_pusARM, INCHES(1, 000), ulDepth);
}
//
// Bail out if the drawing has been aborted.
//
if(!DrawIsDrawing())
{
break;
}
//
// If a name string was supplied, then draw it now.
//
if(g_pcNameString[0] != '\0')
{
//
// Draw the string.
//
DrawString(ulXS, ulYS - lYMin, ulZ, g_pcNameString, INCHES(0, 250),
ulDepth);
}
//
// Do no draw any further iterations if the drawing was aborted.
//
if(!DrawIsDrawing())
{
break;
}
//
// Increase the depth of the next iteration.
//
ulDepth += ROUTER_DEPTH_INCREMENT;
}
//
// Stop the tool if required.
//
if(g_ulTool != 0x00)
{
ToolOff();
}
//
// Move the home position.
//
TableHome();
//
// Indicate that the drawing is complete.
//
DrawStop();
}
//*****************************************************************************
//
//! Performs the second CNC demonstration.
//!
//! This demonstration of the CNC machine draws an optional logo, the supplied
//! string, and a octagonal border around the whole thing. It is intended to
//! be used with a router and wood, with the result being a name plate. The
//! text and logos are drawn one inch (2.54 cm) tall.
//!
//! \return None.
//
//*****************************************************************************
void
Demo2(void)
{
unsigned long ulX, ulY, ulZ, ulDepth, ulIterations;
long lLogoWidth, lWidth, lYMin, lYMax;
//
// Get the width of the logo.
//
if(g_ulIcons & 0x01)
{
//
// Get the width of the LMI logo.
//
lLogoWidth = (DrawGetImageWidth(g_pusLMI, INCHES(1, 000)) +
INCHES(0, 500));
}
else if(g_ulIcons & 0x02)
{
//
// Get the width of the ARM logo.
//
lLogoWidth = (DrawGetImageWidth(g_pusARM, INCHES(1, 000)) +
INCHES(1, 000));
}
else
{
//
// There is no logo, so the width of the "logo" is zero.
//
lLogoWidth = INCHES(0, 000);
}
//
// Get the extents of the name string.
//
if(g_pcNameString[0] != '\0')
{
//
// Get the width and Y extents of the name string.
//
DrawGetStringSize(g_pcNameString, INCHES(1, 000), &lWidth, &lYMin,
&lYMax);
}
else
{
//
// There is no name string, so set the width to zero.
//
lWidth = 0;
//
// Set the Y extents based on the logo.
//
lYMin = 0;
lYMax = INCHES(1, 000);
//
// If there was an icon drawn, then remove the padding that was added
// to the right side.
//
if(g_ulIcons & 0x01)
{
lLogoWidth -= INCHES(0, 500);
}
else if(g_ulIcons & 0x02)
{
lLogoWidth -= INCHES(1, 000);
}
}
//
// If there is no logo and no name string, then return without doing
// anything.
//
if((lLogoWidth == 0) && (lWidth == 0))
{
return;
}
//
// Construct an image of a line going all the way around the image and
// string that will be drawn. The first value is the number of coordinates
// in the border.
//
g_pusBorder[0] = 9;
//
// The total width and height of the border.
//
g_pusBorder[1] = (lLogoWidth + lWidth + INCHES(1, 000)) / 2;
g_pusBorder[2] = (lYMax - lYMin + INCHES(1, 000)) / 2;
//
// The first coordinate is at the far right on the base line of the drawn
// text.
//
g_pusBorder[3] = (lLogoWidth + lWidth + INCHES(1, 000)) / 2;
g_pusBorder[4] = INCHES(0, 500) / 2;
//
// The second coordinate is at the far right at the top of the drawn text.
//
g_pusBorder[5] = (lLogoWidth + lWidth + INCHES(1, 000)) / 2;
g_pusBorder[6] = (lYMax - lYMin + INCHES(0, 500)) / 2;
//
// The third coordinate is at the far right above the top of the drawn
// text.
//
g_pusBorder[7] = (lLogoWidth + lWidth + INCHES(0, 500)) / 2;
g_pusBorder[8] = (lYMax - lYMin + INCHES(1, 000)) / 2;
//
// The fourth coordinate is at the far left above the top of the drawn
// text.
//
g_pusBorder[9] = INCHES(0, 500) / 2;
g_pusBorder[10] = (lYMax - lYMin + INCHES(1, 000)) / 2;
//
// The fifth coordinate is at the far left at the top of the drawn text.
//
g_pusBorder[11] = INCHES(0, 000) / 2;
g_pusBorder[12] = (lYMax - lYMin + INCHES(0, 500)) / 2;
//
// The sixth coordinate is at the far left on the base line of the drawn
// text.
//
g_pusBorder[13] = INCHES(0, 000) / 2;
g_pusBorder[14] = INCHES(0, 500) / 2;
//
// The seventh coordiante is at the far left below the bottom of the drawn
// text.
//
g_pusBorder[15] = INCHES(0, 500) / 2;
g_pusBorder[16] = INCHES(0, 000) / 2;
//
// The eighth coordinate is at the far right below the bottom of the drawn
// text.
//
g_pusBorder[17] = (lLogoWidth + lWidth + INCHES(0, 500)) / 2;
g_pusBorder[18] = INCHES(0, 000) / 2;
//
// The ninth coordinate is at the same place as the first coordinate.
//
g_pusBorder[19] = (lLogoWidth + lWidth + INCHES(1, 000)) / 2;
g_pusBorder[20] = INCHES(0, 500) / 2;
//
// Setup the tool for this demo.
//
DemoSetupTool(&ulX, &ulY, &ulZ, &ulDepth, &ulIterations);
//
// Indicate that a drawing sequence is starting.
//
DrawStart();
//
// Start the tool if required.
//
if(g_ulTool != 0x00)
{
//
// Turn on the tool.
//
ToolOn();
//
// Delay for two seconds while the tool gets up to speed.
//
DemoDelay(2000);
}
//
// Loop over the requested number of iterations.
//
while(ulIterations--)
{
//
// If an icon was requested, then draw it first.
//
if(g_ulIcons & 0x01)
{
//
// Draw the Luminary Micro logo.
//
DrawImage(ulX + INCHES(1, 000), ulY + INCHES(1, 000) - lYMin, ulZ,
g_pusLMI, INCHES(1, 000), ulDepth);
}
else if(g_ulIcons & 0x02)
{
//
// Draw the ARM logo.
//
DrawImage(ulX + INCHES(1, 000), ulY + INCHES(1, 000) - lYMin, ulZ,
g_pusARM, INCHES(1, 000), ulDepth);
}
//
// Bail out if the drawing has been aborted.
//
if(!DrawIsDrawing())
{
break;
}
//
// If a name string was supplied, then draw it now.
//
if(g_pcNameString[0] != '\0')
{
//
// Draw the string.
//
DrawString(ulX + INCHES(1, 000) + lLogoWidth,
ulY + INCHES(1, 000) - lYMin, ulZ, g_pcNameString,
INCHES(1, 000), ulDepth);
}
//
// Bail out if the drawing has been aborted.
//
if(!DrawIsDrawing())
{
break;
}
//
// Draw the border around the text and logo.
//
DrawImage(ulX + INCHES(0, 500), ulY + INCHES(0, 500), ulZ, g_pusBorder,
lYMax - lYMin + INCHES(1, 000), ulDepth);
//
// Do no draw any further iterations if the drawing was aborted.
//
if(!DrawIsDrawing())
{
break;
}
//
// Increase the depth of the next iteration.
//
ulDepth += ROUTER_DEPTH_INCREMENT;
}
//
// Stop the tool if required.
//
if(g_ulTool != 0x00)
{
ToolOff();
}
//
// Move the home position.
//
TableHome();
//
// Indicate that the drawing is complete.
//
DrawStop();
}
//*****************************************************************************
//
//! Performs the third CNC demonstration.
//!
//! This demonstration of the CNC machine draws a steer head two inches (5 cm)
//! tall. It is intended to be used with a pen and a piece of paper
//! approximately five inches (12.7 cm) square.
//!
//! \return None.
//
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -