Based on this post : http://www.picbasic.co.uk/forum/show...7847#post87847 - Thank You, scalerebotics !!! I re-x-wrote the code. Now I have good results ! But.... HOW can I display all the three digits of var.temperature ?!? Give me a clue, please !!!
Now I have only dig 1 on displayCode:;********************************************************************************************** ; BIG FONTS - need improvements !!! @ DEVICE pic16F628A, INTRC_OSC, WDT_OFF, PWRT_OFF, BOD_OFF, MCLR_ON, LVP_OFF, CPD_OFF, PROTECT_OFF Define NO_CLRWDT 1 DEFINE OSC 4 TRISB = %00011100 'portB configuration 0=out 1=in TRISA = %10100000 'portA configuration PortA = %11100000 CMCON = 7 VRCON = 0 INTCON = 0 OPTION_REG=%00000111 'weak pullups on, TMRO prescale = 256 Lcd_DC var PortB.0 Lcd_SDA var PortA.3 Lcd_RST var PortA.4 Lcd_CLK var PortA.2 DQ var PortB.2 i var Byte j var Word k var Byte Nc var Byte PosX var Byte PosY var Byte LcdStr var Byte [28] Lcd_Data var Byte CharNum var Byte FA VAR BYTE[5] 'upper left of character FB VAR BYTE[5] 'upper right of character FC VAR BYTE[5] 'lower left of character FD VAR BYTE[5] 'lower right of character LcdReg var Byte x var Byte y var Byte cursor var Byte Temperature Var Word TempC Var Word Sign Var Word Float Var Word Dummy Var Byte DS18B20_12bit CON %01111111 ' 750ms, 0.0625°C 'initialize display----------------------------------------------- pause 250 '----------------------------------------------------------------- 'Initialize LCD, run 1st this! Low Lcd_RST 'Reset LCD (HW reset) pause 100 High Lcd_RST 'Release Reset Low Lcd_DC 'Command/Data Lcd_Data= $21: GOSUB Lcd_SentByte ' LCD EXTENDED COMMANDS Lcd_Data= $c2: GOSUB Lcd_SentByte ' SET LCD Vop (CONTRAST) era c8 Lcd_Data= $06: GOSUB Lcd_SentByte ' SET TEMP COEFFICENT Lcd_Data= $13: GOSUB Lcd_Sentbyte ' LCD BIAS MODE Lcd_Data= $20: GOSUB Lcd_Sentbyte ' LCD STANDARD COMMANDS Lcd_Data= $09: GOSUB Lcd_Sentbyte ; all on pause 1000 Lcd_data= $08: gosub lcd_sentbyte ' lcd blank Lcd_Data= $0c: GOSUB Lcd_sentbyte ' LCD IN NORMAL MODE gosub Lcd_Clear 'Clear contents of screen Low Lcd_DC Pause 100 '================================================== ' Init Sensor 1 OWOUT DQ, 1, [$CC, $4E, 0, 0, DS18B20_12bit] OWOut DQ, 1, [$CC, $48] ' Start temperature conversion OWOut DQ, 1, [$CC, $B8] OWOut DQ, 1, [$CC, $BE] Pause 50 OWIn DQ, 2, [temperature.byte0, temperature.byte1] '================================================== main: pause 100 sign = " " ' Start temp.conv.Sensor1 OWOut DQ, 1, [$CC, $44] OWOut DQ, 1, [$CC, $BE] OWIn DQ, 2, [temperature.byte0, temperature.byte1] If Temperature.15 then Temperature= ~Temperature +1 sign="-" Endif Dummy = 625 * Temperature TempC = DIV32 10 TempC = (Temperature & $7FF) >> 4 Float = ((Temperature.Lowbyte & $0F ) * 25 )>>2 Temperature = TempC*100 + Float LcdStr(2) = 48 + TEMPERATURE dig 1 LcdStr(1) = 48 + TEMPERATURE dig 2 LcdStr(0) = 48 + TEMPERATURE dig 3 Nc=2 Gosub Lcd_SentString gosub afisare goto main '================================================== afisare: High Lcd_DC LcdReg = %10000000 ' cursor X call PrintCtrlLcd LcdReg = %01000000 ' cursor Y call PrintCtrlLcd SHiftOUT Lcd_SDA , Lcd_CLK , 1, [ FA(0),FA(1),FA(2),FA(3),FA(4)] 'upper left LcdReg = %10000000 + 5 ' cursor X call PrintCtrlLcd LcdReg = %01000000 ' cursor Y call PrintCtrlLcd SHiftOUT Lcd_SDA , Lcd_CLK , 1, [ FB(0),FB(1),FB(2),FB(3),FB(4)] 'upper right LcdReg = %10000000 ' cursor X call PrintCtrlLcd LcdReg = %01000001 ' cursor Y call PrintCtrlLcd SHiftOUT Lcd_SDA , Lcd_CLK , 1, [ FC(0),FC(1),FC(2),FC(3),FC(4)] 'lower left LcdReg = %10000000 + 5 ' cursor X call PrintCtrlLcd LcdReg = %01000001 ' cursor Y call PrintCtrlLcd SHiftOUT Lcd_SDA , Lcd_CLK , 1, [ FD(0),FD(1),FD(2),FD(3),FD(4)] 'lower right Low Lcd_DC Return '================================================== Lcd_Clear: For cursor = 0 to 5 PosX=0:PosY=Cursor:Gosub Lcd_GotoXY High Lcd_DC For i= 1 to 84 Lcd_Data=0:Gosub Lcd_SentByte Lcd_Data=0:Gosub Lcd_SentByte Next i Next cursor Return '================================================== Lcd_GotoXY: Low Lcd_DC Lcd_Data=%01000000 | PosY :Gosub Lcd_SentByte 'Y Lcd_Data=%10000000 | PosX :Gosub Lcd_SentByte 'X Return '================================================== Lcd_SentByte: SHiftOUT Lcd_SDA , Lcd_CLK , 1, [ Lcd_Data ] Return '================================================== Lcd_SentString: ;For k=0 to Nc-1 FOR K=0 TO NC Lcd_Data=LcdStr(k) Gosub Lcd_SentChar next k Return '================================================== Lcd_SentChar: lookdown Lcd_data,[" !\#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~"],CharNum Lcd_data = CharNum + 32 SELECT CASE lcd_data Case 48 ' a zero FA(0)=$00:FA(1)=$FC:FA(2)=$FE:FA(3)=$FE:FA(4)=$06 ' // 0 FB(0)=$06:FB(1)=$FE:FB(2)=$FE:FB(3)=$FC:FB(4)=$00 ' // 0 FC(0)=$00:FC(1)=$7F:FC(2)=$FF:FC(3)=$FF:FC(4)=$C0 ' // 0 FD(0)=$C0:FD(1)=$FF:FD(2)=$FF:FD(3)=$7F:FD(4)=$00 ' // 0 Case 49 ' a one FA(0)=$00:FA(1)=$00:FA(2)=$18:FA(3)=$1C:FA(4)=$FE ' // 1 FB(0)=$FE:FB(1)=$FE:FB(2)=$00:FB(3)=$00:FB(4)=$00 ' // 1 FC(0)=$00:FC(1)=$00:FC(2)=$00:FC(3)=$C0:FC(4)=$FF ' // 1 FD(0)=$FF:FD(1)=$FF:FD(2)=$C0:FD(3)=$00:FD(4)=$00 ' // 1 Case 50 ' a TWO FA(0)=$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FC(1)=$7F:FC(2)=$FF:FC(3)=$FF:FC(4)=$C0 ' // 6 FD(0)=$C0:FD(1)=$FF:FD(2)=$FF:FD(3)=$7F:FD(4)=$00 ' // 6 Case 55 ' a SEVEN FA(0)=$00:FA(1)=$06:FA(2)=$06:FA(3)=$06:FA(4)=$86 ' // 7 FB(0)=$E6:FB(1)=$FE:FB(2)=$7E:FB(3)=$1E:FB(4)=$00 ' // 7 FC(0)=$00:FC(1)=$80:FC(2)=$F0:FC(3)=$FE:FC(4)=$3F ' // 7 FD(0)=$07:FD(1)=$01:FD(2)=$00:FD(3)=$00:FD(4)=$00 ' // 7 Case 56 ' a EIGHT FA(0)=$00:FA(1)=$7C:FA(2)=$FE:FA(3)=$FE:FA(4)=$86 ' // 8 FB(0)=$86:FB(1)=$FE:FB(2)=$FE:FB(3)=$7C:FB(4)=$00 ' // 8 FC(0)=$00:FC(1)=$7E:FC(2)=$FF:FC(3)=$FF:FC(4)=$C1 ' // 8 FD(0)=$C1:FD(1)=$FF:FD(2)=$FF:FD(3)=$7E:FD(4)=$00 ' // 8 Case 57 ' a NINE FA(0)=$00:FA(1)=$FC:FA(2)=$FE:FA(3)=$FE:FA(4)=$86 ' // 9 FB(0)=$86:FB(1)=$FE:FB(2)=$FE:FB(3)=$FC:FB(4)=$00 ' // 9 FC(0)=$00:FC(1)=$78:FC(2)=$F9:FC(3)=$F9:FC(4)=$C1 ' // 9 FD(0)=$C1:FD(1)=$FF:FD(2)=$FF:FD(3)=$7F:FD(4)=$00 ' // 9 end SELECT High Lcd_DC PrintCtrlLcd: LCD_DC = 0 PrintDataLcd: for x = 1 to 8 LCD_SDA = LcdReg.7 LCD_CLK = 1 LcdReg = LcdReg << 1 LCD_CLK = 0 next x LCD_DC = 1 return END....
Bookmarks