Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/ttrftech/NanoVNA
Browse files Browse the repository at this point in the history
  • Loading branch information
reald committed Dec 10, 2019
2 parents 9fb936e + 6a88f8e commit 1081bf7
Show file tree
Hide file tree
Showing 8 changed files with 156 additions and 197 deletions.
166 changes: 60 additions & 106 deletions Font8x8.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,112 +110,60 @@ const uint8_t x8x8_bits[][8]={



const uint8_t x8x8_len[] = {
1, /* nul */
6, /* delta */
5, /* multiline marker */
6, /* arrow left */
6, /* arrow right */
8, /* pi */
8, /* micro */
8, /* omega */
6, /* degree */
4, /* 0x20 ' ' */
5, /* 0x21 '!' */
6, /* 0x22 '"' */
8, /* 0x23 '#' */
7, /* 0x24 '$' */
8, /* 0x25 '%' */
8, /* 0x26 '&' */
4, /* 0x27 ''' */
5, /* 0x28 '(' */
5, /* 0x29 ')' */
9, /* 0x2A '*' */
7, /* 0x2B '+' */
4, /* 0x2C ',' */
7, /* 0x2D '-' */
3, /* 0x2E '.' */
8, /* 0x2F '/' */
7, /* 0x30 '0' */
7, /* 0x31 '1' */
7, /* 0x32 '2' */
7, /* 0x33 '3' */
8, /* 0x34 '4' */
7, /* 0x35 '5' */
7, /* 0x36 '6' */
7, /* 0x37 '7' */
7, /* 0x38 '8' */
7, /* 0x39 '9' */
3, /* 0x3A ':' */
4, /* 0x3B ';' */
6, /* 0x3C '<' */
7, /* 0x3D '=' */
6, /* 0x3E '>' */
7, /* 0x3F '?' */
8, /* 0x40 '@' */
7, /* 0x41 'A' */
8, /* 0x42 'B' */
8, /* 0x43 'C' */
8, /* 0x44 'D' */
8, /* 0x45 'E' */
8, /* 0x46 'F' */
8, /* 0x47 'G' */
7, /* 0x48 'H' */
5, /* 0x49 'I' */
8, /* 0x4A 'J' */
8, /* 0x4B 'K' */
8, /* 0x4C 'L' */
8, /* 0x4D 'M' */
8, /* 0x4E 'N' */
8, /* 0x4F 'O' */
8, /* 0x50 'P' */
7, /* 0x51 'Q' */
8, /* 0x52 'R' */
7, /* 0x53 'S' */
7, /* 0x54 'T' */
7, /* 0x55 'U' */
7, /* 0x56 'V' */
8, /* 0x57 'W' */
8, /* 0x58 'X' */
7, /* 0x59 'Y' */
8, /* 0x5A 'Z' */
5, /* 0x5B '[' */
8, /* 0x5C '\' */
5, /* 0x5D ']' */
8, /* 0x5E '^' */
9, /* 0x5F '_' */
4, /* 0x60 '`' */
8, /* 0x61 'a' */
8, /* 0x62 'b' */
7, /* 0x63 'c' */
8, /* 0x64 'd' */
7, /* 0x65 'e' */
7, /* 0x66 'f' */
8, /* 0x67 'g' */
8, /* 0x68 'h' */
5, /* 0x69 'i' */
6, /* 0x6A 'j' */
8, /* 0x6B 'k' */
5, /* 0x6C 'l' */
8, /* 0x6D 'm' */
7, /* 0x6E 'n' */
7, /* 0x6F 'o' */
8, /* 0x70 'p' */
8, /* 0x71 'q' */
7, /* 0x72 'r' */
7, /* 0x73 's' */
6, /* 0x74 't' */
8, /* 0x75 'u' */
7, /* 0x76 'v' */
8, /* 0x77 'w' */
8, /* 0x78 'x' */
7, /* 0x79 'y' */
7, /* 0x7A 'z' */
7, /* 0x7B '{' */
3, /* 0x7C '|' */
7, /* 0x7D '}' */
8, /* 0x7E '~' */
8, /* 0x7F '' */
static const uint8_t x8x8_len[] = {
1 /* nul */ | 6<<4, /* delta */
5 /* multil. */ | 6<<4, /* left */
6 /* right */ | 8<<4, /* pi */
8 /* micro */ | 8<<4, /* omega */
6 /* degree */ | 4<<4, /* 0x20 ' ' */
5 /* 0x21 '!' */ | 6<<4, /* 0x22 '"' */
8 /* 0x23 '#' */ | 7<<4, /* 0x24 '$' */
8 /* 0x25 '%' */ | 8<<4, /* 0x26 '&' */
4 /* 0x27 ''' */ | 5<<4, /* 0x28 '(' */
5 /* 0x29 ')' */ | 9<<4, /* 0x2A '*' */
7 /* 0x2B '+' */ | 4<<4, /* 0x2C ',' */
7 /* 0x2D '-' */ | 3<<4, /* 0x2E '.' */
8 /* 0x2F '/' */ | 7<<4, /* 0x30 '0' */
7 /* 0x31 '1' */ | 7<<4, /* 0x32 '2' */
7 /* 0x33 '3' */ | 8<<4, /* 0x34 '4' */
7 /* 0x35 '5' */ | 7<<4, /* 0x36 '6' */
7 /* 0x37 '7' */ | 7<<4, /* 0x38 '8' */
7 /* 0x39 '9' */ | 3<<4, /* 0x3A ':' */
4 /* 0x3B ';' */ | 6<<4, /* 0x3C '<' */
7 /* 0x3D '=' */ | 6<<4, /* 0x3E '>' */
7 /* 0x3F '?' */ | 8<<4, /* 0x40 '@' */
7 /* 0x41 'A' */ | 8<<4, /* 0x42 'B' */
8 /* 0x43 'C' */ | 8<<4, /* 0x44 'D' */
8 /* 0x45 'E' */ | 8<<4, /* 0x46 'F' */
8 /* 0x47 'G' */ | 7<<4, /* 0x48 'H' */
5 /* 0x49 'I' */ | 8<<4, /* 0x4A 'J' */
8 /* 0x4B 'K' */ | 8<<4, /* 0x4C 'L' */
8 /* 0x4D 'M' */ | 8<<4, /* 0x4E 'N' */
8 /* 0x4F 'O' */ | 8<<4, /* 0x50 'P' */
7 /* 0x51 'Q' */ | 8<<4, /* 0x52 'R' */
7 /* 0x53 'S' */ | 7<<4, /* 0x54 'T' */
7 /* 0x55 'U' */ | 7<<4, /* 0x56 'V' */
8 /* 0x57 'W' */ | 8<<4, /* 0x58 'X' */
7 /* 0x59 'Y' */ | 8<<4, /* 0x5A 'Z' */
5 /* 0x5B '[' */ | 8<<4, /* 0x5C '\' */
5 /* 0x5D ']' */ | 8<<4, /* 0x5E '^' */
9 /* 0x5F '_' */ | 4<<4, /* 0x60 '`' */
8 /* 0x61 'a' */ | 8<<4, /* 0x62 'b' */
7 /* 0x63 'c' */ | 8<<4, /* 0x64 'd' */
7 /* 0x65 'e' */ | 7<<4, /* 0x66 'f' */
8 /* 0x67 'g' */ | 8<<4, /* 0x68 'h' */
5 /* 0x69 'i' */ | 6<<4, /* 0x6A 'j' */
8 /* 0x6B 'k' */ | 5<<4, /* 0x6C 'l' */
8 /* 0x6D 'm' */ | 7<<4, /* 0x6E 'n' */
7 /* 0x6F 'o' */ | 8<<4, /* 0x70 'p' */
8 /* 0x71 'q' */ | 7<<4, /* 0x72 'r' */
7 /* 0x73 's' */ | 6<<4, /* 0x74 't' */
8 /* 0x75 'u' */ | 7<<4, /* 0x76 'v' */
8 /* 0x77 'w' */ | 8<<4, /* 0x78 'x' */
7 /* 0x79 'y' */ | 7<<4, /* 0x7A 'z' */
7 /* 0x7B '{' */ | 3<<4, /* 0x7C '|' */
7 /* 0x7D '}' */ | 8<<4, /* 0x7E '~' */
8 /* 0x7F '' */ | 0<<4
};


Expand All @@ -240,3 +188,9 @@ uint8_t x8x8_map_char_table(uint8_t ch)
return ch;
}



uint8_t x8x8_get_len(uint8_t ch)
{
return (x8x8_len[ch/2] >> 4*(ch%2) ) & 0x0f;
}
2 changes: 1 addition & 1 deletion NANOVNA_STM32_F072/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*/
#define BOARD_NANOVNA_STM32_F072
#define BOARD_NAME "NanoVNA"
#define USER_CALL "My" /* add your name here */

/*
* Board frequencies.
*/
Expand Down
22 changes: 12 additions & 10 deletions ili9341.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,31 +337,33 @@ ili9341_read_memory_continue(int len, uint16_t* out)


unsigned char
ili9341_drawchar(uint8_t ch, int x, int y, uint16_t fg, uint16_t bg, uint8_t size, uint8_t var, uint8_t invert)
ili9341_drawchar(uint8_t ch, int x, int y, const uint16_t fg, const uint16_t bg, const uint8_t size, const uint8_t var, const uint8_t invert)
{
uint16_t *buf = spi_buffer;
uint16_t charwidthpx = 8 * size;

uint16_t cline;
uint32_t ccol;
uint8_t bits;
int cline, ccol;

ch = x8x8_map_char_table(ch);

if ( var != FALSE )
{
charwidthpx = x8x8_len[ch] * size;
charwidthpx = x8x8_get_len(ch) * size;
}

for(cline = 0; cline < 8*size; cline++)
for (cline = 0; cline < 8*size; cline++)
{
bits = x8x8_bits[ch][cline/size];

if (invert)
if (invert != FALSE)
bits = ~bits;

for (ccol = 0; ccol < charwidthpx; ccol++)
{
*buf++ = (0x80 & bits) ? fg : bg;
if (ccol % size == (size-1))
if ( (uint8_t)(ccol % size) == (size-1))
{
bits <<= 1;
}
Expand All @@ -375,7 +377,7 @@ ili9341_drawchar(uint8_t ch, int x, int y, uint16_t fg, uint16_t bg, uint8_t siz


unsigned int
ili9341_drawstring(const char *str, int x, int y, uint16_t fg, uint16_t bg, uint8_t size, uint8_t var, uint8_t invert)
ili9341_drawstring(const char *str, int x, int y, const uint16_t fg, const uint16_t bg, const uint8_t size, const uint8_t var, const uint8_t invert)
{
unsigned char clengthpx = 0;
unsigned int strwidthpx = 0;
Expand Down Expand Up @@ -462,8 +464,8 @@ ili9341_drawfont(uint8_t ch, const font_t *font, int x, int y, uint16_t fg, uint

#if 0
const uint16_t colormap[] = {
RGB565(255,0,0), RGB565(0,255,0), RGB565(0,0,255),
RGB565(255,255,0), RGB565(0,255,255), RGB565(255,0,255)
RGB_565(0,0,255), RGB_565(255,0,0), RGB_565(0,255,0),
RGB_565(255,0,255), RGB_565(255,255,0), RGB_565(0,255,255)
};

void
Expand All @@ -476,7 +478,7 @@ ili9341_test(int mode)
#if 1
ili9341_fill(0, 0, 320, 240, 0);
for (y = 0; y < 240; y++) {
ili9341_fill(0, y, 320, 1, RGB565(y, (y + 120) % 256, 240-y));
ili9341_fill(0, y, 320, 1, RGB_565((y + 120) % 256, 240-y, y));
}
break;
case 1:
Expand Down
7 changes: 2 additions & 5 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@
static void apply_error_term_at(int i);
static void apply_edelay_at(int i);
static void cal_interpolate(int s);
static void set_frequencies(uint32_t start, uint32_t stop, int16_t points);
static void update_frequencies(void);

static void set_frequencies(uint32_t start, uint32_t stop, int16_t points);

bool sweep(bool break_on_operation);

Expand Down Expand Up @@ -608,7 +607,6 @@ config_t config = {
.grid_color = 0x1084,
.menu_normal_color = 0xffff,
.menu_active_color = 0x7777,
/* .trace_color = { RGB565(0,255,255), RGB565(255,0,40), RGB565(0,0,255), RGB565(50,255,0) }, */
.trace_color = { RGB_565(255,255,0), RGB_565(0,40,255), RGB_565(0,255,0), RGB_565(255,200,20) },
.touch_cal = { 411, 592, 151, 189 }, //{ 620, 600, 160, 190 },
.default_loadcal = 0,
Expand Down Expand Up @@ -783,8 +781,7 @@ static void set_frequencies(uint32_t start, uint32_t stop, int16_t points)



void
update_frequencies(void)
static void update_frequencies(void)
{
uint32_t start, stop;
if (frequency1 > 0) {
Expand Down
18 changes: 7 additions & 11 deletions nanovna.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ extern void tlv320aic3204_select(int channel);
#define HEIGHT 233

#define CELLOFFSETX 5

#define AREA_WIDTH_NORMAL (WIDTH + CELLOFFSETX*2)

extern int area_width;
Expand All @@ -143,7 +142,9 @@ extern int area_height;
// font

extern const uint8_t x8x8_bits[][8];
extern const uint8_t x8x8_len[];
extern uint8_t x8x8_get_len(uint8_t ch);
extern uint8_t x8x8_map_char_table(uint8_t ch);

extern const uint8_t numfont20x22[][22 * 3];

#define S_DELTA "\001"
Expand All @@ -156,8 +157,6 @@ extern const uint8_t numfont20x22[][22 * 3];
#define S_RARROW "\004"
#define C_DELTA '\001'

extern uint8_t x8x8_map_char_table(uint8_t ch);



// trace
Expand Down Expand Up @@ -246,7 +245,6 @@ void draw_frequencies(void);
void draw_all(bool flush);

void draw_cal_status(void);
void draw_frequencies(void);

void markmap_all_markers(void);

Expand All @@ -268,7 +266,6 @@ extern int16_t vbat;
/*
* ili9341.c
*/
#define RGB565(b,r,g) ( (((b)<<8)&0xfc00) | (((r)<<2)&0x03e0) | (((g)>>3)&0x001f) )
#define RGB_565(r, g, b) ( (((b)<<8)&0xfc00) | (((r)<<2)&0x03e0) | (((g)>>3)&0x001f) )

typedef struct {
Expand All @@ -288,8 +285,8 @@ void ili9341_test(int mode);
void ili9341_bulk(int x, int y, int w, int h);
void ili9341_fill(int x, int y, int w, int h, int color);

unsigned char ili9341_drawchar(uint8_t ch, int x, int y, uint16_t fg, uint16_t bg, uint8_t size, uint8_t var, uint8_t invert);
unsigned int ili9341_drawstring(const char *str, int x, int y, uint16_t fg, uint16_t bg, uint8_t size, uint8_t var, uint8_t invert);
unsigned char ili9341_drawchar(uint8_t ch, int x, int y, const uint16_t fg, const uint16_t bg, const uint8_t size, const uint8_t var, const uint8_t invert);
unsigned int ili9341_drawstring(const char *str, int x, int y, const uint16_t fg, const uint16_t bg, const uint8_t size, const uint8_t var, const uint8_t invert);
#define ili9341_drawstring_size(str, x, y, fg, bg, size) ili9341_drawstring(str, x, y, fg, bg, size, TRUE, FALSE)
#define ili9341_drawstring_8x8(str, x, y, fg, bg) ili9341_drawstring(str, x, y, fg, bg, 1, FALSE, FALSE)
#define ili9341_drawstring_8x8_var(str, x, y, fg, bg) ili9341_drawstring(str, x, y, fg, bg, 1, TRUE, FALSE)
Expand Down Expand Up @@ -392,13 +389,11 @@ extern uint8_t operation_requested;
void touch_start_watchdog(void);
void touch_position(int *x, int *y);
void handle_touch_interrupt(void);
void touch_start_watchdog(void);

#define TOUCH_THRESHOLD 2000

void touch_cal_exec(void);
void touch_draw_test(void);
void touch_position(int *x, int *y);
void enter_dfu(void);

/*
Expand All @@ -424,7 +419,8 @@ static inline uint8_t vbat2bati(int16_t vbat)
if (vbat < 3450) return 25;
if (vbat < 3700) return 50;
if (vbat < 4100) return 75;
return 100;

return 100;
}

/*EOF*/
4 changes: 2 additions & 2 deletions plot.c
Original file line number Diff line number Diff line change
Expand Up @@ -1646,7 +1646,7 @@ cell_drawchar(int w, int h, uint8_t ch, int x, int y, uint16_t fg, uint16_t bg,

if ( var != FALSE )
{
charwidthpx = x8x8_len[ch] * size;
charwidthpx = x8x8_get_len(ch) * size;
}

if ( y <= -(8*size) || y >= h || x <= -(charwidthpx) || x >= w )
Expand Down Expand Up @@ -2053,7 +2053,7 @@ draw_battery_status(void)
int i, c;
uint16_t *buf = spi_buffer;
uint8_t vbati = vbat2bati(vbat);
uint16_t col = vbati == 0 ? RGB565(0, 255, 0) : RGB565(0, 0, 240);
uint16_t col = vbati == 0 ? RGB_565(255, 0, 0) : RGB_565(0, 240, 0);
memset(spi_buffer, 0, w * h * 2);

// battery head
Expand Down
Loading

0 comments on commit 1081bf7

Please sign in to comment.