initial upload

This commit is contained in:
Harald Pichler 2016-01-22 15:41:55 +01:00
parent c2f9c584b9
commit fce1b561da
17 changed files with 737 additions and 0 deletions

View file

@ -0,0 +1,16 @@
//***********************************************************************
//
// Name:LEDStripDriver liararies v0.9b for Grove - LED Strip Driver v0.9b
// Author:Frankie.Chu at Seeed Studio.
// Date:March 9,2012
// Version:0.9b
// Software platform:Arduino-1.0
// Hardware platform:Arduino UNO/Seeeduino/Arduino Mega +
// Grove - LED Strip Driver v0.9b
// Demo code:
// DualLEDStrip:Light the two LED strips with two driver.
// SingleLEDStrip:Light the single LED strip.
// DemoForWhiteLEDStrip:Light the White LED Flexi-Strip.
// Default:"-"pin of it is connected to "B" of the driver.
//
//***********************************************************************

View file

@ -0,0 +1,107 @@
// This library 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 2.1 of the License, or (at your option) any later version.
//
// This library 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 this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// Modified Record:
/***************************************************************************/
#include "RGBdriver.h"
RGBdriver::RGBdriver(uint8_t Clk, uint8_t Data)
{
Clkpin = Clk;
Datapin = Data;
pinMode(Datapin, OUTPUT);
pinMode(Clkpin, OUTPUT);
}
void RGBdriver::begin(void)
{
Send32Zero();
}
void RGBdriver::end(void)
{
Send32Zero();
}
void RGBdriver::ClkRise(void)
{
digitalWrite(Clkpin, LOW);
delayMicroseconds(20);
digitalWrite(Clkpin, HIGH);
delayMicroseconds(20);
}
void RGBdriver::Send32Zero(void)
{
unsigned char i;
for (i=0; i<32; i++)
{
digitalWrite(Datapin, LOW);
ClkRise();
}
}
uint8_t RGBdriver::TakeAntiCode(uint8_t dat)
{
uint8_t tmp = 0;
if ((dat & 0x80) == 0)
{
tmp |= 0x02;
}
if ((dat & 0x40) == 0)
{
tmp |= 0x01;
}
return tmp;
}
// gray data
void RGBdriver::DatSend(uint32_t dx)
{
uint8_t i;
for (i=0; i<32; i++)
{
if ((dx & 0x80000000) != 0)
{
digitalWrite(Datapin, HIGH);
}
else
{
digitalWrite(Datapin, LOW);
}
dx <<= 1;
ClkRise();
}
}
// Set color
void RGBdriver::SetColor(uint8_t Red,uint8_t Green,uint8_t Blue)
{
uint32_t dx = 0;
dx |= (uint32_t)0x03 << 30; // highest two bits 1flag bits
dx |= (uint32_t)TakeAntiCode(Blue) << 28;
dx |= (uint32_t)TakeAntiCode(Green) << 26;
dx |= (uint32_t)TakeAntiCode(Red) << 24;
dx |= (uint32_t)Blue << 16;
dx |= (uint32_t)Green << 8;
dx |= Red;
DatSend(dx);
}

View file

@ -0,0 +1,20 @@
#ifndef RGB_DRIVER_H
#define RGB_DRIVER_H
#include <inttypes.h>
#include <Arduino.h>
class RGBdriver
{
public:
RGBdriver(uint8_t, uint8_t);
void begin(void);
void end(void);
void ClkRise(void);
void Send32Zero(void);
uint8_t TakeAntiCode(uint8_t dat);
void DatSend(uint32_t dx);
void SetColor(uint8_t Red,uint8_t Green,uint8_t Blue);
private:
uint8_t Clkpin;
uint8_t Datapin;
};
#endif

View file

@ -0,0 +1,44 @@
// Author:Frankie.Chu
// Date:March 9,2012
// This library 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 2.1 of the License, or (at your option) any later version.
//
// This library 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 this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
/***************************************************************************/
#include "RGBdriver.h"
#define CLK 2//pins definitions for the driver
#define DIO 3
RGBdriver Driver(CLK,DIO);
void setup()
{
}
void loop()
{
unsigned int i;
while(1){
for(i = 0;i < 256;i ++)
{
Driver.begin(); // begin
Driver.SetColor(0,0,i); //Blue. First node data. SetColor(R,G,B)
Driver.end();
delay(10);
}
for(i = 255;i > 0;i --)
{
Driver.begin(); // begin
Driver.SetColor(0,0,i); //Blue. first node data
Driver.end();
delay(10);
}
}
}

View file

@ -0,0 +1,42 @@
// Author:Frankie.Chu
// Date:March 9,2012
// This library 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 2.1 of the License, or (at your option) any later version.
//
// This library 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 this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
/***************************************************************************/
#include "RGBdriver.h"
#define CLK 2//pins definitions for the driver
#define DIO 3
RGBdriver Driver(CLK,DIO);
void setup()
{
}
void loop()
{
Driver.begin(); // begin
Driver.SetColor(255, 0, 0); //Red. first node data
Driver.SetColor(0, 0, 255); //Blue. second node data
Driver.end();
delay(500);
Driver.begin(); // begin
Driver.SetColor(0, 0, 255); //Blue. first node data
Driver.SetColor(0, 255, 0); //Green. second node data
Driver.end();
delay(500);
Driver.begin(); // begin
Driver.SetColor(0, 255, 0); //Green. first node data
Driver.SetColor(255, 0, 0); //Red. second node data
Driver.end();
delay(500);
}

View file

@ -0,0 +1,39 @@
// Author:Frankie.Chu
// Date:March 9,2012
// This library 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 2.1 of the License, or (at your option) any later version.
//
// This library 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 this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
/***************************************************************************/
#include "RGBdriver.h"
#define CLK 2//pins definitions for the driver
#define DIO 3
RGBdriver Driver(CLK,DIO);
void setup()
{
}
void loop()
{
Driver.begin(); // begin
Driver.SetColor(255, 0, 0); //Red. first node data
Driver.end();
delay(500);
Driver.begin(); // begin
Driver.SetColor(0, 255, 0); //Green. first node data
Driver.end();
delay(500);
Driver.begin(); // begin
Driver.SetColor(0, 0, 255);//Blue. first node data
Driver.end();
delay(500);
}