Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ project.create.previouslink = Previous
project.board.activity-board = Propeller Activity Board WX
project.board.s3 = Scribbler Robot
project.board.heb = Hackable Electronic Badge
project.board.flip = Propeller Flip
project.board.flip = Propeller FLiP or Project Board
project.board.other = Other

confirm.request.title = Email confirm request
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/cdn/blockly/generators/propc.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ var profile = {
contiguous_pins_end: 11
},
"flip": {
description: "Propeller Flip Board",
description: "Propeller FLiP or Project Board",
digital: [["0", "0"], ["1", "1"], ["2", "2"], ["3", "3"], ["4", "4"], ["5", "5"], ["6", "6"], ["7", "7"], ["8", "8"], ["9", "9"], ["10", "10"], ["11", "11"], ["12", "12"], ["13", "13"], ["14", "14"], ["15", "15"], ["16", "16"], ["17", "17"], ["18", "18"], ["19", "19"], ["20", "20"], ["21", "21"], ["22", "22"], ["23", "23"], ["24", "24"], ["25", "25"], ["26", "26"], ["27", "27"], ["28", "28"], ["29", "29"], ["30", "30"], ["31", "31"]],
servo: [["0", "0"], ["1", "1"], ["2", "2"], ["3", "3"], ["4", "4"], ["5", "5"], ["6", "6"], ["7", "7"], ["8", "8"], ["9", "9"], ["10", "10"], ["11", "11"], ["12", "12"], ["13", "13"], ["14", "14"], ["15", "15"], ["16", "16"], ["17", "17"], ["18", "18"], ["19", "19"], ["20", "20"], ["21", "21"], ["22", "22"], ["23", "23"], ["24", "24"], ["25", "25"], ["26", "26"], ["27", "27"], ["28", "28"], ["29", "29"], ["30", "30"], ["31", "31"]],
analog: [["A0", "A0"], ["A1", "A1"], ["A2", "A2"], ["A3", "A3"], ["A4", "A4"], ["A5", "A5"]],
Expand Down
141 changes: 134 additions & 7 deletions src/main/webapp/cdn/blockly/generators/propc/communicate.js
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,133 @@ Blockly.propc.serial_receive_text = function () {
}
};


//--------------- Shift In/Out Blocks ------------------------------------------
Blockly.Blocks.shift_in = {
helpUrl: Blockly.MSG_PROTOCOLS_HELPURL,
init: function() {
this.setTooltip(Blockly.MSG_SHIFT_IN_TOOLTIP);
this.setColour(colorPalette.getColor('protocols'));
this.appendDummyInput()
.appendField("shift in")
.appendField(new Blockly.FieldDropdown(
[['2','2'],
['3','3'],
['4','4'],
['5','5'],
['6','6'],
['7','7'],
['8','8'],
['9','9'],
['10','10'],
['11','11'],
['12','12'],
['13','13'],
['14','14'],
['15','15'],
['16','16'],
['17','17'],
['18','18'],
['19','19'],
['20','20'],
['21','21'],
['22','22'],
['23','23'],
['24','24'],
['25','25'],
['26','26'],
['27','27'],
['28','28'],
['29','29'],
['30','30'],
['31','31'],
['32','32']]), "BITS")
.appendField("bits")
.appendField(new Blockly.FieldDropdown([["MSB first","MSB"], ["LSB first","LSB"]]), "MODE")
.appendField(new Blockly.FieldDropdown([["before clock","PRE"], ["after clock","POST"]]), "ORDER")
.appendField("DATA")
.appendField(new Blockly.FieldDropdown(profile.default.digital), "DATA")
.appendField("CLK")
.appendField(new Blockly.FieldDropdown(profile.default.digital), "CLK");
this.setInputsInline(true);
this.setOutput(true, null);
}
};

Blockly.propc.shift_in = function() {
var bits = this.getFieldValue('BITS');
var mode = this.getFieldValue('MODE');
var ord = this.getFieldValue('ORDER');
var dat = this.getFieldValue('DATA');
var clk = this.getFieldValue('CLK');

return ['shift_in(' + dat + ', ' + clk + ', ' + mode + ord + ', ' + bits + ')', Blockly.propc.ORDER_NONE];
};

Blockly.Blocks.shift_out = {
helpUrl: Blockly.MSG_PROTOCOLS_HELPURL,
init: function() {
this.setTooltip(Blockly.MSG_SHIFT_OUT_TOOLTIP);
this.setColour(colorPalette.getColor('protocols'));
this.appendValueInput("VALUE")
.setCheck("Number")
.appendField("shift out the")
.appendField(new Blockly.FieldDropdown(
[['2','2'],
['3','3'],
['4','4'],
['5','5'],
['6','6'],
['7','7'],
['8','8'],
['9','9'],
['10','10'],
['11','11'],
['12','12'],
['13','13'],
['14','14'],
['15','15'],
['16','16'],
['17','17'],
['18','18'],
['19','19'],
['20','20'],
['21','21'],
['22','22'],
['23','23'],
['24','24'],
['25','25'],
['26','26'],
['27','27'],
['28','28'],
['29','29'],
['30','30'],
['31','31'],
['32','32']]), "BITS")
.appendField("lowest bits of");
this.appendDummyInput()
.appendField(new Blockly.FieldDropdown([["MSB first","MSBFIRST"], ["LSB first","LSBFIRST"]]), "MODE")
.appendField("DATA")
.appendField(new Blockly.FieldDropdown(profile.default.digital), "DATA")
.appendField("CLK")
.appendField(new Blockly.FieldDropdown(profile.default.digital), "CLK");
this.setInputsInline(true);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
}
};

Blockly.propc.shift_out = function() {
var bits = this.getFieldValue('BITS');
var mode = this.getFieldValue('MODE');
var dat = this.getFieldValue('DATA');
var clk = this.getFieldValue('CLK');
var val = Blockly.propc.valueToCode(this, 'VALUE', Blockly.propc.ORDER_NONE) || '0';

return 'shift_out(' + dat + ', ' + clk + ', ' + mode + ', ' + bits + ', ' + val + ');\n';
};


//--------------- Serial LCD Blocks --------------------------------------------
Blockly.Blocks.debug_lcd_init = {
helpUrl: Blockly.MSG_SERIAL_LCD_HELPURL,
Expand Down Expand Up @@ -1497,12 +1624,12 @@ Blockly.Blocks.wx_init = {
bkg_colors.setColours(['#FFFFFF','#000000']).setColumns(2);
this.setColour(colorPalette.getColor('protocols'));
this.appendDummyInput()
.appendField("Simple WX initialize DO")
.appendField(new Blockly.FieldDropdown([['31 (WX)', '31']].concat(profile.default.digital)), "DO")
.appendField("Simple WX initialize mode")
.appendField(new Blockly.FieldDropdown([['Terminal on USB', 'USB_PGM_TERM'], ['Terminal on WX', 'USB_PGM'], ['Term & Programming on WX', 'WX_ALL_COM']]), "MODE") // .concat(profile.default.digital)
.appendField(" DO")
.appendField(new Blockly.FieldDropdown([['WX Socket', '31']].concat(profile.default.digital)), "DO")
.appendField("DI")
.appendField(new Blockly.FieldDropdown([['30 (WX)', '30']].concat(profile.default.digital)), "DI")
.appendField(" mode")
.appendField(new Blockly.FieldDropdown([['Terminal via Wifi', 'USB_PGM'], ['Terminal via USB', 'USB_PGM_TERM']].concat(profile.default.digital)), "MODE");
.appendField(new Blockly.FieldDropdown([['WX Socket', '30']].concat(profile.default.digital)), "DI");
this.setInputsInline(false);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
Expand All @@ -1515,7 +1642,7 @@ Blockly.propc.wx_init = function() {
var bkg = (this.getFieldValue('BKG') === '#FFFFFF') ? '1' : '0';
var title = this.getFieldValue('TITLE');
var mode = this.getFieldValue('MODE');
if(pin_do === '31' && pin_di === '30' && mode === 'USB_PGM') mode = 'WX_ALL_COM';
//if(pin_do === '31' && pin_di === '30' && mode === 'USB_PGM') mode = 'WX_ALL_COM';
var code = '';
code += 'wifi_start(' + pin_do + ', ' + pin_di + ', 115200, ' + mode + ');\n';
code += 'wifi_setBuffer(__wxBffr, sizeof(__wxBffr));\n';
Expand All @@ -1537,7 +1664,7 @@ Blockly.propc.wx_init = function() {
Blockly.Blocks.wx_config_page = {
helpUrl: Blockly.MSG_SWX_HELPURL,
init: function() {
this.setTooltip(Blockly.MSG_SWX_INIT_TOOLTIP);
this.setTooltip(Blockly.MSG_SWX_CONFIG_PAGE_TOOLTIP);
var bkg_colors = new Blockly.FieldColour("#FFFFFF");
bkg_colors.setColours(['#FFFFFF','#000000']).setColumns(2);
this.setColour(colorPalette.getColor('protocols'));
Expand Down
127 changes: 120 additions & 7 deletions src/main/webapp/cdn/blockly/generators/propc/gpio.js
Original file line number Diff line number Diff line change
Expand Up @@ -1053,14 +1053,127 @@ Blockly.propc.activitybot_display_calibration = function() {

code = '';
code += 'if(!abd_intTabSetup) interpolation_table_setup();\n';
code += 'print("=== LEFT SERVO ===\\n");\n';
code += 'print("Table Entries = %d, Zero Speed Index = %d\\n\\n", abd_elCntL, abd_cntrLidx);\n';
code += 'print("=== LEFT SERVO ===\\r");\n';
code += 'print("Table Entries = %d, Zero Speed Index = %d\\r\\r", abd_elCntL, abd_cntrLidx);\n';
code += 'print("Index, Servo Drive, Encoder Ticks/Second\\n");\n';
code += 'for(int __rIdx = 0; __rIdx < abd_elCntL; __rIdx++) print("%d, %d, %d\\n", __rIdx, abd_spdrL[__rIdx], abd_spdmL[__rIdx]);\n';
code += 'print("\\n\\n=== RIGHT SERVO ===\\n");\n';
code += 'print("Table Entries = %d, Zero Speed Index = %d\\n\\n", abd_elCntR, abd_cntrRidx);\n';
code += 'print("Index, Servo Drive, Encoder Ticks/Second\\n");\n';
code += 'for(int __rIdx = 0; __rIdx < abd_elCntR; __rIdx++) print("%d, %d, %d\\n", __rIdx, abd_spdrR[__rIdx], abd_spdmR[__rIdx]);\n';
code += 'for(int __rIdx = 0; __rIdx < abd_elCntL; __rIdx++) print("%d, %d, %d\\r", __rIdx, abd_spdrL[__rIdx], abd_spdmL[__rIdx]);\n';
code += 'print("\\r\\r=== RIGHT SERVO ===\\r");\n';
code += 'print("Table Entries = %d, Zero Speed Index = %d\\r\\r", abd_elCntR, abd_cntrRidx);\n';
code += 'print("Index, Servo Drive, Encoder Ticks/Second\\r");\n';
code += 'for(int __rIdx = 0; __rIdx < abd_elCntR; __rIdx++) print("%d, %d, %d\\r", __rIdx, abd_spdrR[__rIdx], abd_spdmR[__rIdx]);\n';

return code;
};

Blockly.Blocks.mcp320x_read = {
helpUrl: Blockly.MSG_ANALOG_PULSES_HELPURL,
init: function() {
this.setTooltip(Blockly.MSG_MCP320X_READ_TOOLTIP);
this.setColour(colorPalette.getColor('io'));
this.appendDummyInput()
.appendField(new Blockly.FieldDropdown([["MCP3202","2"], ["MCP3204","4"], ["MCP8208","8"]], function (ch_c) {
this.sourceBlock_.updateShape_({"CH_C": ch_c});}), "CHIP")
.appendField("CS")
.appendField(new Blockly.FieldDropdown(profile.default.digital), "CS_PIN")
.appendField("CLK")
.appendField(new Blockly.FieldDropdown(profile.default.digital), "CLK_PIN")
.appendField("DO")
.appendField(new Blockly.FieldDropdown(profile.default.digital), "DO_PIN")
.appendField("DI")
.appendField(new Blockly.FieldDropdown(profile.default.digital), "DI_PIN");
this.appendDummyInput('CHANNELS')
.setAlign(Blockly.ALIGN_RIGHT)
.appendField("channel")
.appendField(new Blockly.FieldDropdown([["1","1"], ["2", "2"]]), "CHAN")
.appendField("read (0-3.3V) in volt-100ths");
this.setInputsInline(false);
this.setOutput(true, null);
},
mutationToDom: function () {
var container = document.createElement('mutation');
var ch_c = this.getFieldValue('CHIP');
container.setAttribute('chip', ch_c);
return container;
},
domToMutation: function (xmlElement) {
var ch_c = xmlElement.getAttribute('chip');
this.updateShape_({"CH_C": ch_c});
},
updateShape_: function (details) {

var num = details['CH_C'];
if (details['CH_C'] === undefined) {
num = this.getFieldValue('CH_C');
}

var chan_count = [];

for (var i = 1; i <= num; i++) {
chan_count.push([i.toString(), i.toString()]);
}

this.removeInput('CHANNELS');
this.appendDummyInput('CHANNELS')
.setAlign(Blockly.ALIGN_RIGHT)
.appendField("channel")
.appendField(new Blockly.FieldDropdown(chan_count), "CHAN")
.appendField("read (0-3.3V) in volt-100ths");
}
};

Blockly.propc.mcp320x_read = function() {
var chip = parseInt(this.getFieldValue('CHIP'));
var cs_pin = this.getFieldValue('CS_PIN');
var clk_pin = this.getFieldValue('CLK_PIN');
var do_pin = this.getFieldValue('DO_PIN');
var di_pin = this.getFieldValue('DI_PIN');
var channel = '000' + parseInt(this.getFieldValue('CHANNEL')).toString(2) + "1";

if(chip < 4) {
channel = "11" + channel.substr(0,1) + "1";
} else {
channel = "11" + channel.substr(0,3) + "0";
}

var func = '';
func += 'int __Mvref = 330;';
func += 'int read_mcp320x(int __McsPin, int __MclkPin, int __MdoPin, int __MdiPin, int __Mbits, int __Mdata, int __MVr) {\n';
func += ' high(__McsPin); low(__MclkPin); low(__McsPin);\n';
func += ' shift_out(__MdiPin, __MclkPin, MSBFIRST, __Mbits, __Mdata);\n';
func += ' int __Mvolts = shift_in(__MdiPin, __MclkPin, MSBPOST, 12);\n';
func += ' high(__McsPin); high(__MclkPin);\n return ((__Mvolts * __MVr) / 4096);}';
Blockly.propc.global_vars_["mcp320x_read"] = func;


var code = '';
code += 'read_mcp320x(' + cs_pin + ', ' + clk_pin + ', ' + do_pin;
code += ', ' + di_pin + ', ' + channel.length + ', 0b' + channel + ', __Mvref)';

return [code, Blockly.propc.ORDER_NONE];
};

Blockly.Blocks.mcp320x_set_vref = {
helpUrl: Blockly.MSG_ANALOG_PULSES_HELPURL,
init: function() {
this.setTooltip(Blockly.MSG_MCP320X_SET_VREF_TOOLTIP);
this.setColour(colorPalette.getColor('io'));
this.appendDummyInput()
.appendField("MCP320X set Vref to")
.appendField(new Blockly.FieldTextInput('330',
Blockly.FieldTextInput.numberValidator), "VREF")
.appendField("volt 100ths");
this.setInputsInline(true);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
}
};

Blockly.propc.mcp320x_set_vref = function() {
var vref = parseInt(this.getFieldValue('VREF'));

var code = '';
if(Blockly.propc.global_vars_["mcp320x_read"] !== undefined) {
code += '__Mvref = ' + vref + ';\n';
}
return code;
};
7 changes: 6 additions & 1 deletion src/main/webapp/cdn/blockly/language/en/_messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,10 @@ Blockly.MSG_SERIAL_TX_TOOLTIP = "Serial transmit number: sends 32-bit integer as
Blockly.MSG_SERIAL_SEND_TEXT_TOOLTIP = "Serial transmit text: sends text as characters terminated by a 0 (NULL).";
Blockly.MSG_SERIAL_RX_TOOLTIP = "Serial receive number: receives 4 bytes MSB first and stores a a 32-bit integer.";
Blockly.MSG_SERIAL_RECEIVE_TEXT_TOOLTIP = "Serial receive text: receives and stores characters into a variable until a 0 (NULL).";
Blockly.MSG_SWX_INIT_TOOLTIP = "Simple WX initialize: Requires simplewx.html file. Match DO/DI to Propeller I/O pin connections. Set terminal routing, page title, and background color.";
Blockly.MSG_SHIFT_IN_TOOLTIP = "Shift In: serially shifts in a specified number of bits and provides an integer value.";
Blockly.MSG_SHIFT_OUT_TOOLTIP = "Shift Out: serially shifts in a specified number of bits from the specified value.";
Blockly.MSG_SWX_INIT_TOOLTIP = "Simple WX initialize: Requires simplewx.html file. Match DO/DI to Propeller I/O pin connections, set terminal and program routing.";
Blockly.MSG_SWX_CONFIG_PAGE_TOOLTIP = "Simple WX configure page: Requires simplewx.html file. Set terminal page title and background color.";
Blockly.MSG_SWX_SET_TOOLTIP = "Simple WX set widget: Requires simplewx.html file. Set location, type, color, and values for a new widget.";
Blockly.MSG_SWX_READ_TOOLTIP = "Simple WX read widgets: Requires simplewx.html file. Reads the current values of all the widgets.";
Blockly.MSG_SWX_GET_TOOLTIP = "Simple WX widget value: Requires simplewx.html file. Provides the value of a widget from when it was last read.";
Expand Down Expand Up @@ -357,6 +360,8 @@ Blockly.MSG_PULSE_OUT_TOOLTIP = "Pulse-out: outputs a high or low pulse to the s
Blockly.MSG_PWM_START_TOOLTIP = "PWM initialize: sets up PWM object in the Propeller.";
Blockly.MSG_PWM_SET_TOOLTIP = "PWM set: sends the specified PWM pulses out the Propeller I/O pin specified. Set duty cycle to 0 to stop sending pulses.";
Blockly.MSG_PWM_STOP_TOOLTIP = "PWM stop: Stops PWM object, frees up resources used on the Propeller.";
Blockly.MSG_MCP320X_SET_VREF_TOOLTIP = "MCP320X set Vref: Set to the Vref voltage of the A/D chip.";
Blockly.MSG_MCP320X_READ_TOOLTIP = "MCP320X read: Reads an analog voltage from the specified channel. Match to Propeller I/O pin connections.";
Blockly.MSG_WAV_PLAY_TOOLTIP = "WAV play: Plays the specified .WAV file stored on the SD card.";
Blockly.MSG_WAV_STATUS_TOOLTIP = "WAV status: returns 1/true if a .WAV file is playing, returns 0/false if not.";
Blockly.MSG_WAV_VOLUME_TOOLTIP = "WAV volume: sets the volume of the WAV player - 0 (quietest) to 10 (loudest).";
Expand Down
20 changes: 19 additions & 1 deletion src/main/webapp/frame/framec.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,14 @@
<block type="serial_send_text"></block>
<block type="serial_rx"></block>
<block type="serial_receive_text"></block>
<block type="shift_in"></block>
<block type="shift_out">
<value name="VALUE">
<block type="math_number">
<field name="NUM">10</field>
</block>
</value>
</block>
</category>
<category name="<fmt:message key="category.communicate.WS2812B" />">
<block type="ws2812b_init"></block>
Expand Down Expand Up @@ -557,7 +565,13 @@
<block type="wx_init"></block>
<block type="wx_config_page"></block>
<block type="wx_set_widget"></block>
<block type="wx_send_widget"></block>
<block type="wx_send_widget">
<value name="NUM">
<block type="math_number">
<field name="NUM">10</field>
</block>
</value>
</block>
<block type="wx_read_widgets"></block>
<block type="wx_get_widget"></block>
<block type="wx_evt_connected"></block>
Expand Down Expand Up @@ -682,6 +696,10 @@
</value>
</block>
</category>
<category name="<fmt:message key="category.analog-pulses.voltage" />" include="flip">
<block type="mcp320x_read"></block>
<block type="mcp320x_set_vref"></block>
</category>
</category>
<category name="<fmt:message key="category.audio" />" exclude="s3" colour="200">
<category name="<fmt:message key="category.audio.freqout" />" exclude="s3">
Expand Down