calliope-edu / scratch-gui

Graphical User Interface for creating and running Scratch 3.0 projects.
https://llk.github.io/scratch-gui/develop/
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Add Motor Blocks #17

Open Amerlander opened 4 months ago

Amerlander commented 4 months ago

We plan to have motor blocks for the Motor Board and for the Motion kit.

Current implementation in HEX File:

if(command == MbitMoreCommand::CMD_MOTOR) {
    const int motorCommand = data[0] & 0b11111;
    // data[1] = Motor 1
    // data[2] = Motor 2
    if (motorCommand == MbitMoreMotorCommand::SET_M_SPEED) {
        // TODO
    } else if (motorCommand == MbitMoreMotorCommand::SET_MOTIONKIT_SPEED) {
        // TODO
    }
  }
declare const enum MbitMoreCommand
{
    CMD_MOTOR = 0x06,
}

declare const enum MbitMoreMotorCommand
{
    SET_M_SPEED = 0x01,
    SET_MOTIONKIT_SPEED = 0x02,
}
Amerlander commented 4 months ago

@joernalraun can you specify what blocks we need?

joernalraun commented 4 months ago

Views of motor block:

Bildschirmfoto 2024-04-29 um 17 36 34 Bildschirmfoto 2024-04-29 um 17 40 32 Bildschirmfoto 2024-04-29 um 17 36 28

Views of MotionKit block (should show MotionKit instead of Motor):

Bildschirmfoto 2024-04-29 um 17 38 25 Bildschirmfoto 2024-04-29 um 17 38 20 Bildschirmfoto 2024-04-29 um 17 38 08 Bildschirmfoto 2024-04-29 um 17 38 00
joernalraun commented 4 months ago

@haithembelhaj as we cannot offer the MakeCode user add-on option for the labels, would it be possible to also add the previous two blocks at the end of all Calliope mini blocks for motors/cars? When everything else is done and there is still time/fun to do so? ;)

Amerlander commented 4 months ago

@haithembelhaj We created a HEX file today for the Motors: https://github.com/calliope-edu/pxt-calliope/commit/0aa93688d94b1c8562cc876d3206bdee92fc703a

Calliope-More-Motors.zip (C17 is also included now)

It listens on data[0] >> 5 == MbitMoreCommand::CMD_MOTOR | 0x06

It then awaits in data[0] & 0b11111 either of:

With values for direction and speed in:

haithembelhaj commented 4 months ago

@Amerlander I added the block following the specs but without success sadly :( https://github.com/calliope-edu/scratch-vm/commit/c7c4f5b41432084e5c8fefcaae8e6fcd092bd94e I'm I doing something wrong?

Amerlander commented 4 months ago

Your code locks fine. I'll check if there is something going wrong with the hex file.

Amerlander commented 4 months ago

The Motor should be part of the first command. I changed it in scsratch-vm: https://github.com/calliope-edu/scratch-vm/commit/1aab934d631ad43e5eb1195d482c64b1ef3786d8 @haithembelhaj Can you have a look?

Amerlander commented 4 months ago

There was an issue in the hex file too. It now works with the changes from above and this new hex file:

Calliope-More.zip

haithembelhaj commented 4 months ago

amazing! I updated the VM by removing the logs :)

Amerlander commented 4 months ago

If you only updated the VM you could just re-run the Job by opening the last job and click on the re-run-button on the top right: https://github.com/calliope-edu/scratch-gui/actions/runs/8942832422 image

That should rebuild the page with the current vm without having to commit to the gui repo.

joernalraun commented 4 months ago

Right now the block is english, can this be translated as well and we need motor in it "set motor"... In German it should be "setze Motor XX auf XX".

haithembelhaj commented 4 months ago

@joernalraun translated and deployed :)