bumped version.
SRC = ds1302.c maxdetect.c piNes.c \
gertboard.c piFace.c \
- lcd128x64.c lcd.c
+ lcd128x64.c lcd.c \
+ piGlow.c
OBJ = $(SRC:.c=.o)
@install -m 0644 piFace.h $(DESTDIR)$(PREFIX)/include
@install -m 0644 lcd128x64.h $(DESTDIR)$(PREFIX)/include
@install -m 0644 lcd.h $(DESTDIR)$(PREFIX)/include
+ @install -m 0644 piGlow.h $(DESTDIR)$(PREFIX)/include
.PHONEY: install
install: $(DYNAMIC) install-headers
@rm -f $(DESTDIR)$(PREFIX)/include/piFace.h
@rm -f $(DESTDIR)$(PREFIX)/include/lcd128x64.h
@rm -f $(DESTDIR)$(PREFIX)/include/lcd.h
+ @rm -f $(DESTDIR)$(PREFIX)/include/piGlow.h
@rm -f $(DESTDIR)$(PREFIX)/lib/libwiringPiDev.*
@ldconfig
piFace.o: piFace.h
lcd128x64.o: font.h lcd128x64.h
lcd.o: lcd.h
+piGlow.o: piGlow.h
--- /dev/null
+/*
+ * piGlow.c:
+ * Easy access to the Pimoroni PiGlow board.
+ *
+ * Copyright (c) 2013 Gordon Henderson.
+ ***********************************************************************
+ * This file is part of wiringPi:
+ * https://projects.drogon.net/raspberry-pi/wiringpi/
+ *
+ * wiringPi is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * wiringPi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with wiringPi. If not, see <http://www.gnu.org/licenses/>.
+ ***********************************************************************
+ */
+
+#include <wiringPi.h>
+#include <sn3218.h>
+
+#include "piGlow.h"
+
+static int myBase ;
+
+static int leg0 [6] = { 6, 7, 8, 5, 4, 9 } ;
+static int leg1 [6] = { 17, 16, 15, 13, 11, 10 } ;
+static int leg2 [6] = { 0, 1, 2, 3, 14, 12 } ;
+
+
+/*
+ * piGlow1:
+ * Light up an individual LED
+ *********************************************************************************
+ */
+
+void piGlow1 (const int leg, const int ring, const int intensity)
+{
+ int *legLeds ;
+
+ if ((leg < 0) || (leg > 2)) return ;
+ if ((ring < 0) || (ring > 5)) return ;
+
+ /**/ if (leg == 0)
+ legLeds = leg0 ;
+ else if (leg == 1)
+ legLeds = leg1 ;
+ else
+ legLeds = leg2 ;
+
+ analogWrite (myBase + legLeds [ring], intensity) ;
+}
+
+/*
+ * piGlowLeg:
+ * Light up all 6 LEDs on a leg
+ *********************************************************************************
+ */
+
+void piGlowLeg (const int leg, const int intensity)
+{
+ int i ;
+ int *legLeds ;
+
+ if ((leg < 0) || (leg > 2))
+ return ;
+
+ /**/ if (leg == 0)
+ legLeds = leg0 ;
+ else if (leg == 1)
+ legLeds = leg1 ;
+ else
+ legLeds = leg2 ;
+
+ for (i = 0 ; i < 6 ; ++i)
+ analogWrite (myBase + legLeds [i], intensity) ;
+}
+
+
+/*
+ * piGlowRing:
+ * Light up 3 LEDs in a ring. Ring 0 is the outermost, 5 the innermost
+ *********************************************************************************
+ */
+
+void piGlowRing (const int ring, const int intensity)
+{
+ if ((ring < 0) || (ring > 5))
+ return ;
+
+ analogWrite (myBase + leg0 [ring], intensity) ;
+ analogWrite (myBase + leg1 [ring], intensity) ;
+ analogWrite (myBase + leg2 [ring], intensity) ;
+}
+
+/*
+ * piGlowSetup:
+ * Initialise the board & remember the pins we're using
+ *********************************************************************************
+ */
+
+void piGlowSetup (const int pinBase)
+{
+ sn3218Setup (myBase = pinBase) ;
+
+// Turn all off to start with
+
+ piGlowLeg (0, 0) ;
+ piGlowLeg (1, 0) ;
+ piGlowLeg (2, 0) ;
+}
--- /dev/null
+/*
+ * piglow.h:
+ * Easy access to the Pimoroni PiGlow board.
+ *
+ * Copyright (c) 2013 Gordon Henderson.
+ ***********************************************************************
+ * This file is part of wiringPi:
+ * https://projects.drogon.net/raspberry-pi/wiringpi/
+ *
+ * wiringPi is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * wiringPi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with wiringPi. If not, see <http://www.gnu.org/licenses/>.
+ ***********************************************************************
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern void piGlow1 (const int leg, const int ring, const int intensity) ;
+extern void piGlowLeg (const int leg, const int intensity) ;
+extern void piGlowRing (const int ring, const int intensity) ;
+extern void piGlowSetup (const int pinBase) ;
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null
+#
+# Makefile:
+# wiringPi - Wiring Compatable library for the Raspberry Pi
+# https://projects.drogon.net/wiring-pi
+#
+# Copyright (c) 2012-2013 Gordon Henderson
+#################################################################################
+# This file is part of wiringPi:
+# Wiring Compatable library for the Raspberry Pi
+#
+# wiringPi is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# wiringPi is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with wiringPi. If not, see <http://www.gnu.org/licenses/>.
+#################################################################################
+
+
+#DEBUG = -g -O0
+DEBUG = -O3
+CC = gcc
+INCLUDE = -I/usr/local/include
+CFLAGS = $(DEBUG) -Wall $(INCLUDE) -Winline -pipe
+
+LDFLAGS = -L/usr/local/lib
+LDLIBS = -lwiringPi -lwiringPiDev -lpthread -lm
+
+# Should not alter anything below this line
+###############################################################################
+
+SRC = piGlow0.c piGlow1.c
+
+OBJ = $(SRC:.c=.o)
+
+BINS = $(SRC:.c=)
+
+all: $(BINS)
+
+piGlow0: piGlow0.o
+ @echo [link]
+ @$(CC) -o $@ piGlow0.o $(LDFLAGS) $(LDLIBS)
+
+piGlow1: piGlow1.o
+ @echo [link]
+ @$(CC) -o $@ piGlow1.o $(LDFLAGS) $(LDLIBS)
+
+.c.o:
+ @echo [CC] $<
+ @$(CC) -c $(CFLAGS) $< -o $@
+
+clean:
+ @echo "[Clean]"
+ @rm -f $(OBJ) *~ core tags $(BINS)
+
+tags: $(SRC)
+ @echo [ctags]
+ @ctags $(SRC)
+
+depend:
+ makedepend -Y $(SRC)
+
+# DO NOT DELETE
--- /dev/null
+/*
+ * piGlow1.c:
+ * Very simple demonstration of the PiGlow board.
+ * This uses the piGlow devLib.
+ *
+ * Copyright (c) 2013 Gordon Henderson.
+ ***********************************************************************
+ * This file is part of wiringPi:
+ * https://projects.drogon.net/raspberry-pi/wiringpi/
+ *
+ * wiringPi is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * wiringPi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with wiringPi. If not, see <http://www.gnu.org/licenses/>.
+ ***********************************************************************
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <poll.h>
+
+#include <wiringPi.h>
+#include <piGlow.h>
+
+#define PIGLOW_BASE 533
+
+
+/*
+ * keypressed: clearKeypressed:
+ * Simple but effective ways to tell if the enter key has been pressed
+ *********************************************************************************
+ */
+
+static int keypressed (void)
+{
+ struct pollfd polls ;
+
+ polls.fd = fileno (stdin) ;
+ polls.events = POLLIN ;
+
+ return poll (&polls, 1, 0) != 0 ;
+}
+
+static void clearKeypressed (void)
+{
+ while (keypressed ())
+ (void)getchar () ;
+}
+
+
+/*
+ * pulseLed:
+ * Pulses the LED at position leg, ring from off to a max. value,
+ * then off again
+ *********************************************************************************
+ */
+
+static void pulseLed (int leg, int ring)
+{
+ int i ;
+
+ for (i = 0 ; i < 140 ; ++i)
+ {
+ piGlow1 (leg, ring, i) ;
+ delay (1) ;
+ }
+ delay (10) ;
+ for (i = 140 ; i >= 0 ; --i)
+ {
+ piGlow1 (leg, ring, i) ;
+ delay (1) ;
+ }
+}
+
+/*
+ * pulseLeg:
+ * Same as above, but a whole leg at a time
+ *********************************************************************************
+ */
+
+static void pulseLeg (int leg)
+{
+ int i ;
+
+ for (i = 0 ; i < 140 ; ++i)
+ {
+ piGlowLeg (leg, i) ; delay (1) ;
+ }
+ delay (10) ;
+ for (i = 140 ; i >= 0 ; --i)
+ {
+ piGlowLeg (leg, i) ; delay (1) ;
+ }
+}
+
+
+/*
+ * pulse Ring:
+ * Same as above, but a whole ring at a time
+ *********************************************************************************
+ */
+
+static void pulseRing (int ring)
+{
+ int i ;
+
+ for (i = 0 ; i < 140 ; ++i)
+ {
+ piGlowRing (ring, i) ; delay (1) ;
+ }
+ delay (10) ;
+ for (i = 140 ; i >= 0 ; --i)
+ {
+ piGlowRing (ring, i) ; delay (1) ;
+ }
+}
+
+
+/*
+ * main:
+ * Our little demo prgoram
+ *********************************************************************************
+ */
+
+int main (void)
+{
+ int i ;
+ int ring, leg ;
+
+// Always initialise wiringPi:
+// Use the Sys method if you don't need to run as root
+
+ wiringPiSetupSys () ;
+
+// Initialise the piGlow devLib with our chosen pin base
+
+ piGlowSetup (PIGLOW_BASE) ;
+
+// LEDs, one at a time
+
+ printf ("LEDs, one at a time\n") ;
+ for (; !keypressed () ;)
+ for (leg = 0 ; leg < 3 ; ++leg)
+ {
+ for (ring = 0 ; ring < 6 ; ++ring)
+ {
+ pulseLed (leg, ring) ;
+ if (keypressed ())
+ break ;
+ }
+ if (keypressed ())
+ break ;
+ }
+ clearKeypressed () ;
+
+// Rings, one at a time
+
+ printf ("Rings, one at a time\n") ;
+ for (; !keypressed () ;)
+ for (ring = 0 ; ring < 6 ; ++ring)
+ {
+ pulseRing (ring) ;
+ if (keypressed ())
+ break ;
+ }
+ clearKeypressed () ;
+
+// Legs, one at a time
+
+ printf ("Legs, one at a time\n") ;
+ for (; !keypressed () ;)
+ for (leg = 0 ; leg < 3 ; ++leg)
+ {
+ pulseLeg (leg) ;
+ if (keypressed ())
+ break ;
+ }
+ clearKeypressed () ;
+
+ delay (1000) ;
+
+// Sequence - alternating rings, legs and random
+
+ printf ("Sequence now\n") ;
+
+ for (; !keypressed () ;)
+ {
+ for (i = 0 ; i < 20 ; ++i)
+ for (leg = 2 ; leg >= 0 ; --leg)
+ {
+ piGlowLeg (leg, 100) ;
+ delay (100) ;
+ piGlowLeg (leg, 0) ;
+ }
+
+ for (i = 0 ; i < 20 ; ++i)
+ for (ring = 5 ; ring >= 0 ; --ring)
+ {
+ piGlowRing (ring, 100) ;
+ delay (50) ;
+ piGlowRing (ring, 0) ;
+ }
+
+ for (i = 0 ; i < 1000 ; ++i)
+ {
+ leg = random () % 3 ;
+ ring = random () % 6 ;
+ piGlow1 (leg, ring, random () % 256) ;
+ delay (5) ;
+ piGlow1 (leg, ring, 0) ;
+ }
+ }
+
+ return 0 ;
+}
# define FALSE (1==2)
#endif
-#define VERSION "2.09"
+#define VERSION "2.10"
#define I2CDETECT "/usr/sbin/i2cdetect"
int wpMode ;