-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
166 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#ifndef PLANET096_BITMAP_H | ||
#define PLANET096_BITMAP_H | ||
|
||
#include <Arduino.h> | ||
|
||
typedef struct _Planet096Bitmap { | ||
uint8_t *bitmap; | ||
uint8_t width, height; | ||
} Planet096Bitmap; | ||
|
||
static inline Planet096Bitmap createBitmap(uint8_t *bitmap, uint8_t width, uint8_t height) { | ||
Planet096Bitmap bitmap_image; | ||
bitmap_image.bitmap = bitmap; | ||
bitmap_image.width = width; | ||
bitmap_image.height = height; | ||
|
||
return bitmap_image; | ||
} | ||
|
||
#endif |
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,64 @@ | ||
#include <planet096_scene.h> | ||
#include <planet096_ui_image.h> | ||
|
||
Planet096Image::Planet096Image(): | ||
scene(nullptr) { } | ||
|
||
Planet096Image::Planet096Image(Planet096Scene *scene): | ||
scene(scene) { } | ||
|
||
Planet096Image::Planet096Image(Planet096Scene *scene, Planet096Bitmap bitmap): | ||
scene(scene), | ||
bitmap(bitmap) { } | ||
|
||
void Planet096Image::setX(uint8_t x) { | ||
this->x = x; | ||
this->invalidate(); | ||
} | ||
|
||
uint8_t Planet096Image::getX() { | ||
return this->x; | ||
} | ||
|
||
void Planet096Image::setY(uint8_t y) { | ||
this->y = y; | ||
this->invalidate(); | ||
} | ||
|
||
uint8_t Planet096Image::getY() { | ||
return this->y; | ||
} | ||
|
||
void Planet096Image::setColor(Planet096Color color) { | ||
this->color = color; | ||
this->invalidate(); | ||
} | ||
|
||
uint8_t Planet096Image::getColor() { | ||
return this->color; | ||
} | ||
|
||
void Planet096Image::setBitmap(Planet096Bitmap bitmap) { | ||
this->bitmap = bitmap; | ||
this->invalidate(); | ||
} | ||
|
||
Planet096Bitmap Planet096Image::getBitmap() { | ||
return this->bitmap; | ||
} | ||
|
||
bool Planet096Image::isUpdated() { | ||
bool is_updated = this->is_updated; | ||
this->is_updated = !is_updated; | ||
|
||
return is_updated; | ||
} | ||
|
||
void Planet096Image::hasRendered() { | ||
this->has_rendered = true; | ||
} | ||
|
||
void Planet096Image::invalidate() { | ||
if(this->has_rendered) | ||
this->scene->renderWidget(); | ||
} |
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,44 @@ | ||
#ifndef PLANET096_UI_IMAGE_H | ||
#define PLANET096_UI_IMAGE_H | ||
|
||
#include <Arduino.h> | ||
#include <planet096_bitmap.h> | ||
#include <planet096_colors.h> | ||
#include <planet096_scene.h> | ||
|
||
class Planet096Scene; | ||
|
||
class Planet096Image { | ||
public: | ||
Planet096Image(); | ||
Planet096Image(Planet096Scene *scene); | ||
Planet096Image(Planet096Scene *scene, Planet096Bitmap bitmap); | ||
|
||
void setX(uint8_t x); | ||
uint8_t getX(); | ||
|
||
void setY(uint8_t y); | ||
uint8_t getY(); | ||
|
||
void setColor(Planet096Color color); | ||
uint8_t getColor(); | ||
|
||
void setBitmap(Planet096Bitmap bitmap); | ||
Planet096Bitmap getBitmap(); | ||
|
||
bool isUpdated(); | ||
void hasRendered(); | ||
|
||
private: | ||
uint8_t x = 0, y = 0; | ||
Planet096Color color = WHITE; | ||
bool has_rendered = false, | ||
is_updated = true; | ||
|
||
Planet096Bitmap bitmap; | ||
Planet096Scene *scene; | ||
|
||
void invalidate(); | ||
}; | ||
|
||
#endif |
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