Repetier-Firmware 0.2
Repetier/gcode.h
Go to the documentation of this file.
00001 /*
00002     This file is part of Repetier-Firmware.
00003 
00004     Repetier-Firmware is free software: you can redistribute it and/or modify
00005     it under the terms of the GNU General Public License as published by
00006     the Free Software Foundation, either version 3 of the License, or
00007     (at your option) any later version.
00008 
00009     Foobar is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012     GNU General Public License for more details.
00013 
00014     You should have received a copy of the GNU General Public License
00015     along with Repetier-Firmware.  If not, see <http://www.gnu.org/licenses/>.
00016 
00017 */
00018 
00019 #include <avr/pgmspace.h>
00020 // Workaround for http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34734 
00021 //#ifdef PROGMEM 
00022 //#undef PROGMEM 
00023 //#define PROGMEM __attribute__((section(".progmem.data"))) 
00024 //#endif
00025 
00026 typedef struct { // 52 bytes per command needed
00027    unsigned int params;
00028    unsigned int N; // Line number
00029    byte M;
00030    byte G;
00031    float X;
00032    float Y;
00033    float Z;
00034    float E;
00035    float F;
00036    byte T;
00037    long S;
00038    long P;
00039    char text[17];
00040 } GCode;
00041 
00042 class SerialOutput : public Print {
00043 public:
00044   SerialOutput();
00045   void write(uint8_t);
00046   void print_P(PGM_P ptr);
00047   void println_P(PGM_P ptr);
00048   void print_long_P(PGM_P ptr,long value);
00049   void print_int_P(PGM_P ptr,int value);
00050   void print_float_P(PGM_P ptr,float value,uint8_t digits = 2);
00051   void println_long_P(PGM_P ptr,long value);
00052   void println_int_P(PGM_P ptr,int value);
00053   void println_float_P(PGM_P ptr,float value,uint8_t digits = 2);
00054   void printFloat(double number, uint8_t digits=2); 
00055 
00056 };
00057 
00058 extern SerialOutput out;
00060 extern GCode *gcode_next_command();
00062 extern void gcode_command_finished();
00063 // check for new commands
00064 extern void gcode_read_serial();
00065 extern void gcode_print_command(GCode *code);
00066 extern bool gcode_parse_binary(GCode *code,byte *buffer);
00067 extern bool gcode_parse_ascii(GCode *code,char *line);
00068 
00069 // Helper macros to detect, if parameter is stored in GCode struct
00070 #define GCODE_HAS_N(a) ((a->params & 1)!=0)
00071 #define GCODE_HAS_M(a) ((a->params & 2)!=0)
00072 #define GCODE_HAS_G(a) ((a->params & 4)!=0)
00073 #define GCODE_HAS_X(a) ((a->params & 8)!=0)
00074 #define GCODE_HAS_Y(a) ((a->params & 16)!=0)
00075 #define GCODE_HAS_Z(a) ((a->params & 32)!=0)
00076 #define GCODE_HAS_E(a) ((a->params & 64)!=0)
00077 #define GCODE_HAS_F(a) ((a->params & 256)!=0)
00078 #define GCODE_HAS_T(a) ((a->params & 512)!=0)
00079 #define GCODE_HAS_S(a) ((a->params & 1024)!=0)
00080 #define GCODE_HAS_P(a) ((a->params & 2048)!=0)
00081 #define GCODE_HAS_STRING(a) ((a->params & 32768)!=0)
00082 
00083 extern byte debug_level;
00084 #define DEBUG_ECHO ((debug_level & 1)!=0)
00085 #define DEBUG_INFO ((debug_level & 2)!=0)
00086 #define DEBUG_ERRORS ((debug_level & 4)!=0)
00087 #define DEBUG_DRYRUN ((debug_level & 8)!=0)
00088 #define DEBUG_COMMUNICATION ((debug_level & 16)!=0)
00089 #define DEBUG_NO_MOVES ((debug_level & 32)!=0)
 All Data Structures Files Functions Variables Typedefs Friends Defines