Hey all again,
I am now at the point with my project that I need to write some basic "alarm clock functions". I would like to use the NES controller to increment hour and minutes. My plan was just to simply save a combination of bits (certain button presses), read this combination against possible outcomes, and jump to the code to react accordingly.
For my way, I wanted to use the combination %11011110 (down and A buttons are pressed) for incrementing the hour and %11011101 (down and B buttons are pressed) to increment the minutes. I will not decrement, just rollover the display back to zero by the use of code cases. After all this, write the new changed hour/minute on the DS1307 and then have it displayed.
I do manage to read the NES controller data just fine and the correct current time displays fine but I still cannot seem to get things incrementing (I am only trying the hours first). Here is my code for the incrementing part:
I am not worrying about optimization yet, I am just trying to see if I set time with the controller.
I am now at the point with my project that I need to write some basic "alarm clock functions". I would like to use the NES controller to increment hour and minutes. My plan was just to simply save a combination of bits (certain button presses), read this combination against possible outcomes, and jump to the code to react accordingly.
For my way, I wanted to use the combination %11011110 (down and A buttons are pressed) for incrementing the hour and %11011101 (down and B buttons are pressed) to increment the minutes. I will not decrement, just rollover the display back to zero by the use of code cases. After all this, write the new changed hour/minute on the DS1307 and then have it displayed.
I do manage to read the NES controller data just fine and the correct current time displays fine but I still cannot seem to get things incrementing (I am only trying the hours first). Here is my code for the incrementing part:
Code:
Read_NES_Controller:
pulsout neslatch,1 'latch the data into the NES controller's 4021
gosub Shiftin_LSB_Pre 'shift in the button data from the NES controller
let nesregister = var_in
'//Set Alarm 1
'//Set Alarm 2
'//Set ???????
'//Set Current Time
if nesregister = %11011110 then goto Set_Time_Hour'"down" and "A" are pressed
'if nesregister = %11011101 then goto Set_Time_Minute'"down" and "B" are pressed
Set_Time_Hour:
hi2cin 1,(minute,hour) 'obtain minute and hour information from DS1307
bcdtoascii hour,hourtens,hourones 'convert hour data to ascii
let hourtens = hourtens - $30 'convert "hourtens" to decimal
let hourones = hourones - $30 'convert "hourones" to decimal
if hour = $23 then goto Rollover 'if last hour of day is shown,roll up
select case hourones 'investigate hourones
case < 9 'if ones place of hours is less than nine...
let hour = hour + 1 '...then add one to current hour
case > 9 'if ones place of hours is more than nine...
let hour = hour + 6 '...then add six (hex remember?) to get "0"
endselect 'stop investigating
goto Done_Setting_Hour 'go to write to DS1307 new hour
Rollover:
let hour = $00 'hour was $23 so change to $00 (rollover)
goto Done_Setting_Hour 'go to write to DS1307 new hour
Done_Setting_Hour:
hi2cout 2,(hour) 'write to DS1307 new hour
loop