#include "image_patterns.h" #include "frame_buffer_control.h" #include "waveform_patterns.h" #include "motion_patterns.h" #include "ram.h" // private variables unsigned char img_pattern_data[IMG_MAX_NUM_IMAGES][IMG_MAX_IMAGE_HEIGHT][IMG_MAX_IMAGE_WIDTH][3]={{{{0}}}}; // private functions void img_patterns_compute_range(unsigned short int area_min,unsigned short int area_max,short int pattern_start,unsigned short int max_size,unsigned short int *buff_start, unsigned short int *buff_end,unsigned char *img_start) { unsigned short int cp_size; if(pattern_start<0) { *buff_start=area_min; *img_start=-pattern_start; if((-pattern_start)(area_max-area_min)) { *buff_start=0; *img_start=0; cp_size=0; } else { *buff_start=area_min+pattern_start; *img_start=0; cp_size=max_size-1; } if(*buff_start+cp_size>area_max) { *buff_end=area_max; cp_size-=(*buff_start+cp_size-area_max); } else *buff_end=*buff_start+cp_size; } // public functions void img_patterns_init(TMemory *memory,unsigned short int ram_base_address) { //initialize internal variables (read only variables) memory->data[ram_base_address+FRAME_BUFFER_CONTROL_IMG_MAX_WIDTH_OFFSET]=IMG_MAX_IMAGE_WIDTH; memory->data[ram_base_address+FRAME_BUFFER_CONTROL_IMG_MAX_HEIGHT_OFFSET]=IMG_MAX_IMAGE_HEIGHT; memory->data[ram_base_address+FRAME_BUFFER_CONTROL_IMG_NUM_IMGS_OFFSET]=IMG_MAX_NUM_IMAGES; } void img_general(TLEDArea *area,TIMGDisplayData *pattern_data,unsigned char buffer_id,unsigned short int period,TFBControl *control) { unsigned short int buff_row=0,buff_col=0,img_row=0,img_col=0; unsigned short int buff_start_row=0,buff_end_row=0,buff_start_col=0,buff_end_col=0; unsigned char img_start_row=0,img_start_col=0; short int row_offset,col_offset; TWaveform *waveform; TMotion *motion; TPixelRGB pixel; // execute motion if(pattern_data->motion_index!=0xFF) { motion=(TMotion *)frame_buffer_control_get_parameters(control,pattern_data->motion_index); mtn_compute(motion); col_offset=motion->current_col; row_offset=motion->current_row; } else { col_offset=0; row_offset=0; } // compute displayed area img_patterns_compute_range(area->min_row,area->max_row,row_offset,IMG_MAX_IMAGE_HEIGHT,&buff_start_row,&buff_end_row,&img_start_row); img_patterns_compute_range(area->min_col,area->max_col,col_offset,IMG_MAX_IMAGE_WIDTH,&buff_start_col,&buff_end_col,&img_start_col); // execute waveform for(buff_row=buff_start_row,img_row=img_start_row;buff_row<=buff_end_row;buff_row++,img_row++) for(buff_col=buff_start_col,img_col=img_start_col;buff_col<=buff_end_col;buff_col++,img_col++) { if(pattern_data->waveform_index!=0xFF) { waveform=(TWaveform *)frame_buffer_control_get_parameters(control,pattern_data->waveform_index); waveform->max.R=img_pattern_data[pattern_data->buffer_id][img_row][img_col][0]; waveform->max.G=img_pattern_data[pattern_data->buffer_id][img_row][img_col][1]; waveform->max.B=img_pattern_data[pattern_data->buffer_id][img_row][img_col][2]; pixel=wf_pixel(waveform); } else { pixel.R=img_pattern_data[pattern_data->buffer_id][img_row][img_col][0]; pixel.G=img_pattern_data[pattern_data->buffer_id][img_row][img_col][1]; pixel.B=img_pattern_data[pattern_data->buffer_id][img_row][img_col][2]; } frame_buffer_set_pixel(&control->frame_buffer,buffer_id,pixel.R,pixel.G,pixel.B,buff_row,buff_col); } }