Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/microsoft/pxt into kim-in…
Browse files Browse the repository at this point in the history
…puts
  • Loading branch information
kimprice committed Sep 10, 2024
2 parents dbd3d33 + 09cbe2b commit 368cca1
Show file tree
Hide file tree
Showing 45 changed files with 715 additions and 297 deletions.
1 change: 1 addition & 0 deletions common-docs/reference/text/char-at.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ for (let i = 0; i < sentence.length; i++) {

## See also

[char code at](/reference/text/char-code-at),
[substr](/reference/text/substr)
33 changes: 33 additions & 0 deletions common-docs/reference/text/char-code-at.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# char Code At

Get the code for a character (letter, number, or symbol) from a place in a text string.

```sig
"".charCodeAt(0)
```

Like the position of a character in the an alphabet, or the traditional order of characters in a language, characters are assigned a code in a character set when used with computers. If a character set used only the 5 characters of "ABCDE", then 'A', as the first character, would have a character code of `0` and 'D' would have a charcter code of `3`.

You can find the code of a character in a text string by selecting it from it's position in a string.

## Parameters

* **index**: the [number](/types/number) for the position in the text string to return a character code for.

## Returns

* a [number](/types/string) that is the code in the character set for the selected position in the text string.

## Example

Find the character code for the character at position `6` in a string.

```blocks
let sentence = "Super space ship"
let myCharCode = sentence.charCodeAt(6)
```

## See also

[char at](/reference/text/char-at),
[substr](/reference/text/substr)
12 changes: 6 additions & 6 deletions common-docs/teachertool/catalog-shared.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
{
"id": "59AAC5BA-B0B3-4389-AA90-1E767EFA8563",
"use": "block_used_n_times",
"template": "${Block} used ${count} times",
"description": "This block was used the specified number of times in your project.",
"template": "${Block} used at least ${count} time(s)",
"description": "This block was used at least the specified number of times in your project.",
"docPath": "/teachertool",
"tags": ["General"],
"params": [
Expand All @@ -24,7 +24,7 @@
{
"id": "7AE7EA2A-3AC8-42DC-89DB-65E3AE157156",
"use": "block_comment_used",
"template": "At least ${count} comments",
"template": "At least ${count} comment(s)",
"description": "The project contains at least the specified number of comments.",
"docPath": "/teachertool",
"maxCount": 1,
Expand All @@ -41,7 +41,7 @@
{
"id": "B8987394-1531-4C71-8661-BE4086CE0C6E",
"use": "n_loops",
"template": "At least ${count} loops used",
"template": "At least ${count} loop(s) used",
"docPath": "/teachertool",
"description": "The program uses at least this many loops of any kind (for, repeat, while, or for-of).",
"maxCount": 1,
Expand All @@ -58,7 +58,7 @@
{
"id": "79D5DAF7-FED3-473F-81E2-E004922E5F55",
"use": "custom_function_called",
"template": "At least ${count} custom functions exist and get called",
"template": "At least ${count} custom function(s) exist and get called",
"docPath": "/teachertool",
"description": "At least this many user-defined functions are created and called.",
"maxCount": 1,
Expand All @@ -75,7 +75,7 @@
{
"id": "0DFA44C8-3CA5-4C77-946E-AF09F6C03879",
"use": "variable_usage",
"template": "Uses at least ${count} variables",
"template": "Uses at least ${count} variable(s)",
"docPath": "/teachertool",
"description": "The program creates and uses at least this many user-defined variables.",
"maxCount": 1,
Expand Down
2 changes: 1 addition & 1 deletion common-docs/teachertool/test/catalog-shared.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"template": "Ask AI: ${question}",
"description": "Experimental: AI outputs may not be accurate. Use with caution and always review responses.",
"docPath": "/teachertool",
"maxCount": 10,
"maxCount": 5,
"tags": ["General"],
"requestFeedback": true,
"params": [
Expand Down
8 changes: 8 additions & 0 deletions docs/blog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Microsoft MakeCode Blog

## [MakeCode for the micro:bit 2024 Update](/blog/microbit/2024-update)

September 4, 2024 by [Jaqster](https://github.com/jaqster)

Today we are releasing our annual update for [MakeCode for the micro:bit](https://makecode.microbit.org). This year we have been focusing on some core foundational and infrastructure-level work...

**[Continue reading this blog post](/blog/microbit/2024-update)**

## [MakeCode Arcade - now more ways to play!](/blog/arcade/arcade-on-microbit-xbox)

November 6th, 2023 by [Jaqster](https://github.com/jaqster)
Expand Down
1 change: 1 addition & 0 deletions docs/blog/SUMMARY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Microsoft MakeCode Blog

* [Blog](/blog)
* [MakeCode for the micro:bit 2024 Update](/blog/microbit/2024-update)
* [MakeCode Arcade - now more ways to play!](/blog/arcade/arcade-on-microbit-xbox)
* [MakeCode Minecraft 2023 Update](/blog/minecraft/2023-release)
* [MakeCode Clever Integration Released!](/blog/clever-release)
Expand Down
92 changes: 92 additions & 0 deletions docs/blog/microbit/2024-update.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# MakeCode for the micro:bit 2024 Update

**Posted on September 4, 2024 by [Jaqster](https://github.com/jaqster)**

Today we are releasing our annual update for [MakeCode for the micro:bit](https://makecode.microbit.org). This year we have been focusing on some core foundational and infrastructure-level work to ensure that MakeCode is set up for future success and is more reliable and secure than ever before.

## Security & privacy comes first

In alignment with [Microsoft’s Secure Future Initiative](https://blogs.microsoft.com/blog/2024/05/03/prioritizing-security-above-all-else), we have worked to ensure that MakeCode adheres to strict product security policies and follows all the best practices of [Microsoft’s Security Development Lifecycle](https://www.microsoft.com/en-us/securityengineering/sdl) approach to building software. As an educational product, we know that security and privacy are paramount to any digital learning experience used in schools. And we are committed to ensuring that MakeCode remains a safe, secure environment for learning. For more information about Microsoft MakeCode’s privacy policies, please visit [makecode.com/privacy-faq](https://makecode.com/privacy-faq).

![Microsoft logo](/static/blog/microbit/2024-update/msft-logo.png)

## Blockly update

Another big foundational area of work for us this past year has been to upgrade the MakeCode visual programming interface to use the latest Blockly library. MakeCode has a long-standing partnership with the [Google Blockly Team](https://developers.google.com/blockly) who build the underlying library that almost all visual programming languages use. You shouldn't notice any big visual differences in the MakeCode blocks, but by upgrading we are now able to access all the latest Blockly plugins and features, including support for future work around [accessible blocks](https://developers.google.com/blockly/accessibility). If you’re interested in learning more about our work on the "Great Blockly Upgrade", watch this talk from the [Blockly Summit](https://youtu.be/SoXN61lSL9U).

![Blockly logo](/static/blog/microbit/2024-update/blockly-logo.png)

## Version history

Have you ever been working on a project when all of a sudden, your evil twin takes over and completely destroys your work and introduces a ton of bugs? Well, never fear, Version History is here! You can access previous versions of your code through the Project Settings menu in the upper right corner.

![Project settings menu](/static/blog/microbit/2024-update/project-settings-menu.jpg)

In the **Version History** pane, you can see the timestamps of when your code was automatically saved. You can click on the different times to see the version of your code at that time, and you can see when you shared your project. Using the buttons at the top, you can save a copy of any version of your program, or you can restore an older version of your code (before your evil twin took over).

![Version history animation](/static/blog/microbit/2024-update/version-history.gif)

## Tutorial accessibility improvements

We released [Immersive Reader](https://youtu.be/ZYJhQ0HNvq4) support for tutorial instructions back in 2021 in order to support students with literacy challenges. We’re continuing to improve the accessibility of our tutorials for color blind and vision impaired users by changing the block name color highlighting to include the icon and improve color contrast readability.

![Tutorial instructions](/static/blog/microbit/2024-update/tutorial-instructions.jpg)

## Audio recording improvements in simulator

Last year we released the [audio recording and playback extension](https://makecode.com/blog/microbit/2023-release) allowing students record short audio clips and play them back on the micro:bit. This year we made some improvements to better support this extension in the micro:bit on-screen simulator as well – specifically to support the sample rate to better mimic the sounds on hardware. Now students can experiment with recording audio with their computer where they will hear:

* Worse audio quality at lower sample rates (and better at higher)
* Longer recording times at lower sample rates (and shorter at higher)
* The ability to change playback speed by changing the output sample rate

![Audio sampling](/static/blog/microbit/2024-update/audio-sampling.jpg)

## WebUSB reliability

[Last year](https://makecode.com/blog/microbit/2023-release) we released the new "one-click-to-download" functionality supported by WebUSB. Since then, we’ve done a lot of work to ensure that this method of pairing the micro:bit to the browser is reliable and just works all the time across different platforms. Please try it out – it should be very stable. If you are still experiencing any issues with downloading programs to the micro:bit through this method, please let us know by filing a ticket at the [micro:bit support desk](https://support.microbit.org/support/tickets/new).

## New blocks

And finally, we do have a few new blocks in this release –

### Char code from string

This is a helpful Text block that will return the ASCII code of a character in a string at a specified index position.

![CharCode block](/static/blog/microbit/2024-update/char-code-block.jpg)

### Pins update

Big thanks to GitHub contributor [Sae](https://github.com/sae220) who helped us make this subtle change to allow for more flexibility in programming the micro:bit pins. MakeCode allows you to read from and write to pins **P0-P16** on the micro:bit, and these pins can be used for both analog and/or digital signals. To learn more about the micro:bit pins, see https://makecode.microbit.org/device/pins. In this release, we updated the pins blocks to allow for dragging and dropping different pin values and even variables.

![Old pin identifiers](/static/blog/microbit/2024-update/old-pin-identifiers.png)
_Old Pins_
<br/><br/>

![New pin identifiers](/static/blog/microbit/2024-update/new-pin-identifiers.png)
_New Pins_
<br/><br/>

![New pins blocks animation](/static/blog/microbit/2024-update/new-pins.gif)

### Nested blocks

It's not new, but we’ve improved the color contrast for nested blocks of the same color with a lighter border to make them more readable.

![Old nested blocks](/static/blog/microbit/2024-update/old-nested-blocks.png)
_Old nested blocks_
<br/><br/>

![New nested blocks](/static/blog/microbit/2024-update/new-nested-blocks.png)
_New nested blocks_
<br/><br/>

Thank you to everyone who has logged bugs, submitted PR’s, translated and suggested new features throughout the year! Any new bugs you find in this release, please log them as a [GitHub issue](https://github.com/Microsoft/pxt-microbit/issues).

As for any other comments, suggestions, and feedback, please participate in the micro:bit community on [Slack](https://tech.microbit.org/get-involved/where-to-find) or the [MakeCode Forum](https://forum.makecode.com).

Happy Making and Coding!

<br/>
The MakeCode Team
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions localtypings/pxtarget.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,7 @@ declare namespace pxt {

dragFileImage?: string;
connectDeviceImage?: string;
disconnectDeviceImage?: string;
selectDeviceImage?: string;
connectionSuccessImage?: string;
incompatibleHardwareImage?: string;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pxt-core",
"version": "10.3.3",
"version": "10.3.5",
"description": "Microsoft MakeCode provides Blocks / JavaScript / Python tools and editors",
"keywords": [
"TypeScript",
Expand Down
53 changes: 47 additions & 6 deletions pxtblocks/contextMenu/blockItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,19 @@ enum BlockContextWeight {
}

export function registerBlockitems() {
// Unregister the builtin options that we don't use
Blockly.ContextMenuRegistry.registry.unregister("blockDuplicate");
Blockly.ContextMenuRegistry.registry.unregister("blockCollapseExpand");
Blockly.ContextMenuRegistry.registry.unregister("blockHelp");
Blockly.ContextMenuRegistry.registry.unregister("blockInline");

registerDuplicate();
registerCollapseExpandBlock();
registerHelp();

// Fix the weights of the builtin options we do use
Blockly.ContextMenuRegistry.registry.getItem("blockDelete").weight = BlockContextWeight.DeleteBlock;
Blockly.ContextMenuRegistry.registry.getItem("blockComment").weight = BlockContextWeight.AddComment;
Blockly.ContextMenuRegistry.registry.getItem("blockDuplicate").weight = BlockContextWeight.Duplicate;

// Unregister the builtin options that we don't use
Blockly.ContextMenuRegistry.registry.unregister("blockCollapseExpand");
Blockly.ContextMenuRegistry.registry.unregister("blockHelp");
Blockly.ContextMenuRegistry.registry.unregister("blockInline");
}

/**
Expand Down Expand Up @@ -100,3 +101,43 @@ function registerHelp() {
Blockly.ContextMenuRegistry.registry.register(helpOption);
}

function registerDuplicate() {
const duplicateOption: Blockly.ContextMenuRegistry.RegistryItem = {
displayText() {
return lf("Duplicate")
},
preconditionFn(scope: Blockly.ContextMenuRegistry.Scope) {
const block = scope.block;
if (!block!.isInFlyout && block!.isDeletable() && block!.isMovable()) {
if (block!.isDuplicatable()) {
return 'enabled';
}
return 'disabled';
}
return 'hidden';
},
callback(scope: Blockly.ContextMenuRegistry.Scope) {
if (!scope.block) return;

let duplicateOnDrag = false;
if ((scope.block as any).duplicateOnDrag_) {
(scope.block as any).duplicateOnDrag_ = false;
duplicateOnDrag = true;
}

const data = scope.block.toCopyData();

if (duplicateOnDrag) {
(scope.block as any).duplicateOnDrag_ = true;
}

if (!data) return;

Blockly.clipboard.paste(data, scope.block.workspace);
},
scopeType: Blockly.ContextMenuRegistry.ScopeType.BLOCK,
id: 'blockDuplicate',
weight: BlockContextWeight.Duplicate,
};
Blockly.ContextMenuRegistry.registry.register(duplicateOption);
}
7 changes: 7 additions & 0 deletions pxtblocks/contextMenu/workspaceItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ function registerSnapshotCode() {
pxt.tickEvent("blocks.context.screenshot", undefined, { interactiveConsent: true });
(async () => {
let uri = await screenshotAsync(scope.workspace, null, pxt.appTarget.appTheme?.embedBlocksInSnapshot);

if (pxt.BrowserUtils.isSafari()) {
// For some reason, Safari doesn't always load embedded images the first time. This is a silly fix,
// but snapshotting a second time fixes the issue.
uri = await screenshotAsync(scope.workspace, null, pxt.appTarget.appTheme?.embedBlocksInSnapshot);
}

if (pxt.BrowserUtils.isSafari()) {
uri = uri.replace(/^data:image\/[^;]/, 'data:application/octet-stream');
}
Expand Down
6 changes: 6 additions & 0 deletions pxtblocks/fields/field_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -478,4 +478,10 @@ export function setBlockDataForField(block: Blockly.Block, field: string, data:

export function getBlockDataForField(block: Blockly.Block, field: string) {
return getBlockData(block).fieldData[field];
}

export function deleteBlockDataForField(block: Blockly.Block, field: string) {
const blockData = getBlockData(block);
delete blockData.fieldData[field];
setBlockData(block, blockData);
}
Loading

0 comments on commit 368cca1

Please sign in to comment.