Skip to content

Commit ce49870

Browse files
committed
refactor: move Log2Representation to log2/ subdirectory
Hide internal log2 math implementation from public API by moving Log2Representation.h/.cpp and Log2RepresentationConst.h to src/log2/. Also fix circular include between Log2Representation.h and Const.h.
1 parent cc0ae96 commit ce49870

8 files changed

Lines changed: 12 additions & 11 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" "src/fas_ramp"
3-
INCLUDE_DIRS "src" "src/pd_esp32" "src/fas_ramp"
2+
SRC_DIRS "src" "src/pd_esp32" "src/fas_ramp" "src/log2"
3+
INCLUDE_DIRS "src" "src/pd_esp32" "src/fas_ramp" "src/log2"
44
REQUIRES
55
esp_driver_gpio
66
esp_driver_rmt

extras/tests/pc_based/Makefile

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

21-
LIB_H=FastAccelStepper.h Log2Representation.h StepperISR.h \
21+
LIB_H=FastAccelStepper.h log2/Log2Representation.h log2/Log2RepresentationConst.h StepperISR.h \
2222
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 \
@@ -33,15 +33,15 @@ test_%.o: test_%.cpp $(SRC_LIB_H) RampChecker.h stubs.h
3333
g++ -c $(CXXFLAGS) -o $@ $<
3434

3535
log2_test: log2_test.o Log2Representation.o
36-
log2_test.o: log2_test.cpp $(PRJ_ROOT)/src/Log2Representation.h stubs.h test_03.h
36+
log2_test.o: log2_test.cpp $(PRJ_ROOT)/src/log2/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/fas_ramp/RampCalculator.h stubs.h test_03.h
39+
rmc_test.o: rmc_test.cpp $(PRJ_ROOT)/src/log2/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

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

4747
RampGenerator.o: $(PRJ_ROOT)/src/fas_ramp/RampGenerator.cpp $(SRC_LIB_H)

extras/tests/pc_based/log2_test.cpp

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

3-
#include "Log2Representation.h"
3+
#include "log2/Log2Representation.h"
44

55
//
66
// This file can be renamed to a .ino and compiled as sketch to be run on the

extras/tests/pc_based/rmc_test.cpp

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

6+
#include "log2/Log2Representation.h"
67
#include "fas_ramp/RampCalculator.h"
78

89
// Not a real test case

src/fas_ramp/RampCalculator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include <stdint.h>
55

6-
#include "Log2Representation.h"
6+
#include "log2/Log2Representation.h"
77
#include "fas_arch/common.h"
88

99
#if (TICKS_PER_S == 16000000L)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#define PROGMEM
66
#define pgm_read_byte_near(x) (*(x))
77
#endif
8-
#include "Log2Representation.h"
8+
#include "log2/Log2Representation.h"
99
#ifdef TEST
1010
#include <stdio.h>
1111
#endif
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define LOG2REPRESENTATION_H
33
#include <stdint.h>
44

5-
#include <Log2RepresentationConst.h>
5+
#include "log2/Log2RepresentationConst.h"
66

77
typedef int16_t pmf_logarithmic;
88

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#ifndef LOG2REPRESENTATIONCONST_H
44
#define LOG2REPRESENTATIONCONST_H
55

6-
#include <Log2Representation.h>
6+
// pmf_logarithmic must be defined before including this file
77

88
// LOG2_CONST_1 = 0.000000 0 = 0x0000
99
#define LOG2_CONST_1 ((pmf_logarithmic)0x0000)

0 commit comments

Comments
 (0)