Skip to content

Instantly share code, notes, and snippets.

@MaBecker
Created February 11, 2019 18:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MaBecker/4c29a1d56a922dc01a23f7b4e1326b7c to your computer and use it in GitHub Desktop.
Save MaBecker/4c29a1d56a922dc01a23f7b4e1326b7c to your computer and use it in GitHub Desktop.
Espruinino: Test module SH1106 on ESP8266
// oled_sh1106.js
SDA = D5;
SCL = D4;
var esp = require('ESP8266');
esp.logDebug(false);
esp.setLog(0);
var g;
function draw() {
g.setFontVector(25);
g.drawString("Espruino",0,0);
g.drawString("Rocks!",0,32);
g.flip();
}
function onInit(){
I2C1.setup({sda:SDA,scl:SCL, bitrate:4000000});
// no optimization and module uploaded as function
g = require("SH1106").connect(I2C1, draw);
// use module from flash
//g = require("SH1106S").connect(I2C1, function(){});
}
setTimeout(save,1E3);
/*
* no optimization
process.memory();
={ free: 1267, usage: 333, total: 1600, history: 170,
gc: 0, gctime: 1.862 }
* module uploaded as function
process.memory()
={ free: 1265, usage: 335, total: 1600, history: 170,
gc: 0, gctime: 1.862 }
* use module from flash
>process.memory()
={ free: 1357, usage: 243, total: 1600, history: 60,
gc: 0, gctime: 1.874 }
* freeHeap is for all cases 11736
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment