From 38b9b25d4612298f5599e7471568714ea1fa2a01 Mon Sep 17 00:00:00 2001 From: Elena ``of Valhalla'' Grandi Date: Fri, 14 Mar 2025 09:20:28 +0100 Subject: Moved arduino version in its own directory --- Colours.cpp | 86 ------------------------------ Colours.h | 38 ------------- examples/hue_rotation/hue_rotation.ino | 27 ---------- examples/wtfpl-2.txt | 14 ----- keywords.txt | 3 -- src/Colours.cpp | 86 ++++++++++++++++++++++++++++++ src/Colours.h | 38 +++++++++++++ src/examples/hue_rotation/hue_rotation.ino | 27 ++++++++++ src/examples/wtfpl-2.txt | 14 +++++ src/keywords.txt | 3 ++ 10 files changed, 168 insertions(+), 168 deletions(-) delete mode 100644 Colours.cpp delete mode 100644 Colours.h delete mode 100644 examples/hue_rotation/hue_rotation.ino delete mode 100644 examples/wtfpl-2.txt delete mode 100644 keywords.txt create mode 100644 src/Colours.cpp create mode 100644 src/Colours.h create mode 100644 src/examples/hue_rotation/hue_rotation.ino create mode 100644 src/examples/wtfpl-2.txt create mode 100644 src/keywords.txt diff --git a/Colours.cpp b/Colours.cpp deleted file mode 100644 index 7ae49a2..0000000 --- a/Colours.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Colours - library for managing the colours on RGB LEDs - * Copyright 2009, 2013 Elena Grandi - * - * This file is part of Colours. - * - * Colours 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. - * - * Colours 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 Colours. If not, see . - */ - -#include "Arduino.h" -#include "Colours.h" - -Colours::Colours(int rPin,int gPin,int bPin) { - _initPINs(rPin,gPin,bPin); - _invert = false; -} - -Colours::Colours(int rPin,int gPin,int bPin,bool invert) { - _initPINs(rPin,gPin,bPin); - _invert = invert; -} - -void Colours::_initPINs(int rPin,int gPin,int bPin) { - _rPin = rPin; - _gPin = gPin; - _bPin = bPin; - pinMode(_rPin,OUTPUT); - pinMode(_gPin,OUTPUT); - pinMode(_bPin,OUTPUT); -} - -void Colours::writeRGB(unsigned char r,unsigned char g,unsigned char b) { - if (_invert) { - analogWrite(_rPin, 255-r); - analogWrite(_gPin, 255-g); - analogWrite(_bPin, 255-b); - } else { - analogWrite(_rPin, r); - analogWrite(_gPin, g); - analogWrite(_bPin, b); - } -} - -void Colours::writeHSV(unsigned int h,unsigned char s,unsigned char v) { - h = h % 360; - if (s==0) { - writeRGB(v,v,v); - } else { - unsigned int f,p,q,t; - f = 256*(h%60)/60; - p = v*(256-s)/256; - q = v*(256-f*s/256)/256; - t = v*(256-s*(256-f)/256)/256; - switch( (h/60) % 6 ) { - case 0: - writeRGB(v,t,p); - break; - case 1: - writeRGB(q,v,p); - break; - case 2: - writeRGB(p,v,t); - break; - case 3: - writeRGB(p,q,v); - break; - case 4: - writeRGB(t,p,v); - break; - case 5: - writeRGB(v,p,q); - break; - } - } -} diff --git a/Colours.h b/Colours.h deleted file mode 100644 index 421dfc9..0000000 --- a/Colours.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Colours - library for managing the colours on RGB LEDs - * Copyright 2009, 2013 Elena Grandi - * - * This file is part of Colours. - * - * Colours 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. - * - * Colours 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 Colours. If not, see . - */ - -#ifndef COLOURS_h -#define COLOURS_h - -#include "Arduino.h" - -class Colours { - public: - Colours(int rPin,int gPin,int bPin); - Colours(int rPin,int gPin,int bPin,bool invert); - void writeRGB(unsigned char r,unsigned char g,unsigned char b); - void writeHSV(unsigned int h,unsigned char s,unsigned char v); - private: - int _rPin,_gPin,_bPin; - bool _invert; - void _initPINs(int rPin,int gPin,int bPin); -}; - -#endif diff --git a/examples/hue_rotation/hue_rotation.ino b/examples/hue_rotation/hue_rotation.ino deleted file mode 100644 index 00a48d7..0000000 --- a/examples/hue_rotation/hue_rotation.ino +++ /dev/null @@ -1,27 +0,0 @@ -/* - * hue_rotation - Cycle an RGB LED through hue values. - * Copyright 2009, 2013 Elena Grandi - * - * This work is free. You can redistribute it and/or modify it under the - * terms of the Do What The Fuck You Want To Public License, Version 2, - * as published by Sam Hocevar. See the examples/wtfpl-2.txt file - * for more details. - */ - -#include - -Colours colours(6,5,3); -// For common cathode RGB LEDs comment the line above and uncomment -// the one below. -//Colours colours(6,5,3,true); - -void setup() { -} - -void loop() { - int h; - for (h=0;h<360;h++) { - colours.writeHSV(h,255,255); - delay(50); - } -} diff --git a/examples/wtfpl-2.txt b/examples/wtfpl-2.txt deleted file mode 100644 index ee7d6a5..0000000 --- a/examples/wtfpl-2.txt +++ /dev/null @@ -1,14 +0,0 @@ - DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE - Version 2, December 2004 - - Copyright (C) 2004 Sam Hocevar - - Everyone is permitted to copy and distribute verbatim or modified - copies of this license document, and changing it is allowed as long - as the name is changed. - - DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. You just DO WHAT THE FUCK YOU WANT TO. - diff --git a/keywords.txt b/keywords.txt deleted file mode 100644 index 92dd91d..0000000 --- a/keywords.txt +++ /dev/null @@ -1,3 +0,0 @@ -Colours KEYWORD1 -writeRGB KEYWORD2 -writeHSV KEYWORD2 diff --git a/src/Colours.cpp b/src/Colours.cpp new file mode 100644 index 0000000..7ae49a2 --- /dev/null +++ b/src/Colours.cpp @@ -0,0 +1,86 @@ +/* + * Colours - library for managing the colours on RGB LEDs + * Copyright 2009, 2013 Elena Grandi + * + * This file is part of Colours. + * + * Colours 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. + * + * Colours 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 Colours. If not, see . + */ + +#include "Arduino.h" +#include "Colours.h" + +Colours::Colours(int rPin,int gPin,int bPin) { + _initPINs(rPin,gPin,bPin); + _invert = false; +} + +Colours::Colours(int rPin,int gPin,int bPin,bool invert) { + _initPINs(rPin,gPin,bPin); + _invert = invert; +} + +void Colours::_initPINs(int rPin,int gPin,int bPin) { + _rPin = rPin; + _gPin = gPin; + _bPin = bPin; + pinMode(_rPin,OUTPUT); + pinMode(_gPin,OUTPUT); + pinMode(_bPin,OUTPUT); +} + +void Colours::writeRGB(unsigned char r,unsigned char g,unsigned char b) { + if (_invert) { + analogWrite(_rPin, 255-r); + analogWrite(_gPin, 255-g); + analogWrite(_bPin, 255-b); + } else { + analogWrite(_rPin, r); + analogWrite(_gPin, g); + analogWrite(_bPin, b); + } +} + +void Colours::writeHSV(unsigned int h,unsigned char s,unsigned char v) { + h = h % 360; + if (s==0) { + writeRGB(v,v,v); + } else { + unsigned int f,p,q,t; + f = 256*(h%60)/60; + p = v*(256-s)/256; + q = v*(256-f*s/256)/256; + t = v*(256-s*(256-f)/256)/256; + switch( (h/60) % 6 ) { + case 0: + writeRGB(v,t,p); + break; + case 1: + writeRGB(q,v,p); + break; + case 2: + writeRGB(p,v,t); + break; + case 3: + writeRGB(p,q,v); + break; + case 4: + writeRGB(t,p,v); + break; + case 5: + writeRGB(v,p,q); + break; + } + } +} diff --git a/src/Colours.h b/src/Colours.h new file mode 100644 index 0000000..421dfc9 --- /dev/null +++ b/src/Colours.h @@ -0,0 +1,38 @@ +/* + * Colours - library for managing the colours on RGB LEDs + * Copyright 2009, 2013 Elena Grandi + * + * This file is part of Colours. + * + * Colours 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. + * + * Colours 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 Colours. If not, see . + */ + +#ifndef COLOURS_h +#define COLOURS_h + +#include "Arduino.h" + +class Colours { + public: + Colours(int rPin,int gPin,int bPin); + Colours(int rPin,int gPin,int bPin,bool invert); + void writeRGB(unsigned char r,unsigned char g,unsigned char b); + void writeHSV(unsigned int h,unsigned char s,unsigned char v); + private: + int _rPin,_gPin,_bPin; + bool _invert; + void _initPINs(int rPin,int gPin,int bPin); +}; + +#endif diff --git a/src/examples/hue_rotation/hue_rotation.ino b/src/examples/hue_rotation/hue_rotation.ino new file mode 100644 index 0000000..00a48d7 --- /dev/null +++ b/src/examples/hue_rotation/hue_rotation.ino @@ -0,0 +1,27 @@ +/* + * hue_rotation - Cycle an RGB LED through hue values. + * Copyright 2009, 2013 Elena Grandi + * + * This work is free. You can redistribute it and/or modify it under the + * terms of the Do What The Fuck You Want To Public License, Version 2, + * as published by Sam Hocevar. See the examples/wtfpl-2.txt file + * for more details. + */ + +#include + +Colours colours(6,5,3); +// For common cathode RGB LEDs comment the line above and uncomment +// the one below. +//Colours colours(6,5,3,true); + +void setup() { +} + +void loop() { + int h; + for (h=0;h<360;h++) { + colours.writeHSV(h,255,255); + delay(50); + } +} diff --git a/src/examples/wtfpl-2.txt b/src/examples/wtfpl-2.txt new file mode 100644 index 0000000..ee7d6a5 --- /dev/null +++ b/src/examples/wtfpl-2.txt @@ -0,0 +1,14 @@ + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + + Copyright (C) 2004 Sam Hocevar + + Everyone is permitted to copy and distribute verbatim or modified + copies of this license document, and changing it is allowed as long + as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. + diff --git a/src/keywords.txt b/src/keywords.txt new file mode 100644 index 0000000..92dd91d --- /dev/null +++ b/src/keywords.txt @@ -0,0 +1,3 @@ +Colours KEYWORD1 +writeRGB KEYWORD2 +writeHSV KEYWORD2 -- cgit v1.2.3