Added Ham band coloring

pull/8/head
erikkaashoek 5 years ago
parent 28b6712338
commit bf6accf142

@ -851,6 +851,7 @@ config_t config = {
.magic = CONFIG_MAGIC,
.dac_value = 1922,
.grid_color = DEFAULT_GRID_COLOR,
.ham_color = DEFAULT_HAM_COLOR,
.menu_normal_color = DEFAULT_MENU_COLOR,
.menu_active_color = DEFAULT_MENU_ACTIVE_COLOR,
.trace_color = { DEFAULT_TRACE_1_COLOR, DEFAULT_TRACE_2_COLOR, DEFAULT_TRACE_3_COLOR},

@ -35,7 +35,7 @@
#define __SELFTEST__
#define __CALIBRATE__
#define __FAST_SWEEP__ // Pre-fill SI4432 RSSI buffer to get fastest sweep in zero span mode
#define __HAM_BAND__
//#define __ULTRA__ // Add harmonics mode on low input.
//#define __ULTRA_SA__ // Adds ADF4351 control for extra high 1st IF stage
#define __SPUR__ // Does spur reduction by shifting IF
@ -451,6 +451,7 @@ typedef struct config {
uint32_t correction_frequency[CORRECTION_POINTS];
float correction_value[CORRECTION_POINTS];
uint32_t deviceid;
uint16_t ham_color;
// uint8_t _reserved[22];
uint32_t checksum;
} config_t;
@ -556,6 +557,7 @@ extern volatile uint8_t redraw_request;
#define DARK_GREY RGB565(140,140,140)
#define LIGHT_GREY RGB565(220,220,220)
#define DEFAULT_GRID_COLOR RGB565(128,128,128)
#define DEFAULT_HAM_COLOR RGB565(80,80,80)
#define DEFAULT_GRID_VALUE_COLOR RGB565(196,196,196)
#define DEFAULT_MENU_COLOR RGB565(255,255,255)
#define DEFAULT_MENU_TEXT_COLOR RGB565( 0, 0, 0)

@ -405,6 +405,49 @@ rectangular_grid(int x, int y)
}
#endif
#ifdef __HAM_BAND__
typedef const struct {
uint32_t start;
uint32_t stop;
} ham_bands_t;
const ham_bands_t ham_bands[] =
{
{135700, 137800},
{472000, 479000},
{1800000, 2000000},
{3500000, 3800000},
{5250000, 5450000},
{7000000, 7200000},
{10100000, 10150000},
{14000000, 14350000},
{18068000, 18168000},
{21000000, 21450000},
{24890000, 24990000},
{28000000, 29700000},
{50000000, 52000000},
{70000000, 70500000},
{144000000, 146000000}
};
int ham_band(int x) // Search which index in the frequency tabled matches with frequency f using actual_rbw
{
uint32_t f = frequencies[x];
int L = 0;
int R = (sizeof ham_bands)/sizeof(uint32_t) - 1;
while (L <= R) {
int m = (L + R) / 2;
if (ham_bands[m].stop < f)
L = m + 1;
else if (ham_bands[m].start > f)
R = m - 1;
else
return true; // index is m
}
return false;
}
#endif
static int
rectangular_grid_x(int x)
{
@ -847,7 +890,7 @@ trace_get_value_string_delta(int t, char *buf, int len, float array[POINTS_COUNT
extern const char *unit_string[];
void trace_get_value_string(
inline void trace_get_value_string( // Only used at one place
int t, char *buf, int len,
int i, float coeff[POINTS_COUNT],
int ri, int mtype,
@ -1515,6 +1558,11 @@ draw_cell(int m, int n)
// Draw rectangular plot (40 system ticks for all screen calls)
if (trace_type & RECTANGULAR_GRID_MASK) {
for (x = 0; x < w; x++) {
#ifdef __HAM_BAND__
if (ham_band(x+x0)) {
for (y = 0; y < h; y++) cell_buffer[y * CELLWIDTH + x] = config.ham_color;
}
#endif
if (rectangular_grid_x(x + x0)) {
for (y = 0; y < h; y++) cell_buffer[y * CELLWIDTH + x] = c;
}

Loading…
Cancel
Save

Powered by TurnKey Linux.