mirror of
https://github.com/s00500/SimpleExpressions
synced 2024-11-23 21:20:55 +00:00
Merge branch 'master' into master
This commit is contained in:
commit
95a7024a71
@ -5,7 +5,7 @@
|
|||||||
{
|
{
|
||||||
"keys":
|
"keys":
|
||||||
{
|
{
|
||||||
"LANG_CATEGORY_SOUND": "User Sound",
|
"LANG_CATEGORY_SOUND": "Sound",
|
||||||
"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",
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
name=SimpleExpressions
|
name=SimpleExpressions
|
||||||
version=1.0.0
|
version=1.1.0
|
||||||
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
|
||||||
|
@ -17,92 +17,111 @@ Facilino.hexToRgb = function(hex) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Blockly.Blocks['show_mouth'] = {
|
Blockly.Blocks['show_mouth'] = {
|
||||||
category: Facilino.locales.getKey('LANG_CATEGORY_SCREEN'),
|
category: Facilino.locales.getKey('LANG_CATEGORY_SCREEN'),
|
||||||
subcategory: Facilino.locales.getKey('LANG_SUBCATERGORY_WS2812'),
|
subcategory: Facilino.locales.getKey('LANG_SUBCATERGORY_WS2812'),
|
||||||
category_colour: Facilino.LANG_COLOUR_SCREEN,
|
category_colour: Facilino.LANG_COLOUR_SCREEN,
|
||||||
colour: Facilino.LANG_COLOUR_SCREEN_LEDSTRIP,
|
colour: Facilino.LANG_COLOUR_SCREEN_LEDSTRIP,
|
||||||
helpUrl: Facilino.getHelpUrl('show_mouth'),
|
helpUrl: Facilino.getHelpUrl('show_mouth'),
|
||||||
tags: [],
|
tags: [],
|
||||||
examples: [],
|
examples: [],
|
||||||
init: function() {
|
init: function() {
|
||||||
this.appendDummyInput('').appendField(Facilino.locales.getKey('LANG_SIMPLEEXPRESSIONS_SHOW_MOUTH')).appendField(new Blockly.FieldImage('img/blocks/round_led_strip.svg', 40*options.zoom, 40*options.zoom));
|
this.appendDummyInput('').appendField("WS2812 7-Ring").appendField(new Blockly.FieldImage('img/blocks/led_strip.svg', 40 * options.zoom, 40 * options.zoom));
|
||||||
this.appendValueInput('PIN').appendField(Facilino.locales.getKey('LANG_SIMPLEEXPRESSIONS_PIN')).setAlign(Blockly.ALIGN_RIGHT).setCheck(Number);
|
this.appendValueInput('PIN').appendField(Facilino.locales.getKey('LANG_SIMPLEEXPRESSIONS_PIN')).setAlign(Blockly.ALIGN_RIGHT).setCheck(Number);
|
||||||
this.appendDummyInput('').appendField('Expression').appendField(new Blockly.FieldDropdown([['Zeros','zeros'],['Happy Small','happySmall'],['Happy Full','happyFull'],['Sad Small','sadSmall'],['Sad Full','sadFull'],['Neutral','neutral'],['Circle','circle'],['Center','center'],['Hook','hook'],['Upsidedown Hook','upsidedownhook'],['Kooh','kooh'],['Upsidedown Kooh','upsidedownkooh'],['Cross','cross'],['Rect','rect'],['Left Arrow','leftarrow'],['Right Arrow','rightarrow'],['Left Half','lefthalf'],['Right Half','righthalf']]),'EXPRESSION').setAlign(Blockly.ALIGN_RIGHT);
|
this.appendDummyInput('').appendField('Expression').appendField(new Blockly.FieldDropdown([
|
||||||
var colour = new Blockly.FieldColour('#000000');
|
['Zeros', 'zeros'],
|
||||||
colour.setColours(['#000000','#808080','#C0C0C0','#FFFFFF','#800000','#FF0000','#808000','#FFFF00','#008000','#00FF00','#008080','#00FFFF','#000080','#0000FF','#800080','#FF00FF']).setColumns(4);
|
['Happy Small', 'happySmall'],
|
||||||
this.appendDummyInput('').appendField('Color').appendField(colour,'COLOR').setAlign(Blockly.ALIGN_RIGHT);
|
['Happy Full', 'happyFull'],
|
||||||
this.setPreviousStatement(true,'code');
|
['Sad Small', 'sadSmall'],
|
||||||
this.setNextStatement(true,'code');
|
['Sad Full', 'sadFull'],
|
||||||
this.setColour(Facilino.LANG_COLOUR_SCREEN_LEDSTRIP);
|
['Neutral', 'neutral'],
|
||||||
this.setTooltip("");
|
['Circle', 'circle'],
|
||||||
}
|
['Center', 'center'],
|
||||||
|
['Hook', 'hook'],
|
||||||
|
['Upsidedown Hook', 'upsidedownhook'],
|
||||||
|
['Kooh', 'kooh'],
|
||||||
|
['Upsidedown Kooh', 'upsidedownkooh'],
|
||||||
|
['Cross', 'cross'],
|
||||||
|
['Rect', 'rect'],
|
||||||
|
['Left Arrow', 'leftarrow'],
|
||||||
|
['Right Arrow', 'rightarrow'],
|
||||||
|
['Left Half', 'lefthalf'],
|
||||||
|
['Right Half', 'righthalf']
|
||||||
|
]), 'EXPRESSION').setAlign(Blockly.ALIGN_RIGHT);
|
||||||
|
var colour = new Blockly.FieldColour('#000000');
|
||||||
|
colour.setColours(['#000000', '#808080', '#C0C0C0', '#FFFFFF', '#800000', '#FF0000', '#808000', '#FFFF00', '#008000', '#00FF00', '#008080', '#00FFFF', '#000080', '#0000FF', '#800080', '#FF00FF']).setColumns(4);
|
||||||
|
this.appendDummyInput('').appendField('Color').appendField(colour, 'COLOR').setAlign(Blockly.ALIGN_RIGHT);
|
||||||
|
this.setPreviousStatement(true, 'code');
|
||||||
|
this.setNextStatement(true, 'code');
|
||||||
|
this.setColour(Facilino.LANG_COLOUR_SCREEN_LEDSTRIP);
|
||||||
|
this.setTooltip("");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Blockly.Arduino['show_mouth'] = function(block) {
|
Blockly.Arduino['show_mouth'] = function(block) {
|
||||||
var input_expression = this.getFieldValue('EXPRESSION');
|
var input_expression = this.getFieldValue('EXPRESSION');
|
||||||
var input_color = this.getFieldValue('COLOR');
|
var input_color = this.getFieldValue('COLOR');
|
||||||
var input_pin = Blockly.Arduino.valueToCode(this,'PIN',Blockly.Arduino.ORDER_ATOMIC) || '';
|
var input_pin = Blockly.Arduino.valueToCode(this, 'PIN', Blockly.Arduino.ORDER_ATOMIC) || '';
|
||||||
Blockly.Arduino.definitions_['define_simpleexpressions_h'] = '#include <SimpleExpressions.h>';
|
Blockly.Arduino.definitions_['define_simpleexpressions_h'] = '#include <SimpleExpressions.h>';
|
||||||
Blockly.Arduino.setups_['setup_simpleexpressions_mouth'] = 'SimpleExpressions.initMouth('+input_pin+');\n';
|
Blockly.Arduino.setups_['setup_simpleexpressions_mouth'] = 'SimpleExpressions.initMouth(' + input_pin + ');\n';
|
||||||
var color_rgb=Facilino.hexToRgb(input_color);
|
var color_rgb = Facilino.hexToRgb(input_color);
|
||||||
var code='SimpleExpressions.writeMouth("'+input_expression+'",'+color_rgb.r +','+color_rgb.g+','+color_rgb.b+');\n' ;
|
var code = 'SimpleExpressions.writeMouth("' + input_expression + '",' + color_rgb.r + ',' + color_rgb.g + ',' + color_rgb.b + ');\n';
|
||||||
code+= '\n';
|
code += '\n';
|
||||||
return code;
|
return code;
|
||||||
};
|
};
|
||||||
|
|
||||||
Blockly.Arduino.dyor_piezo_buzzer_predef_sounds = function() {
|
Blockly.Arduino.dyor_piezo_buzzer_predef_sounds = function() {
|
||||||
var dropdown_pin = Blockly.Arduino.valueToCode(this, 'PIN', Blockly.Arduino.ORDER_ATOMIC) || '';
|
var dropdown_pin = Blockly.Arduino.valueToCode(this, 'PIN', Blockly.Arduino.ORDER_ATOMIC) || '';
|
||||||
var code= '';
|
var code = '';
|
||||||
Blockly.Arduino.definitions_['define_simpleexpressions_h'] = '#include <SimpleExpressions.h>';
|
Blockly.Arduino.definitions_['define_simpleexpressions_h'] = '#include <SimpleExpressions.h>';
|
||||||
Blockly.Arduino.setups_['setup_simpleexpressions_buzzer'] = 'SimpleExpressions.initBuzzer('+dropdown_pin+');\n';
|
Blockly.Arduino.setups_['setup_simpleexpressions_buzzer'] = 'SimpleExpressions.initBuzzer(' + dropdown_pin + ');\n';
|
||||||
code='SimpleExpressions.playSound('+this.getFieldValue('OPTION')+');\n';
|
code = 'SimpleExpressions.playSound(' + this.getFieldValue('OPTION') + ');\n';
|
||||||
return code;
|
return code;
|
||||||
};
|
};
|
||||||
|
|
||||||
Blockly.Blocks.dyor_piezo_buzzer_predef_sounds = {
|
Blockly.Blocks.dyor_piezo_buzzer_predef_sounds = {
|
||||||
category: Facilino.locales.getKey('LANG_CATEGORY_SOUND'),
|
category: Facilino.locales.getKey('LANG_CATEGORY_SOUND'),
|
||||||
subcategory: Facilino.locales.getKey('LANG_SUBCATEGORY_BUZZER'),
|
subcategory: Facilino.locales.getKey('LANG_SUBCATEGORY_BUZZER'),
|
||||||
tags: ['buzzer','sound'],
|
tags: ['buzzer', 'sound'],
|
||||||
helpUrl: Facilino.getHelpUrl('dyor_piezo_buzzer_predef_sounds'),
|
helpUrl: Facilino.getHelpUrl('dyor_piezo_buzzer_predef_sounds'),
|
||||||
examples: [''],
|
examples: [''],
|
||||||
category_colour: Facilino.LANG_COLOUR_SOUND,
|
category_colour: Facilino.LANG_COLOUR_SOUND,
|
||||||
colour: Facilino.LANG_COLOUR_SOUND_BUZZER,
|
colour: Facilino.LANG_COLOUR_SOUND_BUZZER,
|
||||||
//dyor_piezo_buzzer initialization
|
//dyor_piezo_buzzer initialization
|
||||||
init: function() {
|
init: function() {
|
||||||
this.setColour(Facilino.LANG_COLOUR_SOUND_BUZZER);
|
this.setColour(Facilino.LANG_COLOUR_SOUND_BUZZER);
|
||||||
this.appendDummyInput('')
|
this.appendDummyInput('')
|
||||||
.appendField(Facilino.locales.getKey('LANG_PIEZO_BUZZER'))
|
.appendField(Facilino.locales.getKey('LANG_PIEZO_BUZZER'))
|
||||||
.appendField(new Blockly.FieldImage('img/blocks/buzzer.svg', 52*options.zoom, 35*options.zoom));
|
.appendField(new Blockly.FieldImage('img/blocks/buzzer.svg', 52 * options.zoom, 35 * options.zoom));
|
||||||
this.appendValueInput('PIN')
|
this.appendValueInput('PIN')
|
||||||
.appendField(Facilino.locales.getKey('LANG_PIEZO_BUZZER_PIN')).appendField(new Blockly.FieldImage("img/blocks/pwm_signal.svg",24*options.zoom,24*options.zoom))
|
.appendField(Facilino.locales.getKey('LANG_PIEZO_BUZZER_PIN')).appendField(new Blockly.FieldImage("img/blocks/pwm_signal.svg", 24 * options.zoom, 24 * options.zoom))
|
||||||
.setCheck(Number)
|
.setCheck(Number)
|
||||||
.setAlign(Blockly.ALIGN_RIGHT);
|
.setAlign(Blockly.ALIGN_RIGHT);
|
||||||
this.appendDummyInput('').appendField(new Blockly.FieldImage('img/blocks/speaker.svg', 24*options.zoom, 24*options.zoom))
|
this.appendDummyInput('').appendField(new Blockly.FieldImage('img/blocks/speaker.svg', 24 * options.zoom, 24 * options.zoom))
|
||||||
.appendField(new Blockly.FieldDropdown([
|
.appendField(new Blockly.FieldDropdown([
|
||||||
['CONNECTION', '0'],
|
['CONNECTION', '0'],
|
||||||
['DISCONNECTION', '1'],
|
['DISCONNECTION', '1'],
|
||||||
['BUTTON PUSHED', '2'],
|
['BUTTON PUSHED', '2'],
|
||||||
['MODE 1', '3'],
|
['MODE 1', '3'],
|
||||||
['MODE 2', '4'],
|
['MODE 2', '4'],
|
||||||
['MODE 3', '5'],
|
['MODE 3', '5'],
|
||||||
['SURPRISE', '6'],
|
['SURPRISE', '6'],
|
||||||
['OHOOH', '7'],
|
['OHOOH', '7'],
|
||||||
['OHOOH2', '8'],
|
['OHOOH2', '8'],
|
||||||
['CUDDLY', '9'],
|
['CUDDLY', '9'],
|
||||||
['SLEEPING','10'],
|
['SLEEPING', '10'],
|
||||||
['HAPPY','11'],
|
['HAPPY', '11'],
|
||||||
['SUPER_HAPPY','12'],
|
['SUPER_HAPPY', '12'],
|
||||||
['HAPPY_SHORT','13'],
|
['HAPPY_SHORT', '13'],
|
||||||
['SAD','14'],
|
['SAD', '14'],
|
||||||
['CONFUSED','15'],
|
['CONFUSED', '15'],
|
||||||
['FART1','16'],
|
['FART1', '16'],
|
||||||
['FART2','17'],
|
['FART2', '17'],
|
||||||
['FART3','18'],
|
['FART3', '18'],
|
||||||
['PIRATES','19']
|
['PIRATES', '19']
|
||||||
]), 'OPTION').setAlign(Blockly.ALIGN_RIGHT);
|
]), 'OPTION').setAlign(Blockly.ALIGN_RIGHT);
|
||||||
this.setInputsInline(false);
|
this.setInputsInline(false);
|
||||||
this.setPreviousStatement(true,'code');
|
this.setPreviousStatement(true, 'code');
|
||||||
this.setNextStatement(true,'code');
|
this.setNextStatement(true, 'code');
|
||||||
this.setTooltip(Facilino.locales.getKey('LANG_PIEZO_BUZZER_PREDEF_SOUNDS_TOOLTIP'));
|
this.setTooltip(Facilino.locales.getKey('LANG_PIEZO_BUZZER_PREDEF_SOUNDS_TOOLTIP'));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -4,21 +4,13 @@
|
|||||||
#define ledc_channel 5
|
#define ledc_channel 5
|
||||||
|
|
||||||
void SimpleExpressionsClass::init(int aMouthPin, int aBuzzerPin) {
|
void SimpleExpressionsClass::init(int aMouthPin, int aBuzzerPin) {
|
||||||
mouth = Adafruit_NeoPixel(7, aMouthPin, NEO_GRB + NEO_KHZ800);
|
initMouth(aMouthPin);
|
||||||
mouth.begin();
|
initBuzzer(aBuzzerPin);
|
||||||
|
|
||||||
buzzerPin = aBuzzerPin;
|
|
||||||
|
|
||||||
#if defined(ESP32)
|
|
||||||
ledcSetup(ledc_channel, 2000, 8); // channel, max frequency, resolution
|
|
||||||
ledcAttachPin(aBuzzerPin, ledc_channel);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
clearMouth();
|
clearMouth();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimpleExpressionsClass::init(int aMouthPin, int aBuzzerPin) {
|
|
||||||
|
void SimpleExpressionsClass::initMouth(int aMouthPin) {
|
||||||
mouth = Adafruit_NeoPixel(7, aMouthPin, NEO_GRB + NEO_KHZ800);
|
mouth = Adafruit_NeoPixel(7, aMouthPin, NEO_GRB + NEO_KHZ800);
|
||||||
mouth.begin();
|
mouth.begin();
|
||||||
clearMouth();
|
clearMouth();
|
||||||
@ -37,7 +29,7 @@ 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) {
|
||||||
@ -62,7 +54,7 @@ void SimpleExpressionsClass::printMouth(int number, int r, int g, int b) {
|
|||||||
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) {
|
||||||
|
@ -16,8 +16,8 @@ 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);
|
||||||
|
@ -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,
|
||||||
|
Loading…
Reference in New Issue
Block a user