Skip to content

Commit

Permalink
feat: 8802 마빗 LED블럭 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Tnks2U committed Nov 22, 2024
1 parent 1af7ad7 commit 6d9b717
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 11 deletions.
35 changes: 30 additions & 5 deletions src/playground/blocks/hardware/block_microbit2.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,8 @@ Entry.Microbit2 = new (class Microbit2 {
unplot: '끄기',
on: '켜기',
off: '끄기',
remove: '지우기',
light: '밝히기',
microbit_2_HEART: '하트',
microbit_2_HEART_SMALL: '작은 하트',
microbit_2_HAPPY: '행복',
Expand Down Expand Up @@ -1526,6 +1528,17 @@ Entry.Microbit2 = new (class Microbit2 {
skeleton: 'basic',
statements: [],
params: [
{
type: 'Dropdown',
options: [
[Lang.Blocks.remove, 'remove'],
[Lang.Blocks.light, 'light'],
],
value: 'remove',
fontSize: 11,
bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
},
{
type: 'Indicator',
img: 'block_icon/hardware_icon.svg',
Expand All @@ -1538,12 +1551,24 @@ Entry.Microbit2 = new (class Microbit2 {
def: {
type: 'microbit2_reset_screen',
},
paramsKeyMap: {},
paramsKeyMap: { LED_STATUS: 0 },
func: (sprite, script) => {
const reqOptions = {
id: script.entity.id,
command: this.functionKeys.RESET_SCREEN,
};
const ledStatus = script.getField('LED_STATUS');
let reqOptions;
if (ledStatus === 'light') {
const defaultLed = '99999:99999:99999:99999:99999';
reqOptions = {
id: script.entity.id,
command: this.functionKeys.SET_CUSTOM_IMAGE,
payload: defaultLed,
};
} else {
reqOptions = {
id: script.entity.id,
command: this.functionKeys.RESET_SCREEN,
};
}

this.requestCommandWithResponse(reqOptions);
const parsedResponse = this.getResponse(reqOptions);
},
Expand Down
30 changes: 26 additions & 4 deletions src/playground/blocks/hardwareLite/block_microbit2_lite.js
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,8 @@ const EVENT_INTERVAL = 150;
unplot: '끄기',
on: '켜기',
off: '끄기',
remove: '지우기',
light: '밝히기',
microbit_2_HEART: '하트',
microbit_2_HEART_SMALL: '작은 하트',
microbit_2_HAPPY: '행복',
Expand Down Expand Up @@ -1565,6 +1567,17 @@ const EVENT_INTERVAL = 150;
skeleton: 'basic',
statements: [],
params: [
{
type: 'Dropdown',
options: [
[Lang.Blocks.remove, 'remove'],
[Lang.Blocks.light, 'light'],
],
value: 'remove',
fontSize: 11,
bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
},
{
type: 'Indicator',
img: 'block_icon/hardwarelite_icon.svg',
Expand All @@ -1577,11 +1590,20 @@ const EVENT_INTERVAL = 150;
def: {
type: 'microbit2lite_reset_screen',
},
paramsKeyMap: {},
paramsKeyMap: { LED_STATUS: 0 },
func: async (sprite, script) => {
const response = await this.getResponseWithSync(
`${this.functionKeys.RESET_SCREEN};`
);
const ledStatus = script.getField('LED_STATUS');
let response;
if (ledStatus === 'light') {
const defaultLed = '99999:99999:99999:99999:99999';
response = await this.getResponseWithSync(
`${this.functionKeys.SET_CUSTOM_IMAGE};${defaultLed}`
);
} else {
response = await this.getResponseWithSync(
`${this.functionKeys.RESET_SCREEN};`
);
}
return this.getResponse(response);
},
},
Expand Down
23 changes: 21 additions & 2 deletions src/playground/blocks/hardwareLite/block_microbit2ble_lite.js
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,8 @@ const convertPresetImageToLedState = (preset) => {
unplot: '끄기',
on: '켜기',
off: '끄기',
remove: '지우기',
light: '밝히기',
microbit_2_HEART: '하트',
microbit_2_HEART_SMALL: '작은 하트',
microbit_2_HAPPY: '행복',
Expand Down Expand Up @@ -1630,6 +1632,17 @@ const convertPresetImageToLedState = (preset) => {
skeleton: 'basic',
statements: [],
params: [
{
type: 'Dropdown',
options: [
[Lang.Blocks.remove, 'remove'],
[Lang.Blocks.light, 'light'],
],
value: 'remove',
fontSize: 11,
bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
},
{
type: 'Indicator',
img: 'block_icon/hardwarelite_icon.svg',
Expand All @@ -1642,9 +1655,15 @@ const convertPresetImageToLedState = (preset) => {
def: {
type: 'microbit2blelite_reset_screen',
},
paramsKeyMap: {},
paramsKeyMap: { LED_STATUS: 0 },
func: async (sprite, script) => {
this.ledState = getInitialLedState();
const ledStatus = script.getField('LED_STATUS');
if (ledStatus === 'light') {
const defaultLed = '99999:99999:99999:99999:99999';
this.ledState = convertPresetImageToLedState(defaultLed);
} else {
this.ledState = getInitialLedState();
}
await this.services.LedService.writeMatrixState(this.ledState);
},
},
Expand Down

0 comments on commit 6d9b717

Please sign in to comment.