diff --git a/board.c b/board.c index 836e5e3..f70982a 100644 --- a/board.c +++ b/board.c @@ -543,7 +543,7 @@ void BOARD_EEPROM_Init(void) gEeprom.CROSS_BAND_RX_TX = (Data[2] < 3) ? Data[2] : CROSS_BAND_OFF; gEeprom.BATTERY_SAVE = (Data[3] < 5) ? Data[3] : 4; gEeprom.DUAL_WATCH = (Data[4] < 3) ? Data[4] : DUAL_WATCH_CHAN_A; - gEeprom.BACKLIGHT = (Data[5] < ARRAY_SIZE(gSubMenu_BACKLIGHT)) ? Data[5] : 4; + gEeprom.BACKLIGHT = (Data[5] < ARRAY_SIZE(gSubMenu_BACKLIGHT)) ? Data[5] : 3; gEeprom.TAIL_NOTE_ELIMINATION = (Data[6] < 2) ? Data[6] : false; gEeprom.VFO_OPEN = (Data[7] < 2) ? Data[7] : true; diff --git a/driver/backlight.c b/driver/backlight.c index 805c929..bfeedfe 100644 --- a/driver/backlight.c +++ b/driver/backlight.c @@ -20,7 +20,7 @@ #include "settings.h" // this is decremented once every 500ms -uint8_t gBacklightCountdown = 0; +uint16_t gBacklightCountdown = 0; void BACKLIGHT_TurnOn(void) { @@ -34,22 +34,27 @@ void BACKLIGHT_TurnOn(void) { default: case 1: // 5 sec - gBacklightCountdown = 2 * 5; + gBacklightCountdown = 5; break; case 2: // 10 sec - gBacklightCountdown = 2 * 10; + gBacklightCountdown = 10; break; case 3: // 20 sec - gBacklightCountdown = 2 * 20; + gBacklightCountdown = 20; break; - case 4: // 40 sec - gBacklightCountdown = 2 * 40; + case 4: // 1 min + gBacklightCountdown = 60; break; - case 5: // 80 sec - gBacklightCountdown = 2 * 80; + case 5: // 2 min + gBacklightCountdown = 60 * 2; break; - case 6: // always on + case 6: // 4 min + gBacklightCountdown = 60 * 4; + break; + case 7: // always on gBacklightCountdown = 0; break; } + + gBacklightCountdown *= 2; } diff --git a/driver/backlight.h b/driver/backlight.h index 1819a24..67967bf 100644 --- a/driver/backlight.h +++ b/driver/backlight.h @@ -19,7 +19,7 @@ #include -extern uint8_t gBacklightCountdown; +extern uint16_t gBacklightCountdown; void BACKLIGHT_TurnOn(void); diff --git a/firmware.bin b/firmware.bin index a9e3b7a..8f66461 100644 Binary files a/firmware.bin and b/firmware.bin differ diff --git a/firmware.packed.bin b/firmware.packed.bin index ebced18..947497a 100644 Binary files a/firmware.packed.bin and b/firmware.packed.bin differ diff --git a/ui/menu.c b/ui/menu.c index 10ecdca..145133e 100644 --- a/ui/menu.c +++ b/ui/menu.c @@ -249,14 +249,15 @@ const char gSubMenu_F_LOCK[6][4] = "438" }; -const char gSubMenu_BACKLIGHT[7][7] = +const char gSubMenu_BACKLIGHT[8][7] = { "OFF", "5 sec", "10 sec", "20 sec", - "40 sec", - "80 sec", + "1 min", + "2 min", + "4 min", "ON" }; diff --git a/ui/menu.h b/ui/menu.h index 1aa256c..96da38d 100644 --- a/ui/menu.h +++ b/ui/menu.h @@ -138,7 +138,7 @@ extern const char gSubMenu_PONMSG[4][5]; extern const char gSubMenu_ROGER[3][6]; extern const char gSubMenu_RESET[2][4]; extern const char gSubMenu_F_LOCK[6][4]; -extern const char gSubMenu_BACKLIGHT[7][7]; +extern const char gSubMenu_BACKLIGHT[8][7]; #ifdef ENABLE_COMPANDER extern const char gSubMenu_Compand[4][6]; #endif diff --git a/utils/main.cpp b/utils/main.cpp index bbfe7bd..2d963ab 100644 --- a/utils/main.cpp +++ b/utils/main.cpp @@ -68,10 +68,13 @@ typedef struct int16_t sum_dB; } t_gain_table; -void __fastcall create_gain_table(const char *filename) +void create_gain_table(const char *filename) { std::vector gain_table; + if (filename == NULL) + return; + // front end register dB values // const int16_t lna_short_dB[4] = { (-19), (-16), (-11), (0)}; // was const int16_t lna_short_dB[4] = { (-33), (-30), (-24), (0)}; // corrected @@ -149,7 +152,7 @@ void __fastcall create_gain_table(const char *filename) } // sort the table according top the sum dB - for (unsigned int i = 0; i < gain_table.size() - 1; i++) + for (unsigned int i = 0; i < (gain_table.size() - 1); i++) { t_gain_table entry1 = gain_table[i]; for (unsigned int k = i + 1; k < gain_table.size(); k++) @@ -196,7 +199,7 @@ void __fastcall create_gain_table(const char *filename) } } - // find the QS original index + // find the index for the original Quansheng register settings for (int i = (int)gain_table.size() - 1; i >= 0; i--) { const t_gain_table entry = gain_table[i]; @@ -217,6 +220,25 @@ void __fastcall create_gain_table(const char *filename) // *************************** // save the table to a file +/* + typedef struct + { + #if 1 + // bitfields take up less flash bytes + uint8_t lna_short:2; // 0 ~ 3 + uint8_t lna:3; // 0 ~ 7 + uint8_t mixer:2; // 0 ~ 3 + uint8_t pga:3; // 0 ~ 7 + #else + uint8_t lna_short; // 0 ~ 3 + uint8_t lna; // 0 ~ 7 + uint8_t mixer; // 0 ~ 3 + uint8_t pga; // 0 ~ 7 + #endif + } t_am_fix_gain_table; + //} __attribute__((packed)) t_am_fix_gain_table; +*/ + FILE *file = fopen(filename, "w"); if (file == NULL) return; @@ -261,10 +283,13 @@ void __fastcall create_gain_table(const char *filename) // "rotate_font()" has nothing to do with this program at all, I just needed // to write a bit of code to rotate some fonts I've drawn -void __fastcall rotate_font(const char *filename1, const char *filename2) +void rotate_font(const char *filename1, const char *filename2) { std::vector data; + if (filename1 == NULL || filename2 == NULL) + return; + // **************************** // load the file