Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ov
POV-Fan-software
Commits
4e6e98aa
Commit
4e6e98aa
authored
Nov 17, 2021
by
crvaksda
😁
Browse files
Finally fixed color-format from fb (RGB565).
parent
979f4e09
Changes
3
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
4e6e98aa
...
...
@@ -2,5 +2,5 @@
This repository contains all the software required to turn an old ceiling fan into a fully functional POV-display.
## Build Instructions
To build, use
`$ gcc -
o pov -l
pthread -lm main.c spi.c pov.c`
.
To build, use
`$ gcc -pthread
-o pov
-lm main.c spi.c pov.c
-lm
`
.
And then
`$./pov`
to run the application.
\ No newline at end of file
pov.c
View file @
4e6e98aa
...
...
@@ -66,6 +66,7 @@ static int set_wing_led_color(volatile led_wing *wing, int led, uint8_t r, uint8
static
void
get_xy_from_rt
(
int
*
x
,
int
*
y
,
int
r
,
int
t
){
*
x
=
(
int
)((
float
)
r
*
cos
(
t
))
+
var_info
.
xres
/
2
;
*
y
=
(
int
)((
float
)
r
*
sin
(
t
))
+
var_info
.
yres
/
2
;
//printf("x: %d, y: %d, r: %d, t: %d\n", *x, *y, r, t);
}
//static void get_rt_from_xy(int *r, int *t, int x, int y){
...
...
@@ -84,19 +85,18 @@ static void calculate_index_table(){
for
(
int
*
r
=
radii
;
r
<
radii
+
NUM_LEDS_PER_WING
;
r
++
){
// This will have to be different for staggered leds/wings.
for
(
int
t
=
0
;
t
<
THETA_RESOLUTION
;
t
++
){
get_xy_from_rt
(
&
x
,
&
y
,
*
r
,
t
);
indices
[
r
-
radii
][
t
]
=
x
%
var_info
.
xres
+
y
*
(
x
/
var_info
.
xres
)
;
indices
[
r
-
radii
][
t
]
=
x
+
y
*
var_info
.
xres
;
}
}
}
static
void
get_pixel_color
(
int
fb_index
,
int
*
r
,
int
*
g
,
int
*
b
){
if
(
fb_index
<
var_info
.
xres
*
var_info
.
yres
){
//printf("x: %d, y: %d\n", x, y);
//fb_pixel *p = &fb[x % var_info.xres + y * (x / var_info.xres)];
fb_pixel
*
p
=
&
fb
[
fb_index
];
*
r
=
p
->
r
;
*
g
=
p
->
g
;
*
b
=
p
->
b
;
//printf("i: %d, r: %d, g: %d, b: %d\n", fb_index, *r, *g, *b);
}
}
...
...
@@ -219,7 +219,7 @@ void *pov_run(){
int
msec
=
0
,
trigger
=
10
;
/* 10ms */
clock_t
before
=
clock
();
int
cnt
=
0
;
while
(
cnt
++
<
3
0000
){
while
(
true
||
cnt
++
<
6
0000
){
err
=
update_fb
();
if
(
err
){
goto
pov_cleanup
;
...
...
pov.h
View file @
4e6e98aa
// Real life measurements in cm:
#define TOTAL_FAN_DIAMETER 130
#define TOTAL_WING_LED_LENGTH 44
#define FAN_DEADZONE_RADIUS 21
// Fan characteristics:
#define NUM_LEDS_PER_WING 64
#define NUM_WINGS 1 // 5
#define LED_SPACING 4 // Number of fb-pixels between each led.
#define FAN_BLIND_ZONE_R 30 // Number of led-pixels in fan blind zone.
// Misc.:
#define THETA_RESOLUTION 1 // This should be set to something sort of reasonable. // 300
#define POV_BUFFER_TYPE const volatile char
#define POV_SCREEN_WIDTH 800
#define POV_SCREEN_HEIGHT 600
#define POV_SCREEN_BPP 8
#define FRAME_BUFFER_SIZE POV_SCREEN_WIDTH * POV_SCREEN_HEIGHT //320*480
// Total diameter of display: 130cm
// Deadzone radius: 21cm
// 44cm / 64 leds = 0.6875cm/led
// => FAN_BLIND_ZONE_R = 30.5454
// 800 pixels / 130cm = 6.154 pixels/cm
// => 4.23 pixels/led
typedef
struct
_fb_pixel
{
uint8_t
b
;
uint8_t
r
;
uint8_t
g
;
uint8_t
a
;
// FB-settings:
#define POV_SCREEN_WIDTH 720
#define POV_SCREEN_HEIGHT 480
#define POV_SCREEN_BPP 16
#define FRAME_BUFFER_SIZE POV_SCREEN_WIDTH * POV_SCREEN_HEIGHT * (POV_SCREEN_BPP / 8)
// Calculated values:
// Total diameter of display: 130cm
// Deadzone radius: 21cm
// 44cm / 64 leds = 0.6875cm/led
// => FAN_BLIND_ZONE_R = 30.5454
// 800 pixels / 130cm = 6.154 pixels/cm
// => 4.23 pixels/led
// Tip: Mess with constants until radii[NUM_LEDS - 1] is as close as possible to POV_SCREEN_WIDTH / 2.
#define LED_SPACING (int) \
( \
((float)POV_SCREEN_WIDTH / (float)TOTAL_FAN_DIAMETER) \
* ((float)TOTAL_WING_LED_LENGTH / (float)NUM_LEDS_PER_WING) \
) // Number of fb-pixels between each led. 5 for 800x600.
#define FAN_BLIND_ZONE_R (int) \
( \
(float) FAN_DEADZONE_RADIUS \
/ ((float)TOTAL_WING_LED_LENGTH / (float)NUM_LEDS_PER_WING) \
) // 31 // Number of led-pixels in fan blind zone.
typedef
struct
_fb_pixel
{
// 16bpp => RGB565 (BGR?)
uint16_t
b
:
5
;
uint16_t
g
:
6
;
uint16_t
r
:
5
;
}
fb_pixel
;
typedef
struct
_led_pixel
{
uint8_t
p
;
uint8_t
b
;
...
...
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