diff --git a/app/app.c b/app/app.c index 4bce1b7..a18e4a1 100644 --- a/app/app.c +++ b/app/app.c @@ -71,6 +71,7 @@ static uint16_t pga = 6; // -3dB #ifdef ENABLE_AM_FIX // moving average RSSI buffer struct { + unsigned int count; unsigned int index; uint16_t samples[10]; // 100ms long buffer (10ms RSSI sample rate) uint16_t sum; // sum of all samples in the buffer @@ -78,6 +79,16 @@ static uint16_t pga = 6; // -3dB unsigned int rssi_peak_hold_val = 0; unsigned int rssi_peak_hold_count = 0; + + void APP_reset_AM_fix(void) + { + // reset the moving average filter + memset(&moving_avg_rssi, 0, sizeof(moving_avg_rssi)); + + // reset the peak hold + rssi_peak_hold_val = 0; + rssi_peak_hold_count = 0; + } #endif static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld); @@ -432,10 +443,7 @@ void APP_StartListening(FUNCTION_Type_t Function) #endif #ifdef ENABLE_AM_FIX - // reset the moving average filter - memset(&moving_avg_rssi, 0, sizeof(moving_avg_rssi)); - rssi_peak_hold_val = 0; - rssi_peak_hold_count = 0; + APP_reset_AM_fix(); #endif gVFO_RSSI_Level[gEeprom.RX_CHANNEL == 0] = 0; @@ -1344,8 +1352,9 @@ void APP_CheckKeys(void) #ifdef ENABLE_AM_FIX void adjustAMFrontEnd10ms(void) { + // we don't play with the front end gains if in FM mode if (!gRxVfo->IsAM) - return; // we don't play with the front end gains if in FM mode + return; // we're in AM mode @@ -1363,7 +1372,7 @@ void APP_CheckKeys(void) case FUNCTION_INCOMING: break; } - + // REG_10 <15:0> 0x0038 Rx AGC Gain Table[0]. (Index Max->Min is 3,2,1,0,-1) // // <9:8> = LNA Gain Short @@ -1404,22 +1413,22 @@ void APP_CheckKeys(void) register uint16_t new_mixer = mixer; register uint16_t new_pga = pga; - // -86dBm, any higher and the AM demodulator starts to saturate - const uint16_t desired_rssi = (-86 + 160) * 2; // dBm to ADC sample + // -84dBm, any higher and the AM demodulator starts to saturate/clip (distort) + const uint16_t desired_rssi = (-84 + 160) * 2; // dBm to ADC sample // sample the current RSSI level - uint16_t rssi = BK4819_GetRSSI(); // 9-bit value + uint16_t rssi = BK4819_GetRSSI(); // 9-bit value (0 .. 511) //gCurrentRSSI = rssi; // compute the moving average RSSI - moving_avg_rssi.sum -= moving_avg_rssi.samples[moving_avg_rssi.index]; // remove the oldest sample + if (moving_avg_rssi.count < ARRAY_SIZE(moving_avg_rssi.samples)) + moving_avg_rssi.count++; + moving_avg_rssi.sum -= moving_avg_rssi.samples[moving_avg_rssi.index]; // subtract the oldest sample moving_avg_rssi.sum += rssi; // add the newest sample moving_avg_rssi.samples[moving_avg_rssi.index] = rssi; // save the newest sample - if (++moving_avg_rssi.index >= ARRAY_SIZE(moving_avg_rssi.samples)) // + if (++moving_avg_rssi.index >= ARRAY_SIZE(moving_avg_rssi.samples)) // next buffer slot moving_avg_rssi.index = 0; // wrap-a-round - - // compute the average - rssi = moving_avg_rssi.sum / ARRAY_SIZE(moving_avg_rssi.samples); + rssi = moving_avg_rssi.sum / moving_avg_rssi.count; // compute the average of the past 'n' samples if (rssi >= rssi_peak_hold_val) { // enter hold mode (pause any gain increases) @@ -1432,7 +1441,9 @@ void APP_CheckKeys(void) else rssi_peak_hold_val = rssi; - if (rssi > (desired_rssi + 4)) + // the register adjustments below to be a bit more inteligent in order to obtain a consitant fine step size + + if (rssi > desired_rssi) { // decrease gain if (new_pga > 6) @@ -1444,9 +1455,6 @@ void APP_CheckKeys(void) if (new_lna > 2) new_lna--; else - if (new_lna_short > 0) - new_lna_short++; - else if (new_pga > 0) new_pga--; else @@ -1455,6 +1463,9 @@ void APP_CheckKeys(void) else if (new_mixer > 0) new_mixer--; + else + if (new_lna_short > 0) + new_lna_short--; } if (moving_avg_rssi.index > 0) @@ -1462,7 +1473,7 @@ void APP_CheckKeys(void) if (rssi_peak_hold_count == 0) { - if (rssi < (desired_rssi - 4)) + if (rssi < (desired_rssi - 7)) { // increase gain if (new_pga < 7) new_pga++; @@ -1480,7 +1491,7 @@ void APP_CheckKeys(void) } if (lna_short == new_lna_short && lna == new_lna && mixer == new_mixer && pga == new_pga) - return; // no change + return; // no gain changes // apply the new gain settings to the front end @@ -1490,6 +1501,12 @@ void APP_CheckKeys(void) pga = new_pga; BK4819_WriteRegister(BK4819_REG_13, (lna_short << 8) | (lna << 5) | (mixer << 3) | (pga << 0)); + + + + // TODO: offset the RSSI reading to the rest of the firmware to cancel out the gain adjustments we've made here + + } #endif diff --git a/firmware b/firmware index e4eac52..11455ed 100644 Binary files a/firmware and b/firmware differ diff --git a/firmware.bin b/firmware.bin index 87309b6..9f18b6c 100644 Binary files a/firmware.bin and b/firmware.bin differ diff --git a/firmware.packed.bin b/firmware.packed.bin index 3e15279..885dc51 100644 Binary files a/firmware.packed.bin and b/firmware.packed.bin differ diff --git a/font.c b/font.c index 3b99fc6..76e9add 100644 --- a/font.c +++ b/font.c @@ -149,117 +149,117 @@ const uint8_t gFontBig[95][15] = {0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00} }; #endif - +/* const uint8_t gFontSmallDigits[11][7] = { - {0x00, 0x3E, 0x41, 0x41, 0x41, 0x41, 0x3E}, - {0x00, 0x00, 0x42, 0x7F, 0x40, 0x00, 0x00}, - {0x00, 0x62, 0x51, 0x51, 0x49, 0x49, 0x46}, - {0x00, 0x22, 0x41, 0x49, 0x49, 0x4D, 0x32}, - {0x00, 0x18, 0x14, 0x12, 0x11, 0x7F, 0x10}, - {0x00, 0x27, 0x45, 0x45, 0x45, 0x45, 0x39}, - {0x00, 0x3E, 0x49, 0x49, 0x49, 0x49, 0x30}, - {0x00, 0x01, 0x71, 0x09, 0x05, 0x03, 0x00}, - {0x00, 0x36, 0x49, 0x49, 0x49, 0x49, 0x36}, - {0x00, 0x46, 0x49, 0x49, 0x49, 0x29, 0x1E}, - {0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00} + {0x00, 0x3E, 0x41, 0x41, 0x41, 0x41, 0x3E}, // '0' + {0x00, 0x00, 0x42, 0x7F, 0x40, 0x00, 0x00}, // '1' + {0x00, 0x62, 0x51, 0x51, 0x49, 0x49, 0x46}, // '2' + {0x00, 0x22, 0x41, 0x49, 0x49, 0x4D, 0x32}, // '3' + {0x00, 0x18, 0x14, 0x12, 0x11, 0x7F, 0x10}, // '4' + {0x00, 0x27, 0x45, 0x45, 0x45, 0x45, 0x39}, // '5' + {0x00, 0x3E, 0x49, 0x49, 0x49, 0x49, 0x30}, // '6' + {0x00, 0x01, 0x71, 0x09, 0x05, 0x03, 0x00}, // '7' + {0x00, 0x36, 0x49, 0x49, 0x49, 0x49, 0x36}, // '8' + {0x00, 0x46, 0x49, 0x49, 0x49, 0x29, 0x1E}, // '9' + {0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00} // '-' }; - +*/ const uint8_t gFontSmall[95][7] = { - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x5E, 0x00, 0x00, 0x00}, - {0x00, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00}, - {0x00, 0x14, 0x3E, 0x14, 0x3E, 0x14, 0x00}, - {0x00, 0x26, 0x49, 0x7F, 0x49, 0x32, 0x00}, - {0x00, 0x63, 0x13, 0x08, 0x04, 0x62, 0x61}, - {0x00, 0x30, 0x4B, 0x4D, 0x55, 0x22, 0x50}, - {0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00}, - {0x00, 0x00, 0x1C, 0x22, 0x41, 0x00, 0x00}, - {0x00, 0x00, 0x41, 0x22, 0x1C, 0x00, 0x00}, - {0x00, 0x00, 0x2A, 0x1C, 0x1C, 0x2A, 0x00}, - {0x00, 0x08, 0x08, 0x3E, 0x08, 0x08, 0x00}, - {0x00, 0x00, 0x40, 0x60, 0x20, 0x00, 0x00}, - {0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x00}, - {0x00, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00}, - {0x00, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02}, - {0x00, 0x3E, 0x41, 0x41, 0x41, 0x41, 0x3E}, - {0x00, 0x00, 0x40, 0x42, 0x7F, 0x40, 0x40}, - {0x00, 0x62, 0x51, 0x51, 0x49, 0x49, 0x46}, - {0x00, 0x22, 0x41, 0x49, 0x49, 0x49, 0x36}, - {0x00, 0x18, 0x14, 0x12, 0x11, 0x7F, 0x10}, - {0x00, 0x27, 0x45, 0x45, 0x45, 0x45, 0x39}, - {0x00, 0x3E, 0x49, 0x49, 0x49, 0x49, 0x32}, - {0x00, 0x01, 0x01, 0x71, 0x09, 0x05, 0x03}, - {0x00, 0x36, 0x49, 0x49, 0x49, 0x49, 0x36}, - {0x00, 0x26, 0x49, 0x49, 0x49, 0x49, 0x3E}, - {0x00, 0x00, 0x00, 0x6C, 0x6C, 0x00, 0x00}, - {0x00, 0x00, 0x40, 0x6C, 0x2C, 0x00, 0x00}, - {0x00, 0x08, 0x14, 0x22, 0x41, 0x00, 0x00}, - {0x00, 0x14, 0x14, 0x14, 0x14, 0x14, 0x00}, - {0x00, 0x00, 0x41, 0x22, 0x14, 0x08, 0x00}, - {0x00, 0x02, 0x01, 0x51, 0x09, 0x06, 0x00}, - {0x00, 0x30, 0x4A, 0x4A, 0x52, 0x3C, 0x00}, - {0x00, 0x7E, 0x09, 0x09, 0x09, 0x09, 0x7E}, - {0x00, 0x7F, 0x49, 0x49, 0x49, 0x49, 0x36}, - {0x00, 0x3E, 0x41, 0x41, 0x41, 0x41, 0x22}, - {0x00, 0x7F, 0x41, 0x41, 0x41, 0x41, 0x3E}, - {0x00, 0x7F, 0x49, 0x49, 0x49, 0x49, 0x41}, - {0x00, 0x7F, 0x09, 0x09, 0x09, 0x09, 0x01}, - {0x00, 0x3E, 0x41, 0x49, 0x49, 0x49, 0x3A}, - {0x00, 0x7F, 0x08, 0x08, 0x08, 0x08, 0x7F}, - {0x00, 0x41, 0x41, 0x7F, 0x41, 0x41, 0x00}, - {0x00, 0x20, 0x41, 0x41, 0x3F, 0x01, 0x01}, - {0x00, 0x7F, 0x08, 0x0C, 0x12, 0x21, 0x40}, - {0x00, 0x7F, 0x40, 0x40, 0x40, 0x40, 0x40}, - {0x00, 0x7F, 0x02, 0x04, 0x04, 0x02, 0x7F}, - {0x00, 0x7F, 0x02, 0x04, 0x08, 0x10, 0x7F}, - {0x00, 0x3E, 0x41, 0x41, 0x41, 0x41, 0x3E}, - {0x00, 0x7F, 0x09, 0x09, 0x09, 0x09, 0x06}, - {0x00, 0x3E, 0x41, 0x51, 0x61, 0x41, 0x3E}, - {0x00, 0x7F, 0x09, 0x09, 0x19, 0x29, 0x46}, - {0x00, 0x26, 0x49, 0x49, 0x49, 0x49, 0x32}, - {0x00, 0x01, 0x01, 0x7F, 0x01, 0x01, 0x00}, - {0x00, 0x3F, 0x40, 0x40, 0x40, 0x40, 0x3F}, - {0x00, 0x07, 0x38, 0x40, 0x40, 0x38, 0x07}, - {0x00, 0x3F, 0x40, 0x30, 0x30, 0x40, 0x3F}, - {0x00, 0x63, 0x14, 0x08, 0x08, 0x14, 0x63}, - {0x00, 0x07, 0x08, 0x70, 0x08, 0x07, 0x00}, - {0x00, 0x61, 0x51, 0x49, 0x45, 0x43, 0x41}, - {0x00, 0x00, 0x7F, 0x41, 0x41, 0x00, 0x00}, - {0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x60}, - {0x00, 0x00, 0x00, 0x41, 0x41, 0x7F, 0x00}, - {0x00, 0x04, 0x02, 0x01, 0x02, 0x04, 0x00}, - {0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40}, - {0x00, 0x00, 0x03, 0x07, 0x06, 0x00, 0x00}, - {0x00, 0x20, 0x54, 0x54, 0x54, 0x78, 0x00}, - {0x00, 0x7F, 0x44, 0x44, 0x44, 0x38, 0x00}, - {0x00, 0x38, 0x44, 0x44, 0x44, 0x28, 0x00}, - {0x00, 0x38, 0x44, 0x44, 0x44, 0x7F, 0x00}, - {0x00, 0x38, 0x54, 0x54, 0x54, 0x48, 0x00}, - {0x00, 0x7C, 0x0A, 0x0A, 0x0A, 0x02, 0x00}, - {0x00, 0x58, 0x54, 0x54, 0x54, 0x3C, 0x00}, - {0x00, 0x7F, 0x04, 0x04, 0x04, 0x78, 0x00}, - {0x00, 0x00, 0x00, 0x7A, 0x00, 0x00, 0x00}, - {0x00, 0x20, 0x40, 0x40, 0x3D, 0x00, 0x00}, - {0x00, 0x00, 0x7F, 0x10, 0x28, 0x44, 0x00}, - {0x00, 0x00, 0x00, 0x3F, 0x40, 0x00, 0x00}, - {0x00, 0x7C, 0x08, 0x10, 0x10, 0x08, 0x7C}, - {0x00, 0x7C, 0x04, 0x04, 0x04, 0x78, 0x00}, - {0x00, 0x38, 0x44, 0x44, 0x44, 0x38, 0x00}, - {0x00, 0x7C, 0x14, 0x14, 0x14, 0x08, 0x00}, - {0x00, 0x08, 0x14, 0x14, 0x14, 0x7C, 0x40}, - {0x00, 0x7C, 0x04, 0x04, 0x04, 0x08, 0x00}, - {0x00, 0x08, 0x54, 0x54, 0x54, 0x20, 0x00}, - {0x00, 0x3F, 0x44, 0x44, 0x44, 0x40, 0x00}, - {0x00, 0x3C, 0x40, 0x40, 0x40, 0x3C, 0x00}, - {0x00, 0x0C, 0x30, 0x40, 0x30, 0x0C, 0x00}, - {0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C, 0x00}, - {0x00, 0x44, 0x28, 0x10, 0x28, 0x44, 0x00}, - {0x00, 0x0C, 0x50, 0x50, 0x50, 0x3C, 0x00}, - {0x00, 0x44, 0x64, 0x54, 0x4C, 0x44, 0x00}, - {0x00, 0x08, 0x36, 0x41, 0x00, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x41, 0x36, 0x08, 0x00}, - {0x00, 0x04, 0x02, 0x04, 0x08, 0x04, 0x00} + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // ' ' + {0x00, 0x00, 0x00, 0x5E, 0x00, 0x00, 0x00}, // '!' + {0x00, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00}, // '"' + {0x00, 0x14, 0x3E, 0x14, 0x3E, 0x14, 0x00}, // '#' + {0x00, 0x26, 0x49, 0x7F, 0x49, 0x32, 0x00}, // '$' + {0x00, 0x63, 0x13, 0x08, 0x04, 0x62, 0x61}, // '%' + {0x00, 0x30, 0x4B, 0x4D, 0x55, 0x22, 0x50}, // '&' + {0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00}, // ''' + {0x00, 0x00, 0x1C, 0x22, 0x41, 0x00, 0x00}, // '(' + {0x00, 0x00, 0x41, 0x22, 0x1C, 0x00, 0x00}, // ')' + {0x00, 0x00, 0x2A, 0x1C, 0x1C, 0x2A, 0x00}, // '*' + {0x00, 0x08, 0x08, 0x3E, 0x08, 0x08, 0x00}, // '+' + {0x00, 0x00, 0x40, 0x60, 0x20, 0x00, 0x00}, // ',' + {0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x00}, // '-' + {0x00, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00}, // '.' + {0x00, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02}, // '/' + {0x00, 0x3E, 0x41, 0x41, 0x41, 0x41, 0x3E}, // '0' + {0x00, 0x00, 0x40, 0x42, 0x7F, 0x40, 0x40}, // '1' + {0x00, 0x62, 0x51, 0x51, 0x49, 0x49, 0x46}, // '2' + {0x00, 0x22, 0x41, 0x49, 0x49, 0x49, 0x36}, // '3' + {0x00, 0x18, 0x14, 0x12, 0x11, 0x7F, 0x10}, // '4' + {0x00, 0x27, 0x45, 0x45, 0x45, 0x45, 0x39}, // '5' + {0x00, 0x3E, 0x49, 0x49, 0x49, 0x49, 0x32}, // '6' + {0x00, 0x01, 0x01, 0x71, 0x09, 0x05, 0x03}, // '7' + {0x00, 0x36, 0x49, 0x49, 0x49, 0x49, 0x36}, // '8' + {0x00, 0x46, 0x49, 0x49, 0x49, 0x29, 0x1E}, // '9' + {0x00, 0x00, 0x00, 0x6C, 0x6C, 0x00, 0x00}, // ':' + {0x00, 0x00, 0x40, 0x6C, 0x2C, 0x00, 0x00}, // ';' + {0x00, 0x08, 0x14, 0x22, 0x41, 0x00, 0x00}, // '<' + {0x00, 0x14, 0x14, 0x14, 0x14, 0x14, 0x00}, // '=' + {0x00, 0x00, 0x41, 0x22, 0x14, 0x08, 0x00}, // '>' + {0x00, 0x02, 0x01, 0x51, 0x09, 0x06, 0x00}, // '?' + {0x00, 0x30, 0x4A, 0x4A, 0x52, 0x3C, 0x00}, // '@' + {0x00, 0x7E, 0x09, 0x09, 0x09, 0x09, 0x7E}, // 'A' + {0x00, 0x7F, 0x49, 0x49, 0x49, 0x49, 0x36}, // 'B' + {0x00, 0x3E, 0x41, 0x41, 0x41, 0x41, 0x22}, // 'C' + {0x00, 0x7F, 0x41, 0x41, 0x41, 0x41, 0x3E}, // 'D' + {0x00, 0x7F, 0x49, 0x49, 0x49, 0x49, 0x41}, // 'E' + {0x00, 0x7F, 0x09, 0x09, 0x09, 0x09, 0x01}, // 'F' + {0x00, 0x3E, 0x41, 0x49, 0x49, 0x49, 0x3A}, // 'G' + {0x00, 0x7F, 0x08, 0x08, 0x08, 0x08, 0x7F}, // 'H' + {0x00, 0x41, 0x41, 0x7F, 0x41, 0x41, 0x00}, // 'I' + {0x00, 0x20, 0x41, 0x41, 0x3F, 0x01, 0x01}, // 'J' + {0x00, 0x7F, 0x08, 0x0C, 0x12, 0x21, 0x40}, // 'K' + {0x00, 0x7F, 0x40, 0x40, 0x40, 0x40, 0x40}, // 'L' + {0x00, 0x7F, 0x02, 0x04, 0x04, 0x02, 0x7F}, // 'M' + {0x00, 0x7F, 0x02, 0x04, 0x08, 0x10, 0x7F}, // 'N' + {0x00, 0x3E, 0x41, 0x41, 0x41, 0x41, 0x3E}, // 'O' + {0x00, 0x7F, 0x09, 0x09, 0x09, 0x09, 0x06}, // 'P' + {0x00, 0x3E, 0x41, 0x51, 0x61, 0x41, 0x3E}, // 'Q' + {0x00, 0x7F, 0x09, 0x09, 0x19, 0x29, 0x46}, // 'R' + {0x00, 0x26, 0x49, 0x49, 0x49, 0x49, 0x32}, // 'S' + {0x00, 0x01, 0x01, 0x7F, 0x01, 0x01, 0x00}, // 'T' + {0x00, 0x3F, 0x40, 0x40, 0x40, 0x40, 0x3F}, // 'U' + {0x00, 0x07, 0x38, 0x40, 0x40, 0x38, 0x07}, // 'V' + {0x00, 0x3F, 0x40, 0x30, 0x30, 0x40, 0x3F}, // 'W' + {0x00, 0x63, 0x14, 0x08, 0x08, 0x14, 0x63}, // 'X' + {0x00, 0x07, 0x08, 0x70, 0x08, 0x07, 0x00}, // 'Y' + {0x00, 0x61, 0x51, 0x49, 0x45, 0x43, 0x41}, // 'Z' + {0x00, 0x00, 0x7F, 0x41, 0x41, 0x00, 0x00}, // '[' + {0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x60}, // '"\' + {0x00, 0x00, 0x00, 0x41, 0x41, 0x7F, 0x00}, // ']' + {0x00, 0x04, 0x02, 0x01, 0x02, 0x04, 0x00}, // '^' + {0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40}, // '_' + {0x00, 0x00, 0x03, 0x07, 0x06, 0x00, 0x00}, // '`' + {0x00, 0x20, 0x54, 0x54, 0x54, 0x78, 0x00}, // 'a' + {0x00, 0x7F, 0x44, 0x44, 0x44, 0x38, 0x00}, // 'b' + {0x00, 0x38, 0x44, 0x44, 0x44, 0x28, 0x00}, // 'c' + {0x00, 0x38, 0x44, 0x44, 0x44, 0x7F, 0x00}, // 'd' + {0x00, 0x38, 0x54, 0x54, 0x54, 0x48, 0x00}, // 'e' + {0x00, 0x7C, 0x0A, 0x0A, 0x0A, 0x02, 0x00}, // 'f' + {0x00, 0x58, 0x54, 0x54, 0x54, 0x3C, 0x00}, // 'g' + {0x00, 0x7F, 0x04, 0x04, 0x04, 0x78, 0x00}, // 'h' + {0x00, 0x00, 0x00, 0x7A, 0x00, 0x00, 0x00}, // 'i' + {0x00, 0x20, 0x40, 0x40, 0x3D, 0x00, 0x00}, // 'j' + {0x00, 0x00, 0x7F, 0x10, 0x28, 0x44, 0x00}, // 'k' + {0x00, 0x00, 0x00, 0x3F, 0x40, 0x00, 0x00}, // 'l' + {0x00, 0x7C, 0x08, 0x10, 0x10, 0x08, 0x7C}, // 'm' + {0x00, 0x7C, 0x04, 0x04, 0x04, 0x78, 0x00}, // 'n' + {0x00, 0x38, 0x44, 0x44, 0x44, 0x38, 0x00}, // 'o' + {0x00, 0x7C, 0x14, 0x14, 0x14, 0x08, 0x00}, // 'p' + {0x00, 0x08, 0x14, 0x14, 0x14, 0x7C, 0x40}, // 'q' + {0x00, 0x7C, 0x04, 0x04, 0x04, 0x08, 0x00}, // 'r' + {0x00, 0x08, 0x54, 0x54, 0x54, 0x20, 0x00}, // 's' + {0x00, 0x3F, 0x44, 0x44, 0x44, 0x40, 0x00}, // 't' + {0x00, 0x3C, 0x40, 0x40, 0x40, 0x3C, 0x00}, // 'u' + {0x00, 0x0C, 0x30, 0x40, 0x30, 0x0C, 0x00}, // 'v' + {0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C, 0x00}, // 'w' + {0x00, 0x44, 0x28, 0x10, 0x28, 0x44, 0x00}, // 'x' + {0x00, 0x0C, 0x50, 0x50, 0x50, 0x3C, 0x00}, // 'y' + {0x00, 0x44, 0x64, 0x54, 0x4C, 0x44, 0x00}, // 'z' + {0x00, 0x08, 0x36, 0x41, 0x00, 0x00, 0x00}, // '{' + {0x00, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x00}, // '|' + {0x00, 0x00, 0x00, 0x41, 0x36, 0x08, 0x00}, // '}' + {0x00, 0x04, 0x02, 0x04, 0x08, 0x04, 0x00} // '->' }; diff --git a/font.h b/font.h index fc4c8a8..75d1d47 100644 --- a/font.h +++ b/font.h @@ -22,7 +22,7 @@ //extern const uint8_t gFontBig[95][16]; extern const uint8_t gFontBig[95][15]; extern const uint8_t gFontBigDigits[11][26]; -extern const uint8_t gFontSmallDigits[11][7]; +//extern const uint8_t gFontSmallDigits[11][7]; extern const uint8_t gFontSmall[95][7]; #endif diff --git a/ui/helper.c b/ui/helper.c index 4410cfd..714a423 100644 --- a/ui/helper.c +++ b/ui/helper.c @@ -177,9 +177,14 @@ void UI_DisplayFrequencySmall(const char *pDigits, uint8_t X, uint8_t Y, bool bD const unsigned int Digit = pDigits[i++]; if (bDisplayLeadingZero || bCanDisplay || Digit > 0) { - bCanDisplay = true; - memmove(pFb, gFontSmallDigits[Digit], char_width); + #if 0 + memmove(pFb, gFontSmallDigits[Digit], char_width); + #else + const unsigned int index = (Digit < 10) ? '0' - 32 + Digit : '-' - 32; + memmove(pFb, gFontSmall[index], char_width); + #endif pFb += char_width; + bCanDisplay = true; } } @@ -194,7 +199,12 @@ void UI_DisplayFrequencySmall(const char *pDigits, uint8_t X, uint8_t Y, bool bD while (i < 8) { const unsigned int Digit = pDigits[i++]; - memmove(pFb, gFontSmallDigits[Digit], char_width); + #if 0 + memmove(pFb, gFontSmallDigits[Digit], char_width); + #else + const unsigned int index = (Digit < 10) ? '0' - 32 + Digit : '-' - 32; + memmove(pFb, gFontSmall[index], char_width); + #endif pFb += char_width; } } @@ -210,9 +220,14 @@ void UI_DisplaySmallDigits(const uint8_t size, const char *str, const uint8_t x, const unsigned int c = (unsigned int)str[i]; if (c > 0) display = true; - if (display && c < ARRAY_SIZE(gFontSmallDigits)) + if (display && c < 11) { - memmove(gFrameBuffer[y] + xx, gFontSmallDigits[c], char_width); + #if 0 + memmove(gFrameBuffer[y] + xx, gFontSmallDigits[c], char_width); + #else + const unsigned int index = (c < 10) ? '0' - 32 + c : '-' - 32; + memmove(gFrameBuffer[y] + xx, gFontSmall[index], char_width); + #endif xx += char_width; } } diff --git a/version.c b/version.c index 05455b6..af82e76 100644 --- a/version.c +++ b/version.c @@ -2,7 +2,7 @@ #ifdef GIT_HASH #define VER GIT_HASH #else - #define VER "230921" + #define VER "230922" #endif const char Version[] = "OEFW-"VER;