123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787 |
- /*
- u8g_dev_ssd1351_128x128.c
- Universal 8bit Graphics Library
-
- Copyright (c) 2013, jamjardavies@gmail.com
- Copyright (c) 2013, olikraus@gmail.com
- All rights reserved.
- Redistribution and use in source and binary forms, with or without modification,
- are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright notice, this list
- of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright notice, this
- list of conditions and the following disclaimer in the documentation and/or other
- materials provided with the distribution.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- History:
- Initial version 20 May 2013 jamjardavies@gmail.com
- indexed device 22 May 2013 olikraus@gmail.com
-
- */
- #include "u8g.h"
- #define WIDTH 128
- #define HEIGHT 128
- #define PAGE_HEIGHT 8
- static const uint8_t u8g_dev_ssd1351_128x128_init_seq[] PROGMEM = {
- U8G_ESC_CS(0), /* disable chip */
- U8G_ESC_DLY(50),
- U8G_ESC_ADR(0), /* instruction mode */
- U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
- U8G_ESC_CS(1), /* enable chip */
- U8G_ESC_DLY(50),
- 0xfd, /* Command Lock */
- U8G_ESC_ADR(1),
- 0x12,
- U8G_ESC_ADR(0), /* instruction mode */
- 0xfd,
- U8G_ESC_ADR(1),
- 0xb1, /* Command Lock */
- U8G_ESC_ADR(0), /* instruction mode */
- 0xae, /* Set Display Off */
- U8G_ESC_ADR(0), /* instruction mode */
- 0xb3,
- U8G_ESC_ADR(1),
- 0xf1, /* Front Clock Div */
- U8G_ESC_ADR(0), /* instruction mode */
- 0xca,
- U8G_ESC_ADR(1),
- 0x7f, /* Set Multiplex Ratio */
- U8G_ESC_ADR(0), /* instruction mode */
- 0xa0,
- U8G_ESC_ADR(1),
- 0xb4, /* Set Colour Depth */
- U8G_ESC_ADR(0), /* instruction mode */
- 0x15,
- U8G_ESC_ADR(1),
- 0x00, 0x7f, /* Set Column Address */
- U8G_ESC_ADR(0), /* instruction mode */
- 0x75,
- U8G_ESC_ADR(1),
- 0x00, 0x7f, /* Set Row Address */
- U8G_ESC_ADR(0), /* instruction mode */
- 0xa1,
- U8G_ESC_ADR(1),
- 0x00, /* Set Display Start Line */
- U8G_ESC_ADR(0), /* instruction mode */
- 0xa2,
- U8G_ESC_ADR(1),
- 0x00, /* Set Display Offset */
- U8G_ESC_ADR(0), /* instruction mode */
- 0xb5,
- U8G_ESC_ADR(1),
- 0x00, /* Set GPIO */
- U8G_ESC_ADR(0), /* instruction mode */
- 0xab,
- U8G_ESC_ADR(1),
- 0x01, /* Set Function Selection */
- U8G_ESC_ADR(0), /* instruction mode */
- 0xb1,
- U8G_ESC_ADR(1),
- 0x32, /* Set Phase Length */
- U8G_ESC_ADR(0), /* instruction mode */
- 0xb4,
- U8G_ESC_ADR(1),
- 0xa0, 0xb5, 0x55, /* Set Segment Low Voltage */
- U8G_ESC_ADR(0), /* instruction mode */
- 0xbb,
- U8G_ESC_ADR(1),
- 0x17, /* Set Precharge Voltage */
- U8G_ESC_ADR(0), /* instruction mode */
- 0xbe,
- U8G_ESC_ADR(1),
- 0x05, /* Set VComH Voltage */
- U8G_ESC_ADR(0), /* instruction mode */
- 0xc1,
- U8G_ESC_ADR(1),
- 0xc8, 0x80, 0xc8, /* Set Contrast */
- U8G_ESC_ADR(0), /* instruction mode */
- 0xc7,
- U8G_ESC_ADR(1),
- 0x0f, /* Set Master Contrast */
- U8G_ESC_ADR(0), /* instruction mode */
- 0xb6,
- U8G_ESC_ADR(1),
- 0x01, /* Set Second Precharge Period */
- U8G_ESC_ADR(0), /* instruction mode */
- 0xa6, /* Set Display Mode Reset */
- U8G_ESC_ADR(0), /* instruction mode */
- 0xb8, /* Set CMD Grayscale Lookup */
- U8G_ESC_ADR(1),
- 0x05,
- 0x06,
- 0x07,
- 0x08,
- 0x09,
- 0x0a,
- 0x0b,
- 0x0c,
- 0x0D,
- 0x0E,
- 0x0F,
- 0x10,
- 0x11,
- 0x12,
- 0x13,
- 0x14,
- 0x15,
- 0x16,
- 0x18,
- 0x1a,
- 0x1b,
- 0x1C,
- 0x1D,
- 0x1F,
- 0x21,
- 0x23,
- 0x25,
- 0x27,
- 0x2A,
- 0x2D,
- 0x30,
- 0x33,
- 0x36,
- 0x39,
- 0x3C,
- 0x3F,
- 0x42,
- 0x45,
- 0x48,
- 0x4C,
- 0x50,
- 0x54,
- 0x58,
- 0x5C,
- 0x60,
- 0x64,
- 0x68,
- 0x6C,
- 0x70,
- 0x74,
- 0x78,
- 0x7D,
- 0x82,
- 0x87,
- 0x8C,
- 0x91,
- 0x96,
- 0x9B,
- 0xA0,
- 0xA5,
- 0xAA,
- 0xAF,
- 0xB4,
- U8G_ESC_ADR(0),
- 0xaf, /* Set Display On */
- 0x5c,
- U8G_ESC_DLY(50),
- U8G_ESC_CS(0), /* disable chip */
- U8G_ESC_ADR(1),
- U8G_ESC_END /* end of sequence */
- };
- /* set gpio to high */
- static const uint8_t u8g_dev_ssd1351_128x128gh_init_seq[] PROGMEM = {
- U8G_ESC_CS(0), /* disable chip */
- U8G_ESC_DLY(50),
- U8G_ESC_ADR(0), /* instruction mode */
- U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
- U8G_ESC_CS(1), /* enable chip */
- U8G_ESC_DLY(50),
- 0xfd, /* Command Lock */
- U8G_ESC_ADR(1),
- 0x12,
- U8G_ESC_ADR(0), /* instruction mode */
- 0xfd,
- U8G_ESC_ADR(1),
- 0xb1, /* Command Lock */
- U8G_ESC_ADR(0), /* instruction mode */
- 0xae, /* Set Display Off */
- U8G_ESC_ADR(0), /* instruction mode */
- 0xb3,
- U8G_ESC_ADR(1),
- 0xf1, /* Front Clock Div */
- U8G_ESC_ADR(0), /* instruction mode */
- 0xca,
- U8G_ESC_ADR(1),
- 0x7f, /* Set Multiplex Ratio */
- U8G_ESC_ADR(0), /* instruction mode */
- 0xa0,
- U8G_ESC_ADR(1),
- 0xb4, /* Set Colour Depth */
- U8G_ESC_ADR(0), /* instruction mode */
- 0x15,
- U8G_ESC_ADR(1),
- 0x00, 0x7f, /* Set Column Address */
- U8G_ESC_ADR(0), /* instruction mode */
- 0x75,
- U8G_ESC_ADR(1),
- 0x00, 0x7f, /* Set Row Address */
- U8G_ESC_ADR(0), /* instruction mode */
- 0xa1,
- U8G_ESC_ADR(1),
- 0x00, /* Set Display Start Line */
- U8G_ESC_ADR(0), /* instruction mode */
- 0xa2,
- U8G_ESC_ADR(1),
- 0x00, /* Set Display Offset */
- U8G_ESC_ADR(0), /* instruction mode */
- 0xb5,
- U8G_ESC_ADR(1),
- 0x03, /* Set GPIO to High Level */
- U8G_ESC_ADR(0), /* instruction mode */
- 0xab,
- U8G_ESC_ADR(1),
- 0x01, /* Set Function Selection */
- U8G_ESC_ADR(0), /* instruction mode */
- 0xb1,
- U8G_ESC_ADR(1),
- 0x32, /* Set Phase Length */
- U8G_ESC_ADR(0), /* instruction mode */
- 0xb4,
- U8G_ESC_ADR(1),
- 0xa0, 0xb5, 0x55, /* Set Segment Low Voltage */
- U8G_ESC_ADR(0), /* instruction mode */
- 0xbb,
- U8G_ESC_ADR(1),
- 0x17, /* Set Precharge Voltage */
- U8G_ESC_ADR(0), /* instruction mode */
- 0xbe,
- U8G_ESC_ADR(1),
- 0x05, /* Set VComH Voltage */
- U8G_ESC_ADR(0), /* instruction mode */
- 0xc1,
- U8G_ESC_ADR(1),
- 0xc8, 0x80, 0xc8, /* Set Contrast */
- U8G_ESC_ADR(0), /* instruction mode */
- 0xc7,
- U8G_ESC_ADR(1),
- 0x0f, /* Set Master Contrast */
- U8G_ESC_ADR(0), /* instruction mode */
- 0xb6,
- U8G_ESC_ADR(1),
- 0x01, /* Set Second Precharge Period */
- U8G_ESC_ADR(0), /* instruction mode */
- 0xa6, /* Set Display Mode Reset */
- U8G_ESC_ADR(0), /* instruction mode */
- 0xb8, /* Set CMD Grayscale Lookup */
- U8G_ESC_ADR(1),
- 0x05,
- 0x06,
- 0x07,
- 0x08,
- 0x09,
- 0x0a,
- 0x0b,
- 0x0c,
- 0x0D,
- 0x0E,
- 0x0F,
- 0x10,
- 0x11,
- 0x12,
- 0x13,
- 0x14,
- 0x15,
- 0x16,
- 0x18,
- 0x1a,
- 0x1b,
- 0x1C,
- 0x1D,
- 0x1F,
- 0x21,
- 0x23,
- 0x25,
- 0x27,
- 0x2A,
- 0x2D,
- 0x30,
- 0x33,
- 0x36,
- 0x39,
- 0x3C,
- 0x3F,
- 0x42,
- 0x45,
- 0x48,
- 0x4C,
- 0x50,
- 0x54,
- 0x58,
- 0x5C,
- 0x60,
- 0x64,
- 0x68,
- 0x6C,
- 0x70,
- 0x74,
- 0x78,
- 0x7D,
- 0x82,
- 0x87,
- 0x8C,
- 0x91,
- 0x96,
- 0x9B,
- 0xA0,
- 0xA5,
- 0xAA,
- 0xAF,
- 0xB4,
- U8G_ESC_ADR(0),
- 0xaf, /* Set Display On */
- 0x5c,
- U8G_ESC_DLY(50),
- U8G_ESC_CS(0), /* disable chip */
- U8G_ESC_ADR(1),
- U8G_ESC_END /* end of sequence */
- };
- #define u8g_dev_ssd1351_128x128_init_seq u8g_dev_ssd1351_128x128_init_seq
- static const uint8_t u8g_dev_ssd1351_128x128_column_seq[] PROGMEM = {
- U8G_ESC_CS(1),
- U8G_ESC_ADR(0), 0x15,
- U8G_ESC_ADR(1), 0x00, 0x7f,
- U8G_ESC_ADR(0), 0x75,
- U8G_ESC_ADR(1), 0x00, 0x7f,
- U8G_ESC_ADR(0), 0x5c,
- U8G_ESC_ADR(1),
- U8G_ESC_CS(0),
- U8G_ESC_END
- };
- #define RGB332_STREAM_BYTES 8
- static uint8_t u8g_ssd1351_stream_bytes[RGB332_STREAM_BYTES*3];
- void u8g_ssd1351_to_stream(uint8_t *ptr)
- {
- uint8_t cnt = RGB332_STREAM_BYTES;
- uint8_t val;
- uint8_t *dest = u8g_ssd1351_stream_bytes;
- for( cnt = 0; cnt < RGB332_STREAM_BYTES; cnt++ )
- {
- val = *ptr++;
- *dest++ = ((val & 0xe0) >> 2);
- *dest++ = ((val & 0x1c) << 1);
- *dest++ = ((val & 0x03) << 4);
- }
- }
- #ifdef OBSOLETE
- // Convert the internal RGB 332 to R
- static uint8_t u8g_ssd1351_get_r(uint8_t colour)
- {
- //return ((colour & 0xe0) >> 5) * 9;
- //return ((colour & 0xe0) >> 5) * 8;
- return ((colour & 0xe0) >> 2) ;
- }
- // Convert the internal RGB 332 to G
- static uint8_t u8g_ssd1351_get_g(uint8_t colour)
- {
- //return ((colour & 0x1c) >> 2) * 9;
- //return ((colour & 0x1c) >> 2) * 8;
- return ((colour & 0x1c) << 1);
- }
- // Convert the internal RGB 332 to B
- static uint8_t u8g_ssd1351_get_b(uint8_t colour)
- {
- //return (colour & 0x03) * 21;
- return (colour & 0x03) * 16;
- }
- #endif
- uint8_t u8g_dev_ssd1351_128x128_332_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
- {
- // u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
- switch(msg)
- {
- case U8G_DEV_MSG_INIT:
- u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_50NS);
- u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1351_128x128_init_seq);
- break;
- case U8G_DEV_MSG_STOP:
- break;
- case U8G_DEV_MSG_PAGE_FIRST:
- u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1351_128x128_column_seq);
- break;
- case U8G_DEV_MSG_PAGE_NEXT:
- {
- u8g_uint_t x;
- uint8_t page_height;
- uint8_t i;
- u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
- uint8_t *ptr = pb->buf;
- u8g_SetChipSelect(u8g, dev, 1);
- page_height = pb->p.page_y1;
- page_height -= pb->p.page_y0;
- page_height++;
- for( i = 0; i < page_height; i++ )
- {
-
- for (x = 0; x < pb->width; x+=RGB332_STREAM_BYTES)
- {
- u8g_ssd1351_to_stream(ptr);
- u8g_WriteSequence(u8g, dev, RGB332_STREAM_BYTES*3, u8g_ssd1351_stream_bytes);
- ptr += RGB332_STREAM_BYTES;
- }
- }
- u8g_SetChipSelect(u8g, dev, 0);
- }
- break;
- case U8G_DEV_MSG_GET_MODE:
- return U8G_MODE_R3G3B2;
- }
- return u8g_dev_pb8h8_base_fn(u8g, dev, msg, arg);
- }
- uint8_t u8g_dev_ssd1351_128x128gh_332_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
- {
- // u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
- switch(msg)
- {
- case U8G_DEV_MSG_INIT:
- u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_50NS);
- u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1351_128x128gh_init_seq);
- break;
- case U8G_DEV_MSG_STOP:
- break;
- case U8G_DEV_MSG_PAGE_FIRST:
- u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1351_128x128_column_seq);
- break;
- case U8G_DEV_MSG_PAGE_NEXT:
- {
- u8g_uint_t x;
- uint8_t page_height;
- uint8_t i;
- u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
- uint8_t *ptr = pb->buf;
- u8g_SetChipSelect(u8g, dev, 1);
- page_height = pb->p.page_y1;
- page_height -= pb->p.page_y0;
- page_height++;
- for( i = 0; i < page_height; i++ )
- {
-
- for (x = 0; x < pb->width; x+=RGB332_STREAM_BYTES)
- {
- u8g_ssd1351_to_stream(ptr);
- u8g_WriteSequence(u8g, dev, RGB332_STREAM_BYTES*3, u8g_ssd1351_stream_bytes);
- ptr += RGB332_STREAM_BYTES;
- }
- }
- u8g_SetChipSelect(u8g, dev, 0);
- }
- break;
- case U8G_DEV_MSG_GET_MODE:
- return U8G_MODE_R3G3B2;
- }
- return u8g_dev_pb8h8_base_fn(u8g, dev, msg, arg);
- }
- static uint8_t u8g_dev_ssd1351_128x128_r[256];
- static uint8_t u8g_dev_ssd1351_128x128_g[256];
- static uint8_t u8g_dev_ssd1351_128x128_b[256];
- uint8_t u8g_dev_ssd1351_128x128_idx_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
- {
- // u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
- switch(msg)
- {
- case U8G_DEV_MSG_INIT:
- u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_50NS);
- u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1351_128x128_init_seq);
- break;
- case U8G_DEV_MSG_STOP:
- break;
-
- case U8G_DEV_MSG_SET_COLOR_ENTRY:
- u8g_dev_ssd1351_128x128_r[ ((u8g_dev_arg_irgb_t *)arg)->idx ] = ((u8g_dev_arg_irgb_t *)arg)->r;
- u8g_dev_ssd1351_128x128_g[ ((u8g_dev_arg_irgb_t *)arg)->idx ] = ((u8g_dev_arg_irgb_t *)arg)->g;
- u8g_dev_ssd1351_128x128_b[ ((u8g_dev_arg_irgb_t *)arg)->idx ] = ((u8g_dev_arg_irgb_t *)arg)->b;
- break;
-
- case U8G_DEV_MSG_PAGE_FIRST:
- u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1351_128x128_column_seq);
- break;
- case U8G_DEV_MSG_PAGE_NEXT:
- {
- int x;
- u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
- uint8_t *ptr = pb->buf;
- u8g_SetChipSelect(u8g, dev, 1);
- for (x = 0; x < pb->width; x++)
- {
- u8g_WriteByte(u8g, dev, u8g_dev_ssd1351_128x128_r[(*ptr)>>2]);
- u8g_WriteByte(u8g, dev, u8g_dev_ssd1351_128x128_g[(*ptr)>>2]);
- u8g_WriteByte(u8g, dev, u8g_dev_ssd1351_128x128_b[(*ptr)>>2]);
- ptr++;
- }
- u8g_SetChipSelect(u8g, dev, 0);
- }
- break;
- case U8G_DEV_MSG_GET_MODE:
- return U8G_MODE_INDEX;
- }
- return u8g_dev_pb8h8_base_fn(u8g, dev, msg, arg);
- }
- void u8g_ssd1351_hicolor_to_stream(uint8_t *ptr)
- {
- register uint8_t cnt = RGB332_STREAM_BYTES;
- register uint8_t low, high, r, g, b;
- uint8_t *dest = u8g_ssd1351_stream_bytes;
- for( cnt = 0; cnt < RGB332_STREAM_BYTES; cnt++ )
- {
- low = *ptr++;
- high = *ptr++;
-
- r = high & ~7;
- r >>= 2;
- b = low & 31;
- b <<= 1;
- g = high & 7;
- g <<= 3;
- g |= (low>>5)&7;
-
- *dest++ = r;
- *dest++ = g;
- *dest++ = b;
- }
- }
- uint8_t u8g_dev_ssd1351_128x128_hicolor_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_SPI_CLK_CYCLE_50NS);
- u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1351_128x128_init_seq);
- break;
- case U8G_DEV_MSG_STOP:
- break;
- case U8G_DEV_MSG_PAGE_FIRST:
- u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1351_128x128_column_seq);
- break;
- case U8G_DEV_MSG_PAGE_NEXT:
- {
- u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
- uint8_t i, j;
- uint8_t page_height;
- uint8_t *ptr = pb->buf;
- u8g_SetChipSelect(u8g, dev, 1);
- page_height = pb->p.page_y1;
- page_height -= pb->p.page_y0;
- page_height++;
- for( j = 0; j < page_height; j++ )
- {
- for (i = 0; i < pb->width; i+=RGB332_STREAM_BYTES)
- {
- u8g_ssd1351_hicolor_to_stream(ptr);
- u8g_WriteSequence(u8g, dev, RGB332_STREAM_BYTES*3, u8g_ssd1351_stream_bytes);
- ptr += RGB332_STREAM_BYTES*2;
- }
-
- }
- u8g_SetChipSelect(u8g, dev, 0);
-
- }
- break; /* continue to base fn */
- case U8G_DEV_MSG_GET_MODE:
- return U8G_MODE_HICOLOR;
- }
- return u8g_dev_pbxh16_base_fn(u8g, dev, msg, arg);
- }
- uint8_t u8g_dev_ssd1351_128x128gh_hicolor_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_SPI_CLK_CYCLE_50NS);
- u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1351_128x128gh_init_seq);
- break;
- case U8G_DEV_MSG_STOP:
- break;
- case U8G_DEV_MSG_PAGE_FIRST:
- u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1351_128x128_column_seq);
- break;
- case U8G_DEV_MSG_PAGE_NEXT:
- {
- u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
- uint8_t i, j;
- uint8_t page_height;
- uint8_t *ptr = pb->buf;
- u8g_SetChipSelect(u8g, dev, 1);
- page_height = pb->p.page_y1;
- page_height -= pb->p.page_y0;
- page_height++;
- for( j = 0; j < page_height; j++ )
- {
- for (i = 0; i < pb->width; i+=RGB332_STREAM_BYTES)
- {
- u8g_ssd1351_hicolor_to_stream(ptr);
- u8g_WriteSequence(u8g, dev, RGB332_STREAM_BYTES*3, u8g_ssd1351_stream_bytes);
- ptr += RGB332_STREAM_BYTES*2;
- }
-
- }
- u8g_SetChipSelect(u8g, dev, 0);
-
- }
- break; /* continue to base fn */
- case U8G_DEV_MSG_GET_MODE:
- return U8G_MODE_HICOLOR;
- }
- return u8g_dev_pbxh16_base_fn(u8g, dev, msg, arg);
- }
- uint8_t u8g_dev_ssd1351_128x128_byte_buf[WIDTH*PAGE_HEIGHT] U8G_NOCOMMON ;
- u8g_pb_t u8g_dev_ssd1351_128x128_byte_pb = { {PAGE_HEIGHT, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_ssd1351_128x128_byte_buf};
- u8g_dev_t u8g_dev_ssd1351_128x128_332_sw_spi = { u8g_dev_ssd1351_128x128_332_fn, &u8g_dev_ssd1351_128x128_byte_pb, U8G_COM_SW_SPI };
- u8g_dev_t u8g_dev_ssd1351_128x128_332_hw_spi = { u8g_dev_ssd1351_128x128_332_fn, &u8g_dev_ssd1351_128x128_byte_pb, U8G_COM_HW_SPI };
- u8g_dev_t u8g_dev_ssd1351_128x128gh_332_sw_spi = { u8g_dev_ssd1351_128x128gh_332_fn, &u8g_dev_ssd1351_128x128_byte_pb, U8G_COM_SW_SPI };
- u8g_dev_t u8g_dev_ssd1351_128x128gh_332_hw_spi = { u8g_dev_ssd1351_128x128gh_332_fn, &u8g_dev_ssd1351_128x128_byte_pb, U8G_COM_HW_SPI };
- //u8g_dev_t u8g_dev_ssd1351_128x128_idx_sw_spi = { u8g_dev_ssd1351_128x128_idx_fn, &u8g_dev_ssd1351_128x128_byte_pb, U8G_COM_SW_SPI };
- //u8g_dev_t u8g_dev_ssd1351_128x128_idx_hw_spi = { u8g_dev_ssd1351_128x128_idx_fn, &u8g_dev_ssd1351_128x128_byte_pb, U8G_COM_HW_SPI };
- /* only half of the height, because two bytes are needed for one pixel */
- u8g_pb_t u8g_dev_ssd1351_128x128_hicolor_byte_pb = { {PAGE_HEIGHT/2, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_ssd1351_128x128_byte_buf};
- u8g_dev_t u8g_dev_ssd1351_128x128_hicolor_sw_spi = { u8g_dev_ssd1351_128x128_hicolor_fn, &u8g_dev_ssd1351_128x128_hicolor_byte_pb, U8G_COM_SW_SPI };
- u8g_dev_t u8g_dev_ssd1351_128x128_hicolor_hw_spi = { u8g_dev_ssd1351_128x128_hicolor_fn, &u8g_dev_ssd1351_128x128_hicolor_byte_pb, U8G_COM_HW_SPI };
- u8g_dev_t u8g_dev_ssd1351_128x128gh_hicolor_sw_spi = { u8g_dev_ssd1351_128x128gh_hicolor_fn, &u8g_dev_ssd1351_128x128_hicolor_byte_pb, U8G_COM_SW_SPI };
- u8g_dev_t u8g_dev_ssd1351_128x128gh_hicolor_hw_spi = { u8g_dev_ssd1351_128x128gh_hicolor_fn, &u8g_dev_ssd1351_128x128_hicolor_byte_pb, U8G_COM_HW_SPI };
- uint8_t u8g_dev_ssd1351_128x128_4x_byte_buf[WIDTH*PAGE_HEIGHT*4] U8G_NOCOMMON ;
- u8g_pb_t u8g_dev_ssd1351_128x128_4x_332_byte_pb = { {PAGE_HEIGHT*4, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_ssd1351_128x128_4x_byte_buf};
- u8g_dev_t u8g_dev_ssd1351_128x128_4x_332_sw_spi = { u8g_dev_ssd1351_128x128_332_fn, &u8g_dev_ssd1351_128x128_4x_332_byte_pb, U8G_COM_SW_SPI };
- u8g_dev_t u8g_dev_ssd1351_128x128_4x_332_hw_spi = { u8g_dev_ssd1351_128x128_332_fn, &u8g_dev_ssd1351_128x128_4x_332_byte_pb, U8G_COM_HW_SPI };
- u8g_dev_t u8g_dev_ssd1351_128x128gh_4x_332_sw_spi = { u8g_dev_ssd1351_128x128gh_332_fn, &u8g_dev_ssd1351_128x128_4x_332_byte_pb, U8G_COM_SW_SPI };
- u8g_dev_t u8g_dev_ssd1351_128x128gh_4x_332_hw_spi = { u8g_dev_ssd1351_128x128gh_332_fn, &u8g_dev_ssd1351_128x128_4x_332_byte_pb, U8G_COM_HW_SPI };
- u8g_pb_t u8g_dev_ssd1351_128x128_4x_hicolor_byte_pb = { {PAGE_HEIGHT/2*4, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_ssd1351_128x128_4x_byte_buf};
- u8g_dev_t u8g_dev_ssd1351_128x128_4x_hicolor_sw_spi = { u8g_dev_ssd1351_128x128_hicolor_fn, &u8g_dev_ssd1351_128x128_4x_hicolor_byte_pb, U8G_COM_SW_SPI };
- u8g_dev_t u8g_dev_ssd1351_128x128_4x_hicolor_hw_spi = { u8g_dev_ssd1351_128x128_hicolor_fn, &u8g_dev_ssd1351_128x128_4x_hicolor_byte_pb, U8G_COM_HW_SPI };
- u8g_dev_t u8g_dev_ssd1351_128x128gh_4x_hicolor_sw_spi = { u8g_dev_ssd1351_128x128gh_hicolor_fn, &u8g_dev_ssd1351_128x128_4x_hicolor_byte_pb, U8G_COM_SW_SPI };
- u8g_dev_t u8g_dev_ssd1351_128x128gh_4x_hicolor_hw_spi = { u8g_dev_ssd1351_128x128gh_hicolor_fn, &u8g_dev_ssd1351_128x128_4x_hicolor_byte_pb, U8G_COM_HW_SPI };
- /*
- U8G_PB_DEV(u8g_dev_ssd1351_128x128_332_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1351_128x128_332_fn, U8G_COM_SW_SPI);
- U8G_PB_DEV(u8g_dev_ssd1351_128x128_332_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1351_128x128_332_fn, U8G_COM_HW_SPI);
- U8G_PB_DEV(u8g_dev_ssd1351_128x128_idx_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1351_128x128_idx_fn, U8G_COM_SW_SPI);
- U8G_PB_DEV(u8g_dev_ssd1351_128x128_idx_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1351_128x128_idx_fn, U8G_COM_HW_SPI);
- */
|