| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- #pragma once
- #include <Arduino.h>
- #include <SPI.h>
- #include <U8g2lib.h>
- class ST7305_U8g2 {
- private:
- int _sck;
- int _mosi;
- int _dc;
- int _cs;
- int _rst;
- SPIClass *_spi = nullptr;
- U8G2 u8g2_wrapper;
- uint8_t *_my_buf = nullptr;
- void _cmd(uint8_t cmd);
- void _data(const uint8_t *data, size_t len);
- void _cmd_data(uint8_t cmd, const uint8_t *data, size_t len);
- static uint8_t u8x8_d_st7305_custom(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
- static uint8_t u8x8_byte_custom(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
- public:
- ST7305_U8g2(int sck = 11, int mosi = 12, int dc = 5, int cs = 40, int rst = 41);
- ~ST7305_U8g2();
- // tile_buf_height 0 means full-buffer mode, about 15 KB RAM for 300x400.
- // A smaller value can be used with firstPage()/nextPage(), but this demo uses full-buffer mode.
- void begin(uint8_t tile_buf_height = 0, const u8g2_cb_t *rotation = U8G2_R0);
- void reset();
- void fullInit();
- // LOCAL ADDITION (not upstream): selects the ST7305 low-power driving mode,
- // command 0x39, instead of the high-power mode 0x38 that fullInit() sets.
- // Low power drops the panel's internal refresh rate, which suits a clock
- // that changes once a minute. Safe to call at any time.
- void setLowPowerMode(bool low);
- U8G2 *getU8g2()
- {
- return &u8g2_wrapper;
- }
- };
|