Manages the 1-wire bus
Dependents: oldheating heating
web/web-1wire-ajax.c@4:822208cb5a13, 2019-05-01 (annotated)
- Committer:
- andrewboyson
- Date:
- Wed May 01 07:16:03 2019 +0000
- Revision:
- 4:822208cb5a13
- Parent:
- 2:79cad6a51fd0
Updated web library
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
andrewboyson | 2:79cad6a51fd0 | 1 | #include <stdint.h> |
andrewboyson | 2:79cad6a51fd0 | 2 | #include <stdio.h> |
andrewboyson | 2:79cad6a51fd0 | 3 | |
andrewboyson | 2:79cad6a51fd0 | 4 | #include "http.h" |
andrewboyson | 2:79cad6a51fd0 | 5 | #include "ds18b20.h" |
andrewboyson | 2:79cad6a51fd0 | 6 | #include "1-wire.h" |
andrewboyson | 2:79cad6a51fd0 | 7 | #include "1-wire-bus.h" |
andrewboyson | 2:79cad6a51fd0 | 8 | #include "1-wire-device.h" |
andrewboyson | 2:79cad6a51fd0 | 9 | |
andrewboyson | 2:79cad6a51fd0 | 10 | static void addRomToHttp(char* pRom) |
andrewboyson | 2:79cad6a51fd0 | 11 | { |
andrewboyson | 2:79cad6a51fd0 | 12 | for (char* p = pRom; p < pRom + 8; p++) HttpAddByteAsHex(*p); |
andrewboyson | 2:79cad6a51fd0 | 13 | } |
andrewboyson | 2:79cad6a51fd0 | 14 | |
andrewboyson | 2:79cad6a51fd0 | 15 | void WebOneWireAjax() |
andrewboyson | 2:79cad6a51fd0 | 16 | { |
andrewboyson | 2:79cad6a51fd0 | 17 | HttpOk("text/plain; charset=UTF-8", "no-cache", NULL, NULL); |
andrewboyson | 2:79cad6a51fd0 | 18 | |
andrewboyson | 2:79cad6a51fd0 | 19 | HttpAddInt16AsHex (DeviceScanMs); HttpAddChar('\n'); |
andrewboyson | 2:79cad6a51fd0 | 20 | HttpAddInt16AsHex (OneWireBusLowTweak); HttpAddChar('\n'); |
andrewboyson | 2:79cad6a51fd0 | 21 | HttpAddInt16AsHex (OneWireBusFloatTweak); HttpAddChar('\n'); |
andrewboyson | 2:79cad6a51fd0 | 22 | HttpAddInt16AsHex (OneWireBusReadTweak); HttpAddChar('\n'); |
andrewboyson | 2:79cad6a51fd0 | 23 | HttpAddInt16AsHex (OneWireBusHighTweak); HttpAddChar('\n'); |
andrewboyson | 2:79cad6a51fd0 | 24 | HttpAddInt16AsHex (OneWireBusReleaseTweak); HttpAddChar('\n'); |
andrewboyson | 2:79cad6a51fd0 | 25 | HttpAddNibbleAsHex(OneWireTrace); HttpAddChar('\n'); |
andrewboyson | 2:79cad6a51fd0 | 26 | HttpAddChar('\f'); |
andrewboyson | 2:79cad6a51fd0 | 27 | |
andrewboyson | 2:79cad6a51fd0 | 28 | for (int device = 0; device < DeviceCount; device++) |
andrewboyson | 2:79cad6a51fd0 | 29 | { |
andrewboyson | 2:79cad6a51fd0 | 30 | addRomToHttp ( DeviceList + device * 8); |
andrewboyson | 2:79cad6a51fd0 | 31 | HttpAddInt16AsHex(*(DS18B20Value + device) ); |
andrewboyson | 2:79cad6a51fd0 | 32 | HttpAddChar('\n'); |
andrewboyson | 2:79cad6a51fd0 | 33 | } |
andrewboyson | 2:79cad6a51fd0 | 34 | HttpAddChar('\f'); |
andrewboyson | 2:79cad6a51fd0 | 35 | |
andrewboyson | 2:79cad6a51fd0 | 36 | for (int rom = 0; rom < DS18B20RomCount; rom++) |
andrewboyson | 2:79cad6a51fd0 | 37 | { |
andrewboyson | 2:79cad6a51fd0 | 38 | addRomToHttp(DS18B20Roms + rom * 8); |
andrewboyson | 2:79cad6a51fd0 | 39 | HttpAddText(DS18B20RomNames[rom]); |
andrewboyson | 2:79cad6a51fd0 | 40 | HttpAddChar('\n'); |
andrewboyson | 2:79cad6a51fd0 | 41 | } |
andrewboyson | 2:79cad6a51fd0 | 42 | } |
andrewboyson | 2:79cad6a51fd0 | 43 |