{
  "format": "evn-blocks",
  "version": 3,
  "title": "Servo: every block",
  "needs": "a Geekservo 270-degree servo on servo port 1 and a Geekservo continuous-rotation servo on servo port 2, both free to turn",
  "description": "Every servo block once. Port 1 is the 270-degree servo, driven by angle: a jump, sweeps that wait and one that does not, a raw pulse, and a sweep stopped part way. Port 2 is the continuous-rotation servo, driven by speed (duty): forwards, backwards, stop.",
  "workspace": {
    "blocks": {
      "languageVersion": 0,
      "blocks": [
        {
          "type": "evn_setup_start",
          "x": 30,
          "y": 30,
          "next": {
            "block": {
              "type": "evn_servo_setup",
              "fields": {
                "PORT": "1",
                "PROFILE": "geekservo_270"
              },
              "next": {
                "block": {
                  "type": "evn_servo_setup",
                  "fields": {
                    "PORT": "2",
                    "PROFILE": "geekservo_cr"
                  }
                }
              }
            }
          }
        },
        {
          "type": "evn_program_start",
          "x": 30,
          "y": 170,
          "next": {
            "block": {
              "type": "evn_comment",
              "fields": {
                "TEXT": "the 270-degree servo: a jump, then sweeps at a set speed (degrees per second)"
              },
              "next": {
                "block": {
                  "type": "evn_servo_angle",
                  "fields": {
                    "PORT": "1"
                  },
                  "inputs": {
                    "ANGLE": {
                      "shadow": {
                        "type": "math_number",
                        "fields": {
                          "NUM": 135
                        }
                      }
                    }
                  },
                  "next": {
                    "block": {
                      "type": "evn_wait",
                      "inputs": {
                        "TIME": {
                          "shadow": {
                            "type": "math_number",
                            "fields": {
                              "NUM": 500
                            }
                          }
                        }
                      },
                      "next": {
                        "block": {
                          "type": "evn_servo_move",
                          "fields": {
                            "PORT": "1",
                            "WAIT": "TRUE"
                          },
                          "inputs": {
                            "ANGLE": {
                              "shadow": {
                                "type": "math_number",
                                "fields": {
                                  "NUM": 0
                                }
                              }
                            },
                            "SPEED": {
                              "shadow": {
                                "type": "math_number",
                                "fields": {
                                  "NUM": 100
                                }
                              }
                            }
                          },
                          "next": {
                            "block": {
                              "type": "evn_servo_move",
                              "fields": {
                                "PORT": "1",
                                "WAIT": "FALSE"
                              },
                              "inputs": {
                                "ANGLE": {
                                  "shadow": {
                                    "type": "math_number",
                                    "fields": {
                                      "NUM": 270
                                    }
                                  }
                                },
                                "SPEED": {
                                  "shadow": {
                                    "type": "math_number",
                                    "fields": {
                                      "NUM": 200
                                    }
                                  }
                                }
                              },
                              "next": {
                                "block": {
                                  "type": "text_print",
                                  "inputs": {
                                    "TEXT": {
                                      "shadow": {
                                        "type": "text",
                                        "fields": {
                                          "TEXT": "sweeping, and the program goes on"
                                        }
                                      }
                                    }
                                  },
                                  "next": {
                                    "block": {
                                      "type": "evn_wait_until",
                                      "inputs": {
                                        "COND": {
                                          "block": {
                                            "type": "evn_servo_done",
                                            "fields": {
                                              "PORT": "1"
                                            }
                                          }
                                        }
                                      },
                                      "next": {
                                        "block": {
                                          "type": "evn_comment",
                                          "fields": {
                                            "TEXT": "a raw pulse: 1500 us is the middle of 600..2400 us, 135 degrees"
                                          },
                                          "next": {
                                            "block": {
                                              "type": "evn_servo_pulse",
                                              "fields": {
                                                "PORT": "1"
                                              },
                                              "inputs": {
                                                "US": {
                                                  "shadow": {
                                                    "type": "math_number",
                                                    "fields": {
                                                      "NUM": 1500
                                                    }
                                                  }
                                                }
                                              },
                                              "next": {
                                                "block": {
                                                  "type": "evn_wait",
                                                  "inputs": {
                                                    "TIME": {
                                                      "shadow": {
                                                        "type": "math_number",
                                                        "fields": {
                                                          "NUM": 1000
                                                        }
                                                      }
                                                    }
                                                  },
                                                  "next": {
                                                    "block": {
                                                      "type": "evn_comment",
                                                      "fields": {
                                                        "TEXT": "stop a sweep part way (about 60 degrees on from 135): the servo holds where it got to"
                                                      },
                                                      "next": {
                                                        "block": {
                                                          "type": "evn_servo_move",
                                                          "fields": {
                                                            "PORT": "1",
                                                            "WAIT": "FALSE"
                                                          },
                                                          "inputs": {
                                                            "ANGLE": {
                                                              "shadow": {
                                                                "type": "math_number",
                                                                "fields": {
                                                                  "NUM": 0
                                                                }
                                                              }
                                                            },
                                                            "SPEED": {
                                                              "shadow": {
                                                                "type": "math_number",
                                                                "fields": {
                                                                  "NUM": 60
                                                                }
                                                              }
                                                            }
                                                          },
                                                          "next": {
                                                            "block": {
                                                              "type": "evn_wait",
                                                              "inputs": {
                                                                "TIME": {
                                                                  "shadow": {
                                                                    "type": "math_number",
                                                                    "fields": {
                                                                      "NUM": 1000
                                                                    }
                                                                  }
                                                                }
                                                              },
                                                              "next": {
                                                                "block": {
                                                                  "type": "evn_servo_stop",
                                                                  "fields": {
                                                                    "PORT": "1"
                                                                  },
                                                                  "next": {
                                                                    "block": {
                                                                      "type": "evn_comment",
                                                                      "fields": {
                                                                        "TEXT": "the continuous servo: duty -100..100 %, 0 stops it"
                                                                      },
                                                                      "next": {
                                                                        "block": {
                                                                          "type": "evn_servo_duty",
                                                                          "fields": {
                                                                            "PORT": "2"
                                                                          },
                                                                          "inputs": {
                                                                            "DUTY": {
                                                                              "shadow": {
                                                                                "type": "math_number",
                                                                                "fields": {
                                                                                  "NUM": 50
                                                                                }
                                                                              }
                                                                            }
                                                                          },
                                                                          "next": {
                                                                            "block": {
                                                                              "type": "evn_wait",
                                                                              "inputs": {
                                                                                "TIME": {
                                                                                  "shadow": {
                                                                                    "type": "math_number",
                                                                                    "fields": {
                                                                                      "NUM": 2000
                                                                                    }
                                                                                  }
                                                                                }
                                                                              },
                                                                              "next": {
                                                                                "block": {
                                                                                  "type": "evn_servo_duty",
                                                                                  "fields": {
                                                                                    "PORT": "2"
                                                                                  },
                                                                                  "inputs": {
                                                                                    "DUTY": {
                                                                                      "shadow": {
                                                                                        "type": "math_number",
                                                                                        "fields": {
                                                                                          "NUM": -50
                                                                                        }
                                                                                      }
                                                                                    }
                                                                                  },
                                                                                  "next": {
                                                                                    "block": {
                                                                                      "type": "evn_wait",
                                                                                      "inputs": {
                                                                                        "TIME": {
                                                                                          "shadow": {
                                                                                            "type": "math_number",
                                                                                            "fields": {
                                                                                              "NUM": 2000
                                                                                            }
                                                                                          }
                                                                                        }
                                                                                      },
                                                                                      "next": {
                                                                                        "block": {
                                                                                          "type": "evn_servo_stop",
                                                                                          "fields": {
                                                                                            "PORT": "2"
                                                                                          }
                                                                                        }
                                                                                      }
                                                                                    }
                                                                                  }
                                                                                }
                                                                              }
                                                                            }
                                                                          }
                                                                        }
                                                                      }
                                                                    }
                                                                  }
                                                                }
                                                              }
                                                            }
                                                          }
                                                        }
                                                      }
                                                    }
                                                  }
                                                }
                                              }
                                            }
                                          }
                                        }
                                      }
                                    }
                                  }
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      ]
    }
  }
}
