grovepi/docs/api/complex/index.html
2025-03-21 16:04:17 +01:00

1064 lines
No EOL
40 KiB
HTML

<!doctype html>
<html lang="en" class="no-js">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="description" content="Python documentation for the GrovePi">
<link rel="canonical" href="https://dexterind.github.io/GrovePi/api/complex/">
<meta name="author" content="DexterInd Team">
<meta name="lang:clipboard.copy" content="Copy to clipboard">
<meta name="lang:clipboard.copied" content="Copied to clipboard">
<meta name="lang:search.language" content="en">
<meta name="lang:search.pipeline.stopwords" content="True">
<meta name="lang:search.pipeline.trimmer" content="True">
<meta name="lang:search.result.none" content="No matching documents">
<meta name="lang:search.result.one" content="1 matching document">
<meta name="lang:search.result.other" content="# matching documents">
<meta name="lang:search.tokenizer" content="[\s\-]+">
<link rel="shortcut icon" href="../../img/favicon.ico">
<meta name="generator" content="mkdocs-1.0.4, mkdocs-material-4.1.2">
<title>Complex Devices - GrovePi Documentation</title>
<link rel="stylesheet" href="../../assets/stylesheets/application.3020aac5.css">
<script src="../../assets/javascripts/modernizr.01ccdecf.js"></script>
<link href="https://fonts.gstatic.com" rel="preconnect" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,400i,700|Roboto+Mono">
<style>body,input{font-family:"Roboto","Helvetica Neue",Helvetica,Arial,sans-serif}code,kbd,pre{font-family:"Roboto Mono","Courier New",Courier,monospace}</style>
<link rel="stylesheet" href="../../assets/fonts/material-icons.css">
</head>
<body dir="ltr">
<svg class="md-svg">
<defs>
<svg xmlns="http://www.w3.org/2000/svg" width="416" height="448"
viewBox="0 0 416 448" id="__github">
<path fill="currentColor" d="M160 304q0 10-3.125 20.5t-10.75 19-18.125
8.5-18.125-8.5-10.75-19-3.125-20.5 3.125-20.5 10.75-19 18.125-8.5
18.125 8.5 10.75 19 3.125 20.5zM320 304q0 10-3.125 20.5t-10.75
19-18.125 8.5-18.125-8.5-10.75-19-3.125-20.5 3.125-20.5 10.75-19
18.125-8.5 18.125 8.5 10.75 19 3.125 20.5zM360
304q0-30-17.25-51t-46.75-21q-10.25 0-48.75 5.25-17.75 2.75-39.25
2.75t-39.25-2.75q-38-5.25-48.75-5.25-29.5 0-46.75 21t-17.25 51q0 22 8
38.375t20.25 25.75 30.5 15 35 7.375 37.25 1.75h42q20.5 0
37.25-1.75t35-7.375 30.5-15 20.25-25.75 8-38.375zM416 260q0 51.75-15.25
82.75-9.5 19.25-26.375 33.25t-35.25 21.5-42.5 11.875-42.875 5.5-41.75
1.125q-19.5 0-35.5-0.75t-36.875-3.125-38.125-7.5-34.25-12.875-30.25-20.25-21.5-28.75q-15.5-30.75-15.5-82.75
0-59.25 34-99-6.75-20.5-6.75-42.5 0-29 12.75-54.5 27 0 47.5 9.875t47.25
30.875q36.75-8.75 77.25-8.75 37 0 70 8 26.25-20.5
46.75-30.25t47.25-9.75q12.75 25.5 12.75 54.5 0 21.75-6.75 42 34 40 34
99.5z" />
</svg>
</defs>
</svg>
<input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off">
<input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off">
<label class="md-overlay" data-md-component="overlay" for="__drawer"></label>
<a href="#api-complex-devices" tabindex="1" class="md-skip">
Skip to content
</a>
<header class="md-header" data-md-component="header">
<nav class="md-header-nav md-grid">
<div class="md-flex">
<div class="md-flex__cell md-flex__cell--shrink">
<a href="https://dexterind.github.io/GrovePi" title="GrovePi Documentation" class="md-header-nav__button md-logo">
<i class="md-icon"></i>
</a>
</div>
<div class="md-flex__cell md-flex__cell--shrink">
<label class="md-icon md-icon--menu md-header-nav__button" for="__drawer"></label>
</div>
<div class="md-flex__cell md-flex__cell--stretch">
<div class="md-flex__ellipsis md-header-nav__title" data-md-component="title">
<span class="md-header-nav__topic">
GrovePi Documentation
</span>
<span class="md-header-nav__topic">
Complex Devices
</span>
</div>
</div>
<div class="md-flex__cell md-flex__cell--shrink">
<label class="md-icon md-icon--search md-header-nav__button" for="__search"></label>
<div class="md-search" data-md-component="search" role="dialog">
<label class="md-search__overlay" for="__search"></label>
<div class="md-search__inner" role="search">
<form class="md-search__form" name="search">
<input type="text" class="md-search__input" name="query" placeholder="Search" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="query" data-md-state="active">
<label class="md-icon md-search__icon" for="__search"></label>
<button type="reset" class="md-icon md-search__icon" data-md-component="reset" tabindex="-1">
&#xE5CD;
</button>
</form>
<div class="md-search__output">
<div class="md-search__scrollwrap" data-md-scrollfix>
<div class="md-search-result" data-md-component="result">
<div class="md-search-result__meta">
Type to start searching
</div>
<ol class="md-search-result__list"></ol>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="md-flex__cell md-flex__cell--shrink">
<div class="md-header-nav__source">
<a href="https://github.com/DexterInd/GrovePi/" title="Go to repository" class="md-source" data-md-source="github">
<div class="md-source__icon">
<svg viewBox="0 0 24 24" width="24" height="24">
<use xlink:href="#__github" width="24" height="24"></use>
</svg>
</div>
<div class="md-source__repository">
DexterInd/GrovePi
</div>
</a>
</div>
</div>
</div>
</nav>
</header>
<div class="md-container">
<main class="md-main">
<div class="md-main__inner md-grid" data-md-component="container">
<div class="md-sidebar md-sidebar--primary" data-md-component="navigation">
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
<nav class="md-nav md-nav--primary" data-md-level="0">
<label class="md-nav__title md-nav__title--site" for="__drawer">
<a href="https://dexterind.github.io/GrovePi" title="GrovePi Documentation" class="md-nav__button md-logo">
<i class="md-icon"></i>
</a>
GrovePi Documentation
</label>
<div class="md-nav__source">
<a href="https://github.com/DexterInd/GrovePi/" title="Go to repository" class="md-source" data-md-source="github">
<div class="md-source__icon">
<svg viewBox="0 0 24 24" width="24" height="24">
<use xlink:href="#__github" width="24" height="24"></use>
</svg>
</div>
<div class="md-source__repository">
DexterInd/GrovePi
</div>
</a>
</div>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../.." title="About" class="md-nav__link">
About
</a>
</li>
<li class="md-nav__item">
<a href="../../quickstart/" title="Getting Started" class="md-nav__link">
Getting Started
</a>
</li>
<li class="md-nav__item">
<a href="../../fw/" title="Firmware Stuff" class="md-nav__link">
Firmware Stuff
</a>
</li>
<li class="md-nav__item">
<a href="../../hw/" title="Hardware Ports" class="md-nav__link">
Hardware Ports
</a>
</li>
<li class="md-nav__item md-nav__item--active md-nav__item--nested">
<input class="md-toggle md-nav__toggle" data-md-toggle="nav-5" type="checkbox" id="nav-5" checked>
<label class="md-nav__link" for="nav-5">
API Reference
</label>
<nav class="md-nav" data-md-component="collapsible" data-md-level="1">
<label class="md-nav__title" for="nav-5">
API Reference
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../gpio/" title="GPIO Functions" class="md-nav__link">
GPIO Functions
</a>
</li>
<li class="md-nav__item">
<a href="../general/" title="General Sensors" class="md-nav__link">
General Sensors
</a>
</li>
<li class="md-nav__item md-nav__item--active">
<input class="md-toggle md-nav__toggle" data-md-toggle="toc" type="checkbox" id="__toc">
<label class="md-nav__link md-nav__link--active" for="__toc">
Complex Devices
</label>
<a href="./" title="Complex Devices" class="md-nav__link md-nav__link--active">
Complex Devices
</a>
<nav class="md-nav md-nav--secondary">
<label class="md-nav__title" for="__toc">Table of contents</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="#grovepiledbar_initpin-orientation" title="grovepi.ledBar_init(pin, orientation)" class="md-nav__link">
grovepi.ledBar_init(pin, orientation)
</a>
</li>
<li class="md-nav__item">
<a href="#grovepiledbar_orientationpin-orientation" title="grovepi.ledBar_orientation(pin, orientation)" class="md-nav__link">
grovepi.ledBar_orientation(pin, orientation)
</a>
</li>
<li class="md-nav__item">
<a href="#grovepiledbar_setlevelpin-level" title="grovepi.ledBar_setLevel(pin, level)" class="md-nav__link">
grovepi.ledBar_setLevel(pin, level)
</a>
</li>
<li class="md-nav__item">
<a href="#grovepiledbar_toggleledpin-led" title="grovepi.ledBar_toggleLed(pin, led)" class="md-nav__link">
grovepi.ledBar_toggleLed(pin, led)
</a>
</li>
<li class="md-nav__item">
<a href="#grovepiledbar_setbitspin-state" title="grovepi.ledBar_setBits(pin, state)" class="md-nav__link">
grovepi.ledBar_setBits(pin, state)
</a>
</li>
<li class="md-nav__item">
<a href="#grovepiledbar_getbitspin" title="grovepi.ledBar_getBits(pin)" class="md-nav__link">
grovepi.ledBar_getBits(pin)
</a>
</li>
<li class="md-nav__item">
<a href="#grovepifourdigit_initpin" title="grovepi.fourDigit_init(pin)" class="md-nav__link">
grovepi.fourDigit_init(pin)
</a>
</li>
<li class="md-nav__item">
<a href="#grovepifourdigit_numberpin-value-leading_zero" title="grovepi.fourDigit_number(pin, value, leading_zero)" class="md-nav__link">
grovepi.fourDigit_number(pin, value, leading_zero)
</a>
</li>
<li class="md-nav__item">
<a href="#grovepifourdigit_brightnesspin-brightness" title="grovepi.fourDigit_brightness(pin, brightness)" class="md-nav__link">
grovepi.fourDigit_brightness(pin, brightness)
</a>
</li>
<li class="md-nav__item">
<a href="#grovepifourdigit_digitpin-segment-value" title="grovepi.fourDigit_digit(pin, segment, value)" class="md-nav__link">
grovepi.fourDigit_digit(pin, segment, value)
</a>
</li>
<li class="md-nav__item">
<a href="#grovepifourdigit_segmentpin-segment-leds" title="grovepi.fourDigit_segment(pin, segment, leds)" class="md-nav__link">
grovepi.fourDigit_segment(pin, segment, leds)
</a>
</li>
<li class="md-nav__item">
<a href="#grovepifourdigit_scorepin-left-right" title="grovepi.fourDigit_score(pin, left, right)" class="md-nav__link">
grovepi.fourDigit_score(pin, left, right)
</a>
</li>
<li class="md-nav__item">
<a href="#grovepifourdigit_monitorpin-analog-duration" title="grovepi.fourDigit_monitor(pin, analog, duration)" class="md-nav__link">
grovepi.fourDigit_monitor(pin, analog, duration)
</a>
</li>
<li class="md-nav__item">
<a href="#grovepifourdigit_onpin" title="grovepi.fourDigit_on(pin)" class="md-nav__link">
grovepi.fourDigit_on(pin)
</a>
</li>
<li class="md-nav__item">
<a href="#grovepifourdigit_offpin" title="grovepi.fourDigit_off(pin)" class="md-nav__link">
grovepi.fourDigit_off(pin)
</a>
</li>
<li class="md-nav__item">
<a href="#grovepistorecolorred-green-blue" title="grovepi.storeColor(red, green, blue)" class="md-nav__link">
grovepi.storeColor(red, green, blue)
</a>
</li>
<li class="md-nav__item">
<a href="#grovepichainablergbled_initpin-numleds" title="grovepi.chainableRgbLed_init(pin, numLeds)" class="md-nav__link">
grovepi.chainableRgbLed_init(pin, numLeds)
</a>
</li>
<li class="md-nav__item">
<a href="#grovepichainablergbled_testpin-numleds-testcolor" title="grovepi.chainableRgbLed_test(pin, numLeds, testColor)" class="md-nav__link">
grovepi.chainableRgbLed_test(pin, numLeds, testColor)
</a>
</li>
<li class="md-nav__item">
<a href="#grovepichainablergbled_patternpin-pattern-whichled" title="grovepi.chainableRgbLed_pattern(pin, pattern, whichLed)" class="md-nav__link">
grovepi.chainableRgbLed_pattern(pin, pattern, whichLed)
</a>
</li>
<li class="md-nav__item">
<a href="#grovepichainablergbled_modulopin-offset-divisor" title="grovepi.chainableRgbLed_modulo(pin, offset, divisor)" class="md-nav__link">
grovepi.chainableRgbLed_modulo(pin, offset, divisor)
</a>
</li>
<li class="md-nav__item">
<a href="#grovepichainablergbled_setlevelpin-level-reverse" title="grovepi.chainableRgbLed_setLevel(pin, level, reverse)" class="md-nav__link">
grovepi.chainableRgbLed_setLevel(pin, level, reverse)
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="../interrupt/" title="Interrupt-Based Devices" class="md-nav__link">
Interrupt-Based Devices
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="../../supported/" title="Supported Modules" class="md-nav__link">
Supported Modules
</a>
</li>
<li class="md-nav__item">
<a href="../../release-notes/" title="Release Notes" class="md-nav__link">
Release Notes
</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="md-sidebar md-sidebar--secondary" data-md-component="toc">
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
<nav class="md-nav md-nav--secondary">
<label class="md-nav__title" for="__toc">Table of contents</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="#grovepiledbar_initpin-orientation" title="grovepi.ledBar_init(pin, orientation)" class="md-nav__link">
grovepi.ledBar_init(pin, orientation)
</a>
</li>
<li class="md-nav__item">
<a href="#grovepiledbar_orientationpin-orientation" title="grovepi.ledBar_orientation(pin, orientation)" class="md-nav__link">
grovepi.ledBar_orientation(pin, orientation)
</a>
</li>
<li class="md-nav__item">
<a href="#grovepiledbar_setlevelpin-level" title="grovepi.ledBar_setLevel(pin, level)" class="md-nav__link">
grovepi.ledBar_setLevel(pin, level)
</a>
</li>
<li class="md-nav__item">
<a href="#grovepiledbar_toggleledpin-led" title="grovepi.ledBar_toggleLed(pin, led)" class="md-nav__link">
grovepi.ledBar_toggleLed(pin, led)
</a>
</li>
<li class="md-nav__item">
<a href="#grovepiledbar_setbitspin-state" title="grovepi.ledBar_setBits(pin, state)" class="md-nav__link">
grovepi.ledBar_setBits(pin, state)
</a>
</li>
<li class="md-nav__item">
<a href="#grovepiledbar_getbitspin" title="grovepi.ledBar_getBits(pin)" class="md-nav__link">
grovepi.ledBar_getBits(pin)
</a>
</li>
<li class="md-nav__item">
<a href="#grovepifourdigit_initpin" title="grovepi.fourDigit_init(pin)" class="md-nav__link">
grovepi.fourDigit_init(pin)
</a>
</li>
<li class="md-nav__item">
<a href="#grovepifourdigit_numberpin-value-leading_zero" title="grovepi.fourDigit_number(pin, value, leading_zero)" class="md-nav__link">
grovepi.fourDigit_number(pin, value, leading_zero)
</a>
</li>
<li class="md-nav__item">
<a href="#grovepifourdigit_brightnesspin-brightness" title="grovepi.fourDigit_brightness(pin, brightness)" class="md-nav__link">
grovepi.fourDigit_brightness(pin, brightness)
</a>
</li>
<li class="md-nav__item">
<a href="#grovepifourdigit_digitpin-segment-value" title="grovepi.fourDigit_digit(pin, segment, value)" class="md-nav__link">
grovepi.fourDigit_digit(pin, segment, value)
</a>
</li>
<li class="md-nav__item">
<a href="#grovepifourdigit_segmentpin-segment-leds" title="grovepi.fourDigit_segment(pin, segment, leds)" class="md-nav__link">
grovepi.fourDigit_segment(pin, segment, leds)
</a>
</li>
<li class="md-nav__item">
<a href="#grovepifourdigit_scorepin-left-right" title="grovepi.fourDigit_score(pin, left, right)" class="md-nav__link">
grovepi.fourDigit_score(pin, left, right)
</a>
</li>
<li class="md-nav__item">
<a href="#grovepifourdigit_monitorpin-analog-duration" title="grovepi.fourDigit_monitor(pin, analog, duration)" class="md-nav__link">
grovepi.fourDigit_monitor(pin, analog, duration)
</a>
</li>
<li class="md-nav__item">
<a href="#grovepifourdigit_onpin" title="grovepi.fourDigit_on(pin)" class="md-nav__link">
grovepi.fourDigit_on(pin)
</a>
</li>
<li class="md-nav__item">
<a href="#grovepifourdigit_offpin" title="grovepi.fourDigit_off(pin)" class="md-nav__link">
grovepi.fourDigit_off(pin)
</a>
</li>
<li class="md-nav__item">
<a href="#grovepistorecolorred-green-blue" title="grovepi.storeColor(red, green, blue)" class="md-nav__link">
grovepi.storeColor(red, green, blue)
</a>
</li>
<li class="md-nav__item">
<a href="#grovepichainablergbled_initpin-numleds" title="grovepi.chainableRgbLed_init(pin, numLeds)" class="md-nav__link">
grovepi.chainableRgbLed_init(pin, numLeds)
</a>
</li>
<li class="md-nav__item">
<a href="#grovepichainablergbled_testpin-numleds-testcolor" title="grovepi.chainableRgbLed_test(pin, numLeds, testColor)" class="md-nav__link">
grovepi.chainableRgbLed_test(pin, numLeds, testColor)
</a>
</li>
<li class="md-nav__item">
<a href="#grovepichainablergbled_patternpin-pattern-whichled" title="grovepi.chainableRgbLed_pattern(pin, pattern, whichLed)" class="md-nav__link">
grovepi.chainableRgbLed_pattern(pin, pattern, whichLed)
</a>
</li>
<li class="md-nav__item">
<a href="#grovepichainablergbled_modulopin-offset-divisor" title="grovepi.chainableRgbLed_modulo(pin, offset, divisor)" class="md-nav__link">
grovepi.chainableRgbLed_modulo(pin, offset, divisor)
</a>
</li>
<li class="md-nav__item">
<a href="#grovepichainablergbled_setlevelpin-level-reverse" title="grovepi.chainableRgbLed_setLevel(pin, level, reverse)" class="md-nav__link">
grovepi.chainableRgbLed_setLevel(pin, level, reverse)
</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="md-content">
<article class="md-content__inner md-typeset">
<a href="https://github.com/DexterInd/GrovePi/edit/master/docs/api/complex.md" title="Edit this page" class="md-icon md-content__icon">&#xE3C9;</a>
<h1 id="api-complex-devices">API - Complex Devices<a class="headerlink" href="#api-complex-devices" title="Permanent link">&para;</a></h1>
<p>In this section the Python API reference for more complex devices is described. This library is supported on both major versions
of Python: 2.x and 3.x.</p>
<p>The API for the following sensors is described in this section:</p>
<ul>
<li><a href="http://wiki.seeedstudio.com/Grove-LED_Bar/">Grove LED bar</a></li>
<li><a href="http://wiki.seeedstudio.com/Grove-4-Digit_Display/">Grove 4-Digit Display</a></li>
<li><a href="https://www.seeedstudio.com/Grove-Chainable-RGB-LED-p-850.html">Grove Chainable RGB LED</a></li>
</ul>
<hr />
<p><strong>IMPORTANT</strong></p>
<p>This library and the other ones too are not thread-safe. You cannot call the GrovePi from multiple threads or processes
as that will put the GrovePi into a broken state.</p>
<p>In case you need to reset the GrovePi from your Raspberry Pi, <a href="../fw/#resetting-the-grovepi">check this section</a>.</p>
<p>The functions don't verify if the input parameters are valid and therefore the parameters have to be verified/validated before that.
Calling a function with improper parameters can result in an undefined behavior for the GrovePi.</p>
<hr />
<h2 id="grovepiledbar_initpin-orientation"><code>grovepi.ledBar_init(pin, orientation)</code><a class="headerlink" href="#grovepiledbar_initpin-orientation" title="Permanent link">&para;</a></h2>
<p>Initialize an <a href="http://wiki.seeedstudio.com/Grove-LED_Bar/">LED bar</a>.</p>
<p><strong>Parameters</strong></p>
<ul>
<li><code>pin {Integer}</code> a number to identify the port (D2-D8) to which the LED bar is assigned to</li>
<li><code>orientation {Integer}</code> <code>0</code> to go from red to green or 1 to go the other way</li>
</ul>
<p><strong>Returns</strong>: <code>1</code> all the time</p>
<hr />
<h2 id="grovepiledbar_orientationpin-orientation"><code>grovepi.ledBar_orientation(pin, orientation)</code><a class="headerlink" href="#grovepiledbar_orientationpin-orientation" title="Permanent link">&para;</a></h2>
<p>Set the orientation on an already initialized <a href="http://wiki.seeedstudio.com/Grove-LED_Bar/">LED bar</a>.</p>
<p><strong>Parameters</strong></p>
<ul>
<li><code>pin {Integer}</code> a number to identify the port (D2-D8) to which the LED bar is assigned to</li>
<li><code>orientation {Integer}</code> <code>0</code> to go from red to green or 1 to go the other way</li>
</ul>
<p><strong>Returns</strong>: <code>1</code> all the time</p>
<hr />
<h2 id="grovepiledbar_setlevelpin-level"><code>grovepi.ledBar_setLevel(pin, level)</code><a class="headerlink" href="#grovepiledbar_setlevelpin-level" title="Permanent link">&para;</a></h2>
<p>Set the level on an <a href="http://wiki.seeedstudio.com/Grove-LED_Bar/">LED bar</a>.</p>
<p><strong>Parameters</strong></p>
<ul>
<li><code>pin {Integer}</code> a number to identify the port (D2-D8) to which the LED bar is assigned to</li>
<li><code>orientation {Integer}</code> <code>0</code> to <code>10</code> corresponding to the number of levels that exist on the LED bar.</li>
</ul>
<p><strong>Returns</strong>: <code>1</code> all the time</p>
<hr />
<h2 id="grovepiledbar_toggleledpin-led"><code>grovepi.ledBar_toggleLed(pin, led)</code><a class="headerlink" href="#grovepiledbar_toggleledpin-led" title="Permanent link">&para;</a></h2>
<p>Toggle the state of one LED of the 10 levels of the <a href="http://wiki.seeedstudio.com/Grove-LED_Bar/">LED bar</a>.</p>
<p><strong>Parameters</strong></p>
<ul>
<li><code>pin {Integer}</code> a number to identify the port (D2-D8) to which the LED bar is assigned to</li>
<li><code>led {Integer}</code> taking values from <code>0</code> to <code>10</code> depending on which LED to toggle</li>
</ul>
<p><strong>Returns</strong>: <code>1</code> all the time</p>
<hr />
<h2 id="grovepiledbar_setbitspin-state"><code>grovepi.ledBar_setBits(pin, state)</code><a class="headerlink" href="#grovepiledbar_setbitspin-state" title="Permanent link">&para;</a></h2>
<p>Set the LED activations of the <a href="http://wiki.seeedstudio.com/Grove-LED_Bar/">LED bar</a> based on the binary representation of a 10-bit number.</p>
<p><strong>Parameters</strong></p>
<ul>
<li><code>pin {Integer}</code> a number to identify the port (D2-D8) to which the LED bar is assigned to</li>
<li><code>state {Integer}</code> a number from <code>0</code> to <code>1023</code> that covers all states for all 10 LEDs of the LED bar</li>
</ul>
<p><strong>Returns</strong>: <code>1</code> all the time</p>
<hr />
<h2 id="grovepiledbar_getbitspin"><code>grovepi.ledBar_getBits(pin)</code><a class="headerlink" href="#grovepiledbar_getbitspin" title="Permanent link">&para;</a></h2>
<p>Read the state of LED activations on the <a href="http://wiki.seeedstudio.com/Grove-LED_Bar/">LED bar</a>.</p>
<p><strong>Parameters</strong></p>
<ul>
<li><code>pin {Integer}</code> a number to identify the port (D2-D8) to which the LED bar is assigned to</li>
</ul>
<p><strong>Returns</strong>: a number from <code>0</code> to <code>1023</code> to represent the binary state of all 10 LEDs of the LED bar</p>
<hr />
<h2 id="grovepifourdigit_initpin"><code>grovepi.fourDigit_init(pin)</code><a class="headerlink" href="#grovepifourdigit_initpin" title="Permanent link">&para;</a></h2>
<p>Initialize a <a href="http://wiki.seeedstudio.com/Grove-4-Digit_Display/">Grove 4-Digit Display</a>.</p>
<p><strong>Parameters</strong></p>
<ul>
<li><code>pin {Integer}</code> the port (D2-D8) to which the 4-Digit display is set to</li>
</ul>
<p><strong>Returns</strong>: <code>1</code> all the time</p>
<hr />
<h2 id="grovepifourdigit_numberpin-value-leading_zero"><code>grovepi.fourDigit_number(pin, value, leading_zero)</code><a class="headerlink" href="#grovepifourdigit_numberpin-value-leading_zero" title="Permanent link">&para;</a></h2>
<p>Set the <a href="http://wiki.seeedstudio.com/Grove-4-Digit_Display/">Grove 4-Digit Display</a> to display a number.</p>
<p><strong>Parameters</strong></p>
<ul>
<li><code>pin {Integer}</code> the port (D2-D8) to which the 4-Digit display is set to</li>
<li><code>value {Integer}</code> a value between <code>0</code> and <code>9999</code> representing the number to be printed on the display</li>
<li><code>leading_zero {Boolean}</code> whether to add leading zeros or not</li>
</ul>
<p><strong>Returns</strong>: <code>1</code> all the time</p>
<hr />
<h2 id="grovepifourdigit_brightnesspin-brightness"><code>grovepi.fourDigit_brightness(pin, brightness)</code><a class="headerlink" href="#grovepifourdigit_brightnesspin-brightness" title="Permanent link">&para;</a></h2>
<p>Set the brightness of the <a href="http://wiki.seeedstudio.com/Grove-4-Digit_Display/">Grove 4-Digit Display</a>.</p>
<p><strong>Parameters</strong></p>
<ul>
<li><code>pin {Integer}</code> the port (D2-D8) to which the 4-Digit display is set to</li>
<li><code>brightness {Integer}</code> a number between <code>0</code> (for the darkest option) and <code>7</code> (for the brightest) representing the brightness of the display</li>
</ul>
<p><strong>Returns</strong>: <code>1</code> all the time</p>
<hr />
<h2 id="grovepifourdigit_digitpin-segment-value"><code>grovepi.fourDigit_digit(pin, segment, value)</code><a class="headerlink" href="#grovepifourdigit_digitpin-segment-value" title="Permanent link">&para;</a></h2>
<p>Set individual segment of the <a href="http://wiki.seeedstudio.com/Grove-4-Digit_Display/">Grove 4-Digit Display</a>.</p>
<p><strong>Parameters</strong></p>
<ul>
<li><code>pin {Integer}</code> the port (D2-D8) to which the 4-Digit display is set to</li>
<li><code>segment {Integer}</code> a number from <code>0</code> to <code>3</code> representing the segment</li>
<li><code>value {Integer}</code> value of the segment - <code>0</code> to <code>15</code></li>
</ul>
<p><strong>Returns</strong>: <code>1</code> all the time</p>
<hr />
<h2 id="grovepifourdigit_segmentpin-segment-leds"><code>grovepi.fourDigit_segment(pin, segment, leds)</code><a class="headerlink" href="#grovepifourdigit_segmentpin-segment-leds" title="Permanent link">&para;</a></h2>
<p>Set the individual LED segments of a digit of the <a href="http://wiki.seeedstudio.com/Grove-4-Digit_Display/">Grove 4-Digit Display</a>.</p>
<p><strong>Parameters</strong></p>
<ul>
<li><code>pin {Integer}</code> the port (D2-D8) to which the 4-Digit display is set to</li>
<li><code>segment {Integer}</code> which segment of the display to modify (<code>0</code> to <code>3</code>)</li>
<li><code>leds {Integer}</code> a number from <code>0</code> to <code>255</code> representing the binary activations of the selected <code>segment</code> - the 8th bit is the colon</li>
</ul>
<p><strong>Returns</strong>: <code>1</code> all the time</p>
<hr />
<h2 id="grovepifourdigit_scorepin-left-right"><code>grovepi.fourDigit_score(pin, left, right)</code><a class="headerlink" href="#grovepifourdigit_scorepin-left-right" title="Permanent link">&para;</a></h2>
<p>Set values on either side of the <a href="http://wiki.seeedstudio.com/Grove-4-Digit_Display/">Grove 4-Digit Display</a>.
To the left and right values, leading zeros are added and the colon is lit up</p>
<p><strong>Parameters</strong></p>
<ul>
<li><code>pin {Integer}</code> the port (D2-D8) to which the 4-Digit display is set to</li>
<li><code>left {Integer}</code> value to be displayed on the left side of the display (takes values from <code>0</code> to <code>99</code>)</li>
<li><code>right {Integer}</code> value to be displayed on the right side of the display (takes values from <code>0</code> to <code>99</code>)</li>
</ul>
<p><strong>Returns</strong>: <code>1</code> all the time</p>
<hr />
<h2 id="grovepifourdigit_monitorpin-analog-duration"><code>grovepi.fourDigit_monitor(pin, analog, duration)</code><a class="headerlink" href="#grovepifourdigit_monitorpin-analog-duration" title="Permanent link">&para;</a></h2>
<p>Display the <a href="#grovepianalogreadpin">analogRead</a> values onto the <a href="http://wiki.seeedstudio.com/Grove-4-Digit_Display/">Grove 4-Digit Display</a> for a given time.</p>
<p><strong>Parameters</strong></p>
<ul>
<li><code>pin {Integer}</code> the port (D2-D8) to which the 4-Digit display is set to</li>
<li><code>analog {Integer}</code> the port (A0-A2) on which analog values are read from</li>
<li><code>duration {Integer}</code> for how many seconds (<code>0</code> to <code>255</code>) the readings are to be displayed</li>
</ul>
<p><strong>Returns</strong>: <code>1</code> all the time</p>
<hr />
<h2 id="grovepifourdigit_onpin"><code>grovepi.fourDigit_on(pin)</code><a class="headerlink" href="#grovepifourdigit_onpin" title="Permanent link">&para;</a></h2>
<p>Turn the whole <a href="http://wiki.seeedstudio.com/Grove-4-Digit_Display/">Grove 4-Digit Display</a> on.</p>
<p><strong>Parameters</strong></p>
<ul>
<li><code>pin {Integer}</code> the port (D2-D8) to which the 4-Digit display is set to</li>
</ul>
<p><strong>Returns</strong>: <code>1</code> all the time</p>
<hr />
<h2 id="grovepifourdigit_offpin"><code>grovepi.fourDigit_off(pin)</code><a class="headerlink" href="#grovepifourdigit_offpin" title="Permanent link">&para;</a></h2>
<p>Turn the whole <a href="http://wiki.seeedstudio.com/Grove-4-Digit_Display/">Grove 4-Digit Display</a> off.</p>
<p><strong>Parameters</strong></p>
<ul>
<li><code>pin {Integer}</code> the port (D2-D8) to which the 4-Digit display is set to</li>
</ul>
<p><strong>Returns</strong>: <code>1</code> all the time</p>
<hr />
<h2 id="grovepistorecolorred-green-blue"><code>grovepi.storeColor(red, green, blue)</code><a class="headerlink" href="#grovepistorecolorred-green-blue" title="Permanent link">&para;</a></h2>
<p>Store a color for later use with the <a href="https://www.seeedstudio.com/Grove-Chainable-RGB-LED-p-850.html">Grove Chainable RGB LED</a>.</p>
<p><strong>Parameters</strong></p>
<ul>
<li><code>red {Integer}</code> value from <code>0</code> to <code>255</code></li>
<li><code>green {Integer}</code> value from <code>0</code> to <code>255</code></li>
<li><code>blue {Integer}</code> value from <code>0</code> to <code>255</code></li>
</ul>
<p><strong>Returns</strong>: <code>1</code> all the time</p>
<hr />
<h2 id="grovepichainablergbled_initpin-numleds"><code>grovepi.chainableRgbLed_init(pin, numLeds)</code><a class="headerlink" href="#grovepichainablergbled_initpin-numleds" title="Permanent link">&para;</a></h2>
<p>Initialize a number of <a href="https://www.seeedstudio.com/Grove-Chainable-RGB-LED-p-850.html">chained LEDs</a> on given port.</p>
<p><strong>Parameters</strong></p>
<ul>
<li><code>pin {Integer}</code> the port (D2-D8) to which the Grove RGB LED(s) are connected to</li>
<li><code>numLeds {Integer}</code> number of chained LEDs</li>
</ul>
<p><strong>Returns</strong>: <code>1</code> all the time</p>
<hr />
<h2 id="grovepichainablergbled_testpin-numleds-testcolor"><code>grovepi.chainableRgbLed_test(pin, numLeds, testColor)</code><a class="headerlink" href="#grovepichainablergbled_testpin-numleds-testcolor" title="Permanent link">&para;</a></h2>
<p>Initialize <a href="https://www.seeedstudio.com/Grove-Chainable-RGB-LED-p-850.html">chained LEDs</a> on given port and set a test color on all of them.</p>
<p><strong>Parameters</strong></p>
<ul>
<li><code>pin {Integer}</code> the port (D2-D8) to which the Grove RGB LED(s) are connected to</li>
<li><code>numLeds {Integer}</code> number of chained LEDs</li>
<li>
<p><code>testColor {Integer}</code> the color to use for all chained LEDs</p>
<ul>
<li><code>0</code> for black (or nothing)</li>
<li><code>1</code> for blue</li>
<li><code>2</code> for green</li>
<li><code>3</code> for cyan</li>
<li><code>4</code> for red</li>
<li><code>5</code> for magenta</li>
<li><code>6</code> for yellow</li>
<li><code>7</code> for white</li>
</ul>
</li>
</ul>
<p><strong>Returns</strong>: <code>1</code> all the time</p>
<hr />
<h2 id="grovepichainablergbled_patternpin-pattern-whichled"><code>grovepi.chainableRgbLed_pattern(pin, pattern, whichLed)</code><a class="headerlink" href="#grovepichainablergbled_patternpin-pattern-whichled" title="Permanent link">&para;</a></h2>
<p>Set one or more <a href="https://www.seeedstudio.com/Grove-Chainable-RGB-LED-p-850.html">chained LEDs</a> to a stored color following a given pattern.</p>
<p><strong>Parameters</strong></p>
<ul>
<li><code>pin {Integer}</code> the port (D2-D8) to which the Grove RGB LED(s) are connected to</li>
<li>
<p><code>pattern {Integer}</code></p>
<ul>
<li><code>0</code> for this LED only</li>
<li><code>1</code> for all LEDs except this LED</li>
<li><code>2</code> this LED and all LEDs inwards</li>
<li><code>3</code> this LED and all LEDs outwards</li>
</ul>
</li>
<li>
<p><code>whichLed {Integer}</code> the index of the LED you wish to set counting outwards from the GrovePi starting with <code>0</code></p>
</li>
</ul>
<p><strong>Returns</strong>: <code>1</code> all the time</p>
<hr />
<h2 id="grovepichainablergbled_modulopin-offset-divisor"><code>grovepi.chainableRgbLed_modulo(pin, offset, divisor)</code><a class="headerlink" href="#grovepichainablergbled_modulopin-offset-divisor" title="Permanent link">&para;</a></h2>
<p>Set one or more <a href="https://www.seeedstudio.com/Grove-Chainable-RGB-LED-p-850.html">chained LEDs</a> to a stored color following the "pattern" of the modulo operation.</p>
<p><strong>Parameters</strong></p>
<ul>
<li><code>pin {Integer}</code> the port (D2-D8) to which the Grove RGB LED(s) are connected to</li>
<li><code>offset {Integer}</code> the index of the LED you want to start at (<code>0</code> is for the 1st LED)</li>
<li><code>divisor {Integer}</code> sets the color to those LEDs of whose indexes divided by <code>divisor</code> have the remainder set to <code>0</code> - for <code>divisor=1</code> every LED gets set, but for <code>divisor=2</code> every 2nd LED gets set </li>
</ul>
<p><strong>Returns</strong>: <code>1</code> all the time</p>
<hr />
<h2 id="grovepichainablergbled_setlevelpin-level-reverse"><code>grovepi.chainableRgbLed_setLevel(pin, level, reverse)</code><a class="headerlink" href="#grovepichainablergbled_setlevelpin-level-reverse" title="Permanent link">&para;</a></h2>
<p>Set one or more <a href="https://www.seeedstudio.com/Grove-Chainable-RGB-LED-p-850.html">chained LEDs</a> to a stored color similar to a bar graph.</p>
<p><strong>Parameters</strong></p>
<ul>
<li><code>pin {Integer}</code> the port (D2-D8) to which the Grove RGB LED(s) are connected to</li>
<li><code>level {Integer}</code> the number of LEDs you want to set to the stored color</li>
<li><code>reverse {Integer}</code> <code>0</code> when counting outwards from the GrovePi or <code>1</code> when it's the other way (from the most outward LED inwards)</li>
</ul>
<p><strong>Returns</strong>: <code>1</code> all the time</p>
</article>
</div>
</div>
</main>
<footer class="md-footer">
<div class="md-footer-nav">
<nav class="md-footer-nav__inner md-grid">
<a href="../general/" title="General Sensors" class="md-flex md-footer-nav__link md-footer-nav__link--prev" rel="prev">
<div class="md-flex__cell md-flex__cell--shrink">
<i class="md-icon md-icon--arrow-back md-footer-nav__button"></i>
</div>
<div class="md-flex__cell md-flex__cell--stretch md-footer-nav__title">
<span class="md-flex__ellipsis">
<span class="md-footer-nav__direction">
Previous
</span>
General Sensors
</span>
</div>
</a>
<a href="../interrupt/" title="Interrupt-Based Devices" class="md-flex md-footer-nav__link md-footer-nav__link--next" rel="next">
<div class="md-flex__cell md-flex__cell--stretch md-footer-nav__title">
<span class="md-flex__ellipsis">
<span class="md-footer-nav__direction">
Next
</span>
Interrupt-Based Devices
</span>
</div>
<div class="md-flex__cell md-flex__cell--shrink">
<i class="md-icon md-icon--arrow-forward md-footer-nav__button"></i>
</div>
</a>
</nav>
</div>
<div class="md-footer-meta md-typeset">
<div class="md-footer-meta__inner md-grid">
<div class="md-footer-copyright">
<div class="md-footer-copyright__highlight">
Maintained by the <a href="/release-notes/#maintenance-team">DexterInd Team</a>.
</div>
powered by
<a href="https://www.mkdocs.org">MkDocs</a>
and
<a href="https://squidfunk.github.io/mkdocs-material/">
Material for MkDocs</a>
</div>
<div class="md-footer-social">
<link rel="stylesheet" href="../../assets/fonts/font-awesome.css">
<a href="https://github.com/DexterInd" class="md-footer-social__link fa fa-github"></a>
<a href="https://twitter.com/dexterind" class="md-footer-social__link fa fa-twitter"></a>
</div>
</div>
</div>
</footer>
</div>
<script src="../../assets/javascripts/application.267712eb.js"></script>
<script>app.initialize({version:"1.0.4",url:{base:"../.."}})</script>
</body>
</html>