| |
webtemp.pwp
//
// PicoWeb Project File for WebLED
//
#define BANNER "\r\nPicoWeb WebTemp\r\n"
#define EEPROM_IP /* use file "ip" for default IP address */
#define NET_CONFIG_IP /* allow IP address reconfiguration via net */
#define ENABLE_WATCHDOG /* use Atmel watchdog timer hardware */
#define DEBUGGER /* include debugger firmware */
//#define CLOCK 8000000
#define CLOCK 7372000 /* clock rate of microcontroller (in Hz) */
#define BAUD_RATE 19200 /* serial port baud rate */
link add i2cprog_I2C_PORT1_PRESENT.o // use special version of I2C routine
// HTML and images
webtemp.htm // (default Web page)
body.htm
thermo.htm
title.htm
scale.htm
setpt.htm
bruce.jpg // images
dave_3.jpg
empty.gif
finger4.gif
flame1a.gif
flame2.gif
ice4.gif
ice5.gif
scale.gif
steve.jpg
trans3.jpg
vbar_bot.gif
vbar_red.gif
vbar_tic.gif
vbar_top.gif
vbar_wht.gif
// public CGI routines
temperature.cgi
temp_top.cgi
temp_bottom.cgi
set_point.cgi
setpoint_finger.cgi
//
// included application-specific pcode and/or AVR assembly language follows
//
#avr_reset
;--------------------------------------------------------------------------
; this code is executed each time microcontroller is reset
;--------------------------------------------------------------------------
;
; start DS1621 temperature conversion
;
ldi yl,0xEE
rcall ds1621_write
sbi ddrd,LED_BIT
.section eeprom
eeprom_setpt: .byte 70 ; default temperature setpoint
.cseg
#avr_slow
;--------------------------------------------------------------------------
; this code is executed each trip through "slow idle" loop (~1 sec period)
;--------------------------------------------------------------------------
;
rcall check_heater ; check heater (set LED as required)
#avr_fast
;--------------------------------------------------------------------------
; this code is executed each trip through "fast idle" loop
;--------------------------------------------------------------------------
;
#avr_asm
;--------------------------------------------------------------------------
; application-specific CGI pcode and AVR assembly routines go here
;--------------------------------------------------------------------------
;
;+
; **-temperature-show the temperature in decimal.
;-
.eseg
temperature:
pcall tempf_buf
pcall update_heater
pjump decconv ; convert to decimal ascii
;+
; **-decconv-decimal converter.
;
; inputs:
; buf = word to convert
;
; outputs:
; result printed (with pputc)
;
; caveats:
; MUST be called with pcall!!
;-
#define DIG_BUF buf+6
#define DIG_PTR buf+4
#define DEC_REM buf+2
#define DEC_VAL buf
.cseg
decconv:
pmovwi DIG_PTR,DIG_BUF
pbitwi DEC_VAL,0x8000 ; check the sign
pjumpeq decconv1 ; positive - start conversion
pnegw DEC_VAL ; negate it
pputc '-'
decconv1:
pdiv DEC_VAL,[DEC_VAL],10 ; get next one
paddwi DEC_REM,'0' ; convert digit for display
pmovbi [DIG_PTR],[byte DEC_REM] ; save digit
paddwi DIG_PTR,1 ; bump past digit just stored
psubwi DEC_VAL,0 ; test remaining value
pjumpne decconv1 ; back if more to convert
decconv2:
psubwi DIG_PTR,1 ; point to next one
pputcb [DIG_PTR] ; show it
pcmpwi DIG_PTR,DIG_BUF ; check if just did last one
pjumpne decconv2 ; nope - do next one
pret
;+
; **-temp_top-output image height for lower themometer (white)
;-
.eseg
temp_top:
pcall tempf_buf
pcall compute_top
pjump decconv
compute_top:
pmovwi buf+2,130
psubwi buf+2,[buf]
pshnw buf+2,1
pmovwi buf,[buf+2]
pret
;+
; **-temp_bottom-output image height for lower themometer (red)
;-
.eseg
temp_bottom:
pcall tempf_buf
pshnw buf,1
pjump decconv
;+
; **-set_point-set heater set point from GET command line
;-
.eseg
set_point:
purlparm buf,"s=" ; search for command string
pjumpne not_setting_setpoint ; exit if not found
purl2int buf+2,buf ; found...convert to integer
pwreebi eeprom_setpt,[byte buf+2] ; store in EEPROM
not_setting_setpoint:
pcall get_setpoint
pjump decconv
;+
; **-get_setpoint-get set point byte from EEPROM
;-
.eseg
get_setpoint:
pcall update_heater
pclrw buf
pee2s buf,eeprom_setpt,1 ; get set point byte from EEPROM
pret
;+
; **-update_heater-
;-
#define CUR_TEMP buf
#define CUR_SETP buf+14
update_heater:
pclrw CUR_SETP
pee2s CUR_SETP,eeprom_setpt,1 ; get setpoint
pcall tempf_buf ; get temperature (into buf)
pcmpwi CUR_TEMP,[CUR_SETP] ; check temp against setpoint
pjumplo heater_on
pmovbi PORTD+0x20,1<<LED_BIT
pret
heater_on:
pmovbi PORTD+0x20,0
pret
;+
; **-tempf_buf-read current temp (deg-C) into buf
;-
tempf_buf:
pclrw buf
pread_temp buf ; get temp
pmovwi buf+4,0x80 ; set up for sign test
pandwi buf+4,[buf] ; check the sign
pjumpeq temp_positive ; it is positive
pmovbi buf+1,0xff ; extend the sign
pnegw buf ; negate
temp_positive:
pmul buf,[buf],9 ; C*9
pdiv buf,[buf],5 ; /5
pandwi buf+4,0x80 ; test original sign
pjumpeq temp_norenegate ; positive
pnegw buf
temp_norenegate:
paddwi buf,32 ; +32 - buf now has temp (F)
pret
;+
; **-setpoint_finger-output HTML image height to position "finger"
;-
setpoint_finger:
pcall get_setpoint
pcall compute_top
psubwi buf,3
pjump decconv
;+
; **-check_heater-set LED according to current temp and set point
;-
.cseg
;
; MUST BE in program memory (.cseg) because we call from idle loop!!!!
;
check_heater:
pbegin
pee2s buf,511,1 ; is external pcode loaded?
pandwi buf,0xff
pjumpne no_update_heater ; no...exit
pcall update_heater ; yes...update heater state
no_update_heater:
pend
ret
Back
|
|
|