diff --git a/app/app.c b/app/app.c index a920e76..4398c29 100644 --- a/app/app.c +++ b/app/app.c @@ -1321,7 +1321,6 @@ void APP_Update(void) DUALWATCH_Alternate(); // toggle between the two VFO's gUpdateRSSI = true; - gBatterySave_10ms = 10; // 100ms } diff --git a/bitmaps.c b/bitmaps.c index 59176a3..c8bf72c 100644 --- a/bitmaps.c +++ b/bitmaps.c @@ -29,7 +29,7 @@ const uint8_t BITMAP_PowerSave[8] = #endif }; -const uint8_t BITMAP_BatteryLevel1[18] = +const uint8_t BITMAP_BatteryLevel1[17] = { 0b00000000, 0b00111110, @@ -47,11 +47,10 @@ const uint8_t BITMAP_BatteryLevel1[18] = 0b01000001, 0b01000001, 0b01000001, - 0b01000001, 0b01111111 }; -const uint8_t BITMAP_BatteryLevel2[18] = +const uint8_t BITMAP_BatteryLevel2[17] = { 0b00000000, 0b00111110, @@ -66,14 +65,13 @@ const uint8_t BITMAP_BatteryLevel2[18] = 0b01000001, 0b01000001, 0b01000001, - 0b01000001, 0b01011101, 0b01011101, 0b01000001, 0b01111111 }; -const uint8_t BITMAP_BatteryLevel3[18] = +const uint8_t BITMAP_BatteryLevel3[17] = { 0b00000000, 0b00111110, @@ -85,7 +83,6 @@ const uint8_t BITMAP_BatteryLevel3[18] = 0b01000001, 0b01000001, 0b01000001, - 0b01000001, 0b01011101, 0b01011101, 0b01000001, @@ -95,7 +92,7 @@ const uint8_t BITMAP_BatteryLevel3[18] = 0b01111111 }; -const uint8_t BITMAP_BatteryLevel4[18] = +const uint8_t BITMAP_BatteryLevel4[17] = { 0b00000000, 0b00111110, @@ -104,7 +101,6 @@ const uint8_t BITMAP_BatteryLevel4[18] = 0b01000001, 0b01000001, 0b01000001, - 0b01000001, 0b01011101, 0b01011101, 0b01000001, @@ -117,7 +113,7 @@ const uint8_t BITMAP_BatteryLevel4[18] = 0b01111111 }; -const uint8_t BITMAP_BatteryLevel5[18] = +const uint8_t BITMAP_BatteryLevel5[17] = { 0b00000000, 0b00111110, @@ -125,7 +121,6 @@ const uint8_t BITMAP_BatteryLevel5[18] = 0b01000001, 0b01011101, 0b01011101, - 0b01011101, 0b01000001, 0b01011101, 0b01011101, diff --git a/bitmaps.h b/bitmaps.h index 9364a43..675e28a 100644 --- a/bitmaps.h +++ b/bitmaps.h @@ -6,11 +6,11 @@ extern const uint8_t BITMAP_PowerSave[8]; -extern const uint8_t BITMAP_BatteryLevel1[18]; -extern const uint8_t BITMAP_BatteryLevel2[18]; -extern const uint8_t BITMAP_BatteryLevel3[18]; -extern const uint8_t BITMAP_BatteryLevel4[18]; -extern const uint8_t BITMAP_BatteryLevel5[18]; +extern const uint8_t BITMAP_BatteryLevel1[17]; +extern const uint8_t BITMAP_BatteryLevel2[17]; +extern const uint8_t BITMAP_BatteryLevel3[17]; +extern const uint8_t BITMAP_BatteryLevel4[17]; +extern const uint8_t BITMAP_BatteryLevel5[17]; extern const uint8_t BITMAP_USB_C[9]; diff --git a/driver/bk4819.c b/driver/bk4819.c index 9e2e83f..47f70f7 100644 --- a/driver/bk4819.c +++ b/driver/bk4819.c @@ -81,9 +81,26 @@ void BK4819_Init(void) (58u << 4) | // AF Rx Gain-2 ( 8u << 0)); // AF DAC Gain (after Gain-1 and Gain-2) - const uint8_t dtmf_coeffs[] = {0x6F,0x6B,0x67,0x62,0x50,0x47,0x3A,0x2C,0x41,0x37,0x25,0x17,0xE4,0xCB,0xB5,0x9F}; - for (unsigned int i = 0; i < ARRAY_SIZE(dtmf_coeffs); i++) - BK4819_WriteRegister(BK4819_REG_09, (i << 12) | dtmf_coeffs[i]); +// const uint8_t dtmf_coeffs[] = {0x6F,0x6B,0x67,0x62,0x50,0x47,0x3A,0x2C,0x41,0x37,0x25,0x17,0xE4,0xCB,0xB5,0x9F}; +// for (unsigned int i = 0; i < ARRAY_SIZE(dtmf_coeffs); i++) +// BK4819_WriteRegister(BK4819_REG_09, (i << 12) | dtmf_coeffs[i]); + + BK4819_WriteRegister(BK4819_REG_09, 0x006F); // 6F + BK4819_WriteRegister(BK4819_REG_09, 0x106B); // 6B + BK4819_WriteRegister(BK4819_REG_09, 0x2067); // 67 + BK4819_WriteRegister(BK4819_REG_09, 0x3062); // 62 + BK4819_WriteRegister(BK4819_REG_09, 0x4050); // 50 + BK4819_WriteRegister(BK4819_REG_09, 0x5046); // 47 ** + BK4819_WriteRegister(BK4819_REG_09, 0x603A); // 3A + BK4819_WriteRegister(BK4819_REG_09, 0x702C); // 2C + BK4819_WriteRegister(BK4819_REG_09, 0x8041); // 41 + BK4819_WriteRegister(BK4819_REG_09, 0x9037); // 37 + BK4819_WriteRegister(BK4819_REG_09, 0xA025); // 25 + BK4819_WriteRegister(BK4819_REG_09, 0xB017); // 17 + BK4819_WriteRegister(BK4819_REG_09, 0xC0E4); // E4 + BK4819_WriteRegister(BK4819_REG_09, 0xD0CB); // CB + BK4819_WriteRegister(BK4819_REG_09, 0xE0B5); // B5 + BK4819_WriteRegister(BK4819_REG_09, 0xF09F); // 9F BK4819_WriteRegister(BK4819_REG_1F, 0x5454); BK4819_WriteRegister(BK4819_REG_3E, 0xA037); @@ -677,30 +694,30 @@ void BK4819_RX_TurnOn(void) // DSP Voltage Setting = 1 // ANA LDO = 2.7v // VCO LDO = 2.7v - // RF LDO = 2.7v + // RF LDO = 2.7v // PLL LDO = 2.7v // ANA LDO bypass // VCO LDO bypass - // RF LDO bypass + // RF LDO bypass // PLL LDO bypass // Reserved bit is 1 instead of 0 - // Enable DSP - // Enable XTAL - // Enable Band Gap - BK4819_WriteRegister(BK4819_REG_37, 0x1F0F); + // Enable DSP + // Enable XTAL + // Enable Band Gap + BK4819_WriteRegister(BK4819_REG_37, 0x1F0F); // 0001111100001111 // Turn off everything BK4819_WriteRegister(BK4819_REG_30, 0); - // Enable VCO Calibration - // Enable RX Link - // Enable AF DAC - // Enable PLL/VCO + // Enable VCO Calibration + // Enable RX Link + // Enable AF DAC + // Enable PLL/VCO // Disable PA Gain // Disable MIC ADC // Disable TX DSP - // Enable RX DSP - BK4819_WriteRegister(BK4819_REG_30, 0xBFF1); + // Enable RX DSP + BK4819_WriteRegister(BK4819_REG_30, 0b1011111111110001); // 1 0 1111 1 1 1111 0 0 0 1 } void BK4819_PickRXFilterPathBasedOnFrequency(uint32_t Frequency) @@ -813,8 +830,7 @@ void BK4819_EnableDTMF(void) // BK4819_WriteRegister(BK4819_REG_24, (1u << BK4819_REG_24_SHIFT_UNKNOWN_15) -// | (24u << BK4819_REG_24_SHIFT_THRESHOLD) // original - | (31u << BK4819_REG_24_SHIFT_THRESHOLD) // hopefully reduced sensitivity + | (24u << BK4819_REG_24_SHIFT_THRESHOLD) | (1u << BK4819_REG_24_SHIFT_UNKNOWN_6) | BK4819_REG_24_ENABLE | BK4819_REG_24_SELECT_DTMF diff --git a/driver/st7565.c b/driver/st7565.c index e0f0f42..0c1e4aa 100644 --- a/driver/st7565.c +++ b/driver/st7565.c @@ -23,9 +23,6 @@ #include "driver/st7565.h" #include "driver/system.h" -#define LCD_WIDTH 128 -#define LCD_HEIGHT 64 - uint8_t gStatusLine[128]; uint8_t gFrameBuffer[7][128]; diff --git a/driver/st7565.h b/driver/st7565.h index 882eb2a..8954bdd 100644 --- a/driver/st7565.h +++ b/driver/st7565.h @@ -20,6 +20,9 @@ #include #include +#define LCD_WIDTH 128 +#define LCD_HEIGHT 64 + extern uint8_t gStatusLine[128]; extern uint8_t gFrameBuffer[7][128]; diff --git a/firmware b/firmware index 28df24f..0bc01d8 100644 Binary files a/firmware and b/firmware differ diff --git a/firmware.bin b/firmware.bin index 899439e..f90f8e0 100644 Binary files a/firmware.bin and b/firmware.bin differ diff --git a/firmware.packed.bin b/firmware.packed.bin index 0b86c6f..8236ecf 100644 Binary files a/firmware.packed.bin and b/firmware.packed.bin differ diff --git a/ui/main.c b/ui/main.c index ea8d29d..c140bc9 100644 --- a/ui/main.c +++ b/ui/main.c @@ -35,16 +35,15 @@ void UI_DisplayMain(void) { - const unsigned int display_width = 128; char String[16]; unsigned int vfo_num; memset(gFrameBuffer, 0, sizeof(gFrameBuffer)); if (gEeprom.KEY_LOCK && gKeypadLocked > 0) - { - UI_PrintString("Long press #", 0, display_width - 1, 1, 8); - UI_PrintString("to unlock", 0, display_width - 1, 3, 8); + { // tell user how to unlock the keyboard + UI_PrintString("Long press #", 0, LCD_WIDTH - 1, 1, 8); + UI_PrintString("to unlock", 0, LCD_WIDTH - 1, 3, 8); ST7565_BlitFullScreen(); return; } @@ -285,8 +284,7 @@ void UI_DisplayMain(void) break; case MDF_NAME: // show the channel name - if (gEeprom.VfoInfo[vfo_num].Name[0] <= 32 || - gEeprom.VfoInfo[vfo_num].Name[0] >= 127) + if (gEeprom.VfoInfo[vfo_num].Name[0] <= 32 || gEeprom.VfoInfo[vfo_num].Name[0] >= 127) { // no channel name, show the channel number instead sprintf(String, "CH-%03u", gEeprom.ScreenChannel[vfo_num] + 1); } @@ -300,8 +298,7 @@ void UI_DisplayMain(void) #ifdef ENABLE_CHAN_NAME_FREQ case MDF_NAME_FREQ: // show the channel name and frequency - if (gEeprom.VfoInfo[vfo_num].Name[0] <= 32 || - gEeprom.VfoInfo[vfo_num].Name[0] >= 127) + if (gEeprom.VfoInfo[vfo_num].Name[0] <= 32 || gEeprom.VfoInfo[vfo_num].Name[0] >= 127) { // no channel name, show channel number instead sprintf(String, "CH-%03u", gEeprom.ScreenChannel[vfo_num] + 1); } @@ -373,7 +370,7 @@ void UI_DisplayMain(void) if (Level >= 1) { - uint8_t *pLine = pLine1 + display_width; + uint8_t *pLine = pLine1 + LCD_WIDTH; memmove(pLine + 0, BITMAP_Antenna, sizeof(BITMAP_Antenna)); if (Level >= 2) memmove(pLine + 5, BITMAP_AntennaLevel1, sizeof(BITMAP_AntennaLevel1)); @@ -398,21 +395,21 @@ void UI_DisplayMain(void) strcpy(String, "AM"); } else - { // show the CTCSS/DCS symbol + { // or show the CTCSS/DCS symbol const FREQ_Config_t *pConfig = (SomeValue == 1) ? gEeprom.VfoInfo[vfo_num].pTX : gEeprom.VfoInfo[vfo_num].pRX; const unsigned int code_type = pConfig->CodeType; const char *code_list[] = {"", "CT", "DCS", "DCR"}; if (code_type >= 0 && code_type < ARRAY_SIZE(code_list)) strcpy(String, code_list[code_type]); } - UI_PrintStringSmall(String, display_width + 24, 0, Line + 1); + UI_PrintStringSmall(String, LCD_WIDTH + 24, 0, Line + 1); { // show the TX power const char pwr_list[] = "LMH"; const unsigned int i = gEeprom.VfoInfo[vfo_num].OUTPUT_POWER; String[0] = (i >= 0 && i < ARRAY_SIZE(pwr_list)) ? pwr_list[i] : '\0'; String[1] = '\0'; - UI_PrintStringSmall(String, display_width + 46, 0, Line + 1); + UI_PrintStringSmall(String, LCD_WIDTH + 46, 0, Line + 1); } if (gEeprom.VfoInfo[vfo_num].ConfigRX.Frequency != gEeprom.VfoInfo[vfo_num].ConfigTX.Frequency) @@ -424,31 +421,30 @@ void UI_DisplayMain(void) case TX_OFFSET_FREQUENCY_DIRECTION_SUB: String[0] = '-'; break; } String[1] = '\0'; - UI_PrintStringSmall(String, display_width + 54, 0, Line + 1); + UI_PrintStringSmall(String, LCD_WIDTH + 54, 0, Line + 1); } // show the TX/RX reverse symbol if (gEeprom.VfoInfo[vfo_num].FrequencyReverse) - UI_PrintStringSmall("R", display_width + 62, 0, Line + 1); + UI_PrintStringSmall("R", LCD_WIDTH + 62, 0, Line + 1); { // show the narrow band symbol - String[0] = '?'; - switch (gEeprom.VfoInfo[vfo_num].CHANNEL_BANDWIDTH) + String[0] = '\0'; + if (gEeprom.VfoInfo[vfo_num].CHANNEL_BANDWIDTH == BANDWIDTH_NARROW) { - case BANDWIDTH_WIDE: String[0] = '\0'; break; - case BANDWIDTH_NARROW: String[0] = 'N'; break; + String[0] = 'N'; + String[1] = '\0'; } - String[1] = '\0'; - UI_PrintStringSmall(String, display_width + 70, 0, Line + 1); + UI_PrintStringSmall(String, LCD_WIDTH + 70, 0, Line + 1); } // show the DTMF decoding symbol if (gEeprom.VfoInfo[vfo_num].DTMF_DECODING_ENABLE || gSetting_KILLED) - UI_PrintStringSmall("DTMF", display_width + 78, 0, Line + 1); + UI_PrintStringSmall("DTMF", LCD_WIDTH + 78, 0, Line + 1); // show the audio scramble symbol if (gEeprom.VfoInfo[vfo_num].SCRAMBLING_TYPE > 0 && gSetting_ScrambleEnable) - UI_PrintStringSmall("SCR", display_width + 106, 0, Line + 1); + UI_PrintStringSmall("SCR", LCD_WIDTH + 106, 0, Line + 1); } #ifdef ENABLE_DTMF_DECODER diff --git a/ui/rssi.c b/ui/rssi.c index 49f07b5..8b392d9 100644 --- a/ui/rssi.c +++ b/ui/rssi.c @@ -36,6 +36,9 @@ void UI_UpdateRSSI(uint16_t RSSI) char s[8]; const uint8_t line = (gEeprom.RX_CHANNEL == 0) ? 3 : 7; + if (gEeprom.KEY_LOCK && gKeypadLocked > 0) + return; // the screen is currently in use + gVFO_RSSI[gEeprom.RX_CHANNEL] = RSSI; gVFO_RSSI_Level[gEeprom.RX_CHANNEL] = 0; @@ -58,8 +61,11 @@ void Render(const uint8_t rssi, const uint8_t RssiLevel, const uint8_t VFO) uint8_t *pLine; uint8_t Line; + if (gEeprom.KEY_LOCK && gKeypadLocked > 0) + return; // the screen is currently in use + if (gCurrentFunction == FUNCTION_TRANSMIT || gScreenToDisplay != DISPLAY_MAIN) - return; + return; // it's still in use if (VFO == 0) { diff --git a/ui/status.c b/ui/status.c index 2e57756..732b6a6 100644 --- a/ui/status.c +++ b/ui/status.c @@ -36,9 +36,9 @@ void UI_DisplayStatus(const bool test_display) gUpdateStatus = false; - memset(line, 0, sizeof(gStatusLine)); + memset(gStatusLine, 0, sizeof(gStatusLine)); - line += 2; +// line += 2; // POWER-SAVE indicator if (gCurrentFunction == FUNCTION_POWER_SAVE || test_display) @@ -109,11 +109,10 @@ void UI_DisplayStatus(const bool test_display) // USB-C charge indicator if (gChargingWithTypeC || test_display) memmove(line, BITMAP_USB_C, sizeof(BITMAP_USB_C)); - line += sizeof(BITMAP_USB_C); +// line += sizeof(BITMAP_USB_C); - line += 4; - // BATTERY LEVEL indicator + line = gStatusLine + LCD_WIDTH - sizeof(BITMAP_BatteryLevel5); // point to the far right side of the screen if (gBatteryDisplayLevel >= 5 || test_display) memmove(line, BITMAP_BatteryLevel5, sizeof(BITMAP_BatteryLevel5)); else @@ -128,7 +127,6 @@ void UI_DisplayStatus(const bool test_display) else if (gLowBatteryBlink == 1) memmove(line, BITMAP_BatteryLevel1, sizeof(BITMAP_BatteryLevel1)); -// line += sizeof(BITMAP_BatteryLevel1); ST7565_BlitStatusLine(); } diff --git a/version.c b/version.c index 795c852..aea9735 100644 --- a/version.c +++ b/version.c @@ -2,7 +2,7 @@ #ifdef GIT_HASH #define VER GIT_HASH #else - #define VER "230918" + #define VER "230919" #endif const char Version[] = "OEFW-"VER; diff --git a/win_make.bat b/win_make.bat index e569c6a..cbd5692 100644 --- a/win_make.bat +++ b/win_make.bat @@ -21,7 +21,7 @@ del /S /Q *.d >nul 2>nul :: https://github.com/OneOfEleven/k5prog-win :: ::python -m pip install --upgrade pip crcmod -fw-pack.py firmware.bin 230918 firmware.packed.bin +fw-pack.py firmware.bin 230919 firmware.packed.bin ::arm-none-eabi-size firmware