Skip to content

Commit 4eb8664

Browse files
Merge pull request #45 from parallaxinc/develop
Update local develop branch
2 parents 2cd2780 + 960fee9 commit 4eb8664

File tree

12 files changed

+291
-73
lines changed

12 files changed

+291
-73
lines changed

blocklyc.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@
7373
<title>BlocklyProp Solo</title>
7474

7575
<!-- JavaScript libraries -->
76+
<script src="https://browser.sentry-cdn.com/5.12.1/bundle.min.js"
77+
integrity="sha384-y+an4eARFKvjzOivf/Z7JtMJhaN6b+lLQ5oFbBbUwZNNVir39cYtkjW1r6Xjbxg3"
78+
crossorigin="anonymous">
79+
</script>
7680
<script type="text/javascript" src="src/lib/chartist.min.js"></script>
7781
<script type="text/javascript" src="src/lib/jquery-1.11.3.min.js"></script>
7882
<script type="text/javascript" src="src/lib/jquery.validate.min.js"></script>

index.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@
5959

6060
<script type="application/javascript" src="src/lib/jquery-1.11.3.min.js"></script>
6161
<script type="application/javascript" src="src/lib/bootstrap/core/js/bootstrap.min.js"></script>
62+
<script src="https://browser.sentry-cdn.com/5.12.1/bundle.min.js"
63+
integrity="sha384-y+an4eARFKvjzOivf/Z7JtMJhaN6b+lLQ5oFbBbUwZNNVir39cYtkjW1r6Xjbxg3"
64+
crossorigin="anonymous">
65+
</script>
6266
<script type="application/javascript" src="src/globals.js"></script>
6367
<script type="application/javascript" src="src/utils.js"></script>
6468
<script type="application/javascript" src="src/index.js"></script>
@@ -152,7 +156,7 @@ <h4 class="modal-title w-100" id="licenseLabel">BlocklyProp Solo License</h4>
152156
<li><a onclick="showLicense()">License</a></li>
153157
<li>
154158
<a href="http://www.parallax.com" target="_blank">
155-
v1.4.1 Parallax &copy; 2015 - <span id="footer_copyright"></span></a>
159+
v1.4.2.4 Parallax &copy; 2015 - <span id="footer_copyright"></span></a>
156160
</li>
157161
</ul>
158162
</div>

package-lock.json

Lines changed: 58 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
},
1919
"homepage": "https://github.com/parallaxinc/solo#readme",
2020
"dependencies": {
21+
"@sentry/browser": "^5.12.1",
2122
"blockly": "^2.20190722.1",
2223
"bootstrap": "^3.4.1",
2324
"jquery": "^3.4.1"

src/blockly/generators/propc/gpio.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,9 @@ Blockly.Blocks.base_freqout = {
369369
.appendRange('R,0,40000000,0')
370370
.appendField("frequency (Hz)")
371371
.setCheck('Number');
372-
this.setInputsInline(true);
372+
// Align inputs vertically - solo #313
373+
this.setInputsInline(false);
374+
373375
this.setPreviousStatement(true, "Block");
374376
this.setNextStatement(true, null);
375377
},

src/blockly/generators/propc/sensors.js

Lines changed: 108 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,9 +1004,12 @@ Blockly.Blocks.lis3dh_init = {
10041004
.appendField(new Blockly.FieldDropdown(profile.default.digital), 'SDI_PIN')
10051005
.appendField("CS")
10061006
.appendField(new Blockly.FieldDropdown(profile.default.digital), 'CS_PIN')
1007-
.appendField('', 'TEMP')
1008-
.appendField('', 'UNIT')
1009-
.appendField('', 'SMOOTHING');
1007+
.appendField('', 'TEMP') // Temperature calibration
1008+
.appendField('', 'UNIT') // Temperature calibration
1009+
.appendField('', 'SMOOTHING') // Tilt axis smoothing
1010+
.appendField('', 'VSS_VOLTAGE') // ADC ground offset initialization
1011+
.appendField('', 'VDD_VOLTAGE'); // ADC 3.3 offset initialization
1012+
10101013
this.setInputsInline(false);
10111014
this.setPreviousStatement(true, "Block");
10121015
this.setNextStatement(true, null);
@@ -1050,30 +1053,81 @@ Blockly.Blocks.lis3dh_init = {
10501053
.appendField(new Blockly.FieldNumber('0', 0, 100, 1), "SMOOTHING");
10511054
this.setFieldValue(smoothing || '0', 'SMOOTHING');
10521055

1056+
// This has to appear above the voltage block if one is defined.
1057+
if (this.getInput('VOLT_CALIBRATE') ) {
1058+
this.moveInputBefore('TILT_CALIBRATE', 'VOLT_CALIBRATE');
1059+
}
10531060
} else if (!hasTiltBlocks && this.getInput('TILT_CALIBRATE')) {
10541061
this.removeInput('TILT_CALIBRATE');
10551062
if (!this.getField('SMOOTHING')) {
10561063
this.getInput('PINS').appendField('', 'SMOOTHING');
10571064
}
10581065
}
10591066
},
1067+
buildVoltageInput: function(hasVoltageBlocks) {
1068+
// Create a init field for the ADC voltage offset
1069+
if (hasVoltageBlocks && !this.getInput('VOLT_CALIBRATE')) {
1070+
// Ground calibration value
1071+
var vssVoltField = this.getInput('VSS_VOLTAGE');
1072+
1073+
// 3.3 volt calibration
1074+
var vddVoltField = this.getInput('VDD_VOLTAGE')
1075+
1076+
this.getInput('PINS').removeField('VSS_VOLTAGE');
1077+
this.getInput('PINS').removeField('VDD_VOLTAGE');
1078+
1079+
1080+
this.appendDummyInput('VOLT_CALIBRATE')
1081+
.appendField('calibrate ADC GND ')
1082+
.appendField(
1083+
new Blockly.FieldNumber(
1084+
'0',
1085+
null,
1086+
null,
1087+
1
1088+
),"VSS_VOLTAGE")
1089+
.appendField(' 3.3V ')
1090+
.appendField(
1091+
new Blockly.FieldNumber(
1092+
'0',
1093+
null,
1094+
null,
1095+
1
1096+
), "VDD_VOLTAGE");
1097+
1098+
this.setFieldValue(vssVoltField || '0', 'VSS_VOLTAGE');
1099+
this.setFieldValue(vddVoltField || '0', 'VDD_VOLTAGE');
1100+
1101+
// Move this input field to the bottom of the init block
1102+
this.moveInputBefore('VOLT_CALIBRATE', null);
1103+
} else if (!hasVoltageBlocks && this.getInput('VOLT_CALIBRATE')) {
1104+
// Destroy the ADC init fields
1105+
this.removeInput('VOLT_CALIBRATE');
1106+
if (!this.getField('VOLTAGE')) {
1107+
this.getInput('PINS').appendField('', 'VSS_VOLTAGE');
1108+
this.getInput('PINS').appendField('', 'VDD_VOLTAGE');
1109+
}
1110+
}
1111+
},
1112+
10601113
onchange: function (event) {
1114+
// Act when the block is dragged from the fly-out to the canvas
10611115
if (event && !this.isInFlyout) {
10621116
var warnText = null;
1063-
if (Blockly.getMainWorkspace().getBlocksByType(this.type).length > 1) {
1117+
if (Blockly.getMainWorkspace().getBlocksByType(this.type, false).length > 1) {
10641118
warnText = 'WARNING! Only one LIS3DH init block can be used!';
10651119
}
10661120
this.setWarningText(warnText);
10671121

10681122
// Look for read temperature blocks
10691123
var tempBlocksPresent = false;
1070-
if ((Blockly.getMainWorkspace().getBlocksByType('lis3dh_temp') || []).length > 0) {
1124+
if ((Blockly.getMainWorkspace().getBlocksByType('lis3dh_temp', false) || []).length > 0) {
10711125
tempBlocksPresent = true;
10721126
}
10731127
this.buildTempInput(tempBlocksPresent);
10741128

10751129
// Look for read tilt blocks
1076-
var tiltBlockList = Blockly.getMainWorkspace().getBlocksByType('lis3dh_read') || [];
1130+
var tiltBlockList = Blockly.getMainWorkspace().getBlocksByType('lis3dh_read', false) || [];
10771131
var tiltBlocksPresent = false;
10781132
for (var i = 0; i < tiltBlockList.length; i++) {
10791133
if (tiltBlockList[i].getFieldValue('SENSOR') === 'tilt') {
@@ -1082,6 +1136,17 @@ Blockly.Blocks.lis3dh_init = {
10821136
}
10831137
}
10841138
this.buildSmoothingInput(tiltBlocksPresent);
1139+
1140+
// Look for read voltage blocks
1141+
var voltBlockList = Blockly.getMainWorkspace().getBlocksByType('lis3dh_read', false) || [];
1142+
var voltBlocksPresent = false;
1143+
for (var i = 0; i < tiltBlockList.length; i++) {
1144+
if (voltBlockList[i].getFieldValue('SENSOR') === 'adc_mV') {
1145+
voltBlocksPresent = true;
1146+
break;
1147+
}
1148+
}
1149+
this.buildVoltageInput(voltBlocksPresent);
10851150
}
10861151
}
10871152
};
@@ -1090,10 +1155,12 @@ Blockly.propc.lis3dh_init = function () {
10901155
var sck_pin = this.getFieldValue('SCK_PIN');
10911156
var sdi_pin = this.getFieldValue('SDI_PIN');
10921157
var cs_pin = this.getFieldValue('CS_PIN');
1158+
10931159
if (!this.disabled) {
10941160
Blockly.propc.definitions_["lis3dh"] = '#include "lis3dh.h"';
10951161
Blockly.propc.global_vars_["lis3dh_init"] = 'lis3dh *lis3dh_sensor;';
10961162
var setupCode = 'lis3dh_sensor = lis3dh_init(' + sck_pin + ', ' + sdi_pin + ', ' + cs_pin + ');';
1163+
10971164
if (this.getInput('TEMP_CALIBRATE')) {
10981165
var temp_val = this.getFieldValue('TEMP');
10991166
var temp_unit = this.getFieldValue('UNIT');
@@ -1103,6 +1170,23 @@ Blockly.propc.lis3dh_init = function () {
11031170
if (this.getInput('TILT_CALIBRATE') && tilt_smoothing !== 0) {
11041171
setupCode += 'lis3dh_tiltConfig(lis3dh_sensor, 100 - ' + tilt_smoothing + ');';
11051172
}
1173+
1174+
if (this.getInput('VOLT_CALIBRATE')) {
1175+
var vssVoltField = this.getFieldValue('VSS_VOLTAGE');
1176+
var vddVoltField = this.getFieldValue('VDD_VOLTAGE');
1177+
1178+
if ((vssVoltField !== undefined) && (vddVoltField !== undefined)) {
1179+
setupCode += 'lis3dh_adcCal_mV(lis3dh_sensor, ';
1180+
1181+
if (vssVoltField === 0 && vddVoltField === 0) {
1182+
setupCode += '0, 0, 0, 0 );';
1183+
}
1184+
else {
1185+
setupCode += '0, 3300, ' + vssVoltField + ', ' + vddVoltField + ');';
1186+
}
1187+
}
1188+
}
1189+
11061190
Blockly.propc.setups_["lis3dh_init"] = setupCode + '\n';
11071191
}
11081192
return '';
@@ -1113,13 +1197,17 @@ Blockly.Blocks.lis3dh_read = {
11131197
init: function () {
11141198
this.setTooltip(Blockly.MSG_LIS3DH_READ_TOOLTIP);
11151199
this.setColour(colorPalette.getColor('input'));
1200+
11161201
this.appendDummyInput('ACTION')
11171202
.appendField("LIS3DH read")
1118-
.appendField(new Blockly.FieldDropdown([
1119-
['acceleration (1000ths of g\'s)', 'accel_mg'],
1120-
['voltage (mV)', 'adc_mV'],
1121-
['tilt (degrees)', 'tilt']
1122-
], function (action) {this.getSourceBlock().configureFields(action)}), 'SENSOR');
1203+
.appendField(
1204+
new Blockly.FieldDropdown([
1205+
['acceleration (1000ths of g\'s)', 'accel_mg'],
1206+
['tilt (degrees)', 'tilt'],
1207+
['voltage (mV)', 'adc_mV']
1208+
], function (action) {this.getSourceBlock().configureFields(action)}),
1209+
'SENSOR');
1210+
11231211
this.appendDummyInput('VARS')
11241212
.appendField("store X in", 'LABEL_0')
11251213
.appendField(new Blockly.FieldVariable(Blockly.LANG_VARIABLES_GET_ITEM), 'STORE_1')
@@ -1131,25 +1219,23 @@ Blockly.Blocks.lis3dh_read = {
11311219
this.setInputsInline(false);
11321220
this.setPreviousStatement(true, "Block");
11331221
this.setNextStatement(true, null);
1222+
1223+
// Field values - this gets populated in the configureFields method
11341224
this.fieldVals = [];
11351225
},
1136-
configureFields: function (action) {
1226+
configureFields: function (action) {
1227+
// Set default if no action provided.
11371228
if (!action) {
11381229
action = 'accel_mg';
11391230
}
11401231

11411232
// The value of this field determines how the block will appear
11421233
var blockText = {
1143-
'accel_mg': {
1144-
label: ['store X in', 'Y in', 'Z in'],
1145-
},
1146-
'adc_mV': {
1147-
label: ['store AD1 in', 'AD2 in', 'AD3 in'],
1148-
},
1149-
'tilt': {
1150-
label: ['store X in', 'Y in', 'Z in'],
1151-
}
1152-
}
1234+
'accel_mg': {label: ['store X in', 'Y in', 'Z in']},
1235+
'adc_mV': {label: ['store AD1 in', 'AD2 in', 'AD3 in']},
1236+
'tilt': {label: ['store X in', 'Y in', 'Z in']}
1237+
};
1238+
11531239
for (var i = 0; i < 3; i++) {
11541240
this.setFieldValue(blockText[action].label[i], 'LABEL_' + i.toString(10));
11551241
}

src/blockly/language/en/messages.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ Blockly.MSG_LSM9DS1_READ_TOOLTIP = "IMU read: get measurements from specified se
468468
Blockly.MSG_LSM9DS1_MAG_CALIBRATE_TOOLTIP = "IMU Calibrate Magnetometer: Initialize first. Rotate slowly thru all 3 axes until P26/P27 LEDs turn off.";
469469
Blockly.MSG_LSM9DS1_TILT_TOOLTIP = "IMU tilt: gets tilt along specified axis.";
470470
Blockly.MSG_LSM9DS1_HEADING_TOOLTIP = "IMU heading: specify axes, get current heading in degrees.";
471-
Blockly.MSG_LIS3DH_INIT_TOOLTIP = "LIS3DH initialize: match to Propeller I/O pin connections. If LIS3DH tilt blocks are used, specify a smoothing factor (between 0-100). If LIS3DH temperature blocks are used, set an initial temperature.";
471+
Blockly.MSG_LIS3DH_INIT_TOOLTIP = "LIS3DH initialize: match to Propeller I/O pin connections. If measuring tilt, set a smoothing factor (0-100). If measuring temperature, set an initial value and units. If measuring ADC voltage, set an offset value (+/- 500 mV). \nRight click and choose Help.";
472472
Blockly.MSG_LIS3DH_READ_TOOLTIP = "LIS3DH read: Select the sensors to read, then select the variables to store the readings into.";
473473
Blockly.MSG_LIS3DH_TEMP_TOOLTIP = "LIS3DH temperature: read the temperature.";
474474
Blockly.MSG_SENSOR_PING_TOOLTIP = "Ping))) distance: gets distance measured in the specified units, match to Propeller I/O pin.";
@@ -800,8 +800,9 @@ page_text_label['clientdownload_os_menu'] = "Choose a different operating system
800800
page_text_label['clientdownload_showall'] = "Show clients for all operating systems";
801801
page_text_label['clientdownload_title'] = "BlocklyProp Launcher";
802802

803+
/* BP Client dialog messages */
803804
page_text_label['client_unknown'] = "BlocklyProp is unable to determine what version of BlocklyProp Launcher is installed on your computer.<br>You may need to install or reinstall the BlocklyProp Launcher.";
804-
page_text_label['client_update_warning'] = "BlocklyProp Solo requires BlocklyProp Launcher version <span class=\"client-required-version\"></span>, or later.<br>You are using incompatible software: BlocklyProp Client version <span class=\"client-your-version\"></span>.<br>Download and install the latest software from the link below.";
805+
page_text_label['client_update_warning'] = "BlocklyProp Solo requires BlocklyProp Launcher version <span class=\"client-required-version\"></span>, or later.<br><br>The version detected on your system, BlocklyProp Client version <span class=\"client-your-version\"></span> may not work<br>correctly with Solo. We recommend downloading and installing the latest software for<br>best results. You can use the link below to get started.";
805806
page_text_label['client_update_danger'] = "BlocklyProp now requires at least version <span class=\"client-required-version\"></span> of BlocklyProp Launcher.<br>You appear to be using BlocklyProp Launcher version <span class=\"client-your-version\"></span>.<br>You will not be able to load projects to your device until you upgrade your BlocklyProp Launcher.<br>Please use the link below to download the newest version.";
806807

807808
page_text_label['confirm_do_email'] = "Email:";

0 commit comments

Comments
 (0)