Blockly.Blocks['sendtoarduino'] = {
  init: function() {
    this.appendValueInput("MESSAGE")
        .setCheck("String")
        .appendField("Envoyer à l'arduino :");
    this.setPreviousStatement(true, null);
    this.setNextStatement(true, null);
    this.setColour(330);
 this.setTooltip("envoi d'un string à l'Arduino de la maquette");
 this.setHelpUrl("");
  }
};

Blockly.Blocks['turn_led'] = {
  init: function() {
    this.appendDummyInput()
        .appendField("Mettre la LED en l'état")
        .appendField(new Blockly.FieldDropdown([["allumée","1"], ["éteinte","0"]]), "val");
    this.setPreviousStatement(true, null);
    this.setNextStatement(true, null);
    this.setColour(345);
 this.setTooltip("Change l'état d'une LED");
 this.setHelpUrl("");
  }
};

Blockly.Blocks['arduino_wait'] = {
  init: function() {
    this.appendValueInput("time")
        .setCheck("Number")
        .appendField("Attendre");
    this.appendDummyInput()
        .appendField("secondes");
    this.setInputsInline(true);
    this.setPreviousStatement(true, null);
    this.setNextStatement(true, null);
    this.setColour(330);
 this.setTooltip("");
 this.setHelpUrl("");
  }
};

Blockly.Blocks['turn_io'] = {
  init: function() {
    this.appendValueInput("IO")
        .setCheck("Number")
        .appendField("Turn io");
    this.appendValueInput("VAL")
        .setCheck("Number")
        .appendField("to val");
    this.appendDummyInput();
    this.setPreviousStatement(true, null);
    this.setNextStatement(true, null);
    this.setColour(0);
 this.setTooltip("Outil de debug");
 this.setHelpUrl("");
  }
};




/* ACT 4 */

Blockly.Blocks['activate_camera'] = {
  init: function() {
    this.appendDummyInput()
        .appendField("Démarrer la diffusion");
    this.setPreviousStatement(true, null);
    this.setNextStatement(true, null);
    this.setColour(0);
 this.setTooltip("Active la caméra du module lunaire");
 this.setHelpUrl("");
  }
};

Blockly.Blocks['establish_telecoms'] = {
  init: function() {
    this.appendDummyInput()
        .appendField("Etablir la communication")
        .appendField(new Blockly.FieldDropdown([["Houston - Amarillo - Rapid City","1"], ["Houston - Little Rock","OPTIONNAME"], ["Houston - Jacksonville","OPTIONNAME"], ["Little Rock - Norman","OPTIONNAME"], ["Little Rock - Atlanta - Jacksonville","OPTIONNAME"], ["Norman - Rapid City","OPTIONNAME"], ["Norman - Louisville","OPTIONNAME"], ["Louisville - Chicago","OPTIONNAME"], ["Louisville - Washington","OPTIONNAME"], ["Louisville - Richmond","OPTIONNAME"], ["Chicago - Rapid City","OPTIONNAME"], ["Chicago - Bufallo","OPTIONNAME"], ["Bufallo - Washington","OPTIONNAME"], ["Jacksonville - Richmond","OPTIONNAME"]]), "val");
    this.setPreviousStatement(true, null);
    this.setNextStatement(true, null);
    this.setColour(0);
 this.setTooltip("Fait passer le signal entre deux villes");
 this.setHelpUrl("");
  }
};

Blockly.Blocks['setup_camera_module'] = {
  init: function() {
    this.appendDummyInput()
        .appendField("Mettre en place la caméra");
    this.setNextStatement(true, null);
    this.setColour(0);
 this.setTooltip("Déclenche un mécanisme");
 this.setHelpUrl("");
  }
};

Blockly.Blocks['open_hatch'] = {
  init: function() {
    this.appendDummyInput()
        .appendField("Ouvrir la trappe du module lunaire");
    this.setPreviousStatement(true, null);
    this.setNextStatement(true, null);
    this.setColour(0);
 this.setTooltip("Ouvre la porte qui permet aux astronautes de sortir");
 this.setHelpUrl("");
  }
};

Blockly.Blocks['activate_moon_signal'] = {
  init: function() {
    this.appendDummyInput()
        .appendField("Envoyer le signal TV vers la Terre");
    this.setPreviousStatement(true, null);
    this.setNextStatement(true, null);
    this.setColour(0);
 this.setTooltip("Envoie le signal vers la Terre par le biais d'une antenne");
 this.setHelpUrl("");
  }
};

Blockly.Blocks['call_phone'] = {
  init: function() {
    this.appendValueInput("NUM")
        .setCheck(null)
        .appendField("Appeler le téléphone au numéro");
    this.appendDummyInput();
    this.setPreviousStatement(true, null);
    this.setNextStatement(true, null);
    this.setColour(0);
 this.setTooltip("Appel le téléphone au numéro donné");
 this.setHelpUrl("");
  }
};

Blockly.Blocks['is_telecom_working'] = {
  init: function() {
    this.appendDummyInput()
        .appendField("la liaison entre Washington et Louisville fonctionne");
    this.setOutput(true, null);
    this.setColour(230);
 this.setTooltip("");
 this.setHelpUrl("");
  }
};

Blockly.Blocks['count_letter_in_string'] = {
  init: function() {
    this.appendValueInput("text")
        .setCheck("String")
        .appendField("Compter la lettre")
        .appendField(new Blockly.FieldTextInput("a"), "letter")
        .appendField("dans le texte");
    this.setOutput(true, "Number");
    this.setColour(230);
 this.setTooltip("Compte le nombre d'apparitions de cette lettre dans un texte");
 this.setHelpUrl("");
  }
};
