From 86aa2b71215f890eb045d3b3998f6ffc3aad3cbf Mon Sep 17 00:00:00 2001 From: "David (Pololu)" Date: Wed, 12 Oct 2016 12:06:11 -0700 Subject: [PATCH] Updated the component libraries. --- LSM303.h | 5 +---- PololuBuzzer.cpp | 28 +++++++++++++--------------- QTRSensors.cpp | 9 +++++---- QTRSensors.h | 1 + USBPause.h | 2 +- components.txt | 16 ++++++++-------- update_components.sh | 14 +++++++------- 7 files changed, 36 insertions(+), 39 deletions(-) diff --git a/LSM303.h b/LSM303.h index 47d7db5..4ed35a7 100644 --- a/LSM303.h +++ b/LSM303.h @@ -243,7 +243,7 @@ template float LSM303::heading(vector from) vector_normalize(&N); // compute heading - float heading = atan2(vector_dot(&E, &from), vector_dot(&N, &from)) * 180 / M_PI; + float heading = atan2(vector_dot(&E, &from), vector_dot(&N, &from)) * 180 / PI; if (heading < 0) heading += 360; return heading; } @@ -261,6 +261,3 @@ template float LSM303::vector_dot(const vector *a } #endif - - - diff --git a/PololuBuzzer.cpp b/PololuBuzzer.cpp index d6070a2..09c095b 100644 --- a/PololuBuzzer.cpp +++ b/PololuBuzzer.cpp @@ -31,32 +31,31 @@ static const unsigned int cs2_divider[] = {0, 1, 8, 32, 64, 128, 256, 1024}; unsigned char buzzerInitialized = 0; volatile unsigned char buzzerFinished = 1; // flag: 0 while playing -const char *buzzerSequence = 0; +const char * volatile buzzerSequence = 0; // declaring these globals as static means they won't conflict // with globals in other .cpp files that share the same name static volatile unsigned int buzzerTimeout = 0; // tracks buzzer time limit -static char play_mode_setting = PLAY_AUTOMATIC; +static volatile char play_mode_setting = PLAY_AUTOMATIC; extern volatile unsigned char buzzerFinished; // flag: 0 while playing -extern const char *buzzerSequence; +extern const char * volatile buzzerSequence; -static unsigned char use_program_space; // boolean: true if we should +static volatile unsigned char use_program_space; // boolean: true if we should // use program space // music settings and defaults -static unsigned char octave = 4; // the current octave -static unsigned int whole_note_duration = 2000; // the duration of a whole note -static unsigned int note_type = 4; // 4 for quarter, etc -static unsigned int duration = 500; // the duration of a note in ms -static unsigned int volume = 15; // the note volume -static unsigned char staccato = 0; // true if playing staccato +static volatile unsigned char octave = 4; // the current octave +static volatile unsigned int whole_note_duration = 2000; // the duration of a whole note +static volatile unsigned int note_type = 4; // 4 for quarter, etc +static volatile unsigned int duration = 500; // the duration of a note in ms +static volatile unsigned int volume = 15; // the note volume +static volatile unsigned char staccato = 0; // true if playing staccato // staccato handling -static unsigned char staccato_rest_duration; // duration of a staccato - // rest, or zero if it is time - // to play a note +static volatile unsigned char staccato_rest_duration; // duration of a staccato rest, + // or zero if it is time to play a note static void nextNote(); @@ -615,8 +614,7 @@ static void nextNote() goto parse_character; case 'o': // set the octave permanently - octave = getNumber(); - tmp_octave = octave; + octave = tmp_octave = getNumber(); goto parse_character; case 'r': // Rest - the note value doesn't matter. diff --git a/QTRSensors.cpp b/QTRSensors.cpp index a5c865a..92106ff 100644 --- a/QTRSensors.cpp +++ b/QTRSensors.cpp @@ -46,6 +46,8 @@ void QTRSensors::init(unsigned char *pins, unsigned char numSensors, calibratedMinimumOff=0; calibratedMaximumOff=0; + _lastValue=0; // assume initially that the line is left. + if (numSensors > QTR_MAX_SENSORS) _numSensors = QTR_MAX_SENSORS; else @@ -317,7 +319,6 @@ int QTRSensors::readLine(unsigned int *sensor_values, unsigned long avg; // this is for the weighted total, which is long // before division unsigned int sum; // this is for the denominator which is <= 64000 - static int last_value=0; // assume initially that the line is left. readCalibrated(sensor_values, readMode); @@ -344,7 +345,7 @@ int QTRSensors::readLine(unsigned int *sensor_values, if(!on_line) { // If it last read to the left of center, return 0. - if(last_value < (_numSensors-1)*1000/2) + if(_lastValue < (_numSensors-1)*1000/2) return 0; // If it last read to the right of center, return the max. @@ -353,9 +354,9 @@ int QTRSensors::readLine(unsigned int *sensor_values, } - last_value = avg/sum; + _lastValue = avg/sum; - return last_value; + return _lastValue; } diff --git a/QTRSensors.h b/QTRSensors.h index 9659d58..0dd97e6 100644 --- a/QTRSensors.h +++ b/QTRSensors.h @@ -141,6 +141,7 @@ class QTRSensors unsigned char _numSensors; unsigned char _emitterPin; unsigned int _maxValue; // the maximum value returned by this function + int _lastValue; private: diff --git a/USBPause.h b/USBPause.h index 19dfbe0..9ff36bd 100644 --- a/USBPause.h +++ b/USBPause.h @@ -1,4 +1,4 @@ -// Copyright Pololu Corporation. For more information, see http://www.pololu.com/ +// Copyright Pololu Corporation. For more information, see https://www.pololu.com/ /*! \file USBPause.h * diff --git a/components.txt b/components.txt index 6612bc6..318925a 100644 --- a/components.txt +++ b/components.txt @@ -1,9 +1,9 @@ -https://github.com/pololu/fastgpio-arduino 1.0.2-1-ga80ffb9 -https://github.com/pololu/usb-pause-arduino 1.0.0-1-gdc0010e -https://github.com/pololu/pushbutton-arduino 1.1.1 -https://github.com/pololu/pololu-buzzer-arduino 1.0.0 -https://github.com/pololu/pololu-hd44780-arduino 1.0.0-1-g0edb20e -https://github.com/pololu/lsm303-arduino 2.1.0-1-g0139b82 -https://github.com/pololu/l3g-arduino 2.0.0-1-g71cd3d6 -https://github.com/pololu/qtr-sensors-arduino 2.1.1 +https://github.com/pololu/fastgpio-arduino 2.0.0 +https://github.com/pololu/usb-pause-arduino 2.0.0 +https://github.com/pololu/pushbutton-arduino 2.0.0 +https://github.com/pololu/pololu-buzzer-arduino 1.0.1 +https://github.com/pololu/pololu-hd44780-arduino 2.0.0-1-gc2ceb6f +https://github.com/pololu/lsm303-arduino 3.0.1 +https://github.com/pololu/l3g-arduino 3.0.0 +https://github.com/pololu/qtr-sensors-arduino 3.0.0 diff --git a/update_components.sh b/update_components.sh index 1e741a4..558d20f 100644 --- a/update_components.sh +++ b/update_components.sh @@ -42,14 +42,14 @@ copylib() } library . -copylib https://github.com/pololu/fastgpio-arduino ../fastgpio-arduino/FastGPIO FastGPIO.h -copylib https://github.com/pololu/usb-pause-arduino ../usb-pause-arduino/USBPause USBPause.h -copylib https://github.com/pololu/pushbutton-arduino ../pushbutton-arduino/Pushbutton Pushbutton{.cpp,.h} +copylib https://github.com/pololu/fastgpio-arduino ../fastgpio-arduino FastGPIO.h +copylib https://github.com/pololu/usb-pause-arduino ../usb-pause-arduino USBPause.h +copylib https://github.com/pololu/pushbutton-arduino ../pushbutton-arduino Pushbutton{.cpp,.h} copylib https://github.com/pololu/pololu-buzzer-arduino ../pololu-buzzer-arduino/PololuBuzzer PololuBuzzer{.cpp,.h} -copylib https://github.com/pololu/pololu-hd44780-arduino ../pololu-hd44780-arduino/PololuHD44780 PololuHD44780{.cpp,.h} -copylib https://github.com/pololu/lsm303-arduino ../lsm303-arduino/LSM303 LSM303{.cpp,.h} -copylib https://github.com/pololu/l3g-arduino ../l3g-arduino/L3G L3G{.cpp,.h} -copylib https://github.com/pololu/qtr-sensors-arduino ../qtr-sensors-arduino/QTRSensors QTRSensors{.cpp,.h} +copylib https://github.com/pololu/pololu-hd44780-arduino ../pololu-hd44780-arduino PololuHD44780{.cpp,.h} +copylib https://github.com/pololu/lsm303-arduino ../lsm303-arduino LSM303{.cpp,.h} +copylib https://github.com/pololu/l3g-arduino ../l3g-arduino L3G{.cpp,.h} +copylib https://github.com/pololu/qtr-sensors-arduino ../qtr-sensors-arduino QTRSensors{.cpp,.h} # The Zumo32U4 library has some files that are reused between examples, and we # would like those to stay synchronized.