Procházet zdrojové kódy

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

Mathias Gottschlag před 5 roky
rodič
revize
b82214e974

+ 3
- 3
display/firmware/Cargo.lock Zobrazit soubor

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

+ 1
- 1
display/firmware/Cargo.toml Zobrazit soubor

22
 nb = "0.1.2"
22
 nb = "0.1.2"
23
 bme280 = { git = "https://github.com/mgottschlag/bme280-rs", branch = "destroy" }
23
 bme280 = { git = "https://github.com/mgottschlag/bme280-rs", branch = "destroy" }
24
 embedded-nrf24l01 = { git = "https://github.com/mgottschlag/embedded-nrf24l01", branch = "wip" }
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
 tinygfx = { git = "https://github.com/mgottschlag/tinygfx" }
26
 tinygfx = { git = "https://github.com/mgottschlag/tinygfx" }
27
 protocol = { path = "../../common/rust-protocol" }
27
 protocol = { path = "../../common/rust-protocol" }
28
 
28
 

+ 27
- 5
display/firmware/src/display.rs Zobrazit soubor

3
 use embedded_hal::blocking::delay::DelayUs;
3
 use embedded_hal::blocking::delay::DelayUs;
4
 use embedded_hal::digital::v2::OutputPin;
4
 use embedded_hal::digital::v2::OutputPin;
5
 use epd_waveshare::epd4in2::EPD4in2;
5
 use epd_waveshare::epd4in2::EPD4in2;
6
-use epd_waveshare::prelude::{DisplayStream, WaveshareDisplay};
6
+use epd_waveshare::prelude::{Color, DisplayStream, RefreshLUT, WaveshareDisplay};
7
 use mkl25z4_hal::time::CopyableMonoTimer;
7
 use mkl25z4_hal::time::CopyableMonoTimer;
8
 use tinygfx::color::BlackWhite::{self, Black, White};
8
 use tinygfx::color::BlackWhite::{self, Black, White};
9
 use tinygfx::image::{MonoBitmapImage, MonoImageData};
9
 use tinygfx::image::{MonoBitmapImage, MonoImageData};
15
     DisplayBmeSpi, DisplayBusy, DisplayCs, DisplayDc, DisplayPins, DisplayPwr, DisplayRst,
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
 pub struct Display {
28
 pub struct Display {
23
     pwr: DisplayPwr,
29
     pwr: DisplayPwr,
24
     epd: EPD4in2<DisplayBmeSpi, DisplayCs, DisplayBusy, DisplayDc, DisplayRst>,
30
     epd: EPD4in2<DisplayBmeSpi, DisplayCs, DisplayBusy, DisplayDc, DisplayRst>,
31
+    refresh_counter: usize,
25
 }
32
 }
26
 
33
 
27
 impl Display {
34
 impl Display {
40
         // Disable power again.
47
         // Disable power again.
41
         pins.pwr.set_high().ok();
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
     pub fn update(
57
     pub fn update(
125
         });
136
         });
126
         frame.mirror_x(true);
137
         frame.mirror_x(true);
127
         frame.mirror_y(true);
138
         frame.mirror_y(true);
128
-        //self.epd.set_background_color(Color::Black);
129
         let checkerboard = TinyGfxStream::new(frame);
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
         self.epd.update_frame_stream(spi, checkerboard).unwrap();
152
         self.epd.update_frame_stream(spi, checkerboard).unwrap();
131
         self.epd.display_frame(spi).unwrap();
153
         self.epd.display_frame(spi).unwrap();
132
 
154
 

+ 1
- 3
display/firmware/src/main.rs Zobrazit soubor

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

Loading…
Zrušit
Uložit