Updated backlight menu options

This commit is contained in:
OneOfEleven 2023-09-24 19:52:14 +01:00
parent 1a626f83ae
commit 9cc84bd00b
8 changed files with 50 additions and 19 deletions

View File

@ -543,7 +543,7 @@ void BOARD_EEPROM_Init(void)
gEeprom.CROSS_BAND_RX_TX = (Data[2] < 3) ? Data[2] : CROSS_BAND_OFF; gEeprom.CROSS_BAND_RX_TX = (Data[2] < 3) ? Data[2] : CROSS_BAND_OFF;
gEeprom.BATTERY_SAVE = (Data[3] < 5) ? Data[3] : 4; gEeprom.BATTERY_SAVE = (Data[3] < 5) ? Data[3] : 4;
gEeprom.DUAL_WATCH = (Data[4] < 3) ? Data[4] : DUAL_WATCH_CHAN_A; 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.TAIL_NOTE_ELIMINATION = (Data[6] < 2) ? Data[6] : false;
gEeprom.VFO_OPEN = (Data[7] < 2) ? Data[7] : true; gEeprom.VFO_OPEN = (Data[7] < 2) ? Data[7] : true;

View File

@ -20,7 +20,7 @@
#include "settings.h" #include "settings.h"
// this is decremented once every 500ms // this is decremented once every 500ms
uint8_t gBacklightCountdown = 0; uint16_t gBacklightCountdown = 0;
void BACKLIGHT_TurnOn(void) void BACKLIGHT_TurnOn(void)
{ {
@ -34,22 +34,27 @@ void BACKLIGHT_TurnOn(void)
{ {
default: default:
case 1: // 5 sec case 1: // 5 sec
gBacklightCountdown = 2 * 5; gBacklightCountdown = 5;
break; break;
case 2: // 10 sec case 2: // 10 sec
gBacklightCountdown = 2 * 10; gBacklightCountdown = 10;
break; break;
case 3: // 20 sec case 3: // 20 sec
gBacklightCountdown = 2 * 20; gBacklightCountdown = 20;
break; break;
case 4: // 40 sec case 4: // 1 min
gBacklightCountdown = 2 * 40; gBacklightCountdown = 60;
break; break;
case 5: // 80 sec case 5: // 2 min
gBacklightCountdown = 2 * 80; gBacklightCountdown = 60 * 2;
break; break;
case 6: // always on case 6: // 4 min
gBacklightCountdown = 60 * 4;
break;
case 7: // always on
gBacklightCountdown = 0; gBacklightCountdown = 0;
break; break;
} }
gBacklightCountdown *= 2;
} }

View File

@ -19,7 +19,7 @@
#include <stdint.h> #include <stdint.h>
extern uint8_t gBacklightCountdown; extern uint16_t gBacklightCountdown;
void BACKLIGHT_TurnOn(void); void BACKLIGHT_TurnOn(void);

Binary file not shown.

Binary file not shown.

View File

@ -249,14 +249,15 @@ const char gSubMenu_F_LOCK[6][4] =
"438" "438"
}; };
const char gSubMenu_BACKLIGHT[7][7] = const char gSubMenu_BACKLIGHT[8][7] =
{ {
"OFF", "OFF",
"5 sec", "5 sec",
"10 sec", "10 sec",
"20 sec", "20 sec",
"40 sec", "1 min",
"80 sec", "2 min",
"4 min",
"ON" "ON"
}; };

View File

@ -138,7 +138,7 @@ extern const char gSubMenu_PONMSG[4][5];
extern const char gSubMenu_ROGER[3][6]; extern const char gSubMenu_ROGER[3][6];
extern const char gSubMenu_RESET[2][4]; extern const char gSubMenu_RESET[2][4];
extern const char gSubMenu_F_LOCK[6][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 #ifdef ENABLE_COMPANDER
extern const char gSubMenu_Compand[4][6]; extern const char gSubMenu_Compand[4][6];
#endif #endif

View File

@ -68,10 +68,13 @@ typedef struct
int16_t sum_dB; int16_t sum_dB;
} t_gain_table; } t_gain_table;
void __fastcall create_gain_table(const char *filename) void create_gain_table(const char *filename)
{ {
std::vector <t_gain_table> gain_table; std::vector <t_gain_table> gain_table;
if (filename == NULL)
return;
// front end register dB values // front end register dB values
// const int16_t lna_short_dB[4] = { (-19), (-16), (-11), (0)}; // was // const int16_t lna_short_dB[4] = { (-19), (-16), (-11), (0)}; // was
const int16_t lna_short_dB[4] = { (-33), (-30), (-24), (0)}; // corrected 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 // 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]; t_gain_table entry1 = gain_table[i];
for (unsigned int k = i + 1; k < gain_table.size(); k++) 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--) for (int i = (int)gain_table.size() - 1; i >= 0; i--)
{ {
const t_gain_table entry = gain_table[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 // 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"); FILE *file = fopen(filename, "w");
if (file == NULL) if (file == NULL)
return; 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 // "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 // 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 <uint8_t> data; std::vector <uint8_t> data;
if (filename1 == NULL || filename2 == NULL)
return;
// **************************** // ****************************
// load the file // load the file