Wednesday, April 7, 2010

Some CGCC Features and Examples

Some features of CGCC
If it works in C or C99 give it a try in CGCC

See the original posting for more info on what CGCC is
Link: Original CGCC Post

This page should give some examples of the capabilities that CGCC already supports.

C Style comments
Multiline block comments can be used to comment out large sections of GCode
// Single Line Comment
/*
Multiline Comment
*/

Declare functions with return values
float AddFive(float i) {
return i + 5
}

Evaluate expressions inside GCode
float x = 1;
float r = 2;
G00 X[x + r / 4]

#Include is supported
Useful for making libraries of functions in header files and including them in your GCode programs.
#include "lib.h"

Assignment from native GCode numbered variables
This is useful in probing operations
x = #1

Directly Emit GCode with the __gcode__ keyword
Useful if you run into a situation where CGCC doesn't handle exactly what you need. You can just emit the correct GCode manually.
__gcode__("(DEBUG, THIS IS A TEST)");

The const keyword to declare constants
const float Radius = 5;

Comparison Operators
== != < <= >= >

Arithmatic Operators
+ - * /

Compiler detects the use of uninitialized variables

Compiler detects use of undeclared variables

Postfix Increment and Decrement
x++
x--

If else statements
if (x == y) {
} else {
}

While statements
while (x != y) {
}

1 comment:

  1. Your blog is really awesome. i am so inspire to visit your site. Thanks for sharing this informative article...pcb design

    ReplyDelete