-
Thanks - looks good! Shame about the constants though - must have
taken you ages to inline them, and it's something that the minifier
would have done for you just by changing prototype.C to var C :)Javascript IDE Atom to the rescue :-)
in the end private constants wouldn't help module users, e.g. for using display.sendCommand(...), but the documentation helps module maintainers (well i hope so)Super minor, but it looks like bitMaskArray and pixelBitPosArray are
no longer needed now?good catch, i already changed that locally
A pull request via Espruino's GitHub is still definitely the preferred
wayok, but it is definitely worthwile to think about NPM, at least for maintaining a module (test, versioning, own github repo, ...)
-
@Gordon we can now use modules from NPM, what is the preferred way to release and provide modules, NPM or Espruino webpage?
-
-
here is the code provided as module, after some tests with the 3-wire SPI mode i will write the module.md documentation and create a pull request
major changes
- uses Graphics.createArrayBuffer, without the need for an extra
buffer - reduced footprint with removing all COMMAND constants, to
help users, all commands are written into function documentation -
which afaik is not part of the minified module version - shortened function names for those functions a user should not need for normal usage
- uses Graphics.createArrayBuffer, without the need for an extra
-
I'm not really sure what the plan is with cmd: new Uint8Array?
to change from
this.scd(this.C.CMD_SOMETHING, 0x00);
to
this.scd(this.C.cmd[5], 0x00);
thanks for the hints, i will implement them
Graphics Instance
The (hardware) display buffer needs 3096 bytes, where each byte represents 4 pixels, first pixel to the left. I already refactored the old code to use bitoperations (with bitmasks) instead of working with Strings.(obviously you did not see the old code) It is faster and right now the most time is used for the (hardware) display refresh itself.Is that possible with the arraybuffer Graphics instance? I will try it at home, last time it did not work for me.
ps: afaik the Graphics instance would work with an Array with size 12384 (172*72) which is 4 times larger than my version with size 3096 and i guess it would send 12384 bytes instead of 3096?
-
i thought to be clear about the attached javascript in the first post, it is not a proper module, just an example which one can use to start, right now i am working on a code version which is more in line with a real module coding-style
For the sake of brevity - it looks like there are quite a few
constants that are not used!i started with porting the complete SSD1606 diver specification, which provides a lot more than just displaying some values
You could also shorten - COMMAND_xx to say C_xxx.
for a proper module i thought of using
/** * ...doc for each command */ SSD1606.prototype.C = { cmd: new Uint8Array([ 0x01, 0x02 // ... and so on ]); };
is that ok?
as a newbie i am not aware of e.g.
Best thing is to make GDE021A1.prototype.C into just var C
i started with http://www.espruino.com/Writing+Modules and will - when it's functional - apply http://www.espruino.com/Performance
Are there more places to get hints on best practices for programming Espruino?
-
-
for some projects i use a GDE021A1 e-paper display like this one: http://smart-prototyping.com/NOA-Labs/E-ink-E-paper-new-version-display-module-3.3V-2.04-inch-177x72.html
the provided resources - display specification, display driver specification and some arduino example code are really good, combined with the Espruino documentation i was able to get it running fast
i attached the javascript for anyone who wants a quick start
-
right now i need to write the following to create a working SPI object
var spi = new SPI(); // or SPI1, 2,3 spi.setup(options);
i would like to be able to use
var spi = new SPI().setup(options); // or even better var spi = new SPI(options);
maybe there is some downside to my approach, i would like to know it :-)
-
-
While porting some Arduino C code to an Espruino module i stumbled over
SPI.begin() Description
Initializes the SPI bus by setting SCK, MOSI, and SS to outputs,
pulling SCK and MOSI low, and SS high.as far as i understand the Espruino reference for SPI the first part
Initializes the SPI bus by setting SCK, MOSI, and SS to outputs,
is (in part) handled by SPI.setup() e.g.
SPI3.setup({mosi:B5,miso:B4,sck:B3,mode:3});
for the second part
pulling SCK and MOSI low, and SS high.
i am clueless
- is there something similar for Espruino?
- If yes, where - maybe hidden from user - ?
- If yes, where - maybe hidden from user - ?
- Is that even needed?
- is there something similar for Espruino?
-
-
thx for the help
i did read about the clock problem, my idea is to use GPS or DCF77
-
i am an absolute beginner (and even worse with an enterprise programmer background) and thankful for every hint and critic :-)
for my version of a word clock i am trying to use an e-paper display with an espruino pico
the display is this one: http://smart-prototyping.com/NOA-Labs/E-ink-E-paper-new-version-display-module-3.3V-2.04-inch-177x72.html
so far i have the components and i am on my way to migrate (luckily provided from manufacturer, some quite complicated command sequences) the arduino code to espruino
the final goal is to run from battery, for this i would be thankful if someone can answer my questions
my take on power consumption
- assuming 2s operating time every 5 minutes (its a word clock, update every 5 minutes is enough for me), 24s per hour
- Pico deep sleep needs 0,02mA/h
- Pico operating needs 32mA/h
- Display operating needs 8mA/h (but it is an e-paper, power is only needed to update the display, content stays after that)
Pico current draw in mA/h = 0,23 mA/h = (0,02mA/h:3600s*(3600s-24s)) + (32mA/h:3600s*24s)
Display current draw in mA/h = 0,053 mA/h = 8mA/h:3600s*24s
final power consumption ~ 0,29 mA/h- assuming 1900mA/h from 2x AA eneloops (2.4v)
- according to the specification the display works from 1.9v - 3.3v
- according to the specification the display works from 1.9v - 3.3v
operating time ~ 0,76 years = (1900mA/H:0,286533333 mA/h:24h:365d)
i know that is just a theoretical value, voltage drop will probably happen earlier
Questions
- Is my take on the power consumption correct?
- Are 2.4v enough to drive the pico?
- Is it possible to control the VBAT Pin to only activate at designated timer?
- So far i think i need a transistor, but maybe it is possible without an extra component.
- Are there alternatives to my approach? (can a GPIO pin drive the display? i am not sure about the current draw)
- So far i think i need a transistor, but maybe it is possible without an extra component.
updated
- was 2s operating time per hour, but should be (60min/5min)*2s=24s
- assuming 2s operating time every 5 minutes (its a word clock, update every 5 minutes is enough for me), 24s per hour
-
-
you can test it out by yourself, save the module js https://github.com/espruino/EspruinoDocs/blob/master/devices/ESP8266WiFi_0v25.js in your WebIDE project/modules folder, rename it (e.g. My_ESP8266WiFi_0v25.js) and use that in your code with
require("My_ESP8266WiFi_0v25");
if that works, start hacking away and change the used timeout
@Gordon it might be a good move to futureproofness (does that word even exist?) in adding some timeout argument to the modules methods (with 1000 as default), it really looks like the ESP8266 is a lottery
@Ollie can you test the power with a multimeter, as far as i remember with my breadboard power supply thingie (connected to wall power supply) i got enough to even work without capacitor
-
at first, i am just so happy it finally works, had some problems with an apparently faulty esp8266
after that bad start i ordered some esp8266 esp-01 from eBay, by especially searching for "...tested..." and i got one with the following firmware:
"AT+GMR\r\r\nAT version:0.50.0.0(Sep 18 2015 20:55:38)\r\nSDK version:1.4.0\r\nTested in UK by AudioSpectrumAnalyzers\r\nOK\r\n"
well to get it working with an Espruino Pico i needed to change the ESP8266_v025 module in one little detail
from
if (d=="ready")
to
if (d=="Ready.")
here is a larger part to see the change in context
"reset" : function(callback) { at.cmd("\r\nAT+RST\r\n", 10000, function cb(d) { //console.log(">>>>>"+JSON.stringify(d)); // if (d=="ready")... if (d=="Ready.") setTimeout(function() { wifiFuncs.init(callback); }, 1000); else if (d===undefined) callback("No 'ready' after AT+RST"); else return cb; }); },
ok now to my question, do we want a special ESP8266_v50 module? if yes i will create the issue and pull-request including an update to the documentation
but i would like to know, what is your preferred way to handle the (in this case a lot) duplicate code?
-
for the SSL problem i would go with a custom central station like http://computers.tutsplus.com/tutorials/building-a-wireless-sensor-network-in-your-home--cms-19745
-
you could try using the ESP8266 without calling the reset function
that's in the example code?under the hood, the ESP8266 module uses reset a lot
and haven't been able to connect to anything by trying to talk to it
directly with AT commandsthat might be a problem with the pins (CH_PD needs 3.3v too) or not enough power, i had some strange behaviour while using the esp8266 directly with an espruino pico, powered by laptop usb, with one of those breadboard power supply thingies and 100uF it works reliable
-
i have the same problem, my findings so far:
- seems to be a faulty flash chip
- does not interfere with the function of the ESP8266
- try it out, with AT commands i can join a network etc.
- try it out, with AT commands i can join a network etc.
- does not work with the current Espruino ESP8266 module
- i tried to flash another firmware, no success so far
.. in the end i gave up for now and ordered some ESP8266 ESP-01 from ebay, look for "tested", i am still waiting for them to arrive
- seems to be a faulty flash chip
-
-
i am working with dates and got some confusing behaviour
i expected to be able to create a new
Date
with the valuefrom getTime()
getTime() returns a floating point number, but with rounding
Math.round(getTime());
the result does not changeIs there some error in my code or my expectations, maybe some misinterpretation of the docs on my side?