-
@DrAzzy your protoboard is awesome.
But for the "final" board I want it smaller and only modules on, that I really need.
But for testing this looking really good.just order 2 proto boards on Tindie (#31269)
-
-
-
-
-
-
-
-
Oh man - my ESP-12 is still on the way.
Today two of the ESP-12E arrived (they have some extra pins on the back side)
I think I can solder this also to the shim and tape the extra pins on the back.But one question of how do you stack this board...
I have only the Pico with pin headers - so I decided to remove the plastic parts of the headers
and push the shim directly below - so it is enough space left to stack everything onto breadboard.
But the ESP-12 shim has on the bottom side some space for 3x R and 1x C.
Are they really needed and what values should they have?Also I wonder how to solder the Bluetooth LE HM-10 Shim to Pico...?...
-
Thx @Gordon - this is working.
But I have now another problem...
After some tries to update the code it seems to hang.
Only unplug and replug again helps to flash new code.
But after some reconnects/replugs - the pico is dead :/
If I plug it into USB it only shows short red light, but did not appear in the device list.
On Reset+plugin - red + green light is on (no flashing like on firmware flash mode)Do you know, what this could be and how to solve it?
-
I have some trouble writing data to APA102 LED strip.
In my example I just do the same as the documentation said.
- 4 bytes of 0x00 as a start frame.
- For each LED, a brightness byte (0xE0 + value), a blue value byte, a green value byte, and a red value byte.
- (N/2)/8 bytes of 0xFF as an end frame, where N is the number of LEDs.
result is following source:
SPI2.setup({mosi:B15, sck:B13, baud:4000000}); var NumLEDs = 150; var leds = new Uint8Array(NumLEDs*4); function draw() { var millis = getTime(); var r = Math.random()*255; var g = Math.random()*255; var b = Math.random()*255; for (var pixel = 0; pixel < leds.length; pixel+=4) { leds[pixel+0] = 0xE0 | 5; leds[pixel+1] = b; leds[pixel+2] = g; leds[pixel+3] = r; } write_leds(leds, NumLEDs); } function write_leds(leds, numLeds) { var halfLed = numLed/16 + 1; // compute end frame length var maxIndex = numLed * 4; // maximum leds row index; var index; SPI2.write(0x00); SPI2.write(0x00); SPI2.write(0x00); SPI2.write(0x00); // LED Frame for (index = 0; index < maxIndex; index+=4) { SPI2.write(leds[index+0]); // global brigthness SPI2.write(leds[index+1]); // B SPI2.write(leds[index+2]); // G SPI2.write(leds[index+3]); // R } // for all leds // End Frame for (index = 0; index < halfLed; index++) { SPI2.write(0xFF); } // for end frame } // write_leds() function onInit() { setInterval(draw, 50); } onInit();
But it seems that the data I send is not the data I see.
Also if I change the pixel data to show only red pixels; there is always a kind of random colors to see :/Hope someone can help me here to fix the problem.
- 4 bytes of 0x00 as a start frame.
-
@Gordon I Just try to use your original source and only change the part of rewrite flip
g.flip = function() { ce.reset(); spi.write(0x2A,dc); spi.write(0,2,0,LCD_WIDTH+1); spi.write(0x2B,dc); spi.write(0,3,0,LCD_HEIGHT+2); spi.write(0x2C,dc); var lines = 16; // size of buffer to use for un-paletting var a = new Uint16Array(LCD_WIDTH*lines); for (var y=0;y<LCD_HEIGHT;y+=lines) { E.mapInPlace(new Uint8Array(g.buffer, y*LCD_WIDTH*bits/8, a.length), a, palette, bits); spi.write(a.buffer); } ce.set(); };
And voilà it works also :D
So the display only needs this magix offset for X+2 / Y+3.
Should I take a better picture, or is the pic above ok? Of course you can use. -
Hey @Loop - thx for the hint!!!
it works fine for me by adding this:leds.setRotation(0, true);
-
Hi all,
I have a short test LED-matrix (6x6)
It is arranged in zigzag order starting at top right going left down.06<05<04<03<02<01 07>08>09>10>11>12 18<17<16<15<14<13 19>20>21>22>23>24 30<29<28<27<26<25 31>32>33>34>35>36
How can I configure the Graphics to have correct coordinates?
This is my current source code:SPI2.setup({baud:3200000, mosi:B15}); var leds = Graphics.createArrayBuffer(6,6,24,{zigzag:true, color_order:'bgr'}); leds.flip = function() { SPI2.send4bit(leds.buffer, 0b0001, 0b0011); }; leds.clear(); // some text leds.setColor(0.1,0.1,0.1); leds.drawString("L",0,0); leds.flip();
My result is following:
.....X .....X .....X .....X ...XXX ......
But I expect this:
X..... X..... X..... X..... XXX... ......
-
here is my file to play with. I just add it to my local webserver and load it with require.
@Gordon Thx for your help, bringing this screen to life ;) -
Ok, don't know why, but when I modify the flip by add 2px to the X and 3px to the Y it works...
Line 11 + 13
exports.connectPaletted = function(palette, spi, dc, ce, rst, callback) { var bits; if (palette.length>16) bits=8; else if (palette.length>4) bits=4; else if (palette.length>2) bits=2; else bits=1; var g = Graphics.createArrayBuffer(LCD_WIDTH, LCD_HEIGHT, bits, { msb:true }); g.flip = function() { ce.reset(); spi.write(0x2A,dc); spi.write(2,2,2,LCD_WIDTH+1); spi.write(0x2B,dc); spi.write(3,3,3,LCD_HEIGHT+2); spi.write(0x2C,dc); var lines = 16; // size of buffer to use for un-paletting var a = new Uint16Array(LCD_WIDTH*lines); for (var y=0;y<LCD_HEIGHT;y+=lines) { E.mapInPlace(new Uint8Array(g.buffer, y*LCD_WIDTH*bits/8, a.length), a, palette, bits); spi.write(a.buffer); } ce.set(); }; init(spi, dc, ce, rst, callback); return g; };
-
-
Now it is much better, but still not as expected...
I have to do some extra effort to make this working.
I'm wondering that I have to do the range to width and height only up to 127 instead of 128.
But with 127 it works "better"var exports = {}; /* Copyright (c) 2015 Gordon Williams, Pur3 Ltd. See the file LICENSE for copying permission. Module for the ILI9163 LCD controller ,------------------. | ILI9163 128x128 | +-----------------´ | VCC | B15 | 3.3v | GND | B14 | GND | CS/CE | B13 | | RST | B10 | 3.3v | A0/DC | B1 | | SDA | A7 | | SCL | A6 | | LED | A5 | */ var LCD_WIDTH = 128; var LCD_HEIGHT = 128; function init(spi, dc, ce, rst, callback) { function cmd(c,d) { dc.reset(); spi.write(c, ce); if (d!==undefined) { dc.set(); spi.write(d, ce); } } if (rst) { digitalPulse(rst,0,10); } else { cmd(0x01); //ST7735_SWRESET: Software reset, 0 args, w/delay: 150 ms delay } setTimeout(function() { cmd(0x11); //ST7735_SLPOUT: Out of sleep mode, 0 args, w/delay: 500 ms delay setTimeout(function() { cmd(0xB1,[0x01,0x2C,0x2D]); //ST7735_FRMCTR1: Set Frame rate ctrl - normal mode, 3 args: (Rate = fosc/(1x2+40) * (LINE+2C+2D)) cmd(0xB2,[0x01,0x2C,0x2D]); //ST7735_FRMCTR2: Set Frame rate control - idle mode, 3 args: Rate = fosc/(1x2+40) * (LINE+2C+2D) cmd(0xB3,[0x01,0x2C,0x2D,0x01,0x2C,0x2D]); //ST7735_FRMCTR3: Set Frame rate ctrl - partial mode, 6 args: Dot inversion mode + Line inversion mode cmd(0xB4,0x07); // ST7735_INVCTR: Set Display inversion ctrl, 1 arg, no delay: No inversion cmd(0xC0,[0xA2,0x02,0x84]); //ST7735_PWCTR1: Set Power control, 3 args, no delay: init + -4.6V + AUTO mode cmd(0xC1,0xC5); //ST7735_PWCTR2: Set Power control, 1 arg, no delay: VGH25 = 2.4C VGSEL = -10 VGH = 3 * AVDD cmd(0xC2,[0x0A,0x00]); //ST7735_PWCTR3: Set Power control, 2 args, no delay: Opamp current small + Boost frequency cmd(0xC3,[0x8A,0x2A]); //ST7735_PWCTR4: Set Power control, 2 args, no delay: BCLK/2, Opamp current small & Medium low cmd(0xC4,[0x8A,0xEE]); //ST7735_PWCTR5: Set Power control, 2 args, no delay: cmd(0xC5,0x0E); //ST7735_VMCTR1: Set Power control, 1 arg, no delay: cmd(0x20,0x00); //ST7735_INVOFF: Don't invert display, no args, no delay cmd(0x36,0xC8); //ST7735_MADCTL: Set Memory access control (directions), 1 arg: row addr/col addr, bottom to top refresh cmd(0x3A,0x05); //ST7735_COLMOD: Set color mode, 1 arg, no delay: 16-bit color cmd(0x2A,[0x00,0x00,0x00,0x7F]); //ST7735_CASET: Set Column addr set, 4 args, no delay: XSTART = 0 + XEND = 127 cmd(0x2B,[0x00,0x00,0x00,0x7F]); //ST7735_RASET: Set Row addr set, 4 args, no delay: XSTART = 0 + XEND = 127 cmd(0xE0,[0x02,0x1c,0x07,0x12,0x37,0x32,0x29,0x2d,0x29,0x25,0x2B,0x39,0x00,0x01,0x03,0x10]); //ST7735_GMCTRP1: color and gamma correction cmd(0xE1,[0x03,0x1d,0x07,0x06,0x2E,0x2C,0x29,0x2D,0x2E,0x2E,0x37,0x3F,0x00,0x00,0x02,0x10]); //ST7735_GMCTRN1: color and gamma correction cmd(0x13); //ST7735_NORON: Set Normal display on, no args, w/delay: 10 ms delay cmd(0x29); //ST7735_DISPON: Set Main screen turn on, no args w/delay: 100 ms delay if (callback) callback(); },10); } ,100); } exports.connect = function(spi, dc, ce, rst, callback) { var g = Graphics.createCallback(LCD_WIDTH, LCD_HEIGHT, 16, { setPixel:function(x,y,c){ ce.reset(); spi.write(0x2A,dc); spi.write(0,x,0,x+1); spi.write(0x2B,dc); spi.write(0,y,0,y+1); spi.write(0x2C,dc); spi.write(c>>8,c); ce.set(); }, fillRect:function(x1,y1,x2,y2,c){ ce.reset(); spi.write(0x2A,dc); spi.write(0,x1,0,x2); spi.write(0x2B,dc); spi.write(0,y1,0,y2); spi.write(0x2C,dc); spi.write({data:String.fromCharCode(c>>8,c), count:(x2-x1+1)*(y2-y1+1)}); ce.set(); } }); init(spi, dc, ce, rst, callback); return g; }; exports.connectPaletted = function(palette, spi, dc, ce, rst, callback) { var bits; if (palette.length>16) bits=8; else if (palette.length>4) bits=4; else if (palette.length>2) bits=2; else bits=1; var g = Graphics.createArrayBuffer(LCD_WIDTH, LCD_HEIGHT, bits, { msb:true }); g.flip = function() { ce.reset(); spi.write(0x2A,dc); spi.write(0,0,0,LCD_WIDTH-1); spi.write(0x2B,dc); spi.write(0,0,0,LCD_HEIGHT-1); spi.write(0x2C,dc); var lines = 16; // size of buffer to use for un-paletting var a = new Uint16Array(LCD_WIDTH*lines); for (var y=0;y<LCD_HEIGHT;y+=lines) { E.mapInPlace(new Uint8Array(g.buffer, y*LCD_WIDTH*bits/8, a.length), a, palette, bits); spi.write(a.buffer); } ce.set(); }; init(spi, dc, ce, rst, callback); return g; }; B15.set();// VCC B14.reset(); // GND A5.set(); // Backlight On var colorPalette = new Uint16Array([0, 0xF80F, 0x001F, 0xFFFF]); var spi = new SPI(); spi.setup({mosi:A7 /* sda */, sck:A6 /* scl */}); var g = exports.connectPaletted(colorPalette, spi, B1 /* DC */, B13 /* CE */, B10 /* RST */, function() { g.clear(); //g.setRotation(2); g.setColor(3); g.drawString("Hello",0,0); g.setColor(1); g.setFontVector(20); g.drawString("Espruino",0,10); g.flip(); });
-
I also ordered one (~3.80 USD), but did not arrived yet.
-
I just figured out on my train drive, that I need
this code + this code + this code
I started to create the code, based on this defines as cmd blockBut good idea to add this later on to one LCD-display driver library.
Perhaps it is useful to see also this implementation as reference. -
I create a new thread for the ST7735...
It did not work out of the box, so I have to modify it. -
I try to port another driver library for this inexpensive 1.44" display
It uses the ST7735 driver - which is used by most of these cheap displays.
Currently I try to use first the new ILI9163 library from Gordon (Forum post)Here is what I get as initial state:
Try this as inline to play with commands...
This is what comes out of the box with the ILI9163 driver:
As you can see, the coordinates are not right now. Everything seems to be shifted...var exports = {}; /* Copyright (c) 2015 Gordon Williams, Pur3 Ltd. See the file LICENSE for copying permission. Module for the ILI9163 LCD controller ILI9163 128x128 | VCC | B15 | 3.3v | GND | B14 | GND | CS/CE | B13 | | RST | B10 | 3.3v | A0/DC | B1 | | SDA | A7 | | SCL | A6 | | LED | A5 | */ var LCD_WIDTH = 128; var LCD_HEIGHT = 128; function init(spi, dc, ce, rst, callback) { function cmd(c,d) { dc.reset(); spi.write(c, ce); if (d!==undefined) { dc.set(); spi.write(d, ce); } } if (rst) { digitalPulse(rst,0,10); } else { cmd(0x01); //Software reset } setTimeout(function() { cmd(0x11); //Exit Sleep setTimeout(function() { cmd(0x26, 0x04); //Set Default Gamma cmd(0xB1, [0x0e,0x10]); //Set Frame Rate cmd(0xC0, [0x08,0]); //Set VRH1[4:0] & VC[2:0] for VCI1 & GVDD cmd(0xC1, 0x05); //Set BT[2:0] for AVDD & VCL & VGH & VGL cmd(0xC5, [0x38,0x40]); //Set VMH[6:0] & VML[6:0] for VOMH & VCOML cmd(0x3a, 5); //Set Color Format, 5=16 bit,3=12 bit cmd(0x36, 0xc8); //RGB cmd(0x2A,[0,0,0,LCD_WIDTH]); //Set Column Address cmd(0x2B,[0,0,0,LCD_HEIGHT]); //Set Page Address cmd(0xB4, 0); // display inversion cmd(0xf2, 1); //Enable Gamma bit cmd(0xE0,[0x3f,0x22,0x20,0x30,0x29,0x0c,0x4e,0xb7,0x3c,0x19,0x22,0x1e,0x02,0x01,0x00]); cmd(0xE1,[0x00,0x1b,0x1f,0x0f,0x16,0x13,0x31,0x84,0x43,0x06,0x1d,0x21,0x3d,0x3e,0x3f]); cmd(0x29); // Display On cmd(0x2C); // reset frame ptr if (callback) callback(); },20); } ,100); } exports.connect = function(spi, dc, ce, rst, callback) { var g = Graphics.createCallback(LCD_WIDTH, LCD_HEIGHT, 16, { setPixel:function(x,y,c){ ce.reset(); spi.write(0x2A,dc); spi.write(0,x,0,x+1); spi.write(0x2B,dc); spi.write(0,y,0,y+1); spi.write(0x2C,dc); spi.write(c>>8,c); ce.set(); }, fillRect:function(x1,y1,x2,y2,c){ ce.reset(); spi.write(0x2A,dc); spi.write(0,x1,0,x2); spi.write(0x2B,dc); spi.write(0,y1,0,y2); spi.write(0x2C,dc); spi.write({data:String.fromCharCode(c>>8,c), count:(x2-x1+1)*(y2-y1+1)}); ce.set(); } }); init(spi, dc, ce, rst, callback); return g; }; exports.connectPaletted = function(palette, spi, dc, ce, rst, callback) { var bits; if (palette.length>16) bits=8; else if (palette.length>4) bits=4; else if (palette.length>2) bits=2; else bits=1; var g = Graphics.createArrayBuffer(LCD_WIDTH, LCD_HEIGHT, bits, { msb:true }); g.flip = function() { ce.reset(); spi.write(0x2A,dc); spi.write(0,0,0,LCD_WIDTH); spi.write(0x2B,dc); spi.write(0,0,0,LCD_HEIGHT); spi.write(0x2C,dc); var lines = 16; // size of buffer to use for un-paletting var a = new Uint16Array(LCD_WIDTH*lines); for (var y=0;y<LCD_HEIGHT;y+=lines) { E.mapInPlace(new Uint8Array(g.buffer, y*LCD_WIDTH*bits/8, a.length), a, palette, bits); spi.write(a.buffer); } ce.set(); }; init(spi, dc, ce, rst, callback); return g; }; /* using library */ B15.set();// VCC B14.reset(); // GND A5.set(); // Backlight On var colorPalette = new Uint16Array([0, 0xF80F, 0x001F, 0xFFFF]); var spi = new SPI(); spi.setup({mosi:A7 /* sda */, sck:A6 /* scl */}); var g = exports.connectPaletted(colorPalette, spi, B1 /* DC */, B13 /* CE */, B10 /* RST */, function() { g.clear(); //g.setRotation(2); g.setColor(3); g.drawString("Hello",0,0); g.setColor(1); g.setFontVector(20); g.drawString("Espruino",0,10); g.flip(); });
I will start working on this tomorrow - my son is getting his third tooth, so everything is grumpy today :/
Thanks to @Gordon, I'll try add these commands tomorrow -
-
Thanks @Gordon!
I will try this today - never thought it could be so simple.
I really love your work and playing with Javascript is so awesome ;)
Thx @DrAzzy - looking forward to play with the boards