Working as normal

This commit is contained in:
Lukas Bachschwell 2017-11-22 16:20:14 +01:00
parent e3d6ae422b
commit 29762e3852
3 changed files with 19 additions and 14 deletions

View File

@ -14,7 +14,7 @@ typedef Frame;
#define shapeNumber 5 // add the current shape count here #define shapeNumber 5 // add the current shape count here
// and don't make names longer than 20! // and don't make names longer than 20!
const PROGMEM Frame shapes[] = { const Frame shapes[] = {
{ {
"zeros", "zeros",
{ {
@ -24,7 +24,7 @@ const PROGMEM Frame shapes[] = {
{0,0,0}, {0,0,0},
{0,0,0}, {0,0,0},
{0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}
} }
}, },
{ {
@ -36,7 +36,7 @@ const PROGMEM Frame shapes[] = {
{0,150,0}, {0,150,0},
{0,0,0}, {0,0,0},
{0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}
} }
}, },
{ {
@ -48,7 +48,7 @@ const PROGMEM Frame shapes[] = {
{0,150,0}, {0,150,0},
{0,150,0}, {0,150,0},
{0,0,0}, {0,0,0},
{0,0,0}, {0,0,0}
} }
}, },
{ {
@ -60,7 +60,7 @@ const PROGMEM Frame shapes[] = {
{0, 0, 0}, {0, 0, 0},
{0, 0, 0}, {0, 0, 0},
{0, 150,0}, {0, 150,0},
{0, 150,0}, {0, 150,0}
} }
}, },
{ {
@ -72,8 +72,8 @@ const PROGMEM Frame shapes[] = {
{0,0,0}, {0,0,0},
{0,150,0}, {0,150,0},
{0,150,0}, {0,150,0},
{0,150,0}, {0,150,0}
} }
}, }
}; };
#endif #endif

View File

@ -34,20 +34,21 @@ void SimpleExpressionsClass::writeMouth(unsigned int mouthId){
} }
*/ */
void SimpleExpressionsClass::writeMouth(char mouthName[] ){ void SimpleExpressionsClass::writeMouth(char mouthName[] ){
int number = -1; int number = -1;
for(int i = 0; i < shapeNumber; i++){ for(int i = 0; i < shapeNumber; i++){
// perform on first encounter // perform on first encounter
Serial.print("aname: "); //Serial.print("aname: ");
Serial.println(shapes[i].name); if(strncmp(shapes[i].name, mouthName, 20) == 0) {
if(strcmp(shapes[i].name, mouthName) == 0) { //Serial.print("####################match ");
Serial.println("match"); //Serial.println(shapes[i].name);
number = i; number = i;
break; break;
} }
} }
if(number != -1){ if(number != -1){
writeMouthGeneric(shapes[number].data); printMouthShape(number);
} else { } else {
if(debug) Serial.println("Error: mouth name does not exist"); if(debug) Serial.println("Error: mouth name does not exist");
} }
@ -61,10 +62,15 @@ void SimpleExpressionsClass::printMouthShape(int number) {
} }
void SimpleExpressionsClass::writeMouthGeneric(const int mouthArray[7][3]) { void SimpleExpressionsClass::writeMouthGeneric(const int mouthArray[7][3]) {
for(uint16_t i=0; i<7; i++) { for(uint16_t i=0; i<7; i++) {
mouth.setPixelColor(i, mouth.Color(mouthArray[i][0], mouthArray[i][1], mouthArray[i][2])); mouth.setPixelColor(i, mouth.Color(mouthArray[i][0], mouthArray[i][1], mouthArray[i][2]));
} }
for(uint16_t i = 0; i<7; i++) {
Serial.println(mouth.getPixelColor(i));
}
Serial.println("#############");
mouth.show(); mouth.show();
} }

View File

@ -36,9 +36,8 @@ class SimpleExpressionsClass
private: private:
Adafruit_NeoPixel mouth;
int pinBuzzer; int pinBuzzer;
Adafruit_NeoPixel mouth;
long int getMouthShape(int number); long int getMouthShape(int number);
long int getAnimShape(int anim, int index); long int getAnimShape(int anim, int index);