fix: move the display's initial code to the app#78
fix: move the display's initial code to the app#78CloudyPadmal merged 2 commits intofossasia:mainfrom
Conversation
Reviewer's GuideThis PR centralizes display initialization logic in the app by introducing waveform abstractions, extending the EPD driver interface, implementing a QuickLut for the UC8253 controller with init and LUT setup routines, and refactoring the Protocol class to manage tag IDs internally and streamline NFC operations. Class diagram for new waveform abstractions and EPD driver interfaceclassDiagram
class Lut {
+int cmd
+Uint8List data
}
class Waveform {
<<abstract>>
+String desc
+int pll
+List~Lut~ luts
}
class QuickLut {
+desc
+pll
+luts
}
class Driver {
<<abstract>>
+String driverName
+List~int~ transmissionLines
+int refresh
+int vcomLut
+int wwLut
+int bwLut
+int wbLut
+int bbLut
+int panelSetting
+int pllControl
+WaveformList waveforms
+Future<void> setlut(Protocol, Waveform)
+Future<void> init(Protocol)
}
class Uc8253 {
+refresh
+vcomLut
+wwLut
+bwLut
+wbLut
+bbLut
+panelSetting
+pllControl
+waveforms
+driverName
+transmissionLines
+setlut(Protocol, Waveform)
+init(Protocol)
}
QuickLut --|> Waveform
Uc8253 --|> Driver
WaveformList --> Waveform
Class diagram for relationships between Protocol and EPD driverclassDiagram
class Protocol {
+Epd epd
+Future<void> writeImage(Uint8List image)
}
class Epd {
+Driver controller
+List<Uint8List> extractEpaperColorFrames(Uint8List image)
}
class Driver {
<<abstract>>
+Future<void> init(Protocol p)
+Future<void> setlut(Protocol p, Waveform waveform)
+List<int> transmissionLines
+int refresh
}
Protocol --> Epd
Epd --> Driver
Driver <.. Protocol : uses
Protocol ..> Driver : calls init, setlut
Protocol ..> Epd : calls extractEpaperColorFrames
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey @kienvo - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `lib/util/epd/driver/uc8253.dart:11` </location>
<code_context>
// UC8253 commands/registers,
// define in the epaper display controller (UC8253) reference manual
class Uc8253 extends Driver {
@override
int get refresh => 0x12;
@override
+ int get vcomLut => 0x20;
+ @override
+ int get wwLut => 0x21;
+ @override
+ int get bwLut => 0x22;
+ @override
+ int get wbLut => 0x23;
+ @override
+ int get bbLut => 0x24;
+ @override
+ int get panelSetting => 0x00;
+ @override
+ int get pllControl => 0x30;
+ @override
+ WaveformList waveforms = [QuickLut()];
+ @override
get driverName => 'UC8253';
@override
List<int> get transmissionLines => [0x10, 0x13];
+
+ @override
+ Future<void> setlut(Protocol p, Waveform waveform) async {
+ await p.writeMsg(
+ Uint8List.fromList([p.fw.epdCmd, p.epd.controller.pllControl]));
</code_context>
<issue_to_address>
No error handling for protocol communication failures.
If writeMsg fails, setlut may throw and leave the device in an inconsistent state. Please add error handling or rollback logic to address partial updates.
</issue_to_address>
### Comment 2
<location> `lib/util/epd/driver/uc8253.dart:107` </location>
<code_context>
+ @override
+ int get pllControl => 0x30;
+ @override
+ WaveformList waveforms = [QuickLut()];
+ @override
get driverName => 'UC8253';
</code_context>
<issue_to_address>
waveforms is mutable but likely intended to be constant.
Consider declaring waveforms as final to prevent reassignment if it is meant to remain constant.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
@override
WaveformList waveforms = [QuickLut()];
=======
@override
final WaveformList waveforms = [QuickLut()];
>>>>>>> REPLACE
</suggested_fix>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| @override | ||
| String get desc => "Quick waveform for R_sense = 4R7 and PLL = 10Hz"; | ||
| @override | ||
| int get pll => 0x01; // 10Hz | ||
| @override | ||
| List<Lut> get luts => [ | ||
| Lut( | ||
| cmd: 0x20, | ||
| data: Uint8List.fromList([ | ||
| // lut_vcom_quick |
There was a problem hiding this comment.
suggestion (bug_risk): No error handling for protocol communication failures.
If writeMsg fails, setlut may throw and leave the device in an inconsistent state. Please add error handling or rollback logic to address partial updates.
| @override | ||
| WaveformList waveforms = [QuickLut()]; |
There was a problem hiding this comment.
suggestion: waveforms is mutable but likely intended to be constant.
Consider declaring waveforms as final to prevent reassignment if it is meant to remain constant.
| @override | |
| WaveformList waveforms = [QuickLut()]; | |
| @override | |
| final WaveformList waveforms = [QuickLut()]; |
| await p.writeMsg(Uint8List.fromList([p.fw.epdSend, 0xCF, 0x8D])); | ||
| // 480x240, LUTs from register | ||
| // await p.writeMsg(Uint8List.fromList([p.fw.epdSend, 0xEF, 0x8D])); | ||
| // await setlut(p, waveforms[0]); |
There was a problem hiding this comment.
Commented out code should usually not be committed. Is there a good reason to do it here?
There was a problem hiding this comment.
This PR depends on #70 and has already been explained there.
Vishveshwara
left a comment
There was a problem hiding this comment.
Looks good to me , please just remove any unacessary comments like code which was used for debugging.
Fixes #76
Summary by Sourcery
Abstract EPaper waveform handling and integrate it into the UC8253 driver, refactor the NFC Protocol to streamline tag communication, and relocate display initialization into the application to correct startup issues.
New Features:
WaveformandLut) and addQuickLutimplementation for the UC8253 driverinitandsetlutmethods inUc8253to manage panel initialization and LUT loadingBug Fixes:
Enhancements:
Protocolto storetagIdinternally and remove redundant tagId parameters from NFC operationsepd.controller.initbefore frame transmission