初始化提交
This commit is contained in:
22
arduino-cli/libraries/Grove_LCD_RGB_Backlight/.gitattributes
vendored
Normal file
22
arduino-cli/libraries/Grove_LCD_RGB_Backlight/.gitattributes
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
# Auto detect text files and perform LF normalization
|
||||
* text=auto
|
||||
|
||||
# Custom for Visual Studio
|
||||
*.cs diff=csharp
|
||||
*.sln merge=union
|
||||
*.csproj merge=union
|
||||
*.vbproj merge=union
|
||||
*.fsproj merge=union
|
||||
*.dbproj merge=union
|
||||
|
||||
# Standard to msysgit
|
||||
*.doc diff=astextplain
|
||||
*.DOC diff=astextplain
|
||||
*.docx diff=astextplain
|
||||
*.DOCX diff=astextplain
|
||||
*.dot diff=astextplain
|
||||
*.DOT diff=astextplain
|
||||
*.pdf diff=astextplain
|
||||
*.PDF diff=astextplain
|
||||
*.rtf diff=astextplain
|
||||
*.RTF diff=astextplain
|
||||
215
arduino-cli/libraries/Grove_LCD_RGB_Backlight/.gitignore
vendored
Normal file
215
arduino-cli/libraries/Grove_LCD_RGB_Backlight/.gitignore
vendored
Normal file
@@ -0,0 +1,215 @@
|
||||
#################
|
||||
## Eclipse
|
||||
#################
|
||||
|
||||
*.pydevproject
|
||||
.project
|
||||
.metadata
|
||||
bin/
|
||||
tmp/
|
||||
*.tmp
|
||||
*.bak
|
||||
*.swp
|
||||
*~.nib
|
||||
local.properties
|
||||
.classpath
|
||||
.settings/
|
||||
.loadpath
|
||||
|
||||
# External tool builders
|
||||
.externalToolBuilders/
|
||||
|
||||
# Locally stored "Eclipse launch configurations"
|
||||
*.launch
|
||||
|
||||
# CDT-specific
|
||||
.cproject
|
||||
|
||||
# PDT-specific
|
||||
.buildpath
|
||||
|
||||
|
||||
#################
|
||||
## Visual Studio
|
||||
#################
|
||||
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
|
||||
# User-specific files
|
||||
*.suo
|
||||
*.user
|
||||
*.sln.docstates
|
||||
|
||||
# Build results
|
||||
|
||||
[Dd]ebug/
|
||||
[Rr]elease/
|
||||
x64/
|
||||
build/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
*_i.c
|
||||
*_p.c
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.log
|
||||
*.scc
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# NCrunch
|
||||
*.ncrunch*
|
||||
.*crunch*.local.xml
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.Publish.xml
|
||||
*.pubxml
|
||||
|
||||
# NuGet Packages Directory
|
||||
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
|
||||
#packages/
|
||||
|
||||
# Windows Azure Build Output
|
||||
csx
|
||||
*.build.csdef
|
||||
|
||||
# Windows Store app package directory
|
||||
AppPackages/
|
||||
|
||||
# Others
|
||||
sql/
|
||||
*.Cache
|
||||
ClientBin/
|
||||
[Ss]tyle[Cc]op.*
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.[Pp]ublish.xml
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file to a newer
|
||||
# Visual Studio version. Backup files are not needed, because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
|
||||
# SQL Server files
|
||||
App_Data/*.mdf
|
||||
App_Data/*.ldf
|
||||
|
||||
#############
|
||||
## Windows detritus
|
||||
#############
|
||||
|
||||
# Windows image file caches
|
||||
Thumbs.db
|
||||
ehthumbs.db
|
||||
|
||||
# Folder config file
|
||||
Desktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# Mac crap
|
||||
.DS_Store
|
||||
|
||||
|
||||
#############
|
||||
## Python
|
||||
#############
|
||||
|
||||
*.py[co]
|
||||
|
||||
# Packages
|
||||
*.egg
|
||||
*.egg-info
|
||||
dist/
|
||||
build/
|
||||
eggs/
|
||||
parts/
|
||||
var/
|
||||
sdist/
|
||||
develop-eggs/
|
||||
.installed.cfg
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
.coverage
|
||||
.tox
|
||||
|
||||
#Translations
|
||||
*.mo
|
||||
|
||||
#Mr Developer
|
||||
.mr.developer.cfg
|
||||
21
arduino-cli/libraries/Grove_LCD_RGB_Backlight/License.txt
Normal file
21
arduino-cli/libraries/Grove_LCD_RGB_Backlight/License.txt
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 Seeed Technology Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
83
arduino-cli/libraries/Grove_LCD_RGB_Backlight/README.md
Normal file
83
arduino-cli/libraries/Grove_LCD_RGB_Backlight/README.md
Normal file
@@ -0,0 +1,83 @@
|
||||
Grove - LCD RGB Backlight
|
||||
---------------------------------------------------------
|
||||
|
||||

|
||||
|
||||
|
||||
[Grove - LCD RGB Backlight](https://www.seeedstudio.com/Grove-LCD-RGB-Backlight-p-1643.html)
|
||||
|
||||
Done with the tedious mono color backlight? This Grove - LCD RBG Backlight enables you to set the color to whatever you like via the simple and concise Grove interface. It takes I2C as the communication method with your microcontroller. The number of pins required for data exchange and backlight control shrinks from ~10 to 2, relieving IOs for other challenging tasks. In addition, Grove - LCD RGB Backlight supports user-defined characters. Want to get a love heart or another custom character? Just take advantage of this feature and design it!
|
||||
|
||||
|
||||
## Usage:
|
||||
|
||||
This is an Arudino Library. It include a .h file, a .cpp file and some examples. Through these examples, you can quickly master the use of Grove - LCD RGB Backlight.
|
||||
|
||||
The in the following, we will introduce some functions which are used very intuitively.
|
||||
|
||||
|
||||
### Initialization
|
||||
Before we use this lcd, we should initialize it. You can use this function:
|
||||
|
||||
lcd.begin(16, 2);
|
||||
|
||||
This means that this lcd has 16 columns and 2 rows.
|
||||
|
||||
|
||||
### Change Color of Backlight
|
||||
One of Grove - LCD RGB Backlight's most important feature is changing the backlight color. It's very simple; just use the folowing function:
|
||||
|
||||
void setRGB(int r, int g, int b);
|
||||
|
||||
|
||||
### Clear Display
|
||||
|
||||
You can clear the display by this function:
|
||||
|
||||
void clear();
|
||||
|
||||
### Turn on and turn off display
|
||||
|
||||
void noDisplay(); // turn off display
|
||||
void display(); // turn on display
|
||||
|
||||
### Blink
|
||||
|
||||
void noBlink();
|
||||
void blink();
|
||||
|
||||
### Cursor
|
||||
|
||||
void noCursor();
|
||||
void cursor();
|
||||
|
||||
### Blink LED Backlight
|
||||
|
||||
void noBlinkLED();
|
||||
void blinkLED();
|
||||
|
||||
|
||||
For more information, please refer to [wiki page](http://wiki.seeedstudio.com/Grove-LCD_RGB_Backlight/).
|
||||
|
||||
|
||||
----
|
||||
|
||||
This software is written by loovee([luweicong@seeedstudio.com](luweicong@seeedstudio.com "luweicong@seeedstudio.com")) for seeed studio<br>
|
||||
and is licensed under [The MIT License](http://opensource.org/licenses/mit-license.php). Check License.txt for more information.<br>
|
||||
|
||||
Contributing to this software is warmly welcomed. You can do this basically by<br>
|
||||
[forking](https://help.github.com/articles/fork-a-repo), committing modifications and then [pulling requests](https://help.github.com/articles/using-pull-requests) (follow the links above<br>
|
||||
for operating guide). Adding change log and your contact into file header is encouraged.<br>
|
||||
Thanks for your contribution.
|
||||
|
||||
Seeed Studio is an open hardware facilitation company based in Shenzhen, China. <br>
|
||||
Benefiting from local manufacture power and convenient global logistic system, <br>
|
||||
we integrate resources to serve new era of innovation. Seeed also works with <br>
|
||||
global distributors and partners to push open hardware movement.<br>
|
||||
|
||||
|
||||
|
||||
[](https://github.com/igrigorik/ga-beacon)
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
Autoscroll.ino
|
||||
2013 Copyright (c) Seeed Technology Inc. All right reserved.
|
||||
|
||||
Author:Loovee
|
||||
2013-9-18
|
||||
|
||||
Grove - Serial LCD RGB Backlight demo.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <Wire.h>
|
||||
#include "rgb_lcd.h"
|
||||
|
||||
rgb_lcd lcd;
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
// set up the LCD's number of columns and rows:
|
||||
lcd.begin(16, 2);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// set the cursor to (0,0):
|
||||
lcd.setCursor(0, 0);
|
||||
// print from 0 to 9:
|
||||
for (int thisChar = 0; thisChar < 10; thisChar++)
|
||||
{
|
||||
lcd.print(thisChar);
|
||||
delay(500);
|
||||
}
|
||||
|
||||
// set the cursor to (16,1):
|
||||
lcd.setCursor(16,1);
|
||||
// set the display to automatically scroll:
|
||||
lcd.autoscroll();
|
||||
// print from 0 to 9:
|
||||
for (int thisChar = 0; thisChar < 10; thisChar++)
|
||||
{
|
||||
lcd.print(thisChar);
|
||||
delay(500);
|
||||
}
|
||||
// turn off automatic scrolling
|
||||
lcd.noAutoscroll();
|
||||
|
||||
// clear screen for the next loop:
|
||||
lcd.clear();
|
||||
}
|
||||
|
||||
/*********************************************************************************************************
|
||||
END FILE
|
||||
*********************************************************************************************************/
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
Blink.ino
|
||||
2013 Copyright (c) Seeed Technology Inc. All right reserved.
|
||||
|
||||
Author:Loovee
|
||||
2013-9-18
|
||||
|
||||
Grove - Serial LCD RGB Backlight demo.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <Wire.h>
|
||||
#include "rgb_lcd.h"
|
||||
|
||||
rgb_lcd lcd;
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
// set up the LCD's number of columns and rows:
|
||||
lcd.begin(16, 2);
|
||||
|
||||
// Print a message to the LCD.
|
||||
lcd.print("hello, world!");
|
||||
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// Turn off the blinking cursor:
|
||||
lcd.noBlink();
|
||||
delay(3000);
|
||||
// Turn on the blinking cursor:
|
||||
lcd.blink();
|
||||
delay(3000);
|
||||
}
|
||||
|
||||
/*********************************************************************************************************
|
||||
END FILE
|
||||
*********************************************************************************************************/
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
Cursor.ino
|
||||
2013 Copyright (c) Seeed Technology Inc. All right reserved.
|
||||
|
||||
Author:Loovee
|
||||
2013-9-18
|
||||
|
||||
Grove - Serial LCD RGB Backlight demo.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <Wire.h>
|
||||
#include "rgb_lcd.h"
|
||||
|
||||
rgb_lcd lcd;
|
||||
|
||||
void setup()
|
||||
{
|
||||
// set up the LCD's number of columns and rows:
|
||||
lcd.begin(16, 2);
|
||||
// Print a message to the LCD.
|
||||
lcd.print("hello, world!");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// Turn off the cursor:
|
||||
lcd.noCursor();
|
||||
delay(500);
|
||||
// Turn on the cursor:
|
||||
lcd.cursor();
|
||||
delay(500);
|
||||
}
|
||||
|
||||
/*********************************************************************************************************
|
||||
END FILE
|
||||
*********************************************************************************************************/
|
||||
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
CustomCharacter.ino
|
||||
2013 Copyright (c) Seeed Technology Inc. All right reserved.
|
||||
|
||||
Author:Loovee
|
||||
2013-9-18
|
||||
|
||||
Grove - Serial LCD RGB Backlight demo.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <Wire.h>
|
||||
#include "rgb_lcd.h"
|
||||
|
||||
rgb_lcd lcd;
|
||||
|
||||
// make some custom characters:
|
||||
byte heart[8] = {
|
||||
0b00000,
|
||||
0b01010,
|
||||
0b11111,
|
||||
0b11111,
|
||||
0b11111,
|
||||
0b01110,
|
||||
0b00100,
|
||||
0b00000
|
||||
};
|
||||
|
||||
byte smiley[8] = {
|
||||
0b00000,
|
||||
0b00000,
|
||||
0b01010,
|
||||
0b00000,
|
||||
0b00000,
|
||||
0b10001,
|
||||
0b01110,
|
||||
0b00000
|
||||
};
|
||||
|
||||
byte frownie[8] = {
|
||||
0b00000,
|
||||
0b00000,
|
||||
0b01010,
|
||||
0b00000,
|
||||
0b00000,
|
||||
0b00000,
|
||||
0b01110,
|
||||
0b10001
|
||||
};
|
||||
|
||||
byte armsDown[8] = {
|
||||
0b00100,
|
||||
0b01010,
|
||||
0b00100,
|
||||
0b00100,
|
||||
0b01110,
|
||||
0b10101,
|
||||
0b00100,
|
||||
0b01010
|
||||
};
|
||||
|
||||
byte armsUp[8] = {
|
||||
0b00100,
|
||||
0b01010,
|
||||
0b00100,
|
||||
0b10101,
|
||||
0b01110,
|
||||
0b00100,
|
||||
0b00100,
|
||||
0b01010
|
||||
};
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
|
||||
lcd.begin(16, 2);
|
||||
#if 1
|
||||
// create a new character
|
||||
lcd.createChar(0, heart);
|
||||
// create a new character
|
||||
lcd.createChar(1, smiley);
|
||||
// create a new character
|
||||
lcd.createChar(2, frownie);
|
||||
// create a new character
|
||||
lcd.createChar(3, armsDown);
|
||||
// create a new character
|
||||
lcd.createChar(4, armsUp);
|
||||
#endif
|
||||
// set up the lcd's number of columns and rows:
|
||||
|
||||
|
||||
lcd.setCursor(0, 0);
|
||||
// Print a message to the lcd.
|
||||
lcd.print("I ");
|
||||
lcd.write((unsigned char)0);
|
||||
lcd.print(" Arduino! ");
|
||||
lcd.write(1);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// read the potentiometer on A0:
|
||||
int sensorReading = analogRead(A0);
|
||||
// map the result to 200 - 1000:
|
||||
int delayTime = map(sensorReading, 0, 1023, 200, 1000);
|
||||
// set the cursor to the bottom row, 5th position:
|
||||
lcd.setCursor(4, 1);
|
||||
// draw the little man, arms down:
|
||||
lcd.write(3);
|
||||
delay(delayTime);
|
||||
lcd.setCursor(4, 1);
|
||||
// draw him arms up:
|
||||
lcd.write(4);
|
||||
delay(delayTime);
|
||||
}
|
||||
|
||||
/*********************************************************************************************************
|
||||
END FILE
|
||||
*********************************************************************************************************/
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
Display.ino
|
||||
2013 Copyright (c) Seeed Technology Inc. All right reserved.
|
||||
|
||||
Author:Loovee
|
||||
2013-9-18
|
||||
|
||||
Grove - Serial LCD RGB Backlight demo.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <Wire.h>
|
||||
#include "rgb_lcd.h"
|
||||
|
||||
rgb_lcd lcd;
|
||||
|
||||
void setup() {
|
||||
// set up the LCD's number of columns and rows:
|
||||
lcd.begin(16, 2);
|
||||
// Print a message to the LCD.
|
||||
lcd.print("hello, world!");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// Turn off the display:
|
||||
lcd.noDisplay();
|
||||
delay(500);
|
||||
// Turn on the display:
|
||||
lcd.display();
|
||||
delay(500);
|
||||
}
|
||||
|
||||
/*********************************************************************************************************
|
||||
END FILE
|
||||
*********************************************************************************************************/
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
Hello World.ino
|
||||
2013 Copyright (c) Seeed Technology Inc. All right reserved.
|
||||
|
||||
Author:Loovee
|
||||
2013-9-18
|
||||
|
||||
Grove - Serial LCD RGB Backlight demo.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <Wire.h>
|
||||
#include "rgb_lcd.h"
|
||||
|
||||
rgb_lcd lcd;
|
||||
|
||||
const int colorR = 255;
|
||||
const int colorG = 0;
|
||||
const int colorB = 0;
|
||||
|
||||
void setup()
|
||||
{
|
||||
// set up the LCD's number of columns and rows:
|
||||
lcd.begin(16, 2);
|
||||
|
||||
lcd.setRGB(colorR, colorG, colorB);
|
||||
|
||||
// Print a message to the LCD.
|
||||
lcd.print("hello, world!");
|
||||
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// set the cursor to column 0, line 1
|
||||
// (note: line 1 is the second row, since counting begins with 0):
|
||||
lcd.setCursor(0, 1);
|
||||
// print the number of seconds since reset:
|
||||
lcd.print(millis()/1000);
|
||||
|
||||
delay(100);
|
||||
}
|
||||
|
||||
/*********************************************************************************************************
|
||||
END FILE
|
||||
*********************************************************************************************************/
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
Hello World.ino
|
||||
2013 Copyright (c) Seeed Technology Inc. All right reserved.
|
||||
|
||||
Author:Loovee
|
||||
2013-9-18
|
||||
|
||||
Grove - Serial LCD RGB Backlight demo.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <Wire.h>
|
||||
#include "rgb_lcd.h"
|
||||
|
||||
rgb_lcd lcd;
|
||||
|
||||
void setup() {
|
||||
// set up the LCD's number of columns and rows:
|
||||
lcd.begin(16, 2);
|
||||
// Print a message to the LCD.
|
||||
lcd.print("hello, world!");
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// scroll 13 positions (string length) to the left
|
||||
// to move it offscreen left:
|
||||
for (int positionCounter = 0; positionCounter < 13; positionCounter++) {
|
||||
// scroll one position left:
|
||||
lcd.scrollDisplayLeft();
|
||||
// wait a bit:
|
||||
delay(150);
|
||||
}
|
||||
|
||||
// scroll 29 positions (string length + display length) to the right
|
||||
// to move it offscreen right:
|
||||
for (int positionCounter = 0; positionCounter < 29; positionCounter++) {
|
||||
// scroll one position right:
|
||||
lcd.scrollDisplayRight();
|
||||
// wait a bit:
|
||||
delay(150);
|
||||
}
|
||||
|
||||
// scroll 16 positions (display length + string length) to the left
|
||||
// to move it back to center:
|
||||
for (int positionCounter = 0; positionCounter < 16; positionCounter++) {
|
||||
// scroll one position left:
|
||||
lcd.scrollDisplayLeft();
|
||||
// wait a bit:
|
||||
delay(150);
|
||||
}
|
||||
|
||||
// delay at the end of the full loop:
|
||||
delay(1000);
|
||||
|
||||
}
|
||||
|
||||
/*********************************************************************************************************
|
||||
END FILE
|
||||
*********************************************************************************************************/
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
SerialDisplay.ino
|
||||
2013 Copyright (c) Seeed Technology Inc. All right reserved.
|
||||
|
||||
Author:Loovee
|
||||
2013-9-18
|
||||
|
||||
Grove - Serial LCD RGB Backlight demo.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <Wire.h>
|
||||
#include "rgb_lcd.h"
|
||||
|
||||
rgb_lcd lcd;
|
||||
|
||||
void setup(){
|
||||
// set up the LCD's number of columns and rows:
|
||||
lcd.begin(16, 2);
|
||||
// initialize the serial communications:
|
||||
Serial.begin(9600);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// when characters arrive over the serial port...
|
||||
if (Serial.available())
|
||||
{
|
||||
// wait a bit for the entire message to arrive
|
||||
delay(100);
|
||||
// clear the screen
|
||||
lcd.clear();
|
||||
// read all the available characters
|
||||
while (Serial.available() > 0)
|
||||
{
|
||||
// display each character to the LCD
|
||||
lcd.write(Serial.read());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************************************************
|
||||
END FILE
|
||||
*********************************************************************************************************/
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
TextDirection.ino
|
||||
2013 Copyright (c) Seeed Technology Inc. All right reserved.
|
||||
|
||||
Author:Loovee
|
||||
2013-9-18
|
||||
|
||||
Grove - Serial LCD RGB Backlight demo.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <Wire.h>
|
||||
#include "rgb_lcd.h"
|
||||
|
||||
rgb_lcd lcd;
|
||||
|
||||
int thisChar = 'a';
|
||||
|
||||
void setup()
|
||||
{
|
||||
// set up the LCD's number of columns and rows:
|
||||
lcd.begin(16, 2);
|
||||
// turn on the cursor:
|
||||
lcd.cursor();
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// reverse directions at 'm':
|
||||
if (thisChar == 'm')
|
||||
{
|
||||
// go right for the next letter
|
||||
lcd.rightToLeft();
|
||||
}
|
||||
// reverse again at 's':
|
||||
if (thisChar == 's')
|
||||
{
|
||||
// go left for the next letter
|
||||
lcd.leftToRight();
|
||||
}
|
||||
// reset at 'z':
|
||||
if (thisChar > 'z')
|
||||
{
|
||||
// go to (0,0):
|
||||
lcd.home();
|
||||
// start again at 0
|
||||
thisChar = 'a';
|
||||
}
|
||||
// print the character
|
||||
lcd.write(thisChar);
|
||||
// wait a second:
|
||||
delay(1000);
|
||||
// increment the letter:
|
||||
thisChar++;
|
||||
}
|
||||
|
||||
/*********************************************************************************************************
|
||||
END FILE
|
||||
*********************************************************************************************************/
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
fade.ino
|
||||
2013 Copyright (c) Seeed Technology Inc. All right reserved.
|
||||
|
||||
Author:Loovee
|
||||
2013-10-15
|
||||
|
||||
Grove - Serial LCD RGB Backlight demo.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <Wire.h>
|
||||
#include "rgb_lcd.h"
|
||||
|
||||
rgb_lcd lcd;
|
||||
|
||||
void setup()
|
||||
{
|
||||
// set up the LCD's number of columns and rows:
|
||||
lcd.begin(16, 2);
|
||||
// Print a message to the LCD.
|
||||
lcd.print("fade demo");
|
||||
|
||||
}
|
||||
|
||||
void breath(unsigned char color)
|
||||
{
|
||||
|
||||
for(int i=0; i<255; i++)
|
||||
{
|
||||
lcd.setPWM(color, i);
|
||||
delay(5);
|
||||
}
|
||||
|
||||
delay(500);
|
||||
for(int i=254; i>=0; i--)
|
||||
{
|
||||
lcd.setPWM(color, i);
|
||||
delay(5);
|
||||
}
|
||||
|
||||
delay(500);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
breath(REG_RED);
|
||||
breath(REG_GREEN);
|
||||
breath(REG_BLUE);
|
||||
}
|
||||
|
||||
/*********************************************************************************************************
|
||||
END FILE
|
||||
*********************************************************************************************************/
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
setColor.ino
|
||||
2013 Copyright (c) Seeed Technology Inc. All right reserved.
|
||||
|
||||
Author:Loovee
|
||||
2013-10-15
|
||||
|
||||
Grove - Serial LCD RGB Backlight demo.
|
||||
you can set color by serial input, input "rrr ggg bbb"
|
||||
|
||||
rrr means red, 0-255, eg: 005, 015, 135
|
||||
ggg means green
|
||||
bbb means blue
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <Wire.h>
|
||||
#include "rgb_lcd.h"
|
||||
|
||||
rgb_lcd lcd;
|
||||
|
||||
char dtaUart[15];
|
||||
char dtaLen = 0;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
// set up the LCD's number of columns and rows:
|
||||
lcd.begin(16, 2);
|
||||
// Print a message to the LCD.
|
||||
lcd.print("set cllor");
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
if(dtaLen == 11)
|
||||
{
|
||||
int r = (dtaUart[0]-'0')*100 + (dtaUart[1] - '0')*10 + (dtaUart[2] - '0'); // get r
|
||||
int g = (dtaUart[4]-'0')*100 + (dtaUart[5] - '0')*10 + (dtaUart[6] - '0');
|
||||
int b = (dtaUart[8]-'0')*100 + (dtaUart[9] - '0')*10 + (dtaUart[10] - '0');
|
||||
|
||||
dtaLen = 0;
|
||||
|
||||
lcd.setRGB(r, g, b);
|
||||
|
||||
Serial.println("get data");
|
||||
|
||||
Serial.println(r);
|
||||
Serial.println(g);
|
||||
Serial.println(b);
|
||||
Serial.println();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void serialEvent()
|
||||
{
|
||||
while(Serial.available())
|
||||
{
|
||||
dtaUart[dtaLen++] = Serial.read();
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************************************************
|
||||
END FILE
|
||||
*********************************************************************************************************/
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
SerialDisplay.ino
|
||||
2013 Copyright (c) Seeed Technology Inc. All right reserved.
|
||||
|
||||
Author:Loovee
|
||||
2013-9-18
|
||||
|
||||
Grove - Serial LCD RGB Backlight demo.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <Wire.h>
|
||||
#include "rgb_lcd.h"
|
||||
|
||||
rgb_lcd lcd;
|
||||
|
||||
const int numRows = 2;
|
||||
const int numCols = 16;
|
||||
|
||||
void setup()
|
||||
{
|
||||
// set up the LCD's number of columns and rows:
|
||||
lcd.begin(numCols,numRows);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// loop from ASCII 'a' to ASCII 'z':
|
||||
for (int thisLetter = 'a'; thisLetter <= 'z'; thisLetter++) {
|
||||
// loop over the columns:
|
||||
for (int thisCol = 0; thisCol < numRows; thisCol++) {
|
||||
// loop over the rows:
|
||||
for (int thisRow = 0; thisRow < numCols; thisRow++) {
|
||||
// set the cursor position:
|
||||
lcd.setCursor(thisRow,thisCol);
|
||||
// print the letter:
|
||||
lcd.write(thisLetter);
|
||||
delay(200);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************************************************
|
||||
END FILE
|
||||
*********************************************************************************************************/
|
||||
40
arduino-cli/libraries/Grove_LCD_RGB_Backlight/keywords.txt
Normal file
40
arduino-cli/libraries/Grove_LCD_RGB_Backlight/keywords.txt
Normal file
@@ -0,0 +1,40 @@
|
||||
#######################################
|
||||
# Syntax Coloring Map For Grove - Serial LCD GRB BackLight
|
||||
#######################################
|
||||
|
||||
#######################################
|
||||
# Datatypes (KEYWORD1)
|
||||
#######################################
|
||||
rgb_lcd KEYWORD1
|
||||
lcd KEYWORD1
|
||||
|
||||
#######################################
|
||||
# Methods and Functions (KEYWORD2)
|
||||
#######################################
|
||||
begin KEYWORD2
|
||||
clear KEYWORD2
|
||||
home KEYWORD2
|
||||
display KEYWORD2
|
||||
noBlink KEYWORD2
|
||||
blink KEYWORD2
|
||||
noCursor KEYWORD2
|
||||
cursor KEYWORD2
|
||||
scrollDisplayLeft KEYWORD2
|
||||
scrollDisplayRight KEYWORD2
|
||||
leftToRight KEYWORD2
|
||||
rightToLeft KEYWORD2
|
||||
autoscroll KEYWORD2
|
||||
noAutoscroll KEYWORD2
|
||||
createChar KEYWORD2
|
||||
write KEYWORD2
|
||||
command KEYWORD2
|
||||
setRGB KEYWORD2
|
||||
setPWM KEYWORD2
|
||||
setColor KEYWORD2
|
||||
setColorWhite KEYWORD2
|
||||
|
||||
|
||||
#######################################
|
||||
# Constants (LITERAL1)
|
||||
#######################################
|
||||
I2C_ADDRESS LITERAL1
|
||||
@@ -0,0 +1,9 @@
|
||||
name=Grove - LCD RGB Backlight
|
||||
version=1.0.0
|
||||
author=Seeed Studio
|
||||
maintainer=Seeed Studio <techsupport@seeed.cc>
|
||||
sentence=Arduino library to control Grove - LCD RGB Backlight.
|
||||
paragraph=Arduino library to control Grove - LCD RGB Backlight.
|
||||
category=Display
|
||||
url=https://github.com/Seeed-Studio/Grove_LCD_RGB_Backlight
|
||||
architectures=*
|
||||
300
arduino-cli/libraries/Grove_LCD_RGB_Backlight/rgb_lcd.cpp
Normal file
300
arduino-cli/libraries/Grove_LCD_RGB_Backlight/rgb_lcd.cpp
Normal file
@@ -0,0 +1,300 @@
|
||||
/*
|
||||
rgb_lcd.cpp
|
||||
2013 Copyright (c) Seeed Technology Inc. All right reserved.
|
||||
|
||||
Author:Loovee
|
||||
2013-9-18
|
||||
|
||||
add rgb backlight fucnction @ 2013-10-15
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.1 USA
|
||||
*/
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
#include <Wire.h>
|
||||
|
||||
#include "rgb_lcd.h"
|
||||
|
||||
void i2c_send_byte(unsigned char dta)
|
||||
{
|
||||
Wire.beginTransmission(LCD_ADDRESS); // transmit to device #4
|
||||
Wire.write(dta); // sends five bytes
|
||||
Wire.endTransmission(); // stop transmitting
|
||||
}
|
||||
|
||||
void i2c_send_byteS(unsigned char *dta, unsigned char len)
|
||||
{
|
||||
Wire.beginTransmission(LCD_ADDRESS); // transmit to device #4
|
||||
for(int i=0; i<len; i++)
|
||||
{
|
||||
Wire.write(dta[i]);
|
||||
}
|
||||
Wire.endTransmission(); // stop transmitting
|
||||
}
|
||||
|
||||
rgb_lcd::rgb_lcd()
|
||||
{
|
||||
}
|
||||
|
||||
void rgb_lcd::begin(uint8_t cols, uint8_t lines, uint8_t dotsize)
|
||||
{
|
||||
|
||||
Wire.begin();
|
||||
|
||||
if (lines > 1) {
|
||||
_displayfunction |= LCD_2LINE;
|
||||
}
|
||||
_numlines = lines;
|
||||
_currline = 0;
|
||||
|
||||
// for some 1 line displays you can select a 10 pixel high font
|
||||
if ((dotsize != 0) && (lines == 1)) {
|
||||
_displayfunction |= LCD_5x10DOTS;
|
||||
}
|
||||
|
||||
// SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION!
|
||||
// according to datasheet, we need at least 40ms after power rises above 2.7V
|
||||
// before sending commands. Arduino can turn on way befer 4.5V so we'll wait 50
|
||||
delayMicroseconds(50000);
|
||||
|
||||
|
||||
// this is according to the hitachi HD44780 datasheet
|
||||
// page 45 figure 23
|
||||
|
||||
// Send function set command sequence
|
||||
command(LCD_FUNCTIONSET | _displayfunction);
|
||||
delayMicroseconds(4500); // wait more than 4.1ms
|
||||
|
||||
// second try
|
||||
command(LCD_FUNCTIONSET | _displayfunction);
|
||||
delayMicroseconds(150);
|
||||
|
||||
// third go
|
||||
command(LCD_FUNCTIONSET | _displayfunction);
|
||||
|
||||
|
||||
// finally, set # lines, font size, etc.
|
||||
command(LCD_FUNCTIONSET | _displayfunction);
|
||||
|
||||
// turn the display on with no cursor or blinking default
|
||||
_displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF;
|
||||
display();
|
||||
|
||||
// clear it off
|
||||
clear();
|
||||
|
||||
// Initialize to default text direction (for romance languages)
|
||||
_displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT;
|
||||
// set the entry mode
|
||||
command(LCD_ENTRYMODESET | _displaymode);
|
||||
|
||||
|
||||
// backlight init
|
||||
setReg(REG_MODE1, 0);
|
||||
// set LEDs controllable by both PWM and GRPPWM registers
|
||||
setReg(REG_OUTPUT, 0xFF);
|
||||
// set MODE2 values
|
||||
// 0010 0000 -> 0x20 (DMBLNK to 1, ie blinky mode)
|
||||
setReg(REG_MODE2, 0x20);
|
||||
|
||||
setColorWhite();
|
||||
|
||||
}
|
||||
|
||||
/********** high level commands, for the user! */
|
||||
void rgb_lcd::clear()
|
||||
{
|
||||
command(LCD_CLEARDISPLAY); // clear display, set cursor position to zero
|
||||
delayMicroseconds(2000); // this command takes a long time!
|
||||
}
|
||||
|
||||
void rgb_lcd::home()
|
||||
{
|
||||
command(LCD_RETURNHOME); // set cursor position to zero
|
||||
delayMicroseconds(2000); // this command takes a long time!
|
||||
}
|
||||
|
||||
void rgb_lcd::setCursor(uint8_t col, uint8_t row)
|
||||
{
|
||||
|
||||
col = (row == 0 ? col|0x80 : col|0xc0);
|
||||
unsigned char dta[2] = {0x80, col};
|
||||
|
||||
i2c_send_byteS(dta, 2);
|
||||
|
||||
}
|
||||
|
||||
// Turn the display on/off (quickly)
|
||||
void rgb_lcd::noDisplay()
|
||||
{
|
||||
_displaycontrol &= ~LCD_DISPLAYON;
|
||||
command(LCD_DISPLAYCONTROL | _displaycontrol);
|
||||
}
|
||||
|
||||
void rgb_lcd::display() {
|
||||
_displaycontrol |= LCD_DISPLAYON;
|
||||
command(LCD_DISPLAYCONTROL | _displaycontrol);
|
||||
}
|
||||
|
||||
// Turns the underline cursor on/off
|
||||
void rgb_lcd::noCursor()
|
||||
{
|
||||
_displaycontrol &= ~LCD_CURSORON;
|
||||
command(LCD_DISPLAYCONTROL | _displaycontrol);
|
||||
}
|
||||
|
||||
void rgb_lcd::cursor() {
|
||||
_displaycontrol |= LCD_CURSORON;
|
||||
command(LCD_DISPLAYCONTROL | _displaycontrol);
|
||||
}
|
||||
|
||||
// Turn on and off the blinking cursor
|
||||
void rgb_lcd::noBlink()
|
||||
{
|
||||
_displaycontrol &= ~LCD_BLINKON;
|
||||
command(LCD_DISPLAYCONTROL | _displaycontrol);
|
||||
}
|
||||
void rgb_lcd::blink()
|
||||
{
|
||||
_displaycontrol |= LCD_BLINKON;
|
||||
command(LCD_DISPLAYCONTROL | _displaycontrol);
|
||||
}
|
||||
|
||||
// These commands scroll the display without changing the RAM
|
||||
void rgb_lcd::scrollDisplayLeft(void)
|
||||
{
|
||||
command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVELEFT);
|
||||
}
|
||||
void rgb_lcd::scrollDisplayRight(void)
|
||||
{
|
||||
command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVERIGHT);
|
||||
}
|
||||
|
||||
// This is for text that flows Left to Right
|
||||
void rgb_lcd::leftToRight(void)
|
||||
{
|
||||
_displaymode |= LCD_ENTRYLEFT;
|
||||
command(LCD_ENTRYMODESET | _displaymode);
|
||||
}
|
||||
|
||||
// This is for text that flows Right to Left
|
||||
void rgb_lcd::rightToLeft(void)
|
||||
{
|
||||
_displaymode &= ~LCD_ENTRYLEFT;
|
||||
command(LCD_ENTRYMODESET | _displaymode);
|
||||
}
|
||||
|
||||
// This will 'right justify' text from the cursor
|
||||
void rgb_lcd::autoscroll(void)
|
||||
{
|
||||
_displaymode |= LCD_ENTRYSHIFTINCREMENT;
|
||||
command(LCD_ENTRYMODESET | _displaymode);
|
||||
}
|
||||
|
||||
// This will 'left justify' text from the cursor
|
||||
void rgb_lcd::noAutoscroll(void)
|
||||
{
|
||||
_displaymode &= ~LCD_ENTRYSHIFTINCREMENT;
|
||||
command(LCD_ENTRYMODESET | _displaymode);
|
||||
}
|
||||
|
||||
// Allows us to fill the first 8 CGRAM locations
|
||||
// with custom characters
|
||||
void rgb_lcd::createChar(uint8_t location, uint8_t charmap[])
|
||||
{
|
||||
|
||||
location &= 0x7; // we only have 8 locations 0-7
|
||||
command(LCD_SETCGRAMADDR | (location << 3));
|
||||
|
||||
|
||||
unsigned char dta[9];
|
||||
dta[0] = 0x40;
|
||||
for(int i=0; i<8; i++)
|
||||
{
|
||||
dta[i+1] = charmap[i];
|
||||
}
|
||||
i2c_send_byteS(dta, 9);
|
||||
}
|
||||
|
||||
// Control the backlight LED blinking
|
||||
void rgb_lcd::blinkLED(void)
|
||||
{
|
||||
// blink period in seconds = (<reg 7> + 1) / 24
|
||||
// on/off ratio = <reg 6> / 256
|
||||
setReg(0x07, 0x17); // blink every second
|
||||
setReg(0x06, 0x7f); // half on, half off
|
||||
}
|
||||
|
||||
void rgb_lcd::noBlinkLED(void)
|
||||
{
|
||||
setReg(0x07, 0x00);
|
||||
setReg(0x06, 0xff);
|
||||
}
|
||||
|
||||
/*********** mid level commands, for sending data/cmds */
|
||||
|
||||
// send command
|
||||
inline void rgb_lcd::command(uint8_t value)
|
||||
{
|
||||
unsigned char dta[2] = {0x80, value};
|
||||
i2c_send_byteS(dta, 2);
|
||||
}
|
||||
|
||||
// send data
|
||||
inline size_t rgb_lcd::write(uint8_t value)
|
||||
{
|
||||
|
||||
unsigned char dta[2] = {0x40, value};
|
||||
i2c_send_byteS(dta, 2);
|
||||
return 1; // assume sucess
|
||||
}
|
||||
|
||||
void rgb_lcd::setReg(unsigned char addr, unsigned char dta)
|
||||
{
|
||||
Wire.beginTransmission(RGB_ADDRESS); // transmit to device #4
|
||||
Wire.write(addr);
|
||||
Wire.write(dta);
|
||||
Wire.endTransmission(); // stop transmitting
|
||||
}
|
||||
|
||||
void rgb_lcd::setRGB(unsigned char r, unsigned char g, unsigned char b)
|
||||
{
|
||||
setReg(REG_RED, r);
|
||||
setReg(REG_GREEN, g);
|
||||
setReg(REG_BLUE, b);
|
||||
}
|
||||
|
||||
const unsigned char color_define[4][3] =
|
||||
{
|
||||
{255, 255, 255}, // white
|
||||
{255, 0, 0}, // red
|
||||
{0, 255, 0}, // green
|
||||
{0, 0, 255}, // blue
|
||||
};
|
||||
|
||||
void rgb_lcd::setColor(unsigned char color)
|
||||
{
|
||||
if(color > 3)return ;
|
||||
setRGB(color_define[color][0], color_define[color][1], color_define[color][2]);
|
||||
}
|
||||
152
arduino-cli/libraries/Grove_LCD_RGB_Backlight/rgb_lcd.h
Normal file
152
arduino-cli/libraries/Grove_LCD_RGB_Backlight/rgb_lcd.h
Normal file
@@ -0,0 +1,152 @@
|
||||
/*
|
||||
rgb_lcd.h
|
||||
2013 Copyright (c) Seeed Technology Inc. All right reserved.
|
||||
|
||||
Author:Loovee
|
||||
2013-9-18
|
||||
|
||||
add rgb backlight fucnction @ 2013-10-15
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.1 USA
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __RGB_LCD_H__
|
||||
#define __RGB_LCD_H__
|
||||
|
||||
#include <inttypes.h>
|
||||
#include "Print.h"
|
||||
|
||||
// Device I2C Arress
|
||||
#define LCD_ADDRESS (0x7c>>1)
|
||||
#define RGB_ADDRESS (0xc4>>1)
|
||||
|
||||
|
||||
// color define
|
||||
#define WHITE 0
|
||||
#define RED 1
|
||||
#define GREEN 2
|
||||
#define BLUE 3
|
||||
|
||||
#define REG_RED 0x04 // pwm2
|
||||
#define REG_GREEN 0x03 // pwm1
|
||||
#define REG_BLUE 0x02 // pwm0
|
||||
|
||||
#define REG_MODE1 0x00
|
||||
#define REG_MODE2 0x01
|
||||
#define REG_OUTPUT 0x08
|
||||
|
||||
// commands
|
||||
#define LCD_CLEARDISPLAY 0x01
|
||||
#define LCD_RETURNHOME 0x02
|
||||
#define LCD_ENTRYMODESET 0x04
|
||||
#define LCD_DISPLAYCONTROL 0x08
|
||||
#define LCD_CURSORSHIFT 0x10
|
||||
#define LCD_FUNCTIONSET 0x20
|
||||
#define LCD_SETCGRAMADDR 0x40
|
||||
#define LCD_SETDDRAMADDR 0x80
|
||||
|
||||
// flags for display entry mode
|
||||
#define LCD_ENTRYRIGHT 0x00
|
||||
#define LCD_ENTRYLEFT 0x02
|
||||
#define LCD_ENTRYSHIFTINCREMENT 0x01
|
||||
#define LCD_ENTRYSHIFTDECREMENT 0x00
|
||||
|
||||
// flags for display on/off control
|
||||
#define LCD_DISPLAYON 0x04
|
||||
#define LCD_DISPLAYOFF 0x00
|
||||
#define LCD_CURSORON 0x02
|
||||
#define LCD_CURSOROFF 0x00
|
||||
#define LCD_BLINKON 0x01
|
||||
#define LCD_BLINKOFF 0x00
|
||||
|
||||
// flags for display/cursor shift
|
||||
#define LCD_DISPLAYMOVE 0x08
|
||||
#define LCD_CURSORMOVE 0x00
|
||||
#define LCD_MOVERIGHT 0x04
|
||||
#define LCD_MOVELEFT 0x00
|
||||
|
||||
// flags for function set
|
||||
#define LCD_8BITMODE 0x10
|
||||
#define LCD_4BITMODE 0x00
|
||||
#define LCD_2LINE 0x08
|
||||
#define LCD_1LINE 0x00
|
||||
#define LCD_5x10DOTS 0x04
|
||||
#define LCD_5x8DOTS 0x00
|
||||
|
||||
class rgb_lcd : public Print
|
||||
{
|
||||
|
||||
public:
|
||||
rgb_lcd();
|
||||
|
||||
void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS);
|
||||
|
||||
void clear();
|
||||
void home();
|
||||
|
||||
void noDisplay();
|
||||
void display();
|
||||
void noBlink();
|
||||
void blink();
|
||||
void noCursor();
|
||||
void cursor();
|
||||
void scrollDisplayLeft();
|
||||
void scrollDisplayRight();
|
||||
void leftToRight();
|
||||
void rightToLeft();
|
||||
void autoscroll();
|
||||
void noAutoscroll();
|
||||
|
||||
void createChar(uint8_t, uint8_t[]);
|
||||
void setCursor(uint8_t, uint8_t);
|
||||
|
||||
virtual size_t write(uint8_t);
|
||||
void command(uint8_t);
|
||||
|
||||
// color control
|
||||
void setRGB(unsigned char r, unsigned char g, unsigned char b); // set rgb
|
||||
void setPWM(unsigned char color, unsigned char pwm){setReg(color, pwm);} // set pwm
|
||||
|
||||
void setColor(unsigned char color);
|
||||
void setColorAll(){setRGB(0, 0, 0);}
|
||||
void setColorWhite(){setRGB(255, 255, 255);}
|
||||
|
||||
// blink the LED backlight
|
||||
void blinkLED(void);
|
||||
void noBlinkLED(void);
|
||||
|
||||
using Print::write;
|
||||
|
||||
private:
|
||||
void send(uint8_t, uint8_t);
|
||||
void setReg(unsigned char addr, unsigned char dta);
|
||||
|
||||
uint8_t _displayfunction;
|
||||
uint8_t _displaycontrol;
|
||||
uint8_t _displaymode;
|
||||
|
||||
uint8_t _initialized;
|
||||
|
||||
uint8_t _numlines,_currline;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user