Add conversion to hPa
This commit is contained in:
+27
-4
@@ -90,8 +90,30 @@ delay1:
|
||||
jr nz,delay1
|
||||
ret
|
||||
|
||||
convert_to_hpa:
|
||||
ld a,(pressure)
|
||||
convert_to_hpa: ; shift the decimal point in (pressure) two places left
|
||||
ld hl,pressure
|
||||
ld b,0 ; count of digits ahead of the point
|
||||
find_point:
|
||||
ld a,(hl)
|
||||
or a
|
||||
ret z ; no point in the string, leave it alone
|
||||
cp a,2eh ; period
|
||||
jr z,found_point
|
||||
inc hl
|
||||
inc b
|
||||
jr find_point
|
||||
found_point:
|
||||
ld a,b
|
||||
cp 3 ; need three whole digits to shift by two
|
||||
ret c
|
||||
dec hl ; step back over the ones digit
|
||||
dec hl ; hl now holds the new tenths digit
|
||||
ld a,(hl)
|
||||
ld (hl),2eh ; drop the point in two places left
|
||||
inc hl
|
||||
ld (hl),a ; and the saved digit after it
|
||||
inc hl
|
||||
ld (hl),00h ; null terminate, discarding the rest
|
||||
ret
|
||||
|
||||
read_char_b:
|
||||
@@ -141,6 +163,7 @@ print_telem_to_lcd:
|
||||
ld hl,temperature
|
||||
call print_str_to_lcd
|
||||
|
||||
call convert_to_hpa
|
||||
call move_to_presaddr
|
||||
ld hl,pressure
|
||||
call print_str_to_lcd
|
||||
@@ -202,7 +225,7 @@ move_to_tempaddr:
|
||||
ret
|
||||
|
||||
move_to_presaddr:
|
||||
ld a,0c1h
|
||||
ld a,0c3h
|
||||
out (lcd_ctrl),a
|
||||
call lcd_delay
|
||||
ret
|
||||
@@ -214,7 +237,7 @@ move_to_humidaddr:
|
||||
ret
|
||||
|
||||
clabel: DB 'degree C',0
|
||||
plabel: DB 'pascal',0
|
||||
plabel: DB 'hPa',0
|
||||
hlabel: DB '% RH',0
|
||||
|
||||
char_max equ 15
|
||||
|
||||
Reference in New Issue
Block a user