From 4ec7e493520d558dd05e911b58ea354d25f33f45 Mon Sep 17 00:00:00 2001 From: Martin Ashby Date: Mon, 28 May 2018 11:40:30 +0100 Subject: Started animated implementation --- unicorn/Unicorn2.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 unicorn/Unicorn2.go (limited to 'unicorn/Unicorn2.go') diff --git a/unicorn/Unicorn2.go b/unicorn/Unicorn2.go new file mode 100644 index 0000000..716fe4d --- /dev/null +++ b/unicorn/Unicorn2.go @@ -0,0 +1,32 @@ +// Version 2 of unicorn, uses gif.GIF as store of pixels +// & a separate goroutine to render it so it can do +// animated GIFs +package unicorn + +import ( + "image/gif" +) + +// Unicorn2 ... +// Interface for interacting with the Unicorn HAT HD +// Implemented by both real & fake unicorns. +type Unicorn2 interface { + GetGif() *gif.GIF + SetGif(*gif.GIF) + + StartRender() + // Required for os to not think we're stuck + MainLoop() +} + +type BaseUnicorn2 struct { + g *gif.GIF +} + +func (u *BaseUnicorn2) GetGif() *gif.GIF { + return u.g +} + +func (u *BaseUnicorn2) SetGif(g *gif.GIF) { + u.g = g +} -- cgit v1.2.3-ZIG