const KS_COLOR = 180; // Türkisblau

Blockly.defineBlocksWithJsonArray([
  // --- TASTER ---
  {
    "type": "ks_button_event",
    "message0": "Falls Taster %1 %2",
    "args0": [
      {
        "type": "field_dropdown",
        "name": "BUTTON",
        "options": [ ["SW1 (D2)", "btn1"], ["SW2 (D3)", "btn2"] ]
      },
      {
        "type": "field_dropdown",
        "name": "EVENT",
        "options": [
          ["wurde gedrückt", "KK_SINGLE_CLICK"],
          ["wurde doppelt gedrückt", "KK_DOUBLE_CLICK"],
          ["wurde lange gedrückt", "KK_LONG_PRESS"]
        ]
      }
    ],
    "output": "Boolean",
    "colour": KS_COLOR
  },
  
  // --- LEDs & SUMMER ---
  {
    "type": "ks_single_led",
    "message0": "Schalte %1 auf %2",
    "args0": [
      {
        "type": "field_dropdown",
        "name": "LED",
        "options": [ ["Rote LED", "1"], ["Blaue LED", "2"] ]
      },
      {
        "type": "field_dropdown",
        "name": "STATE",
        "options": [ ["AN", "true"], ["AUS", "false"] ]
      }
    ],
    "previousStatement": null,
    "nextStatement": null,
    "colour": KS_COLOR
  },
  {
    "type": "ks_rgb_led",
    "message0": "Setze RGB LED auf R:%1 G:%2 B:%3",
    "args0": [
      { "type": "input_value", "name": "R", "check": "Number" },
      { "type": "input_value", "name": "G", "check": "Number" },
      { "type": "input_value", "name": "B", "check": "Number" }
    ],
    "previousStatement": null,
    "nextStatement": null,
    "colour": KS_COLOR
  },
  {
    "type": "ks_buzzer",
    "message0": "Spiele Ton mit Frequenz %1 Hz für %2 ms",
    "args0": [
      { "type": "input_value", "name": "FREQ", "check": "Number" },
      { "type": "input_value", "name": "DUR", "check": "Number" }
    ],
    "previousStatement": null,
    "nextStatement": null,
    "colour": KS_COLOR
  },

  // --- SENSOREN ---
  {
    "type": "ks_read_analog",
    "message0": "Lese %1",
    "args0": [
      {
        "type": "field_dropdown",
        "name": "SENSOR",
        "options": [ 
          ["Potentiometer (0-1023)", "POTI"], 
          ["Lichtsensor LDR (0-100%)", "LDR"], 
          ["Temperatur LM35 (°C)", "LM35"] 
        ]
      }
    ],
    "output": "Number",
    "colour": KS_COLOR
  },
  {
    "type": "ks_read_dht",
    "message0": "Lese %1 von DHT11",
    "args0": [
      {
        "type": "field_dropdown",
        "name": "TYPE",
        "options": [ ["Temperatur (°C)", "TEMP"], ["Luftfeuchtigkeit (%)", "HUM"] ]
      }
    ],
    "output": "Number",
    "colour": KS_COLOR
  },

  // --- INFRAROT ---
  {
    "type": "ks_ir_print",
    "message0": "Sende empfangene IR-Signale an seriellen Monitor",
    "previousStatement": null,
    "nextStatement": null,
    "colour": KS_COLOR
  },
  {
    "type": "ks_ir_check",
    "message0": "Falls IR-Signal gleich %1",
    "args0": [{ "type": "field_input", "name": "HEXCODE", "text": "0xFF30CF" }],
    "output": "Boolean",
    "colour": KS_COLOR
  }
]);