ESP8266 i Atmega 8Mhz
: 31 sty 2018, 2:50
Witam
Mam mały problem dostałem kod od Bartka do czytania czasu z serwera UTC i o ile kod na atmedze taktowanej 16Mhz działa to za chiny nie mogę tego odpalić na 8Mhz
To jest kod na 16Mhz
a to jest kod po przeróbce na 8Mhz
Zmienilem ustawienia w programie z 115200 na 9600 zmienilem tez ustawienia Timer2 wydaje mi sie ze dobrze to wszystko poustawialem ale cos jest nie tak
Gdzie jest blad ?
Co robie nie tak ?
ESP8266 mam ustawiony na 9600 a nie na 115200 wiec powinno chyba ruszyc a nie chce
Mam mały problem dostałem kod od Bartka do czytania czasu z serwera UTC i o ile kod na atmedze taktowanej 16Mhz działa to za chiny nie mogę tego odpalić na 8Mhz
To jest kod na 16Mhz
Code: [Zaznacz cały] [Rozwiń/Zwiń]
- $regfile = "m32def.dat"
- $crystal = 16000000 '11059200
- $swstack = 64
- $hwstack = 64
- $framesize = 200
- $baud = 115200 '115200
- Config Submode = New
- '****************************************************************
- '* PROGRAMM CONSTANTS/SETTINGS *
- '****************************************************************
- Const Nastepny_odczyt_ntp = 3600 'synchronizacja czasu co godzinê
- '****************************************************************
- '* ALPHANUMERIC LCD CONFIG *
- '****************************************************************
- Config Lcdpin = Pin , Db4 = Porta.2 , Db5 = Porta.3 , Db6 = Porta.4 , Db7 = Porta.5 , E = Porta.1 , Rs = Porta.0 'ZL3AVR
- Config Lcd = 20x4
- 'Config Lcd = 16 * 2
- 'Config Lcdpin = Pin , Db4 = Portd.4 , Db5 = Portd.5 , Db6 = Portd.6 , Db7 = Portd.7 , E = Portd.3 , Rs = Portd.2 'ZL2AVR
- Deflcdchar 1 , 2 , 15 , 20 , 16 , 14 , 1 , 1 , 30 ' replace [x] with number (0-7)
- Cursor Off Noblink
- Cls
- '****************************************************************
- '* CONFIG FOR HARDWARE TWI (I2C) *
- '****************************************************************
- $lib "i2c_twi.lbx"
- Config Scl = Portc.0
- Config Sda = Portc.1
- I2cinit
- Config Twi = 400000
- '*****************************************************************
- '* CONFIG FOR DS3231 I2C CLOCK (RTC) *
- '*****************************************************************
- Config Clock = User
- Config Date = Dmy , Separator = /
- 'address of ds1307
- Const Ds3231w = &HD0
- Const Ds3231r = &HD1
- Dim Weekday As Byte , Old_day As Byte , Weekday_str As String * 10
- '*****************************************************************
- '* USART CONFIG FOR ESP8266 *
- '*****************************************************************
- Config Serialin0 = Buffered , Size = 100 ' from ESP8266
- Config Serialout0 = Buffered , Size = 100 ' to ESP8266
- Open "COM1:" For Binary As #1
- Echo Off : $timeout = 3000
- '*****************************************************************
- '* SOFTWARE PORT FOR DEBUG *
- '*****************************************************************
- Open "COMC.7:115200,8,n,1" For Output As #2
- '*****************************************************************
- '* I/O PIN`s CONFIGURATION *
- '*****************************************************************
- 'Config Portb.0 = Output : Set Portb.0 : Buzz Alias Portb.0
- '*****************************************************************
- '* TIMER2 CONFIG FOR TIME BASE *
- '*****************************************************************
- Config Timer2 = Timer , Prescale = 1024 , Compare = Disconnect , Pwm = Off , Clear Timer = 1
- On Compare2 Timer2_isr Nosave : Compare2 = 215 '20ms @11MHz/1024Hz
- Dim 20ms As Byte , 100ms As Byte
- '*****************************************************************
- '* TIMER0 CONFIG FOR LCD BACKLIGHT PWM *
- '*****************************************************************
- 'Config Timer0 = Pwm , Prescale = 1 , Pwm = On , Compare Pwm = Clear Up
- ' Pwm0 = 50
- '*****************************************************************
- '* VARIABLES *
- '*****************************************************************
- Dim Second_tick As Byte , Timeout As Byte , Sys_sec As Long , No_ntp As Byte , Ntp_progress As Byte
- Dim Wait_start As Byte , Got_time As Byte , Net_status As Byte , Wait_answear As Byte
- Dim Got_match As Byte , Inp_str1 As String * 100 , Char As Byte , Idx As Byte , Helpb As Byte
- Dim Answear As Byte , Insp As Byte
- Okay Alias 1
- Error Alias 2
- ' Ntp Stuff
- Dim Timestr As String * 10
- Dim Tt(4) As String * 1
- Dim Ss(4) As Byte
- Dim L1 As Long At Ss Overlay ' Overlay a long variable to receive-string
- Dim L2 As Long ' with overlay you need no transfer from the byte-array to a long-variable
- Dim Odczekaj_czas As Word
- Dim Info_timeout As Byte
- Const Letni = "AT+GMT=2"
- Const Zimowy = "AT+GMT=1"
- Dim Daylight_saving As String * 10
- '***** wpisuje do DS-a "pierdo³y" ¿eby widziæ pierwsze synchro *****
- Time$ = "00:00:00" 'automatycznie zapisze w DS`ie
- Date$ = "00-01-01" 'automatycznie zapisze w DS`ie
- '*****--------------------------------------------------------*****
- Sub Ntp_dst_correction
- 'Dont change order of time and date variables !!! This order is required for Date/Time functions used.
- 'this routine is orginated by framuel
- Local Second As Byte
- Local Minute As Byte
- Local Hour As Byte
- Local Day As Byte
- Local Month As Byte
- Local Year As Byte
- Local Dow As Byte 'Day of week
- Day = Date(l2) 'set 3 variables: Day, Month, Year, so Year contains now current year
- 'DST starts at the last sunday of March, so let's see what weekday the 1st of April is
- Month = 4
- Day = 1
- Hour = 2
- Minute = 0
- Second = 0
- Dow = Dayofweek(day) '0 = Monday to 6 = Sunday
- Day = 31 - Dow 'Now count back the days until last sunday
- Month = 3 'and set month to March
- If L2 >= Syssec(second) Then
- 'DST ends at the last sunday of October, so let's see what weekday the 1st of November is
- Day = 1
- Month = 11
- Dow = Dayofweek(day) '0 = Monday to 6 = Sunday
- Day = 31 - Dow 'Now count back the days until last sunday
- Month = 10 'and set month to October
- Locate 3 , 1
- If L2 < Syssec(second) Then 'jeœli data w sysec mniejsza od aktulnej to jest lato
- L2 = L2 + 3600 '7200
- Lcd "Sumer Time"
- Else
- L2 = L2 + 0 '3600
- Lcd "Winter Time"
- End If
- End If
- End Sub
- Enable Compare2
- Enable Interrupts
- Print #1 , "AT+RST"
- Print#2 , "Started.."
- Do
- If 20ms = 1 Then
- 20ms = 0
- Incr 100ms
- 'Set Buzz
- End If
- If Ischarwaiting(#1) > 0 Then
- Char = Inkey(#1)
- Select Case Char
- Case 10
- Case 13 : Got_match = 1
- Case Else
- Inp_str1 = Inp_str1 + Chr(char)
- Incr Idx
- If Idx > 99 Then Got_match = 1
- End Select
- End If
- If Got_match = 1 Then
- Got_match = 0
- If Inp_str1 <> "" Then
- Select Case Inp_str1
- Case "SEND OK"
- Answear = Okay
- Case "OK"
- Answear = Okay
- Case "ERROR"
- Answear = Error
- Case "WIFI GOT IP"
- Net_status = 1
- Case "WIFI CONNECTED"
- Case "WIFI DISCONNECT"
- Net_status = 0
- Case Else
- Insp = Instr(inp_str1 , ",CONNECT")
- If Insp > 0 Then Answear = Okay
- Insp = Instr(inp_str1 , "+IPD,1,4:")
- If Insp > 0 Then
- Timestr = Mid(inp_str1 , 10 , 4)
- Tt(1) = Mid(timestr , 4 , 1) 'from big endian to little endian
- Tt(2) = Mid(timestr , 3 , 1) 'swap the bytes
- Tt(3) = Mid(timestr , 2 , 1)
- Tt(4) = Mid(timestr , 1 , 1)
- Ss(1) = Asc(tt(1)) 'this is L1 split in 4s by overlay
- Ss(2) = Asc(tt(2))
- Ss(3) = Asc(tt(3))
- Ss(4) = Asc(tt(4))
- L2 = L1 + 1139293696
- 'L2 = L2 + 7200 ' offset in seconds UTC + 2 hour
- Call Ntp_dst_correction
- Time$ = Time(l2) 'set the time
- Date$ = Date(l2) 'set the date
- Sys_sec = Syssec(time$ , Date$)
- Got_time = 1
- Odczekaj_czas = Nastepny_odczyt_ntp
- 'Reset Buzz
- Locate 4 , 1 : Lcd Spc(16) 'clear Lowerline
- Locate 4 , 4 : Lcd "Download Time" : Info_timeout = 2
- End If
- End Select
- End If
- 'Locate 1 , 16 : Lcd "*"
- Print #2 , Inp_str1
- Inp_str1 = ""
- Idx = 0
- End If
- If 100ms > 9 Then '200ms
- 100ms = 0
- Incr Second_tick
- If Net_status = 1 Then
- If No_ntp = 1 Then
- Select Case Ntp_progress
- Case 1
- Print #1 , "AT+CIPMUX=1"
- Incr Ntp_progress
- Case 2
- Select Case Answear
- Case Okay
- Waitms 200
- Print #1 , "AT+CIPSTART=1," ; Chr(34) ; "UDP" ; Chr(34) ; "," ; Chr(34) ; "193.67.79.202" ; Chr(34) ; ",37"
- ' MIREK 132.163.4.103 /DE 193.67.79.202 /TPSA 217.96.29.26 /193.67.79.202 ,217.96.29.26
- Incr Ntp_progress
- Case Error
- End Select
- Case 3
- Select Case Answear
- Case Okay
- Print #1 , "AT+CIPSEND=1,3"
- Incr Ntp_progress
- Case Error
- End Select
- Case 4
- Select Case Answear
- Case Okay
- Print #1 , "X"
- Incr Ntp_progress
- Wait_answear = 5
- Case Error
- End Select
- Case 5
- If Answear > 0 Then
- Incr Ntp_progress
- End If
- Case 6
- If Wait_answear > 0 Then
- Decr Wait_answear
- If Got_time = 1 Then
- No_ntp = 0
- Print #1 , "AT+CIPCLOSE=1"
- Incr Ntp_progress
- End If
- Else
- Print #1 , "AT+CIPCLOSE=1"
- Incr Ntp_progress
- End If
- End Select
- End If
- End If
- Answear = 0
- End If
- If Second_tick > 4 Then '5x200ms=1s
- Second_tick = 0
- 'Locate 1 , 16 : Lcd " "
- ' Incr Sys_sec
- ' Time$ = Time(sys_sec)
- Locate 1 , 7 : Lcd Time$
- Locate 2 , 7 : Lcd Date$
- If Info_timeout > 0 Then
- Decr Info_timeout
- If Info_timeout = 0 Then Old_day = 0
- End If
- If Old_day <> _day Then
- Old_day = _day
- Weekday = Dayofweek()
- Weekday_str = Lookupstr(weekday , Weekdays)
- Helpb = 12 - Len(weekday_str)
- If Helpb > 0 Then Weekday_str = Space(helpb) + Weekday_str
- Locate 4 , 1 : Lcd Spc(16) 'clear Lowerline
- Locate 3 , 2 : Lcd Weekday_str
- End If
- If Odczekaj_czas > 0 Then Decr Odczekaj_czas
- If Odczekaj_czas = 0 Then
- No_ntp = 1
- Ntp_progress = 1
- Odczekaj_czas = 20
- ' Locate 2 , 1 : Lcd Spc(16) 'clear Lowerline
- Locate 4 , 6 : Lcd "Loading..." ': Info_timeout = 2
- End If
- End If
- Loop
- End
- Timer2_isr:
- $asm
- !PUSH R24
- !in R24, sreg
- !PUSH R24
- $end Asm
- 20ms = 1
- ' Tuned with NoSave Tool
- $asm
- !POP R24
- !out sreg, r24
- !POP R24
- $end Asm
- Return
- Getdatetime:
- I2cstart ' Generate start code
- I2cwbyte Ds3231w ' send address
- I2cwbyte 0 ' start address in 1307
- I2cstart ' Generate start code
- I2cwbyte Ds3231r ' send address
- I2crbyte _sec , Ack
- I2crbyte _min , Ack ' MINUTES
- I2crbyte _hour , Ack ' Hours
- I2crbyte Weekday , Ack ' Day of Week
- I2crbyte _day , Ack ' Day of Month
- I2crbyte _month , Ack ' Month of Year
- I2crbyte _year , Nack ' Year
- I2cstop
- _sec = Makedec(_sec) : _min = Makedec(_min) : _hour = Makedec(_hour)
- _day = Makedec(_day) : _month = Makedec(_month) : _year = Makedec(_year)
- Return
- Setdate:
- _day = Makebcd(_day) : _month = Makebcd(_month) : _year = Makebcd(_year)
- I2cstart ' Generate start code
- I2cwbyte Ds3231w ' send address
- I2cwbyte 4 ' starting address in 1307
- I2cwbyte _day ' Send Data to SECONDS
- I2cwbyte _month ' MINUTES
- I2cwbyte _year ' Hours
- I2cstop
- Return
- Settime:
- _sec = Makebcd(_sec) : _min = Makebcd(_min) : _hour = Makebcd(_hour)
- I2cstart ' Generate start code
- I2cwbyte Ds3231w ' send address
- I2cwbyte 0 ' starting address in 1307
- I2cwbyte _sec ' Send Data to SECONDS
- I2cwbyte _min ' MINUTES
- I2cwbyte _hour ' Hours
- I2cstop
- Return
- Weekdays:
- Data "Monday" , "Tuesday" , "Wednesday" , "Thursday" , "Friday" , "Saturday" , "Sunday"
- 'Data "Poniedzialek" , "Wtorek" , "{001}roda" , "Czwartek" , "Piatek" , "Sobota" , "Niedziela"
Code: [Zaznacz cały] [Rozwiń/Zwiń]
- $regfile = "m32def.dat"
- $crystal = 8000000 '11059200
- $swstack = 64
- $hwstack = 64
- $framesize = 200
- $baud = 9600 '115200
- Config Submode = New
- '****************************************************************
- '* PROGRAMM CONSTANTS/SETTINGS *
- '****************************************************************
- Const Nastepny_odczyt_ntp = 3600 'synchronizacja czasu co godzinê
- '****************************************************************
- '* ALPHANUMERIC LCD CONFIG *
- '****************************************************************
- Config Lcdpin = Pin , Db4 = Porta.2 , Db5 = Porta.3 , Db6 = Porta.4 , Db7 = Porta.5 , E = Porta.1 , Rs = Porta.0 'ZL3AVR
- Config Lcd = 20x4
- 'Config Lcd = 16 * 2
- 'Config Lcdpin = Pin , Db4 = Portd.4 , Db5 = Portd.5 , Db6 = Portd.6 , Db7 = Portd.7 , E = Portd.3 , Rs = Portd.2 'ZL2AVR
- Deflcdchar 1 , 2 , 15 , 20 , 16 , 14 , 1 , 1 , 30 ' replace [x] with number (0-7)
- Cursor Off Noblink
- Cls
- '****************************************************************
- '* CONFIG FOR HARDWARE TWI (I2C) *
- '****************************************************************
- $lib "i2c_twi.lbx"
- Config Scl = Portc.0
- Config Sda = Portc.1
- I2cinit
- Config Twi = 400000
- '*****************************************************************
- '* CONFIG FOR DS3231 I2C CLOCK (RTC) *
- '*****************************************************************
- Config Clock = User
- Config Date = Dmy , Separator = /
- 'address of ds1307
- Const Ds3231w = &HD0
- Const Ds3231r = &HD1
- Dim Weekday As Byte , Old_day As Byte , Weekday_str As String * 10
- '*****************************************************************
- '* USART CONFIG FOR ESP8266 *
- '*****************************************************************
- Config Serialin0 = Buffered , Size = 100 ' from ESP8266
- Config Serialout0 = Buffered , Size = 100 ' to ESP8266
- Open "COM1:" For Binary As #1
- Echo Off : $timeout = 3000
- '*****************************************************************
- '* SOFTWARE PORT FOR DEBUG *
- '*****************************************************************
- Open "COMC.7:9600,8,n,1" For Output As #2
- '*****************************************************************
- '* I/O PIN`s CONFIGURATION *
- '*****************************************************************
- 'Config Portb.0 = Output : Set Portb.0 : Buzz Alias Portb.0
- '*****************************************************************
- '* TIMER2 CONFIG FOR TIME BASE *
- '*****************************************************************
- Config Timer2 = Timer , Prescale = 1024 , Compare = Disconnect , Pwm = Off , Clear Timer = 1
- On Compare2 Timer2_isr Nosave : Compare2 = 77 '20ms @11MHz/1024Hz
- Dim 20ms As Byte , 100ms As Byte
- '*****************************************************************
- '* TIMER0 CONFIG FOR LCD BACKLIGHT PWM *
- '*****************************************************************
- 'Config Timer0 = Pwm , Prescale = 1 , Pwm = On , Compare Pwm = Clear Up
- ' Pwm0 = 50
- '*****************************************************************
- '* VARIABLES *
- '*****************************************************************
- Dim Second_tick As Byte , Timeout As Byte , Sys_sec As Long , No_ntp As Byte , Ntp_progress As Byte
- Dim Wait_start As Byte , Got_time As Byte , Net_status As Byte , Wait_answear As Byte
- Dim Got_match As Byte , Inp_str1 As String * 100 , Char As Byte , Idx As Byte , Helpb As Byte
- Dim Answear As Byte , Insp As Byte
- Okay Alias 1
- Error Alias 2
- ' Ntp Stuff
- Dim Timestr As String * 10
- Dim Tt(4) As String * 1
- Dim Ss(4) As Byte
- Dim L1 As Long At Ss Overlay ' Overlay a long variable to receive-string
- Dim L2 As Long ' with overlay you need no transfer from the byte-array to a long-variable
- Dim Odczekaj_czas As Word
- Dim Info_timeout As Byte
- Const Letni = "AT+GMT=2"
- Const Zimowy = "AT+GMT=1"
- Dim Daylight_saving As String * 10
- '***** wpisuje do DS-a "pierdo³y" ¿eby widziæ pierwsze synchro *****
- Time$ = "00:00:00" 'automatycznie zapisze w DS`ie
- Date$ = "00-01-01" 'automatycznie zapisze w DS`ie
- '*****--------------------------------------------------------*****
- Sub Ntp_dst_correction
- 'Dont change order of time and date variables !!! This order is required for Date/Time functions used.
- 'this routine is orginated by framuel
- Local Second As Byte
- Local Minute As Byte
- Local Hour As Byte
- Local Day As Byte
- Local Month As Byte
- Local Year As Byte
- Local Dow As Byte 'Day of week
- Day = Date(l2) 'set 3 variables: Day, Month, Year, so Year contains now current year
- 'DST starts at the last sunday of March, so let's see what weekday the 1st of April is
- Month = 4
- Day = 1
- Hour = 2
- Minute = 0
- Second = 0
- Dow = Dayofweek(day) '0 = Monday to 6 = Sunday
- Day = 31 - Dow 'Now count back the days until last sunday
- Month = 3 'and set month to March
- If L2 >= Syssec(second) Then
- 'DST ends at the last sunday of October, so let's see what weekday the 1st of November is
- Day = 1
- Month = 11
- Dow = Dayofweek(day) '0 = Monday to 6 = Sunday
- Day = 31 - Dow 'Now count back the days until last sunday
- Month = 10 'and set month to October
- Locate 3 , 1
- If L2 < Syssec(second) Then 'jeœli data w sysec mniejsza od aktulnej to jest lato
- L2 = L2 + 3600 '7200
- Lcd "Sumer Time"
- Else
- L2 = L2 + 0 '3600
- Lcd "Winter Time"
- End If
- End If
- End Sub
- Enable Compare2
- Enable Interrupts
- Print #1 , "AT+RST"
- Print#2 , "Started.."
- Do
- If 20ms = 1 Then
- 20ms = 0
- Incr 100ms
- 'Set Buzz
- End If
- If Ischarwaiting(#1) > 0 Then
- Char = Inkey(#1)
- Select Case Char
- Case 10
- Case 13 : Got_match = 1
- Case Else
- Inp_str1 = Inp_str1 + Chr(char)
- Incr Idx
- If Idx > 99 Then Got_match = 1
- End Select
- End If
- If Got_match = 1 Then
- Got_match = 0
- If Inp_str1 <> "" Then
- Select Case Inp_str1
- Case "SEND OK"
- Answear = Okay
- Case "OK"
- Answear = Okay
- Case "ERROR"
- Answear = Error
- Case "WIFI GOT IP"
- Net_status = 1
- Case "WIFI CONNECTED"
- Case "WIFI DISCONNECT"
- Net_status = 0
- Case Else
- Insp = Instr(inp_str1 , ",CONNECT")
- If Insp > 0 Then Answear = Okay
- Insp = Instr(inp_str1 , "+IPD,1,4:")
- If Insp > 0 Then
- Timestr = Mid(inp_str1 , 10 , 4)
- Tt(1) = Mid(timestr , 4 , 1) 'from big endian to little endian
- Tt(2) = Mid(timestr , 3 , 1) 'swap the bytes
- Tt(3) = Mid(timestr , 2 , 1)
- Tt(4) = Mid(timestr , 1 , 1)
- Ss(1) = Asc(tt(1)) 'this is L1 split in 4s by overlay
- Ss(2) = Asc(tt(2))
- Ss(3) = Asc(tt(3))
- Ss(4) = Asc(tt(4))
- L2 = L1 + 1139293696
- 'L2 = L2 + 7200 ' offset in seconds UTC + 2 hour
- Call Ntp_dst_correction
- Time$ = Time(l2) 'set the time
- Date$ = Date(l2) 'set the date
- Sys_sec = Syssec(time$ , Date$)
- Got_time = 1
- Odczekaj_czas = Nastepny_odczyt_ntp
- 'Reset Buzz
- Locate 4 , 1 : Lcd Spc(16) 'clear Lowerline
- Locate 4 , 4 : Lcd "Download Time" : Info_timeout = 2
- End If
- End Select
- End If
- 'Locate 1 , 16 : Lcd "*"
- Print #2 , Inp_str1
- Inp_str1 = ""
- Idx = 0
- End If
- If 100ms > 9 Then '200ms
- 100ms = 0
- Incr Second_tick
- If Net_status = 1 Then
- If No_ntp = 1 Then
- Select Case Ntp_progress
- Case 1
- Print #1 , "AT+CIPMUX=1"
- Incr Ntp_progress
- Case 2
- Select Case Answear
- Case Okay
- Waitms 200
- Print #1 , "AT+CIPSTART=1," ; Chr(34) ; "UDP" ; Chr(34) ; "," ; Chr(34) ; "193.67.79.202" ; Chr(34) ; ",37"
- ' MIREK 132.163.4.103 /DE 193.67.79.202 /TPSA 217.96.29.26 /193.67.79.202 ,217.96.29.26
- Incr Ntp_progress
- Case Error
- End Select
- Case 3
- Select Case Answear
- Case Okay
- Print #1 , "AT+CIPSEND=1,3"
- Incr Ntp_progress
- Case Error
- End Select
- Case 4
- Select Case Answear
- Case Okay
- Print #1 , "X"
- Incr Ntp_progress
- Wait_answear = 5
- Case Error
- End Select
- Case 5
- If Answear > 0 Then
- Incr Ntp_progress
- End If
- Case 6
- If Wait_answear > 0 Then
- Decr Wait_answear
- If Got_time = 1 Then
- No_ntp = 0
- Print #1 , "AT+CIPCLOSE=1"
- Incr Ntp_progress
- End If
- Else
- Print #1 , "AT+CIPCLOSE=1"
- Incr Ntp_progress
- End If
- End Select
- End If
- End If
- Answear = 0
- End If
- If Second_tick > 4 Then '5x200ms=1s
- Second_tick = 0
- 'Locate 1 , 16 : Lcd " "
- ' Incr Sys_sec
- ' Time$ = Time(sys_sec)
- Locate 1 , 7 : Lcd Time$
- Locate 2 , 7 : Lcd Date$
- If Info_timeout > 0 Then
- Decr Info_timeout
- If Info_timeout = 0 Then Old_day = 0
- End If
- If Old_day <> _day Then
- Old_day = _day
- Weekday = Dayofweek()
- Weekday_str = Lookupstr(weekday , Weekdays)
- Helpb = 12 - Len(weekday_str)
- If Helpb > 0 Then Weekday_str = Space(helpb) + Weekday_str
- Locate 4 , 1 : Lcd Spc(16) 'clear Lowerline
- Locate 3 , 2 : Lcd Weekday_str
- End If
- If Odczekaj_czas > 0 Then Decr Odczekaj_czas
- If Odczekaj_czas = 0 Then
- No_ntp = 1
- Ntp_progress = 1
- Odczekaj_czas = 20
- ' Locate 2 , 1 : Lcd Spc(16) 'clear Lowerline
- Locate 4 , 6 : Lcd "Loading..." ': Info_timeout = 2
- End If
- End If
- Loop
- End
- Timer2_isr:
- $asm
- !PUSH R24
- !in R24, sreg
- !PUSH R24
- $end Asm
- 20ms = 1
- ' Tuned with NoSave Tool
- $asm
- !POP R24
- !out sreg, r24
- !POP R24
- $end Asm
- Return
- Getdatetime:
- I2cstart ' Generate start code
- I2cwbyte Ds3231w ' send address
- I2cwbyte 0 ' start address in 1307
- I2cstart ' Generate start code
- I2cwbyte Ds3231r ' send address
- I2crbyte _sec , Ack
- I2crbyte _min , Ack ' MINUTES
- I2crbyte _hour , Ack ' Hours
- I2crbyte Weekday , Ack ' Day of Week
- I2crbyte _day , Ack ' Day of Month
- I2crbyte _month , Ack ' Month of Year
- I2crbyte _year , Nack ' Year
- I2cstop
- _sec = Makedec(_sec) : _min = Makedec(_min) : _hour = Makedec(_hour)
- _day = Makedec(_day) : _month = Makedec(_month) : _year = Makedec(_year)
- Return
- Setdate:
- _day = Makebcd(_day) : _month = Makebcd(_month) : _year = Makebcd(_year)
- I2cstart ' Generate start code
- I2cwbyte Ds3231w ' send address
- I2cwbyte 4 ' starting address in 1307
- I2cwbyte _day ' Send Data to SECONDS
- I2cwbyte _month ' MINUTES
- I2cwbyte _year ' Hours
- I2cstop
- Return
- Settime:
- _sec = Makebcd(_sec) : _min = Makebcd(_min) : _hour = Makebcd(_hour)
- I2cstart ' Generate start code
- I2cwbyte Ds3231w ' send address
- I2cwbyte 0 ' starting address in 1307
- I2cwbyte _sec ' Send Data to SECONDS
- I2cwbyte _min ' MINUTES
- I2cwbyte _hour ' Hours
- I2cstop
- Return
- Weekdays:
- Data "Monday" , "Tuesday" , "Wednesday" , "Thursday" , "Friday" , "Saturday" , "Sunday"
- 'Data "Poniedzialek" , "Wtorek" , "{001}roda" , "Czwartek" , "Piatek" , "Sobota" , "Niedziela"
Gdzie jest blad ?
Co robie nie tak ?
ESP8266 mam ustawiony na 9600 a nie na 115200 wiec powinno chyba ruszyc a nie chce