summaryrefslogtreecommitdiffstats
path: root/_site/log/e-reader/index.html
blob: a5dbc0110ebffcafd029f728f329b018856a4de8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<!DOCTYPE html>
<html>
    <head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>ESP32 e-reader prototype</title>
  <link rel="stylesheet" href="/assets/css/main.css">
  <link rel="stylesheet" href="/assets/css/skeleton.css">
</head>


  <body>

    <div id="nav-container" class="container">
  <ul id="navlist" class="left">
    
    <li >
      <a href="/" class="link-decor-none">hme</a>
    </li>
    <li >
      <a href="/projects/" class="link-decor-none">poc</a>
    </li>
    <li >
      <a href="/about/" class="link-decor-none">abt</a>
    </li>
    <li>
      <a href="/cgi-bin/find.cgi" class="link-decor-none">lup</a>
    </li>
    <li>
      <a href="/feed.xml" class="link-decor-none">rss</a>
    </li>
  </ul>
</div>



    <main>
      <div class="container">
        <div class="container-2">
          <h2 class="center" id="title">ESP32 E-READER PROTOTYPE</h2>
          <h5 class="center">24 OCTOBER 2023</h5>
          <br>
          <div class="twocol justify"><p>First project with e-paper displays and ESP32.</p>

<video style="max-width:100%;" controls="" poster="poster.png">
  <source src="ereader.mp4" type="video/mp4" />
</video>

<p>System: ESP-WROOM-32, 7.5” Waveshare e-paper display, three buttons
(prev/next/sleep).</p>

<p>2023-09-23: 512KB SRAM, 4MB flash (shared with FreeRTOS and ESP-IDF). Not
enough storage for books. Using ESP32’s built-in WiFi to stream them over HTTP.
Recording the reading progress in RTC memory.</p>

<p>Rasterized pages encoded as tightly packed bitmaps (1 byte =&gt; 8 pixels), no
headers, arranged along 48 KB (480x800) boundaries; Reader can stream pages
using HTTP Range requests with zero server-side logic. Keeps both ends lean.</p>

<p>Page table stores 3 pages (prev/current/next) in a circular buffer. When the
user requests a page, program cycles through the table, updates the screen, and
downloads the next page.</p>

<p>Responsiveness is inadequate. Scheduling GPIO (user input), SPI, and HTTP on
one core causes input lag. Pinned the GPIO and SPI tasks to one core, the HTTP
task to the other core.</p>

<p>Better, but screen updates are blocking user input; Made SPI transfer async:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>void epd_draw_async(const uint8_t *buf, size_t n)
{
    static spi_transaction_t t[3];

    memset(&amp;t[0], 0, sizeof(t[0])); 
    t[0].length = 8;
    t[0].tx_data[0] = 0x13;
    t[0].user = (void*) 0; 
    t[0].flags = SPI_TRANS_USE_TXDATA;

    memset(&amp;t[1], 0, sizeof(t[1])); 
    t[1].length = 8 * n;
    t[1].tx_buffer = buf;
    t[1].user = (void*) 1; 

    memset(&amp;t[2], 0, sizeof(t[2])); 
    t[2].length = 8;
    t[2].tx_data[0] = 0x12;
    t[2].user = (void*) 0; 
    t[2].flags = SPI_TRANS_USE_TXDATA;

    for (int i = 0; i &lt; 3; i++)
        spi_device_queue_trans(spi, &amp;t[i], portMAX_DELAY);
}
</code></pre></div></div>

<p>Much better.</p>

<p>2023-10-06: Moved the page table to DMA-capable memory; Reclaimed a few more
CPU cycles from the SPI transfers.</p>

<p>Can’t think of anything else.</p>

<p>Verdict: Works but limited. Led to <a href="../etlas/">Etlas</a>.</p>

<p>Commit:
<a href="https://git.asciimx.com/esp32-e-reader/commit/?id=7f691c46093933b67aab466c0ca582ace8ab73d4">7f691c4</a></p>
</div>
          <p class="post-author right">by W. D. Sadeep Madurange</p>
        </div>
      </div>
    </main>

    <div class="footer">
  <div class="container">
    <div class="twelve columns right container-2">
      <p id="footer-text">&copy; ASCIIMX - 2026</p>
    </div>
  </div>
</div>


  </body>
</html>