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

SPI data/command pin argument #235

Closed
gfwilliams opened this issue Feb 12, 2014 · 2 comments
Closed

SPI data/command pin argument #235

gfwilliams opened this issue Feb 12, 2014 · 2 comments

Comments

@gfwilliams
Copy link
Member

Many SPI LCDs have a D/C (data/command) pin, and expect command + data pairs of bytes. It'd make a massive amount of sense to allow:

SPI.send([...],cs_pin,dc_pin)

where the 9th bit of the supplied data was the value of the DC pin for that byte.

@gfwilliams
Copy link
Member Author

It might make more sense to include it in SPI.setup instead.

Code for the ILI9341 could then look like:

SPI.setup({ ... nbit9 : dc });


  var LCD = Graphics.createCallback(LCD_WIDTH, LCD_HEIGHT, 16, {
    setPixel:function(x,y,c){
      spi.write(0x12A,[x>>8,x,(x+1)>>8,x+1],
                    0x12B,[y>>8,y,(y+1)>>8,y+1],
                    0x12C,[c>>8,c], ce);
    },
 ...

instead of:

  function writeCD(c,d){
    dc.write(0);
    ce.write(0);
    spi.send(c);
    dc.write(1);
    spi.send(d);
    ce.write(1);
  }

  var LCD = Graphics.createCallback(LCD_WIDTH, LCD_HEIGHT, 16, {
    setPixel:function(x,y,c){
      writeCD(0x2A,[x>>8,x,(x+1)>>8,x+1]);
      writeCD(0x2B,[y>>8,y,(y+1)>>8,y+1]);
      writeCD(0x2C,[c>>8,c]);
    },
 ...

@gfwilliams
Copy link
Member Author

gfwilliams commented Jun 8, 2017

edit: misunderstood this one.

Still closing though - I think this is overkill for most things, and the gfx speed issues could probably be solved another way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant