Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
BlinkenLights
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UCC
BlinkenLights
Commits
acca5d0e
Commit
acca5d0e
authored
Mar 20, 2014
by
Mitchell Pomery
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set LED array via web browser
parent
4df6d9f2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
7 deletions
+55
-7
BlinkenLights.ino
BlinkenLights.ino
+55
-7
No files found.
BlinkenLights.ino
View file @
acca5d0e
...
...
@@ -26,7 +26,7 @@
#define PREFIX "" // Document root for our pages
#define PORT 80 // Web Server Port
#define NAMELEN 8 // Max variable length in request
#define VALUELEN 25
6
// Max value from request
#define VALUELEN 25
5
// Max value from request
#define WIDTH 7 // How many LEDs wide our array is
#define HEIGHT 6 // How many LEDs high our array is
#define STRIPLENGTH 42 // Number of LED's in light strip
...
...
@@ -156,7 +156,7 @@ int coordToPos(int xpos, int ypos) {
*/
void
setLED
(
int
pos
,
int
red
,
int
green
,
int
blue
)
{
if
(
pos
>
0
&&
pos
<
STRIPLENGTH
)
{
strip
.
setPixelColor
(
i
,
(
int
)
red
,
(
int
)
green
,
(
int
)
blue
);
strip
.
setPixelColor
(
pos
,
(
int
)
red
,
(
int
)
green
,
(
int
)
blue
);
}
}
...
...
@@ -274,6 +274,51 @@ char *url_tail, bool tail_complete) {
}
}
void
webSetArray
(
WebServer
&
server
,
WebServer
::
ConnectionType
type
,
char
*
url_tail
,
bool
tail_complete
)
{
URLPARAM_RESULT
rc
;
char
name
[
NAMELEN
];
char
value
[
VALUELEN
];
server
.
httpSuccess
();
// Kill the connection before doing anything if all they want is head
if
(
type
==
WebServer
::
HEAD
)
{
return
;
}
else
if
(
type
==
WebServer
::
GET
)
{
///TODO: Get rid of these magic numbers
//if (strlen(url_tail) >= 252) {
for
(
int
i
=
0
;
i
<
WIDTH
;
i
++
)
{
for
(
int
j
=
0
;
j
<
HEIGHT
;
j
++
)
{
char
red
[
3
];
char
green
[
3
];
char
blue
[
3
];
red
[
2
]
=
'\0'
;
green
[
2
]
=
'\0'
;
blue
[
2
]
=
'\0'
;
int
start
=
HEIGHT
*
i
+
j
;
Serial
.
print
(
start
);
Serial
.
print
(
" "
);
red
[
0
]
=
url_tail
[
6
*
start
];
red
[
1
]
=
url_tail
[(
6
*
start
)
+
1
];
green
[
0
]
=
url_tail
[(
6
*
start
)
+
2
];
green
[
1
]
=
url_tail
[(
6
*
start
)
+
3
];
blue
[
0
]
=
url_tail
[(
6
*
start
)
+
4
];
blue
[
1
]
=
url_tail
[(
6
*
start
)
+
5
];
Serial
.
print
(
red
);
Serial
.
print
(
green
);
Serial
.
print
(
blue
);
Serial
.
println
(
""
);
setLED
(
i
,
j
,
hexToChar
(
red
),
hexToChar
(
green
),
hexToChar
(
blue
));
}
}
//}
}
else
{
server
.
print
(
"Unknown Request"
);
}
}
/**
* Set the brightness to a specific magnitude
* @param server
...
...
@@ -451,10 +496,11 @@ void setup() {
//webserver.addCommand("individual", &webSetLED);
webserver
.
addCommand
(
"brightness"
,
&
webSetBrightness
);
webserver
.
addCommand
(
"get"
,
&
webGetArray
);
webserver
.
addCommand
(
"set"
,
&
webSetArray
);
// Start Webserver
webserver
.
begin
();
for
(
int
i
=
-
128
;
i
<
128
;
i
++
)
{
/*
for (int i = -128; i < 128; i++) {
Serial.print(i);
Serial.print(" ");
Serial.print((char) i);
...
...
@@ -465,7 +511,7 @@ void setup() {
Serial.print(" ");
Serial.print(d);
Serial.println("");
}
}
*/
// Start Lights
strip
.
begin
();
...
...
@@ -476,8 +522,8 @@ void setup() {
void
loop
()
{
// process incoming connections one at a time forever
char
buff
[
64
];
int
len
=
64
;
char
buff
[
256
];
int
len
=
256
;
webserver
.
processConnection
(
buff
,
&
len
);
if
(
lightOption
>
NUMSEQUENCES
)
{
//lightOption = 1;
...
...
@@ -510,6 +556,8 @@ void loop()
break
;
}
updateLights
();
// Show our lights
if
(
position
==
0
&&
lightOption
>
10
)
{
// if we have completed a sequence, move to the next one
lightOption
++
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment