ssd1606timing.ino 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /* Arduino Smart_Eink Library
  2. * Copyright (C) 2016 by NOA Labs
  3. * Author Bruce Guo (NOA Labs)
  4. *
  5. * This file is E-ink demo showing string.
  6. *
  7. * This Library is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation, either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This Library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this Library. If not, see
  19. * <http://www.gnu.org/licenses/>.
  20. */
  21. /*
  22. D/C ~ D5
  23. CS ~ D6
  24. BUSY ~ D7
  25. BS ~ D8
  26. MOSI ~ D11
  27. MISO ~ D12
  28. CLK ~ D13
  29. */
  30. #include <SmartEink.h>
  31. #include <SPI.h>
  32. E_ink Eink;
  33. unsigned long wait_max;
  34. void wait(void)
  35. {
  36. unsigned v;
  37. unsigned long w;
  38. w = millis();
  39. do
  40. {
  41. v = digitalRead(A0);
  42. } while( v != 0 );
  43. w = millis() - w;
  44. Serial.print("wait: ");
  45. Serial.print(w);
  46. Serial.println(" ");
  47. }
  48. void setup()
  49. {
  50. Serial.begin(9600);
  51. while (!Serial) {
  52. ; // wait for serial port to connect. Needed for native USB port only
  53. }
  54. pinMode(8,OUTPUT);
  55. pinMode(9,OUTPUT);
  56. pinMode(10,OUTPUT);
  57. digitalWrite(8, HIGH);
  58. delay(1000);
  59. Eink.InitEink();
  60. delay(1000);
  61. Eink.WriteComm(0x3b);//set gate line width
  62. Eink.WriteData(0x08);//60 + value*4 us --> this influences delay 4: 694/ms, 9:1062/297, 8(POR):957/266
  63. }
  64. unsigned x = 0;
  65. void loop()
  66. {
  67. Eink.WriteComm(0x44);//set RAM x address start/end, in page 36
  68. Eink.WriteData(0x00);//RAM x address start at 00h;
  69. Eink.WriteData(0x11);//RAM x address end at 11h(17)->72: [because 1F(31)->128 and 12(18)->76]
  70. Eink.WriteComm(0x45);//set RAM y address start/end, in page 37
  71. Eink.WriteData(0x00);//RAM y address start at 00h;
  72. Eink.WriteData(0xab);//RAM y address start at ABh(171)->172: [because B3(179)->180]
  73. Eink.WriteComm(0x11);//data enter mode
  74. Eink.WriteData(0x07);
  75. Eink.WriteComm(0x4E);//set RAM x address count to 0;
  76. Eink.WriteData(0x00);
  77. Eink.WriteComm(0x4F);//set RAM y address count to 0;
  78. Eink.WriteData(0);
  79. Eink.ClearScreen();// clear the screen
  80. Eink.WriteComm(0x11);//data enter mode
  81. Eink.WriteData(0x07);
  82. Eink.WriteComm(0x4E);//set RAM x address count to 0;
  83. Eink.WriteData(0x08);
  84. Eink.WriteComm(0x4F);//set RAM y address count to 0;
  85. Eink.WriteData(x*2);
  86. x ++;
  87. x = x & 0x01f;
  88. //delay(1000);
  89. Eink.WriteComm(0x24);
  90. Eink.WriteData(0x00);
  91. Eink.WriteData(0x03);
  92. Eink.WriteData(0x0f);
  93. Eink.WriteData(0x3f);
  94. Eink.WriteData(0xff);
  95. Eink.WriteData(0xff);
  96. Eink.WriteData(0xff);
  97. Eink.WriteData(0xff);
  98. Eink.WriteData(0xff);
  99. Eink.WriteData(0x03);
  100. Eink.WriteData(0x0f);
  101. Eink.WriteData(0x3f);
  102. Eink.WriteData(0xff);
  103. Eink.WriteData(0xff);
  104. Eink.WriteData(0xff);
  105. Eink.WriteData(0xff);
  106. Eink.WriteData(0xff);
  107. Eink.WriteData(0x00);
  108. Eink.WriteComm(0x22);//display updata sequence option ,in page 33
  109. Eink.WriteData(0xC0);//enable sequence: clk -> CP -> on
  110. Eink.WriteComm(0x20);
  111. Serial.print("Clk+CP ");
  112. wait();
  113. //delay(1000);
  114. Eink.WriteComm(0x22);//display updata sequence option ,in page 33
  115. Eink.WriteData(0x04);//enable sequence: clk -> CP -> LUT -> initial display -> pattern display
  116. Eink.WriteComm(0x20);
  117. //delay(1000);
  118. Serial.print("To Display ");
  119. wait();
  120. Eink.WriteComm(0x22);
  121. Eink.WriteData(0x03);
  122. Eink.WriteComm(0x20);
  123. //delay(1000);
  124. Serial.print("CP/Clock off ");
  125. wait();
  126. //delay(1000);
  127. //Eink.ClearScreen();// clear the screen
  128. //Eink.EinkP8x16Str(14,8,"NOA-Labs.com");
  129. //Eink.EinkP8x16Str(10,8,"smart-prototyping.com");
  130. //Eink.EinkP8x16Str(6,8,"0123456789");
  131. //Eink.EinkP8x16Str(2,8,"ABCDEFG abcdefg");
  132. //Eink.RefreshScreen();
  133. }
  134. void xloop()
  135. {
  136. }