Skip to content

Commit 490e7f3

Browse files
committed
Revert "put common types into namespace"
This reverts commit f6e55bf.
1 parent f6e55bf commit 490e7f3

9 files changed

+32
-37
lines changed

examples/MultipleScenesSD/MultipleScenesSD.ino

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

1717
#define SERVO_PIN 3
1818
#define CS_PIN 4
19-
#define SCENE_AMOUNT 2
19+
#define SCENE_AMOUNT = 2
2020

2121
// Servo object to send positions
2222
Servo myServo;

src/BlenderServoAnimation.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -322,16 +322,16 @@ Scene *BlenderServoAnimation::getCurrentScene() {
322322
return this->scene;
323323
}
324324

325-
void BlenderServoAnimation::onPositionChange(PositionCallback callback) {
326-
this->servoManager.setPositionCallback(callback);
325+
void BlenderServoAnimation::onPositionChange(pcb positionCallback) {
326+
this->servoManager.setPositionCallback(positionCallback);
327327
}
328328

329-
void BlenderServoAnimation::onModeChange(ModeCallback callback) {
330-
this->modeCallback = callback;
329+
void BlenderServoAnimation::onModeChange(mcb modeCallback) {
330+
this->modeCallback = modeCallback;
331331
}
332332

333-
void BlenderServoAnimation::onSceneChange(SceneCallback callback) {
334-
this->sceneCallback = callback;
333+
void BlenderServoAnimation::onSceneChange(scb sceneCallback) {
334+
this->sceneCallback = sceneCallback;
335335
}
336336

337337
void BlenderServoAnimation::changeMode(byte mode) {

src/BlenderServoAnimation.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "AnimationData.h"
22
#include "Scene.h"
33
#include "ServoManager.h"
4-
#include "CommonTypes.h"
4+
#include "typedefs.h"
55
#include <Arduino.h>
66
#include <stdarg.h>
77

@@ -31,9 +31,9 @@ class BlenderServoAnimation {
3131

3232
void addScene(const byte *data, int size, byte fps, int frames);
3333
void addScene(Stream &stream, byte fps, int frame);
34-
void onPositionChange(PositionCallback callback);
35-
void onModeChange(ModeCallback callback);
36-
void onSceneChange(SceneCallback callback);
34+
void onPositionChange(pcb positionCallback);
35+
void onModeChange(mcb modeCallback);
36+
void onSceneChange(scb sceneCallback);
3737
void run(unsigned long currentMicros = micros());
3838
void play();
3939
void playSingle(byte index);
@@ -65,8 +65,8 @@ class BlenderServoAnimation {
6565

6666
bool *playedIndexes = nullptr;
6767

68-
ModeCallback modeCallback = nullptr;
69-
SceneCallback sceneCallback = nullptr;
68+
mcb modeCallback = nullptr;
69+
scb sceneCallback = nullptr;
7070

7171
byte mode = MODE_DEFAULT;
7272

src/CommonTypes.h

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/Servo.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#include "Servo.h"
2-
#include "CommonTypes.h"
2+
#include "typedefs.h"
33
#include <Arduino.h>
44

55
using BlenderServoAnimationLibrary::Servo;
66

7-
Servo::Servo(byte id, PositionCallback callback, byte threshold) {
7+
Servo::Servo(byte id, pcb positionCallback, byte threshold) {
88
this->id = id;
99
this->positionCallback = positionCallback;
1010
this->setThreshold(threshold);
@@ -53,8 +53,8 @@ bool Servo::isNeutral() {
5353
return this->currentPosition == this->neutralPosition;
5454
}
5555

56-
void Servo::setPositionCallback(PositionCallback callback) {
57-
this->positionCallback = callback;
56+
void Servo::setPositionCallback(pcb positionCallback) {
57+
this->positionCallback = positionCallback;
5858
}
5959

6060
void Servo::setThreshold(byte value) {

src/Servo.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "CommonTypes.h"
1+
#include "typedefs.h"
22
#include <Arduino.h>
33

44
#ifndef BlenderServoAnimationLibrary_Servo_H
@@ -9,13 +9,13 @@ namespace BlenderServoAnimationLibrary {
99
class Servo {
1010

1111
public:
12-
Servo(byte id, PositionCallback callback, byte threshold = 0);
12+
Servo(byte id, pcb positionCallback, byte threshold = 0);
1313

1414
void move(int position, bool useOffset = true);
1515
void moveTowardsNeutral();
1616
void setThreshold(byte value);
1717
void setOffset(int offset);
18-
void setPositionCallback(PositionCallback callback);
18+
void setPositionCallback(pcb positionCallback);
1919

2020
bool isNeutral();
2121

@@ -32,7 +32,7 @@ class Servo {
3232
int currentPosition = -1;
3333
int offset = 0;
3434

35-
PositionCallback positionCallback = nullptr;
35+
pcb positionCallback = nullptr;
3636

3737
bool positionExceedsThreshold(int position);
3838
};

src/ServoManager.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ ServoManager::~ServoManager() {
1111
}
1212
}
1313

14-
void ServoManager::setPositionCallback(PositionCallback callback) {
15-
this->positionCallback = callback;
14+
void ServoManager::setPositionCallback(pcb positionCallback) {
15+
this->positionCallback = positionCallback;
1616

1717
for (byte i = 0; i < this->servoAmount; i++) {
18-
this->servos[i]->setPositionCallback(callback);
18+
this->servos[i]->setPositionCallback(positionCallback);
1919
}
2020
}
2121

src/ServoManager.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "AnimationData.h"
22
#include "Command.h"
33
#include "Servo.h"
4-
#include "CommonTypes.h"
4+
#include "typedefs.h"
55
#include <Arduino.h>
66

77
#ifndef BlenderServoAnimationLibrary_ServoManager_H
@@ -14,7 +14,7 @@ class ServoManager {
1414
public:
1515
~ServoManager();
1616

17-
void setPositionCallback(PositionCallback callback);
17+
void setPositionCallback(pcb positionCallback);
1818
void setDefaultThreshold(byte value);
1919
void setThreshold(byte servoId, byte value);
2020
void setOffset(byte servoId, int offset);
@@ -28,7 +28,7 @@ class ServoManager {
2828

2929
Command command;
3030

31-
PositionCallback positionCallback = nullptr;
31+
pcb positionCallback = nullptr;
3232

3333
byte servoAmount = 0;
3434
byte defaultThreshold = 0;

src/typedefs.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#include <Arduino.h>
2+
3+
typedef void (*mcb)(byte, byte); // Mode callback
4+
typedef void (*pcb)(byte, int); // Position callback
5+
typedef void (*scb)(byte, byte); // Scene callback

0 commit comments

Comments
 (0)