-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpeter-webpage-dht11-example.txt
More file actions
69 lines (54 loc) · 2.24 KB
/
peter-webpage-dht11-example.txt
File metadata and controls
69 lines (54 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
\ by Peterforth August 2022
\ with all my gratitude to Brad Nelson for his outstanding support and development
\ of ESP32forth started on eforth by Bill Munch, Dr. Ting and many FIG int. members
\ join and support our developments on the Forth2020 group.
\ https://www.facebook.com/groups/forth2020/
\ and the ESP32forth support team https://www.facebook.com/groups/esp32a/
forth also streams also httpd
also web-interface
0 value mystr 0 value mystr# 0 value mystrn
: mystr-init 10 dup allocate throw to mystr to mystrn 0 to mystr# ;
: mystr-grow mystrn 1+ 2* to mystrn mystr mystrn resize throw to mystr ;
: +mystr ( ch -- ) mystr# mystrn >= if mystr-grow then
mystr mystr# + c! 1 +to mystr# ;
: 1tch begin >in @ #tib @ >= while refill drop nl +mystr repeat ;
: tch ( -- ch ) tib >in @ + c@ ;
: |? ( -- f ) 1tch tch [char] | = ;
: m$ mystr-init
begin |? 0= while tch +mystr 1 >in +! repeat 1 >in +!
mystr mystr# ;
: m| m$ state @ if swap [ internals ] aliteral aliteral then ; immediate
\ initdh11 rtemp and rhumid are from project #16 *****
\ if you don´t have them remove from the source *****
\ or use the line below with 3 fake words
: initdh11 ; : rtemp 22 ; : rhumid 45 ; ( 3 fake words)
initdh11
also httpd
0 value counter
: rtemp>str ( --addr n ) <# # # 46 hold # # #> ;
: counter>str ( --addr n ) 1 +to counter counter <# #S #> ;
: page-html
s" text/html" ok-response m|
<meta http-equiv="refresh" content="8" >
<h1>Temp & Humidity Demo</h1>
<h2>temperature C: | send
rtemp rtemp>str send
m| </h2> | send
m| <h2>humidity % : | send
200 ms
rhumid rtemp>str send
m| </h2> | send
m| <h4>----------<h4><br> | send
m| <h3>Number requests : | send
counter>str send m| </h3> | send
;
: serve-page
." Requesting > " path type cr
path s" /" str= if page-html exit then
notfound-response
;
: runpage login 80 server
begin handleClient if serve-page then pause again ;
\ edit here your ***********************************
\ router name and password ********************************
z" ssid" z" password" runpage