Merge pull request #9 from reedbn/fixed-width-freqs

Fixed width freqs and replace MNU with gear symbol
This commit is contained in:
reedbn 2020-01-28 20:29:53 -08:00 committed by GitHub
commit 87cf184fe6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 20 deletions

View File

@ -101,7 +101,12 @@ const uint8_t FreeSansBold9pt7bBitmaps[] PROGMEM = {
0x78, 0x1E, 0x03, 0x00, 0xC0, 0x70, 0x38, 0x0E, 0x00, 0xFE, 0xFE, 0x0E,
0x1C, 0x38, 0x38, 0x70, 0xE0, 0xFF, 0xFF, 0x37, 0x66, 0x66, 0x6E, 0xE6,
0x66, 0x66, 0x67, 0x30, 0xFF, 0xFF, 0x80, 0xCE, 0x66, 0x66, 0x67, 0x76,
0x66, 0x66, 0x6E, 0xC0, 0x71, 0x8E };
0x66, 0x66, 0x6E, 0xC0, 0x71, 0x8E, 0x0C, 0x00, 0xF0, 0x00, 0x8F, 0x10,
0x1C, 0xF3, 0x83, 0xFF, 0xFC, 0x7F, 0xFF, 0xE3, 0xF0, 0xFE, 0x1E, 0x07,
0xC1, 0xC0, 0x38, 0xF8, 0x01, 0xFF, 0x80, 0x1F, 0xF8, 0x01, 0xFF, 0x80,
0x1F, 0x1C, 0x03, 0x81, 0xE0, 0x78, 0x3F, 0x0F, 0xC7, 0xFF, 0xFE, 0x3F,
0xFF, 0xC3, 0xCF, 0x38, 0x08, 0xF1, 0x00, 0x0F, 0x00
};
const GFXglyph FreeSansBold9pt7bGlyphs[] PROGMEM = {
{ 0, 0, 0, 5, 0, 1 }, // 0x20 ' '
@ -198,11 +203,16 @@ const GFXglyph FreeSansBold9pt7bGlyphs[] PROGMEM = {
{ 1207, 4, 17, 7, 1, -12 }, // 0x7B '{'
{ 1216, 1, 17, 5, 2, -12 }, // 0x7C '|'
{ 1219, 4, 17, 7, 2, -12 }, // 0x7D '}'
{ 1228, 8, 2, 9, 0, -4 } }; // 0x7E '~'
{ 1228, 8, 2, 9, 0, -4 }, // 0x7E '~'
{ 1231, 20, 20, 22, 1, -12 }, // 0x7F gear icon
{ 1231, 0, 0, 10, 0, 1 }, // 0x80 10px space to match numbers
{ 1231, 0, 0, 4, 0, 1 }, // 0x81 4px space to match period
};
const GFXfont FreeSansBold9pt7b PROGMEM = {
(uint8_t *)FreeSansBold9pt7bBitmaps,
(GFXglyph *)FreeSansBold9pt7bGlyphs,
0x20, 0x7E, 22 };
// Approx. 1902 bytes
0x20, //first character
0x81, //last character
22 //yAdvance (newline)
};

View File

@ -11,7 +11,8 @@ struct Point ts_point;
/*
* This formats the frequency given in f
*/
void formatFreq(uint32_t freq, char* buff, uint16_t buff_size) {
void formatFreq(uint32_t freq, char* buff, uint16_t buff_size, uint8_t fixed_width)
{
memset(buff, 0, buff_size);
ultoa(freq, buff, DEC);
@ -20,10 +21,20 @@ void formatFreq(uint32_t freq, char* buff, uint16_t buff_size) {
const uint8_t num_leading_digits_raw = num_digits % 3;
const uint8_t num_leading_digits = (0 == num_leading_digits_raw) ? 3 : num_leading_digits_raw;
if(0 == num_spacers){
return;
if(0 < fixed_width){
while(0 < fixed_width - num_digits - num_spacers){
if(0 == fixed_width % 4){
buff[0] = '\x81';//separator size
}
else{
buff[0] = '\x80';//digit size
}
--fixed_width;
++buff;
}
}
ultoa(freq, buff, DEC);
buff += num_leading_digits;
num_digits -= num_leading_digits;
for(int i = num_digits-1; i >= 0; --i){
@ -214,13 +225,6 @@ void displayChar(int16_t x, int16_t y, unsigned char c, uint16_t color, uint16_t
tft.drawCharGFX(x,y,c,color,bg,1);
}
void displayRawText(char *text, int x1, int y1, int color, int background){
tft.setTextColor(color,background);
tft.setCursor(x1,y1);
tft.setBound(0,320);
tft.print(text);
}
void displayRawText(char *text, int x1, int y1, int w, int color, int background){
tft.setTextColor(color,background);
tft.setCursor(x1,y1);

View File

@ -15,10 +15,9 @@ void displayVline(unsigned int x, unsigned int y, unsigned int l, unsigned int c
void displayRect(unsigned int x,unsigned int y,unsigned int w,unsigned int h,unsigned int c);
void displayFillrect(unsigned int x,unsigned int y,unsigned int w,unsigned int h,unsigned int c);
void displayChar(int16_t x, int16_t y, unsigned char c, uint16_t color, uint16_t bg);
void displayRawText(char *text, int x1, int y1, int color, int background);
void displayText(char *text, int x1, int y1, int w, int h, int color, int background, int border);
void formatFreq(uint32_t freq, char* buff, uint16_t buff_size);
void formatFreq(uint32_t freq, char* buff, uint16_t buff_size, uint8_t fixed_width = 0);
/* touch functions */
boolean readTouch();

View File

@ -105,7 +105,7 @@ constexpr Button btn_set[BUTTON_TOTAL] PROGMEM = {
{LAYOUT_BUTTON_X + 0*LAYOUT_BUTTON_PITCH_X, LAYOUT_BUTTON_Y + 2*LAYOUT_BUTTON_PITCH_Y, LAYOUT_BUTTON_WIDTH, LAYOUT_BUTTON_HEIGHT, BUTTON_15 , "15", '5'},
{LAYOUT_BUTTON_X + 1*LAYOUT_BUTTON_PITCH_X, LAYOUT_BUTTON_Y + 2*LAYOUT_BUTTON_PITCH_Y, LAYOUT_BUTTON_WIDTH, LAYOUT_BUTTON_HEIGHT, BUTTON_10 , "10", '1'},
{LAYOUT_BUTTON_X + 2*LAYOUT_BUTTON_PITCH_X, LAYOUT_BUTTON_Y + 2*LAYOUT_BUTTON_PITCH_Y, LAYOUT_BUTTON_WIDTH, LAYOUT_BUTTON_HEIGHT, BUTTON_BLANK_1, "", '\0'},
{LAYOUT_BUTTON_X + 3*LAYOUT_BUTTON_PITCH_X, LAYOUT_BUTTON_Y + 2*LAYOUT_BUTTON_PITCH_Y, LAYOUT_BUTTON_WIDTH, LAYOUT_BUTTON_HEIGHT, BUTTON_MNU, "MNU", 'M'},
{LAYOUT_BUTTON_X + 3*LAYOUT_BUTTON_PITCH_X, LAYOUT_BUTTON_Y + 2*LAYOUT_BUTTON_PITCH_Y, LAYOUT_BUTTON_WIDTH, LAYOUT_BUTTON_HEIGHT, BUTTON_MNU, "\x7F", 'M'},
{LAYOUT_BUTTON_X + 4*LAYOUT_BUTTON_PITCH_X, LAYOUT_BUTTON_Y + 2*LAYOUT_BUTTON_PITCH_Y, LAYOUT_BUTTON_WIDTH, LAYOUT_BUTTON_HEIGHT, BUTTON_FRQ, "FRQ", 'F'},
};
@ -226,11 +226,12 @@ void displayVFO(Vfo_e vfo){
}
}
c[1] = ':';
c[2] = ' ';
if (VFO_A == vfo){
getButton(BUTTON_VFOA, &button);
formatFreq(globalSettings.vfoA.frequency, c+2, sizeof(c)-2);
formatFreq(globalSettings.vfoA.frequency, c+3, sizeof(c)-3, 10);
if (VFO_A == globalSettings.activeVfo){
displayColor = COLOR_ACTIVE_VFO_TEXT;
@ -245,7 +246,7 @@ void displayVFO(Vfo_e vfo){
if (VFO_B == vfo){
getButton(BUTTON_VFOB, &button);
formatFreq(globalSettings.vfoB.frequency, c+2, sizeof(c)-2);
formatFreq(globalSettings.vfoB.frequency, c+3, sizeof(c)-3, 10);
if (VFO_B == globalSettings.activeVfo){
displayColor = COLOR_ACTIVE_VFO_TEXT;