taweili / ardublock

ArduBlock is a Block Programming Language for Arduino.
GNU General Public License v3.0
414 stars 292 forks source link

Add support for Guino #123

Open taweili opened 10 years ago

taweili commented 10 years ago

http://www.instructables.com/id/Guino-Dashboard-for-your-Arduino/?ALLSTEPS

karlTH commented 10 years ago

i ve add the function for make :+1: - a graph

i ve make a block guino_init because i need : GUINO_GERER_INTERFACE();

at the start of void loop without a block, i don t know how to put some code at the start of the void loop. thanks for help on this point

danielfsc commented 10 years ago

Why you don't put this in void setup? Em 23/11/2014 18:24, "THOMAS karl" notifications@github.com escreveu:

i ve add the function for make [image: :+1:] - a graph

  • a slider (virtual potentiometre)

i ve make a block guino_init because i need : GUINO_GERER_INTERFACE();

at the start of void loop without a block, i don t know how to put some code at the start of the void loop. thanks for help on this point

— Reply to this email directly or view it on GitHub https://github.com/taweili/ardublock/issues/123#issuecomment-64133025.

karlTH commented 10 years ago

my friend look the librairie of guino he try to put it in the setup.

i ve an other mistake in the class guino_read the variable isn't incremental. i don't understand why ?

some idee ? thanks

danielfsc commented 10 years ago

Did you try the code > loop block?

2014-11-24 8:15 GMT-02:00 THOMAS karl notifications@github.com:

my friend look the librairie of guino he try to put it in the setup.

i ve an other mistake in the class guino_read the variable isn't incremental. i don't understand why ?

some idee ? thanks

— Reply to this email directly or view it on GitHub https://github.com/taweili/ardublock/issues/123#issuecomment-64173529.

Dr. Daniel Girardi Universidade Federal de Santa Catarina - Campus Blumenau Rua Pomerode, 710 Salto do Norte - Blumenau - SC 89065-300

karlTH commented 10 years ago

how did youuse it loop block ?

danielfsc commented 10 years ago

Check this out. My version is different from oficial but you can build this in your version.

2014-11-24 9:39 GMT-02:00 THOMAS karl notifications@github.com:

how did youuse it loop block ?

— Reply to this email directly or view it on GitHub https://github.com/taweili/ardublock/issues/123#issuecomment-64181758.

Dr. Daniel Girardi Universidade Federal de Santa Catarina - Campus Blumenau Rua Pomerode, 710 Salto do Norte - Blumenau - SC 89065-300

karlTH commented 10 years ago

thanks i will try something in the loop block very good idea and i will tell you

i ve a bug in the creation of a variable. the name is always _ABVAR_1_Guinotracegraphique if i put a second block in ardubloc the arduino code generation is still _ABVAR_1_Guinotracegraphique, i ve never _ABVAR_2_Guinotracegraphique

i ve a bug on the incremental this is the class any idea ??

package com.ardublock.translator.block.Duinoedu;

import com.ardublock.translator.Translator; import com.ardublock.translator.block.TranslatorBlock; import com.ardublock.translator.block.exception.SocketNullException; import com.ardublock.translator.block.exception.SubroutineNotDeclaredException;

public class Guino_Read extends TranslatorBlock {

public Guino_Read (Long blockId, Translator translator, String codePrefix, String codeSuffix, String label)
{
    super(blockId, translator, codePrefix, codeSuffix, label);
}

//@Override
    public String toCode() throws SocketNullException, SubroutineNotDeclaredException
    {

        String Title;
        String Variable;
        String Min;
        String Max;
        TranslatorBlock translatorBlock = this.getRequiredTranslatorBlockAtSocket(0);
        Title = translatorBlock.toCode();
        translatorBlock = this.getRequiredTranslatorBlockAtSocket(1);
        Variable = translatorBlock.toCode();
        translatorBlock = this.getRequiredTranslatorBlockAtSocket(2);
        Min = translatorBlock.toCode();
        translatorBlock = this.getRequiredTranslatorBlockAtSocket(3);
        Max = translatorBlock.toCode();

        String internalVariableName = translator.getNumberVariable(label);
        if (internalVariableName == null)
        {
            internalVariableName = translator.buildVariableName(label);
            translator.addNumberVariable(label, internalVariableName);
            translator.addDefinitionCommand("int " + internalVariableName + " = 0 ;");

// translator.addSetupCommand(internalVariableName + " = 0;"); }

        translator.addHeaderFile("EasyTransfer.h");
        translator.addHeaderFile("EEPROM.h");
        translator.addHeaderFile("Guino.h");
        translator.addDefinitionCommand("//libraries at http://duinoedu.com/dl/lib/dupont/EDU_Guino/");
        translator.addSetupCommand("GUINO_BRANCHER();");
        translator.addGuinoCommand("GUINO_AFFICHER_GRAPH("+Title+","+internalVariableName+","+Min+","+Max+");\nGUINO_AFFICHER_LIGNE(); ");

        String ret =    internalVariableName+"="+Variable+";\n"+
                        "GUINO_LIRE("+internalVariableName+");\n";
        return  ret ;

    }

}

danielfsc commented 10 years ago

Send your .abp, please.

2014-11-24 10:04 GMT-02:00 THOMAS karl notifications@github.com:

thanks i will try something in the loop block very good idea and i will tell you

i ve a bug in the creation of a variable. the name is always _ABVAR_1_Guinotracegraphique if i put a second block in ardubloc the arduino code generation is still _ABVAR_1_Guinotracegraphique, i ve never _ABVAR_2_Guinotracegraphique

i ve a bug on the incremental this is the class any idea ??

package com.ardublock.translator.block.Duinoedu;

import com.ardublock.translator.Translator; import com.ardublock.translator.block.TranslatorBlock; import com.ardublock.translator.block.exception.SocketNullException; import com.ardublock.translator.block.exception.SubroutineNotDeclaredException;

public class Guino_Read extends TranslatorBlock {

public Guino_Read (Long blockId, Translator translator, String codePrefix, String codeSuffix, String label) { super(blockId, translator, codePrefix, codeSuffix, label); }

//@Override public String toCode() throws SocketNullException, SubroutineNotDeclaredException {

    String Title;
    String Variable;
    String Min;
    String Max;
    TranslatorBlock translatorBlock = this.getRequiredTranslatorBlockAtSocket(0);
    Title = translatorBlock.toCode();
    translatorBlock = this.getRequiredTranslatorBlockAtSocket(1);
    Variable = translatorBlock.toCode();
    translatorBlock = this.getRequiredTranslatorBlockAtSocket(2);
    Min = translatorBlock.toCode();
    translatorBlock = this.getRequiredTranslatorBlockAtSocket(3);
    Max = translatorBlock.toCode();

    String internalVariableName = translator.getNumberVariable(label);
    if (internalVariableName == null)
    {
        internalVariableName = translator.buildVariableName(label);
        translator.addNumberVariable(label, internalVariableName);
        translator.addDefinitionCommand("int " + internalVariableName + " = 0 ;");

// translator.addSetupCommand(internalVariableName + " = 0;"); }

    translator.addHeaderFile("EasyTransfer.h");
    translator.addHeaderFile("EEPROM.h");
    translator.addHeaderFile("Guino.h");
    translator.addDefinitionCommand("//libraries at http://duinoedu.com/dl/lib/dupont/EDU_Guino/");
    translator.addSetupCommand("GUINO_BRANCHER();");
    translator.addGuinoCommand("GUINO_AFFICHER_GRAPH("+Title+","+internalVariableName+","+Min+","+Max+");\nGUINO_AFFICHER_LIGNE(); ");

    String ret =    internalVariableName+"="+Variable+";\n"+
                    "GUINO_LIRE("+internalVariableName+");\n";
    return  ret ;

}

}

— Reply to this email directly or view it on GitHub https://github.com/taweili/ardublock/issues/123#issuecomment-64185073.

Dr. Daniel Girardi Universidade Federal de Santa Catarina - Campus Blumenau Rua Pomerode, 710 Salto do Norte - Blumenau - SC 89065-300

karlTH commented 10 years ago

here is the abp in text mode

http://pastebin.com/dTg2mNnB

copy and past save as .abp

danielfsc commented 10 years ago

Well, I don't have your guino blocks. Can you send your ardublock.jar?

2014-11-24 10:12 GMT-02:00 THOMAS karl notifications@github.com:

here is the .abp in text mod from my version no incremental for guino_read and guino_slider

<?xml version="1.0" encoding="UTF-8" standalone="no"?>

437 309

1023

605 381

0

605 357

3

605 333

Pot2

605 309

437 135

1023

605 207

0

605 183

3

605 159

Pot1

605 135

graph1

437 111

199 282

411

1023

437 429

0

437 405

Graph2

437 285

199 108

398 416

1023

437 255

0

437 231

100 100

/cb:CODEBLOCKS

— Reply to this email directly or view it on GitHub https://github.com/taweili/ardublock/issues/123#issuecomment-64185769.

Dr. Daniel Girardi Universidade Federal de Santa Catarina - Campus Blumenau Rua Pomerode, 710 Salto do Norte - Blumenau - SC 89065-300

karlTH commented 10 years ago

https://drive.google.com/file/d/0ByqtNDjRdc-fSE9ObjRjRXRwRk0/view?usp=sharing here my jar

danielfsc commented 10 years ago

I'm not sure if that is the problem but when you use the Guino Slider block to create a variable it try to create a variable with same name. Try to create a variable with different name. I'm run out of time to help you now, but send your source and tomorrow I will look that for you.

2014-11-24 10:27 GMT-02:00 THOMAS karl notifications@github.com:

https://drive.google.com/file/d/0ByqtNDjRdc-fSE9ObjRjRXRwRk0/view?usp=sharing here my jar

— Reply to this email directly or view it on GitHub https://github.com/taweili/ardublock/issues/123#issuecomment-64187140.

Dr. Daniel Girardi Universidade Federal de Santa Catarina - Campus Blumenau Rua Pomerode, 710 Salto do Norte - Blumenau - SC 89065-300

karlTH commented 10 years ago

super thanks a lot here are my source. i ve also start to mofifie loopblock, translator.java and GenerateCodeButtonListener.java i want the code "GUINO_GERER_INTERFACE();" appear at the start of loop if there is a guino block like scoop but i forget something

here are the source https://drive.google.com/file/d/0ByqtNDjRdc-fNk82cVJjRVpPNk0/view?usp=sharing

danielfsc commented 10 years ago

Look if this solve your problem: On lines 32, 35 e 36 I change the variable label by Title.

2014-11-24 11:10 GMT-02:00 THOMAS karl notifications@github.com:

super thanks a lot here are my source. i ve also start to mofifie loopblock, translator.java and GenerateCodeButtonListener.java i want the code "GUINO_GERER_INTERFACE();" appear at the start of loop if there is a guino block like scoop but i forget something

here are the source

https://drive.google.com/file/d/0ByqtNDjRdc-fNk82cVJjRVpPNk0/view?usp=sharing

— Reply to this email directly or view it on GitHub https://github.com/taweili/ardublock/issues/123#issuecomment-64191431.

Dr. Daniel Girardi Universidade Federal de Santa Catarina - Campus Blumenau Rua Pomerode, 710 Salto do Norte - Blumenau - SC 89065-300

karlTH commented 10 years ago

thanks it works very well

please could you also take a look for the loop block ? i want the code "GUINO_GERER_INTERFACE();" appear at the start of loop if there is a guino block but i forget something

danielfsc commented 10 years ago

I don't read the documentation of guino but I believe that this function should be called before you use other guino functions. There is no problem use a analogRead/Write before you call Guino_gerer_interface(). Try that.

2014-11-25 13:35 GMT-02:00 THOMAS karl notifications@github.com:

thanks it works very well

please could you also take a look for the loop block ? i want the code "GUINO_GERER_INTERFACE();" appear at the start of loop if there is a guino block but i forget something

— Reply to this email directly or view it on GitHub https://github.com/taweili/ardublock/issues/123#issuecomment-64417824.

Dr. Daniel Girardi Universidade Federal de Santa Catarina - Campus Blumenau Rua Pomerode, 710 Salto do Norte - Blumenau - SC 89065-300

karlTH commented 10 years ago

i ve modifie loopblock i ve had this if (translator.isGuinoProgram()) { ret += "GUINO_GERER_INTERFACE();\n"; }

i ve modifie , translator.java and GenerateCodeButtonListener.java but ret += "GUINO_GERER_INTERFACE();\n"; never appear i don t understand why. there is a bug could you help me ? i ve try with analogRead/Write in .abp but nothing append.

karlTH commented 10 years ago

i find the mistake

before

if (!block.hasPlug() && (Block.NULL.equals(block.getBeforeBlockID())))

i put this if (block.getGenusName().equals("DuinoEDU_Guino_Read")) { translator.setGuinoProgram(true);

        }
        if (block.getGenusName().equals("DuinoEDU_Guino_Title"))
        {
            translator.setGuinoProgram(true);

        }
        if (block.getGenusName().equals("DuinoEDU_Guino_Slider"))
        {
            translator.setGuinoProgram(true);

        }