RGB LED cube 5x5x5
1.0
Martin Stejskal, Schmidt Dominik
|
Main file for RGB LED cube 5x5x5. More...
#include <avr/io.h>
#include <inttypes.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include "settings.h"
#include <util/delay.h>
#include "bit_operations.h"
#include "framebuffer.h"
#include "pwm_rgb.h"
#include "animation_codes.h"
#include "anim_snake.h"
Go to the source code of this file.
Functions | |
void | set_io_to_defaults (void) |
Set I/O to defaults. More... | |
void | init_animation_counter (void) |
Initialize Timer2 for interrupt, witch use animation function. More... | |
void | animation_process_word (uint16_t i_tmp, uint8_t *p_framebuffer_cnt) |
Process loaded word to "i_tmp" and if needed save data to framebuffer, or proceed special commands. More... | |
ISR (TIMER2_COMP_vect) | |
Function for animation process. More... | |
int | main (void) |
Main function. More... | |
Variables | |
volatile uint16_t | i_fb_data [5][5] |
Framebuffer for 1 image, that is displayed. More... | |
volatile uint8_t | i_stat_cfg_anime = 0b00000000 |
Status and configuration variable for animation process. More... | |
volatile uint16_t * | p_anime = 0 |
Pointer for animation process. More... | |
volatile uint8_t | anime_slowdown_factor = 1 |
Slowdown factor for animation. More... | |
volatile uint8_t | anime_slowdown_counter = 1 |
Counter for slowdown factor. More... | |
Main file for RGB LED cube 5x5x5.
Definition in file rgb_led_cube_5x5x5.c.
|
inline |
Process loaded word to "i_tmp" and if needed save data to
framebuffer, or proceed special commands.
i_tmp | Loaded word (16 bit) from memory (Flash or SRAM) |
i_framebuffer_cnt | Counter for framebuffer. It counts how many words were written to framebuffer |
Definition at line 397 of file rgb_led_cube_5x5x5.c.
void init_animation_counter | ( | void | ) |
Initialize Timer2 for interrupt, witch use animation function.
Set timer2 to CTC mode and set interrupt time to approximately 10 ms
Definition at line 371 of file rgb_led_cube_5x5x5.c.
ISR | ( | TIMER2_COMP_vect | ) |
Function for animation process.
Approximately every 10 ms is called this interrupt. Every 40 ms (every
fourth time) this function increase pointer value and read another image.
If animation is at the end, then is wait for a "new pointer" and show last
image in buffer. Use timer2, because interrupt priority is one of the first.
Definition at line 147 of file rgb_led_cube_5x5x5.c.
int main | ( | void | ) |
Main function.
Initialization of functions
Show content of i_fb_data in infinite loop
Definition at line 258 of file rgb_led_cube_5x5x5.c.
void set_io_to_defaults | ( | void | ) |
Set I/O to defaults.
Prepare all pins to default state. This function first set all pins
to Hi-Z and then set I/O
Definition at line 296 of file rgb_led_cube_5x5x5.c.
volatile uint8_t anime_slowdown_counter = 1 |
Counter for slowdown factor.
Internal variable. Value is increased every 40 ms and set to 1 when
anime_slowdown_factor == anime_slowdown_counter. Should not be changed by
user.
Definition at line 125 of file rgb_led_cube_5x5x5.c.
volatile uint8_t anime_slowdown_factor = 1 |
Slowdown factor for animation.
Every 40 ms is possible load new frame -> 25 fps. However, sometimes it is
too short time, so it is possible make animation slower. If is set to 1,
then every 40 ms is load new frame. If is set to 2, then every 80 ms is
loaded new frame and so on. This value can be changed any time during
animation (Should be part of animation code).
Definition at line 116 of file rgb_led_cube_5x5x5.c.
volatile uint16_t i_fb_data[5][5] |
Framebuffer for 1 image, that is displayed.
Define frame buffer - buffer size: 16bits -> 3 colors x 5 led in
column -> 5 columns in one wall -> 5x16bits -> 5 walls -> 5x5x16bits
First index is for "wall" (0~4) and second is for "column" (0~4).
Must be global and volatile, because it is used also by interrupts.
Definition at line 63 of file rgb_led_cube_5x5x5.c.
volatile uint8_t i_stat_cfg_anime = 0b00000000 |
Status and configuration variable for animation process.
Bit meaning:
7 (MSB) - Animation is running (1 - running ; 0 - not running)
Named as: anim_run
6 - request for change animation (pointer is updated)
Named as: anim_change 5 - random - If activated, the all command are ignored and just dummy read 4 3 - counter[1] - phase of animation waiting process (0~3 - if 3 -> change
image)
Named as: anim_cnt1
2 - counter[0] Named as: anim_cnt0
1 - Data on SRAM valid
Named as: anim_SRAM_valid
0 - Data are stored in FLASH (if 1, else data are stored in SRAM - 0)
Named as: anim_read_FLASH
Definition at line 96 of file rgb_led_cube_5x5x5.c.
volatile uint16_t* p_anime = 0 |
Pointer for animation process.
To this pointer is stored SRAM or FLASH address, where are data stored.
16 bit pointer should be enough.
Definition at line 104 of file rgb_led_cube_5x5x5.c.