You are reading a single comment by @Wilberforce and its replies. Click here to read the full conversation.
  • @Gordon
    There are a few things going on in this thread!

    I'm still a bit confused here - does the existing DS18B20 library not work with ESP8266? My understanding was just that the current one was fine, but it just returned the previous reading (which means the first one returns 85 or something like that).

    a. Yes - the code works on the ESP8266

    b. Add support ds18s20 as well as ds18s20

    @hygyI modifed this code originally, cause the original is does not work with ds18s20 just with 18b20.

    c. Callback

    @gordon The code above waits 1 second for the callback - seems pretty extreme? I doubt many people would be happy with that.

    The time it takes for a conversion depends on the resolution and if parasitic mode mode is in use.
    http://forum.espruino.com/comments/12612­450/
    The modified code #21 http://forum.espruino.com/comments/12729­356/ takes the resolution into account so, the callback is no longer 1 sec, but depends on the resolution

    d. One of the issues with the original code is that the initial reading is bogus. The device returns all 111111's, and this turns out to be a value of 85c. For the next call, the real value is in place as the conversion is done. There is no way of knowing if this is a 'real' 85c or the bogus first value

    One solution would be to return undefined until the first conversion is done.
    Another, the constructor could be modified to starts a conversion, so that by the time the first call is made to getTemp, however this could not be guaranteed.

    e. The original code has function getTemp(verify) - Gets the temperature reading.
    the proposed code has function(callback,verify)

    So existing code that use getTemp with verify used would fails as the first param is now a callback.
    I have not idea how widespread this usage is, however I believe the getTemp should work for older code without having to change params.

    f. versioning
    The git hash is a good idea, although the .js and .min.js would have different hash, even though they are a 'pair'. If the .js source had a hash comment, at least local projects and SD card modules would have the version details in them.
    The idea of the x.y notation like used in node is that if a function signature changes (like e above), the major number x would be incremented to indicate. However without package.json this would not be of much benefit ;-(

About

Avatar for Wilberforce @Wilberforce started