2021-04-21 14:35:26 +01:00
|
|
|
#include <string>
|
2021-01-16 16:38:58 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
namespace pimoroni {
|
|
|
|
|
|
|
|
class PicoScroll {
|
2021-01-19 18:43:43 +00:00
|
|
|
private:
|
|
|
|
static const uint8_t DEFAULT_ADDRESS = 0x74;
|
|
|
|
static const uint BUFFER_SIZE = 144;
|
|
|
|
public:
|
|
|
|
static const int WIDTH = 17;
|
|
|
|
static const int HEIGHT = 7;
|
|
|
|
static const uint8_t A = 12;
|
|
|
|
static const uint8_t B = 13;
|
|
|
|
static const uint8_t X = 14;
|
|
|
|
static const uint8_t Y = 15;
|
2021-01-16 16:38:58 +00:00
|
|
|
|
2021-01-19 18:43:43 +00:00
|
|
|
private:
|
|
|
|
uint8_t __fb[BUFFER_SIZE];
|
|
|
|
|
2021-01-16 16:38:58 +00:00
|
|
|
public:
|
|
|
|
void init();
|
|
|
|
void update();
|
2021-04-21 14:35:26 +01:00
|
|
|
void set_pixels(const char *pixels);
|
|
|
|
void set_bitmap_1d(const char *bitmap, size_t bitmap_len, int brightness, int offset);
|
|
|
|
void scroll_text(const char *text, size_t text_len, int brightness, int delay_ms);
|
|
|
|
void scroll_text(std::string text, int brightness, int delay_ms=100) {
|
|
|
|
scroll_text(text.c_str(), text.length(), brightness, delay_ms);
|
|
|
|
};
|
|
|
|
void set_text(const char *text, size_t text_len, int brightness, int offset);
|
|
|
|
void set_text(std::string text, int brightness, int offset=0) {
|
|
|
|
set_text(text.c_str(), text.length(), brightness, offset);
|
|
|
|
}
|
2021-01-16 16:38:58 +00:00
|
|
|
void set_pixel(uint8_t x, uint8_t y, uint8_t v);
|
|
|
|
void clear();
|
|
|
|
bool is_pressed(uint8_t button);
|
|
|
|
|
2021-01-19 18:43:43 +00:00
|
|
|
private:
|
|
|
|
void i2c_write(uint8_t reg, const char *data, uint8_t len);
|
2021-01-16 16:38:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|