Skip to content

Commit a8ed6e5

Browse files
committed
Add Library + Docs
1 parent 177226d commit a8ed6e5

File tree

8 files changed

+199
-1
lines changed

8 files changed

+199
-1
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# Arduino_GigaDisplayRBG
2-
Minimal library for controlling the RGB on the GIGA Display Shield.
2+
3+
Minimal library for controlling the built-in RGB on the GIGA Display Shield via the IS31FL3197 driver (I2C).

docs/api.md

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# ArduinoLSM6DS3 library
2+
3+
## Classes
4+
5+
### `GigaDisplayRGB`
6+
7+
Base class for all RGB functions.
8+
9+
#### Syntax
10+
11+
```
12+
GigaDisplayRGB rgb; //creates an object
13+
14+
rgb.begin(); //using the object
15+
```
16+
17+
## Methods
18+
19+
### `begin()`
20+
21+
Initialize the library.
22+
23+
#### Syntax
24+
25+
```
26+
rgb.begin()
27+
```
28+
29+
#### Parameters
30+
31+
None.
32+
33+
#### Returns
34+
35+
None.
36+
37+
### `on()`
38+
39+
Set pixel color (r,g,b).
40+
41+
#### Syntax
42+
43+
```
44+
rgb.on(r, g, b)
45+
```
46+
47+
#### Parameters
48+
49+
Accepts values in range of 0-255 (8-bit).
50+
51+
- `uint8_t`, `uint8_t`, `uint8_t`
52+
53+
#### Returns
54+
55+
None.
56+
57+
### `off()`
58+
59+
Turns off all pixels by setting all parameters to 0. Same effect as using `rgb.on(0,0,0)`
60+
61+
#### Syntax
62+
63+
```
64+
rgb.off()
65+
```
66+
67+
#### Parameters
68+
69+
None.
70+
71+
#### Returns
72+
73+
None.

docs/readme.md

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Arduino_GigaDisplayRGB Library
2+
3+
Minimal library for controlling the built-in RGB on the GIGA Display Shield via the IS31FL3197 driver (I2C).
4+
5+
To use this library:
6+
7+
```
8+
#include <Arduino_GigaDisplayRGB.h>
9+
```
10+
11+
12+
Minimal example:
13+
14+
```
15+
#include <Arduino_GigaDisplayRGB.h>
16+
17+
GigaDisplayRGB rgb;
18+
19+
void setup() {
20+
rgb.begin();
21+
}
22+
23+
void loop() {
24+
rgb.on(255, 0, 0);
25+
delay(100);
26+
rgb.off();
27+
delay(100);
28+
}
29+
```

examples/SimpleRGB/SimpleRGB.ino

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include <Arduino_GigaDisplayRGB.h>
2+
3+
//Create rgb object
4+
GigaDisplayRGB rgb;
5+
6+
void setup() {
7+
//init library
8+
rgb.begin();
9+
}
10+
11+
void loop() {
12+
//all pixels off
13+
rgb.on(0, 0, 0);
14+
delay(100);
15+
16+
//red pixel on
17+
rgb.on(255, 0, 0);
18+
delay(100);
19+
20+
//green pixel on
21+
rgb.on(0, 255, 0);
22+
delay(100);
23+
24+
//blue pixel on
25+
rgb.on(0, 0, 255);
26+
delay(100);
27+
28+
//all pixels on
29+
rgb.on(255, 255, 255);
30+
delay(100);
31+
}

library.properties

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name=GigaDisplayRGB
2+
version=0.0.1
3+
author=Arduino
4+
maintainer=Arduino <info@arduino.cc>
5+
sentence=Controls the RGB on the GIGA Display Shield
6+
paragraph=
7+
category=Device Control
8+
url=https://www.arduino.cc/
9+
architectures=mbed_giga
10+
includes=GigaDisplayRGB.h

src/Arduino_GigaDisplayRGB.h

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifndef _ARDUINO_GIGADISPLAYRGB_H_
2+
#define _ARDUINO_GIGADISPLAYRGB_H_
3+
4+
#include "GigaDisplayRGB.h"
5+
6+
#endif

src/GigaDisplayRGB.cpp

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#include "GigaDisplayRGB.h"
2+
3+
GigaDisplayRGB::GigaDisplayRGB(){
4+
}
5+
6+
void GigaDisplayRGB::begin()
7+
{
8+
Wire1.begin();
9+
writeByte(0x1, 0xF1);
10+
writeByte(0x2, 0xFF);
11+
}
12+
13+
void GigaDisplayRGB::on(uint8_t r, uint8_t g, uint8_t b)
14+
{
15+
writeByte(0x10, r);
16+
writeByte(0x12, g);
17+
writeByte(0x11, b);
18+
writeByte(0x2b, 0xc5);
19+
}
20+
21+
void GigaDisplayRGB::off()
22+
{
23+
on(0, 0, 0);
24+
}
25+
26+
void GigaDisplayRGB::writeByte(uint8_t subAddress, uint8_t data)
27+
{
28+
Wire1.beginTransmission(0x50);
29+
Wire1.write(subAddress);
30+
Wire1.write(data);
31+
Wire1.endTransmission();
32+
}

src/GigaDisplayRGB.h

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#ifndef GigaDisplayRGB_h
2+
#define GigaDisplayRGB_h
3+
4+
#include "Wire.h"
5+
6+
class GigaDisplayRGB {
7+
public:
8+
GigaDisplayRGB();
9+
void begin();
10+
void on(uint8_t,uint8_t,uint8_t);
11+
void off();
12+
private:
13+
void writeByte(uint8_t,uint8_t);
14+
};
15+
16+
#endif

0 commit comments

Comments
 (0)