1
0
mirror of https://github.com/s00500/SimpleExpressions synced 2025-07-12 19:41:00 +00:00

9 Commits
1.1.0 ... 1.1.1

Author SHA1 Message Date
5618498992 Improving ESP32 LED Handeling, versionbump 2018-05-20 18:27:04 +02:00
10c656448b fixed consts in header 2017-12-19 13:22:17 +01:00
8526e6d4a5 Merge pull request #3 from roboticafacil/master
New icon for "show_mouth" and corrected name for translation
2017-12-16 20:12:23 +01:00
db7a00935f Merge branch 'master' into master 2017-12-16 20:11:59 +01:00
95a7024a71 Merge branch 'master' into master 2017-12-16 20:11:15 +01:00
0a23390b93 modified: lang/SimpleExpressions.json
modified:   simpleExpression_blocks.js
2017-12-16 11:46:18 +01:00
be3c222c62 new file: img/blocks/round_led_strip.svg 2017-12-16 11:44:16 +01:00
6d19e4bd02 Update SimpleExpressions.cpp 2017-12-13 14:51:57 +01:00
5574f6f732 Bug fixes 2017-12-13 14:49:20 +01:00
6 changed files with 395 additions and 138 deletions

View File

@ -0,0 +1,242 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="52mm"
height="51mm"
viewBox="0 0 52 51"
version="1.1"
id="svg8"
inkscape:version="0.92.1 r15371"
sodipodi:docname="round_led_strip.svg">
<defs
id="defs2">
<marker
style="overflow:visible"
refY="0"
refX="0"
orient="auto"
id="DistanceX">
<path
id="path4487"
style="stroke:#000000;stroke-width:0.5"
d="M 3,-3 -3,3 M 0,-5 V 5"
inkscape:connector-curvature="0" />
</marker>
<pattern
y="0"
x="0"
width="8"
patternUnits="userSpaceOnUse"
id="Hatch"
height="8">
<path
id="path4490"
stroke-width="0.25"
stroke="#000000"
linecap="square"
d="M8 4 l-4,4" />
<path
id="path4492"
stroke-width="0.25"
stroke="#000000"
linecap="square"
d="M6 2 l-4,4" />
<path
id="path4494"
stroke-width="0.25"
stroke="#000000"
linecap="square"
d="M4 0 l-4,4" />
</pattern>
<symbol
id="*Model_Space" />
<symbol
id="*Paper_Space" />
<symbol
id="*Paper_Space0" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="1.4"
inkscape:cx="123.32321"
inkscape:cy="41.326652"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="1366"
inkscape:window-height="705"
inkscape:window-x="-8"
inkscape:window-y="-8"
inkscape:window-maximized="1" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-246)">
<path
inkscape:connector-curvature="0"
d="M 11.211967,266.92368 H 1.2119672"
style="fill:none;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none"
id="path4502" />
<path
inkscape:connector-curvature="0"
d="m 23.042094,256.43333 -5,-8.66027"
style="fill:none;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none"
id="path4504" />
<path
inkscape:connector-curvature="0"
d="m 38.042094,261.43332 5,-8.66027"
style="fill:none;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none"
id="path4506" />
<path
inkscape:connector-curvature="0"
d="m 41.211967,276.92369 h 10"
style="fill:none;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none"
id="path4508" />
<path
inkscape:connector-curvature="0"
d="m 21.211967,276.92369 h 10"
style="fill:none;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none"
id="path4510" />
<path
inkscape:connector-curvature="0"
d="m 29.38184,287.41408 5,8.66026"
style="fill:none;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none"
id="path4512" />
<path
inkscape:connector-curvature="0"
d="m 14.38184,282.41409 -4.9999998,8.66023"
style="fill:none;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none"
id="path4514" />
<path
inkscape:connector-curvature="0"
d="m 1.2119672,266.92368 v 10.00001"
style="fill:none;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none"
id="path4516" />
<path
inkscape:connector-curvature="0"
d="m 18.042094,247.77306 -8.6602538,4.99999"
style="fill:none;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none"
id="path4518" />
<path
inkscape:connector-curvature="0"
d="M 43.042094,252.77305 34.38184,247.77306"
style="fill:none;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none"
id="path4520" />
<path
inkscape:connector-curvature="0"
d="M 51.211967,276.92369 V 266.92368"
style="fill:none;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none"
id="path4522" />
<path
inkscape:connector-curvature="0"
d="M 31.211967,276.92369 V 266.92368"
style="fill:none;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none"
id="path4524" />
<path
inkscape:connector-curvature="0"
d="m 34.38184,296.07434 8.660254,-5.00002"
style="fill:none;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none"
id="path4526" />
<path
inkscape:connector-curvature="0"
d="m 9.3818402,291.07432 8.6602538,5.00002"
style="fill:none;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none"
id="path4528" />
<path
inkscape:connector-curvature="0"
d="m 9.3818402,252.77305 4.9999998,8.66027"
style="fill:none;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none"
id="path4530" />
<path
inkscape:connector-curvature="0"
d="m 34.38184,247.77306 -5,8.66027"
style="fill:none;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none"
id="path4532" />
<path
inkscape:connector-curvature="0"
d="m 51.211967,266.92368 h -10"
style="fill:none;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none"
id="path4534" />
<path
inkscape:connector-curvature="0"
d="m 31.211967,266.92368 h -10"
style="fill:none;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none"
id="path4536" />
<path
inkscape:connector-curvature="0"
d="m 43.042094,291.07432 -5,-8.66023"
style="fill:none;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none"
id="path4538" />
<path
inkscape:connector-curvature="0"
d="m 18.042094,296.07434 5,-8.66026"
style="fill:none;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none"
id="path4540" />
<path
inkscape:connector-curvature="0"
d="M 1.2119672,276.92369 H 11.211967"
style="fill:none;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none"
id="path4542" />
<path
inkscape:connector-curvature="0"
d="m 14.38184,261.43332 8.660254,-4.99999"
style="fill:none;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none"
id="path4544" />
<path
inkscape:connector-curvature="0"
d="m 29.38184,256.43333 8.660254,4.99999"
style="fill:none;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none"
id="path4546" />
<path
inkscape:connector-curvature="0"
d="m 41.211967,266.92368 v 10.00001"
style="fill:none;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none"
id="path4548" />
<path
inkscape:connector-curvature="0"
d="m 21.211967,266.92368 v 10.00001"
style="fill:none;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none"
id="path4550" />
<path
inkscape:connector-curvature="0"
d="m 38.042094,282.41409 -8.660254,4.99999"
style="fill:none;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none"
id="path4552" />
<path
inkscape:connector-curvature="0"
d="M 23.042094,287.41408 14.38184,282.41409"
style="fill:none;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none"
id="path4554" />
<path
inkscape:connector-curvature="0"
d="M 11.211967,276.92369 V 266.92368"
style="fill:none;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none"
id="path4556" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 9.1 KiB

View File

@ -9,6 +9,7 @@
"LANG_SUBCATEGORY_BUZZER": "Buzzer", "LANG_SUBCATEGORY_BUZZER": "Buzzer",
"LANG_PIEZO_BUZZER": "Buzzer", "LANG_PIEZO_BUZZER": "Buzzer",
"LANG_PIEZO_BUZZER_PIN": "PIN", "LANG_PIEZO_BUZZER_PIN": "PIN",
"LANG_SIMPLEEXPRESSIONS_SHOW_MOUTH": "7-RGB LEDs",
"LANG_PIEZO_BUZZER_PREDEF_SOUNDS_TOOLTIP": "Plays some basic sounds based on SimpleExpressions library" "LANG_PIEZO_BUZZER_PREDEF_SOUNDS_TOOLTIP": "Plays some basic sounds based on SimpleExpressions library"
} }
} }

View File

@ -1,5 +1,5 @@
name=SimpleExpressions name=SimpleExpressions
version=1.1.0 version=1.1.1
author=Lukas Bachschwell author=Lukas Bachschwell
maintainer=Lukas Bachschwell <lukas@lbsfilm.at> maintainer=Lukas Bachschwell <lukas@lbsfilm.at>
sentence=Make you Robots cute and noisy sentence=Make you Robots cute and noisy

View File

@ -20,8 +20,8 @@ void SimpleExpressionsClass::initBuzzer(int aBuzzerPin) {
buzzerPin = aBuzzerPin; buzzerPin = aBuzzerPin;
#if defined(ESP32) #if defined(ESP32)
ledcSetup(ledc_channel, 2000, 8); // channel, max frequency, resolution ledcSetup(ledc_channel, 2000, 8); // channel, max frequency, resolution
ledcAttachPin(aBuzzerPin, ledc_channel); ledcAttachPin(aBuzzerPin, ledc_channel);
#endif #endif
} }
@ -29,19 +29,19 @@ void SimpleExpressionsClass::initBuzzer(int aBuzzerPin) {
//-- MOUTHS ----------------------------------------// //-- MOUTHS ----------------------------------------//
/////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////
void SimpleExpressionsClass::writeMouth(char mouthName[], int r, int g, int b) { void SimpleExpressionsClass::writeMouth(const char mouthName[], int r, int g, int b) {
int number = -1; int number = -1;
for(int i = 0; i < frameCount; i++){ for(int i = 0; i < frameCount; i++) {
if(strncmp(shapes[i].name, mouthName, 20) == 0) { if(strncmp(shapes[i].name, mouthName, 20) == 0) {
number = i; number = i;
break; break;
}
}
if(number != -1){
printMouth(number, r, g, b);
} else {
if(debug) Serial.println("Error: mouth name does not exist");
} }
}
if(number != -1) {
printMouth(number, r, g, b);
} else {
if(debug) Serial.println("Error: mouth name does not exist");
}
} }
void SimpleExpressionsClass::printMouth(int number, int r, int g, int b) { void SimpleExpressionsClass::printMouth(int number, int r, int g, int b) {
@ -49,31 +49,31 @@ void SimpleExpressionsClass::printMouth(int number, int r, int g, int b) {
if(shapes[number].data[i]) mouth.setPixelColor(i, mouth.Color(r, g, b)); if(shapes[number].data[i]) mouth.setPixelColor(i, mouth.Color(r, g, b));
else mouth.setPixelColor(i, 0); else mouth.setPixelColor(i, 0);
} }
mouth.show(); showMouth();
delay(1); delay(1);
clearPixels(); clearPixels();
} }
void SimpleExpressionsClass::writeMouth(char mouthName[] ) { void SimpleExpressionsClass::writeMouth(const char mouthName[] ) {
int number = -1; int number = -1;
for(int i = 0; i < colorFrameCount; i++){ for(int i = 0; i < colorFrameCount; i++) {
if(strncmp(shapes[i].name, mouthName, 20) == 0) { if(strncmp(shapes[i].name, mouthName, 20) == 0) {
number = i; number = i;
break; break;
}
}
if(number != -1){
printMouth(number);
} else {
if(debug) Serial.println("Error: mouth name does not exist");
} }
}
if(number != -1) {
printMouth(number);
} else {
if(debug) Serial.println("Error: mouth name does not exist");
}
} }
void SimpleExpressionsClass::printMouth(int number) { void SimpleExpressionsClass::printMouth(int number) {
for(uint16_t i = 0; i<7; i++) { 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.setPixelColor(i, mouth.Color(colorShapes[number].data[i][0], colorShapes[number].data[i][1], colorShapes[number].data[i][2]));
} }
mouth.show(); showMouth();
delay(1); delay(1);
clearPixels(); clearPixels();
} }
@ -84,7 +84,7 @@ void SimpleExpressionsClass::writeMouthGeneric(const bool mouthArray[7], int r,
if(mouthArray[i]) mouth.setPixelColor(i, mouth.Color(r, g, b)); if(mouthArray[i]) mouth.setPixelColor(i, mouth.Color(r, g, b));
else mouth.setPixelColor(i, 0); else mouth.setPixelColor(i, 0);
} }
mouth.show(); showMouth();
delay(1); delay(1);
clearPixels(); clearPixels();
} }
@ -93,7 +93,7 @@ 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]));
} }
mouth.show(); showMouth();
delay(1); delay(1);
clearPixels(); clearPixels();
} }
@ -103,7 +103,7 @@ void SimpleExpressionsClass::clearMouth() {
for(int i = 0; i < 7; i++) { for(int i = 0; i < 7; i++) {
mouth.setPixelColor(i, 0); mouth.setPixelColor(i, 0);
} }
mouth.show(); showMouth();
delay(1); delay(1);
clearPixels(); clearPixels();
} }
@ -115,24 +115,37 @@ void SimpleExpressionsClass::clearPixels() { // avoid strange issues on ESP32 wi
} }
delay(1); delay(1);
} }
void SimpleExpressionsClass::showMouth() {
#if defined(ESP32)
portDISABLE_INTERRUPTS();
mouth.show();
delay(1);
portENABLE_INTERRUPTS();
clearPixels();
#else
mouth.show();
#endif
}
/////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////
//-- SOUNDS -----------------------------------------------------// //-- SOUNDS -----------------------------------------------------//
/////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////
void SimpleExpressionsClass::_tone (float noteFrequency, long noteDuration, int silentDuration){ void SimpleExpressionsClass::_tone (float noteFrequency, long noteDuration, int silentDuration){
if(silentDuration==0){silentDuration=1;} if(silentDuration==0) {silentDuration=1;}
#if defined(ESP32) #if defined(ESP32)
ledcWriteTone(ledc_channel, noteFrequency); ledcWriteTone(ledc_channel, noteFrequency);
delay(noteDuration); // milliseconds delay(noteDuration); // milliseconds
ledcWrite(ledc_channel, 0); // notone ledcWrite(ledc_channel, 0); // notone
#else #else
tone(buzzerPin, noteFrequency, noteDuration); tone(buzzerPin, noteFrequency, noteDuration);
delay(noteDuration); // milliseconds delay(noteDuration); // milliseconds
#endif #endif
delay(silentDuration); delay(silentDuration);
} }
@ -142,138 +155,138 @@ void SimpleExpressionsClass::bendTones (float initFrequency, float finalFrequenc
// bendTones (880, 2093, 1.02, 18, 1); // bendTones (880, 2093, 1.02, 18, 1);
// bendTones (note_A5, note_C7, 1.02, 18, 0); // bendTones (note_A5, note_C7, 1.02, 18, 0);
if(silentDuration==0){silentDuration=1;} if(silentDuration==0) {silentDuration=1;}
if(initFrequency < finalFrequency) if(initFrequency < finalFrequency)
{ {
for (int i=initFrequency; i<finalFrequency; i=i*prop) { for (int i=initFrequency; i<finalFrequency; i=i*prop) {
_tone(i, noteDuration, silentDuration); _tone(i, noteDuration, silentDuration);
} }
} else{ } else{
for (int i=initFrequency; i>finalFrequency; i=i/prop) { for (int i=initFrequency; i>finalFrequency; i=i/prop) {
_tone(i, noteDuration, silentDuration); _tone(i, noteDuration, silentDuration);
} }
} }
} }
void SimpleExpressionsClass::playSound(int soundName){ void SimpleExpressionsClass::playSound(int soundName){
switch(soundName){ switch(soundName) {
case S_CONNECTION: case S_CONNECTION:
_tone(NOTE_E5,50,30); _tone(NOTE_E5,50,30);
_tone(NOTE_E6,55,25); _tone(NOTE_E6,55,25);
_tone(NOTE_A6,60,10); _tone(NOTE_A6,60,10);
break; break;
case S_DISCONNECTION: case S_DISCONNECTION:
_tone(NOTE_E5,50,30); _tone(NOTE_E5,50,30);
_tone(NOTE_A6,55,25); _tone(NOTE_A6,55,25);
_tone(NOTE_E6,50,10); _tone(NOTE_E6,50,10);
break; break;
case S_BUTTON_PUSHED: case S_BUTTON_PUSHED:
bendTones (NOTE_E6, NOTE_G6, 1.03, 20, 2); bendTones (NOTE_E6, NOTE_G6, 1.03, 20, 2);
delay(30); delay(30);
bendTones (NOTE_E6, NOTE_D7, 1.04, 10, 2); bendTones (NOTE_E6, NOTE_D7, 1.04, 10, 2);
break; break;
case S_MODE1: case S_MODE1:
bendTones (NOTE_E6, NOTE_A6, 1.02, 30, 10); //1318.51 to 1760 bendTones (NOTE_E6, NOTE_A6, 1.02, 30, 10); //1318.51 to 1760
break; break;
case S_MODE2: case S_MODE2:
bendTones (NOTE_G6, NOTE_D7, 1.03, 30, 10); //1567.98 to 2349.32 bendTones (NOTE_G6, NOTE_D7, 1.03, 30, 10); //1567.98 to 2349.32
break; break;
case S_MODE3: case S_MODE3:
_tone(NOTE_E6,50,100); //D6 _tone(NOTE_E6,50,100); //D6
_tone(NOTE_G6,50,80); //E6 _tone(NOTE_G6,50,80); //E6
_tone(NOTE_D7,300,0); //G6 _tone(NOTE_D7,300,0); //G6
break; break;
case S_SURPRISE: case S_SURPRISE:
bendTones(800, 2150, 1.02, 10, 1); bendTones(800, 2150, 1.02, 10, 1);
bendTones(2149, 800, 1.03, 7, 1); bendTones(2149, 800, 1.03, 7, 1);
break; break;
case S_OHOOH: case S_OHOOH:
bendTones(880, 2000, 1.04, 8, 3); //A5 = 880 bendTones(880, 2000, 1.04, 8, 3); //A5 = 880
delay(200); delay(200);
for (int i=880; i<2000; i=i*1.04) { for (int i=880; i<2000; i=i*1.04) {
_tone(NOTE_B5,5,10); _tone(NOTE_B5,5,10);
} }
break; break;
case S_OHOOH2: case S_OHOOH2:
bendTones(1880, 3000, 1.03, 8, 3); bendTones(1880, 3000, 1.03, 8, 3);
delay(200); delay(200);
for (int i=1880; i<3000; i=i*1.03) { for (int i=1880; i<3000; i=i*1.03) {
_tone(NOTE_C6,10,10); _tone(NOTE_C6,10,10);
} }
break; break;
case S_CUDDLY: case S_CUDDLY:
bendTones(700, 900, 1.03, 16, 4); bendTones(700, 900, 1.03, 16, 4);
bendTones(899, 650, 1.01, 18, 7); bendTones(899, 650, 1.01, 18, 7);
break; break;
case S_SLEEPING: case S_SLEEPING:
bendTones(100, 500, 1.04, 10, 10); bendTones(100, 500, 1.04, 10, 10);
delay(500); delay(500);
bendTones(400, 100, 1.04, 10, 1); bendTones(400, 100, 1.04, 10, 1);
break; break;
case S_HAPPY: case S_HAPPY:
bendTones(1500, 2500, 1.05, 20, 8); bendTones(1500, 2500, 1.05, 20, 8);
bendTones(2499, 1500, 1.05, 25, 8); bendTones(2499, 1500, 1.05, 25, 8);
break; break;
case S_SUPER_HAPPY: case S_SUPER_HAPPY:
bendTones(2000, 6000, 1.05, 8, 3); bendTones(2000, 6000, 1.05, 8, 3);
delay(50); delay(50);
bendTones(5999, 2000, 1.05, 13, 2); bendTones(5999, 2000, 1.05, 13, 2);
break; break;
case S_HAPPY_SHORT: case S_HAPPY_SHORT:
bendTones(1500, 2000, 1.05, 15, 8); bendTones(1500, 2000, 1.05, 15, 8);
delay(100); delay(100);
bendTones(1900, 2500, 1.05, 10, 8); bendTones(1900, 2500, 1.05, 10, 8);
break; break;
case S_SAD: case S_SAD:
bendTones(880, 669, 1.02, 20, 200); bendTones(880, 669, 1.02, 20, 200);
break; break;
case S_CONFUSED: case S_CONFUSED:
bendTones(1000, 1700, 1.03, 8, 2); bendTones(1000, 1700, 1.03, 8, 2);
bendTones(1699, 500, 1.04, 8, 3); bendTones(1699, 500, 1.04, 8, 3);
bendTones(1000, 1700, 1.05, 9, 10); bendTones(1000, 1700, 1.05, 9, 10);
break; break;
case S_FART1: case S_FART1:
bendTones(1600, 3000, 1.02, 2, 15); bendTones(1600, 3000, 1.02, 2, 15);
break; break;
case S_FART2: case S_FART2:
bendTones(2000, 6000, 1.02, 2, 20); bendTones(2000, 6000, 1.02, 2, 20);
break; break;
case S_FART3: case S_FART3:
bendTones(1600, 4000, 1.02, 2, 20); bendTones(1600, 4000, 1.02, 2, 20);
bendTones(4000, 3000, 1.02, 2, 20); bendTones(4000, 3000, 1.02, 2, 20);
break; break;
case PIRATES: case PIRATES:
// This is funny but very experimental and probably take long haha =P // This is funny but very experimental and probably take long haha =P
for (int i = 0; i < 203; i++) { //203 is the total number of music notes in the song for (int i = 0; i < 203; i++) { //203 is the total number of music notes in the song
int wait = duration[i] * songspeed; int wait = duration[i] * songspeed;
_tone( notes[i], wait, 0); //tone(pin,frequency,duration) _tone( notes[i], wait, 0); //tone(pin,frequency,duration)
} }
break; break;
} }

View File

@ -13,34 +13,35 @@
class SimpleExpressionsClass class SimpleExpressionsClass
{ {
public: public:
// General // General
void init(int mouthPin, int buzzerPin); void init(int mouthPin, int buzzerPin);
void initMouth(int mouthPin); void initMouth(int mouthPin);
void initBuzzer(int buzzerPin); void initBuzzer(int buzzerPin);
// Mouths // Mouths
void printMouth(int number, int r, int g, int b); void printMouth(int number, int r, int g, int b);
void writeMouth(char mouthName[], int r, int g, int b); void writeMouth(const char mouthName[], int r, int g, int b);
void printMouth(int number); void printMouth(int number);
void writeMouth(char mouthName[]); void writeMouth(const char mouthName[]);
void clearMouth(); void clearMouth();
void showMouth();
void writeMouthGeneric(const int mouthArray[7][3]); void writeMouthGeneric(const int mouthArray[7][3]);
void writeMouthGeneric(const bool mouthArray[7], int r, int g, int b); void writeMouthGeneric(const bool mouthArray[7], int r, int g, int b);
// Sounds // Sounds
void _tone (float noteFrequency, long noteDuration, int silentDuration); void _tone (float noteFrequency, long noteDuration, int silentDuration);
void bendTones (float initFrequency, float finalFrequency, float prop, long noteDuration, int silentDuration); void bendTones (float initFrequency, float finalFrequency, float prop, long noteDuration, int silentDuration);
void playSound(int soundName); void playSound(int soundName);
private: private:
Adafruit_NeoPixel mouth; Adafruit_NeoPixel mouth;
void clearPixels(); void clearPixels();
int buzzerPin; int buzzerPin;
}; };
extern SimpleExpressionsClass SimpleExpressions; extern SimpleExpressionsClass SimpleExpressions;

View File

@ -134,7 +134,7 @@
const int songspeed = 1; const int songspeed = 1;
const PROGMEM int notes[] = { //Note of the song, 0 is a rest/pulse const PROGMEM double notes[] = { //Note of the song, 0 is a rest/pulse
NOTE_E4, NOTE_G4, NOTE_A4, NOTE_A4, 0, NOTE_E4, NOTE_G4, NOTE_A4, NOTE_A4, 0,
NOTE_A4, NOTE_B4, NOTE_C5, NOTE_C5, 0, NOTE_A4, NOTE_B4, NOTE_C5, NOTE_C5, 0,
NOTE_C5, NOTE_D5, NOTE_B4, NOTE_B4, 0, NOTE_C5, NOTE_D5, NOTE_B4, NOTE_B4, 0,