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

Needs delays for fast processors #2

Open
vpatron opened this issue Oct 22, 2021 · 1 comment
Open

Needs delays for fast processors #2

vpatron opened this issue Oct 22, 2021 · 1 comment

Comments

@vpatron
Copy link
Contributor

vpatron commented Oct 22, 2021

Hi, this would not work with a Raspberry Pi Pico.

I found out it needs delays. I put sleep(0.000_072) after each SPI write because the datasheet says the commands can take up to 72 microseconds and it works fine now.

    def _write(self, cmd, data):
        self.cmd[0] = cmd
        self.cmd[1] = (data & 0xF0)
        self.cmd[2] = ((data << 4) & 0xF0)
        self.spi.write(self.cmd)
        sleep(0.000_072)   # Most st7920 commands need 72 us delay
    
    def init(self):
        if self.rst:
            self.rst(0)
            sleep(0.1)
            self.rst(1)
        for cmd in (ST7920_BASIC,
                    ST7920_CLEAR_SCREEN,
                    ST7920_DISPLAY_CTRL,
                    ST7920_EXTEND,
                    ST7920_EXTEND | 0x02):
            self._write(ST7920_CMD, cmd)
            sleep(0.000_072)
        self.show()

Thanks for posting this program. It's a good simple example and I found it very useful.

@Lepeshka92
Copy link
Owner

Thank you. I add delay to _write method

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

No branches or pull requests

2 participants