Skip to content

Commit cc0ae96

Browse files
committed
refactor: move ramp implementation to fas_ramp/ subdirectory
Hide internal ramp generator, calculator and control headers from public API by moving them to src/fas_ramp/. This reduces the visible definitions in the public header to the minimum.
1 parent 65bc8f0 commit cc0ae96

10 files changed

Lines changed: 20 additions & 18 deletions

File tree

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
idf_component_register(
2-
SRC_DIRS "src" "src/pd_esp32"
3-
INCLUDE_DIRS "src" "src/pd_esp32"
2+
SRC_DIRS "src" "src/pd_esp32" "src/fas_ramp"
3+
INCLUDE_DIRS "src" "src/pd_esp32" "src/fas_ramp"
44
REQUIRES
55
esp_driver_gpio
66
esp_driver_rmt

extras/tests/pc_based/Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ ramp_helper.o: ramp_helper.cpp $(SRC_LIB_H) stubs.h
1919
g++ -c $(CXXFLAGS) -o $@ $<
2020

2121
LIB_H=FastAccelStepper.h Log2Representation.h StepperISR.h \
22-
RampGenerator.h RampControl.h RampCalculator.h \
22+
fas_ramp/RampGenerator.h fas_ramp/RampControl.h fas_ramp/RampCalculator.h \
2323
fas_arch/common.h fas_queue/base.h pd_test/test_queue.h
2424
LIB_O=FastAccelStepper.o Log2Representation.o StepperISR_test.o \
2525
RampGenerator.o RampControl.o RampCalculator.o StepperISR.o
@@ -36,21 +36,21 @@ log2_test: log2_test.o Log2Representation.o
3636
log2_test.o: log2_test.cpp $(PRJ_ROOT)/src/Log2Representation.h stubs.h test_03.h
3737

3838
rmc_test: rmc_test.o Log2Representation.o RampCalculator.o
39-
rmc_test.o: rmc_test.cpp $(PRJ_ROOT)/src/Log2Representation.h $(PRJ_ROOT)/src/RampCalculator.h stubs.h test_03.h
39+
rmc_test.o: rmc_test.cpp $(PRJ_ROOT)/src/Log2Representation.h $(PRJ_ROOT)/src/fas_ramp/RampCalculator.h stubs.h test_03.h
4040

4141
FastAccelStepper.o: $(PRJ_ROOT)/src/FastAccelStepper.cpp $(SRC_LIB_H)
4242
$(COMPILE.cpp) $< -o $@
4343

4444
Log2Representation.o: $(PRJ_ROOT)/src/Log2Representation.cpp $(PRJ_ROOT)/src/Log2Representation.h
4545
$(COMPILE.cpp) $< -o $@
4646

47-
RampGenerator.o: $(PRJ_ROOT)/src/RampGenerator.cpp $(SRC_LIB_H)
47+
RampGenerator.o: $(PRJ_ROOT)/src/fas_ramp/RampGenerator.cpp $(SRC_LIB_H)
4848
$(COMPILE.cpp) $< -o $@
4949

50-
RampControl.o: $(PRJ_ROOT)/src/RampControl.cpp $(SRC_LIB_H)
50+
RampControl.o: $(PRJ_ROOT)/src/fas_ramp/RampControl.cpp $(SRC_LIB_H)
5151
$(COMPILE.cpp) $< -o $@
5252

53-
RampCalculator.o: $(PRJ_ROOT)/src/RampCalculator.cpp $(SRC_LIB_H)
53+
RampCalculator.o: $(PRJ_ROOT)/src/fas_ramp/RampCalculator.cpp $(SRC_LIB_H)
5454
$(COMPILE.cpp) $< -o $@
5555

5656
StepperISR.o: $(PRJ_ROOT)/src/StepperISR.cpp $(SRC_LIB_H)

extras/tests/pc_based/rmc_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include <stdio.h>
44
#include <stdlib.h>
55

6-
#include "RampCalculator.h"
6+
#include "fas_ramp/RampCalculator.h"
77

88
// Not a real test case
99

src/FastAccelStepper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ class FastAccelStepperEngine {
225225
// and until the stepper task is serviced. The stepper task will then
226226
// control the direction flags
227227

228-
#include "RampGenerator.h"
228+
#include "fas_ramp/RampGenerator.h"
229229

230230
//
231231
// ## Timing values - Architecture dependent
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "RampCalculator.h"
1+
#include "fas_ramp/RampCalculator.h"
22

33
#include <math.h>
44

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include "FastAccelStepper.h"
44
#include "StepperISR.h"
55

6-
#include "RampControl.h"
6+
#include "fas_ramp/RampControl.h"
77
#include "fas_arch/common.h"
88

99
#ifdef SUPPORT_LOG2_TIMER_FREQ_VARIABLES
@@ -26,7 +26,7 @@ void init_ramp_module() {
2626
// #define TRACE
2727
#ifdef TRACE
2828
#ifdef TEST
29-
#define TRACE_OUTPUT(x) printf(": %c \n",x)
29+
#define TRACE_OUTPUT(x) printf(": %c \n", x)
3030
#endif
3131
#else
3232
#define TRACE_OUTPUT(x)
@@ -182,8 +182,8 @@ void _getNextCommand(const struct ramp_ro_s* ramp, const struct ramp_rw_s* rw,
182182
uint32_t possible_coast_steps =
183183
(remaining_steps - performed_ramp_up_steps) >> 2;
184184
#ifdef TEST
185-
printf("possible coast steps %d, prus=%d\n", possible_coast_steps,
186-
performed_ramp_up_steps);
185+
printf("possible coast steps %d, prus=%d\n", possible_coast_steps,
186+
performed_ramp_up_steps);
187187
#endif
188188
if ((possible_coast_steps > 0) && (possible_coast_steps <= 510)) {
189189
// curr_ticks is not necessarily correct due to speed increase
@@ -192,7 +192,8 @@ void _getNextCommand(const struct ramp_ro_s* ramp, const struct ramp_rw_s* rw,
192192
TRACE_OUTPUT('l');
193193
this_state = RAMP_STATE_COAST;
194194
#ifdef TEST
195-
printf("high speed coast %d %d coast_time=%d\n", possible_coast_steps,
195+
printf("high speed coast %d %d coast_time=%d\n",
196+
possible_coast_steps,
196197
remaining_steps - performed_ramp_up_steps, coast_time);
197198
#endif
198199
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#ifndef RAMP_CONTROL_H
22
#define RAMP_CONTROL_H
33

4+
#include "fas_ramp/RampCalculator.h"
45
#include "fas_arch/common.h"
56

67
struct ramp_ro_s {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include <stdint.h>
22

33
#include "FastAccelStepper.h"
4-
#include "RampGenerator.h"
4+
#include "fas_ramp/RampGenerator.h"
55
#include "StepperISR.h"
66

77
// This define in order to not shoot myself.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#ifndef RAMP_GENERATOR_H
22
#define RAMP_GENERATOR_H
33

4-
#include "RampCalculator.h"
5-
#include "RampControl.h"
4+
#include "fas_ramp/RampCalculator.h"
5+
#include "fas_ramp/RampControl.h"
66
#include "fas_arch/common.h"
77

88
class FastAccelStepper;

0 commit comments

Comments
 (0)