|
| 1 | +import 'package:flutter/foundation.dart'; |
| 2 | +import 'package:magic_epaper_app/util/epd/driver/waveform.dart'; |
| 3 | +import 'package:magic_epaper_app/util/protocol.dart'; |
1 | 4 | import 'driver.dart'; |
2 | 5 |
|
| 6 | +class QuickLut extends Waveform { |
| 7 | + static const int GND = 0; |
| 8 | + static const int VSH = 0x40; |
| 9 | + static const int VSL = 0x80; |
| 10 | + static const int VDHR = 0x60; |
| 11 | + @override |
| 12 | + String get desc => "Quick waveform for R_sense = 4R7 and PLL = 10Hz"; |
| 13 | + @override |
| 14 | + int get pll => 0x01; // 10Hz |
| 15 | + @override |
| 16 | + List<Lut> get luts => [ |
| 17 | + Lut( |
| 18 | + cmd: 0x20, |
| 19 | + data: Uint8List.fromList([ |
| 20 | + // lut_vcom_quick |
| 21 | + 0x01, 0x00, 10, 0x00, 0x00, 0x01, 0x00, |
| 22 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 23 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 24 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 25 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 26 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 27 | + |
| 28 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 29 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 30 | + ])), |
| 31 | + Lut( |
| 32 | + cmd: 0x21, |
| 33 | + data: Uint8List.fromList([ |
| 34 | + // lut_ww_quick |
| 35 | + 0x01, VSL | 10, 0x00, 0x00, 0x00, 0x01, 0x00, |
| 36 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 37 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 38 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 39 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 40 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 41 | + ])), |
| 42 | + Lut( |
| 43 | + cmd: 0x22, |
| 44 | + data: Uint8List.fromList([ |
| 45 | + // lut_r_quick |
| 46 | + 0x01, VSL | 10, 0x00, 0x00, 0x00, 0x01, 0x00, |
| 47 | + 0x01, 10, 0x00, 0x00, 0x00, 0x01, 0x00, |
| 48 | + 0x01, VSH | 10, 5, 0x00, 0x00, 0x02, 0x00, |
| 49 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 50 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 51 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 52 | + |
| 53 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 54 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 55 | + ])), |
| 56 | + Lut( |
| 57 | + cmd: 0x23, |
| 58 | + data: Uint8List.fromList([ |
| 59 | + // lut_w_quick |
| 60 | + 0x01, 10, 0x00, 0x00, 0x00, 0x01, 0x00, |
| 61 | + 0x01, 10, 0x00, 0x00, 0x00, 0x01, 0x00, |
| 62 | + 0x01, 10, 0x00, 0x00, 0x00, 0x01, 0x00, |
| 63 | + 0x00, VSH | 2, 0x00, 0x00, 0x00, 0x01, 0x00, |
| 64 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 65 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 66 | + |
| 67 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 68 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 69 | + ])), |
| 70 | + Lut( |
| 71 | + cmd: 0x24, |
| 72 | + data: Uint8List.fromList([ |
| 73 | + // lut_b_quick |
| 74 | + 0x01, 10, 0x00, 0x00, 0x00, 0x01, 0x00, |
| 75 | + 0x01, VSH | 12, 0x00, 0x00, 0x00, 0x01, 0x00, |
| 76 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 77 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 78 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 79 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 80 | + |
| 81 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 82 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 83 | + ])), |
| 84 | + ]; |
| 85 | +} |
| 86 | + |
3 | 87 | // UC8253 commands/registers, |
4 | 88 | // define in the epaper display controller (UC8253) reference manual |
5 | 89 | class Uc8253 extends Driver { |
6 | 90 | @override |
7 | 91 | int get refresh => 0x12; |
8 | 92 | @override |
| 93 | + int get vcomLut => 0x20; |
| 94 | + @override |
| 95 | + int get wwLut => 0x21; |
| 96 | + @override |
| 97 | + int get bwLut => 0x22; |
| 98 | + @override |
| 99 | + int get wbLut => 0x23; |
| 100 | + @override |
| 101 | + int get bbLut => 0x24; |
| 102 | + @override |
| 103 | + int get panelSetting => 0x00; |
| 104 | + @override |
| 105 | + int get pllControl => 0x30; |
| 106 | + @override |
| 107 | + WaveformList waveforms = [QuickLut()]; |
| 108 | + @override |
9 | 109 | get driverName => 'UC8253'; |
10 | 110 | @override |
11 | 111 | List<int> get transmissionLines => [0x10, 0x13]; |
| 112 | + |
| 113 | + @override |
| 114 | + Future<void> setlut(Protocol p, Waveform waveform) async { |
| 115 | + await p.writeMsg( |
| 116 | + Uint8List.fromList([p.fw.epdCmd, p.epd.controller.pllControl])); |
| 117 | + await p.writeMsg(Uint8List.fromList([p.fw.epdSend, waveform.pll])); // 10hz |
| 118 | + |
| 119 | + for (var lut in waveform.luts) { |
| 120 | + await p.writeMsg(Uint8List.fromList([p.fw.epdCmd, lut.cmd])); |
| 121 | + await p.writeMsg(Uint8List.fromList([p.fw.epdSend, ...lut.data])); |
| 122 | + } |
| 123 | + } |
| 124 | + |
| 125 | + @override |
| 126 | + Future<void> init(Protocol p) async { |
| 127 | + // power on |
| 128 | + // FIXME: this command require polling the busy state but currently there is no way to do this in the app |
| 129 | + await p.writeMsg(Uint8List.fromList([p.fw.epdCmd, 0x04])); |
| 130 | + |
| 131 | + // VCOM_AND_DATA_INTERVAL_SETTING |
| 132 | + await p.writeMsg(Uint8List.fromList([p.fw.epdCmd, 0x50])); |
| 133 | + await p.writeMsg(Uint8List.fromList([p.fw.epdSend, 0xff, 0x0f])); |
| 134 | + |
| 135 | + await p.writeMsg(Uint8List.fromList([p.fw.epdCmd, panelSetting])); |
| 136 | + // 480x240, built-in LUTs |
| 137 | + await p.writeMsg(Uint8List.fromList([p.fw.epdSend, 0xCF, 0x8D])); |
| 138 | + // 480x240, LUTs from register |
| 139 | + // await p.writeMsg(Uint8List.fromList([p.fw.epdSend, 0xEF, 0x8D])); |
| 140 | + // await setlut(p, waveforms[0]); |
| 141 | + } |
12 | 142 | } |
0 commit comments