mirror of
https://github.com/s00500/SimpleExpressions
synced 2024-11-21 12:50:54 +00:00
Making the basic mouth work
This commit is contained in:
parent
4411a9e173
commit
1baeec35f0
20
Shapes.h
20
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************************************
|
||||
//***********************************************************************************
|
||||
|
@ -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
|
||||
};
|
||||
|
||||
unsigned long int wave_code[]={
|
||||
0b00001100010010100001000000000000,
|
||||
0b00000110001001010000100000000000,
|
||||
0b00000011000100001000010000100000,
|
||||
0b00000001000010000100001000110000,
|
||||
0b00000000000001000010100100011000,
|
||||
0b00000000000000100001010010001100,
|
||||
0b00000000100000010000001001000110,
|
||||
0b00100000010000001000000100000011,
|
||||
0b00110000001000000100000010000001,
|
||||
0b00011000100100000010000001000000
|
||||
};
|
||||
|
||||
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 SimpleExpressions::putAnimationMouth(unsigned long int aniMouth, int index){
|
||||
void SimpleExpressionsClass::putAnimationMouth(unsigned long int aniMouth, int index){
|
||||
|
||||
ledmatrix.writeFull(getAnimShape(aniMouth,index));
|
||||
//ledmatrix.writeFull(getAnimShape(aniMouth,index));
|
||||
}
|
||||
|
||||
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::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<mouth.numPixels(); i++) {
|
||||
mouth.setPixelColor(i, mouth.Color(0, 0, 0));
|
||||
}
|
||||
mouth.show();
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
//-- SOUNDS -----------------------------------------------------//
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
void SimpleExpressions::_tone (float noteFrequency, long noteDuration, int silentDuration){
|
||||
/*
|
||||
void SimpleExpressionsClass::_tone (float noteFrequency, long noteDuration, int silentDuration){
|
||||
|
||||
// tone(10,261,500);
|
||||
// delay(500);
|
||||
|
||||
if(silentDuration==0){silentDuration=1;}
|
||||
|
||||
tone(SimpleExpressions::pinBuzzer, noteFrequency, noteDuration);
|
||||
tone(SimpleExpressionsClass::pinBuzzer, noteFrequency, noteDuration);
|
||||
delay(noteDuration); //milliseconds to microseconds
|
||||
//noTone(PIN_Buzzer);
|
||||
delay(silentDuration);
|
||||
@ -148,7 +101,7 @@ void SimpleE::bendTones (float initFrequency, float finalFrequency, float prop,
|
||||
}
|
||||
|
||||
|
||||
void SimpleExpressions::sing(int songName){
|
||||
void SimpleExpressionsClass::sing(int songName){
|
||||
switch(songName){
|
||||
|
||||
case S_connection:
|
||||
@ -258,4 +211,8 @@ void SimpleExpressions::sing(int songName){
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
SimpleExpressionsClass SimpleExpressions;
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef SimpleMouth_h
|
||||
#define SimpleMouth_h
|
||||
#ifndef SimpleExpressions_h
|
||||
#define SimpleExpressions_h
|
||||
#include <Adafruit_NeoPixel.h>
|
||||
#ifdef __AVR__
|
||||
#include <avr/power.h>
|
||||
@ -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
|
||||
|
11
examples/mouth.ino
Normal file
11
examples/mouth.ino
Normal file
@ -0,0 +1,11 @@
|
||||
#include <SimpleExpressions.h>
|
||||
|
||||
void setup() {
|
||||
SimpleExpressions.init(13,14);
|
||||
SimpleExpressions.writeMouth();
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user