For a project I'm working on I decided I'd like to use Espruino so I flashed it on an ESP8266.
I have a GME128128-02 1.5" OLED display that is powered by a SSD1327 that I'd like to use. For my purposes I don't need any grayscale usage, only monochrome and only I2C is relevant for this specific screen.
There doesn't seem to be a module for this specific screen model, and none of the ones I tried worked so I decided to try and modify the SSD1306 module. I've already looked at some Arduino/C libraries for the SSD1327 driver and had a peek at the datasheet but after some evenings experimenting I have to admit I'm quite stuck. When I flash the current code I have, I get a bunch of vertical lines for a few seconds, before the screen seemingly turns off.
I feel like I'm probably not too far off but perhaps anyone here can immediately spot my mistakes and help me out. Thank you in advance!
My code:
var exports={};
var C = {
OLED_WIDTH : 128,
OLED_CHAR : 0x40,//0x20,//0x40
OLED_CHUNK : 128
};
// commands sent when initialising the display
var initCmds = new Uint8Array([
0xAE, // 0 Display off (all pixels off)
0xA0, 0x53, // 1 Segment remap (com split, com remap, nibble remap, column remap)
0xA1, 0x00, // 3 Display start line
0xA2, 0x00, // 5 Display offset
0xA4, // 7 Regular display
0xA8, 0x7F, // 8 Set multiplex ratio: 127
// greyscale table?
//0xB8, 0x01, 0x11, // 10 Set greyscale table
//0x22, 0x32, 0x43, // .. cont
//0x54, 0x65, 0x76, // .. cont
0xB3, 0x00, // 19 Front clock divider: 0, Fosc: 0
0xAB, 0x01, // 21 Enable internal Vdd
0xB1, 0xF1, // 23 Set phase periods - 1: 1 clk, 2: 15 clks
0xBC, 0x08, // 25 Pre-charge voltage: Vcomh
0xBE, 0x07, // 27 COM deselect voltage level: 0.86 x Vcc
0xD5, 0x62, // 29 Enable 2nd pre-charge
0xB6, 0x0F, // 31 2nd Pre-charge period: 15 clks
0xA4, // 33 normal display
0xAF, // 34 display on
]);
// commands sent when sending data to the display
var flipCmds = [
0x15,//0x21, // columns
0, 127, //
0x75,//0x22, // rows
0, 31//127//15 /* (height>>3)-1 */
];
function update(options) {
}
exports.connect = function(i2c, callback, options) {
update(options);
var oled = Graphics.createArrayBuffer(128,128,4,{vertical_byte : false});
var addr = 0x3C;
if(options) {
if (options.address) addr = options.address;
// reset display if 'rst' is part of options
if (options.rst) digitalPulse(options.rst, 0, 10);
}
setTimeout(function() {
// configure the OLED
initCmds.forEach(function(d) {i2c.writeTo(addr, [0,d]);});
}, 50);
// if there is a callback, call it now(ish)
if (callback !== undefined) setTimeout(callback, 100);
// write to the screen
oled.flip = function() {
// set how the data is to be sent (whole screen)
flipCmds.forEach(function(d) {i2c.writeTo(addr, [0,d]);});
var chunk = new Uint8Array(C.OLED_CHUNK+1);
chunk[0] = C.OLED_CHAR;
for (var p=0; p<this.buffer.length; p+=C.OLED_CHUNK) {
chunk.set(new Uint8Array(this.buffer,p,C.OLED_CHUNK), 1);
i2c.writeTo(addr, chunk);
}
};
// set contrast, 0..255
oled.setContrast = function(c) { i2c.writeTo(addr, 0, 0x81, c); };
// set off
oled.off = function() { i2c.writeTo(addr, 0, 0xAE); };
// set on
oled.on = function() { i2c.writeTo(addr, 0, 0xAF); };
// return graphics
return oled;
};
function start(){
print("this runs");
g.on();
g.clear();
g.setContrast(128);
g.setColor(1);
// write some text
//g.setFontVector(20);
//g.drawString("Hello world!",0,0);
g.drawString("Hello world!",32,32);
g.fillRect(0, 0, 4, 4);
// write to the screen
g.flip();
}
// I2C
I2C1.setup({scl:D5,sda:D4,bitrate:100000});
var g = exports.connect(I2C1, start);
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Hey everyone!
For a project I'm working on I decided I'd like to use Espruino so I flashed it on an ESP8266.
I have a GME128128-02 1.5" OLED display that is powered by a SSD1327 that I'd like to use. For my purposes I don't need any grayscale usage, only monochrome and only I2C is relevant for this specific screen.
There doesn't seem to be a module for this specific screen model, and none of the ones I tried worked so I decided to try and modify the SSD1306 module. I've already looked at some Arduino/C libraries for the SSD1327 driver and had a peek at the datasheet but after some evenings experimenting I have to admit I'm quite stuck. When I flash the current code I have, I get a bunch of vertical lines for a few seconds, before the screen seemingly turns off.
I feel like I'm probably not too far off but perhaps anyone here can immediately spot my mistakes and help me out. Thank you in advance!
My code:
1 Attachment