Fixed most compilation warnings and a delay issue

* Fixed most compilation warnings (Compiler warning level: All)
* Fixed a delay issue in enc_read function.
This commit is contained in:
Qi Wenmin 2018-01-17 14:42:15 +08:00
parent 95e5c1dfe5
commit 209cd3a49c
6 changed files with 27 additions and 34 deletions

View File

@ -398,7 +398,7 @@ void ReadEEPRom_FT817(byte fromType)
void WriteEEPRom_FT817(byte fromType)
{
byte temp0 = CAT_BUFF[0];
//byte temp0 = CAT_BUFF[0];
byte temp1 = CAT_BUFF[1];
CAT_BUFF[0] = 0;

View File

@ -208,10 +208,14 @@ void sendCWChar(char cwKeyChar)
charLength = ((tmpChar >> 6) & 0x03) + 3;
for (j = 0; j < charLength; j++)
sendBuff[j] = (tmpChar << j + 2) & 0x80;
sendBuff[j] = (tmpChar << (j + 2)) & 0x80;
break;
}
else
{
charLength = 0;
}
}
}
@ -257,7 +261,7 @@ unsigned long scrollDispayTime = 0;
#define scrollSpeed 500
byte displayScrolStep = 0;
int controlAutoCW(){
void controlAutoCW(){
int knob = 0;
byte i;

View File

@ -211,7 +211,7 @@ unsigned long vfoA=7150000L, vfoB=14200000L, sideTone=800, usbCarrier;
unsigned long vfoA_eeprom, vfoB_eeprom; //for protect eeprom life
unsigned long frequency, ritRxFrequency, ritTxFrequency; //frequency is the current frequency on the dial
int cwSpeed = 100; //this is actuall the dot period in milliseconds
unsigned int cwSpeed = 100; //this is actuall the dot period in milliseconds
extern int32_t calibration;
//for store the mode in eeprom
@ -320,8 +320,8 @@ void setNextHamBandFreq(unsigned long f, char moveDirection)
loadMode = (byte)(resultFreq >> 30);
resultFreq = resultFreq & 0x3FFFFFFF;
if ((resultFreq / 1000) < hamBandRange[findedIndex][0] || (resultFreq / 1000) > hamBandRange[findedIndex][1])
resultFreq = (unsigned long)(hamBandRange[findedIndex][0]) * 1000;
if ((resultFreq / 1000) < hamBandRange[(unsigned char)findedIndex][0] || (resultFreq / 1000) > hamBandRange[(unsigned char)findedIndex][1])
resultFreq = (unsigned long)(hamBandRange[(unsigned char)findedIndex][0]) * 1000;
setFrequency(resultFreq);
byteWithFreqToMode(loadMode);
@ -422,8 +422,6 @@ void setTXFilters(unsigned long freq){
*/
void setFrequency(unsigned long f){
uint64_t osc_f;
//1 digits discarded
f = (f / 50) * 50;
@ -448,8 +446,6 @@ void setFrequency(unsigned long f){
*/
void startTx(byte txMode, byte isDisplayUpdate){
unsigned long tx_freq = 0;
//Check Hamband only TX //Not found Hamband index by now frequency
if (tuneTXType >= 100 && getIndexHambanBbyFreq(ritOn ? ritTxFrequency : frequency) == -1) {
//no message
@ -545,8 +541,6 @@ void checkPTT(){
}
void checkButton(){
int i, t1, t2, knob, new_knob;
//only if the button is pressed
if (!btnDown())
return;
@ -575,7 +569,7 @@ void checkButton(){
void doTuning(){
int s = 0;
unsigned long prev_freq;
int incdecValue = 0;
long incdecValue = 0;
if ((vfoActive == VFO_A && ((isDialLock & 0x01) == 0x01)) ||
(vfoActive == VFO_B && ((isDialLock & 0x02) == 0x02)))
@ -610,7 +604,7 @@ void doTuning(){
if (incdecValue > 0 && frequency + incdecValue > HIGHEST_FREQ_DIAL)
frequency = HIGHEST_FREQ_DIAL;
else if (incdecValue < 0 && frequency < -incdecValue + LOWEST_FREQ_DIAL) //for compute and compare based integer type.
else if (incdecValue < 0 && frequency < (unsigned long)(-incdecValue + LOWEST_FREQ_DIAL)) //for compute and compare based integer type.
frequency = LOWEST_FREQ_DIAL;
else
frequency += incdecValue;
@ -630,8 +624,6 @@ void doTuning(){
* RIT only steps back and forth by 100 hz at a time
*/
void doRIT(){
unsigned long newFreq;
int knob = enc_read();
unsigned long old_freq = frequency;

View File

@ -13,7 +13,7 @@
#define printLineF1(x) (printLineF(1, x))
#define printLineF2(x) (printLineF(0, x))
int menuBand(int btn){
void menuBand(int btn){
int knob = 0;
int stepChangeCount = 0;
byte btnPressCount = 0;
@ -301,7 +301,7 @@ void menuExit(int btn){
}
}
int menuCWSpeed(int btn){
void menuCWSpeed(int btn){
int knob = 0;
int wpm;
@ -356,7 +356,7 @@ int menuCWSpeed(int btn){
menuOn = 0;
}
int menuCWAutoKey(int btn){
void menuCWAutoKey(int btn){
if (!btn){
printLineF2(F("CW AutoKey Mode?"));
return;
@ -379,7 +379,7 @@ int menuCWAutoKey(int btn){
menuOn = 0;
}
int menuSetupCwDelay(int btn){
void menuSetupCwDelay(int btn){
int knob = 0;
int tmpCWDelay = cwDelayTime * 10;
@ -427,7 +427,7 @@ int menuSetupCwDelay(int btn){
menuOn = 0;
}
int menuSetupTXCWInterval(int btn){
void menuSetupTXCWInterval(int btn){
int knob = 0;
int tmpTXCWInterval = delayBeforeCWStartTime * 2;
@ -490,10 +490,8 @@ int menuSetupTXCWInterval(int btn){
extern int32_t calibration;
extern uint32_t si5351bx_vcoa;
int factoryCalibration(int btn){
void factoryCalibration(int btn){
int knob = 0;
int32_t prev_calibration;
//keep clear of any previous button press
while (btnDown())
@ -502,10 +500,9 @@ int factoryCalibration(int btn){
if (!btn){
printLineF2(F("Set Calibration?"));
return 0;
return;
}
prev_calibration = calibration;
calibration = 0;
isUSB = true;
@ -560,13 +557,13 @@ int factoryCalibration(int btn){
delay(100);
}
int menuSetupCalibration(int btn){
void menuSetupCalibration(int btn){
int knob = 0;
int32_t prev_calibration;
if (!btn){
printLineF2(F("Set Calibration?"));
return 0;
return;
}
printLineF1(F("Set to Zero-beat,"));

View File

@ -62,7 +62,7 @@ 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;
uint32_t msxp1;
Wire.begin();
i2cWrite(149, 0); // SpreadSpectrum off
i2cWrite(3, si5351bx_clken); // Disable all CLK output drivers

View File

@ -115,7 +115,7 @@ void drawMeter(int8_t needle){
*/
// The generic routine to display one line on the LCD
void printLine(char linenmbr, char *c) {
void printLine(unsigned char linenmbr, const char *c) {
if (strcmp(c, printBuff[linenmbr])) { // only refresh the display when there was a change
lcd.setCursor(0, linenmbr); // place the cursor at the beginning of the selected line
lcd.print(c);
@ -160,11 +160,11 @@ void printLineFromEEPRom(char linenmbr, char lcdColumn, byte eepromStartIndex, b
}
// short cut to print to the first line
void printLine1(char *c){
void printLine1(const char *c){
printLine(1,c);
}
// short cut to print to the first line
void printLine2(char *c){
void printLine2(const char *c){
printLine(0,c);
}
@ -312,9 +312,9 @@ int enc_read(void) {
byte newState;
int enc_speed = 0;
long stop_by = millis() + 50;
unsigned long start_at = millis();
while (millis() < stop_by) { // check if the previous state was stable
while (millis() - start_at < 50) { // check if the previous state was stable
newState = enc_state(); // Get current state
if (newState != enc_prev_state)