123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420 |
- #include "u8g.h"
- #define WIDTH 128
- #define HEIGHT 128
- #define PAGE_HEIGHT 8
- #ifdef FIRST_VERSION
- static const uint8_t u8g_dev_st7687_c144mvgd_init_seq[] PROGMEM = {
- U8G_ESC_CS(0),
- U8G_ESC_ADR(0),
- U8G_ESC_CS(1),
- U8G_ESC_RST(15),
-
- 0x001,
- U8G_ESC_DLY(200),
-
- 0x0d7,
- U8G_ESC_ADR(1),
- 0x09f,
- U8G_ESC_ADR(0),
- U8G_ESC_DLY(100),
-
- 0x0e0,
- U8G_ESC_ADR(1),
- 0x000,
- U8G_ESC_ADR(0),
- U8G_ESC_DLY(100),
-
- #ifdef NOT_REQUIRED
- 0x0fa,
- U8G_ESC_ADR(1),
- 0x000,
- U8G_ESC_ADR(0),
- U8G_ESC_DLY(100),
- #endif
- 0x0e3,
- U8G_ESC_DLY(100),
- 0x0e1,
- U8G_ESC_DLY(100),
-
-
- 0x011,
- U8G_ESC_DLY(100),
-
- 0x0c0,
- U8G_ESC_ADR(1),
- 0x000,
- 0x001,
- U8G_ESC_ADR(0),
- U8G_ESC_DLY(100),
-
- 0x0c3,
- U8G_ESC_ADR(1),
- 0x003,
- U8G_ESC_ADR(0),
-
- 0x0c4,
- U8G_ESC_ADR(1),
- 0x007,
- U8G_ESC_ADR(0),
-
- 0x0c5,
- U8G_ESC_ADR(1),
- 0x001,
- U8G_ESC_ADR(0),
-
- 0x0cb,
- U8G_ESC_ADR(1),
- 0x001,
- U8G_ESC_ADR(0),
-
- 0x036,
- U8G_ESC_ADR(1),
- 0x080,
- U8G_ESC_ADR(0),
- 0x0b5,
- U8G_ESC_ADR(1),
- 0x089,
- U8G_ESC_ADR(0),
- 0x0d0,
- U8G_ESC_ADR(1),
- 0x01d,
- U8G_ESC_ADR(0),
- 0x0b7,
- U8G_ESC_ADR(1),
- 0x040,
- U8G_ESC_ADR(0),
- 0x025,
- U8G_ESC_ADR(1),
- 0x03f,
- U8G_ESC_ADR(0),
- 0x03a,
- U8G_ESC_ADR(1),
- 0x004,
- U8G_ESC_ADR(0),
- 0x0b0,
- U8G_ESC_ADR(1),
- 0x07f,
- U8G_ESC_ADR(0),
- 0x0f0,
- U8G_ESC_ADR(1),
- 0x007,
- 0x00c,
- 0x00c,
- 0x015,
- U8G_ESC_ADR(0),
- 0x0f9,
- U8G_ESC_ADR(1),
- 0x000,
- 0x005,
- 0x008,
- 0x00a,
- 0x00c,
- 0x00e,
- 0x010,
- 0x011,
- 0x012,
- 0x013,
- 0x014,
- 0x015,
- 0x016,
- 0x018,
- 0x01a,
- 0x01b,
- U8G_ESC_ADR(0),
- 0x0f9,
- U8G_ESC_ADR(1),
- 0x000,
- 0x000,
- 0x000,
- 0x000,
- 0x033,
- 0x055,
- 0x055,
- 0x055,
- U8G_ESC_ADR(0),
- 0x029,
- U8G_ESC_CS(0),
- U8G_ESC_END
- };
- #else
- static const uint8_t u8g_dev_st7687_c144mvgd_init_seq[] PROGMEM = {
- U8G_ESC_CS(0),
- U8G_ESC_ADR(0),
- U8G_ESC_CS(1),
- U8G_ESC_RST(15),
- 0x011,
- U8G_ESC_DLY(5),
-
- 0x03a,
- U8G_ESC_ADR(1),
- 0x004,
- U8G_ESC_ADR(0),
-
-
- 0x026,
- U8G_ESC_ADR(1),
- 0x004,
- U8G_ESC_ADR(0),
- 0x0f2,
- U8G_ESC_ADR(1),
- 0x001,
- U8G_ESC_ADR(0),
- 0x0e0,
- U8G_ESC_ADR(1),
- 0x3f,
- 0x25,
- 0x1c,
- 0x1e,
- 0x20,
- 0x12,
- 0x2a,
- 0x90,
- 0x24,
- 0x11,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- U8G_ESC_ADR(0),
- 0x0e1,
- U8G_ESC_ADR(1),
- 0x20,
- 0x20,
- 0x20,
- 0x20,
- 0x05,
- 0x00,
- 0x15,
- 0xa7,
- 0x3d,
- 0x18,
- 0x25,
- 0x2a,
- 0x2b,
- 0x2b,
- 0x3a,
- U8G_ESC_ADR(0),
-
- 0x0b1,
- U8G_ESC_ADR(1),
- 0x008,
- 0x008,
- U8G_ESC_ADR(0),
- 0x0b4,
- U8G_ESC_ADR(1),
- 0x007,
- U8G_ESC_ADR(0),
-
- 0x0c0,
- U8G_ESC_ADR(1),
- 0x00a,
- 0x002,
- U8G_ESC_ADR(0),
-
- 0x0c1,
- U8G_ESC_ADR(1),
- 0x002,
- U8G_ESC_ADR(0),
-
- 0x0c5,
- U8G_ESC_ADR(1),
- 0x050,
- 0x05b,
- U8G_ESC_ADR(0),
- 0x0c7,
- U8G_ESC_ADR(1),
- 0x040,
- U8G_ESC_ADR(0),
- 0x02a,
- U8G_ESC_ADR(1),
- 0x000,
- 0x000,
- 0x000,
- 0x07f,
- U8G_ESC_ADR(0),
- 0x02b,
- U8G_ESC_ADR(1),
- 0x000,
- 0x000,
- 0x000,
- 0x07f,
- U8G_ESC_ADR(0),
- 0x036,
- U8G_ESC_ADR(1),
- 0x000,
- U8G_ESC_ADR(0),
-
- 0x029,
-
- 0x02c,
-
- U8G_ESC_CS(0),
- U8G_ESC_END
- };
- #endif
- static uint8_t get_byte_1(uint8_t v)
- {
- v >>= 4;
- v &= 0x0e;
- return v;
- }
- static uint8_t get_byte_2(uint8_t v)
- {
- uint8_t w;
- w = v;
- w &= 3;
- w = (w<<2) | w;
- v <<= 3;
- v &= 0x0e0;
- w |= v;
- return w;
- }
- uint8_t u8g_dev_st7687_c144mvgd_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
- {
- switch(msg)
- {
- case U8G_DEV_MSG_INIT:
- u8g_InitCom(u8g, dev);
- u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7687_c144mvgd_init_seq);
- break;
- case U8G_DEV_MSG_STOP:
- break;
- case U8G_DEV_MSG_PAGE_NEXT:
- {
- uint8_t y, i, j;
- uint8_t *ptr;
- u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
-
- u8g_SetAddress(u8g, dev, 0);
- u8g_SetChipSelect(u8g, dev, 1);
- y = pb->p.page_y0;
- ptr = pb->buf;
-
- u8g_SetAddress(u8g, dev, 0);
- u8g_WriteByte(u8g, dev, 0x02a );
- u8g_SetAddress(u8g, dev, 1);
- u8g_WriteByte(u8g, dev, 0x000 );
- u8g_WriteByte(u8g, dev, WIDTH-1 );
- u8g_SetAddress(u8g, dev, 0);
- u8g_WriteByte(u8g, dev, 0x02b );
- u8g_SetAddress(u8g, dev, 1);
- u8g_WriteByte(u8g, dev, y );
- u8g_WriteByte(u8g, dev, y+PAGE_HEIGHT-1 );
- u8g_SetAddress(u8g, dev, 0);
- u8g_WriteByte(u8g, dev, 0x02c );
- u8g_SetAddress(u8g, dev, 1);
-
- for( i = 0; i < PAGE_HEIGHT; i ++ )
- {
-
- for( j = 0; j < WIDTH; j ++ )
- {
- u8g_WriteByte(u8g, dev, get_byte_1(*ptr) );
- u8g_WriteByte(u8g, dev, get_byte_2(*ptr) );
- ptr++;
- }
- }
- u8g_SetAddress(u8g, dev, 0);
- u8g_SetChipSelect(u8g, dev, 0);
- }
- break;
- }
- return u8g_dev_pb8h8_base_fn(u8g, dev, msg, arg);
- }
- uint8_t u8g_st7687_c144mvgd_8h8_buf[WIDTH*8] U8G_NOCOMMON ;
- u8g_pb_t u8g_st7687_c144mvgd_8h8_pb = { {8, HEIGHT, 0, 0, 0}, WIDTH, u8g_st7687_c144mvgd_8h8_buf};
- u8g_dev_t u8g_dev_st7687_c144mvgd_sw_spi = { u8g_dev_st7687_c144mvgd_fn, &u8g_st7687_c144mvgd_8h8_pb, u8g_com_arduino_sw_spi_fn };
- u8g_dev_t u8g_dev_st7687_c144mvgd_8bit = { u8g_dev_st7687_c144mvgd_fn, &u8g_st7687_c144mvgd_8h8_pb, U8G_COM_PARALLEL };
|