Skip to content

Commit

Permalink
lubot library for Mixly
Browse files Browse the repository at this point in the history
  • Loading branch information
luokailiang committed Jan 27, 2016
1 parent bc507e1 commit b4acfbc
Show file tree
Hide file tree
Showing 475 changed files with 216,061 additions and 0 deletions.
177 changes: 177 additions & 0 deletions lubot/block/luxerobot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
'use strict';
goog.provide('Blockly.Blocks.luxerobot');
goog.require('Blockly.Blocks');
Blockly.Blocks.luxerobot.HUE = 40;

Blockly.Blocks.luxerobot_on_off = {
init: function() {
this.setColour(Blockly.Blocks.luxerobot.HUE);
this.appendDummyInput("")
.appendTitle(new Blockly.FieldDropdown([[Blockly.LUXE_LED_ON,"HIGH"],[Blockly.LUXE_LED_OFF,"LOW"]]), 'STAT');
this.setOutput(true, Number);
}
};

Blockly.Blocks.luxerobot_led_select = {
init: function() {
this.setColour(Blockly.Blocks.luxerobot.HUE);
this.appendDummyInput("")
.appendTitle(new Blockly.FieldDropdown([["ledLeft","12"],["ledRight","13"]]), 'STAT');
this.setOutput(true, Number);
}
};

Blockly.Blocks.luxerobot_motor_select = {
init: function() {
this.setColour(Blockly.Blocks.luxerobot.HUE);
this.appendDummyInput("")
.appendTitle(new Blockly.FieldDropdown([["motorLeft","5"],["motorRight","6"]]), 'STAT');
this.setOutput(true, Number);
}
};


Blockly.Blocks.luxerobot_motor_dir = {
init: function() {
this.setColour(Blockly.Blocks.luxerobot.HUE);
this.appendDummyInput("")
.appendTitle(new Blockly.FieldDropdown([[Blockly.LUXE_MOTOR_FORWARD,"LOW"],[Blockly.LUXE_MOTOR_REVERSE,"HIGH"]]), 'STAT');
this.setOutput(true, Number);
}
};

var NOTES=[["NOTE_C3", "NOTE_C3"],["NOTE_D3", "NOTE_D3"],["NOTE_E3", "NOTE_E3"],["NOTE_F3", "NOTE_F3"],["NOTE_G3", "NOTE_G3"],["NOTE_A3", "NOTE_A3"],["NOTE_B3", "NOTE_B3"],
["NOTE_C4", "NOTE_C4"],["NOTE_D4", "NOTE_D4"],["NOTE_E4", "NOTE_E4"],["NOTE_F4", "NOTE_F4"],["NOTE_G4", "NOTE_G4"],["NOTE_A4", "NOTE_A4"],["NOTE_B4", "NOTE_B4"],
["NOTE_C5", "NOTE_C5"],["NOTE_D5", "NOTE_D5"],["NOTE_E5", "NOTE_E5"],["NOTE_F5", "NOTE_F5"],["NOTE_G5", "NOTE_G5"],["NOTE_A5", "NOTE_A5"],["NOTE_B5", "NOTE_B5"]];


Blockly.Blocks.luxerobot_notes = {
init: function() {
this.setColour(Blockly.Blocks.luxerobot.HUE);
this.appendDummyInput("")
.appendTitle(new Blockly.FieldDropdown(NOTES), 'STAT');
this.setOutput(true, Number);
}
};

Blockly.Blocks.luxerobot_led = {
init: function() {
this.setColour(Blockly.Blocks.luxerobot.HUE);
this.appendDummyInput("")
.appendTitle(Blockly.LUXE_LED)
.appendTitle(new Blockly.FieldDropdown([["ledLeft","ledLeft"],["ledRight","ledRight"]]), 'PIN')
.appendTitle(Blockly.LUXE_STAT)
.appendTitle(new Blockly.FieldDropdown([[Blockly.LUXE_LED_ON,"on"],[Blockly.LUXE_LED_OFF,"off"]]), 'STAT');
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setInputsInline(true);
}
};

Blockly.Blocks.luxerobot_led_change = {
init: function() {
this.setColour(Blockly.Blocks.luxerobot.HUE);
this.appendDummyInput("")
.appendTitle(Blockly.LUXE_LED)
.appendTitle(new Blockly.FieldDropdown([["ledLeft","ledLeft"],["ledRight","ledRight"]]), 'PIN')
.appendTitle(Blockly.LUXE_LED_CHANGE);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setInputsInline(true);
}
};

Blockly.Blocks.luxerobot_motor = {
init: function() {
this.setColour(Blockly.Blocks.luxerobot.HUE);
this.appendDummyInput("")
.appendTitle(Blockly.LUXE_MOTOR)
.appendTitle(new Blockly.FieldDropdown([["motorLeft","motorLeft"],["motorRight","motorRight"]]), 'PIN');
this.appendValueInput("STAT", Number)
.appendTitle(Blockly.LUXE_SPEED)
.setCheck(Number);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setInputsInline(true);
}
};

Blockly.Blocks.luxerobot_motor2 = {
init: function() {
this.setColour(Blockly.Blocks.luxerobot.HUE);
this.appendDummyInput("")
.appendTitle(Blockly.LUXE_MOTOR)
.appendTitle(new Blockly.FieldDropdown([["motorLeft","motorLeft"],["motorRight","motorRight"]]), 'PIN')
.appendTitle(Blockly.LUXE_DIR)
.appendTitle(new Blockly.FieldDropdown([[Blockly.LUXE_MOTOR_REVERSE,"COUNTERCLOCKWISE"],[Blockly.LUXE_MOTOR_FORWARD,"CLOCKWISE"]]), 'STAT');
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setInputsInline(true);
}
};

Blockly.Blocks.luxerobot_motor_change_dir = {
init: function() {
this.setColour(Blockly.Blocks.luxerobot.HUE);
this.appendDummyInput("")
.appendTitle(Blockly.LUXE_MOTOR)
.appendTitle(new Blockly.FieldDropdown([["motorLeft","motorLeft"],["motorRight","motorRight"]]), 'PIN')
.appendTitle(Blockly.LUXE_MOTOR_CHANGE);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setInputsInline(true);
}
};

Blockly.Blocks.luxerobot_motor_stop = {
init: function() {
this.setColour(Blockly.Blocks.luxerobot.HUE);
this.appendDummyInput("")
.appendTitle(Blockly.LUXE_MOTOR)
.appendTitle(new Blockly.FieldDropdown([["motorLeft","motorLeft"],["motorRight","motorRight"]]), 'PIN')
.appendTitle(Blockly.LUXE_MOTOR_STOP);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setInputsInline(true);
}
};

Blockly.Blocks.luxerobot_speaker_play = {
init: function() {
this.setColour(Blockly.Blocks.luxerobot.HUE);
this.appendValueInput("NOTE", Number)
.appendTitle(Blockly.LUXE_SPEAKER_PLAYSOUND)
.appendTitle(Blockly.LUXE_SPEAKER_FREQUENCY)
.setCheck(Number);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setInputsInline(true);
}
};

Blockly.Blocks.luxerobot_speaker_play_duration = {
init: function() {
this.setColour(Blockly.Blocks.luxerobot.HUE);
this.appendValueInput("NOTE", Number)
.appendTitle(Blockly.LUXE_SPEAKER_PLAYSOUND)
.appendTitle(Blockly.LUXE_SPEAKER_FREQUENCY)
.setCheck(Number)
this.appendValueInput("DURATION", Number)
.appendTitle(Blockly.LUXE_SPEAKER_DURATION)
.setCheck(Number);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setInputsInline(true);
}
};

Blockly.Blocks.luxerobot_speaker_nosound = {
init: function() {
this.setColour(Blockly.Blocks.luxerobot.HUE);
this.appendDummyInput("")
.appendTitle(Blockly.LUXE_SPEANER_NOSOUND);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setInputsInline(true);
}
};
9 changes: 9 additions & 0 deletions lubot/companypin/lubot/pin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
profile["LuBot MK"]= {
description: "lubot",
digital: [["V0", "V0"],["V1", "V1"], ["V2", "V2"], ["V3", "V3"],["A0", "A0"], ["A1", "A1"], ["A2", "A2"], ["A3", "A3"]],
analog: [["A0", "A0"], ["A1", "A1"], ["A2", "A2"], ["A3", "A3"]],
pwm:[["V0", "V0"],["V1", "V1"], ["V2", "V2"], ["V3", "V3"]],
interrupt : [["V0", "V0"]],
serial_select:[["Serial", "Serial"]],
serial: 9600
}
69 changes: 69 additions & 0 deletions lubot/generator/luxerobot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
'use strict';
goog.provide('Blockly.Arduino.luxerobot');
goog.require('Blockly.Arduino');

Blockly.Arduino.luxerobot_on_off = function() {
var code = this.getTitleValue('STAT');
return [code, Blockly.Arduino.ORDER_ATOMIC];
};

Blockly.Arduino.luxerobot_led_select=Blockly.Arduino.luxerobot_on_off;
Blockly.Arduino.luxerobot_motor_select=Blockly.Arduino.luxerobot_on_off;
Blockly.Arduino.luxerobot_motor_dir=Blockly.Arduino.luxerobot_on_off;
Blockly.Arduino.luxerobot_notes=Blockly.Arduino.luxerobot_on_off;

Blockly.Arduino.luxerobot_led = function() {
var dropdown_pin = this.getTitleValue('PIN');
var dropdown_stat = this.getTitleValue('STAT');
var code = dropdown_pin+"."+dropdown_stat+"();\n";
return code;
};

Blockly.Arduino.luxerobot_led_change = function() {
var dropdown_pin = this.getTitleValue('PIN');
var code = dropdown_pin+".change();\n";
return code;
};

Blockly.Arduino.luxerobot_motor = function() {
var dropdown_pin = this.getTitleValue('PIN');
var value_num = Blockly.Arduino.valueToCode(this, 'STAT', Blockly.Arduino.ORDER_ATOMIC);
var code = dropdown_pin+'.setSpeed('+value_num+');\n';
return code;
};

Blockly.Arduino.luxerobot_motor2 = function() {
var dropdown_pin = this.getTitleValue('PIN');
var dropdown_stat = this.getTitleValue('STAT');
var code = dropdown_pin+'.setDirection('+dropdown_stat+');\n'
return code;
};

Blockly.Arduino.luxerobot_motor_change_dir = function() {
var dropdown_pin = this.getTitleValue('PIN');
var code = dropdown_pin+'.changeDirection();\n'
return code;
};

Blockly.Arduino.luxerobot_motor_stop = function() {
var dropdown_pin = this.getTitleValue('PIN');
var code = dropdown_pin+'.stop();\n'
return code;
};

Blockly.Arduino.luxerobot_speaker_play = function() {
var note = Blockly.Arduino.valueToCode(this, 'NOTE', Blockly.Arduino.ORDER_ATOMIC);
var code = 'speaker.play('+note+');\n'
return code;
};

Blockly.Arduino.luxerobot_speaker_play_duration = function() {
var note = Blockly.Arduino.valueToCode(this, 'NOTE', Blockly.Arduino.ORDER_ATOMIC);
var value_num = Blockly.Arduino.valueToCode(this, 'DURATION', Blockly.Arduino.ORDER_ATOMIC);
var code = 'speaker.play('+note+','+value_num+');\n'
return code;
};

Blockly.Arduino.luxerobot_speaker_nosound = function() {
return 'speaker.noPlay();\n';
};
21 changes: 21 additions & 0 deletions lubot/hardware/lubot/avr/boards.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
LuBotMK.name=LuBot MK

LuBotMK.upload.tool=avrdude
LuBotMK.upload.protocol=arduino
LuBotMK.upload.maximum_size=32256
LuBotMK.upload.maximum_data_size=2048
LuBotMK.upload.speed=115200

LuBotMK.bootloader.tool=avrdude
LuBotMK.bootloader.low_fuses=0xff
LuBotMK.bootloader.high_fuses=0xde
LuBotMK.bootloader.extended_fuses=0x05
LuBotMK.bootloader.unlock_bits=0x3F
LuBotMK.bootloader.lock_bits=0x0F
LuBotMK.bootloader.file=optiboot/optiboot_atmega328.hex

LuBotMK.build.mcu=atmega328p
LuBotMK.build.f_cpu=16000000L
LuBotMK.build.board=AVR_UNO
LuBotMK.build.core=arduino
LuBotMK.build.variant=lubotmk
Loading

0 comments on commit b4acfbc

Please sign in to comment.