diff --git a/Shapes.h b/Shapes.h index 71abb71..ba79a4e 100755 --- a/Shapes.h +++ b/Shapes.h @@ -2,6 +2,26 @@ #define Shapes_h +const int zeros[7][3] = { +{0,0,0}, +{0,0,0}, +{0,0,0}, +{0,0,0}, +{0,0,0}, +{0,0,0}, +{0,0,0}, +}; + +const int happySimple[7][3] = { +{0,0,0}, +{0,150,0}, +{0,150,0}, +{0,150,0}, +{0,150,0}, +{0,0,0}, +{0,0,0}, +}; + //*********************************************************************************** //*********************************MOUTHS DEFINES************************************ //*********************************************************************************** diff --git a/SimpleExpressions.cpp b/SimpleExpressions.cpp index f803a91..d29f8b5 100755 --- a/SimpleExpressions.cpp +++ b/SimpleExpressions.cpp @@ -3,7 +3,7 @@ -void SimpleExpressions::init(int mouthPin, int buzzerPin) { +void SimpleExpressionsClass::init(int mouthPin, int buzzerPin) { mouth = Adafruit_NeoPixel(7, mouthPin, NEO_GRB + NEO_KHZ800); pinBuzzer = buzzerPin; @@ -15,7 +15,7 @@ void SimpleExpressions::init(int mouthPin, int buzzerPin) { //-- MOUTHS & ANIMATIONS ----------------------------------------// /////////////////////////////////////////////////////////////////// -unsigned long int SimpleExpressions::getMouthShape(int number){ +unsigned long int SimpleExpressionsClass::getMouthShape(int number){ unsigned long int types []={zero_code,one_code,two_code,three_code,four_code,five_code,six_code,seven_code,eight_code, nine_code,smile_code,happyOpen_code,happyClosed_code,heart_code,bigSurprise_code,smallSurprise_code,tongueOut_code, vamp1_code,vamp2_code,lineMouth_code,confused_code,diagonal_code,sad_code,sadOpen_code,sadClosed_code, @@ -25,100 +25,53 @@ unsigned long int SimpleExpressions::getMouthShape(int number){ } -unsigned long int SimpleExpressions::getAnimShape(int anim, int index){ +unsigned long int SimpleExpressionsClass::getAnimShape(int anim, int index){ - unsigned long int littleUuh_code[]={ - 0b00000000000000001100001100000000, - 0b00000000000000000110000110000000, - 0b00000000000000000011000011000000, - 0b00000000000000000110000110000000, - 0b00000000000000001100001100000000, - 0b00000000000000011000011000000000, - 0b00000000000000110000110000000000, - 0b00000000000000011000011000000000 - }; +} - unsigned long int dreamMouth_code[]={ - 0b00000000000000000000110000110000, - 0b00000000000000010000101000010000, - 0b00000000011000100100100100011000, - 0b00000000000000010000101000010000 - }; - unsigned long int adivinawi_code[]={ - 0b00100001000000000000000000100001, - 0b00010010100001000000100001010010, - 0b00001100010010100001010010001100, - 0b00000000001100010010001100000000, - 0b00000000000000001100000000000000, - 0b00000000000000000000000000000000 - }; +void SimpleExpressionsClass::putAnimationMouth(unsigned long int aniMouth, int index){ - unsigned long int wave_code[]={ - 0b00001100010010100001000000000000, - 0b00000110001001010000100000000000, - 0b00000011000100001000010000100000, - 0b00000001000010000100001000110000, - 0b00000000000001000010100100011000, - 0b00000000000000100001010010001100, - 0b00000000100000010000001001000110, - 0b00100000010000001000000100000011, - 0b00110000001000000100000010000001, - 0b00011000100100000010000001000000 - }; + //ledmatrix.writeFull(getAnimShape(aniMouth,index)); +} - switch (anim){ - - case littleUuh: - return littleUuh_code[index]; - break; - case dreamMouth: - return dreamMouth_code[index]; - break; - case adivinawi: - return adivinawi_code[index]; - break; - case wave: - return wave_code[index]; - break; +void SimpleExpressionsClass::writeMouth(){ + for(uint16_t i=0; i<7; i++) { + mouth.setPixelColor(i, mouth.Color(happySimple[i][0], happySimple[i][1], happySimple[i][2])); } + mouth.show(); } - -void SimpleExpressions::putAnimationMouth(unsigned long int aniMouth, int index){ - - ledmatrix.writeFull(getAnimShape(aniMouth,index)); -} - - -void SimpleExpressions::putMouth(unsigned long int mouth, bool predefined){ +void SimpleExpressionsClass::putMouth(unsigned long int mouth, bool predefined){ if (predefined){ - ledmatrix.writeFull(getMouthShape(mouth)); + //ledmatrix.writeFull(getMouthShape(mouth)); } else{ - ledmatrix.writeFull(mouth); + //ledmatrix.writeFull(mouth); } } -void SimpleExpressions::clearMouth(){ - ledmatrix.clearMatrix(); +void SimpleExpressionsClass::clearMouth(){ + for(uint16_t i=0; i #ifdef __AVR__ #include @@ -9,12 +9,13 @@ -class SimpleExpressions +class SimpleExpressionsClass { public: void init(int mouthPin, int buzzerPin); + void writeMouth(); void putMouth(unsigned long int mouth, bool predefined = true); void putAnimationMouth(unsigned long int anim, int index); void clearMouth(); @@ -40,4 +41,6 @@ class SimpleExpressions }; +extern SimpleExpressionsClass SimpleExpressions; + #endif diff --git a/examples/mouth.ino b/examples/mouth.ino new file mode 100644 index 0000000..b539617 --- /dev/null +++ b/examples/mouth.ino @@ -0,0 +1,11 @@ +#include + +void setup() { + SimpleExpressions.init(13,14); + SimpleExpressions.writeMouth(); + +} + +void loop() { + +}