sada pokusavam ispisati vrijednost pritiska na GLCDu ali mi ne ispise tocne vrijednosti.Mislim da je to zbog toga jer su mi varijable LONG velicine a za prikaz na GLCDu mi treba WORD velicina.
dio koda kako se prikazuje na 4x20 LCDu
Code: Select all
'*****************DEFINICIJE ZA BMP SeNZOR***************
' Software Defines (variables and pins)
Cal_table var word[11] '11 word array to store calibration data
lUpres var long 'Long variable for Uncompensated Pressure
lPres var Long 'Long variable for Compensated Pressure
lTemp_Var1 Var long 'Long temporary variable
X1 var Long
X2 var Long
X3 var Long
B3 var long
B4 var long
B5 var long
B6 var Long
B7 var long
lAC1 var Long 'Long variables for cal values actually negative in my sensor
lAC2 var long 'These are 'cast' from the Word vars into Long vars in code below
lAC3 var Long
lAC4 var Long
lMB var Long
lMC var Long
bTemp_Var1 var byte 'Byte temp variable
wTemp_Var1 var Word 'Word temp variable
wTemp_Var2 var word 'Word temp variable
lUTemp var long 'Uncompensated temperature reading from sensor
lCTemp var Long 'Compensated (real) temperature x10 (1/10th of C) from sensor
i2c_Reg var Byte 'variable for target i2c register address
OSS con $3 'This value is the Over Sampling Setting for the BMP085
'0 = minimum, 3 = maximum. Also change value in Read_pres if you alter OSS
'Calculate pressure in Pascals from uncompensated pressure lUpres (1/100th's of hPa's)
B6 = b5 - 4000
x1 = (b2 * (B6 * B6 / $1000)) / $800
x2 = (lac2 * B6) / $800
x3 = x1 + x2
B3 = ((lac1 * 4 + x3) << OSS + 2) / 4 'OSS = Over Sampling constant set above
x1 = (lac3 * b6) / $2000
x2 = (b1 * (b6 * b6 / $1000)) / $10000
x3 = ((x1 + x2) + 2) / 4
B4 = (lac4 * (x3 + 32768)) / $8000 'Find B4, note lAC4 is an unsigned Long
B7 = (lUPres - B3) * (50000 >> OSS) 'OSS = Over Sampling constant set above
If B7 < $80000000 then 'branch if value is above or below range
lPres = (B7 * 2) / B4
Else
lPres = (B7 / B4) * 2
Endif
X1 = (lPres / 256) * (lPres / 256)
X1 = (X1 * 3038) / $10000 '$10000 = 2^16
X2 = (-7357 * lPres) / $10000
lPres = lPres + (X1 + X2 + 3791) / 16 'lPres is the true pressure in Pa
'[b]DISPLAY true pressure in hPa
X1 = lPres / 100 'find value above decimal point
'Shift cursor to line_3
LCDOUT $FE,$D4, "P= ",DEC X1,"." 'Send Word size number to LCD
X1 = lPres // 100 'find value below decimal point
LCDOUT $FE,$D4+8, DEC X1,"hPa" 'Send Word size number to LCD
'DISPLAY true pressure in hPa
X1 = lPres / 100 'find value above decimal point
LCDOUT $FE,$D4, "P= ",DEC X1,"." 'Send Word size number to LCD
X1 = lPres // 100 'find value below decimal point
LCDOUT $FE,$D4+8, DEC X1,"hPa" 'Send Word size number to LCD
kako ovaj podebljani dio preraditi da dobijem word velicinu i prikazem ju na GLCDu