-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added command line option to omit a bad pixel
- Loading branch information
Showing
17 changed files
with
376 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
#include "tclled.h" | ||
#include <fcntl.h> | ||
#include <unistd.h> | ||
#include <stdio.h> | ||
#include "UDPSender.h" | ||
#include <stdlib.h> | ||
#include <signal.h> | ||
#include "TCLZoned.hxx" | ||
#include <vector> | ||
#include <list> | ||
#include <string> | ||
#include <algorithm> | ||
#include <iostream> | ||
|
||
void prepPixels(unsigned int *raw, const tcl_buffer &tcl); | ||
void initTclBuf(const tcl_buffer &tcl); | ||
void interruptHandler(int param); | ||
using namespace std; | ||
|
||
|
||
class Options { | ||
public: | ||
|
||
Options(int argc, const char * argv[]): | ||
leds(200), | ||
port(54321) | ||
{ | ||
buffersize ={20,10}; | ||
slurp(argc,argv); | ||
|
||
|
||
|
||
findStart = args.begin(); | ||
findEnd = args.end(); | ||
buffersize = eatXY("size",buffersize); | ||
leds = eatInt("leds",leds); | ||
port = eatInt("port",port); | ||
eatOmissions(); | ||
|
||
eatZones(); | ||
|
||
|
||
|
||
|
||
|
||
} | ||
|
||
~Options() { | ||
std::list<Zone*>::iterator first = zones.begin(), last = zones.end(); | ||
for ( ; first!=last; ++first ) | ||
delete (*first); | ||
} | ||
|
||
void dump() { | ||
|
||
cout << "port:" << port << endl | ||
<<"leds:" << leds << endl | ||
<<"wd:" << buffersize.x << ", ht:" << buffersize.y << endl; | ||
} | ||
public: | ||
XY buffersize; | ||
int leds; | ||
int port; | ||
|
||
vector<string> args; | ||
list<Zone *> zones; | ||
list<XY> omissions; | ||
vector<string>::iterator findStart, findEnd; | ||
|
||
private: | ||
|
||
int getInt(string &strVal) { return atoi(strVal.c_str());} | ||
|
||
XY eatXY(const char *key, XY defaultVal) { | ||
vector<string>::iterator where, keyloc,xloc,yloc; | ||
|
||
where = find(findStart, findEnd,key); | ||
if(where == findEnd) return defaultVal; | ||
|
||
|
||
|
||
keyloc = where; | ||
xloc = where + 1; | ||
yloc = where + 2; | ||
|
||
|
||
XY rval{getInt(*xloc),getInt(*yloc)}; | ||
|
||
args.erase(keyloc,yloc); | ||
return rval; | ||
} | ||
|
||
int eatInt(const char *key, int defaultVal) { | ||
vector<string>::iterator where; | ||
where = find(findStart,findEnd,key); | ||
if(where == findEnd) return defaultVal; | ||
|
||
int rval = getInt(where[1]); | ||
args.erase(where, where+1); | ||
return rval; | ||
} | ||
|
||
int eatFlag(const char *key) { | ||
vector<string>::iterator where; | ||
where = find(findStart,findEnd,key); | ||
|
||
if(where == findEnd) return 0; | ||
// cerr << where[0] << endl; | ||
// args.erase(where); | ||
return 1; | ||
} | ||
|
||
void slurp(int argc, const char **argv) { | ||
for(int i=0 ; i < argc; i++) | ||
args.push_back(argv[i]); | ||
} | ||
|
||
|
||
void eatZones() { | ||
while(findZone()) | ||
zones.push_back(eatZone()); | ||
} | ||
|
||
bool findZone() { | ||
findStart = find(args.begin(), args.end(), "zone"); | ||
if(findStart == args.end()) return false; | ||
findStart++; | ||
|
||
findEnd = find(findStart,args.end(),"zone"); | ||
} | ||
|
||
Zone *eatZone() { | ||
|
||
XY orig = eatXY("origin",XY{0,0}); | ||
XY size = eatXY("size",XY{10,10}); | ||
|
||
int offset = eatInt("offset",0); | ||
bool vertical = eatFlag("vertical"); | ||
int flipX = eatFlag("flipX"); | ||
int flipY = eatFlag("flipY"); | ||
|
||
|
||
args.erase(findStart,findEnd); | ||
|
||
Zone *rval = vertical ? new VZone(orig, size,offset, flipX, flipY) : | ||
new Zone(orig,size,offset, flipX, flipY); | ||
|
||
return rval; | ||
} | ||
|
||
|
||
void eatOmissions() { | ||
|
||
while(true) { | ||
XY omit = eatXY("omit",XY{-1,-1}); | ||
if(omit.x == -1) return; | ||
omissions.push_back(omit); | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
scp * <ssh-identity>:udplights |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[Unit] | ||
Description=Run the UDP -> TCL lighting daemon | ||
After=syslog.target network.target | ||
#BindsTo=dev-spidev2.0.device | ||
RequiresMountsFor=/dev/spidev2.0 | ||
# Requires=dev-spidev2.0.device | ||
[Service] | ||
Type=simple | ||
ExecStart=/usr/bin/udplights/startUdplights.bash | ||
#ExecStart=/home/root/udplights/tallwide size 32 11 leds 200 port 54321 zone size 22 5 offset 100 flipX zone size 10 10 offset 0 origin 22 1 flipY flipX vertical > /dev/null | ||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[Unit] | ||
Description=Run the UDP -> TCL lighting daemon | ||
After=syslog.target network.target | ||
#BindsTo=dev-spidev2.0.device | ||
RequiresMountsFor=/dev/spidev2.0 | ||
# Requires=dev-spidev2.0.device | ||
[Service] | ||
Type=simple | ||
ExecStart=/usr/bin/udplights/startUdplights.bash | ||
#ExecStart=/home/root/udplights/tallwide size 32 11 leds 200 port 54321 zone size 22 5 offset 100 flipX zone size 10 10 offset 0 origin 22 1 flipY flipX vertical > /dev/null | ||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[Unit] | ||
Description=Run the UDP -> TCL lighting daemon | ||
After=syslog.target network.target | ||
#BindsTo=dev-spidev2.0.device | ||
RequiresMountsFor=/dev/spidev2.0 | ||
# Requires=dev-spidev2.0.device | ||
[Service] | ||
Type=simple | ||
ExecStart=/usr/bin/udplights/startUdplights.bash | ||
#ExecStart=/home/root/udplights/tallwide size 32 11 leds 200 port 54321 zone size 22 5 offset 100 flipX zone size 10 10 offset 0 origin 22 1 flipY flipX vertical > /dev/null | ||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// | ||
// main.c | ||
// udpListen | ||
// | ||
// Created by Timothy Kukulski on 10/30/12. | ||
// Copyright (c) 2012 Adobe. All rights reserved. | ||
// | ||
|
||
|
||
#include "tclled.h" | ||
#include <fcntl.h> | ||
#include <unistd.h> | ||
#include <stdio.h> | ||
#include "UDPSender.h" | ||
#include <stdlib.h> | ||
#include <signal.h> | ||
#include "TCLZoned.hxx" | ||
#include <vector> | ||
#include <list> | ||
#include <string> | ||
#include <algorithm> | ||
#include <iostream> | ||
#include "Options.hxx" | ||
|
||
void prepPixels(unsigned int *raw, const tcl_buffer &tcl); | ||
void initTclBuf(const tcl_buffer &tcl); | ||
void interruptHandler(int param); | ||
using namespace std; | ||
|
||
int main(int argc, const char * argv[]) | ||
{ | ||
|
||
Options opts(argc, argv); | ||
|
||
TCLZoned tcl(opts.buffersize.x, opts.buffersize.y, opts.leds); | ||
tcl.addZones(opts.zones); | ||
UDPListener udp(opts.port); | ||
|
||
udp.setNonblocking(); | ||
|
||
opts.dump(); | ||
|
||
uint32_t *udpBuf = tcl.getBuffer()->getBuffer(); | ||
size_t bufSize = tcl.getBuffer()->getBufferSize(); | ||
|
||
|
||
|
||
tcl.testPattern(); | ||
tcl.send(); | ||
|
||
|
||
while(1) { | ||
size_t amount = udp.listen(udpBuf,bufSize); | ||
if(amount == bufSize) { | ||
tcl.send(); | ||
} else { | ||
cout << "bad buffer size:" << amount << " expected: " << bufSize << endl; | ||
} | ||
} | ||
|
||
return 0; | ||
} |
Oops, something went wrong.