u8g_dev_t6963_240x64.c 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. /*
  2. u8g_dev_t6963_240x64.c
  3. Tested with Varitronix MGLS240128TZ
  4. Universal 8bit Graphics Library
  5. Copyright (c) 2013, olikraus@gmail.com
  6. All rights reserved.
  7. Redistribution and use in source and binary forms, with or without modification,
  8. are permitted provided that the following conditions are met:
  9. * Redistributions of source code must retain the above copyright notice, this list
  10. of conditions and the following disclaimer.
  11. * Redistributions in binary form must reproduce the above copyright notice, this
  12. list of conditions and the following disclaimer in the documentation and/or other
  13. materials provided with the distribution.
  14. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
  15. CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
  16. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  17. MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  18. DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
  19. CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  20. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  21. NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  23. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  24. STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  25. ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  26. ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. Application Notes for the MGLS 240x128
  28. www.baso.no/content/pdf/T6963C_Application.pdf
  29. Hitachi App Notes:
  30. https://www.sparkfun.com/datasheets/LCD/Monochrome/AN-029-Toshiba_T6963C.pdf
  31. Notes:
  32. The font selection pins should generate the 8x8 font.
  33. For the MGLS240128TZ only FS1 is available on pin 18.
  34. FS1 must be low to generate the 8x8 font.
  35. */
  36. #include "u8g.h"
  37. #define WIDTH 240
  38. #define HEIGHT 64
  39. #define PAGE_HEIGHT 16
  40. /*
  41. http://www.mark-products.com/graphics.htm#240x64%20Pixel%20Format
  42. */
  43. /* text is not used, so settings are not relevant */
  44. static const uint8_t u8g_dev_t6963_240x64_init_seq[] PROGMEM = {
  45. U8G_ESC_CS(0), /* disable chip */
  46. U8G_ESC_ADR(0), /* data mode */
  47. U8G_ESC_RST(15), /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
  48. U8G_ESC_CS(1), /* enable chip */
  49. U8G_ESC_DLY(50), /* delay 50 ms */
  50. U8G_ESC_ADR(0), /* data mode */
  51. 0x000, /* low byte */
  52. 0x000, /* height byte */
  53. U8G_ESC_ADR(1), /* instruction mode */
  54. 0x021, /* set cursor position */
  55. U8G_ESC_ADR(0), /* data mode */
  56. 0x000, /* low byte */
  57. 0x000, /* height byte */
  58. U8G_ESC_ADR(1), /* instruction mode */
  59. 0x022, /* set offset */
  60. U8G_ESC_ADR(0), /* data mode */
  61. 0x000, /* low byte */
  62. 0x000, /* height byte */
  63. U8G_ESC_ADR(1), /* instruction mode */
  64. 0x040, /* text home */
  65. U8G_ESC_ADR(0), /* data mode */
  66. WIDTH/8, /* low byte */
  67. 0x000, /* height byte */
  68. U8G_ESC_ADR(1), /* instruction mode */
  69. 0x041, /* text columns */
  70. U8G_ESC_ADR(0), /* data mode */
  71. 0x000, /* low byte */
  72. 0x000, /* height byte */
  73. U8G_ESC_ADR(1), /* instruction mode */
  74. 0x042, /* graphics home */
  75. U8G_ESC_ADR(0), /* data mode */
  76. WIDTH/8, /* low byte */
  77. 0x000, /* height byte */
  78. U8G_ESC_ADR(1), /* instruction mode */
  79. 0x043, /* graphics columns */
  80. // mode set
  81. // 0x080: Internal CG, OR Mode
  82. // 0x081: Internal CG, EXOR Mode
  83. // 0x083: Internal CG, AND Mode
  84. // 0x088: External CG, OR Mode
  85. // 0x089: External CG, EXOR Mode
  86. // 0x08B: External CG, AND Mode
  87. U8G_ESC_ADR(1), /* instruction mode */
  88. 0x080, /* mode register: OR Mode, Internal Character Mode */
  89. U8G_ESC_ADR(1), /* instruction mode */
  90. // display mode
  91. // 0x090: Display off
  92. // 0x094: Graphic off, text on, cursor off, blink off
  93. // 0x096: Graphic off, text on, cursor on, blink off
  94. // 0x097: Graphic off, text on, cursor on, blink on
  95. // 0x098: Graphic on, text off, cursor off, blink off
  96. // 0x09a: Graphic on, text off, cursor on, blink off
  97. // ...
  98. // 0x09c: Graphic on, text on, cursor off, blink off
  99. // 0x09f: Graphic on, text on, cursor on, blink on
  100. 0x098, /* mode register: Display Mode, Graphics on, Text off, Cursor off */
  101. U8G_ESC_ADR(0), /* data mode */
  102. 0x000, /* low byte */
  103. 0x000, /* height byte */
  104. U8G_ESC_ADR(1), /* instruction mode */
  105. 0x024, /* set adr pointer */
  106. U8G_ESC_DLY(100), /* delay 100 ms */
  107. U8G_ESC_ADR(0), /* data mode */
  108. U8G_ESC_CS(0), /* disable chip */
  109. U8G_ESC_END /* end of sequence */
  110. };
  111. uint8_t u8g_dev_t6963_240x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
  112. {
  113. switch(msg)
  114. {
  115. case U8G_DEV_MSG_INIT:
  116. u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_NONE);
  117. u8g_WriteEscSeqP(u8g, dev, u8g_dev_t6963_240x64_init_seq);
  118. break;
  119. case U8G_DEV_MSG_STOP:
  120. break;
  121. case U8G_DEV_MSG_PAGE_NEXT:
  122. {
  123. uint8_t y, i;
  124. uint16_t disp_ram_adr;
  125. uint8_t *ptr;
  126. u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
  127. u8g_SetAddress(u8g, dev, 0); /* data mode */
  128. u8g_SetChipSelect(u8g, dev, 1);
  129. y = pb->p.page_y0;
  130. ptr = pb->buf;
  131. disp_ram_adr = WIDTH/8;
  132. disp_ram_adr *= y;
  133. for( i = 0; i < PAGE_HEIGHT; i ++ )
  134. {
  135. u8g_SetAddress(u8g, dev, 0); /* data mode */
  136. u8g_WriteByte(u8g, dev, disp_ram_adr&255 ); /* address low byte */
  137. u8g_WriteByte(u8g, dev, disp_ram_adr>>8 ); /* address hight byte */
  138. u8g_SetAddress(u8g, dev, 1); /* cmd mode */
  139. u8g_WriteByte(u8g, dev, 0x024 ); /* set adr ptr */
  140. u8g_WriteSequence(u8g, dev, WIDTH/8, ptr);
  141. ptr += WIDTH/8;
  142. disp_ram_adr += WIDTH/8;
  143. }
  144. u8g_SetAddress(u8g, dev, 0); /* data mode */
  145. u8g_SetChipSelect(u8g, dev, 0);
  146. }
  147. break;
  148. }
  149. return u8g_dev_pb16h1_base_fn(u8g, dev, msg, arg);
  150. }
  151. // U8G_PB_DEV(u8g_dev_t6963_240x64_8bit, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_t6963_240x64_fn, U8G_COM_T6963);
  152. uint8_t u8g_dev_t6963_240x64_2x_bw_buf[WIDTH/8*PAGE_HEIGHT] U8G_NOCOMMON ;
  153. u8g_pb_t u8g_dev_t6963_240x64_2x_bw_pb = { {PAGE_HEIGHT, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_t6963_240x64_2x_bw_buf};
  154. u8g_dev_t u8g_dev_t6963_240x64_8bit = { u8g_dev_t6963_240x64_fn, &u8g_dev_t6963_240x64_2x_bw_pb, U8G_COM_T6963 };