Various code compilation warning cleanups.  (Thanks, Paul, K1XM)

  i want to go ice fishing
pull/82/head
Anthony Good 2019-11-13 20:26:54 -05:00
rodzic 61997f2790
commit 75c4d6442a
3 zmienionych plików z 33 dodań i 20 usunięć

Wyświetl plik

@ -1120,6 +1120,9 @@ Recent Update History
Completed manual merge of contributed code for HARDWARE_YCCC_SO2R_MINI . Testing in progress. (Thanks, Paul, K1XM)
Includes FEATURE_SO2R_BASE, FEATURE_SO2R_SWITCHES, FEATURE_SO2R_ANTENNA
2019.11.13.01
Various code compilation warning cleanups. (Thanks, Paul, K1XM)
This code is currently maintained for and compiled with Arduino 1.8.x. Your mileage may vary with other versions.
ATTENTION: LIBRARY FILES MUST BE PUT IN LIBRARIES DIRECTORIES AND NOT THE INO SKETCH DIRECTORY !!!!
@ -1134,7 +1137,7 @@ Recent Update History
*/
#define CODE_VERSION "2019.11.08.03"
#define CODE_VERSION "2019.11.13.01"
#define eeprom_magic_number 35 // you can change this number to have the unit re-initialize EEPROM
#include <stdio.h>
@ -9430,7 +9433,7 @@ void winkey_farnsworth_command(byte incoming_serial_byte) {
configuration.wpm_farnsworth = incoming_serial_byte;
}
#else
byte dummy_byte = incoming_serial_byte; // to get rid of compiler warning about unused variable
(void)incoming_serial_byte; // to get rid of compiler warning about unused variable
#endif //FEATURE_FFARNSWORTH
}
@ -9509,16 +9512,18 @@ void winkey_ptt_times_parm2_command(byte incoming_serial_byte) {
#ifdef FEATURE_WINKEY_EMULATION
void winkey_set_pot_parm1_command(byte incoming_serial_byte) {
//#ifdef FEATURE_POTENTIOMETER
pot_wpm_low_value = incoming_serial_byte;
//#endif
}
#endif //FEATURE_WINKEY_EMULATION
//-------------------------------------------------------------------------------------------------------
#ifdef FEATURE_WINKEY_EMULATION
void winkey_set_pot_parm2_command(byte incoming_serial_byte) {
#ifdef FEATURE_POTENTIOMETER
pot_wpm_high_value = (pot_wpm_low_value + incoming_serial_byte);
pot_wpm_high_value = (pot_wpm_low_value + incoming_serial_byte);
#else
(void)incoming_serial_byte; // to get rid of compiler warning about unused variable
#endif
}
#endif //FEATURE_WINKEY_EMULATION
@ -9540,7 +9545,7 @@ void winkey_set_pot_parm3_command (byte incoming_serial_byte) {
#endif //OPTION_WINKEY_2_SUPPORT
configuration.pot_activated = 1;
#else
byte dummy_byte = incoming_serial_byte; // to get rid of compiler warning about unused variable
(void)incoming_serial_byte; // to get rid of compiler warning about unused variable
#endif
}
#endif //FEATURE_WINKEY_EMULATION
@ -18060,7 +18065,6 @@ void MouseRptParser::OnMouseMove(MOUSEINFO *mi){
int current_dY = (mi->dY);
/* X/Y method - doesn't work too well
/*
if ((current_dX != last_dX) && (abs(current_dX) > abs(current_dY)) && (abs(current_dX) > 3)){
dit_buffer = 1;
}

Wyświetl plik

@ -1,7 +1,9 @@
#include "Arduino.h"
#include "buttonarray.h"
Button::InitLimits(uint8_t step){
/* contributed by W6IPA */
void Button::InitLimits(uint8_t step){
/*
typical button values:
@ -25,7 +27,7 @@ Button::InitLimits(uint8_t step){
step_ = step;
}
Button::InitLimits(uint8_t step, int32_t low_limit, int32_t high_limit){
void Button::InitLimits(uint8_t step, int32_t low_limit, int32_t high_limit){
low_limit_ = low_limit;
high_limit_ = high_limit;
step_ = step;
@ -46,7 +48,7 @@ int32_t Button::low_limit(){
}
// Add all buttons in incremental order
ButtonArray::AddAll(){
void ButtonArray::AddAll(){
size_t index;
if (reversed_) {
index = nb_buttons_ - 1;
@ -65,14 +67,14 @@ ButtonArray::AddAll(){
// Adds a single button to the array
// Takes a step (rank in the resistor ladder), and the index in the button array.
ButtonArray::Add(uint8_t step, uint8_t index){
void ButtonArray::Add(uint8_t step, uint8_t index){
Button button;
button.InitLimits(step);
button_array_[index] = button;
high_limit_ = max(button.high_limit() , high_limit_);
}
ButtonArray::Add(uint8_t step, uint8_t index, int32_t low_limit, int32_t high_limit){
void ButtonArray::Add(uint8_t step, uint8_t index, int32_t low_limit, int32_t high_limit){
Button button;
button.InitLimits(step, low_limit, high_limit);
button_array_[index] = button;
@ -84,15 +86,19 @@ int32_t ButtonArray::high_limit(){
}
int8_t ButtonArray::ReadButtons(){
uint32_t analog_read_temp =0;
uint32_t analog_line_read_average=0;
uint32_t analog_read_temp = 0;
uint32_t analog_line_read_average = 0;
//uint8_t number_of_samples = 0;
for (byte x = 0; x < 19; x++){
for (byte x = 0; x < NUMBER_OF_BUTTON_READS_TO_AVERAGE; x++){
analog_read_temp = analogRead(pin_);
if (analog_read_temp <= high_limit_){
analog_line_read_average = (analog_line_read_average + analog_read_temp) / 2;
//analog_line_read_average = analog_line_read_average + analog_read_temp;
//number_of_samples++;
}
}
//analog_line_read_average = analog_line_read_average / number_of_samples;
for (size_t x = 0; x < nb_buttons_; x++) {
Button button = button_array_[x];
if (button.Pressed(analog_line_read_average)) {

Wyświetl plik

@ -5,6 +5,7 @@
#define MAX_ARRAY_BUTTONS 13
#endif
#define DEBOUNCE_MS 200
#define NUMBER_OF_BUTTON_READS_TO_AVERAGE 19
#if defined(ARDUINO_ARCH_ESP32)
#define max_value 4095
@ -15,6 +16,8 @@
#define r1_value 10
#define r2_value 1
/* contributed by W6IPA */
class Button {
private:
int32_t low_limit_;
@ -22,8 +25,8 @@ class Button {
uint8_t step_;
public:
Button(){};
InitLimits(uint8_t step);
InitLimits(uint8_t step, int32_t low_limit, int32_t high_limit);
void InitLimits(uint8_t step);
void InitLimits(uint8_t step, int32_t low_limit, int32_t high_limit);
bool Pressed(int32_t analog_reading);
int32_t high_limit();
int32_t low_limit();
@ -41,9 +44,9 @@ class ButtonArray {
public:
uint32_t last_pressed_ms;
ButtonArray(uint8_t pin, uint8_t nb, bool reversed): pin_(pin), nb_buttons_(nb), reversed_(reversed){};
AddAll();
Add(uint8_t step, uint8_t index);
Add(uint8_t step, uint8_t index, int32_t low_limit, int32_t high_limit);
void AddAll();
void Add(uint8_t step, uint8_t index);
void Add(uint8_t step, uint8_t index, int32_t low_limit, int32_t high_limit);
int32_t high_limit();
int8_t Pressed();
bool Pressed(uint8_t index);