File tree 5 files changed +61
-4
lines changed
backlight/SimpleBacklight
5 files changed +61
-4
lines changed Original file line number Diff line number Diff line change @@ -5,14 +5,14 @@ Minimal library for controlling the built-in RGB on the GIGA Display Shield via
5
5
To use this library:
6
6
7
7
```
8
- #include <Arduino_GigaDisplayRGB .h>
8
+ #include <Arduino_GigaDisplay .h>
9
9
```
10
10
11
11
12
12
Minimal example:
13
13
14
14
```
15
- #include <Arduino_GigaDisplayRGB .h>
15
+ #include <Arduino_GigaDisplay .h>
16
16
17
17
GigaDisplayRGB rgb;
18
18
Original file line number Diff line number Diff line change
1
+ /*
2
+ Changes the display backlight from very dim to 100%
3
+ This example code is in the public domain.
4
+ */
5
+
6
+ #include < Arduino_GigaDisplay.h>
7
+
8
+ // Create backlight object
9
+ GigaDisplayBacklight backlight;
10
+
11
+ void setup () {
12
+ // init library
13
+ backlight.begin ();
14
+ }
15
+
16
+ int i = 0 ;
17
+ void loop () {
18
+ backlight.set (i++ % 100 );
19
+ delay (100 );
20
+ }
Original file line number Diff line number Diff line change 8
8
This example code is in the public domain.
9
9
*/
10
10
11
- #include < Arduino_GigaDisplayRGB .h>
11
+ #include < Arduino_GigaDisplay .h>
12
12
13
13
// Create rgb object
14
14
GigaDisplayRGB rgb;
Original file line number Diff line number Diff line change 8
8
This example code is in the public domain.
9
9
*/
10
10
11
- #include < Arduino_GigaDisplayRGB .h>
11
+ #include < Arduino_GigaDisplay .h>
12
12
13
13
// Create rgb object
14
14
GigaDisplayRGB rgb;
Original file line number Diff line number Diff line change @@ -13,4 +13,41 @@ class GigaDisplayRGB {
13
13
void writeByte (uint8_t ,uint8_t );
14
14
};
15
15
16
+ #include " mbed.h"
17
+ using namespace std ::chrono_literals;
18
+ using namespace std ::chrono;
19
+
20
+ class GigaDisplayBacklight {
21
+ public:
22
+ GigaDisplayBacklight () {}
23
+ void begin (int target_percent = 100 ) {
24
+ pin = new mbed::DigitalOut (PB_12);
25
+ ticker = new mbed::Ticker ();
26
+ ticker->attach (mbed::callback (this , &GigaDisplayBacklight::cb), 2ms);
27
+ set (target_percent);
28
+ }
29
+ void cb () {
30
+ static int counter = 0 ;
31
+ if (counter > intensity) {
32
+ *pin = 0 ;
33
+ } else {
34
+ *pin = 1 ;
35
+ }
36
+ counter += 10 ;
37
+ if (counter == 100 ) {
38
+ counter = 0 ;
39
+ }
40
+ }
41
+ void set (int target_percent) {
42
+ intensity = target_percent;
43
+ }
44
+ void off () {
45
+ set (0 );
46
+ }
47
+ private:
48
+ mbed::Ticker* ticker;
49
+ mbed::DigitalOut* pin;
50
+ int intensity;
51
+ };
52
+
16
53
#endif
You can’t perform that action at this time.
0 commit comments