From fb44b7d2a352f399c0e65a7ce4018c1fc186c6d6 Mon Sep 17 00:00:00 2001 From: DiSlord Date: Wed, 24 Jun 2020 13:36:41 +0300 Subject: [PATCH] Allow more better define waterfall_palette size and use --- plot.c | 7 +++++-- waterfall.c | 7 ++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/plot.c b/plot.c index 8b7c120..b93580f 100644 --- a/plot.c +++ b/plot.c @@ -2180,6 +2180,7 @@ redraw_frame(void) draw_cal_status(); } +//#define _USE_WATERFALL_PALETTE #ifdef _USE_WATERFALL_PALETTE #include "waterfall.c" #endif @@ -2194,11 +2195,12 @@ static void update_waterfall(void){ index_t *index = trace_index[TRACE_ACTUAL]; for (i=0; i< w_width; i++) { // Add new topline uint16_t color; - uint16_t y = CELL_Y(index[i]); // should be always in range 0 - HEIGHT_SCROLL #ifdef _USE_WATERFALL_PALETTE + uint16_t y = _PALETTE_ALIGN(CELL_Y(index[i])); // should be always in range 0 - HEIGHT_SCROLL // y = (uint8_t)i; // for test - color = paltte[y]; + color = waterfall_palette[y]; #elif 0 + uint16_t y = CELL_Y(index[i]); // should be always in range 0 - HEIGHT_SCROLL uint16_t ratio = (HEIGHT_SCROLL - y)*2; // ratio = (i*2); // Uncomment for testing the waterfall colors int16_t b = 255 - ratio; @@ -2214,6 +2216,7 @@ static void update_waterfall(void){ gamma_correct(b); color = RGB565(r, g, b); #else + uint16_t y = CELL_Y(index[i]); // should be always in range 0 - HEIGHT_SCROLL // Calculate gradient palette for range 0 .. 192 // idx r g b // 0 - 192 0 0 diff --git a/waterfall.c b/waterfall.c index d0da63d..af7b6f8 100644 --- a/waterfall.c +++ b/waterfall.c @@ -20,7 +20,8 @@ // Test palette for waterfall // Possibly better use size = HEIGHT_SCROLL / 2 for more compact and allow use on different displays // And build table for every display size -static const uint16_t palette[256] = { +#define _PALETTE_ALIGN(idx) ((idx)>>0) +static const uint16_t waterfall_palette[] = { RGB565(0xBA,0x01,0x00), RGB565(0xBA,0x01,0x00), RGB565(0xB9,0x01,0x00), @@ -277,5 +278,5 @@ RGB565(0x01,0x00,0x89), RGB565(0x01,0x00,0x8A), RGB565(0x00,0x00,0x87), RGB565(0x00,0x00,0x83), -RGB565(0x00,0x00,0x84), -}; \ No newline at end of file +RGB565(0x00,0x00,0x84) +};