Knowledge Base

Welcome to the Robotical knowledge base! These pages will help you get the most out of your Marty

Marty Images

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
martyv2:userguides:python:disco [2021/07/09 12:36]
anita [Passing in Your Add Ons]
martyv2:userguides:python:disco [2021/08/13 03:20]
anita removed
Line 1: Line 1:
-====== Getting Started with Marty's Disco Add ons ======+====== Marty's Disco Add-Ons: Getting Started ======
  
 This page will help you get started with the disco add ons with Marty using the python library. Before we get started, make sure you have [[https://userguides.robotical.io/martyv2/userguides/python|python installed]] and [[https://userguides.robotical.io/martyv2/userguides/sensorsandaddons/discomarty|have set up your disco add ons]].  This page will help you get started with the disco add ons with Marty using the python library. Before we get started, make sure you have [[https://userguides.robotical.io/martyv2/userguides/python|python installed]] and [[https://userguides.robotical.io/martyv2/userguides/sensorsandaddons/discomarty|have set up your disco add ons]]. 
Line 19: Line 19:
 **disco_pattern**(pattern, add_on):  **disco_pattern**(pattern, add_on): 
         ***pattern**: choose the pattern you would your add on to turn to. There are two options, so you must pass in the number **1** or **2**.\\ \\             ***pattern**: choose the pattern you would your add on to turn to. There are two options, so you must pass in the number **1** or **2**.\\ \\    
-        ***add_on**: This allows you to specify the specific add on on your marty that you would like to light up. Click here(link) to learn how to pass in your add ons.\\ \\    +        ***add_on**: This allows you to specify the specific add on on your marty that you would like to light up. [[#passing_in_your_add_ons|Click Here]] to learn how to pass in your add ons.\\ \\    
  
 Try this function using the code below to set all of your disco add ons to pattern **1**. Try this function using the code below to set all of your disco add ons to pattern **1**.
Line 32: Line 32:
 **disco_color**(color, add_on, region):          **disco_color**(color, add_on, region):         
         ***color**: choose the  color you would like your disco add ons to be. You can pass in either a hex code, RGB tuple, or a string calling one of the built in colors: white, red, blue, yellow, green, teal, pink, purple, and orange.\\ \\ //You can use [[https://g.co/kgs/Na34hP|this color picker]] to find the hex code or RGB tuple of the color of your choice.// \\ \\             ***color**: choose the  color you would like your disco add ons to be. You can pass in either a hex code, RGB tuple, or a string calling one of the built in colors: white, red, blue, yellow, green, teal, pink, purple, and orange.\\ \\ //You can use [[https://g.co/kgs/Na34hP|this color picker]] to find the hex code or RGB tuple of the color of your choice.// \\ \\    
-        ***add_on**: This allows you to specify the specific add on on your marty that you would like to light up. Click here(link) to learn how to pass in your add ons.\\ \\    +        ***add_on**: This allows you to specify the specific add on on your marty that you would like to light up. [[#passing_in_your_add_ons|Click Here]] to learn how to pass in your add ons.\\ \\    
         ***region**: This allows you to specify the specific side of Marty’s eye, arm, or leg that you would like to light up. Revisit [[https://userguides.robotical.io/martyv2/userguides/sensorsandaddons/discomarty|setting up your disco add ons]] for a refresher on these regions. You have the option to pass in 0, 1, or 2.          ***region**: This allows you to specify the specific side of Marty’s eye, arm, or leg that you would like to light up. Revisit [[https://userguides.robotical.io/martyv2/userguides/sensorsandaddons/discomarty|setting up your disco add ons]] for a refresher on these regions. You have the option to pass in 0, 1, or 2. 
  
Line 54: Line 54:
  
 **disco_off**(add_on):          **disco_off**(add_on):         
-        ***add_on**: This allows you to specify the specific add on on your marty that you would like to turn off. Click here(link) to learn how to pass in your add ons.+        ***add_on**: This allows you to specify the specific add on on your marty that you would like to turn off. [[#passing_in_your_add_ons|Click Here]] to learn how to pass in your add ons.
  
 Try this function using the code below to turn off all of your disco add ons. Try this function using the code below to turn off all of your disco add ons.
Line 62: Line 62:
  
  
 +\\ 
 +===== Party Marty! =====
 +Now we can use our disco functions to make Marty party! Follow the code below to light up Marty's disco add ons and make Marty dance.
 +
 +<code>
 +from martypy import Marty
 +my_marty = Marty("wifi", "192.168.0.42" # Replace 192.168.0.42 by your Marty's IP
 +my_marty.disco_color('blue', my_marty.Disco.FEET)
 +my_marty.disco_pattern(1, my_marty.Disco.EYES)
 +my_marty.disco_pattern(2, my_marty.Disco.ARMS)
 +my_marty.dance()
 +my_marty.disco_off()
 +</code>
 +
 +
 +
 +\\ 
 ===== Passing in Your Add Ons ===== ===== Passing in Your Add Ons =====
  
 When passing in your add ons, you have two options: When passing in your add ons, you have two options:
  
--You can pass in a string of the name of the add on that you would like to call the function on. You can find the names of all your add ons by visiting the Scratch app and going to **Configure --> ADD-ONS**. Don't forget to disconnect the app after in order to connect with your Marty in python!+1. You can pass in a string of the name of the add on that you would like to call the function on. You can find the names of all your add ons by visiting the Scratch app and going to **Configure --> ADD-ONS**. Don't forget to disconnect the app after in order to connect with your Marty in python! 
 + 
 +2. You can also pass in groupings of the add ons so you can call your chosen function on multiple add ons at a time! We have groupings for:
  
-- You can also pass in groupings of the add ons so that you can call the function on multiple add ons at a time! We have groupings for: +  * my_marty.Disco.EYES 
-     -my_marty.Disco.EYES +  my_marty.Disco.FEET 
-     -my_marty.Disco.FEET +  my_marty.Disco.ARMS 
-     -my_marty.Disco.ARMS +  my_marty.Disco.ALL
-     -my_marty.Disco.ALL +
-     Pass in one the variables above in the **add_on** parameter of your chosen function when you would like to call a pair or all of the add ons.+
  
 +Pass in one the variables above in the **add_on** parameter of your chosen function when you would like to call a pair or all of the add ons.