Added in PiGlow devLib and a couple of examples for the PiGlow
bumped version.
This commit is contained in:
@@ -42,7 +42,8 @@ LIBS =
|
||||
|
||||
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)
|
||||
|
||||
@@ -86,6 +87,7 @@ install-headers:
|
||||
@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
|
||||
@@ -111,6 +113,7 @@ uninstall:
|
||||
@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
|
||||
|
||||
@@ -128,3 +131,4 @@ gertboard.o: gertboard.h
|
||||
piFace.o: piFace.h
|
||||
lcd128x64.o: font.h lcd128x64.h
|
||||
lcd.o: lcd.h
|
||||
piGlow.o: piGlow.h
|
||||
|
||||
117
devLib/piGlow.c
Normal file
117
devLib/piGlow.c
Normal file
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* 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) ;
|
||||
}
|
||||
36
devLib/piGlow.h
Normal file
36
devLib/piGlow.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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
|
||||
Reference in New Issue
Block a user