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
// and don't make names longer than 20!
const PROGMEM Frame shapes[] = {
const Frame shapes[] = {
{
"zeros",
{
@ -24,7 +24,7 @@ const PROGMEM Frame shapes[] = {
{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,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,0,0},
{0,0,0},
{0,0,0}
}
},
{
@ -60,7 +60,7 @@ const PROGMEM Frame shapes[] = {
{0, 0, 0},
{0, 0, 0},
{0, 150,0},
{0, 150,0},
{0, 150,0}
}
},
{
@ -72,8 +72,8 @@ const PROGMEM Frame shapes[] = {
{0,0,0},
{0,150,0},
{0,150,0},
{0,150,0},
{0,150,0}
}
},
}
};
#endif

View File

@ -34,20 +34,21 @@ void SimpleExpressionsClass::writeMouth(unsigned int mouthId){
}
*/
void SimpleExpressionsClass::writeMouth(char mouthName[] ){
int number = -1;
for(int i = 0; i < shapeNumber; i++){
// perform on first encounter
Serial.print("aname: ");
Serial.println(shapes[i].name);
if(strcmp(shapes[i].name, mouthName) == 0) {
Serial.println("match");
//Serial.print("aname: ");
if(strncmp(shapes[i].name, mouthName, 20) == 0) {
//Serial.print("####################match ");
//Serial.println(shapes[i].name);
number = i;
break;
}
}
if(number != -1){
writeMouthGeneric(shapes[number].data);
printMouthShape(number);
} else {
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]) {
for(uint16_t i=0; i<7; i++) {
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();
}

View File

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