Skip to content

Bug in LCDPattern #63

@jhbruhn

Description

@jhbruhn

There seems to be a bug in the LCDPattern implementation. When using the draw_line method (and possibly others), the Pattern is drawn with random data (changes for example on button inputs) instead of the selected pattern (in my case a checkerboard for grayscale).

This was only tested on the simulator though, as I don't have real hardware yet!

Here is an example. The leftmost line should have every second pixel on, but it's actually even more (and changes in more complex programs). The second line is supposed to be solid.

#![no_std]

extern crate alloc;

use {
    alloc::boxed::Box,
    anyhow::Error,
    crankstart::{
        crankstart_game,
        graphics::{Graphics, LCDColor, LCDSolidColor},
        system::System,
        Game, Playdate,
    },
    crankstart_sys::{LCDPattern},
    euclid::{point2},
};

const GRAY_PATTERN: LCDPattern = [0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff];

struct State {
}

impl State {
    pub fn new(_playdate: &Playdate) -> Result<Box<Self>, Error> {
        crankstart::display::Display::get().set_refresh_rate(20.0)?;
        Ok(Box::new(Self {
        }))
    }
}

impl Game for State {
    fn update(&mut self, _playdate: &mut Playdate) -> Result<(), Error> {
        let graphics = Graphics::get();
        graphics.clear(LCDColor::Solid(LCDSolidColor::kColorWhite))?;
        graphics.draw_line(point2(20, 0), point2(20, 200), 1, LCDColor::Pattern(GRAY_PATTERN));
        graphics.draw_line(point2(40, 200), point2(40, 0), 1, LCDColor::Solid(LCDSolidColor::kColorBlack));

        System::get().draw_fps(0, 0)?;

        Ok(())
    }
}

crankstart_game!(State);

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions