From e88ee1826e5e2457aee06bce43d46353543593db Mon Sep 17 00:00:00 2001 From: Reed Nightingale Date: Sun, 26 Jan 2020 10:22:01 -0800 Subject: [PATCH 01/10] Remove unused variables and set default values for colors --- ubitx_ui.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ubitx_ui.cpp b/ubitx_ui.cpp index 6f11eb7..d8328f8 100644 --- a/ubitx_ui.cpp +++ b/ubitx_ui.cpp @@ -193,8 +193,9 @@ int getValueByKnob(int minimum, int maximum, int step_size, int initial, const } void displayVFO(Vfo_e vfo){ - int x, y; - int displayColor, displayBackground, displayBorder; + uint16_t displayColor = COLOR_INACTIVE_TEXT; + uint16_t displayBackground = COLOR_INACTIVE_BACKGROUND; + uint16_t displayBorder = COLOR_INACTIVE_BORDER; Button button; if (globalSettings.splitOn){ From 2ac24eb28df826a631c78e82c2db3358478dbf5a Mon Sep 17 00:00:00 2001 From: Reed Nightingale Date: Sun, 26 Jan 2020 10:22:20 -0800 Subject: [PATCH 02/10] Minor whitespace adjustment, and remove unused variables --- ubitx_v6.3.1_code.ino | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/ubitx_v6.3.1_code.ino b/ubitx_v6.3.1_code.ino index 617977e..0efc991 100644 --- a/ubitx_v6.3.1_code.ino +++ b/ubitx_v6.3.1_code.ino @@ -305,8 +305,6 @@ void checkPTT(){ //check if the encoder button was pressed void checkButton(){ - int i, t1, t2, knob, new_knob; - //only if the button is pressed if (!btnDown()) return; @@ -325,10 +323,9 @@ void checkButton(){ doSetup2(); return; } - } - active_delay(100); + } + active_delay(100); - doCommands(); //wait for the button to go up again while(btnDown()) From b65e5eb90c9ff695b79833a6077430300b5c08f5 Mon Sep 17 00:00:00 2001 From: Reed Nightingale Date: Sun, 26 Jan 2020 10:38:35 -0800 Subject: [PATCH 03/10] un-name unused variable --- PDQ_MinLib/PDQ_GFX.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PDQ_MinLib/PDQ_GFX.h b/PDQ_MinLib/PDQ_GFX.h index cb9f152..f2a551e 100644 --- a/PDQ_MinLib/PDQ_GFX.h +++ b/PDQ_MinLib/PDQ_GFX.h @@ -839,7 +839,7 @@ void PDQ_GFX::drawChar(coord_t x, coord_t y, unsigned char c, color_t color, // Draw a character with GFX font template -void PDQ_GFX::drawCharGFX(coord_t x, coord_t y, unsigned char c, color_t color, color_t bg, uint8_t size) +void PDQ_GFX::drawCharGFX(coord_t x, coord_t y, unsigned char c, color_t color, color_t /*bg*/, uint8_t size) { // Character is assumed previously filtered by write() to eliminate // newlines, returns, non-printable characters, etc. Calling drawChar() From f54320e8cb74869477e77d5ba1c4e2371bcd1b5e Mon Sep 17 00:00:00 2001 From: Reed Nightingale Date: Sun, 26 Jan 2020 10:39:01 -0800 Subject: [PATCH 04/10] Match unsigned with unsigned --- morse.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/morse.cpp b/morse.cpp index 20a1020..2551577 100644 --- a/morse.cpp +++ b/morse.cpp @@ -66,7 +66,7 @@ static void morseLetter(char c, uint16_t dit_duration_ms){ return; } - for (int i = 0; i < sizeof(morse_table)/ sizeof(struct Morse); i++){ + for (unsigned int i = 0; i < sizeof(morse_table)/ sizeof(struct Morse); i++){ struct Morse m; memcpy_P(&m, morse_table + i, sizeof(struct Morse)); From 6dd4b37d8a2f842dcbfe9f10f48978562a651733 Mon Sep 17 00:00:00 2001 From: Reed Nightingale Date: Sun, 26 Jan 2020 10:40:03 -0800 Subject: [PATCH 05/10] analogRead technically returns an int, but it only can be 0-1023, so practically it's an unsigned int. This matches types for the constants. Also removed cwAdcSTFrom, since the value will always be greater than 0 --- keyer.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/keyer.cpp b/keyer.cpp index dbbf4e7..21bdf98 100644 --- a/keyer.cpp +++ b/keyer.cpp @@ -29,7 +29,7 @@ */ //CW ADC Range -static const unsigned int cwAdcSTFrom = 0; +//static const unsigned int cwAdcSTFrom = 0; static const unsigned int cwAdcSTTo = 50; static const unsigned int cwAdcBothFrom = cwAdcSTTo + 1; static const unsigned int cwAdcBothTo = 300; @@ -79,7 +79,7 @@ uint8_t keyerControl = 0; char update_PaddleLatch(bool isUpdateKeyState) { unsigned char tmpKeyerControl = 0; - int paddle = analogRead(ANALOG_KEYER); + unsigned int paddle = analogRead(ANALOG_KEYER); //use the PTT as the key for tune up, quick QSOs if (digitalRead(PTT) == 0) @@ -93,7 +93,7 @@ char update_PaddleLatch(bool isUpdateKeyState) { else{ if (KeyerMode_e::KEYER_STRAIGHT != globalSettings.keyerMode) tmpKeyerControl = 0 ; - else if (paddle >= cwAdcSTFrom && paddle <= cwAdcSTTo) + else if (paddle <= cwAdcSTTo) tmpKeyerControl = DIT_L ; else tmpKeyerControl = 0 ; From c38460576b572207f8827a589e3b428887d97fc1 Mon Sep 17 00:00:00 2001 From: Reed Nightingale Date: Sun, 26 Jan 2020 10:40:59 -0800 Subject: [PATCH 06/10] A number of explicit casts, initializations, and type adjustments to avoid warnings --- setup.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/setup.cpp b/setup.cpp index e933700..135ec00 100644 --- a/setup.cpp +++ b/setup.cpp @@ -87,7 +87,7 @@ struct SettingScreen_t { void runSetting(const SettingScreen_t* const p_screen) { - SettingScreen_t screen = {0}; + SettingScreen_t screen = {nullptr,nullptr,0,0,nullptr,nullptr,nullptr,nullptr}; memcpy_P(&screen,p_screen,sizeof(screen)); displayDialog(screen.Title, screen.AdditionalText); @@ -235,7 +235,7 @@ void ssCwSpeedValidate(const long int candidate_value_in, long int* validated_va { *validated_value_out = LIMIT(candidate_value_in,1,100); } -void ssCwSpeedChange(const long int new_value, char* buff_out, const size_t buff_out_size) +void ssCwSpeedChange(const long int new_value, char* buff_out, const size_t /*buff_out_size*/) { ltoa(new_value, buff_out, 10); } @@ -334,7 +334,7 @@ void ssKeyerInitialize(long int* start_value_out) } void ssKeyerValidate(const long int candidate_value_in, long int* validated_value_out) { - *validated_value_out = LIMIT(candidate_value_in,KeyerMode_e::KEYER_STRAIGHT,KeyerMode_e::KEYER_IAMBIC_B); + *validated_value_out = LIMIT(candidate_value_in,(uint8_t)KeyerMode_e::KEYER_STRAIGHT,(uint8_t)KeyerMode_e::KEYER_IAMBIC_B); } void ssKeyerChange(const long int new_value, char* buff_out, const size_t buff_out_size) { @@ -350,7 +350,7 @@ void ssKeyerChange(const long int new_value, char* buff_out, const size_t buff_o } void ssKeyerFinalize(const long int final_value) { - globalSettings.keyerMode = final_value; + globalSettings.keyerMode = (KeyerMode_e)final_value; SaveSettingsToEeprom(); } const char SS_KEYER_T [] PROGMEM = "CW Keyer/Paddle Type"; @@ -409,7 +409,7 @@ void runResetAllSetting(){runSetting(&ssResetAll);} struct MenuItem_t { const char* const ItemName; - const void (*OnSelect)(); + void (*OnSelect)(); }; void runMenu(const MenuItem_t* const menu_items, const uint16_t num_items); @@ -480,7 +480,7 @@ void movePuck(unsigned int old_index, unsigned int new_index) void runMenu(const MenuItem_t* const menu_items, const uint16_t num_items) { static const unsigned int COUNTS_PER_ITEM = 10; - const unsigned int MAX_KNOB_VALUE = num_items*COUNTS_PER_ITEM - 1; + const int MAX_KNOB_VALUE = num_items*COUNTS_PER_ITEM - 1; int knob_sum = 0; unsigned int old_index = 0; From fea7b8d86803d3cda517f5c696c83a6e63bdf97c Mon Sep 17 00:00:00 2001 From: Reed Nightingale Date: Sun, 26 Jan 2020 10:42:20 -0800 Subject: [PATCH 07/10] Move string to PROGMEM, and remove unused return value --- nano_gui.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nano_gui.cpp b/nano_gui.cpp index 9efe8ec..fdfdfa3 100644 --- a/nano_gui.cpp +++ b/nano_gui.cpp @@ -162,7 +162,7 @@ PDQ_ILI9341 tft; #include "nano_font.h" -bool xpt2046_Init(){ +void xpt2046_Init(){ pinMode(CS_PIN, OUTPUT); digitalWrite(CS_PIN, HIGH); } @@ -246,7 +246,8 @@ void setupTouch(){ int x1, y1, x2, y2, x3, y3, x4, y4; displayClear(DISPLAY_BLACK); - displayText("Click on the cross", 20,100, 200, 50, DISPLAY_WHITE, DISPLAY_BLACK, DISPLAY_BLACK); + strncpy_P(b,(const char*)F("Click on the cross"),sizeof(b)); + displayText(b, 20,100, 200, 50, DISPLAY_WHITE, DISPLAY_BLACK, DISPLAY_BLACK); // TOP-LEFT displayHline(10,20,20,DISPLAY_WHITE); From fe9f04d14681b2d70360acb960bd05ad06b87bd6 Mon Sep 17 00:00:00 2001 From: Reed Nightingale Date: Sun, 26 Jan 2020 10:42:37 -0800 Subject: [PATCH 08/10] Remove unused static --- ubitx_cat.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/ubitx_cat.cpp b/ubitx_cat.cpp index 91c7f49..27d9707 100644 --- a/ubitx_cat.cpp +++ b/ubitx_cat.cpp @@ -19,7 +19,6 @@ static byte rxBufferCheckCount = 0; #define CAT_RECEIVE_TIMEOUT 500 static byte cat[5]; static byte insideCat = 0; -static byte useOpenRadioControl = 0; //for broken protocol #define CAT_RECEIVE_TIMEOUT 500 From 15059367137d7f1b58122a8624415f635797c8dc Mon Sep 17 00:00:00 2001 From: Reed Nightingale Date: Sun, 26 Jan 2020 10:43:11 -0800 Subject: [PATCH 09/10] Remove unused variable --- ubitx_si5351.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ubitx_si5351.cpp b/ubitx_si5351.cpp index 8e900e0..27f1b7a 100644 --- a/ubitx_si5351.cpp +++ b/ubitx_si5351.cpp @@ -66,12 +66,11 @@ void i2cWriten(uint8_t reg, uint8_t *vals, uint8_t vcnt) { // write array void si5351bx_init() { // Call once at power-up, start PLLA - uint8_t reg; uint32_t msxp1; Wire.begin(); i2cWrite(149, 0); // SpreadSpectrum off i2cWrite(3, si5351bx_clken); // Disable all CLK output drivers i2cWrite(183, SI5351BX_XTALPF << 6); // Set 25mhz crystal load capacitance - msxp1 = 128 * SI5351BX_MSA - 512; // and msxp2=0, msxp3=1, not fractional + uint32_t msxp1 = 128 * SI5351BX_MSA - 512; // and msxp2=0, msxp3=1, not fractional uint8_t vals[8] = {0, 1, BB2(msxp1), BB1(msxp1), BB0(msxp1), 0, 0, 0}; i2cWriten(26, vals, 8); // Write to 8 PLLA msynth regs i2cWrite(177, 0x20); // Reset PLLA (0x80 resets PLLB) From 298bb479b5b0114b3f895285946d14e852a2a866 Mon Sep 17 00:00:00 2001 From: Reed Nightingale Date: Sun, 26 Jan 2020 10:47:57 -0800 Subject: [PATCH 10/10] Explicit cast to prevent integer overflow --- encoder.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/encoder.cpp b/encoder.cpp index 9caa45c..7eb57d5 100644 --- a/encoder.cpp +++ b/encoder.cpp @@ -83,7 +83,7 @@ void enc_setup(void) TCCR1A = 0;//"normal" mode TCCR1B = 3;//clock divider of 64 TCNT1 = 0;//start counting at 0 - OCR1A = F_CPU * CALLBACK_PERIOD_MS / 1000 / 64;//set target number + OCR1A = F_CPU * (unsigned long)CALLBACK_PERIOD_MS / 1000 / 64;//set target number TIMSK1 |= (1 << OCIE1A);//enable interrupt }