u8g_dev_pcf8812_96x65.c 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*
  2. u8g_dev_pcf8812_96x65.c
  3. Display: Nokia 96x65
  4. Universal 8bit Graphics Library
  5. Copyright (c) 2011, 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. om6206 comaptible to pcf8812 ?
  28. Status: Tested
  29. Display Controller Seen in
  30. LPH7366 (9 pins, 84x48) PCD8544 Nokia 5110 / 5120 / 5130 / 5160 / 6110 / 6150
  31. LPH7677 (8 pins, 84x48) PCD8544 Nokia 3210
  32. LPH7779 (8 pins, 84x48) PCD8544 Nokia 3310 / 3315 / 3330 / 3110, also 3410?
  33. ??? PCD8544 Nokia 5110 / 6110
  34. LPH7690 ? (96x65) PCF8455/OM6202 Nokia 3410
  35. LPH7690 ? (96x65?) SED1565/S1D15605 Nokia 7110 / 3510?
  36. LPH7690 ??? Nokia 6210
  37. */
  38. #include "u8g.h"
  39. #define WIDTH 96
  40. #define HEIGHT 65
  41. #define PAGE_HEIGHT 8
  42. static const uint8_t u8g_dev_pcf8812_init_seq[] PROGMEM = {
  43. U8G_ESC_CS(0), /* disable chip */
  44. U8G_ESC_ADR(0), /* instruction mode */
  45. U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
  46. U8G_ESC_CS(1), /* enable chip */
  47. 0x021, /* activate chip (PD=0), horizontal increment (V=0), enter extended command set (H=1) */
  48. 0x006, /* temp. control: b10 = 2 */
  49. 0x013, /* bias system 1:48 */
  50. 0x080 | 0x040, /* medium Vop */
  51. 0x020, /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
  52. 0x00c, /* display on, normal operation */
  53. U8G_ESC_DLY(100), /* delay 100 ms */
  54. 0x020, /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
  55. 0x00d, /* display on, invert */
  56. U8G_ESC_DLY(100), /* delay 100 ms */
  57. U8G_ESC_DLY(100), /* delay 100 ms */
  58. 0x020, /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
  59. 0x00c, /* display on, normal */
  60. U8G_ESC_DLY(100), /* delay 100 ms */
  61. U8G_ESC_CS(0), /* disable chip */
  62. U8G_ESC_END /* end of sequence */
  63. };
  64. uint8_t u8g_dev_pcf8812_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
  65. {
  66. switch(msg)
  67. {
  68. case U8G_DEV_MSG_INIT:
  69. u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_400NS);
  70. u8g_WriteEscSeqP(u8g, dev, u8g_dev_pcf8812_init_seq);
  71. break;
  72. case U8G_DEV_MSG_STOP:
  73. break;
  74. case U8G_DEV_MSG_PAGE_NEXT:
  75. {
  76. u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
  77. u8g_SetAddress(u8g, dev, 0); /* command mode */
  78. u8g_SetChipSelect(u8g, dev, 1);
  79. u8g_WriteByte(u8g, dev, 0x020 ); /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
  80. u8g_WriteByte(u8g, dev, 0x080 ); /* set X address */
  81. u8g_WriteByte(u8g, dev, 0x040 | pb->p.page); /* set Y address */
  82. u8g_SetAddress(u8g, dev, 1); /* data mode */
  83. if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
  84. return 0;
  85. /* mirrored output, not tested*/
  86. /*
  87. {
  88. uint8_t i = pb->width;
  89. while( i > 0 )
  90. {
  91. i--;
  92. u8g_WriteByte(u8g, dev, ((unsigned char *)pb->buf)[i] );
  93. }
  94. }
  95. */
  96. u8g_SetChipSelect(u8g, dev, 0);
  97. }
  98. break;
  99. case U8G_DEV_MSG_CONTRAST:
  100. /* the contrast adjustment does not work, needs to be analysed */
  101. u8g_SetAddress(u8g, dev, 0); /* instruction mode */
  102. u8g_SetChipSelect(u8g, dev, 1);
  103. u8g_WriteByte(u8g, dev, 0x021); /* command mode, extended function set */
  104. u8g_WriteByte(u8g, dev, 0x080 | ( (*(uint8_t *)arg) >> 1 ) );
  105. u8g_SetChipSelect(u8g, dev, 0);
  106. return 1;
  107. }
  108. return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
  109. }
  110. /* u8g_com_arduino_sw_spi_fn does not work, too fast??? */
  111. U8G_PB_DEV(u8g_dev_pcf8812_96x65_sw_spi , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_pcf8812_fn, U8G_COM_SW_SPI);
  112. U8G_PB_DEV(u8g_dev_pcf8812_96x65_hw_spi , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_pcf8812_fn, U8G_COM_HW_SPI);