63 lines
850 B
C++
63 lines
850 B
C++
#ifndef PICOLED_H
|
|
#define PICOLED_H
|
|
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
|
|
namespace picoled
|
|
{
|
|
|
|
class pixel
|
|
{
|
|
friend class oled;
|
|
public:
|
|
pixel() :
|
|
pixel(0)
|
|
{}
|
|
|
|
pixel(uint8_t value) :
|
|
value(value)
|
|
{}
|
|
|
|
private:
|
|
uint8_t value;
|
|
};
|
|
|
|
class oled
|
|
{
|
|
public:
|
|
oled(size_t width, size_t height);
|
|
virtual ~oled();
|
|
|
|
oled(const oled&) = delete;
|
|
oled(oled&&) = delete;
|
|
|
|
oled& operator=(const oled&) = delete;
|
|
oled& operator=(oled&&) = delete;
|
|
|
|
pixel& operator()(int x, int y);
|
|
const pixel& operator()(int x, int y) const;
|
|
|
|
void clear();
|
|
|
|
size_t get_width() const { return width; }
|
|
size_t get_height() const { return height; }
|
|
|
|
void update() const;
|
|
|
|
protected:
|
|
virtual void update_impl() const = 0;
|
|
|
|
bool is_on(int x, int y) const;
|
|
|
|
size_t width;
|
|
size_t height;
|
|
|
|
private:
|
|
pixel* pixels;
|
|
};
|
|
|
|
}
|
|
|
|
#endif//PICOLED_H
|