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]
— (current)
Line 1: Line 1:
-====== Getting Started with Marty's 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]].  
-  
-===== Step 1 ===== 
- 
- 
-Import Martypy and establish connection to your Marty. Follow the code below to connect your Marty. 
-<code> 
-from martypy import Marty 
-my_marty = Marty("wifi", "192.168.0.42" # Replace 192.168.0.42 by your Marty's IP 
-</code> 
-You should now be able to play with your disco add ons using the three functions below. 
- 
-===== Step 2 ===== 
- 
-The function //**disco_pattern**// allows you to set your disco add ons to a built-in pattern of lights. You will need to pass in your choice of pattern and specify the add on you would like to turn on, which is outlined below. 
- 
-**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**.\\ \\     
-        ***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.\\ \\     
- 
-Try this function using the code below to set all of your disco add ons to pattern **1**. 
-<code> 
-my_marty.disco_pattern(1, my_marty.Disco.ALL) 
-</code> 
- 
-===== Step 3 ===== 
- 
-The function //**disco_color**// allows you to turn on and set your disco add ons to the color of your choice. 
- 
-**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.// \\ \\     
-        ***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.\\ \\     
-        ***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.  
- 
-Try this function using the code below to set all of your disco add ons to teal. 
-<code> 
-my_marty.disco_color('teal', my_marty.Disco.ALL) 
-</code> 
- 
-You can also get the same color by passing in a hex code or RGB tuple. See the code samples below on how you would pass the color **teal** as a hex code or RGB tuple, respectively. 
-<code> 
-my_marty.disco_color('#02d1bc', my_marty.Disco.ALL) 
-</code> 
-<code> 
-my_marty.disco_color((2, 209, 188), my_marty.Disco.ALL) 
-</code> 
- 
- 
-===== Step 4 ===== 
- 
-The function //**disco_off**// allows you to turn off the disco add on of your choice. You can specify which specific add on you want to turn off, or turn off multiple at a time. 
- 
-**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. 
- 
-Try this function using the code below to turn off all of your disco add ons. 
-<code> 
-my_marty.disco_off() 
-</code> 
- 
- 
-===== Passing in Your Add Ons ===== 
- 
-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! 
- 
-- 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: 
-     -my_marty.Disco.EYES 
-     -my_marty.Disco.FEET 
-     -my_marty.Disco.ARMS 
-     -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. 
- 
-