Bladeren bron

display: Implement fast refresh (WIP, requires better UI code).

Mathias Gottschlag 5 jaren geleden
bovenliggende
commit
b82214e974
4 gewijzigde bestanden met toevoegingen van 32 en 12 verwijderingen
  1. 3
    3
      display/firmware/Cargo.lock
  2. 1
    1
      display/firmware/Cargo.toml
  3. 27
    5
      display/firmware/src/display.rs
  4. 1
    3
      display/firmware/src/main.rs

+ 3
- 3
display/firmware/Cargo.lock Bestand weergeven

@@ -143,7 +143,7 @@ dependencies = [
143 143
  "cortex-m-semihosting 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
144 144
  "embedded-hal 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
145 145
  "embedded-nrf24l01 0.2.0 (git+https://github.com/mgottschlag/embedded-nrf24l01?branch=wip)",
146
- "epd-waveshare 0.4.0 (git+https://github.com/mgottschlag/epd-waveshare.git?branch=streaming)",
146
+ "epd-waveshare 0.4.0 (git+https://github.com/mgottschlag/epd-waveshare?branch=wip)",
147 147
  "mkl25z4 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
148 148
  "mkl25z4-hal 0.1.0 (git+https://github.com/mgottschlag/mkl25z4-hal)",
149 149
  "nb 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -183,7 +183,7 @@ dependencies = [
183 183
 [[package]]
184 184
 name = "epd-waveshare"
185 185
 version = "0.4.0"
186
-source = "git+https://github.com/mgottschlag/epd-waveshare.git?branch=streaming#fc18e6f6fa078312879ec978729390ca4a6ab70a"
186
+source = "git+https://github.com/mgottschlag/epd-waveshare?branch=wip#a24bec5be720c89cedda513a139bc983b0c5e1d0"
187 187
 dependencies = [
188 188
  "embedded-graphics 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
189 189
  "embedded-hal 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -480,7 +480,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
480 480
 "checksum embedded-graphics 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "40a69991ceb896bd4810a0cf2bcc46fc94b7860573c71f965d8e5b3d66942fed"
481 481
 "checksum embedded-hal 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ee4908a155094da7723c2d60d617b820061e3b4efcc3d9e293d206a5a76c170b"
482 482
 "checksum embedded-nrf24l01 0.2.0 (git+https://github.com/mgottschlag/embedded-nrf24l01?branch=wip)" = "<none>"
483
-"checksum epd-waveshare 0.4.0 (git+https://github.com/mgottschlag/epd-waveshare.git?branch=streaming)" = "<none>"
483
+"checksum epd-waveshare 0.4.0 (git+https://github.com/mgottschlag/epd-waveshare?branch=wip)" = "<none>"
484 484
 "checksum freetype-rs 0.24.0 (registry+https://github.com/rust-lang/crates.io-index)" = "340519227cdc8f41c27b3840a02e32dac6102dc314aefe6189cfa355233c445f"
485 485
 "checksum freetype-sys 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d48ac0ce366dd47a115ec8e598d7c51b4a974fc52ded5e53a56b31f55f34f3ea"
486 486
 "checksum generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec"

+ 1
- 1
display/firmware/Cargo.toml Bestand weergeven

@@ -22,7 +22,7 @@ embedded-hal = "0.2.3"
22 22
 nb = "0.1.2"
23 23
 bme280 = { git = "https://github.com/mgottschlag/bme280-rs", branch = "destroy" }
24 24
 embedded-nrf24l01 = { git = "https://github.com/mgottschlag/embedded-nrf24l01", branch = "wip" }
25
-epd-waveshare = { git = "https://github.com/mgottschlag/epd-waveshare.git", branch = "streaming" }
25
+epd-waveshare = { git = "https://github.com/mgottschlag/epd-waveshare", branch = "wip" }
26 26
 tinygfx = { git = "https://github.com/mgottschlag/tinygfx" }
27 27
 protocol = { path = "../../common/rust-protocol" }
28 28
 

+ 27
- 5
display/firmware/src/display.rs Bestand weergeven

@@ -3,7 +3,7 @@ use core::fmt::Write;
3 3
 use embedded_hal::blocking::delay::DelayUs;
4 4
 use embedded_hal::digital::v2::OutputPin;
5 5
 use epd_waveshare::epd4in2::EPD4in2;
6
-use epd_waveshare::prelude::{DisplayStream, WaveshareDisplay};
6
+use epd_waveshare::prelude::{Color, DisplayStream, RefreshLUT, WaveshareDisplay};
7 7
 use mkl25z4_hal::time::CopyableMonoTimer;
8 8
 use tinygfx::color::BlackWhite::{self, Black, White};
9 9
 use tinygfx::image::{MonoBitmapImage, MonoImageData};
@@ -15,13 +15,20 @@ use super::pins::{
15 15
     DisplayBmeSpi, DisplayBusy, DisplayCs, DisplayDc, DisplayPins, DisplayPwr, DisplayRst,
16 16
 };
17 17
 
18
-pub struct DisplayState {
19
-    // TODO
18
+const FULL_REFRESH_INTERVAL: usize = 5;
19
+
20
+pub struct DisplayState {}
21
+
22
+impl DisplayState {
23
+    pub fn new() -> DisplayState {
24
+        DisplayState {}
25
+    }
20 26
 }
21 27
 
22 28
 pub struct Display {
23 29
     pwr: DisplayPwr,
24 30
     epd: EPD4in2<DisplayBmeSpi, DisplayCs, DisplayBusy, DisplayDc, DisplayRst>,
31
+    refresh_counter: usize,
25 32
 }
26 33
 
27 34
 impl Display {
@@ -40,7 +47,11 @@ impl Display {
40 47
         // Disable power again.
41 48
         pins.pwr.set_high().ok();
42 49
 
43
-        Display { pwr: pins.pwr, epd }
50
+        Display {
51
+            pwr: pins.pwr,
52
+            epd,
53
+            refresh_counter: 0,
54
+        }
44 55
     }
45 56
 
46 57
     pub fn update(
@@ -125,8 +136,19 @@ impl Display {
125 136
         });
126 137
         frame.mirror_x(true);
127 138
         frame.mirror_y(true);
128
-        //self.epd.set_background_color(Color::Black);
129 139
         let checkerboard = TinyGfxStream::new(frame);
140
+
141
+        // We perform a full update every FULL_REFRESH_INTERVAL frames.
142
+        // TODO: Proper background.
143
+        self.epd.set_background_color(Color::White);
144
+        if self.refresh_counter == 0 {
145
+            self.refresh_counter = FULL_REFRESH_INTERVAL - 1;
146
+            self.epd.set_lut(spi, Some(RefreshLUT::FULL)).unwrap();
147
+        } else {
148
+            self.refresh_counter -= 1;
149
+            self.epd.set_lut(spi, Some(RefreshLUT::QUICK)).unwrap();
150
+        }
151
+
130 152
         self.epd.update_frame_stream(spi, checkerboard).unwrap();
131 153
         self.epd.display_frame(spi).unwrap();
132 154
 

+ 1
- 3
display/firmware/src/main.rs Bestand weergeven

@@ -85,9 +85,7 @@ const APP: () = {
85 85
                 bathroom: None,
86 86
                 pressure: None,
87 87
             },
88
-            display_state: DisplayState{
89
-                // TODO
90
-            },
88
+            display_state: DisplayState::new(),
91 89
             display,
92 90
             display_bme_spi: Some(pins.display_bme_spi),
93 91
             bme_pins: Some(pins.bme),

Laden…
Annuleren
Opslaan