Browse Source

helper to keep scad and arduino values in sync

- run teeth_config.sh to sync scad values from gears in arduino code.
- small reindent
master
Marc Poulhiès 4 years ago
parent
commit
f8be4ab2c6
  1. 15
      arduino/startracker.ino
  2. 4
      arduino/teeth_config.h
  3. 16
      sync_values.sh

15
arduino/startracker.ino

@ -59,8 +59,11 @@ static const bool stepper_direction = true;
//ratio between the large gear and the small one=0.2549
// Science here !
static const float nr_teeth_small = 11.0;
static const float nr_teeth_big = 53.0;
#include "teeth_config.h"
static const float nr_teeth_small = CONFIG_TEETH_SMALL; // 13.0
static const float nr_teeth_big = CONFIG_TEETH_BIG; // 51.0
static const float axis_hinge_dist_mm = 200;
// Use immediate value. Using symbolic values leads to incorrect value.
@ -80,10 +83,10 @@ static struct rot_state_t {
float stepper_gear_rot_rad = 0;
} rot_state;
#define DUMP(v) do { \
Serial.print(#v " "); \
Serial.println(v, 10); \
} while(0)
#define DUMP(v) do { \
Serial.print(#v " "); \
Serial.println(v, 10); \
} while(0)
static void debug_long(rot_state_t *s){
const unsigned long ellapsed_in_sec = s->elapsed_time_millis/1000;

4
arduino/teeth_config.h

@ -0,0 +1,4 @@
#pragma once
#define CONFIG_TEETH_SMALL 13.0
#define CONFIG_TEETH_BIG 51.0

16
sync_values.sh

@ -0,0 +1,16 @@
#!/bin/bash
SCAD_FILE=3d_models/gears.scad
CONFIG_GEN=arduino/teeth_config.h
gear1_teeth=$(grep 'gear1_teeth =' < $SCAD_FILE | sed -e 's/gear1_teeth = \(.*\);/\1/g')
gear2_teeth=$(grep 'gear2_teeth =' < $SCAD_FILE | sed -e 's/gear2_teeth = \(.*\);/\1/g')
echo $gear2_teeth $gear1_teeth
TMPL="#pragma once\n\
#define CONFIG_TEETH_SMALL 13.0\n\
#define CONFIG_TEETH_BIG 51.0\n\
"
echo -e $TMPL > $CONFIG_GEN
Loading…
Cancel
Save