mirror of
https://github.com/tjboldt/Apple2-IO-RPi.git
synced 2024-11-24 15:31:14 +00:00
Refactor time command to use library
This commit is contained in:
parent
0d73855663
commit
2778b50b1e
@ -5,40 +5,16 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/tjboldt/Apple2-IO-RPi/RaspberryPi/apple2driver/a2io"
|
||||
"github.com/tjboldt/ProDOS-Utilities/prodos"
|
||||
)
|
||||
|
||||
func GetTimeCommand() {
|
||||
fmt.Printf("Sending date/time...\n")
|
||||
/* 49041 ($BF91) 49040 ($BF90)
|
||||
prodosTime := prodos.DateTimeToProDOS(time.Now())
|
||||
|
||||
7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
|
||||
+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+
|
||||
DATE: | year | month | day |
|
||||
+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+
|
||||
for i := 0; i < len(prodosTime); i++ {
|
||||
a2io.WriteByte(prodosTime[i])
|
||||
}
|
||||
|
||||
7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
|
||||
+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+
|
||||
TIME: | hour | | minute |
|
||||
+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+
|
||||
|
||||
49043 ($BF93) 49042 ($BF92)
|
||||
*/
|
||||
now := time.Now()
|
||||
|
||||
year := now.Year() % 100
|
||||
month := now.Month()
|
||||
day := now.Day()
|
||||
hour := now.Hour()
|
||||
minute := now.Minute()
|
||||
|
||||
bf91 := (byte(year) << 1) + (byte(month) >> 3)
|
||||
bf90 := ((byte(month) & 15) << 5) + byte(day)
|
||||
bf93 := byte(hour)
|
||||
bf92 := byte(minute)
|
||||
|
||||
a2io.WriteByte(bf90)
|
||||
a2io.WriteByte(bf91)
|
||||
a2io.WriteByte(bf92)
|
||||
a2io.WriteByte(bf93)
|
||||
fmt.Printf("Send time complete\n")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user