Skip to content

Commit f72119b

Browse files
gin66claude
andcommitted
refactor: Step 3 — move TEST stub to pd_test/test_queue.h
Create src/pd_test/test_queue.h with class StepperQueue : public StepperQueueBase for PC-based testing. Contains _isRunning, isRunning(), isReadyForCommands(), and all common method declarations. Adds #ifdef SUPPORT_ESP32_RMT block so test_17 (which simulates an ESP32 RMT environment) still compiles correctly. Update StepperISR.h: dispatch to pd_test/test_queue.h when TEST is defined (after SUPPORT_AVR, before the remaining monolithic class). Remove the now-redundant #if defined(TEST) block from the monolithic StepperQueue class. Add pd_test/test_queue.h to LIB_H in the PC test Makefile. PC tests: all 20 pass. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent dc75215 commit f72119b

3 files changed

Lines changed: 43 additions & 7 deletions

File tree

‎extras/tests/pc_based/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ ramp_helper.o: ramp_helper.cpp $(SRC_LIB_H) stubs.h
2020

2121
LIB_H=FastAccelStepper.h Log2Representation.h StepperISR.h \
2222
RampGenerator.h RampControl.h RampCalculator.h \
23-
fas_arch/common.h fas_queue/base.h
23+
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
2626

‎src/StepperISR.h‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
#if defined(SUPPORT_AVR)
1010
#include "pd_avr/avr_queue.h"
11+
#elif defined(TEST)
12+
#include "pd_test/test_queue.h"
1113
#else
1214

1315
class StepperQueue : public StepperQueueBase {
@@ -70,12 +72,6 @@ class StepperQueue : public StepperQueueBase {
7072
volatile bool _pauseCommanded;
7173
volatile uint32_t timePWMInterruptEnabled;
7274
#endif
73-
#if defined(TEST)
74-
volatile bool _isRunning;
75-
inline bool isReadyForCommands() { return true; }
76-
inline bool isRunning() { return _isRunning; }
77-
#endif
78-
7975
AqeResultCode addQueueEntry(const struct stepper_command_s* cmd, bool start);
8076
int32_t getCurrentPosition();
8177
uint32_t ticksInQueue();

‎src/pd_test/test_queue.h‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#ifndef PD_TEST_QUEUE_H
2+
#define PD_TEST_QUEUE_H
3+
4+
#include "FastAccelStepper.h"
5+
#include "fas_queue/base.h"
6+
7+
class StepperQueue : public StepperQueueBase {
8+
public:
9+
volatile bool _isRunning;
10+
inline bool isReadyForCommands() { return true; }
11+
inline bool isRunning() { return _isRunning; }
12+
#ifdef SUPPORT_ESP32_RMT
13+
RMT_CHANNEL_T channel;
14+
bool _rmtStopped;
15+
bool lastChunkContainsSteps;
16+
#endif
17+
18+
AqeResultCode addQueueEntry(const struct stepper_command_s* cmd, bool start);
19+
int32_t getCurrentPosition();
20+
uint32_t ticksInQueue();
21+
bool hasTicksInQueue(uint32_t min_ticks);
22+
bool getActualTicksWithDirection(struct actual_ticks_s* speed);
23+
24+
bool init(FastAccelStepperEngine* engine, uint8_t queue_num,
25+
uint8_t step_pin);
26+
void startQueue();
27+
void forceStop();
28+
void _initVars();
29+
void connect();
30+
void disconnect();
31+
32+
void setDirPin(uint8_t dir_pin, bool _dirHighCountsUp) {
33+
dirPin = dir_pin;
34+
dirHighCountsUp = _dirHighCountsUp;
35+
}
36+
37+
static bool isValidStepPin(uint8_t step_pin);
38+
};
39+
40+
#endif // PD_TEST_QUEUE_H

0 commit comments

Comments
 (0)