adding to lisp library
This commit is contained in:
@@ -172,5 +172,31 @@ Returns a list with all items for which tst is true removed from lst."
|
||||
Returns a list with all items for which tst is false removed from lst."
|
||||
(mapcan #'(lambda (x) (when (funcall tst x) (list x))) lst))
|
||||
|
||||
(defun rtc-set (hr min)
|
||||
"(rtc-set hr min)
|
||||
Set the time on a DS3231 RTC. Times are in BCD, so use
|
||||
the appropriate reader macro, e.g. (rtc-set #x12 #x34)
|
||||
for 12:34. Assumes seconds are zero."
|
||||
(with-i2c (str #x68)
|
||||
(write-byte 0 str)
|
||||
(write-byte 0 str)
|
||||
(write-byte min str)
|
||||
(write-byte hr str)))
|
||||
|
||||
(defun rtc-get ()
|
||||
(with-i2c (str #x68)
|
||||
(write-byte 0 str)
|
||||
(restart-i2c str 3)
|
||||
(reverse
|
||||
(list
|
||||
(read-byte str)
|
||||
(read-byte str)
|
||||
(read-byte str)))))
|
||||
|
||||
(defun rtc-now ()
|
||||
"(rtc-now)
|
||||
Set the time using the RTC."
|
||||
(now (rtc-get)))
|
||||
|
||||
)lisplibrary";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user