Some code for the DotStar LED on ItsyBitsy M4 board


#1

Hi,

I wrote some code to access the dotstar led on the itsybitsy m4 board
To use first enter (initdot*) and then you can use (setdot* red green blue)
red green and blue are values ranging from 0 to 255.
Enjoy !

;; ----------------------------
;; ITSYBITSY M4 DOTSTAR SUPPORT
;; ----------------------------

(defvar clkdot* 6)
(defvar datdot* 8)

(defun initdot* ()
(pinmode clkdot* 1)
(pinmode datdot* 1)
(digitalwrite clkdot* t))

(defun 320 ()
(digitalwrite datdot
nil)
(dotimes (x 32)
(digitalwrite clkdot* nil)
(digitalwrite clkdot* t)))

(defun 321 ()
(digitalwrite datdot
t)
(dotimes (x 32)
(digitalwrite clkdot* nil)
(digitalwrite clkdot* t)))

(defun setdot* (red green blue)
(320)
(let (val)
(setq val (+ (
blue 65536) (* green 256) red ))
(setq val (logior #xff000000 val))
(dotimes (x 32)
(if (logbitp 31 val) (digitalwrite datdot* t) (digitalwrite datdot* nil))
(digitalwrite clkdot* nil)
(digitalwrite clkdot* t)
(setq val (ash val 1))))
(32*1))

(defun test ()
(loop
(setdot* (random 256) (random 256) (random 256))
(delay 1000)))

Regards Ronny Suy