Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display Driver and Example for Waveshare 1.28 Round LCD #77

Merged
merged 23 commits into from
Aug 10, 2024

Conversation

GordonCox
Copy link
Contributor

Example project for the Waveshare 1.28 Round LCD Display. Renders simple graphics and displays a ticking second hand as a lock with the Rust logo as the background image.

GordonCox added 18 commits July 20, 2024 09:10
Added board wavershare-rp2040-lcs-1-28, added a driver for this board.
Set the backlight low (off) then clear the screen to black, initialize the screen, set the backlight high (on).  This prevents the unset memory as showing as static on the screen.
Use the V2::outputPin for the backlight.
Added two buffers so that I can swap between them and prevent screen flickering when updating the display.
Added comments and formmating.
Added arrow and window region updates.
Added Precomputation details on the arrow.
Added frame rate delay adjustment
Fixed a defect in the angle_index
Used one buffer for the background, one buffer for the LCD, copy data from background to LCD buffer before displaying the region on screen.
Clean up and simplify the code.
Background Image for the LCD Clock Display.
Removed the display driver and cleaned up the examples so they always use the frame buffer.
@9names
Copy link
Member

9names commented Jul 30, 2024

Hi!
Your example program is pretty cool but it's also quite complex - do you think you could have something simpler like the one for waveshare 0-96

Also easier if an example fits in a single file - framebuffer.rs looks like it's another example, not a module used by an example.

There's also already a handful of crates that support gc8a01a, is there something your driver does that more established crates like mipidsi don't?

@9names
Copy link
Member

9names commented Jul 30, 2024

Also this has some build warnings, and the use of static mut's for your framebuffer is a concern:

warning: crate-level attribute should be in the root module
 --> boards/waveshare-rp2040-lcd-1-28/examples/frame_buffer.rs:1:1
  |
1 | #![no_std]
  | ^^^^^^^^^^
  |
  = note: `#[warn(unused_attributes)]` on by default

warning: crate-level attribute should be in the root module
 --> boards/waveshare-rp2040-lcd-1-28/examples/frame_buffer.rs:2:1
  |
2 | #![no_main]
  | ^^^^^^^^^^^

warning: creating a mutable reference to mutable static is discouraged
   --> boards/waveshare-rp2040-lcd-1-28/examples/waveshare_rp2040_lcd_demo.rs:108:56
    |
108 |     let mut frame_buffer_1 = unsafe { FrameBuffer::new(&mut FRAME_BUFFER_1, LCD_WIDTH, LCD_HEIGHT) };
    |                                                        ^^^^^^^^^^^^^^^^^^^ mutable reference to mutable static
    |
    = note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447>
    = note: this will be a hard error in the 2024 edition
    = note: this mutable reference has lifetime `'static`, but if the static gets accessed (read or written) by any other means, or any other reference is created, then any further use of this mutable reference is Undefined Behavior
    = note: `#[warn(static_mut_refs)]` on by default
help: use `addr_of_mut!` instead to create a raw pointer
    |
108 |     let mut frame_buffer_1 = unsafe { FrameBuffer::new(addr_of_mut!(FRAME_BUFFER_1), LCD_WIDTH, LCD_HEIGHT) };
    |                                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@GordonCox
Copy link
Contributor Author

I can simplify the example. This specific example was created because the display is commonly used for watches so I made something that was also like a watch. I will remove the complexities from it.

I created this display driver as it is a closer match to the one provided by Waveshare for their Python and C examples. I wanted to explicitly show the configuration instructions of the display. I commented the display instructions from the chipset where possible. Some configuration instructions remain undocumented as Waveshare never provided details on them.

I will remove the framebuffer and simplify the example.

I am happy to make the changes as this is the first project I have made with Rust.

Simplified the example made it more like 0.96
@GordonCox
Copy link
Contributor Author

All comments have been considered and new code has been committed for your review.

Removed unused dependency
Moved Dependency to Workspace, updated backlight code.
@GordonCox
Copy link
Contributor Author

Are there any further outstanding issues, I updated the code so that the automatic checks would pass. I learned a lot with those automatic checks and have added some into my own projects.

@9names 9names merged commit 464a0a7 into rp-rs:main Aug 10, 2024
7 checks passed
pysen pushed a commit to pysen/rp-hal-boards that referenced this pull request Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants