u8g_dev_tls8204_84x48.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. u8g_dev_tls8204_84x48.c
  3. Display: Nokia 84x48
  4. Status: Tested with TLS8204V12 Display by Olimex MOD-LCD3310
  5. Contributed: http://code.google.com/p/u8glib/issues/detail?id=126
  6. Universal 8bit Graphics Library
  7. Copyright (c) 2011, olikraus@gmail.com
  8. All rights reserved.
  9. Redistribution and use in source and binary forms, with or without modification,
  10. are permitted provided that the following conditions are met:
  11. * Redistributions of source code must retain the above copyright notice, this list
  12. of conditions and the following disclaimer.
  13. * Redistributions in binary form must reproduce the above copyright notice, this
  14. list of conditions and the following disclaimer in the documentation and/or other
  15. materials provided with the distribution.
  16. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
  17. CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
  18. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  19. MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  20. DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
  21. CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  22. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  23. NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  24. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  25. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  26. STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  27. ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  28. ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. */
  30. #include "u8g.h"
  31. #define WIDTH 84
  32. #define HEIGHT 48
  33. #define PAGE_HEIGHT 8
  34. static const uint8_t u8g_dev_tls8204_init_seq[] PROGMEM = {
  35. U8G_ESC_CS(0), /* disable chip */
  36. U8G_ESC_ADR(0), /* instruction mode */
  37. U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
  38. U8G_ESC_CS(1), /* enable chip */
  39. 0x021, /* activate chip (PD=0), horizontal increment (V=0), enter extended command set (H=1) */
  40. 0x006, /* temp. control: b10 = 2 */
  41. 0x04 | !!((66-1)&(1u<<6)),
  42. 0x40 | ((66-2) & ((1u<<6)-1)),
  43. 0x013, /* bias system 1:48 */
  44. 0x0c0, /* medium Vop */
  45. 0x020, /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
  46. 0x00c, /* display on, normal operation */
  47. U8G_ESC_DLY(100), /* delay 100 ms */
  48. 0x020, /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
  49. 0x00d, /* display on, invert */
  50. U8G_ESC_DLY(100), /* delay 100 ms */
  51. U8G_ESC_DLY(100), /* delay 100 ms */
  52. 0x020, /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
  53. 0x00c, /* display on, normal */
  54. U8G_ESC_DLY(100), /* delay 100 ms */
  55. U8G_ESC_CS(0), /* disable chip */
  56. U8G_ESC_END /* end of sequence */
  57. };
  58. uint8_t u8g_dev_tls8204_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
  59. {
  60. switch(msg)
  61. {
  62. case U8G_DEV_MSG_INIT:
  63. u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_400NS);
  64. u8g_WriteEscSeqP(u8g, dev, u8g_dev_tls8204_init_seq);
  65. break;
  66. case U8G_DEV_MSG_STOP:
  67. break;
  68. case U8G_DEV_MSG_PAGE_NEXT:
  69. {
  70. u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
  71. u8g_SetAddress(u8g, dev, 0); /* command mode */
  72. u8g_SetChipSelect(u8g, dev, 1);
  73. u8g_WriteByte(u8g, dev, 0x020 ); /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
  74. u8g_WriteByte(u8g, dev, 0x080 ); /* set X address */
  75. u8g_WriteByte(u8g, dev, 0x040 | pb->p.page); /* set Y address */
  76. u8g_SetAddress(u8g, dev, 1); /* data mode */
  77. if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
  78. return 0;
  79. u8g_SetChipSelect(u8g, dev, 0);
  80. }
  81. break;
  82. case U8G_DEV_MSG_CONTRAST:
  83. /* the contrast adjustment does not work, needs to be analysed */
  84. u8g_SetAddress(u8g, dev, 0); /* instruction mode */
  85. u8g_SetChipSelect(u8g, dev, 1);
  86. u8g_WriteByte(u8g, dev, 0x021); /* command mode, extended function set */
  87. u8g_WriteByte(u8g, dev, 0x080 | ( (*(uint8_t *)arg) >> 1 ) );
  88. u8g_WriteByte(u8g, dev, 0x020); /* command mode, extended function set */
  89. u8g_SetChipSelect(u8g, dev, 0);
  90. return 1;
  91. }
  92. return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
  93. }
  94. U8G_PB_DEV(u8g_dev_tls8204_84x48_sw_spi , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_tls8204_fn, U8G_COM_SW_SPI);