Add radar sweep background pattern
This commit is contained in:
parent
04759ec9df
commit
e3f23a1427
74
src/main.cpp
74
src/main.cpp
|
@ -104,6 +104,23 @@ void render_drot_border(int8_t x_width, uint16_t text_color, uint16_t border_col
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (x = 0; x < x_width; x++) {
|
||||
is_color = 0;
|
||||
for (y = 0; y < ROT_SIZE; y++) {
|
||||
if (is_color) {
|
||||
if (src[x + (y * ROT_SIZE)] != text_color) {
|
||||
is_color = 0;
|
||||
src[x + (y * ROT_SIZE)] = border_color;
|
||||
}
|
||||
} else {
|
||||
if (src[x + (y * ROT_SIZE)] == text_color) {
|
||||
is_color = 1;
|
||||
src[x + (y * ROT_SIZE) - ROT_SIZE] = border_color;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void render_drot_rotate(int16_t x_width, int16_t rot, int16_t out_x, int16_t out_y)
|
||||
|
@ -147,7 +164,7 @@ void render_drot_rotate(int16_t x_width, int16_t rot, int16_t out_x, int16_t out
|
|||
}
|
||||
}
|
||||
|
||||
void text_print_circular(const char *str, uint8_t text_size, int16_t spacing, uint16_t color, int16_t rot)
|
||||
void text_print_circular(const char *str, uint8_t text_size, int16_t spacing, uint16_t fcolor, uint16_t bcolor, int16_t rot)
|
||||
{
|
||||
uint8_t i;
|
||||
int16_t x_width;
|
||||
|
@ -165,14 +182,15 @@ void text_print_circular(const char *str, uint8_t text_size, int16_t spacing, ui
|
|||
y = sin1(rot);
|
||||
y = (y >> 9) + (y >> 11) + (y >> 12);
|
||||
|
||||
x_width = render_drot_printchar(str, i, text_size, color); // render character
|
||||
render_drot_border(x_width, color, TEXT_BORDER_COLOR); // add border to character
|
||||
x_width = render_drot_printchar(str, i, text_size, fcolor); // render character
|
||||
render_drot_border(x_width, fcolor, bcolor); // add border to character
|
||||
render_drot_rotate(x_width, rot + 0x6000, x, y);
|
||||
rot -= spacing;
|
||||
}
|
||||
}
|
||||
|
||||
int16_t rot = 0;
|
||||
int16_t trot = 0;
|
||||
int16_t brot = 0;
|
||||
|
||||
#define HUE_MIN 0x2000-300
|
||||
#define HUE_MAX 0x2000+300
|
||||
|
@ -250,6 +268,39 @@ void bg_rainbow_circles(uint8_t saturation)
|
|||
}
|
||||
}
|
||||
|
||||
void bg_radarsweep(int16_t rot, int16_t offset, uint8_t lines)
|
||||
{
|
||||
color_rgb rgb;
|
||||
uint16_t w;
|
||||
|
||||
int16_t x, y;
|
||||
|
||||
if (lines == 0xff) lines--;
|
||||
|
||||
dout->fillScreen(BLACK);
|
||||
|
||||
for (uint8_t i = 0; i < lines; i++) {
|
||||
// linear fade
|
||||
w = 256 * lines;
|
||||
w -= (256 * i);
|
||||
w /= lines;
|
||||
w &= 0xff;
|
||||
|
||||
// todo: exponential fade or something
|
||||
|
||||
// get rotational point
|
||||
x = cos1(rot);
|
||||
x = (x >> 8);
|
||||
|
||||
y = sin1(rot);
|
||||
y = (y >> 8);
|
||||
|
||||
hsv2rgb_8b((1536/3), 200, (i > 4) ? (w >> 1) : w, &rgb.r, &rgb.g, &rgb.b);
|
||||
dout->drawLine(x + 120, y + 120, 128, 128, dout->color565(rgb.r, rgb.g, rgb.b));
|
||||
rot -= offset;
|
||||
}
|
||||
}
|
||||
|
||||
void texthue_180degree()
|
||||
{
|
||||
uint16_t hue;
|
||||
|
@ -272,19 +323,26 @@ void texthue_huesatcycle_circles()
|
|||
void loop()
|
||||
{
|
||||
uint16_t hue;
|
||||
color_rgb fc, bc;
|
||||
|
||||
// rainbow circles program
|
||||
bg_rainbow_circles(200);
|
||||
// bg_rainbow_circles(200);
|
||||
// texthue_180degree();
|
||||
brot += 400;
|
||||
bg_radarsweep(brot, 25, 200);
|
||||
|
||||
// small hue shift with larger saturation shifts circles
|
||||
// bg_huesatcycle_circles();
|
||||
// texthue_huesatcycle();
|
||||
|
||||
// text rotation - black text, default border
|
||||
rot += 420 - 69;
|
||||
rgb.r = rgb.g = rgb.b = 0;
|
||||
text_print_circular(name, TEXT_MAX_SIZE, LETTER_SPACING, dout->color565(rgb.r, rgb.g, rgb.b), rot);
|
||||
trot += 420 - 69;
|
||||
fc.r = fc.g = fc.b = 240;
|
||||
bc.r = bc.g = bc.b = 32;
|
||||
text_print_circular(name, TEXT_MAX_SIZE, LETTER_SPACING,
|
||||
dout->color565(fc.r, fc.g, fc.b),
|
||||
dout->color565(bc.r, bc.g, bc.b),
|
||||
trot);
|
||||
|
||||
dout->flush();
|
||||
}
|
24
src/sin1.c
24
src/sin1.c
|
@ -22,7 +22,7 @@
|
|||
* "5 bit" large table = 32 values. The mask: all bit belonging to the table
|
||||
* are 1, the all above 0.
|
||||
*/
|
||||
#define TABLE_BITS (5)
|
||||
#define TABLE_BITS (7)
|
||||
#define TABLE_SIZE (1<<TABLE_BITS)
|
||||
#define TABLE_MASK (TABLE_SIZE-1)
|
||||
|
||||
|
@ -43,13 +43,25 @@
|
|||
* at 0deg, 11.25deg, 22.5deg etc. The values are from -1 to 1 in Q15.
|
||||
*/
|
||||
static int16_t sin90[TABLE_SIZE+1] = {
|
||||
0x0000,0x0647,0x0c8b,0x12c7,0x18f8,0x1f19,0x2527,0x2b1e,
|
||||
0x30fb,0x36b9,0x3c56,0x41cd,0x471c,0x4c3f,0x5133,0x55f4,
|
||||
0x5a81,0x5ed6,0x62f1,0x66ce,0x6a6c,0x6dc9,0x70e1,0x73b5,
|
||||
0x7640,0x7883,0x7a7c,0x7c29,0x7d89,0x7e9c,0x7f61,0x7fd7,
|
||||
0x0000,0x0192,0x0324,0x04b6,0x0647,0x07d9,0x096a,0x0afb,
|
||||
0x0c8b,0x0e1b,0x0fab,0x1139,0x12c7,0x1455,0x15e1,0x176d,
|
||||
0x18f8,0x1a82,0x1c0b,0x1d93,0x1f19,0x209f,0x2223,0x23a6,
|
||||
0x2527,0x26a7,0x2826,0x29a3,0x2b1e,0x2c98,0x2e10,0x2f86,
|
||||
0x30fb,0x326d,0x33de,0x354d,0x36b9,0x3824,0x398c,0x3af2,
|
||||
0x3c56,0x3db7,0x3f16,0x4073,0x41cd,0x4325,0x447a,0x45cc,
|
||||
0x471c,0x4869,0x49b3,0x4afa,0x4c3f,0x4d80,0x4ebf,0x4ffa,
|
||||
0x5133,0x5268,0x539a,0x54c9,0x55f4,0x571d,0x5842,0x5963,
|
||||
0x5a81,0x5b9c,0x5cb3,0x5dc6,0x5ed6,0x5fe2,0x60eb,0x61f0,
|
||||
0x62f1,0x63ee,0x64e7,0x65dd,0x66ce,0x67bc,0x68a5,0x698b,
|
||||
0x6a6c,0x6b4a,0x6c23,0x6cf8,0x6dc9,0x6e95,0x6f5e,0x7022,
|
||||
0x70e1,0x719d,0x7254,0x7306,0x73b5,0x745e,0x7503,0x75a4,
|
||||
0x7640,0x76d8,0x776b,0x77f9,0x7883,0x7908,0x7989,0x7a04,
|
||||
0x7a7c,0x7aee,0x7b5c,0x7bc4,0x7c29,0x7c88,0x7ce2,0x7d38,
|
||||
0x7d89,0x7dd5,0x7e1c,0x7e5e,0x7e9c,0x7ed4,0x7f08,0x7f37,
|
||||
0x7f61,0x7f86,0x7fa6,0x7fc1,0x7fd7,0x7fe8,0x7ff5,0x7ffc,
|
||||
0x7fff
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Sine calculation using interpolated table lookup.
|
||||
* Instead of radiants or degrees we use "turns" here. Means this
|
||||
|
|
Loading…
Reference in New Issue