RGB LED cube 5x5x5  1.0
Martin Stejskal, Schmidt Dominik
 All Files Functions Variables Macros Groups Pages
Macros | Functions
framebuffer.h File Reference

Framebuffer for RGB LED cube 5x5x5. More...

#include <avr/io.h>
#include <avr/interrupt.h>
#include <inttypes.h>
#include "settings.h"
#include <util/delay.h>
#include "bit_operations.h"

Go to the source code of this file.

Macros

#define framebuffer_wall0_void
 Turn off all LED in WALL0. More...
 
#define framebuffer_wall1_void
 Turn off all LED in WALL1. More...
 
#define framebuffer_wall2_void
 Turn off all LED in WALL2. More...
 
#define framebuffer_wall3_void
 Turn off all LED in WALL3. More...
 
#define framebuffer_wall4_void
 Turn off all LED in WALL4. More...
 
#define framebuffer_wall0_ones
 Turn on all LED in WALL0. More...
 
#define framebuffer_wall1_ones
 Turn on all LED in WALL1. More...
 
#define framebuffer_wall2_ones
 Turn on all LED in WALL2. More...
 
#define framebuffer_wall3_ones
 Turn on all LED in WALL3. More...
 
#define framebuffer_wall4_ones
 Turn on all LED in WALL4. More...
 
#define framebuffer_copy_wall0_to_wall1
 Copy data from WALL0 to WALL1. More...
 
#define framebuffer_copy_wall1_to_wall2
 Copy data from WALL1 to WALL2. More...
 
#define framebuffer_copy_wall2_to_wall3
 Copy data from WALL2 to WALL3. More...
 
#define framebuffer_copy_wall3_to_wall4
 Copy data from WALL3 to WALL4. More...
 

Functions

void framebuffer (volatile uint16_t(*p_fb_data)[5][5])
 Frame buffer use pointer to array with data, witch represents one 3D image. More...
 
void init_framebuffer (void)
 Set I/O for framebuffer to defaults. More...
 
void set_active_wall (uint8_t i_wall_number)
 According parameter set active "wall". More...
 
void set_active_column (uint8_t i_column_number)
 According parameter set active "column". More...
 
void load_DATA_RED_on_bus (uint8_t i_data_r)
 Load bits stored in i_data_r to bus with red LEDs. More...
 
void load_DATA_GREEN_on_bus (uint8_t i_data_g)
 Load bits stored in i_data_g to bus with green LEDs. More...
 
void load_DATA_BLUE_on_bus (uint8_t i_data_b)
 Load bits stored in i_data_b to bus with blue LEDs. More...
 

Detailed Description

Framebuffer for RGB LED cube 5x5x5.

Author
Martin Stejskal

Framebuffer display once image on LED cube. As parameter of framebuffer is
pointer to image in SRAM memory. Framebuffer disable global interrupt
however enable it when is needed some delay, so in this "time spaces" MCU
can to other stuff.

Definition in file framebuffer.h.

Macro Definition Documentation

#define framebuffer_copy_wall0_to_wall1
Value:
i_fb_data[1][0] = i_fb_data[0][0];\
i_fb_data[1][1] = i_fb_data[0][1];\
i_fb_data[1][2] = i_fb_data[0][2];\
i_fb_data[1][3] = i_fb_data[0][3];\
i_fb_data[1][4] = i_fb_data[0][4];

Copy data from WALL0 to WALL1.

Definition at line 100 of file framebuffer.h.

#define framebuffer_copy_wall1_to_wall2
Value:
i_fb_data[2][0] = i_fb_data[1][0];\
i_fb_data[2][1] = i_fb_data[1][1];\
i_fb_data[2][2] = i_fb_data[1][2];\
i_fb_data[2][3] = i_fb_data[1][3];\
i_fb_data[2][4] = i_fb_data[1][4];

Copy data from WALL1 to WALL2.

Definition at line 110 of file framebuffer.h.

#define framebuffer_copy_wall2_to_wall3
Value:
i_fb_data[3][0] = i_fb_data[2][0];\
i_fb_data[3][1] = i_fb_data[2][1];\
i_fb_data[3][2] = i_fb_data[2][2];\
i_fb_data[3][3] = i_fb_data[2][3];\
i_fb_data[3][4] = i_fb_data[2][4];

Copy data from WALL2 to WALL3.

Definition at line 120 of file framebuffer.h.

#define framebuffer_copy_wall3_to_wall4
Value:
i_fb_data[4][0] = i_fb_data[3][0];\
i_fb_data[4][1] = i_fb_data[3][1];\
i_fb_data[4][2] = i_fb_data[3][2];\
i_fb_data[4][3] = i_fb_data[3][3];\
i_fb_data[4][4] = i_fb_data[3][4];

Copy data from WALL3 to WALL4.

Definition at line 130 of file framebuffer.h.

#define framebuffer_wall0_ones
Value:
i_fb_data[0][0] = i_fb_data[0][1] =\
i_fb_data[0][2] = i_fb_data[0][3] = i_fb_data[0][4] = 0x7FFF;

Turn on all LED in WALL0.

Definition at line 68 of file framebuffer.h.

#define framebuffer_wall0_void
Value:
i_fb_data[0][0] = i_fb_data[0][1] =\
i_fb_data[0][2] = i_fb_data[0][3] = i_fb_data[0][4] = 0;

Turn off all LED in WALL0.

Definition at line 35 of file framebuffer.h.

#define framebuffer_wall1_ones
Value:
i_fb_data[1][0] = i_fb_data[1][1] =\
i_fb_data[1][2] = i_fb_data[1][3] = i_fb_data[1][4] = 0x7FFF;

Turn on all LED in WALL1.

Definition at line 74 of file framebuffer.h.

#define framebuffer_wall1_void
Value:
i_fb_data[1][0] = i_fb_data[1][1] =\
i_fb_data[1][2] = i_fb_data[1][3] = i_fb_data[1][4] = 0;

Turn off all LED in WALL1.

Definition at line 41 of file framebuffer.h.

#define framebuffer_wall2_ones
Value:
i_fb_data[2][0] = i_fb_data[2][1] =\
i_fb_data[2][2] = i_fb_data[2][3] = i_fb_data[2][4] = 0x7FFF;

Turn on all LED in WALL2.

Definition at line 80 of file framebuffer.h.

#define framebuffer_wall2_void
Value:
i_fb_data[2][0] = i_fb_data[2][1] =\
i_fb_data[2][2] = i_fb_data[2][3] = i_fb_data[2][4] = 0;

Turn off all LED in WALL2.

Definition at line 47 of file framebuffer.h.

#define framebuffer_wall3_ones
Value:
i_fb_data[3][0] = i_fb_data[3][1] =\
i_fb_data[3][2] = i_fb_data[3][3] = i_fb_data[3][4] = 0x7FFF;

Turn on all LED in WALL3.

Definition at line 86 of file framebuffer.h.

#define framebuffer_wall3_void
Value:
i_fb_data[3][0] = i_fb_data[3][1] =\
i_fb_data[3][2] = i_fb_data[3][3] = i_fb_data[3][4] = 0;

Turn off all LED in WALL3.

Definition at line 53 of file framebuffer.h.

#define framebuffer_wall4_ones
Value:
i_fb_data[4][0] = i_fb_data[4][1] =\
i_fb_data[4][2] = i_fb_data[4][3] = i_fb_data[4][4] = 0x7FFF;

Turn on all LED in WALL4.

Definition at line 92 of file framebuffer.h.

#define framebuffer_wall4_void
Value:
i_fb_data[4][0] = i_fb_data[4][1] =\
i_fb_data[4][2] = i_fb_data[4][3] = i_fb_data[4][4] = 0;

Turn off all LED in WALL4.

Definition at line 59 of file framebuffer.h.

Function Documentation

void framebuffer ( volatile uint16_t(*)  p_fb_data[5][5])

Frame buffer use pointer to array with data, witch represents one 3D image.

This function display data pointed to array p_fb_data[][] to LED cube. Whole function must run in infinite loop, else just once image will be showed (for very short time). And because of multiplex, LEDs have to been "refreshed"

Parameters
p_fb_dataPointer to frame buffer. First index is for "wall", second is for "column". Size of every "column" is 16 bits. MSB bit (highest LED in "column") is always "first". LSB bit (lowest one) is "last".
|MSB| |LSB|MSB| |LSB|MSB| |LSB|
+—+—+—+—+—+—+—+—+—+—+—+—+—+—+—+—+
| X | R | R | R | R | R | G | G | G | G | G | B | B | B | B | B |
+—+—+—+—+—+—+—+—+—+—+—+—+—+—+—+—+
Todo:
Timer instead loop

Definition at line 18 of file framebuffer.c.

void init_framebuffer ( void  )

Set I/O for framebuffer to defaults.

Set only pins, that framebuffer controls

Definition at line 73 of file framebuffer.c.

void load_DATA_BLUE_on_bus ( uint8_t  i_data_b)
inline

Load bits stored in i_data_b to bus with blue LEDs.

LSB is represent lowest blue diode in column

Parameters
i_data_bBinary data for blue color

Definition at line 359 of file framebuffer.c.

void load_DATA_GREEN_on_bus ( uint8_t  i_data_g)
inline

Load bits stored in i_data_g to bus with green LEDs.

LSB is represent lowest green diode in column

Parameters
i_data_gBinary data for green color

Definition at line 302 of file framebuffer.c.

void load_DATA_RED_on_bus ( uint8_t  i_data_r)
inline

Load bits stored in i_data_r to bus with red LEDs.

LSB is represent lowest red diode in column

Parameters
i_data_rBinary data for red color

Definition at line 245 of file framebuffer.c.

void set_active_column ( uint8_t  i_column_number)
inline

According parameter set active "column".

If input parameter is out of HW limit, then none "column" is activated

Parameters
i_column_numberColumn number 0~5

Definition at line 193 of file framebuffer.c.

void set_active_wall ( uint8_t  i_wall_number)
inline

According parameter set active "wall".

If input parameter is out of HW limit, then none "wall" is activated

Parameters
i_wall_numberWall number - 0~5

Definition at line 141 of file framebuffer.c.