Skip to content

Commit

Permalink
CueHandler - Converted CueController pointers to references.
Browse files Browse the repository at this point in the history
Section - Reverted `Section::set_mirror()` to return a pointer instead
of reference.
Pixel - Commented out `DISABLE_COLOR_BUFFER` by default.
  • Loading branch information
8bitbuddhist committed May 5, 2019
1 parent ae10896 commit c21a0e2
Show file tree
Hide file tree
Showing 17 changed files with 226 additions and 228 deletions.
1 change: 0 additions & 1 deletion src/core/maestro.h
@@ -1,7 +1,6 @@
/*
Maestro.cpp - Master class for coordinating Sections.
*/

#ifndef MAESTRO_H
#define MAESTRO_H

Expand Down
4 changes: 2 additions & 2 deletions src/core/pixel.h
Expand Up @@ -3,8 +3,8 @@
Inspired by RGBMood (http://forum.arduino.cc/index.php?topic=90160.0)
*/

// TODO: How to make this available in a sketch?
#define DISABLE_COLOR_BUFFER // Disable per-Pixel fading and color buffering.
// FIXME: How to make this available in a sketch?
//#define DISABLE_COLOR_BUFFER // Disable per-Pixel fading and color buffering.

#ifndef PIXEL_H
#define PIXEL_H
Expand Down
5 changes: 2 additions & 3 deletions src/core/section.cpp
Expand Up @@ -384,8 +384,7 @@ namespace PixelMaestro {
* @param x Mirror the x axis.
* @param y Mirror the y axis.
*/
// FIXME: Convert back to pointer (could include nullptr)
Section::Mirror& Section::set_mirror(bool x, bool y) {
Section::Mirror* Section::set_mirror(bool x, bool y) {
if (x == false && y == false) {
delete mirror_;
mirror_ = nullptr;
Expand All @@ -398,7 +397,7 @@ namespace PixelMaestro {
mirror_->set(x, y, this->dimensions_);
}

return *mirror_;
return mirror_;
}

/**
Expand Down
9 changes: 2 additions & 7 deletions src/core/section.h
Expand Up @@ -148,12 +148,7 @@ namespace PixelMaestro {
When getting color output, use get_pixel_color(). This returns RGB values after blending the two Sections together.
*/
struct Layer {
/**
* The Section to use as the layer.
* This is different from the Section containing the Layer object.
*
* TODO: Convert to reference
*/
/// The Section to use as the layer.
Section* section = nullptr;

/// Method of blending the output from the Layer with the base Section.
Expand Down Expand Up @@ -224,7 +219,7 @@ namespace PixelMaestro {
void set_dimensions(uint16_t x, uint16_t y);
Layer& set_layer(Colors::MixMode mix_mode = Colors::MixMode::Alpha, uint8_t alpha = 128);
void set_maestro(Maestro& maestro);
Mirror& set_mirror(bool x, bool y);
Mirror* set_mirror(bool x, bool y);
Point& set_offset(uint16_t x, uint16_t y);
void set_one(uint16_t x, uint16_t y, const Colors::RGB& color, uint8_t step_count);
Scroll& set_scroll(uint16_t x, uint16_t y, bool reverse_x = false, bool reverse_y = false);
Expand Down
80 changes: 40 additions & 40 deletions src/cue/animationcuehandler.cpp
Expand Up @@ -16,9 +16,9 @@ namespace PixelMaestro {
section_num,
layer_num
);
controller_->get_buffer()[++index] = multiplier;
controller_.get_buffer()[++index] = multiplier;

return controller_->assemble(++index);
return controller_.assemble(++index);
}

uint8_t* AnimationCueHandler::set_lightning_options(uint8_t section_num, uint8_t layer_num, uint8_t num_bolts, int8_t drift, uint8_t fork_chance) {
Expand All @@ -28,11 +28,11 @@ namespace PixelMaestro {
section_num,
layer_num
);
controller_->get_buffer()[++index] = num_bolts;
controller_->get_buffer()[++index] = (uint8_t)drift;
controller_->get_buffer()[++index] = fork_chance;
controller_.get_buffer()[++index] = num_bolts;
controller_.get_buffer()[++index] = (uint8_t)drift;
controller_.get_buffer()[++index] = fork_chance;

return controller_->assemble(++index);
return controller_.assemble(++index);
}

uint8_t* AnimationCueHandler::set_plasma_options(uint8_t section_num, uint8_t layer_num, float size, float resolution) {
Expand All @@ -45,16 +45,16 @@ namespace PixelMaestro {
section_num,
layer_num
);
controller_->get_buffer()[++index] = size_byte.converted.byte[0];
controller_->get_buffer()[++index] = size_byte.converted.byte[1];
controller_->get_buffer()[++index] = size_byte.converted.byte[2];
controller_->get_buffer()[++index] = size_byte.converted.byte[3];
controller_->get_buffer()[++index] = resolution_byte.converted.byte[0];
controller_->get_buffer()[++index] = resolution_byte.converted.byte[1];
controller_->get_buffer()[++index] = resolution_byte.converted.byte[2];
controller_->get_buffer()[++index] = resolution_byte.converted.byte[3];

return controller_->assemble(++index);
controller_.get_buffer()[++index] = size_byte.converted.byte[0];
controller_.get_buffer()[++index] = size_byte.converted.byte[1];
controller_.get_buffer()[++index] = size_byte.converted.byte[2];
controller_.get_buffer()[++index] = size_byte.converted.byte[3];
controller_.get_buffer()[++index] = resolution_byte.converted.byte[0];
controller_.get_buffer()[++index] = resolution_byte.converted.byte[1];
controller_.get_buffer()[++index] = resolution_byte.converted.byte[2];
controller_.get_buffer()[++index] = resolution_byte.converted.byte[3];

return controller_.assemble(++index);
}

uint8_t* AnimationCueHandler::set_radial_options(uint8_t section_num, uint8_t layer_num, uint8_t resolution) {
Expand All @@ -64,9 +64,9 @@ namespace PixelMaestro {
section_num,
layer_num
);
controller_->get_buffer()[++index] = resolution;
controller_.get_buffer()[++index] = resolution;

return controller_->assemble(++index);
return controller_.assemble(++index);
}

uint8_t* AnimationCueHandler::set_sparkle_options(uint8_t section_num, uint8_t layer_num, uint8_t threshold) {
Expand All @@ -76,9 +76,9 @@ namespace PixelMaestro {
section_num,
layer_num
);
controller_->get_buffer()[++index] = threshold;
controller_.get_buffer()[++index] = threshold;

return controller_->assemble(++index);
return controller_.assemble(++index);
}

uint8_t* AnimationCueHandler::set_wave_options(uint8_t section_num, uint8_t layer_num, int8_t skew) {
Expand All @@ -88,9 +88,9 @@ namespace PixelMaestro {
section_num,
layer_num
);
controller_->get_buffer()[++index] = (uint8_t)skew;
controller_.get_buffer()[++index] = (uint8_t)skew;

return controller_->assemble(++index);
return controller_.assemble(++index);
}

// General-purpose Cues
Expand All @@ -101,9 +101,9 @@ namespace PixelMaestro {
section_num,
layer_num
);
controller_->get_buffer()[++index] = cycle_index;
controller_.get_buffer()[++index] = cycle_index;

return controller_->assemble(++index);
return controller_.assemble(++index);
}

uint8_t* AnimationCueHandler::set_fade(uint8_t section_num, uint8_t layer_num, bool fade) {
Expand All @@ -113,9 +113,9 @@ namespace PixelMaestro {
section_num,
layer_num
);
controller_->get_buffer()[++index] = (uint8_t)fade;
controller_.get_buffer()[++index] = (uint8_t)fade;

return controller_->assemble(++index);
return controller_.assemble(++index);
}

uint8_t* AnimationCueHandler::set_orientation(uint8_t section_num, uint8_t layer_num, Animation::Orientation orientation) {
Expand All @@ -125,9 +125,9 @@ namespace PixelMaestro {
section_num,
layer_num
);
controller_->get_buffer()[++index] = (uint8_t)orientation;
controller_.get_buffer()[++index] = (uint8_t)orientation;

return controller_->assemble(++index);
return controller_.assemble(++index);
}

uint8_t* AnimationCueHandler::set_palette(uint8_t section_num, uint8_t layer_num, const Palette& palette) {
Expand All @@ -137,11 +137,11 @@ namespace PixelMaestro {
section_num,
layer_num
);
controller_->get_buffer()[++index] = palette.get_num_colors();
controller_.get_buffer()[++index] = palette.get_num_colors();

uint16_t palette_size= serialize_palette(&controller_->get_buffer()[++index], palette);
uint16_t palette_size= serialize_palette(&controller_.get_buffer()[++index], palette);

return controller_->assemble(index + palette_size);
return controller_.assemble(index + palette_size);
}

uint8_t* AnimationCueHandler::set_reverse(uint8_t section_num, uint8_t layer_num, bool reverse) {
Expand All @@ -151,9 +151,9 @@ namespace PixelMaestro {
section_num,
layer_num
);
controller_->get_buffer()[++index] = (uint8_t)reverse;
controller_.get_buffer()[++index] = (uint8_t)reverse;

return controller_->assemble(++index);
return controller_.assemble(++index);
}

uint8_t* AnimationCueHandler::set_timer(uint8_t section_num, uint8_t layer_num, uint16_t interval, uint16_t delay) {
Expand All @@ -166,12 +166,12 @@ namespace PixelMaestro {
section_num,
layer_num
);
controller_->get_buffer()[++index] = interval_byte.converted_0;
controller_->get_buffer()[++index] = interval_byte.converted_1;
controller_->get_buffer()[++index] = delay_byte.converted_0;
controller_->get_buffer()[++index] = delay_byte.converted_1;
controller_.get_buffer()[++index] = interval_byte.converted_0;
controller_.get_buffer()[++index] = interval_byte.converted_1;
controller_.get_buffer()[++index] = delay_byte.converted_0;
controller_.get_buffer()[++index] = delay_byte.converted_1;

return controller_->assemble(++index);
return controller_.assemble(++index);
}

uint8_t* AnimationCueHandler::start(uint8_t section_num, uint8_t layer_num) {
Expand All @@ -182,7 +182,7 @@ namespace PixelMaestro {
layer_num
);

return controller_->assemble(++index);
return controller_.assemble(++index);
}

uint8_t* AnimationCueHandler::stop(uint8_t section_num, uint8_t layer_num) {
Expand All @@ -193,7 +193,7 @@ namespace PixelMaestro {
layer_num
);

return controller_->assemble(++index);
return controller_.assemble(++index);
}

void AnimationCueHandler::run(uint8_t *cue) {
Expand Down
2 changes: 1 addition & 1 deletion src/cue/animationcuehandler.h
Expand Up @@ -34,7 +34,7 @@ namespace PixelMaestro {
OptionsByte
};

explicit AnimationCueHandler(CueController* controller) : CueHandler(controller) { }
explicit AnimationCueHandler(CueController& controller) : CueHandler(controller) { }
~AnimationCueHandler() = default;

// Animation-specific calls
Expand Down

0 comments on commit c21a0e2

Please sign in to comment.