I want to populate a NeoFunctions.cpp file with a lot different functions the call them frrom the main ino file.
Please throw me a bone.
OS Linux
Error:
/home/cwc/Arduino/libraries/NeoFunctions/NeoFunctions.cpp: In member function 'void NeoFunctions::cwc()':
/home/cwc/Arduino/libraries/NeoFunctions/NeoFunctions.cpp:13:6: error: 'strip' was not declared in this scope
strip.setPixelColor(i, strip.Color(0,0,0,w ) );
^
/home/cwc/Arduino/libraries/NeoFunctions/NeoFunctions.cpp:15:3: error: 'strip' was not declared in this scope
strip.show();
^
exit status 1
Error compiling for board Arduino/Genuino Uno.
Arduino (neo.ino)
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
#include <NeoFunctions.h>
#define PIN 6
#define NUM_LEDS 8
#define BRIGHTNESS 50
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRBW + NEO_KHZ800);
void setup() {
Serial.begin(115200);
// This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket
#if defined (__AVR_ATtiny85__)
if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
#endif
// End of trinket special code
strip.setBrightness(BRIGHTNESS);
strip.begin();
strip.show(); // Initialize all pixels to 'off'
}
//set up variables
int w = 0;
int i;
void loop() {
Call cwc function in NeoFunctions.cpp file
}
Header
#ifndef NeoFunctions_h
#define NeoFunctions_h
#include "Arduino.h"
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
class NeoFunctions
{
public:
NeoFunctions();
void cwc();
void clear();
};
#endif
NeoFunctions.cpp file
#include "Arduino.h"
#include "NeoFunctions.h"
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
NeoFunctions::NeoFunctions()
{}
void NeoFunctions::cwc()
{ int i; int w =0;
for(i = 0; i < 16 ; i++){
strip.setPixelColor(i, strip.Color(0,0,0,w ) );
}
strip.show();
delay(30);
w++;
if (w > 255) w = 0;
}
void NeoFunctions::clear()
{
// code to come
}