Manages the 1-wire bus
Dependents: oldheating heating
web/web-1wire-class.js@9:6f663ad53c7e, 2020-06-10 (annotated)
- Committer:
- andrewboyson
- Date:
- Wed Jun 10 11:41:03 2020 +0000
- Revision:
- 9:6f663ad53c7e
- Parent:
- 8:ceafef18cbf7
- Child:
- 11:3859fee99d5d
Changed javascript OneWire class so that DS18B20 values are read as signed 16bit numbers then printed eg OneWire.DS18B20ToString(Ajax.hexToSignedInt16(value))
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
andrewboyson | 1:c272b1fcc834 | 1 | //OneWire script |
andrewboyson | 1:c272b1fcc834 | 2 | 'use strict'; |
andrewboyson | 1:c272b1fcc834 | 3 | |
andrewboyson | 1:c272b1fcc834 | 4 | class OneWire |
andrewboyson | 1:c272b1fcc834 | 5 | { |
andrewboyson | 9:6f663ad53c7e | 6 | static DS18B20ToString(value) |
andrewboyson | 1:c272b1fcc834 | 7 | { |
andrewboyson | 9:6f663ad53c7e | 8 | switch (value) |
andrewboyson | 1:c272b1fcc834 | 9 | { |
andrewboyson | 9:6f663ad53c7e | 10 | case 0x7FFF: return 'CRC error' ; |
andrewboyson | 9:6f663ad53c7e | 11 | case 0x7FFE: return 'ROM not found' ; |
andrewboyson | 9:6f663ad53c7e | 12 | case 0x7FFD: return 'Timed out' ; |
andrewboyson | 9:6f663ad53c7e | 13 | case 0x7FFC: return 'No device detected after reset'; |
andrewboyson | 9:6f663ad53c7e | 14 | case 0x7FFB: return 'Device removed during search' ; |
andrewboyson | 1:c272b1fcc834 | 15 | } |
andrewboyson | 9:6f663ad53c7e | 16 | return (value / 16.0).toFixed(1); |
andrewboyson | 1:c272b1fcc834 | 17 | } |
andrewboyson | 1:c272b1fcc834 | 18 | } |