-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLamp.cpp
120 lines (98 loc) · 1.56 KB
/
Lamp.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#include "Lamp.h"
Lamp::Lamp(CRGB *ledarr, int numberofleds, int cols)
{
//ctor
setLeds(ledarr);
setNumLeds(numberofleds);
setCols(cols);
setRows(numberofleds / cols);
}
Lamp::~Lamp() {
//dtor
}
void Lamp::render() {
if(on()) {
FastLED.show();
}
}
int Lamp::on() {
return is_on;
}
void Lamp::turnOff()
{
is_on = 0;
//do other things?
}
void Lamp::turnOn()
{
is_on = 1;
//do other things?
}
int Lamp::switchAnimation()
{
return next_animation;
}
void Lamp::nextAnimation()
{
next_animation = 0x1;
//do other things?
}
int Lamp::getRows()
{
return rows;
}
void Lamp::setRows(int rows)
{
this->rows = rows;
}
int Lamp::getCols()
{
return cols;
}
void Lamp::setCols(int cols)
{
this->cols = cols;
}
int Lamp::getNumLeds()
{
return num_leds;
}
void Lamp::setNumLeds(int numberofleds)
{
num_leds = numberofleds;
}
void Lamp::setLed(int led, CRGB led_value) {
leds[led] = led_value;
}
CRGB Lamp::getLed(int led) {
return leds[led];
}
CRGB* Lamp::getLeds() {
return leds;
}
void Lamp::setLeds(CRGB *ledarr)
{
leds = ledarr;
}
void Lamp::fill_color(int start, int end, CRGB color) {
for(int i = start; i<=end; i++){
leds[i] = color;
}
}
void Lamp::fill_row(int row, CRGB color) {
int row_end = row*cols-1;
int row_start = row_end-cols;
fill_color(row_start, row_end, color);
}
void Lamp::fill_column(int col, CRGB color) {
for(int i = 0; i < num_leds; i+=cols) {
int led = i+col-1;
leds[led] = color;
}
}
uint16_t Lamp::XY( uint8_t x, uint8_t y)
{
uint16_t i;
i = (y * cols) + x;
return i;
}