Manages the 1-wire bus

Dependents:   oldheating heating

web/web-1wire-class.js

Committer:
andrewboyson
Date:
2021-02-18
Revision:
11:3859fee99d5d
Parent:
9:6f663ad53c7e

File content as of revision 11:3859fee99d5d:

//OneWire script
'use strict';

class OneWire
{
    static DS18B20ToString(value)
    {
        switch (value)
        {
            case 0x7FFF: return 'CRC error'                     ;
            case 0x7FFE: return 'ROM not found'                 ;
            case 0x7FFD: return 'Timed out'                     ;
            case 0x7FFC: return 'No device detected after reset';
            case 0x7FFB: return 'Device removed during search'  ;
            case 0x7FFA: return 'Value not set'                 ;
        }
        return (value / 16.0).toFixed(1);
    }
}