====== 11. Cvičení: Práce na projektu ======
Obsahem cvičení je samostatná práce na projektu a konzultace (projektu, témat z přednášek...).
Studenti z probíhajícího cvičení mají přednostní přístup k deskám.
===== Ukázka animace textu na LCD =====
**flying_letters.c:**
/*******************************************************************
Project main function template for MicroZed based MZ_APO board
designed by Petr Porazil at PiKRON
include your name there and license for distribution.
Remove next text: This line should not appear in submitted
work and project name should be change to match real application.
If this text is there I want 10 points subtracted from final
evaluation.
*******************************************************************/
#define _POSIX_C_SOURCE 200112L
#include
#include
#include
#include
#include
#include
#include "mzapo_parlcd.h"
#include "mzapo_phys.h"
#include "mzapo_regs.h"
#include "font_types.h"
#define M_PI 3.1415
unsigned int hsv2rgb_lcd(int hue, int saturation, int value) {
hue = (hue%360);
float f = ((hue%60)/60.0);
int p = (value*(255-saturation))/255;
int q = (value*(255-(saturation*f)))/255;
int t = (value*(255-(saturation*(1.0-f))))/255;
unsigned int r,g,b;
if (hue < 60){
r = value; g = t; b = p;
} else if (hue < 120) {
r = q; g = value; b = p;
} else if (hue < 180) {
r = p; g = value; b = t;
} else if (hue < 240) {
r = p; g = q; b = value;
} else if (hue < 300) {
r = t; g = p; b = value;
} else {
r = value; g = p; b = q;
}
r>>=3;
g>>=2;
b>>=3;
return (((r&0x1f)<<11)|((g&0x3f)<<5)|(b&0x1f));
}
unsigned short fb[320*480*2];
font_descriptor_t *fdes;
int scale=4;
void draw_pixel(int x, int y, unsigned short color) {
if (x>=0 && x<480 && y>=0 && y<320) {
fb[x+480*y] = color;
}
}
void draw_pixel_big(int x, int y, unsigned short color) {
int i,j;
for (i=0; iwidth) {
width = fdes->maxwidth;
} else {
width = fdes->width[ch-fdes->firstchar];
}
return width;
}
void draw_char(int x, int y, char ch, unsigned short color) {
int w = char_width(ch);
const font_bits_t *ptr;
if ((ch >= fdes->firstchar) && (ch-fdes->firstchar < fdes->size)) {
if (fdes->offset) {
ptr = &fdes->bits[fdes->offset[ch-fdes->firstchar]];
} else {
int bw = (fdes->maxwidth+15)/16;
ptr = &fdes->bits[(ch-fdes->firstchar)*bw*fdes->height];
}
int i, j;
for (i=0; iheight; i++) {
font_bits_t val = *ptr;
for (j=0; j0)) {
for (ptr = 0; ptr < 320*480 ; ptr++) {
fb[ptr]=0;
}
draw_char((int)x,250-(int)y, ch, col);
x+=vx;
y+=vy;
vx = vx*0.97;
vy = vy*0.97-g;
parlcd_write_cmd(parlcd_mem_base, 0x2c);
for (ptr = 0; ptr < 480*320 ; ptr++) {
parlcd_write_data(parlcd_mem_base, fb[ptr]);
}
clock_nanosleep(CLOCK_MONOTONIC, 0, &loop_delay, NULL);
}
}
ptr=0;
parlcd_write_cmd(parlcd_mem_base, 0x2c);
for (i = 0; i < 320 ; i++) {
for (j = 0; j < 480 ; j++) {
fb[ptr]=0;
parlcd_write_data(parlcd_mem_base, fb[ptr++]);
}
}
printf("Goodbye\n");
return 0;
}