Skip to content

Commit

Permalink
Fixed a bug regarding colordepth change (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
mongonta0716 committed Jun 22, 2022
1 parent 456de3c commit bced49a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/Avatar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ void Avatar::start(int colorDepth) {
if (_isDrawing) return;
_isDrawing = true;

this->colorDepth = colorDepth;
DriveContext *ctx = new DriveContext(this);
// TODO(meganetaaan): keep handle of these tasks
xTaskCreate(drawLoop, /* Function to implement the task */
Expand Down
4 changes: 2 additions & 2 deletions src/ColorPalette.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ColorPalette::ColorPalette()
{COLOR_SECONDARY, TFT_BLACK},
{COLOR_BACKGROUND, TFT_BLACK}} {}

uint32_t ColorPalette::get(const char* key) const {
uint16_t ColorPalette::get(const char* key) const {
auto itr = colors.find(key);
if (itr != colors.end()) {
return itr->second;
Expand All @@ -22,7 +22,7 @@ uint32_t ColorPalette::get(const char* key) const {
}
}

void ColorPalette::set(const char* key, uint32_t value) {
void ColorPalette::set(const char* key, uint16_t value) {
auto itr = colors.find(key);
if (itr != colors.end()) {
Serial.println("Overwriting");
Expand Down
8 changes: 4 additions & 4 deletions src/ColorPalette.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ namespace m5avatar {
class ColorPalette {
private:
// ColorType colorType;
// uint32_t colors[2];
std::map<std::string, uint32_t> colors;
// uint16_t colors[2];
std::map<std::string, uint16_t> colors;

public:
// TODO(meganetaaan): constructor with color settings
Expand All @@ -34,8 +34,8 @@ class ColorPalette {
ColorPalette(const ColorPalette &other) = default;
ColorPalette &operator=(const ColorPalette &other) = default;

uint32_t get(const char *key) const;
void set(const char *key, uint32_t value);
uint16_t get(const char *key) const;
void set(const char *key, uint16_t value);
void clear(void);
};
} // namespace m5avatar
Expand Down

0 comments on commit bced49a

Please sign in to comment.