Skip to content

Commit 0f4a154

Browse files
committed
Merge remote-tracking branch 'origin/main' into python_spark_dev
2 parents ff02268 + 930d8a0 commit 0f4a154

15 files changed

Lines changed: 231 additions & 7 deletions

File tree

packages/blocks/src/blocks/arduino.ts

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,89 @@ const blocks: BlockDefinition = [
340340
"BKY_LEAPHY_DISPLAY_LARGE",
341341
6,
342342
),
343+
{
344+
type: "leaphy_lcd_clear",
345+
message0: "%{BKY_LEAPHY_LCD_CLEAR}",
346+
previousStatement: null,
347+
nextStatement: null,
348+
style: "leaphy_blocks",
349+
helpUrl: "",
350+
351+
aiHelp: "Clear the I2C LCD display",
352+
relevanceKey: "LEAPHY_LCD_DISPLAY",
353+
},
354+
{
355+
type: "leaphy_lcd_print_line",
356+
message0: "%{BKY_LEAPHY_LCD_PRINT} %1 %2 %3",
357+
args0: [
358+
{ type: "input_dummy" },
359+
{
360+
type: "field_dropdown",
361+
name: "DISPLAY_ROW",
362+
options: [
363+
["1", "0"],
364+
["2", "1"],
365+
],
366+
},
367+
{ type: "input_value", name: "VALUE" },
368+
],
369+
inputsInline: true,
370+
previousStatement: null,
371+
nextStatement: null,
372+
style: "leaphy_blocks",
373+
helpUrl: "",
374+
375+
aiHelp: "Print the value to the I2C LCD display on a selected row",
376+
relevanceKey: "LEAPHY_LCD_DISPLAY",
377+
},
378+
{
379+
type: "leaphy_lcd_print_value",
380+
message0: "%{BKY_LEAPHY_LCD_PRINT} %1 %2 %3 = %4 %5",
381+
args0: [
382+
{ type: "input_dummy" },
383+
{
384+
type: "field_dropdown",
385+
name: "DISPLAY_ROW",
386+
options: [
387+
["1", "0"],
388+
["2", "1"],
389+
],
390+
},
391+
{ type: "input_value", name: "NAME" },
392+
{ type: "input_dummy" },
393+
{ type: "input_value", name: "VALUE" },
394+
],
395+
inputsInline: true,
396+
previousStatement: null,
397+
nextStatement: null,
398+
style: "leaphy_blocks",
399+
helpUrl: "",
400+
401+
aiHelp:
402+
"Print the value with name to the I2C LCD display on a selected row",
403+
relevanceKey: "LEAPHY_LCD_DISPLAY",
404+
},
405+
{
406+
type: "leaphy_lcd_set_backlight",
407+
message0: "%{BKY_LEAPHY_LCD_SET_BACKLIGHT} %1",
408+
args0: [
409+
{
410+
type: "field_dropdown",
411+
name: "BACKLIGHT",
412+
options: [
413+
["%{BKY_LEAPHY_LCD_BACKLIGHT_ON}", "ON"],
414+
["%{BKY_LEAPHY_LCD_BACKLIGHT_OFF}", "OFF"],
415+
],
416+
},
417+
],
418+
previousStatement: null,
419+
nextStatement: null,
420+
style: "leaphy_blocks",
421+
helpUrl: "",
422+
423+
aiHelp: "Turn the backlight of the I2C LCD display on or off",
424+
relevanceKey: "LEAPHY_LCD_DISPLAY",
425+
},
343426
{
344427
type: "leaphy_gas_sensor",
345428
message0: "%%{BKY_LEAPHY_CHOOSE_GAS} %1",

packages/blocks/src/generators/arduino/dependencies.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
export enum Dependencies {
2-
LEAPHY_EXTENSIONS = "Leaphy Extensions@1.2.1",
2+
LEAPHY_EXTENSIONS = "Leaphy Extensions@1.2.3",
33
ARDUINO_BLE = "ArduinoBLE@1.4.0",
44
LIST = "List@3.0.1",
55

66
SERVO = "Servo@1.2.2",
77
ESP_SERVO = "ESP32Servo@3",
88

99
ADAFRUIT_SSD1306_OLED = "Adafruit SSD1306@2.5",
10+
LIQUIDCRYSTAL_PCF8574 = "LiquidCrystal_PCF8574@2.3.0",
1011
ADAFRUIT_SH110X_OLED = "Adafruit SH110X@2.1.12",
1112
ADAFRUIT_VL53L0X_TOF = "Adafruit_VL53L0X@1.2.4",
1213
ADAFRUIT_LSM6DS_ACCELEROMETER = "Adafruit LSM6DS@4.7.4",

packages/blocks/src/generators/arduino/leaphy_extra.ts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,61 @@ function getCodeGenerators(arduino: Arduino) {
260260

261261
createDisplayBlocks("leaphy_display", false);
262262
createDisplayBlocks("leaphy_display_large", true);
263+
264+
const addLCDSetupCode = () => {
265+
const lcdSetup = "lcd.begin(16, 2);\n lcd.setBacklight(255);\n";
266+
const setup = arduino.addI2CSetup("lcd", lcdSetup);
267+
268+
arduino.addDependency(Dependencies.LIQUIDCRYSTAL_PCF8574);
269+
arduino.addInclude("include_lcd", "#include <LiquidCrystal_PCF8574.h>");
270+
arduino.addInclude("define_lcd", "LiquidCrystal_PCF8574 lcd(0x27);");
271+
return setup;
272+
};
273+
274+
const addLCDPrintLine = () => {
275+
arduino.addDeclaration(
276+
"lcd_print_line",
277+
"void lcdPrintLine(uint8_t row, String value) {\n" +
278+
" lcd.setCursor(0, row);\n" +
279+
" lcd.print(value);\n" +
280+
" for (int i = value.length(); i < 16; i++) lcd.print(' ');\n" +
281+
"}\n",
282+
);
283+
};
284+
285+
arduino.forBlock.leaphy_lcd_clear = () => {
286+
const setup = addLCDSetupCode();
287+
return `${setup}lcd.clear();\n`;
288+
};
289+
290+
arduino.forBlock.leaphy_lcd_print_line = (block) => {
291+
const setup = addLCDSetupCode();
292+
addLCDPrintLine();
293+
294+
const value =
295+
arduino.valueToCode(block, "VALUE", arduino.ORDER_ATOMIC) || "0";
296+
const row = block.getFieldValue("DISPLAY_ROW");
297+
return `${setup}lcdPrintLine(${row}, String(${value}));\n`;
298+
};
299+
300+
arduino.forBlock.leaphy_lcd_print_value = (block) => {
301+
const setup = addLCDSetupCode();
302+
addLCDPrintLine();
303+
304+
const name =
305+
arduino.valueToCode(block, "NAME", arduino.ORDER_ATOMIC) || "0";
306+
const value =
307+
arduino.valueToCode(block, "VALUE", arduino.ORDER_ATOMIC) || "0";
308+
const row = block.getFieldValue("DISPLAY_ROW");
309+
return `${setup}lcdPrintLine(${row}, String(${name}) + " = " + String(${value}));\n`;
310+
};
311+
312+
arduino.forBlock.leaphy_lcd_set_backlight = (block) => {
313+
const setup = addLCDSetupCode();
314+
315+
const backlight = block.getFieldValue("BACKLIGHT");
316+
return `${setup}lcd.setBacklight(${backlight === "ON" ? "255" : "0"});\n`;
317+
};
263318
}
264319

265320
export default getCodeGenerators;

packages/blocks/src/generators/arduino/lists.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { type List, listManager } from "../../categories/lists";
22
import type { Arduino } from "../arduino";
3+
import { Dependencies } from "./dependencies";
34

45
function getCodeGenerators(arduino: Arduino) {
56
arduino.forBlock.lists_add = (block) => {
7+
arduino.addDependency(Dependencies.LIST);
68
const list = listManager.getItem(block.getFieldValue("LIST")) as List;
79
const value =
810
arduino.valueToCode(block, "VALUE", arduino.ORDER_ATOMIC) || "0";
@@ -12,6 +14,7 @@ function getCodeGenerators(arduino: Arduino) {
1214
};
1315

1416
arduino.forBlock.lists_delete = (block) => {
17+
arduino.addDependency(Dependencies.LIST);
1518
const list = listManager.getItem(block.getFieldValue("LIST")) as List;
1619
const index =
1720
arduino.valueToCode(block, "INDEX", arduino.ORDER_ATOMIC) || "0";
@@ -21,13 +24,15 @@ function getCodeGenerators(arduino: Arduino) {
2124
};
2225

2326
arduino.forBlock.lists_clear = (block) => {
27+
arduino.addDependency(Dependencies.LIST);
2428
const list = listManager.getItem(block.getFieldValue("LIST")) as List;
2529

2630
const name = list.name.replaceAll(" ", "_");
2731
return `${name}.clear();\n`;
2832
};
2933

3034
arduino.forBlock.lists_insert = (block) => {
35+
arduino.addDependency(Dependencies.LIST);
3136
const list = listManager.getItem(block.getFieldValue("LIST")) as List;
3237
const value =
3338
arduino.valueToCode(block, "VALUE", arduino.ORDER_ATOMIC) || "0";
@@ -39,6 +44,7 @@ function getCodeGenerators(arduino: Arduino) {
3944
};
4045

4146
arduino.forBlock.lists_get = (block) => {
47+
arduino.addDependency(Dependencies.LIST);
4248
const list = listManager.getItem(block.getFieldValue("LIST")) as List;
4349
const index =
4450
arduino.valueToCode(block, "INDEX", arduino.ORDER_ATOMIC) || "0";
@@ -48,6 +54,7 @@ function getCodeGenerators(arduino: Arduino) {
4854
};
4955

5056
arduino.forBlock.lists_replace = (block) => {
57+
arduino.addDependency(Dependencies.LIST);
5158
const list = listManager.getItem(block.getFieldValue("LIST")) as List;
5259
const value =
5360
arduino.valueToCode(block, "VALUE", arduino.ORDER_ATOMIC) || "0";
@@ -59,6 +66,7 @@ function getCodeGenerators(arduino: Arduino) {
5966
};
6067

6168
arduino.forBlock.lists_length = (block) => {
69+
arduino.addDependency(Dependencies.LIST);
6270
const list = listManager.getItem(block.getFieldValue("LIST")) as List;
6371

6472
const name = list.name.replaceAll(" ", "_");

packages/blocks/src/msg/translations/en.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,11 @@ messages.LEAPHY_DISPLAY_LARGE_CLEAR = "Clear large display";
130130
messages.LEAPHY_DISPLAY_LARGE_DISPLAY = "Show on large display";
131131
messages.LEAPHY_DISPLAY_LARGE_PRINT = "Large display - Set Ln.";
132132
messages.LEAPHY_DISPLAY_LARGE_SET_TEXT_SIZE = "Set text size for large display";
133+
messages.LEAPHY_LCD_CLEAR = "Clear LCD";
134+
messages.LEAPHY_LCD_PRINT = "LCD - Set Line";
135+
messages.LEAPHY_LCD_SET_BACKLIGHT = "Turn LCD backlight";
136+
messages.LEAPHY_LCD_BACKLIGHT_ON = "on";
137+
messages.LEAPHY_LCD_BACKLIGHT_OFF = "off";
133138
messages.LEAPHY_EXTRA_CATEGORY = "Leaphy Extra";
134139
messages.LEAPHY_FLITZ_CATEGORY = "Leaphy Flitz";
135140
messages.LEAPHY_FLITZ_LED = "Nose light - ";

packages/blocks/src/msg/translations/nl.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@ messages.LEAPHY_DISPLAY_LARGE_DISPLAY = "Toon op groot display";
136136
messages.LEAPHY_DISPLAY_LARGE_PRINT = "Stel groot display in - Rg.";
137137
messages.LEAPHY_DISPLAY_LARGE_SET_TEXT_SIZE =
138138
"Zet tekstgrootte van groot display op";
139+
messages.LEAPHY_LCD_CLEAR = "Maak LCD leeg";
140+
messages.LEAPHY_LCD_PRINT = "Stel LCD in - Regel";
141+
messages.LEAPHY_LCD_SET_BACKLIGHT = "Zet LCD achtergrondlicht";
142+
messages.LEAPHY_LCD_BACKLIGHT_ON = "aan";
143+
messages.LEAPHY_LCD_BACKLIGHT_OFF = "uit";
139144
messages.LEAPHY_EXTRA_CATEGORY = "Leaphy Extra"; // untranslated
140145
messages.LEAPHY_FLITZ_CATEGORY = "Leaphy Flitz"; // untranslated
141146
messages.LEAPHY_FLITZ_LED = "Neuslamp -";

packages/blocks/src/msg/translations/ua.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,11 @@ messages.LEAPHY_DISPLAY_LARGE_DISPLAY = "Показати на великому
130130
messages.LEAPHY_DISPLAY_LARGE_PRINT = "Великий дисплей - Вст. рядок";
131131
messages.LEAPHY_DISPLAY_LARGE_SET_TEXT_SIZE =
132132
"Встановити розмір тексту великого дисплея";
133+
messages.LEAPHY_LCD_CLEAR = "Очистити LCD";
134+
messages.LEAPHY_LCD_PRINT = "LCD - Вст. рядок";
135+
messages.LEAPHY_LCD_SET_BACKLIGHT = "Підсвітка LCD";
136+
messages.LEAPHY_LCD_BACKLIGHT_ON = "увімк";
137+
messages.LEAPHY_LCD_BACKLIGHT_OFF = "вимк";
133138
messages.LEAPHY_EXTRA_CATEGORY = "Leaphy Extra";
134139
messages.LEAPHY_FLITZ_CATEGORY = "Leaphy Flitz";
135140
messages.LEAPHY_FLITZ_LED = "Підсвітка носа - ";

packages/client/src/assets/translations/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@
266266
"LED_STRIP_SECTION": "Led strip",
267267
"STANDARD_DISPLAY_SECTION": "Standard display",
268268
"LARGE_DISPLAY_SECTION": "Large display",
269+
"LCD_DISPLAY_SECTION": "LCD display",
269270
"MATRIX_DISPLAY_SECTION": "Matrix display",
270271
"SEGMENT_DISPLAY_SECTION": "Segment display",
271272
"AUDIO_SECTION": "Audio",

packages/client/src/assets/translations/nl.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@
266266
"LED_STRIP_SECTION": "Led strip",
267267
"STANDARD_DISPLAY_SECTION": "Standaard scherm",
268268
"LARGE_DISPLAY_SECTION": "Groot scherm",
269+
"LCD_DISPLAY_SECTION": "LCD scherm",
269270
"MATRIX_DISPLAY_SECTION": "Matrix scherm",
270271
"SEGMENT_DISPLAY_SECTION": "Segment scherm",
271272
"AUDIO_SECTION": "Geluid",

packages/client/src/assets/translations/ua.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@
266266
"LED_STRIP_SECTION": "LED-стрічка",
267267
"STANDARD_DISPLAY_SECTION": "Стандартний дисплей",
268268
"LARGE_DISPLAY_SECTION": "Великий дисплей",
269+
"LCD_DISPLAY_SECTION": "LCD дисплей",
269270
"MATRIX_DISPLAY_SECTION": "Матричний дисплей",
270271
"SEGMENT_DISPLAY_SECTION": "Сегментний дисплей",
271272
"AUDIO_SECTION": "Аудіо",

0 commit comments

Comments
 (0)