-
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.
split out TCL support into a C++ class
- Loading branch information
Showing
7 changed files
with
228 additions
and
63 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<?fileVersion 4.0.0?> | ||
|
||
<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage"> | ||
<storageModule moduleId="org.eclipse.cdt.core.settings"> | ||
<cconfiguration id="cdt.managedbuild.toolchain.gnu.cross.base.1475140007"> | ||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.toolchain.gnu.cross.base.1475140007" moduleId="org.eclipse.cdt.core.settings" name="Default"> | ||
<externalSettings/> | ||
<extensions> | ||
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/> | ||
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> | ||
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/> | ||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> | ||
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> | ||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> | ||
</extensions> | ||
</storageModule> | ||
<storageModule moduleId="cdtBuildSystem" version="4.0.0"> | ||
<configuration buildProperties="" id="cdt.managedbuild.toolchain.gnu.cross.base.1475140007" name="Default" parent="org.eclipse.cdt.build.core.emptycfg"> | ||
<folderInfo id="cdt.managedbuild.toolchain.gnu.cross.base.1475140007.1869955441" name="/" resourcePath=""> | ||
<toolChain id="cdt.managedbuild.toolchain.gnu.cross.base.1523050523" name="cdt.managedbuild.toolchain.gnu.cross.base" superClass="cdt.managedbuild.toolchain.gnu.cross.base"> | ||
<option id="cdt.managedbuild.option.gnu.cross.prefix.1450687038" name="Prefix" superClass="cdt.managedbuild.option.gnu.cross.prefix"/> | ||
<option id="cdt.managedbuild.option.gnu.cross.path.170755611" name="Path" superClass="cdt.managedbuild.option.gnu.cross.path"/> | ||
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.targetPlatform.gnu.cross.1791638063" isAbstract="false" osList="all" superClass="cdt.managedbuild.targetPlatform.gnu.cross"/> | ||
<builder id="cdt.managedbuild.builder.gnu.cross.2066092194" managedBuildOn="false" name="Gnu Make Builder.Default" superClass="cdt.managedbuild.builder.gnu.cross"/> | ||
<tool id="cdt.managedbuild.tool.gnu.cross.c.compiler.147196899" name="Cross GCC Compiler" superClass="cdt.managedbuild.tool.gnu.cross.c.compiler"/> | ||
<tool id="cdt.managedbuild.tool.gnu.cross.cpp.compiler.716879604" name="Cross G++ Compiler" superClass="cdt.managedbuild.tool.gnu.cross.cpp.compiler"/> | ||
<tool id="cdt.managedbuild.tool.gnu.cross.c.linker.1256744201" name="Cross GCC Linker" superClass="cdt.managedbuild.tool.gnu.cross.c.linker"/> | ||
<tool id="cdt.managedbuild.tool.gnu.cross.cpp.linker.1764035620" name="Cross G++ Linker" superClass="cdt.managedbuild.tool.gnu.cross.cpp.linker"/> | ||
<tool id="cdt.managedbuild.tool.gnu.cross.archiver.834425787" name="Cross GCC Archiver" superClass="cdt.managedbuild.tool.gnu.cross.archiver"/> | ||
<tool id="cdt.managedbuild.tool.gnu.cross.assembler.1099179912" name="Cross GCC Assembler" superClass="cdt.managedbuild.tool.gnu.cross.assembler"/> | ||
</toolChain> | ||
</folderInfo> | ||
</configuration> | ||
</storageModule> | ||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/> | ||
</cconfiguration> | ||
</storageModule> | ||
<storageModule moduleId="cdtBuildSystem" version="4.0.0"> | ||
<project id="udpLights.null.952024016" name="udpLights"/> | ||
</storageModule> | ||
<storageModule moduleId="scannerConfiguration"> | ||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> | ||
</storageModule> | ||
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/> | ||
</cproject> |
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,3 @@ | ||
|
||
nbproject | ||
|
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,27 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>udpLights</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name> | ||
<triggers>clean,full,incremental,</triggers> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name> | ||
<triggers>full,incremental,</triggers> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.cdt.core.cnature</nature> | ||
<nature>org.eclipse.cdt.core.ccnature</nature> | ||
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature> | ||
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature> | ||
</natures> | ||
</projectDescription> |
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,119 @@ | ||
/* | ||
* File: TCLFast.hxx | ||
* Author: kukulski | ||
* | ||
* Created on November 9, 2012, 2:58 PM | ||
*/ | ||
|
||
#ifndef TCLFAST_HXX | ||
#define TCLFAST_HXX | ||
|
||
#include "tclled.h" | ||
#include <stdio.h> | ||
#include <fcntl.h> | ||
#include <unistd.h> | ||
|
||
class TCLFast { | ||
|
||
public: | ||
|
||
TCLFast(int wd, int ht) { | ||
width = wd; | ||
height = ht; | ||
|
||
initTCL(); | ||
pixels = tcl.pixels; | ||
set_gamma(3.0, 3.0, 3.0); | ||
|
||
rawBuffer = new unsigned int[wd*ht]; | ||
|
||
} | ||
|
||
~TCLFast() { | ||
delete rawBuffer; | ||
} | ||
|
||
unsigned int *getRawBuffer() { | ||
return rawBuffer; | ||
} | ||
|
||
size_t getBufferSize() { return width * height * 4;} | ||
|
||
void prepPixels() { | ||
for(int i = 0; i < height; i++) | ||
for(int j = 0; j < width; j++) | ||
prepPixel(i,j); | ||
} | ||
|
||
void testPattern() { | ||
tcl_color *pixels = tcl.pixels; | ||
|
||
for(int i = 0; i < width*height; i++) { | ||
|
||
int row = i/width; | ||
int col = i%width; | ||
int quad = i /25; | ||
|
||
tcl_color *px = getTCLPixel(row, col); | ||
|
||
::write_gamma_color(px, row*255/4,col*255/4,quad*255/3); | ||
} | ||
} | ||
|
||
void send() { | ||
::send_buffer(spi,&tcl); | ||
} | ||
|
||
|
||
private: | ||
tcl_buffer tcl; | ||
tcl_color *pixels; | ||
unsigned int *rawBuffer; | ||
int width, height; | ||
int spi; | ||
|
||
void prepPixel(int row, int col) { | ||
unsigned int px = getPixel(row,col); | ||
::write_bgra_gamma(getTCLPixel(row,col),px); | ||
} | ||
tcl_color *getTCLPixel(int row, int col) { | ||
int phase = row & 1; | ||
int unwoundCol = phase?col : (width-col-1); | ||
return &pixels[width*row+unwoundCol]; | ||
} | ||
|
||
|
||
unsigned int getPixel(int row, int col) { | ||
return rawBuffer[width*row+col]; | ||
} | ||
|
||
void initTCL() { | ||
|
||
int leds = width * height; | ||
|
||
/* Open SPI device */ | ||
spi = open("/dev/spidev2.0",O_WRONLY); | ||
if(spi<0) { | ||
/* Open failed */ | ||
fprintf(stderr, "Error: SPI device open failed.\n"); | ||
exit(1); | ||
} | ||
|
||
/* Initialize SPI bus for TCL pixels */ | ||
if(spi_init(spi)<0) { | ||
/* Initialization failed */ | ||
fprintf(stderr, "Unable to initialize SPI bus.\n"); | ||
exit(1); | ||
} | ||
|
||
/* Allocate memory for the pixel buffer and initialize it */ | ||
if(tcl_init(&tcl,leds)<0) { | ||
/* Memory allocation failed */ | ||
fprintf(stderr, "Insufficient memory for pixel buffer.\n"); | ||
exit(1); | ||
} | ||
|
||
} | ||
}; // class TCLFast | ||
#endif /* TCLFAST_HXX */ | ||
|
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