mirror of
https://github.com/taigrr/arduinolibs
synced 2025-01-18 04:33:12 -08:00
233 lines
14 KiB
HTML
233 lines
14 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
|
<title>ArduinoLibs: Dot Matrix Display Demo</title>
|
|
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
|
<link href="search/search.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="search/search.js"></script>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
|
|
</head>
|
|
<body onload='searchBox.OnSelectItem(0);'>
|
|
<!-- Generated by Doxygen 1.7.4 -->
|
|
<script type="text/javascript"><!--
|
|
var searchBox = new SearchBox("searchBox", "search",false,'Search');
|
|
--></script>
|
|
<div id="top">
|
|
<div id="titlearea">
|
|
<table cellspacing="0" cellpadding="0">
|
|
<tbody>
|
|
<tr style="height: 56px;">
|
|
<td style="padding-left: 0.5em;">
|
|
<div id="projectname">ArduinoLibs</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<div id="navrow1" class="tabs">
|
|
<ul class="tablist">
|
|
<li><a href="index.html"><span>Main Page</span></a></li>
|
|
<li class="current"><a href="pages.html"><span>Related Pages</span></a></li>
|
|
<li><a href="modules.html"><span>Modules</span></a></li>
|
|
<li><a href="annotated.html"><span>Classes</span></a></li>
|
|
<li><a href="files.html"><span>Files</span></a></li>
|
|
<li id="searchli">
|
|
<div id="MSearchBox" class="MSearchBoxInactive">
|
|
<span class="left">
|
|
<img id="MSearchSelect" src="search/mag_sel.png"
|
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
|
alt=""/>
|
|
<input type="text" id="MSearchField" value="Search" accesskey="S"
|
|
onfocus="searchBox.OnSearchFieldFocus(true)"
|
|
onblur="searchBox.OnSearchFieldFocus(false)"
|
|
onkeyup="searchBox.OnSearchFieldChange(event)"/>
|
|
</span><span class="right">
|
|
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
|
|
</span>
|
|
</div>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class="header">
|
|
<div class="headertitle">
|
|
<div class="title">Dot Matrix Display Demo </div> </div>
|
|
</div>
|
|
<div class="contents">
|
|
<div class="textblock"><p>This demo shows off various features of drawing with the <a class="el" href="classBitmap.html" title="Represents a monochrome bitmap within main memory.">Bitmap</a> class to a <a class="el" href="classDMD.html" title="Handle large dot matrix displays composed of LED's.">DMD</a> display:</p>
|
|
<ul>
|
|
<li>Drawing circles, lines, and rectangles. </li>
|
|
<li>Filling the screen with a bitmap-based brick pattern. </li>
|
|
<li>Drawing bitmaps directly from program memory. </li>
|
|
<li>Drawing text in various fonts. </li>
|
|
<li>Scrolling text in a "marquee".</li>
|
|
</ul>
|
|
<p><a class="el" href="dmd_running_figure.html">RunningFigure</a> provides another example of drawing and animating bitmaps.</p>
|
|
<p>The full source code for the demo follows:</p>
|
|
<div class="fragment"><pre class="fragment"><span class="comment">/*</span>
|
|
<span class="comment">This example demonstrates how to use the DMD and related classes to</span>
|
|
<span class="comment">draw things on a Freetronics Large Dot Matrix Display.</span>
|
|
<span class="comment"></span>
|
|
<span class="comment">This example is placed into the public domain.</span>
|
|
<span class="comment">*/</span>
|
|
|
|
<span class="preprocessor">#include <DMD.h></span>
|
|
<span class="preprocessor">#include <DejaVuSans9.h></span>
|
|
<span class="preprocessor">#include <DejaVuSansBold9.h></span>
|
|
<span class="preprocessor">#include <DejaVuSansItalic9.h></span>
|
|
<span class="preprocessor">#include <Mono5x7.h></span>
|
|
|
|
<a class="code" href="classDMD.html" title="Handle large dot matrix displays composed of LED's.">DMD</a> display;
|
|
|
|
ISR(TIMER1_OVF_vect)
|
|
{
|
|
display.<a class="code" href="classDMD.html#a9e4bf2a9d247312d35c1401ff61261c8" title="Refresh the display.">refresh</a>();
|
|
}
|
|
|
|
<span class="keywordtype">void</span> setup() {
|
|
display.<a class="code" href="classDMD.html#a4c3b04b384f3d656a9b59690836775e2" title="Enables Timer1 overflow interrupts for updating this display.">enableTimer1</a>();
|
|
}
|
|
|
|
<span class="keywordtype">void</span> loop() {
|
|
drawShapes();
|
|
delay(1000);
|
|
|
|
drawBricks();
|
|
delay(1000);
|
|
|
|
drawStickFigures();
|
|
delay(1000);
|
|
|
|
drawText();
|
|
delay(1000);
|
|
|
|
drawBoldText();
|
|
delay(1000);
|
|
|
|
drawItalicText();
|
|
delay(1000);
|
|
|
|
drawMonoText();
|
|
delay(1000);
|
|
|
|
drawMarquee();
|
|
delay(500);
|
|
}
|
|
|
|
<span class="keywordtype">void</span> drawShapes()
|
|
{
|
|
display.<a class="code" href="classBitmap.html#a839dc8fab05a5ebf7a6b2e61436b2fa1" title="Clears the entire bitmap to the specified color.">clear</a>();
|
|
display.<a class="code" href="classBitmap.html#a933763a4f3cba79fbcf97ae6d0a864aa" title="Draws a circle with a specific center (centerX, centerY) and radius, with the outline in borderColor ...">drawCircle</a>(6, 8, 3);
|
|
display.<a class="code" href="classBitmap.html#a757291b9a39bcb0d64ac98d3a2fa061b" title="Draws a filled circle with a specific center (centerX, centerY) and radius in color.">drawFilledCircle</a>(16, 8, 3);
|
|
display.<a class="code" href="classBitmap.html#aa0a84f3694e343d68e7021552c69f767" title="Draws a line from (x1, y1) to (x2, y2) in color.">drawLine</a>(22, 5, 28, 11);
|
|
display.<a class="code" href="classBitmap.html#aa0a84f3694e343d68e7021552c69f767" title="Draws a line from (x1, y1) to (x2, y2) in color.">drawLine</a>(28, 5, 22, 11);
|
|
display.<a class="code" href="classBitmap.html#aac61e3f7f625db568e37d88b52b3b2fc" title="Draws a rectangle from (x1, y1) to (x2, y2), with the outline in borderColor and the interior filled ...">drawRect</a>(0, 0, display.<a class="code" href="classBitmap.html#a76c3b49e535761f07c553e7336daf523" title="Returns the width of the bitmap in pixels.">width</a>() - 1, display.<a class="code" href="classBitmap.html#adcd4e3dc7594421e647b0f52da9a41a3" title="Returns the height of the bitmap in pixels.">height</a>() - 1);
|
|
}
|
|
|
|
<span class="keywordtype">void</span> drawBricks()
|
|
{
|
|
<span class="keyword">static</span> <span class="keyword">const</span> uint8_t bricks[] PROGMEM = {
|
|
16, 6,
|
|
B11111111, B11111111,
|
|
B10000000, B10000000,
|
|
B10000000, B10000000,
|
|
B11111111, B11111111,
|
|
B00001000, B00001000,
|
|
B00001000, B00001000
|
|
};
|
|
display.<a class="code" href="classBitmap.html#a99da820f9280aace6b512801d5a5e2b2" title="Fills the width x height pixels starting at top-left corner (x, y) with color.">fill</a>(0, 0, display.<a class="code" href="classBitmap.html#a76c3b49e535761f07c553e7336daf523" title="Returns the width of the bitmap in pixels.">width</a>(), display.<a class="code" href="classBitmap.html#adcd4e3dc7594421e647b0f52da9a41a3" title="Returns the height of the bitmap in pixels.">height</a>(), bricks);
|
|
}
|
|
|
|
<span class="keywordtype">void</span> drawStickFigures()
|
|
{
|
|
<span class="keyword">static</span> <span class="keyword">const</span> uint8_t stickFigure[] PROGMEM = {
|
|
9, 13,
|
|
B00111110, B00000000,
|
|
B01000001, B00000000,
|
|
B01000001, B00000000,
|
|
B00111110, B00000000,
|
|
B00001000, B00000000,
|
|
B00001000, B00000000,
|
|
B11111111, B10000000,
|
|
B00001000, B00000000,
|
|
B00001000, B00000000,
|
|
B00010100, B00000000,
|
|
B00100010, B00000000,
|
|
B01000001, B00000000,
|
|
B10000000, B10000000
|
|
};
|
|
display.<a class="code" href="classBitmap.html#a839dc8fab05a5ebf7a6b2e61436b2fa1" title="Clears the entire bitmap to the specified color.">clear</a>();
|
|
display.<a class="code" href="classBitmap.html#a491e9c0bb20ddf5a5eb4933077c8ed72" title="Draws bitmap at (x, y) in color.">drawBitmap</a>(2, 1, stickFigure);
|
|
display.<a class="code" href="classBitmap.html#a4321640464bc08b60348c09bff01b86a" title="Draws bitmap at (x, y) in inverted colors.">drawInvertedBitmap</a>(12, 1, stickFigure);
|
|
display.<a class="code" href="classBitmap.html#a491e9c0bb20ddf5a5eb4933077c8ed72" title="Draws bitmap at (x, y) in color.">drawBitmap</a>(22, 1, stickFigure);
|
|
}
|
|
|
|
<span class="keywordtype">void</span> drawText()
|
|
{
|
|
display.<a class="code" href="classBitmap.html#a839dc8fab05a5ebf7a6b2e61436b2fa1" title="Clears the entire bitmap to the specified color.">clear</a>();
|
|
display.<a class="code" href="classBitmap.html#abf7adfceb267080aa9806388e96358c4" title="Sets the font for use with drawText() and drawChar().">setFont</a>(DejaVuSans9);
|
|
display.<a class="code" href="classBitmap.html#a3e9bcbfb584d5020bd6f0a313ee275f0" title="Draws the len characters of str at (x, y).">drawText</a>(0, 0, <span class="stringliteral">"Hello"</span>);
|
|
display.<a class="code" href="classBitmap.html#a3e9bcbfb584d5020bd6f0a313ee275f0" title="Draws the len characters of str at (x, y).">drawText</a>(9, 8, <span class="stringliteral">"World"</span>);
|
|
}
|
|
|
|
<span class="keywordtype">void</span> drawBoldText()
|
|
{
|
|
display.<a class="code" href="classBitmap.html#a839dc8fab05a5ebf7a6b2e61436b2fa1" title="Clears the entire bitmap to the specified color.">clear</a>();
|
|
display.<a class="code" href="classBitmap.html#abf7adfceb267080aa9806388e96358c4" title="Sets the font for use with drawText() and drawChar().">setFont</a>(DejaVuSansBold9);
|
|
display.<a class="code" href="classBitmap.html#a3e9bcbfb584d5020bd6f0a313ee275f0" title="Draws the len characters of str at (x, y).">drawText</a>(0, 0, <span class="stringliteral">"Hello"</span>);
|
|
display.<a class="code" href="classBitmap.html#a3e9bcbfb584d5020bd6f0a313ee275f0" title="Draws the len characters of str at (x, y).">drawText</a>(4, 8, <span class="stringliteral">"World"</span>);
|
|
}
|
|
|
|
<span class="keywordtype">void</span> drawItalicText()
|
|
{
|
|
display.<a class="code" href="classBitmap.html#a839dc8fab05a5ebf7a6b2e61436b2fa1" title="Clears the entire bitmap to the specified color.">clear</a>();
|
|
display.<a class="code" href="classBitmap.html#abf7adfceb267080aa9806388e96358c4" title="Sets the font for use with drawText() and drawChar().">setFont</a>(DejaVuSansItalic9);
|
|
display.<a class="code" href="classBitmap.html#a3e9bcbfb584d5020bd6f0a313ee275f0" title="Draws the len characters of str at (x, y).">drawText</a>(0, 0, <span class="stringliteral">"Hello"</span>);
|
|
display.<a class="code" href="classBitmap.html#a3e9bcbfb584d5020bd6f0a313ee275f0" title="Draws the len characters of str at (x, y).">drawText</a>(2, 8, <span class="stringliteral">"World"</span>);
|
|
}
|
|
|
|
<span class="keywordtype">void</span> drawMonoText()
|
|
{
|
|
display.<a class="code" href="classBitmap.html#a839dc8fab05a5ebf7a6b2e61436b2fa1" title="Clears the entire bitmap to the specified color.">clear</a>();
|
|
display.<a class="code" href="classBitmap.html#abf7adfceb267080aa9806388e96358c4" title="Sets the font for use with drawText() and drawChar().">setFont</a>(Mono5x7);
|
|
display.<a class="code" href="classBitmap.html#a3e9bcbfb584d5020bd6f0a313ee275f0" title="Draws the len characters of str at (x, y).">drawText</a>(0, 0, <span class="stringliteral">"Hello"</span>);
|
|
display.<a class="code" href="classBitmap.html#a3e9bcbfb584d5020bd6f0a313ee275f0" title="Draws the len characters of str at (x, y).">drawText</a>(3, 8, <span class="stringliteral">"World"</span>);
|
|
}
|
|
|
|
<span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> message[] = <span class="stringliteral">"Eat at Joes!"</span>;
|
|
|
|
<span class="keywordtype">void</span> drawMarquee()
|
|
{
|
|
<span class="keywordtype">int</span> width = display.<a class="code" href="classBitmap.html#a76c3b49e535761f07c553e7336daf523" title="Returns the width of the bitmap in pixels.">width</a>();
|
|
display.<a class="code" href="classBitmap.html#abf7adfceb267080aa9806388e96358c4" title="Sets the font for use with drawText() and drawChar().">setFont</a>(DejaVuSans9);
|
|
<span class="keywordtype">int</span> msgWidth = display.<a class="code" href="classBitmap.html#a0f7607b1c7867987f4500d490a666e8a" title="Returns the width in pixels of the len characters of str in the current font(), including inter-chara...">textWidth</a>(message);
|
|
<span class="keywordtype">int</span> fullScroll = msgWidth + width + 1;
|
|
<span class="keywordflow">for</span> (<span class="keywordtype">int</span> x = 0; x < fullScroll; ++x) {
|
|
display.<a class="code" href="classBitmap.html#a839dc8fab05a5ebf7a6b2e61436b2fa1" title="Clears the entire bitmap to the specified color.">clear</a>();
|
|
display.<a class="code" href="classBitmap.html#a3e9bcbfb584d5020bd6f0a313ee275f0" title="Draws the len characters of str at (x, y).">drawText</a>(width - x, 3, message);
|
|
delay(50);
|
|
}
|
|
}
|
|
</pre></div> </div></div>
|
|
<!-- window showing the filter options -->
|
|
<div id="MSearchSelectWindow"
|
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
|
onkeydown="return searchBox.OnSearchSelectKey(event)">
|
|
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark"> </span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark"> </span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark"> </span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark"> </span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark"> </span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark"> </span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark"> </span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark"> </span>Enumerator</a></div>
|
|
|
|
<!-- iframe showing the search results (closed by default) -->
|
|
<div id="MSearchResultsWindow">
|
|
<iframe src="javascript:void(0)" frameborder="0"
|
|
name="MSearchResults" id="MSearchResults">
|
|
</iframe>
|
|
</div>
|
|
|
|
<hr class="footer"/><address class="footer"><small>Generated on Wed May 30 2012 15:44:34 for ArduinoLibs by 
|
|
<a href="http://www.doxygen.org/index.html">
|
|
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </small></address>
|
|
</body>
|
|
</html>
|