setnewdatex:
serout OLED,Baud,(254,212,"D ",#tempday,",M ",#tempmonth,",D ",#tempdate,",Y 20",#tempyear)
irin [100],b.4,infracnt
serout OLED,Baud,(254,128)
serout OLED,Baud,(" DATE MENU ")
serout OLED,Baud,(254,192)
serout OLED,Baud,("1 - Day 2 - Month")
serout OLED,Baud,(254,148)
serout OLED,Baud,("3 - Date 4 - Year ")
pause 20
serout OLED,Baud,(254,128)
if infracnt = KEY_1 then
tune Piezo, 5,($40)
serout OLED,Baud,(254,1)
pause 300
b29=6
gosub setDay
endif
if infracnt = KEY_2 then
tune Piezo, 5,($40)
serout OLED,Baud,(254,1)
pause 300
gosub SetMonth
endif
if infracnt = KEY_3 then
tune Piezo, 5,($40)
serout OLED,Baud,(254,1)
pause 300
gosub SetDate2
endif
if infracnt = KEY_4 then
tune Piezo, 5,($40)
serout OLED,Baud,(254,1)
pause 300
gosub SetYear
endif
if infracnt = KEY_OK then
tune Piezo, 5,($40)
serout OLED,Baud,(254,1)
gosub updateDate
pause 100
counter = 0
Return
endif
infracnt =200
goto SetnewDatex
SetMonth:
serout OLED,Baud,(254,128)
serout OLED,Baud,(" MONTH ",179,180)
irin [100],b.4,infracnt
if infracnt = KEY_UP then
tune Piezo, 5,($40)
TempMonth = TempMonth + 1
endif
if infracnt = KEY_DOWN then
tune Piezo, 5,($40)
TempMonth = TempMonth -1
endif
if TempMonth > 12 then
TempMonth = 1
endif
if TempMonth <1 then
TempMonth = 12
endif
serout OLED,Baud,(254,192)
select case TempMonth
case 1
serout OLED,Baud,(" January ")
case 2
serout OLED,Baud,(" February ")
case 3
serout OLED,Baud,(" March ")
case 4
serout OLED,Baud,(" April ")
case 5
serout OLED,Baud,(" May ")
case 6
serout OLED,Baud,(" June ")
case 7
serout OLED,Baud,(" July ")
case 8
serout OLED,Baud,(" August ")
case 9
serout OLED,Baud,(" September ")
case 10
serout OLED,Baud,(" October ")
case 11
serout OLED,Baud,(" November ")
case 12
serout OLED,Baud,(" December ")
endselect
if infracnt = KEY_OK then
tune Piezo, 5,($40)
infracnt = 200
serout OLED,Baud,(254,1)
pause 1000
return
endif
infracnt = 200
goto setMonth
setDate2:
serout OLED,Baud,(254,128)
serout OLED,Baud,("SET DATE ",179,180)
irin [100],b.4,infracnt
if infracnt = KEY_UP then
tune Piezo, 5,($40)
TempDate = TempDate + 1
endif
if infracnt = KEY_DOWN then
tune Piezo, 5,($40)
TempDate = TempDate -1
endif
if TempDate > 31 then
TempDate = 1
endif
if TempDate <1 then
TempDate = 31
endif
BINtoascii TempDate,AsciiData3,AsciiData2,AsciiData1
serout OLED,Baud,(254,192)
serout OLED,Baud,("Date - ",AsciiData2,AsciiData1)
if infracnt = KEY_OK then
tune Piezo, 5,($40)
infracnt = 200
serout OLED,Baud,(254,1)
pause 1000
return
endif
infracnt = 200
goto setDate2
SetYear:
irin [100],b.4,infracnt
serout OLED,Baud,(254,128)
serout OLED,Baud,(" SET YEAR ",179,180)
if infracnt = KEY_UP then
tune Piezo, 5,($40)
TempYear = TempYear +1
endif
if infracnt = KEY_DOWN then
tune Piezo, 5,($40)
TempYear = TempYear -1
endif
if TempYear > 20 then
TempYear = 20
endif
if TempYear <1 then
TempYear = 1
endif
BINtoascii TempYear,AsciiData3,AsciiData2,AsciiData1
serout OLED,Baud,(254,192)
serout OLED,Baud,("year - 20",AsciiData2,AsciiData1)
if infracnt = KEY_OK then
infracnt = 200
serout OLED,Baud,(254,1)
pause 1000
return
endif
infracnt = 200
goto setYear
UpdateDate: 'Write new Date data to DS1307
hi2csetup i2cmaster, %11010000, i2cslow, i2cbyte 'Set I2C address for DS1307
month = TempMonth / 10 * 16 'convert OFF time setting to BCD format
month = TempMonth // 10 | month
date = tempdate / 10 * 16 'convert OFF time setting to BCD format
date = tempdate // 10 | date
day = TempDay / 10 * 16 'convert OFF time setting to BCD format
day = TempDay // 10 | day
year = tempyear / 10 * 16 'convert OFF time setting to BCD format
year = tempyear // 10 | year
let control = %00010000 ' Enable output at 1Hz
hi2cout 3,(day,date,month,year,control,255) 'Write new data to DS1307
pause 20
return
' .------------------------------------------.
' | Update Clock, Date and Menu |
' `------------------------------------------'
SetTime: 'Menu 3 Set Alarm Time or Clock Time depending on the value of B29
hi2csetup i2cmaster, %11010000, i2cslow, i2cbyte
hi2cin 1,(tempminutes,temphour)
if temphour>10 then let temphour=temphour-6:endif
for aux= 10 to 50 step 10
if tempminutes>aux then let tempminutes=tempminutes-6:endif
next aux
settimex:
irin [100],b.4,infracnt
serout OLED,Baud,(254,128)
if Selected = 3 then
serout OLED,Baud,("ALARM MENU ")
serout OLED,Baud,(254,212)
serout OLED,Baud,("3 - Set Day ")
else
serout OLED,Baud,(254,128)
serout OLED,Baud,(" TIME MENU ")
endif
serout OLED,Baud,(254,192)
serout OLED,Baud,("1 - Set Hour ")
serout OLED,Baud,(254,148)
serout OLED,Baud,("2 - Set Minute ")
select case infracnt
Case KEY_1
tune Piezo, 5,($40)
serout OLED,Baud,(254,1)
pause 300
gosub sethour
case KEY_2
tune Piezo, 5,($40)
serout OLED,Baud,(254,1)
pause 300
gosub Setmin
Case KEY_3
tune Piezo, 5,($40)
serout OLED,Baud,(254,1)
pause 300
gosub SetDay
Case KEY_OK
tune Piezo, 5,($40)
serout OLED,Baud,(254,1)
if Selected = 1 then
gosub updatetime 'Update DS1307
endif
if Selected = 3 then
gosub updateAlarm 'Update EEPROM
endif
pause 100
counter = 0
Return
endselect
infracnt =200
goto SetTimex
sethour:
irin [100],b.4,infracnt
gosub TimeDate24
serout OLED,Baud,(254,192,179,180)
if infracnt = KEY_UP then
tune Piezo, 5,($40)
TempHour = TempHour + 1
endif
if infracnt = KEY_DOWN then
tune Piezo, 5,($40)
TempHour = TempHour -1
endif
if TempHour > 23 then
TempHour = 0
endif
if TempHour =0 and infracnt =KEY_DOWN then let TempHour = 23:endif
BINtoascii TempHour,AsciiData3,AsciiData2,AsciiData1
serout OLED,Baud,(254,195)
serout OLED,Baud,("hour - ",AsciiData2,AsciiData1)
if infracnt = KEY_OK then
tune Piezo, 5,($40)
infracnt = 200
serout OLED,Baud,(254,1)
pause 1000
return
endif
infracnt = 200
goto sethour
setmin:
irin [100],b.4,infracnt
gosub TimeDate24
serout OLED,Baud,(254,192,179,180)
if infracnt = KEY_UP then
tune Piezo, 5,($40)
TempMinutes = TempMinutes + 1
endif
if infracnt = KEY_DOWN then
tune Piezo, 5,($40)
TempMinutes =TempMinutes -1
endif
if TempMinutes > 59 then
TempMinutes = 0
endif
if TempMinutes =0 and infracnt =key_down then let TempMinutes = 59:endif
BINtoascii TempMinutes,AsciiData3,AsciiData2,AsciiData1
serout OLED,Baud,(254,195)
serout OLED,Baud,("Minute - ",AsciiData2,AsciiData1)
if infracnt = KEY_OK then
tune Piezo, 5,($40)
infracnt = 200
serout OLED,Baud,(254,1)
pause 1000
return
endif
infracnt = 200
goto setmin
setDay:
hi2csetup i2cmaster, %11010000, i2cslow, i2cbyte
hi2cin 3,(tempday)
setdayx:
serout OLED,Baud,(254,128)
serout OLED,Baud,(254,192,179,180)
irin [100],b.4,infracnt
if infracnt = KEY_UP then tune Piezo, 5,($40) let Tempday = Tempday + 1: endif
if infracnt = KEY_DOWN then tune Piezo, 5,($40) let Tempday =Tempday -1: endif
if Selected = 6 then
if tempday > 7 then
tempday = 1
endif
if Tempday <1 then
Tempday = 7
endif
endif
if Selected = 3 then
if Tempday > 10 then
Tempday = 1
endif
if Tempday <1 then
Tempday = 10
endif
endif
serout OLED,Baud,(254,195)
DispDay = Tempday
gosub DisplayDay
if infracnt = KEY_OK then
tune Piezo, 5,($40)
infracnt = 200
serout OLED,Baud,(254,1)
pause 1000
return
endif
infracnt = 200
goto setDayx
DisplayDay:
select case DispDay
case 1
serout OLED,Baud,(" Sunday ")
case 2
serout OLED,Baud,(" Monday ")
case 3
serout OLED,Baud,(" Tueday ")
case 4
serout OLED,Baud,("Wednesday ")
case 5
serout OLED,Baud,(" Thursday ")
case 6
serout OLED,Baud,(" Friday ")
case 7
serout OLED,Baud,(" Saturday ")
case 8
serout OLED,Baud,("Week Days ")
case 9
serout OLED,Baud,("Every Day ")
case 10
serout OLED,Baud,("Week Ends ")
endselect
return
Chime15: '15 min chime
tune Piezo, 8,($07,$05);,$04,$AB
pause 10000
return
Chime30: '30 min chime
tune Piezo, 8,($04,$07);,$05,$AB,$04,$05,$07,$84
pause 10000
return
Chime45: '45 min chime
tune Piezo, 8,($07,$04) ;,$05,$AB,$2B,$05,$07,$84,$07,$05,$04,$AB
pause 10000
return
chimehour: ' hour chime
;tune Piezo, 8,(04,$07,$05,$AB,$04,$05,$07,$84,$07,$04,$05,$AB,$2B,$05,$07,$84)
;pause 200
for counter = 1 to temphour
tune Piezo, 8,($19)
pause 2000
next counter
return