parent
23e9d88bc7
commit
b889726538
|
@ -7,7 +7,7 @@ project(tensorPattern)
|
|||
|
||||
# Let's set a version number.
|
||||
# This file must be manually changed to effect version change.
|
||||
set (VERSION_MAJOR 0)
|
||||
set (VERSION_MAJOR 1)
|
||||
set (VERSION_MINOR 0)
|
||||
set (VERSION_PATCH 0)
|
||||
set (VERSION_PRERELEASE)
|
||||
|
@ -23,6 +23,10 @@ add_compile_options(-Wall -g)
|
|||
|
||||
# Libraries
|
||||
# find_package(SDL COMPONENTS TTF IMAGE GFX REQUIRED) - Later versions.
|
||||
find_package(SDL)
|
||||
if ( NOT SDL_FOUND )
|
||||
message(FATAL_ERROR "SDL not found! Please install libsdl1.2-dev!")
|
||||
endif ( NOT SDL_FOUND )
|
||||
|
||||
# Verbose output (or use: make VERBOSE=1)
|
||||
#set ( CMAKE_VERBOSE_MAKEFILE on )
|
||||
|
|
11
README.txt
11
README.txt
|
@ -1,7 +1,7 @@
|
|||
Tensor pattern generation - Version 0.0.0 - Test patterns.
|
||||
Tensor pattern generation - Version 1.0.0 - Brief tensor / SDL demo - red / mod
|
||||
|
||||
These patterns output as UDP to the tensor wall. There are no previews in this
|
||||
version.
|
||||
These patterns output as UDP to the tensor wall. There is a preview window
|
||||
using SDL.
|
||||
|
||||
Build instructions:
|
||||
|
||||
|
@ -12,7 +12,6 @@ Build instructions:
|
|||
|
||||
Binaries can be found in build/bin.
|
||||
|
||||
The script in the scripts directory was meant to run a pattern for 20 seconds,
|
||||
kill it, then move on to the next. If used, it should be customized for your
|
||||
environment.
|
||||
There are two orphaned binaries in the bin directory. The code that produced
|
||||
them doesn't seem to exist anymore.
|
||||
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
bin/test1_bayard
BIN
bin/test1_bayard
Binary file not shown.
|
@ -1,70 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Make tensor easier.
|
||||
# Joshua Krueger
|
||||
# 05_19_2008
|
||||
|
||||
export TENSOR_PATH="/home/sherman/tensor"
|
||||
|
||||
stopit() {
|
||||
ps -fea | while read -r bline ; do
|
||||
if [[ ! -z "$(echo $bline | grep $TENSOR_PATH)" ]] ; then
|
||||
this="$(echo $bline | while read -r bl bl bl bl bl bl bl oi ; do echo $oi ; done)"
|
||||
killall -9 $this 1>&2 2>/dev/null
|
||||
fi
|
||||
done
|
||||
exit 1
|
||||
}
|
||||
|
||||
trap stopit 2
|
||||
|
||||
# Check the net
|
||||
if [[ -z "$(ifconfig | grep eth0:0)" ]] ; then
|
||||
sudo ifconfig eth0 add 10.5.1.99
|
||||
if [[ -z "$(ifconfig | grep eth0:0)" ]] ; then
|
||||
echo "Josh sucks. This won't work."
|
||||
exit 1
|
||||
else
|
||||
sudo ifconfig eth0:0 netmask 255.255.255.0
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$#" == "0" ]] ; then
|
||||
echo "Usage: tensor <pattern>"
|
||||
echo " tensor all [<seconds for each>]"
|
||||
echo
|
||||
echo " Available patterns:"
|
||||
ls ${TENSOR_PATH} | while read -r aline ; do
|
||||
echo " $aline"
|
||||
done
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$1" == "all" ]] ; then
|
||||
if [[ "$#" == "2" ]] ; then
|
||||
second="${2}"
|
||||
fi
|
||||
|
||||
while [[ 1 ]] ; do
|
||||
ls ${TENSOR_PATH} | while read -r aline ; do
|
||||
${TENSOR_PATH}/${aline} &
|
||||
sleep ${second:-20}
|
||||
killall -9 ${TENSOR_PATH}/${aline} 1>&2 2>/dev/null
|
||||
done
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
if [[ -e "${TENSOR_PATH}/${1}" ]] ; then
|
||||
$TENSOR_PATH/${1}
|
||||
else
|
||||
echo "Pattern \"$1\" not recognized. Valid patterns are:"
|
||||
ls ${TENSOR_PATH} | while read -r aline ; do
|
||||
echo " $aline"
|
||||
done
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
@ -2,31 +2,17 @@
|
|||
# Created 2014_11_14 by Argyle
|
||||
|
||||
# Define the executable source - same as project name.
|
||||
add_executable (blue-wave-left_a2 blue-wave-left_a2.c)
|
||||
add_executable (blue-wave-up_a blue-wave-up_a.c)
|
||||
add_executable (color-cycle-ugly_colors color-cycle-ugly_colors.c)
|
||||
add_executable (green-wave-up_adf green-wave-up_adf.c)
|
||||
add_executable (magenta-green-ortho-scaler_pl magenta-green-ortho-scaler_pl.c)
|
||||
add_executable (red-parabaloid-modular_a3 red-parabaloid-modular_a3.c)
|
||||
add_executable (rgb-hash-sort_ick rgb-hash-sort_ick.c)
|
||||
add_executable (test1_bayard test1_bayard.c)
|
||||
add_executable (tensor test1.c)
|
||||
|
||||
# Configure the version header - not used yet.
|
||||
configure_file("version.h.in" "version.h")
|
||||
add_library(drv-tensor drv-tensor.c)
|
||||
|
||||
# Included directories
|
||||
include_directories(${PROJECT_BINARY_DIR}/bin)
|
||||
include_directories(${PROJECT_BINARY_DIR}/bin ${SDL_INCLUDE_DIR})
|
||||
|
||||
# Linked Libraries
|
||||
target_link_libraries(blue-wave-left_a2 drv-tensor)
|
||||
target_link_libraries(blue-wave-up_a drv-tensor)
|
||||
target_link_libraries(color-cycle-ugly_colors drv-tensor)
|
||||
target_link_libraries(green-wave-up_adf drv-tensor)
|
||||
target_link_libraries(magenta-green-ortho-scaler_pl drv-tensor)
|
||||
target_link_libraries(red-parabaloid-modular_a3 drv-tensor)
|
||||
target_link_libraries(rgb-hash-sort_ick drv-tensor)
|
||||
target_link_libraries(test1_bayard drv-tensor)
|
||||
target_link_libraries(tensor drv-tensor ${SDL_LIBRARY})
|
||||
|
||||
# file(COPY font.ttf Fbyte-01.jpg DESTINATION ${PROJECT_BINARY_DIR}/bin) - not yet
|
||||
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
SRCS = drv-tensor.c
|
||||
OBJS = $(SRCS:.c=.o)
|
||||
|
||||
.c.o:
|
||||
$(CC) $(CFLAGS) $(INCLUDES) -c $*.c
|
||||
|
||||
blue-wave-left_a2: $(OBJS) blue-wave-left_a2.o
|
||||
$(CC) $(CFLAGS) $(OBJS) blue-wave-left_a2.o -o blue-wave-left_a2
|
||||
|
||||
blue-wave-up_a: $(OBJS) blue-wave-up_a.o
|
||||
$(CC) $(CFLAGS) $(OBJS) blue-wave-up_a.o -o blue-wave-up_a
|
||||
|
||||
color-cycle-ugly_colors: $(OBJS) color-cycle-ugly_colors.o
|
||||
$(CC) $(CFLAGS) $(OBJS) color-cycle-ugly_colors.o -o color-cycle-ugly_colors
|
||||
|
||||
green-wave-up_adf: $(OBJS) green-wave-up_adf.o
|
||||
$(CC) $(CFLAGS) $(OBJS) green-wave-up_adf.o -o green-wave-up_adf
|
||||
|
||||
magenta-green-ortho-scaler_pl: $(OBJS) magenta-green-ortho-scaler_pl.o
|
||||
$(CC) $(CFLAGS) $(OBJS) magenta-green-ortho-scaler_pl.o -o magenta-green-ortho-scaler_pl
|
||||
|
||||
red-parabaloid-modular_a3: $(OBJS) red-parabaloid-modular_a3.o
|
||||
$(CC) $(CFLAGS) $(OBJS) red-parabaloid-modular_a3.o -o red-parabaloid-modular_a3
|
||||
|
||||
rgb-hash-sort_ick: $(OBJS) rgb-hash-sort_ick.o
|
||||
$(CC) $(CFLAGS) $(OBJS) rgb-hash-sort_ick.o -o rgb-hash-sort_ick
|
||||
|
||||
test1_bayard: $(OBJS) test1_bayard.o
|
||||
$(CC) $(CFLAGS) $(OBJS) test1_bayard.o -o test1_bayard
|
||||
|
||||
all: rgb-hash-sort_ick red-parabaloid-modular_a3 magenta-green-ortho-scaler_pl green-wave-up_adf color-cycle-ugly_colors blue-wave-up_a blue-wave-left_a2 test1_bayard
|
||||
|
||||
clean:;
|
||||
rm -f core core.* *.o blue-wave-left_a2 blue-wave-up_a color-cycle-ugly_colors green-wave-up_adf magenta-green-ortho-scaler_pl red-parabaloid-modular_a3 rgb-hash-sort_ick test1_bayard
|
|
@ -1,55 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <math.h>
|
||||
#include "drv-tensor.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int x,y,count;
|
||||
unsigned char r,g,b;
|
||||
// double f;
|
||||
|
||||
/* this is how you should declare your tensor frame buffer */
|
||||
|
||||
unsigned char fb[TENSOR_BYTES];
|
||||
|
||||
/* call tensor_init() once, before you call tensor_send() */
|
||||
|
||||
tensor_init();
|
||||
|
||||
/* set this flag if you're going to use tensor in landscape mode */
|
||||
|
||||
tensor_landscape_p = 1;
|
||||
|
||||
count = 0;
|
||||
while(1) {
|
||||
count += 1;
|
||||
|
||||
/* NOTICE: in landscape mode, x ranges between 0 and TENSOR_HEIGHT.
|
||||
* normally, when not in landscape mode, x would range between 0
|
||||
* and TENSOR_HEIGHT. similarly, y is constrained by TENSOR_WIDTH
|
||||
* instead of TENSOR_HEIGHT. */
|
||||
|
||||
for(x=0;x<TENSOR_HEIGHT;x++) {
|
||||
for(y=0;y<TENSOR_WIDTH;y++) {
|
||||
b = count++;
|
||||
g = 0;
|
||||
r = 0;
|
||||
|
||||
fb[y*TENSOR_HEIGHT*3 + x*3 + 0] = r;
|
||||
fb[y*TENSOR_HEIGHT*3 + x*3 + 1] = g;
|
||||
fb[y*TENSOR_HEIGHT*3 + x*3 + 2] = b;
|
||||
}
|
||||
}
|
||||
|
||||
/* after you've completed a frame buffer, call tensor_send() with
|
||||
* that framebuffer */
|
||||
|
||||
tensor_send(fb);
|
||||
|
||||
usleep(50000);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <math.h>
|
||||
#include "drv-tensor.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int x,y,count;
|
||||
unsigned char r,g,b;
|
||||
// double f;
|
||||
|
||||
/* this is how you should declare your tensor frame buffer */
|
||||
|
||||
unsigned char fb[TENSOR_BYTES];
|
||||
|
||||
/* call tensor_init() once, before you call tensor_send() */
|
||||
|
||||
tensor_init();
|
||||
|
||||
/* set this flag if you're going to use tensor in landscape mode */
|
||||
|
||||
tensor_landscape_p = 1;
|
||||
|
||||
count = 0;
|
||||
while(1) {
|
||||
count += 1;
|
||||
|
||||
/* NOTICE: in landscape mode, x ranges between 0 and TENSOR_HEIGHT.
|
||||
* normally, when not in landscape mode, x would range between 0
|
||||
* and TENSOR_HEIGHT. similarly, y is constrained by TENSOR_WIDTH
|
||||
* instead of TENSOR_HEIGHT. */
|
||||
for(y=0;y<TENSOR_WIDTH;y++) {
|
||||
|
||||
for(x=0;x<TENSOR_HEIGHT;x++) {
|
||||
// here
|
||||
b = count++;
|
||||
g = 0;
|
||||
r = 0;
|
||||
|
||||
fb[y*TENSOR_HEIGHT*3 + x*3 + 0] = r;
|
||||
fb[y*TENSOR_HEIGHT*3 + x*3 + 1] = g;
|
||||
fb[y*TENSOR_HEIGHT*3 + x*3 + 2] = b;
|
||||
}
|
||||
}
|
||||
|
||||
/* after you've completed a frame buffer, call tensor_send() with
|
||||
* that framebuffer */
|
||||
|
||||
tensor_send(fb);
|
||||
|
||||
usleep(50000);
|
||||
}
|
||||
return(0);
|
||||
}
|
|
@ -1,86 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <math.h>
|
||||
#include "drv-tensor.h"
|
||||
|
||||
typedef struct {
|
||||
unsigned char r;
|
||||
unsigned char g;
|
||||
unsigned char b;
|
||||
} color_t;
|
||||
|
||||
void blit(int x, int y, unsigned char *fb, color_t color);
|
||||
void reset(unsigned char *fb, color_t color);
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int i,count;
|
||||
// color_t black = {0, 0, 0};
|
||||
// color_t white = {255, 255, 255};
|
||||
color_t red = {255, 0, 0};
|
||||
color_t green = {0,255,0};
|
||||
color_t blue = {0,0,255};
|
||||
color_t purple = {255, 0, 255};
|
||||
color_t cyan = {0, 255,255};
|
||||
color_t yellow = {255, 255, 0};
|
||||
color_t orange = {255,127,0};
|
||||
|
||||
color_t array[7] = { red, orange, yellow, green, cyan, blue, purple};
|
||||
|
||||
// unsigned char r,g,b;
|
||||
// double f;
|
||||
|
||||
/* this is how you should declare your tensor frame buffer */
|
||||
|
||||
//unsigned char fb[TENSOR_BYTES];
|
||||
unsigned char fb[TENSOR_WIDTH][TENSOR_HEIGHT][3];
|
||||
unsigned char *fb2 = &fb[0][0][0];
|
||||
|
||||
/* call tensor_init() once, before you call tensor_send() */
|
||||
|
||||
tensor_init();
|
||||
|
||||
/* set this flag if you're going to use tensor in landscape mode */
|
||||
|
||||
tensor_landscape_p = 1;
|
||||
|
||||
|
||||
printf("Height: %i, Width: %i, Bytes: %i\n", TENSOR_HEIGHT, TENSOR_WIDTH, TENSOR_BYTES);
|
||||
|
||||
printf("H x W: %i, /3: %i\n", TENSOR_HEIGHT * TENSOR_WIDTH, (TENSOR_HEIGHT * TENSOR_WIDTH) / 3);
|
||||
count = 0;
|
||||
while(1) {
|
||||
count ++;
|
||||
|
||||
/* NOTICE: in landscape mode, x ranges between 0 and TENSOR_HEIGHT.
|
||||
* normally, when not in landscape mode, x would range between 0
|
||||
* and TENSOR_HEIGHT. similarly, y is constrained by TENSOR_WIDTH
|
||||
* instead of TENSOR_HEIGHT. */
|
||||
|
||||
for(i=0; i<7; i++) {
|
||||
reset(fb2, array[i]);
|
||||
tensor_send(fb2);
|
||||
usleep(500000);
|
||||
}
|
||||
|
||||
/* after you've completed a frame buffer, call tensor_send() with
|
||||
* that framebuffer */
|
||||
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
void blit(int x, int y, unsigned char *fb, color_t color) {
|
||||
}
|
||||
|
||||
void reset(unsigned char *fb, color_t color) {
|
||||
int i;
|
||||
for (i = 0; i < (20 * 9 * 3) ; i+=3) {
|
||||
fb[i+0] = color.r;
|
||||
fb[i+1] = color.g;
|
||||
fb[i+2] = color.b;
|
||||
}
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <math.h>
|
||||
#include "drv-tensor.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int x,y,count;
|
||||
//int i;
|
||||
unsigned char r,g,b;
|
||||
//double f;
|
||||
|
||||
/* this is how you should declare your tensor frame buffer */
|
||||
|
||||
unsigned char fb[TENSOR_BYTES];
|
||||
|
||||
/* call tensor_init() once, before you call tensor_send() */
|
||||
|
||||
tensor_init();
|
||||
|
||||
/* set this flag if you're going to use tensor in landscape mode */
|
||||
|
||||
tensor_landscape_p = 1;
|
||||
|
||||
count = 0;
|
||||
while(1) {
|
||||
count++;
|
||||
|
||||
/* NOTICE: in landscape mode, x ranges between 0 and TENSOR_HEIGHT.
|
||||
* normally, when not in landscape mode, x would range between 0
|
||||
* and TENSOR_HEIGHT. similarly, y is constrained by TENSOR_WIDTH
|
||||
* instead of TENSOR_HEIGHT. */
|
||||
for(y=0;y<TENSOR_WIDTH;y++) {
|
||||
for(x=0;x<TENSOR_HEIGHT;x++) {
|
||||
// here
|
||||
r = 0;
|
||||
g = g + 1;
|
||||
b = 0;
|
||||
|
||||
fb[y*TENSOR_HEIGHT*3 + x*3 + 0] = r * 0.15;
|
||||
fb[y*TENSOR_HEIGHT*3 + x*3 + 1] = g * 0.15;
|
||||
fb[y*TENSOR_HEIGHT*3 + x*3 + 2] = b * 0.15;
|
||||
}
|
||||
}
|
||||
|
||||
/* after you've completed a frame buffer, call tensor_send() with
|
||||
* that framebuffer */
|
||||
|
||||
tensor_send(fb);
|
||||
|
||||
usleep(50000);
|
||||
}
|
||||
return(0);
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <math.h>
|
||||
#include "drv-tensor.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int x,y,count;
|
||||
unsigned char r,g,b;
|
||||
//double f;
|
||||
|
||||
/* this is how you should declare your tensor frame buffer */
|
||||
|
||||
unsigned char fb[TENSOR_BYTES];
|
||||
|
||||
/* call tensor_init() once, before you call tensor_send() */
|
||||
|
||||
tensor_init();
|
||||
|
||||
/* set this flag if you're going to use tensor in landscape mode */
|
||||
|
||||
tensor_landscape_p = 1;
|
||||
|
||||
count = 0;
|
||||
while(1) {
|
||||
count++;
|
||||
|
||||
/* NOTICE: in landscape mode, x ranges between 0 and TENSOR_HEIGHT.
|
||||
* normally, when not in landscape mode, x would range between 0
|
||||
* and TENSOR_HEIGHT. similarly, y is constrained by TENSOR_WIDTH
|
||||
* instead of TENSOR_HEIGHT. */
|
||||
for(y=0;y<TENSOR_WIDTH;y++) {
|
||||
for(x=0;x<TENSOR_HEIGHT;x++) {
|
||||
// here
|
||||
g = x * count + 1;
|
||||
r =
|
||||
b = y * count - 1;
|
||||
|
||||
fb[y*TENSOR_HEIGHT*3 + x*3 + 0] = r;
|
||||
fb[y*TENSOR_HEIGHT*3 + x*3 + 1] = g;
|
||||
fb[y*TENSOR_HEIGHT*3 + x*3 + 2] = b;
|
||||
}
|
||||
}
|
||||
|
||||
/* after you've completed a frame buffer, call tensor_send() with
|
||||
* that framebuffer */
|
||||
|
||||
tensor_send(fb);
|
||||
|
||||
usleep(50000);
|
||||
}
|
||||
return(0);
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <math.h>
|
||||
#include "drv-tensor.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int x,y,count;
|
||||
unsigned char r,g,b;
|
||||
// double f;
|
||||
|
||||
/* this is how you should declare your tensor frame buffer */
|
||||
|
||||
unsigned char fb[TENSOR_BYTES];
|
||||
|
||||
/* call tensor_init() once, before you call tensor_send() */
|
||||
|
||||
tensor_init();
|
||||
|
||||
/* set this flag if you're going to use tensor in landscape mode */
|
||||
|
||||
tensor_landscape_p = 1;
|
||||
|
||||
count = 0;
|
||||
while(1) {
|
||||
count += 1;
|
||||
|
||||
/* NOTICE: in landscape mode, x ranges between 0 and TENSOR_HEIGHT.
|
||||
* normally, when not in landscape mode, x would range between 0
|
||||
* and TENSOR_HEIGHT. similarly, y is constrained by TENSOR_WIDTH
|
||||
* instead of TENSOR_HEIGHT. */
|
||||
|
||||
for(x=0;x<TENSOR_HEIGHT;x++) {
|
||||
for(y=0;y<TENSOR_WIDTH;y++) {
|
||||
r = (x * y) - count;
|
||||
g = 0;
|
||||
b = 0;
|
||||
|
||||
fb[y*TENSOR_HEIGHT*3 + x*3 + 0] = r;
|
||||
fb[y*TENSOR_HEIGHT*3 + x*3 + 1] = g;
|
||||
fb[y*TENSOR_HEIGHT*3 + x*3 + 2] = b;
|
||||
}
|
||||
}
|
||||
|
||||
/* after you've completed a frame buffer, call tensor_send() with
|
||||
* that framebuffer */
|
||||
|
||||
tensor_send(fb);
|
||||
|
||||
usleep(50000);
|
||||
}
|
||||
return(0);
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <math.h>
|
||||
#include "drv-tensor.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int x,y,count;
|
||||
// int i;
|
||||
unsigned char r,g,b;
|
||||
// double f;
|
||||
|
||||
/* this is how you should declare your tensor frame buffer */
|
||||
|
||||
unsigned char fb[TENSOR_BYTES];
|
||||
|
||||
/* call tensor_init() once, before you call tensor_send() */
|
||||
|
||||
tensor_init();
|
||||
|
||||
/* set this flag if you're going to use tensor in landscape mode */
|
||||
|
||||
tensor_landscape_p = 1;
|
||||
|
||||
count = 0;
|
||||
while(1) {
|
||||
count++;
|
||||
|
||||
/* NOTICE: in landscape mode, x ranges between 0 and TENSOR_HEIGHT.
|
||||
* normally, when not in landscape mode, x would range between 0
|
||||
* and TENSOR_HEIGHT. similarly, y is constrained by TENSOR_WIDTH
|
||||
* instead of TENSOR_HEIGHT. */
|
||||
for(y=0;y<TENSOR_WIDTH;y++) {
|
||||
for(x=0;x<TENSOR_HEIGHT;x++) {
|
||||
// here
|
||||
r = (2 * (20 - x) * count) + (.25 * (20 - x) * (20 - x) * count );
|
||||
g = (2 * x * count) + (.25 * x * x * count);
|
||||
b = (2 * y * count) + (.25 * y * y * count);
|
||||
|
||||
fb[y*TENSOR_HEIGHT*3 + x*3 + 0] = r * 0.15;
|
||||
fb[y*TENSOR_HEIGHT*3 + x*3 + 1] = g * 0.15;
|
||||
fb[y*TENSOR_HEIGHT*3 + x*3 + 2] = b * 0.15;
|
||||
}
|
||||
}
|
||||
|
||||
/* after you've completed a frame buffer, call tensor_send() with
|
||||
* that framebuffer */
|
||||
|
||||
tensor_send(fb);
|
||||
|
||||
usleep(50000);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
|
@ -0,0 +1,242 @@
|
|||
// Tensor Pattern
|
||||
|
||||
|
||||
// Defines
|
||||
#define YES 0
|
||||
#define NO 1
|
||||
#define USE_SDL
|
||||
#define PSIZE_X 40
|
||||
#define PSIZE_Y 40
|
||||
#define BORDER 10
|
||||
#define USE_SDL
|
||||
#define USE_TENSOR
|
||||
//#undef USE_SDL
|
||||
//#undef USE_TENSOR
|
||||
|
||||
// Includes
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <math.h>
|
||||
#include "drv-tensor.h"
|
||||
#ifdef USE_SDL
|
||||
#include "SDL.h"
|
||||
#endif
|
||||
|
||||
// Use 1/3
|
||||
#define TENSOR_WIDTH_EFF (TENSOR_HEIGHT)
|
||||
#define TENSOR_HEIGHT_EFF (TENSOR_WIDTH / 3)
|
||||
#define TENSOR_BYTES_EFF (TENSOR_WIDTH_EFF * TENSOR_HEIGHT_EFF * 3)
|
||||
#define TENSOR_PREVIEW_WIDTH (TENSOR_WIDTH_EFF * PSIZE_X)
|
||||
#define TENSOR_PREVIEW_HEIGHT (TENSOR_HEIGHT_EFF * PSIZE_Y)
|
||||
|
||||
// Typedefs
|
||||
typedef struct {
|
||||
unsigned char r;
|
||||
unsigned char g;
|
||||
unsigned char b;
|
||||
} color_t;
|
||||
|
||||
typedef enum {
|
||||
UP, DOWN, LEFT, RIGHT
|
||||
} dir_t;
|
||||
|
||||
|
||||
// Globals
|
||||
unsigned char fb[TENSOR_BYTES_EFF]; // Tensor frame buffer
|
||||
const color_t white = {.r = 255, .g = 255, .b = 255};
|
||||
const color_t black = {.r = 0, .g = 0, .b = 0};
|
||||
#ifdef USE_SDL
|
||||
SDL_Surface *screen;
|
||||
#endif
|
||||
|
||||
|
||||
// Protos
|
||||
void SetPixel(int x, int y, color_t color);
|
||||
color_t GetPixel(int x, int y);
|
||||
void ColorAll(color_t color);
|
||||
void Update(void);
|
||||
void FadeAll(int dec);
|
||||
#ifdef USE_SDL
|
||||
void UpdatePreview(void);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// Functions
|
||||
int main(void) {
|
||||
int x,y,count;
|
||||
color_t pixel_color;
|
||||
color_t oldColor;
|
||||
|
||||
// Init the display window.
|
||||
#ifdef USE_SDL
|
||||
if ( SDL_Init(SDL_INIT_AUDIO|SDL_INIT_VIDEO) < 0 ) {
|
||||
fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError());
|
||||
exit(EXIT_FAILURE);
|
||||
} else {
|
||||
atexit(SDL_Quit);
|
||||
}
|
||||
|
||||
screen = SDL_SetVideoMode(TENSOR_PREVIEW_WIDTH + (BORDER * 2), TENSOR_PREVIEW_HEIGHT + (BORDER * 2), 32, SDL_SWSURFACE);
|
||||
if (screen == NULL) {
|
||||
fprintf(stderr, "Unable to set video size: %s\n", SDL_GetError());
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Init tensor.
|
||||
tensor_init();
|
||||
tensor_landscape_p = 1; // Landscape mode.
|
||||
|
||||
|
||||
// Pattern loop.
|
||||
ColorAll(white);
|
||||
Update();
|
||||
|
||||
int i;
|
||||
for (i = 0; i < 255; i+=4) {
|
||||
FadeAll(4);
|
||||
Update();
|
||||
}
|
||||
|
||||
count = 0;
|
||||
while(count < 200) {
|
||||
count++;
|
||||
|
||||
// Give each pixel a color value.
|
||||
for(x = 0 ; x < TENSOR_WIDTH_EFF ; x++) {
|
||||
for(y = 0 ; y < TENSOR_HEIGHT_EFF ; y++) {
|
||||
oldColor = GetPixel(x,y);
|
||||
|
||||
pixel_color.r = ((x * y) - count) + (oldColor.r / 2);
|
||||
pixel_color.g = oldColor.g + pixel_color.r;
|
||||
pixel_color.b = 0;
|
||||
|
||||
SetPixel(x, y, pixel_color);
|
||||
}
|
||||
}
|
||||
|
||||
Update();
|
||||
}
|
||||
|
||||
|
||||
for (i = 0; i < 255; i+=4) {
|
||||
FadeAll(4);
|
||||
Update();
|
||||
}
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ColorAll(color_t color) {
|
||||
int x,y;
|
||||
for (x = 0; x < TENSOR_WIDTH_EFF; x++) {
|
||||
for (y = 0; y < TENSOR_HEIGHT_EFF; y++) {
|
||||
SetPixel(x,y,color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FadeAll(int dec) {
|
||||
int x,y;
|
||||
color_t oldColor;
|
||||
|
||||
for (x = 0; x < TENSOR_WIDTH_EFF; x++) {
|
||||
for (y = 0; y < TENSOR_HEIGHT_EFF; y++) {
|
||||
oldColor = GetPixel(x,y);
|
||||
if (oldColor.r < dec) {
|
||||
oldColor.r = 0;
|
||||
} else {
|
||||
oldColor.r -= dec;
|
||||
}
|
||||
|
||||
if (oldColor.g < dec) {
|
||||
oldColor.g = 0;
|
||||
} else {
|
||||
oldColor.g -= dec;
|
||||
}
|
||||
|
||||
if (oldColor.b < dec) {
|
||||
oldColor.b = 0;
|
||||
} else {
|
||||
oldColor.b -= dec;
|
||||
}
|
||||
|
||||
SetPixel(x,y,oldColor);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void SetPixel(int x, int y, color_t color) {
|
||||
fb[(y * TENSOR_WIDTH_EFF * 3) + (x * 3) + 0] = color.r;
|
||||
fb[(y * TENSOR_WIDTH_EFF * 3) + (x * 3) + 1] = color.g;
|
||||
fb[(y * TENSOR_WIDTH_EFF * 3) + (x * 3) + 2] = color.b;
|
||||
}
|
||||
|
||||
|
||||
|
||||
color_t GetPixel(int x, int y) {
|
||||
color_t colorTemp;
|
||||
|
||||
colorTemp.r = fb[(y * TENSOR_WIDTH_EFF * 3) + (x * 3) + 0];
|
||||
colorTemp.g = fb[(y * TENSOR_WIDTH_EFF * 3) + (x * 3) + 1];
|
||||
colorTemp.b = fb[(y * TENSOR_WIDTH_EFF * 3) + (x * 3) + 2];
|
||||
|
||||
return colorTemp;
|
||||
}
|
||||
|
||||
|
||||
void Update(void) {
|
||||
#ifdef USE_SDL
|
||||
UpdatePreview();
|
||||
#endif
|
||||
|
||||
#ifdef USE_TENSOR
|
||||
tensor_send(fb);
|
||||
#endif
|
||||
|
||||
usleep(50000);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef USE_SDL
|
||||
void UpdatePreview(void) {
|
||||
Uint32 color_sdl;
|
||||
Uint32 *bufp;
|
||||
color_t thisColor;
|
||||
int x,y;
|
||||
int i,j;
|
||||
|
||||
if (SDL_MUSTLOCK(screen)) {
|
||||
if (SDL_LockSurface(screen) < 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (x = 0; x < TENSOR_WIDTH_EFF; x++) {
|
||||
for (y = 0; y < TENSOR_HEIGHT_EFF; y++) {
|
||||
thisColor = GetPixel(x,y);
|
||||
color_sdl = SDL_MapRGB(screen->format, (Uint8) thisColor.r, (Uint8) thisColor.g, (Uint8) thisColor.b);
|
||||
for (i = 0; i < PSIZE_X; i++) {
|
||||
for (j = 0; j < PSIZE_Y; j++) {
|
||||
bufp = (Uint32 *) screen->pixels + ( (((y * PSIZE_Y) + j + BORDER) * screen->pitch / 4) + ((x * PSIZE_X) + i + BORDER));
|
||||
*bufp = color_sdl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (SDL_MUSTLOCK(screen)) {
|
||||
SDL_UnlockSurface(screen);
|
||||
}
|
||||
|
||||
SDL_Flip(screen);
|
||||
}
|
||||
#endif
|
|
@ -1,54 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <math.h>
|
||||
#include "drv-tensor.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int x,y,count;
|
||||
unsigned char r,g,b;
|
||||
// double f;
|
||||
|
||||
/* this is how you should declare your tensor frame buffer */
|
||||
|
||||
unsigned char fb[TENSOR_BYTES];
|
||||
|
||||
/* call tensor_init() once, before you call tensor_send() */
|
||||
|
||||
tensor_init();
|
||||
|
||||
/* set this flag if you're going to use tensor in landscape mode */
|
||||
|
||||
tensor_landscape_p = 1;
|
||||
|
||||
count = 0;
|
||||
while(1) {
|
||||
count += 1;
|
||||
|
||||
/* NOTICE: in landscape mode, x ranges between 0 and TENSOR_HEIGHT.
|
||||
* normally, when not in landscape mode, x would range between 0
|
||||
* and TENSOR_HEIGHT. similarly, y is constrained by TENSOR_WIDTH
|
||||
* instead of TENSOR_HEIGHT. */
|
||||
|
||||
for(x=0;x<TENSOR_HEIGHT;x++) {
|
||||
for(y=0;y<TENSOR_WIDTH;y++) {
|
||||
r = (int)(abs(x - y) * (count * 1.0)) % 255;
|
||||
g = (int)(abs(x - y) * (count * 1.3)) % 255;
|
||||
b = (int)(abs(x - y) * (count * 1.5)) % 255;
|
||||
|
||||
fb[y*TENSOR_HEIGHT*3 + x*3 + 0] = r;
|
||||
fb[y*TENSOR_HEIGHT*3 + x*3 + 1] = g;
|
||||
fb[y*TENSOR_HEIGHT*3 + x*3 + 2] = b;
|
||||
}
|
||||
}
|
||||
|
||||
/* after you've completed a frame buffer, call tensor_send() with
|
||||
* that framebuffer */
|
||||
|
||||
tensor_send(fb);
|
||||
|
||||
usleep(50000);
|
||||
}
|
||||
return(0);
|
||||
}
|
Loading…
Reference in New Issue