函数原型:
bool isEPD(void)
功能说明:
返回值:
函数原型:
int32_t height(void)
功能说明:
传入参数:
返回值:
函数原型:
int32_t width (void)
功能说明:
传入参数:
返回值:
函数原型:
void popState(void)
功能说明:
传入参数:
返回值:
函数原型:
void pushState(void)
功能说明:
传入参数:
返回值:
函数原型:
void setBrightness(uint8_t brightness)
功能说明:
传入参数:
返回值:
函数原型:
uint8_t getBrightness(void)
功能说明:
传入参数:
返回值:
函数原型:
void setEpdMode(epd_mode_t epd_mode)
功能说明:
传入参数:
返回值:
函数原型:
epd_mode_t getEpdMode(void)
功能说明:
传入参数:
返回值:
函数原型1:
bool setResolution(uint16_t logical_width = 0, uint16_t logical_height = 0, float refresh_rate = 0.0f, uint16_t output_width = 0, uint16_t output_height = 0, uint_fast8_t scale_w = 0, uint_fast8_t scale_h = 0, uint32_t pixel_clock = 74250000)
函数原型2:
bool setResolution( const config_resolution_t& cfg_resolution )
功能说明:
M5AtomDisplay
。传入参数:
cfg_resolution
包含了如上所示的所有参数。返回值:
函数原型:
void setRotation(uint_fast8_t r)
功能说明:
传入参数:
返回值:
函数原型:
uint8_t getRotation(void)
功能说明:
传入参数:
返回值:
函数原型:
void setBaseColor(T c)
功能说明:
传入参数:
返回值:
函数原型:
uint32_t getBaseColor(void)
功能说明:
传入参数:
返回值:
函数原型1:
void setColor(uint8_t r, uint8_t g, uint8_t b)
函数原型2:
void setColor(T color)
功能说明:
传入参数:
返回值:
函数原型:
void setRawColor(uint32_t c)
功能说明:
传入参数:
返回值:
函数原型:
uint32_t getRawColor(void)
功能说明:
传入参数:
返回值:
函数原型1:
void setColorDepth(uint8_t bpp)
函数原型2:
void* setColorDepth(color_depth_t depth)
功能说明:
传入参数:
函数原型:
color_depth_t getColorDepth(void)
功能说明:
传入参数:
返回值:
函数原型:
RGBColor* getPalette(void)
功能说明:
传入参数:
返回值:
函数原型:
uint32_t getPaletteCount(void)
功能说明:
传入参数:
返回值:
函数原型:
void clear(const T &color)
功能说明
传入参数:
返回值:
函数原型:
void clearDisplay(uint32_t color = 0)
功能说明:
传入参数:
返回值:
函数原型:
void fillScreen(const T &color)
功能说明:
传入参数:
返回值:
函数原型1:
void setCursor(int16_t x, int16_t y)
函数原型2:
void setCursor(int16_t x, int16_t y, uint8_t font)
void setCursor( int32_t x, int32_t y, const IFont* font)
功能说明:
传入参数:
返回值:
函数原型:
int32_t getCursorX(void)
功能说明:
传入参数:
返回值:
函数原型:
int32_t getCursorY(void)
功能说明:
传入参数:
返回值:
函数原型:
void setPivot(float x, float y)
功能说明:
传入参数:
返回值:
函数原型:
float getPivotX(void)
功能说明:
传入参数:
返回值:
函数原型:
float getPivotY(void)
功能说明:
传入参数:
返回值:
函数原型:
void setAddrWindow(int32_t x, int32_t y, int32_t w, int32_t h)
功能说明:
传入参数:
返回值:
函数原型:
void setWindow(uint_fast16_t xs, uint_fast16_t ys, uint_fast16_t xe, uint_fast16_t ye)
功能说明:
传入参数:
返回值:
函数原型:
void setAddrWindow(int32_t x, int32_t y, int32_t w, int32_t h)
功能说明:
传入参数:
返回值:
函数原型:
void setWindow(uint_fast16_t xs, uint_fast16_t ys, uint_fast16_t xe, uint_fast16_t ye)
功能说明:
传入参数:
返回值:
函数原型:
void setClipRect(int32_t x, int32_t y, int32_t w, int32_t h)
功能说明:
传入参数:
返回值:
函数原型:
void getClipRect(int32_t *x, int32_t *y, int32_t *w, int32_t *h)
功能说明:
传入参数:
返回值:
函数原型:
void clearClipRect(void)
功能说明:
传入参数:
返回值:
函数原型:
void scroll(int_fast16_t dx, int_fast16_t dy)
功能说明:
传入参数:
返回值:
案例程序:
#include <Arduino.h>
#include <M5GFX.h>
M5GFX display;
uint16_t x;
uint16_t y;
bool flag = false;
void setup()
{
display.begin();
display.drawString(" Scrolling... ", 0, 0, &fonts::lgfxJapanGothic_24);
}
void loop()
{
if(flag)
{
for (int i=-53; i<=53; i+=1) {
display.scroll(0, -2);
if(i>=53){ flag = false; }
}
}
else
{
for (int i=-53; i<=53; i+=1) {
display.scroll(0, 2);
if(i>=53){ flag = true; }
}
}
}
函数原型:
void setTextScroll(bool scroll)
功能说明:
传入参数:
返回值:
setTextScroll(true)
。函数原型:
void setScrollRect(int32_t x, int32_t y, int32_t w, int32_t h, const T& color)
功能说明:
传入参数:
返回值:
函数原型:
void getScrollRect(int32_t *x, int32_t *y, int32_t *w, int32_t *h)
功能说明:
传入参数:
返回值:
函数原型:
void clearScrollRect(void)
功能说明:
传入参数:
返回值:
案例程序 1 :
#include <Arduino.h>
#include <M5GFX.h>
M5GFX display;
uint32_t count = 0;
void setup() {
display.begin();
display.setRotation(1);
if(display.isEPD())
{
display.setColorDepth(8);//The ink screen product supports a maximum bit depth of 8 bits.
display.setEpdMode(epd_fastest);
}
else
{
display.setColorDepth(16);
}
display.fillScreen(TFT_WHITE);
display.setBaseColor(TFT_WHITE);
display.setTextFont(&fonts::FreeMonoBoldOblique18pt7b);
display.setTextColor(TFT_BLACK);
display.setTextScroll(true);
display.setScrollRect(0, 0, display.width(), display.height());
}
void loop() {
display.printf("Scroll: %d\n", count);
count++;
delay(500);
}
通过对比以下两个案例程序最终实现,可以看出使用 Canvas 的优势。
案例程序 2 (Display):
#include <Arduino.h>
#include <M5GFX.h>
M5GFX display;
uint16_t w;
uint16_t h;
static constexpr char text[] = "Hello world ! This is M5Stack scroll test.";
static constexpr size_t textlen = sizeof(text) / sizeof(text[0]);
int textpos = 0;
int scrollstep = 2;
void setup()
{
display.begin();
display.setRotation(3);
display.setBaseColor(TFT_WHITE);
display.fillScreen(TFT_WHITE);
display.setFont(&fonts::FreeMonoBoldOblique24pt7b);
display.setTextColor(TFT_BLACK);
w = display.width() / 2;
h = display.height() / 2;
}
void loop()
{
int32_t cursor_x = display.getCursorX() - scrollstep;
if (cursor_x <= 0)
{
textpos = 0;
cursor_x = 0;
}
display.setCursor(cursor_x, h-24);
display.scroll(-scrollstep, 0);
while (textpos < textlen && cursor_x <= display.width())
{
display.print(text[textpos++]);
cursor_x = display.getCursorX();
}
}
案例程序 3 (Canvas):
#include <Arduino.h>
#include <M5GFX.h>
M5GFX display;
M5Canvas canvas(&display);
uint16_t w;
uint16_t h;
static constexpr char text[] = "Hello world ! This is M5Stack scroll test.";
static constexpr size_t textlen = sizeof(text) / sizeof(text[0]);
int textpos = 0;
int scrollstep = 2;
void setup()
{
display.begin();
display.setRotation(3);
display.fillScreen(TFT_WHITE);
canvas.createSprite(display.width() + 64, 108);
canvas.fillSprite(TFT_WHITE);
canvas.setBaseColor(TFT_WHITE);
canvas.setFont(&fonts::FreeMonoBoldOblique24pt7b);
canvas.setTextColor(TFT_BLACK);
canvas.setTextSize(1.5);
}
void loop()
{
int32_t cursor_x = canvas.getCursorX() - scrollstep;
if (cursor_x <= 0)
{
textpos = 0;
cursor_x = display.width();
}
canvas.setCursor(cursor_x, 0);
canvas.scroll(-scrollstep, 0);
while (textpos < textlen && cursor_x <= display.width())
{
canvas.setColor(TFT_BLACK);
canvas.print(text[textpos++]);
cursor_x = canvas.getCursorX();
}
int y = (display.height() - canvas.height()) >> 1;
canvas.pushSprite(&display, 0, y);
}
函数原型:
void effect(int32_t x, int32_t y, int32_t w, int32_t h, TFunc&& effector)
功能说明:
传入参数:
返回值: