Browse Source

Smaller binary using inline gcode argument getters

Scott Lahteine 9 years ago
parent
commit
4980ecc1f7
2 changed files with 19 additions and 44 deletions
  1. 0
    11
      Marlin/Marlin.h
  2. 19
    33
      Marlin/Marlin_main.cpp

+ 0
- 11
Marlin/Marlin.h View File

291
 
291
 
292
 // GCode support for external objects
292
 // GCode support for external objects
293
 bool code_seen(char);
293
 bool code_seen(char);
294
-float code_value_float();
295
-unsigned long code_value_ulong();
296
-long code_value_long();
297
 int code_value_int();
294
 int code_value_int();
298
-uint16_t code_value_ushort();
299
-uint8_t code_value_byte();
300
-bool code_value_bool();
301
-float code_value_linear_units();
302
-float code_value_per_axis_unit(int axis);
303
-float code_value_axis_units(int axis);
304
 float code_value_temp_abs();
295
 float code_value_temp_abs();
305
 float code_value_temp_diff();
296
 float code_value_temp_diff();
306
-millis_t code_value_millis();
307
-millis_t code_value_millis_from_seconds();
308
 
297
 
309
 #if ENABLED(DELTA)
298
 #if ENABLED(DELTA)
310
   extern float delta[3];
299
   extern float delta[3];

+ 19
- 33
Marlin/Marlin_main.cpp View File

1167
   #endif
1167
   #endif
1168
 }
1168
 }
1169
 
1169
 
1170
-bool code_has_value() {
1170
+inline bool code_has_value() {
1171
   int i = 1;
1171
   int i = 1;
1172
   char c = seen_pointer[i];
1172
   char c = seen_pointer[i];
1173
   while (c == ' ') c = seen_pointer[++i];
1173
   while (c == ' ') c = seen_pointer[++i];
1176
   return NUMERIC(c);
1176
   return NUMERIC(c);
1177
 }
1177
 }
1178
 
1178
 
1179
-float code_value_float() {
1179
+inline float code_value_float() {
1180
   float ret;
1180
   float ret;
1181
   char* e = strchr(seen_pointer, 'E');
1181
   char* e = strchr(seen_pointer, 'E');
1182
   if (e) {
1182
   if (e) {
1189
   return ret;
1189
   return ret;
1190
 }
1190
 }
1191
 
1191
 
1192
-unsigned long code_value_ulong() { return strtoul(seen_pointer + 1, NULL, 10); }
1192
+inline unsigned long code_value_ulong() { return strtoul(seen_pointer + 1, NULL, 10); }
1193
 
1193
 
1194
-long code_value_long() { return strtol(seen_pointer + 1, NULL, 10); }
1194
+inline long code_value_long() { return strtol(seen_pointer + 1, NULL, 10); }
1195
 
1195
 
1196
-int code_value_int() { return (int)strtol(seen_pointer + 1, NULL, 10); }
1196
+inline int code_value_int() { return (int)strtol(seen_pointer + 1, NULL, 10); }
1197
 
1197
 
1198
-uint16_t code_value_ushort() { return (uint16_t)strtoul(seen_pointer + 1, NULL, 10); }
1198
+inline uint16_t code_value_ushort() { return (uint16_t)strtoul(seen_pointer + 1, NULL, 10); }
1199
 
1199
 
1200
-uint8_t code_value_byte() { return (uint8_t)(constrain(strtol(seen_pointer + 1, NULL, 10), 0, 255)); }
1200
+inline uint8_t code_value_byte() { return (uint8_t)(constrain(strtol(seen_pointer + 1, NULL, 10), 0, 255)); }
1201
 
1201
 
1202
-bool code_value_bool() { return code_value_byte() > 0; }
1202
+inline bool code_value_bool() { return code_value_byte() > 0; }
1203
 
1203
 
1204
 #if ENABLED(INCH_MODE_SUPPORT)
1204
 #if ENABLED(INCH_MODE_SUPPORT)
1205
-  void set_input_linear_units(LinearUnit units) {
1205
+  inline void set_input_linear_units(LinearUnit units) {
1206
     switch (units) {
1206
     switch (units) {
1207
       case LINEARUNIT_INCH:
1207
       case LINEARUNIT_INCH:
1208
         linear_unit_factor = 25.4;
1208
         linear_unit_factor = 25.4;
1215
     volumetric_unit_factor = pow(linear_unit_factor, 3.0);
1215
     volumetric_unit_factor = pow(linear_unit_factor, 3.0);
1216
   }
1216
   }
1217
 
1217
 
1218
-  float axis_unit_factor(int axis) {
1218
+  inline float axis_unit_factor(int axis) {
1219
     return (axis == E_AXIS && volumetric_enabled ? volumetric_unit_factor : linear_unit_factor);
1219
     return (axis == E_AXIS && volumetric_enabled ? volumetric_unit_factor : linear_unit_factor);
1220
   }
1220
   }
1221
 
1221
 
1222
-  float code_value_linear_units() {
1223
-    return code_value_float() * linear_unit_factor;
1224
-  }
1225
-
1226
-  float code_value_per_axis_unit(int axis) {
1227
-    return code_value_float() / axis_unit_factor(axis);
1228
-  }
1222
+  inline float code_value_linear_units() { return code_value_float() * linear_unit_factor; }
1223
+  inline float code_value_per_axis_unit(int axis) { return code_value_float() / axis_unit_factor(axis); }
1224
+  inline float code_value_axis_units(int axis) { return code_value_float() * axis_unit_factor(axis); }
1229
 
1225
 
1230
-  float code_value_axis_units(int axis) {
1231
-    return code_value_float() * axis_unit_factor(axis);
1232
-  }
1233
 #else
1226
 #else
1234
-  float code_value_linear_units() { return code_value_float(); }
1235
 
1227
 
1236
-  float code_value_per_axis_unit(int axis) { return code_value_float(); }
1228
+  inline float code_value_linear_units() { return code_value_float(); }
1229
+  inline float code_value_per_axis_unit(int axis) { return code_value_float(); }
1230
+  inline float code_value_axis_units(int axis) { return code_value_float(); }
1237
 
1231
 
1238
-  float code_value_axis_units(int axis) { return code_value_float(); }
1239
 #endif
1232
 #endif
1240
 
1233
 
1241
 #if ENABLED(TEMPERATURE_UNITS_SUPPORT)
1234
 #if ENABLED(TEMPERATURE_UNITS_SUPPORT)
1242
-  void set_input_temp_units(TempUnit units) {
1243
-    input_temp_units = units;
1244
-  }
1235
+  inline void set_input_temp_units(TempUnit units) { input_temp_units = units; }
1245
   
1236
   
1246
   float code_value_temp_abs() {
1237
   float code_value_temp_abs() {
1247
     switch (input_temp_units) {
1238
     switch (input_temp_units) {
1272
   float code_value_temp_diff() { return code_value_float(); }
1263
   float code_value_temp_diff() { return code_value_float(); }
1273
 #endif
1264
 #endif
1274
 
1265
 
1275
-millis_t code_value_millis() {
1276
-  return code_value_ulong();
1277
-}
1278
-
1279
-millis_t code_value_millis_from_seconds() {
1280
-  return code_value_float() * 1000;
1281
-}
1266
+inline millis_t code_value_millis() { return code_value_ulong(); }
1267
+inline millis_t code_value_millis_from_seconds() { return code_value_float() * 1000; }
1282
 
1268
 
1283
 bool code_seen(char code) {
1269
 bool code_seen(char code) {
1284
   seen_pointer = strchr(current_command_args, code);
1270
   seen_pointer = strchr(current_command_args, code);

Loading…
Cancel
Save