-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
merge live and progmem stream into animation data
- Loading branch information
1 parent
d9ca634
commit 83cc85d
Showing
30 changed files
with
321 additions
and
354 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
#include "internal/Animation.h" | ||
#include "internal/LiveStream.h" | ||
#include "internal/Scene.h" | ||
#include "internal/AnimationData.h" | ||
#include <Arduino.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#include "AnimationData.h" | ||
#include <Arduino.h> | ||
|
||
using namespace BlenderServoAnimation; | ||
|
||
AnimationData::AnimationData() { | ||
} | ||
|
||
AnimationData::AnimationData(const byte *data, int dataSize) { | ||
this->data = data; | ||
this->dataSize = dataSize; | ||
} | ||
|
||
AnimationData::AnimationData(Stream *stream) { | ||
this->stream = stream; | ||
} | ||
|
||
bool AnimationData::isAvailable() { | ||
if (this->stream) { | ||
return this->stream->available() > 0; | ||
} else if (this->data) { | ||
return this->dataSize - this->dataPosition > 0; | ||
} else { | ||
return this->readIndex != this->writeIndex; | ||
} | ||
} | ||
|
||
byte AnimationData::getNextByte() { | ||
if (this->stream) { | ||
return this->stream->read(); | ||
} else if (this->data) { | ||
return this->readProgmem(); | ||
} else { | ||
return this->readBuffer(); | ||
} | ||
} | ||
|
||
byte AnimationData::readProgmem() { | ||
if (this->dataPosition < this->dataSize) { | ||
return pgm_read_byte(this->data + this->dataPosition++); | ||
} else { | ||
return -1; | ||
} | ||
} | ||
|
||
byte AnimationData::readBuffer() { | ||
byte value = this->buffer[this->readIndex++]; | ||
|
||
if (this->readIndex >= BUFFER_SIZE) { | ||
this->readIndex = 0; | ||
} | ||
|
||
return value; | ||
} | ||
|
||
void AnimationData::writeByte(byte value) { | ||
this->buffer[this->writeIndex++] = value; | ||
|
||
if (this->writeIndex >= BUFFER_SIZE) { | ||
this->writeIndex = 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#include <Arduino.h> | ||
|
||
#ifndef BlenderServoAnimation_AnimationData_H | ||
#define BlenderServoAnimation_AnimationData_H | ||
|
||
namespace BlenderServoAnimation { | ||
|
||
class AnimationData { | ||
|
||
public: | ||
static const byte LINE_BREAK = 0xA; | ||
|
||
AnimationData(); | ||
AnimationData(const byte *data, int dataSize); | ||
AnimationData(Stream *stream); | ||
|
||
bool isAvailable(); | ||
|
||
byte getNextByte(); | ||
|
||
void writeByte(byte value); | ||
|
||
private: | ||
static const byte BUFFER_SIZE = 64; | ||
|
||
int dataSize = 0; | ||
int dataPosition = 0; | ||
|
||
const byte *data = nullptr; | ||
|
||
Stream *stream = nullptr; | ||
|
||
byte buffer[BUFFER_SIZE] = {0}; | ||
byte writeIndex = 0; | ||
byte readIndex = 0; | ||
|
||
byte readProgmem(); | ||
byte readBuffer(); | ||
}; | ||
|
||
} // namespace BlenderServoAnimation | ||
|
||
#endif |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.