From f8be4ab2c6a03fe71f6ca3f2eb75bb7ca7127f13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= Date: Tue, 4 Jul 2017 23:22:03 +0200 Subject: [PATCH] helper to keep scad and arduino values in sync - run teeth_config.sh to sync scad values from gears in arduino code. - small reindent --- arduino/startracker.ino | 15 +++++++++------ arduino/teeth_config.h | 4 ++++ sync_values.sh | 16 ++++++++++++++++ 3 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 arduino/teeth_config.h create mode 100755 sync_values.sh diff --git a/arduino/startracker.ino b/arduino/startracker.ino index abe1eb3..3549cb7 100644 --- a/arduino/startracker.ino +++ b/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; diff --git a/arduino/teeth_config.h b/arduino/teeth_config.h new file mode 100644 index 0000000..181de27 --- /dev/null +++ b/arduino/teeth_config.h @@ -0,0 +1,4 @@ +#pragma once +#define CONFIG_TEETH_SMALL 13.0 +#define CONFIG_TEETH_BIG 51.0 + diff --git a/sync_values.sh b/sync_values.sh new file mode 100755 index 0000000..85c9682 --- /dev/null +++ b/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