mirror of
https://github.com/s00500/SimpleExpressions
synced 2024-11-23 05:50:54 +00:00
Adding Shape instead of full color
This commit is contained in:
parent
2c1608672a
commit
d16566b824
134
Shapes.h
134
Shapes.h
@ -4,75 +4,117 @@
|
||||
struct Frame
|
||||
{
|
||||
char name[20];
|
||||
int data[7][3];
|
||||
bool data[7];
|
||||
}
|
||||
typedef Frame;
|
||||
|
||||
|
||||
struct MulticolorFrame
|
||||
{
|
||||
char name[20];
|
||||
int data[7][3];
|
||||
}
|
||||
typedef MulticolorFrame;
|
||||
|
||||
//***********************************************************************************
|
||||
//*********************************MOUTHS DEFINES************************************
|
||||
//***********************************************************************************
|
||||
|
||||
#define shapeNumber 5 // add the current shape count here
|
||||
// and don't make names longer than 20!
|
||||
#define frameCount 18
|
||||
#define colorFrameCount 1
|
||||
|
||||
// TODO: calculate me
|
||||
|
||||
const Frame shapes[] = {
|
||||
{
|
||||
"zeros",
|
||||
{
|
||||
{0,0,0},
|
||||
{0,0,0},
|
||||
{0,0,0},
|
||||
{0,0,0},
|
||||
{0,0,0},
|
||||
{0,0,0},
|
||||
{0,0,0}
|
||||
}
|
||||
{0, 0, 0, 0, 0, 0, 0}
|
||||
},
|
||||
{
|
||||
"happySmall",
|
||||
{
|
||||
{0,0,0},
|
||||
{0,0,0},
|
||||
{0,150,0},
|
||||
{0,150,0},
|
||||
{0,0,0},
|
||||
{0,0,0},
|
||||
{0,0,0}
|
||||
}
|
||||
{0, 0, 1, 1, 0, 0, 0}
|
||||
},
|
||||
{
|
||||
"happyFull",
|
||||
{
|
||||
{0,0,0},
|
||||
{0,150,0},
|
||||
{0,150,0},
|
||||
{0,150,0},
|
||||
{0,150,0},
|
||||
{0,0,0},
|
||||
{0,0,0}
|
||||
}
|
||||
{0, 1, 1, 1, 1, 0, 0}
|
||||
},
|
||||
{
|
||||
"sadSmall",
|
||||
{
|
||||
{0, 0, 0},
|
||||
{0, 0, 0},
|
||||
{0, 0, 0},
|
||||
{0, 0, 0},
|
||||
{0, 0, 0},
|
||||
{0, 150,0},
|
||||
{0, 150,0}
|
||||
}
|
||||
{0, 0, 0, 0, 0, 1, 1}
|
||||
},
|
||||
{
|
||||
"sadFull",
|
||||
{0, 1, 0, 0, 1, 1, 1}
|
||||
},
|
||||
{
|
||||
"neutral",
|
||||
{1, 1, 0, 0, 1, 0, 0}
|
||||
},
|
||||
{
|
||||
"circle",
|
||||
{0, 1, 1, 1, 1, 1, 1}
|
||||
},
|
||||
{
|
||||
"center",
|
||||
{1, 0, 0, 0, 0, 0, 0}
|
||||
},
|
||||
{
|
||||
"hook",
|
||||
{1, 0, 0, 1, 1, 0, 1}
|
||||
},
|
||||
{
|
||||
"upsidedownhook",
|
||||
{1, 0, 1, 0, 1, 1, 0}
|
||||
},
|
||||
{
|
||||
"kooh",
|
||||
{1, 1, 1, 0, 0, 1, 0}
|
||||
},
|
||||
{
|
||||
"upsidedownkooh",
|
||||
{1, 1, 0, 1, 0, 0, 1}
|
||||
},
|
||||
{
|
||||
"cross",
|
||||
{1, 0, 1, 1, 0, 1, 1}
|
||||
},
|
||||
{
|
||||
"rect",
|
||||
{0, 0, 1, 1, 0, 1, 1}
|
||||
},
|
||||
{
|
||||
"leftarrow",
|
||||
{1, 1, 0, 1, 1, 1, 0}
|
||||
},
|
||||
{
|
||||
"rightarrow",
|
||||
{1, 1, 1, 0, 1, 0, 1}
|
||||
},
|
||||
{
|
||||
"lefthalf",
|
||||
{0, 0, 0, 1, 1, 1, 0}
|
||||
},
|
||||
{
|
||||
"righthalf",
|
||||
{0, 1, 1, 0, 0, 0, 1}
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const MulticolorFrame colorShapes[] = {
|
||||
{
|
||||
"colorCircle",
|
||||
{
|
||||
{0,0,0},
|
||||
{0,150,0},
|
||||
{0,0,0},
|
||||
{0,0,0},
|
||||
{0,150,0},
|
||||
{0,150,0},
|
||||
{0,150,0}
|
||||
{50,0,0},
|
||||
{0,50,0},
|
||||
{0,0,50},
|
||||
{50,0,0},
|
||||
{0,50,0},
|
||||
{0,0,50},
|
||||
{50,0,0}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -20,63 +20,71 @@ void SimpleExpressionsClass::init(int mouthPin, int buzzerPin) {
|
||||
//-- MOUTHS ----------------------------------------//
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
long int SimpleExpressionsClass::getAnimShape(int anim, int index){
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
void SimpleExpressionsClass::putAnimationMouth(int aniMouth, int index){
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
void SimpleExpressionsClass::writeMouth(unsigned int mouthId){
|
||||
if(mouthId > shapeNumber) {
|
||||
if(debug) Serial.println("Error: mouth does not exist");
|
||||
return;
|
||||
}
|
||||
writeMouthGeneric(shapes[mouthId].data);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
void SimpleExpressionsClass::writeMouth(char mouthName[] ){
|
||||
void SimpleExpressionsClass::writeMouth(char mouthName[], int r, int g, int b){
|
||||
int number = -1;
|
||||
for(int i = 0; i < shapeNumber; i++){
|
||||
// perform on first encounter
|
||||
//Serial.print("aname: ");
|
||||
for(int i = 0; i < frameCount; i++){
|
||||
if(strncmp(shapes[i].name, mouthName, 20) == 0) {
|
||||
//Serial.print("####################match ");
|
||||
//Serial.println(shapes[i].name);
|
||||
number = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(number != -1){
|
||||
printMouthShape(number);
|
||||
printMouth(number, r, g, b);
|
||||
} else {
|
||||
if(debug) Serial.println("Error: mouth name does not exist");
|
||||
}
|
||||
}
|
||||
|
||||
void SimpleExpressionsClass::printMouthShape(int number) {
|
||||
void SimpleExpressionsClass::printMouth(int number, int r, int g, int b) {
|
||||
for(uint16_t i = 0; i<7; i++) {
|
||||
mouth.setPixelColor(i, mouth.Color(shapes[number].data[i][0], shapes[number].data[i][1], shapes[number].data[i][2]));
|
||||
if(shapes[number].data[i]) mouth.setPixelColor(i, mouth.Color(r, g, b));
|
||||
else mouth.setPixelColor(i, 0);
|
||||
}
|
||||
mouth.show();
|
||||
}
|
||||
|
||||
void SimpleExpressionsClass::writeMouth(char mouthName[] ){
|
||||
int number = -1;
|
||||
for(int i = 0; i < colorFrameCount; i++){
|
||||
if(strncmp(shapes[i].name, mouthName, 20) == 0) {
|
||||
number = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(number != -1){
|
||||
printMouth(number);
|
||||
} else {
|
||||
if(debug) Serial.println("Error: mouth name does not exist");
|
||||
}
|
||||
}
|
||||
|
||||
void SimpleExpressionsClass::printMouth(int number) {
|
||||
for(uint16_t i = 0; i<7; i++) {
|
||||
mouth.setPixelColor(i, mouth.Color(colorShapes[number].data[i][0], colorShapes[number].data[i][1], colorShapes[number].data[i][2]));
|
||||
}
|
||||
mouth.show();
|
||||
}
|
||||
|
||||
|
||||
void SimpleExpressionsClass::writeMouthGeneric(const bool mouthArray[7], int r, int g, int b) {
|
||||
for(uint16_t i=0; i<7; i++) {
|
||||
if(mouthArray[i]) mouth.setPixelColor(i, mouth.Color(r, g, b));
|
||||
else mouth.setPixelColor(i, 0);
|
||||
}
|
||||
mouth.show();
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -16,15 +16,18 @@ class SimpleExpressionsClass
|
||||
|
||||
void init(int mouthPin, int buzzerPin);
|
||||
|
||||
void writeMouth(char mouthName[], int r, int g, int b);
|
||||
void printMouth(int number, int r, int g, int b);
|
||||
|
||||
void writeMouth(char mouthName[]);
|
||||
void printMouthShape(int number);
|
||||
void printMouth(int number);
|
||||
|
||||
void clearMouth();
|
||||
|
||||
void writeMouthRecolored(int mouth, uint32_t color);
|
||||
void writeMouthGeneric(const bool mouthArray[7], int r, int g, int b);
|
||||
void writeMouthGeneric(const int mouthArray[7][3]);
|
||||
|
||||
void putAnimationMouth(int anim, int index);
|
||||
//void putAnimationMouth(int anim, int index);
|
||||
|
||||
//-- Sounds
|
||||
void _tone (float noteFrequency, long noteDuration, int silentDuration);
|
||||
@ -32,7 +35,7 @@ class SimpleExpressionsClass
|
||||
void sing(int songName);
|
||||
|
||||
//-- Gestures
|
||||
void playGesture(int gesture);
|
||||
//void playGesture(int gesture);
|
||||
|
||||
|
||||
private:
|
||||
|
@ -9,18 +9,15 @@ void setup() {
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
SimpleExpressions.writeMouth("zeros");
|
||||
delay(500);
|
||||
SimpleExpressions.printMouthShape(1);
|
||||
delay(500);
|
||||
SimpleExpressions.writeMouth("happyFull");
|
||||
delay(500);
|
||||
SimpleExpressions.writeMouth("zeros");
|
||||
delay(500);
|
||||
SimpleExpressions.writeMouth("sadFull");
|
||||
delay(500);
|
||||
SimpleExpressions.writeMouth("sadSmall");
|
||||
delay(500);
|
||||
|
||||
// for (int i = 0; i < 18; i++) {
|
||||
SimpleExpressions.writeMouth("cross", 30, 0, 0);
|
||||
//Serial.println(i);
|
||||
delay(1000);
|
||||
SimpleExpressions.writeMouth("hook", 0, 30, 0);
|
||||
delay(1000);
|
||||
SimpleExpressions.writeMouth("leftarrow", 0, 15, 30);
|
||||
delay(1000);
|
||||
SimpleExpressions.writeMouth("rightarrow", 0, 15, 30);
|
||||
delay(1000);
|
||||
//}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user