From 0c9294b32417200f746faa62b24073d8fb157afa Mon Sep 17 00:00:00 2001 From: Elliot Williams Date: Wed, 23 Mar 2016 22:47:44 +0100 Subject: [PATCH 1/7] finally added license --- LICENSE.txt | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 LICENSE.txt diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 00000000..c9d461b8 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,24 @@ +MIT License + +Copyright (c) 2014 Elliot Williams + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +Have fun! + From 9146e1c9176874020f6d45bede0fa8e5e6bad03a Mon Sep 17 00:00:00 2001 From: Elliot Williams Date: Wed, 23 Mar 2016 22:55:39 +0100 Subject: [PATCH 2/7] fix timer audio by reset counter --- .../timerAudio/timerAudio.c | 1 + 1 file changed, 1 insertion(+) diff --git a/Chapter09_Introduction-to-Timer-Counter-Hardware/timerAudio/timerAudio.c b/Chapter09_Introduction-to-Timer-Counter-Hardware/timerAudio/timerAudio.c index a5ee9d12..7a819470 100644 --- a/Chapter09_Introduction-to-Timer-Counter-Hardware/timerAudio/timerAudio.c +++ b/Chapter09_Introduction-to-Timer-Counter-Hardware/timerAudio/timerAudio.c @@ -18,6 +18,7 @@ static inline void initTimer(void) { static inline void playNote(uint8_t wavelength, uint16_t duration) { + TCNT0 = 0; /* reset the counter */ OCR0A = wavelength; /* set pitch */ SPEAKER_DDR |= (1 << SPEAKER); /* enable output on speaker */ From f415122924c01bfd907e1f989854a60967d650c5 Mon Sep 17 00:00:00 2001 From: Elliot Williams Date: Wed, 23 Mar 2016 22:59:00 +0100 Subject: [PATCH 3/7] added prototype for nibbleToHexCharacter() --- AVR-Programming-Library/USART.h | 1 + 1 file changed, 1 insertion(+) diff --git a/AVR-Programming-Library/USART.h b/AVR-Programming-Library/USART.h index c3f18ebd..8d020811 100644 --- a/AVR-Programming-Library/USART.h +++ b/AVR-Programming-Library/USART.h @@ -37,6 +37,7 @@ void printWord(uint16_t word); void printBinaryByte(uint8_t byte); /* Prints a byte out in 1s and 0s */ char nibbleToHex(uint8_t nibble); +char nibbleToHexCharacter(uint8_t nibble); void printHexByte(uint8_t byte); /* Prints a byte out in hexadecimal */ uint8_t getNumber(void); From f237cd226ca74d68d084baad204b0cb1a44dda84 Mon Sep 17 00:00:00 2001 From: Elliot Williams Date: Wed, 11 May 2016 21:00:39 +0200 Subject: [PATCH 4/7] Changed poor variable naming: wavelength -> period Doesn't change functionality, but readability. --- Chapter05_Serial-IO/serialOrgan/organ.c | 6 +++--- Chapter05_Serial-IO/serialOrgan/organ.h | 2 +- Chapter05_Serial-IO/serialOrgan/scaleGenerator.py | 14 +++++++------- Chapter06_Digital-Input/avrMusicBox/organ.c | 6 +++--- Chapter06_Digital-Input/avrMusicBox/organ.h | 2 +- .../avrMusicBox/scaleGenerator.py | 14 +++++++------- .../amRadio/scale16.h | 14 +++++++------- .../timerAudio/scale8.h | 2 +- .../timerAudio/timerAudio.c | 4 ++-- 9 files changed, 32 insertions(+), 32 deletions(-) diff --git a/Chapter05_Serial-IO/serialOrgan/organ.c b/Chapter05_Serial-IO/serialOrgan/organ.c index 21557aaa..6041a5ac 100644 --- a/Chapter05_Serial-IO/serialOrgan/organ.c +++ b/Chapter05_Serial-IO/serialOrgan/organ.c @@ -7,12 +7,12 @@ Simple routines to play notes out to a speaker #include "organ.h" #include "pinDefines.h" -void playNote(uint16_t wavelength, uint16_t duration) { +void playNote(uint16_t period, uint16_t duration) { uint16_t elapsed; uint16_t i; - for (elapsed = 0; elapsed < duration; elapsed += wavelength) { + for (elapsed = 0; elapsed < duration; elapsed += period) { /* For loop with variable delay selects the pitch */ - for (i = 0; i < wavelength; i++) { + for (i = 0; i < period; i++) { _delay_us(1); } SPEAKER_PORT ^= (1 << SPEAKER); diff --git a/Chapter05_Serial-IO/serialOrgan/organ.h b/Chapter05_Serial-IO/serialOrgan/organ.h index b60941bc..a9c853df 100644 --- a/Chapter05_Serial-IO/serialOrgan/organ.h +++ b/Chapter05_Serial-IO/serialOrgan/organ.h @@ -3,7 +3,7 @@ // Plays a note for the given duration. None of these times are // calibrated to actual notes or tempi. It's all relative to TIMEBASE. -void playNote(uint16_t wavelength, uint16_t duration); +void playNote(uint16_t period, uint16_t duration); // Does nothing for a time equal to the passed duration. void rest(uint16_t duration); diff --git a/Chapter05_Serial-IO/serialOrgan/scaleGenerator.py b/Chapter05_Serial-IO/serialOrgan/scaleGenerator.py index 010a3493..f72a4dac 100644 --- a/Chapter05_Serial-IO/serialOrgan/scaleGenerator.py +++ b/Chapter05_Serial-IO/serialOrgan/scaleGenerator.py @@ -1,5 +1,5 @@ # scaleGenerator.py -# Scales are in terms of times per cycle (wavelength) rather +# Scales are in terms of times per cycle (period) rather # than pitch. # @@ -8,17 +8,17 @@ SCALE = ['C', 'Cx', 'D', 'Dx', 'E', 'F', 'Fx', 'G', 'Gx', 'A', 'Ax', 'B'] def calculateOctave(baseLength): - wavelengths = [baseLength / math.exp(x*math.log(2)/12) for x in range(0, 12)] - wavelengths = [int(round(x)) for x in wavelengths] - return( zip(SCALE, wavelengths) ) + periods = [baseLength / math.exp(x*math.log(2)/12) for x in range(0, 12)] + periods = [int(round(x)) for x in periods] + return( zip(SCALE, periods) ) def makePitches(basePitch, numOctaves): pitchList = [] for octave in range(0, numOctaves): - for note, wavelength in calculateOctave(basePitch / 2**octave): - if wavelength < 65500: + for note, period in calculateOctave(basePitch / 2**octave): + if period < 65500: noteString = note + str(octave) - pitchList.append((noteString,wavelength)) + pitchList.append((noteString,period)) return(pitchList) def makeDefines(basePitch, numOctaves): diff --git a/Chapter06_Digital-Input/avrMusicBox/organ.c b/Chapter06_Digital-Input/avrMusicBox/organ.c index 21557aaa..6041a5ac 100644 --- a/Chapter06_Digital-Input/avrMusicBox/organ.c +++ b/Chapter06_Digital-Input/avrMusicBox/organ.c @@ -7,12 +7,12 @@ Simple routines to play notes out to a speaker #include "organ.h" #include "pinDefines.h" -void playNote(uint16_t wavelength, uint16_t duration) { +void playNote(uint16_t period, uint16_t duration) { uint16_t elapsed; uint16_t i; - for (elapsed = 0; elapsed < duration; elapsed += wavelength) { + for (elapsed = 0; elapsed < duration; elapsed += period) { /* For loop with variable delay selects the pitch */ - for (i = 0; i < wavelength; i++) { + for (i = 0; i < period; i++) { _delay_us(1); } SPEAKER_PORT ^= (1 << SPEAKER); diff --git a/Chapter06_Digital-Input/avrMusicBox/organ.h b/Chapter06_Digital-Input/avrMusicBox/organ.h index b60941bc..a9c853df 100644 --- a/Chapter06_Digital-Input/avrMusicBox/organ.h +++ b/Chapter06_Digital-Input/avrMusicBox/organ.h @@ -3,7 +3,7 @@ // Plays a note for the given duration. None of these times are // calibrated to actual notes or tempi. It's all relative to TIMEBASE. -void playNote(uint16_t wavelength, uint16_t duration); +void playNote(uint16_t period, uint16_t duration); // Does nothing for a time equal to the passed duration. void rest(uint16_t duration); diff --git a/Chapter06_Digital-Input/avrMusicBox/scaleGenerator.py b/Chapter06_Digital-Input/avrMusicBox/scaleGenerator.py index f482078a..d4bd0cc3 100644 --- a/Chapter06_Digital-Input/avrMusicBox/scaleGenerator.py +++ b/Chapter06_Digital-Input/avrMusicBox/scaleGenerator.py @@ -1,5 +1,5 @@ # scaleGenerator.py -# Scales are in terms of times per cycle (wavelength) rather +# Scales are in terms of times per cycle (period) rather # than pitch. # @@ -8,17 +8,17 @@ SCALE = ['C', 'Cx', 'D', 'Dx', 'E', 'F', 'Fx', 'G', 'Gx', 'A', 'Ax', 'B'] def calculateOctave(baseLength): - wavelengths = [baseLength / math.exp(x*math.log(2)/12) for x in range(0, 12)] - wavelengths = [int(round(x)) for x in wavelengths] - return( zip(SCALE, wavelengths) ) + periods = [baseLength / math.exp(x*math.log(2)/12) for x in range(0, 12)] + periods = [int(round(x)) for x in periods] + return( zip(SCALE, periods) ) def makePitches(basePitch, numOctaves): pitchList = [] for octave in range(0, numOctaves): - for note, wavelength in calculateOctave(basePitch / 2**octave): - if wavelength < 65500: + for note, period in calculateOctave(basePitch / 2**octave): + if period < 65500: noteString = note + str(octave) - pitchList.append((noteString,wavelength)) + pitchList.append((noteString,period)) return(pitchList) def makeDefines(basePitch, numOctaves): diff --git a/Chapter09_Introduction-to-Timer-Counter-Hardware/amRadio/scale16.h b/Chapter09_Introduction-to-Timer-Counter-Hardware/amRadio/scale16.h index 856440cd..73d968c3 100644 --- a/Chapter09_Introduction-to-Timer-Counter-Hardware/amRadio/scale16.h +++ b/Chapter09_Introduction-to-Timer-Counter-Hardware/amRadio/scale16.h @@ -1,7 +1,7 @@ /* Scale in the key of 1/10000 */ /* - These are wavelengths -- if you delay this long, + These are periods -- if you delay this long, then toggle the speaker pin, you'll get approximate pitches. @@ -16,15 +16,15 @@ scale = ['C', 'Cx', 'D', 'Dx', 'E', 'F', 'Fx', 'G', 'Gx', 'A', 'Ax', 'B'] def octave(baseLength): - wavelengths = [baseLength / math.exp(x*math.log(2)/12) for x in range(0, 12)] - wavelengths = [int(round(x)) for x in wavelengths] - return( zip(scale, wavelengths) ) + periods = [baseLength / math.exp(x*math.log(2)/12) for x in range(0, 12)] + periods = [int(round(x)) for x in periods] + return( zip(scale, periods) ) for i in range(0,4): - for note, wavelength in octave(10000 / 2**i): - if wavelength < 65500: + for note, period in octave(10000 / 2**i): + if period < 65500: noteString = note + str(i) - print "#define {:<5}{:>6}".format(noteString, wavelength) + print "#define {:<5}{:>6}".format(noteString, period) */ diff --git a/Chapter09_Introduction-to-Timer-Counter-Hardware/timerAudio/scale8.h b/Chapter09_Introduction-to-Timer-Counter-Hardware/timerAudio/scale8.h index fe890f7f..f6c1b3b8 100644 --- a/Chapter09_Introduction-to-Timer-Counter-Hardware/timerAudio/scale8.h +++ b/Chapter09_Introduction-to-Timer-Counter-Hardware/timerAudio/scale8.h @@ -1,7 +1,7 @@ /* Scale in the key of 1/200 */ /* - These are wavelengths -- if you delay this long, + These are periods -- if you delay this long, then toggle the speaker pin, you'll get approximate pitches. diff --git a/Chapter09_Introduction-to-Timer-Counter-Hardware/timerAudio/timerAudio.c b/Chapter09_Introduction-to-Timer-Counter-Hardware/timerAudio/timerAudio.c index 7a819470..accc7a4a 100644 --- a/Chapter09_Introduction-to-Timer-Counter-Hardware/timerAudio/timerAudio.c +++ b/Chapter09_Introduction-to-Timer-Counter-Hardware/timerAudio/timerAudio.c @@ -16,10 +16,10 @@ static inline void initTimer(void) { TCCR0B |= (1 << CS00) | (1 << CS01); /* CPU clock / 64 */ } -static inline void playNote(uint8_t wavelength, uint16_t duration) { +static inline void playNote(uint8_t period, uint16_t duration) { TCNT0 = 0; /* reset the counter */ - OCR0A = wavelength; /* set pitch */ + OCR0A = period; /* set pitch */ SPEAKER_DDR |= (1 << SPEAKER); /* enable output on speaker */ while (duration) { /* Variable delay */ From 6cf8873d5000fb3073b7535853eb6b61699d92bb Mon Sep 17 00:00:00 2001 From: Elliot Williams Date: Fri, 20 May 2016 12:44:21 +0200 Subject: [PATCH 5/7] change return (0); to return 0; --- Chapter02_Programming-AVRs/blinkLED/blinkLED.c | 2 +- .../blinkLED_AVR_style/blinkLED_AVRStyle.c | 2 +- Chapter03_Digital-Output/povToy/povToy.c | 2 +- Chapter03_Digital-Output/povToy_1up/1up.c | 2 +- Chapter03_Digital-Output/povToy_cylonEyes/cylonEyes_POV.c | 2 +- Chapter03_Digital-Output/povToy_invaders/invaders.c | 2 +- Chapter04_Bit-Twiddling/cylonEyes/cylonEyes.c | 2 +- Chapter04_Bit-Twiddling/cylonEyes_16LFSR/16LFSR.c | 2 +- Chapter04_Bit-Twiddling/cylonEyes_8LFSR/8LFSR.c | 2 +- .../cylonEyes_halfStepping/cylonEyes_halfStepping.c | 2 +- .../cylonEyes_quasiRandomToggle/quasiRandomToggle.c | 2 +- Chapter04_Bit-Twiddling/showingOffBits/showingOffBits.c | 2 +- Chapter05_Serial-IO/serialLoopback/serialLoopback.c | 2 +- Chapter05_Serial-IO/serialOrgan/serialOrgan.c | 2 +- Chapter06_Digital-Input/avrMusicBox/avrMusicBox.c | 2 +- Chapter06_Digital-Input/bossButton/bossButton.c | 2 +- Chapter06_Digital-Input/debouncer/debouncer.c | 4 ++-- Chapter06_Digital-Input/simpleButton/simpleButton.c | 2 +- Chapter06_Digital-Input/toggleButton/toggleButton.c | 2 +- .../toggleButton_debounced/toggleButton_debounced.c | 4 ++-- .../lightSensor/lightSensor.c | 2 +- .../nightLight/nightLight.c | 2 +- .../slowScope/slowScope.c | 2 +- Chapter08_Hardware-Interrupts/capSense/capSense.c | 2 +- Chapter08_Hardware-Interrupts/helloInterrupt/helloInterrupt.c | 2 +- .../helloPinChangeInterrupt/helloPinChangeInterrupt.c | 2 +- .../amRadio/amRadio.c | 2 +- .../reactionTimer/reactionTimer.c | 2 +- .../timerAudio/timerAudio.c | 2 +- Chapter10_Pulse-Width-Modulation/bruteForcePWM/pwm.c | 2 +- Chapter10_Pulse-Width-Modulation/pwm/pwm.c | 2 +- Chapter10_Pulse-Width-Modulation/pwmOnAnyPin/pwmOnAnyPin.c | 2 +- Chapter10_Pulse-Width-Modulation/pwmTimers/pwmTimers.c | 2 +- .../pwm_cross-fading_cylons/cross-fading_cylons.c | 2 +- Chapter11_Driving-Servo-Motors/servoSundial/servoSundial.c | 2 +- Chapter11_Driving-Servo-Motors/servoWorkout/servoWorkout.c | 2 +- .../footstepDetector/footstepDetector.c | 2 +- .../voltmeter/voltmeter.c | 2 +- Chapter13_Advanced-PWM-Tricks/adsr/adsr.c | 2 +- Chapter13_Advanced-PWM-Tricks/arpeggiator/arpeggiator.c | 2 +- Chapter13_Advanced-PWM-Tricks/dds/dds.c | 2 +- Chapter13_Advanced-PWM-Tricks/dds_interrupts/dds_interrupts.c | 2 +- Chapter13_Advanced-PWM-Tricks/dds_saw15/dds_saw15.c | 2 +- Chapter13_Advanced-PWM-Tricks/dialTone/dialTone.c | 2 +- Chapter13_Advanced-PWM-Tricks/fatSaw/fatSaw.c | 2 +- Chapter14_Switches/dcMotorWorkout/dcMotorWorkout.c | 2 +- Chapter15_Advanced-Motors/hBridgeWorkout/hBridgeWorkout.c | 2 +- Chapter15_Advanced-Motors/stepperWorkout/stepperWorkout.c | 2 +- Chapter16_SPI/spiEEPROMDemo/spiEEPROMDemo.c | 2 +- Chapter17_I2C/i2cThermometer/i2cThermometer.c | 2 +- Chapter17_I2C/loggingThermometer/loggingThermometer.c | 2 +- .../progmemDemo1/progmemDemo1.c | 2 +- .../progmemDemo2/progmemDemo2.c | 2 +- .../progmemDemo3/progmemDemo3.c | 2 +- .../progmemDemo4/progmemDemo4.c | 2 +- .../progmemDemo5/progmemDemo5.c | 2 +- .../talkingVoltmeter/talkingVoltmeter.c | 2 +- Chapter19_EEPROM/eememDemo/eememDemo.c | 2 +- Chapter19_EEPROM/favoriteColor/favoriteColor.c | 2 +- Chapter19_EEPROM/quickDemo/quickDemo.c | 2 +- Chapter19_EEPROM/vigenereCipher/vigenereCipher.c | 2 +- 61 files changed, 63 insertions(+), 63 deletions(-) diff --git a/Chapter02_Programming-AVRs/blinkLED/blinkLED.c b/Chapter02_Programming-AVRs/blinkLED/blinkLED.c index dbda9ecf..1a128ba4 100644 --- a/Chapter02_Programming-AVRs/blinkLED/blinkLED.c +++ b/Chapter02_Programming-AVRs/blinkLED/blinkLED.c @@ -22,5 +22,5 @@ int main(void) { _delay_ms(1000); /* wait */ } /* End event loop */ - return (0); /* This line is never reached */ + return 0; /* This line is never reached */ } diff --git a/Chapter02_Programming-AVRs/blinkLED_AVR_style/blinkLED_AVRStyle.c b/Chapter02_Programming-AVRs/blinkLED_AVR_style/blinkLED_AVRStyle.c index 748651f9..42d2e164 100644 --- a/Chapter02_Programming-AVRs/blinkLED_AVR_style/blinkLED_AVRStyle.c +++ b/Chapter02_Programming-AVRs/blinkLED_AVR_style/blinkLED_AVRStyle.c @@ -28,5 +28,5 @@ int main(void) { _delay_ms(DELAYTIME); } - return (0); /* end mainloop */ + return 0; /* end mainloop */ } diff --git a/Chapter03_Digital-Output/povToy/povToy.c b/Chapter03_Digital-Output/povToy/povToy.c index 8f63530a..88410ec9 100644 --- a/Chapter03_Digital-Output/povToy/povToy.c +++ b/Chapter03_Digital-Output/povToy/povToy.c @@ -30,5 +30,5 @@ int main(void) { PORTB = 0; _delay_ms(10); } /* end mainloop */ - return (0); + return 0; } diff --git a/Chapter03_Digital-Output/povToy_1up/1up.c b/Chapter03_Digital-Output/povToy_1up/1up.c index c9304409..5a1f25a5 100644 --- a/Chapter03_Digital-Output/povToy_1up/1up.c +++ b/Chapter03_Digital-Output/povToy_1up/1up.c @@ -55,5 +55,5 @@ int main(void) { _delay_ms(5 * DELAYTIME); } /* end mainloop */ - return (0); + return 0; } diff --git a/Chapter03_Digital-Output/povToy_cylonEyes/cylonEyes_POV.c b/Chapter03_Digital-Output/povToy_cylonEyes/cylonEyes_POV.c index 7b4fd51f..588efa64 100644 --- a/Chapter03_Digital-Output/povToy_cylonEyes/cylonEyes_POV.c +++ b/Chapter03_Digital-Output/povToy_cylonEyes/cylonEyes_POV.c @@ -30,5 +30,5 @@ int main(void) { } } - return (0); + return 0; } diff --git a/Chapter03_Digital-Output/povToy_invaders/invaders.c b/Chapter03_Digital-Output/povToy_invaders/invaders.c index 8f5979a0..99586a7d 100644 --- a/Chapter03_Digital-Output/povToy_invaders/invaders.c +++ b/Chapter03_Digital-Output/povToy_invaders/invaders.c @@ -66,5 +66,5 @@ int main(void) { POVDisplay(invaderData2, sizeof(invaderData2)); } /* end mainloop */ - return (0); + return 0; } diff --git a/Chapter04_Bit-Twiddling/cylonEyes/cylonEyes.c b/Chapter04_Bit-Twiddling/cylonEyes/cylonEyes.c index 665ce1ca..d60f2930 100644 --- a/Chapter04_Bit-Twiddling/cylonEyes/cylonEyes.c +++ b/Chapter04_Bit-Twiddling/cylonEyes/cylonEyes.c @@ -32,5 +32,5 @@ int main(void) { } } /* End event loop */ - return (0); + return 0; } diff --git a/Chapter04_Bit-Twiddling/cylonEyes_16LFSR/16LFSR.c b/Chapter04_Bit-Twiddling/cylonEyes_16LFSR/16LFSR.c index 0f0f3e75..64b987a2 100644 --- a/Chapter04_Bit-Twiddling/cylonEyes_16LFSR/16LFSR.c +++ b/Chapter04_Bit-Twiddling/cylonEyes_16LFSR/16LFSR.c @@ -23,7 +23,7 @@ int main(void) { _delay_ms(DELAY); } /* End event loop */ - return (0); + return 0; } diff --git a/Chapter04_Bit-Twiddling/cylonEyes_8LFSR/8LFSR.c b/Chapter04_Bit-Twiddling/cylonEyes_8LFSR/8LFSR.c index 9c658b1f..aa33648d 100644 --- a/Chapter04_Bit-Twiddling/cylonEyes_8LFSR/8LFSR.c +++ b/Chapter04_Bit-Twiddling/cylonEyes_8LFSR/8LFSR.c @@ -22,7 +22,7 @@ int main(void) { _delay_ms(DELAY); } /* End event loop */ - return (0); + return 0; } diff --git a/Chapter04_Bit-Twiddling/cylonEyes_halfStepping/cylonEyes_halfStepping.c b/Chapter04_Bit-Twiddling/cylonEyes_halfStepping/cylonEyes_halfStepping.c index 4d205ac6..c1418eed 100644 --- a/Chapter04_Bit-Twiddling/cylonEyes_halfStepping/cylonEyes_halfStepping.c +++ b/Chapter04_Bit-Twiddling/cylonEyes_halfStepping/cylonEyes_halfStepping.c @@ -41,5 +41,5 @@ int main(void) { } } /* End event loop */ - return (0); + return 0; } /* end main */ diff --git a/Chapter04_Bit-Twiddling/cylonEyes_quasiRandomToggle/quasiRandomToggle.c b/Chapter04_Bit-Twiddling/cylonEyes_quasiRandomToggle/quasiRandomToggle.c index 8d9a6ad2..2b0ff82a 100644 --- a/Chapter04_Bit-Twiddling/cylonEyes_quasiRandomToggle/quasiRandomToggle.c +++ b/Chapter04_Bit-Twiddling/cylonEyes_quasiRandomToggle/quasiRandomToggle.c @@ -26,5 +26,5 @@ int main(void) { _delay_ms(100); } /* End event loop */ - return (0); + return 0; } diff --git a/Chapter04_Bit-Twiddling/showingOffBits/showingOffBits.c b/Chapter04_Bit-Twiddling/showingOffBits/showingOffBits.c index c3401952..2c1a7ca2 100644 --- a/Chapter04_Bit-Twiddling/showingOffBits/showingOffBits.c +++ b/Chapter04_Bit-Twiddling/showingOffBits/showingOffBits.c @@ -55,5 +55,5 @@ int main(void) { _delay_ms(5 * DELAYTIME); /* pause */ } /* End event loop */ - return (0); /* This line is never reached */ + return 0; /* This line is never reached */ } diff --git a/Chapter05_Serial-IO/serialLoopback/serialLoopback.c b/Chapter05_Serial-IO/serialLoopback/serialLoopback.c index ae8a1a89..014cd968 100644 --- a/Chapter05_Serial-IO/serialLoopback/serialLoopback.c +++ b/Chapter05_Serial-IO/serialLoopback/serialLoopback.c @@ -27,5 +27,5 @@ int main(void) { /* display ascii/numeric value of character */ } /* End event loop */ - return (0); + return 0; } diff --git a/Chapter05_Serial-IO/serialOrgan/serialOrgan.c b/Chapter05_Serial-IO/serialOrgan/serialOrgan.c index 014c279c..5dcb3b51 100644 --- a/Chapter05_Serial-IO/serialOrgan/serialOrgan.c +++ b/Chapter05_Serial-IO/serialOrgan/serialOrgan.c @@ -70,5 +70,5 @@ int main(void) { } } /* End event loop */ - return (0); + return 0; } diff --git a/Chapter06_Digital-Input/avrMusicBox/avrMusicBox.c b/Chapter06_Digital-Input/avrMusicBox/avrMusicBox.c index 4b9e6ac2..2e1886de 100644 --- a/Chapter06_Digital-Input/avrMusicBox/avrMusicBox.c +++ b/Chapter06_Digital-Input/avrMusicBox/avrMusicBox.c @@ -44,5 +44,5 @@ int main(void) { wasButtonPressed = 0; } } /* End event loop */ - return (0); + return 0; } diff --git a/Chapter06_Digital-Input/bossButton/bossButton.c b/Chapter06_Digital-Input/bossButton/bossButton.c index 666c9935..654e9fb5 100644 --- a/Chapter06_Digital-Input/bossButton/bossButton.c +++ b/Chapter06_Digital-Input/bossButton/bossButton.c @@ -42,5 +42,5 @@ int main(void) { } } /* End event loop */ - return (0); + return 0; } diff --git a/Chapter06_Digital-Input/debouncer/debouncer.c b/Chapter06_Digital-Input/debouncer/debouncer.c index c7137810..a03a9faf 100644 --- a/Chapter06_Digital-Input/debouncer/debouncer.c +++ b/Chapter06_Digital-Input/debouncer/debouncer.c @@ -14,7 +14,7 @@ uint8_t debounce(void) { return (1); } } - return (0); + return 0; } int main(void) { @@ -36,5 +36,5 @@ int main(void) { } } /* End event loop */ - return (0); /* This line is never reached */ + return 0; /* This line is never reached */ } diff --git a/Chapter06_Digital-Input/simpleButton/simpleButton.c b/Chapter06_Digital-Input/simpleButton/simpleButton.c index 29eec725..aecbffe2 100644 --- a/Chapter06_Digital-Input/simpleButton/simpleButton.c +++ b/Chapter06_Digital-Input/simpleButton/simpleButton.c @@ -23,5 +23,5 @@ int main(void) { PORTB = 0b11000011; } } /* End event loop */ - return (0); + return 0; } diff --git a/Chapter06_Digital-Input/toggleButton/toggleButton.c b/Chapter06_Digital-Input/toggleButton/toggleButton.c index 5a4b2897..b9dbcd5b 100644 --- a/Chapter06_Digital-Input/toggleButton/toggleButton.c +++ b/Chapter06_Digital-Input/toggleButton/toggleButton.c @@ -24,5 +24,5 @@ int main(void) { buttonWasPressed = 0; /* update the state */ } } /* End event loop */ - return (0); /* This line is never reached */ + return 0; /* This line is never reached */ } diff --git a/Chapter06_Digital-Input/toggleButton_debounced/toggleButton_debounced.c b/Chapter06_Digital-Input/toggleButton_debounced/toggleButton_debounced.c index 28cf8acf..d1b3d999 100644 --- a/Chapter06_Digital-Input/toggleButton_debounced/toggleButton_debounced.c +++ b/Chapter06_Digital-Input/toggleButton_debounced/toggleButton_debounced.c @@ -16,7 +16,7 @@ uint8_t debouncePress(void) { return (1); } } - return (0); + return 0; } int main(void) { @@ -38,5 +38,5 @@ int main(void) { } } /* End event loop */ - return (0); /* This line is never reached */ + return 0; /* This line is never reached */ } diff --git a/Chapter07_Analog-to-Digital-Conversion-I/lightSensor/lightSensor.c b/Chapter07_Analog-to-Digital-Conversion-I/lightSensor/lightSensor.c index 0d1e6862..6136b1ef 100644 --- a/Chapter07_Analog-to-Digital-Conversion-I/lightSensor/lightSensor.c +++ b/Chapter07_Analog-to-Digital-Conversion-I/lightSensor/lightSensor.c @@ -37,5 +37,5 @@ int main(void) { } _delay_ms(50); } /* End event loop */ - return (0); /* This line is never reached */ + return 0; /* This line is never reached */ } diff --git a/Chapter07_Analog-to-Digital-Conversion-I/nightLight/nightLight.c b/Chapter07_Analog-to-Digital-Conversion-I/nightLight/nightLight.c index c372c0c3..d20f3b6b 100644 --- a/Chapter07_Analog-to-Digital-Conversion-I/nightLight/nightLight.c +++ b/Chapter07_Analog-to-Digital-Conversion-I/nightLight/nightLight.c @@ -35,5 +35,5 @@ int main(void) { LED_PORT = 0x00; } } /* End event loop */ - return (0); /* This line is never reached */ + return 0; /* This line is never reached */ } diff --git a/Chapter07_Analog-to-Digital-Conversion-I/slowScope/slowScope.c b/Chapter07_Analog-to-Digital-Conversion-I/slowScope/slowScope.c index fddea3db..991892a3 100644 --- a/Chapter07_Analog-to-Digital-Conversion-I/slowScope/slowScope.c +++ b/Chapter07_Analog-to-Digital-Conversion-I/slowScope/slowScope.c @@ -29,5 +29,5 @@ int main(void) { transmitByte(ADCH); /* transmit the high byte, left-adjusted */ _delay_ms(SAMPLE_DELAY); } /* End event loop */ - return (0); /* This line is never reached */ + return 0; /* This line is never reached */ } diff --git a/Chapter08_Hardware-Interrupts/capSense/capSense.c b/Chapter08_Hardware-Interrupts/capSense/capSense.c index b79182e5..c90f657c 100644 --- a/Chapter08_Hardware-Interrupts/capSense/capSense.c +++ b/Chapter08_Hardware-Interrupts/capSense/capSense.c @@ -63,5 +63,5 @@ int main(void) { printString("\r\n"); } /* End event loop */ - return (0); /* This line is never reached */ + return 0; /* This line is never reached */ } diff --git a/Chapter08_Hardware-Interrupts/helloInterrupt/helloInterrupt.c b/Chapter08_Hardware-Interrupts/helloInterrupt/helloInterrupt.c index ab0a4c10..ab420c89 100644 --- a/Chapter08_Hardware-Interrupts/helloInterrupt/helloInterrupt.c +++ b/Chapter08_Hardware-Interrupts/helloInterrupt/helloInterrupt.c @@ -41,5 +41,5 @@ int main(void) { LED_PORT ^= (1 << LED0); } /* End event loop */ - return (0); /* This line is never reached */ + return 0; /* This line is never reached */ } diff --git a/Chapter08_Hardware-Interrupts/helloPinChangeInterrupt/helloPinChangeInterrupt.c b/Chapter08_Hardware-Interrupts/helloPinChangeInterrupt/helloPinChangeInterrupt.c index 75369ac0..16951a53 100644 --- a/Chapter08_Hardware-Interrupts/helloPinChangeInterrupt/helloPinChangeInterrupt.c +++ b/Chapter08_Hardware-Interrupts/helloPinChangeInterrupt/helloPinChangeInterrupt.c @@ -35,5 +35,5 @@ int main(void) { LED_PORT ^= (1 << LED0); } /* End event loop */ - return (0); /* This line is never reached */ + return 0; /* This line is never reached */ } diff --git a/Chapter09_Introduction-to-Timer-Counter-Hardware/amRadio/amRadio.c b/Chapter09_Introduction-to-Timer-Counter-Hardware/amRadio/amRadio.c index 9e37d149..f3f341db 100644 --- a/Chapter09_Introduction-to-Timer-Counter-Hardware/amRadio/amRadio.c +++ b/Chapter09_Introduction-to-Timer-Counter-Hardware/amRadio/amRadio.c @@ -77,5 +77,5 @@ int main(void) { _delay_ms(2500); } /* End event loop */ - return (0); /* This line is never reached */ + return 0; /* This line is never reached */ } diff --git a/Chapter09_Introduction-to-Timer-Counter-Hardware/reactionTimer/reactionTimer.c b/Chapter09_Introduction-to-Timer-Counter-Hardware/reactionTimer/reactionTimer.c index e7471a16..c611b282 100644 --- a/Chapter09_Introduction-to-Timer-Counter-Hardware/reactionTimer/reactionTimer.c +++ b/Chapter09_Introduction-to-Timer-Counter-Hardware/reactionTimer/reactionTimer.c @@ -64,5 +64,5 @@ int main(void) { printString("Press any key to try again.\r\n"); } /* End event loop */ - return (0); /* This line is never reached */ + return 0; /* This line is never reached */ } diff --git a/Chapter09_Introduction-to-Timer-Counter-Hardware/timerAudio/timerAudio.c b/Chapter09_Introduction-to-Timer-Counter-Hardware/timerAudio/timerAudio.c index accc7a4a..f348d59b 100644 --- a/Chapter09_Introduction-to-Timer-Counter-Hardware/timerAudio/timerAudio.c +++ b/Chapter09_Introduction-to-Timer-Counter-Hardware/timerAudio/timerAudio.c @@ -45,5 +45,5 @@ int main(void) { _delay_ms(1000); } /* End event loop */ - return (0); /* This line is never reached */ + return 0; /* This line is never reached */ } diff --git a/Chapter10_Pulse-Width-Modulation/bruteForcePWM/pwm.c b/Chapter10_Pulse-Width-Modulation/bruteForcePWM/pwm.c index e9424f1a..1031dcd3 100644 --- a/Chapter10_Pulse-Width-Modulation/bruteForcePWM/pwm.c +++ b/Chapter10_Pulse-Width-Modulation/bruteForcePWM/pwm.c @@ -43,5 +43,5 @@ int main(void) { brightness += direction; } /* End event loop */ - return (0); /* This line is never reached */ + return 0; /* This line is never reached */ } diff --git a/Chapter10_Pulse-Width-Modulation/pwm/pwm.c b/Chapter10_Pulse-Width-Modulation/pwm/pwm.c index 75e3b00b..04edd158 100644 --- a/Chapter10_Pulse-Width-Modulation/pwm/pwm.c +++ b/Chapter10_Pulse-Width-Modulation/pwm/pwm.c @@ -41,5 +41,5 @@ int main(void) { } /* End event loop */ - return (0); /* This line is never reached */ + return 0; /* This line is never reached */ } diff --git a/Chapter10_Pulse-Width-Modulation/pwmOnAnyPin/pwmOnAnyPin.c b/Chapter10_Pulse-Width-Modulation/pwmOnAnyPin/pwmOnAnyPin.c index 507d82ae..729f5063 100644 --- a/Chapter10_Pulse-Width-Modulation/pwmOnAnyPin/pwmOnAnyPin.c +++ b/Chapter10_Pulse-Width-Modulation/pwmOnAnyPin/pwmOnAnyPin.c @@ -55,5 +55,5 @@ int main(void) { } } /* End event loop */ - return (0); /* This line is never reached */ + return 0; /* This line is never reached */ } diff --git a/Chapter10_Pulse-Width-Modulation/pwmTimers/pwmTimers.c b/Chapter10_Pulse-Width-Modulation/pwmTimers/pwmTimers.c index c3e3318e..4c189464 100644 --- a/Chapter10_Pulse-Width-Modulation/pwmTimers/pwmTimers.c +++ b/Chapter10_Pulse-Width-Modulation/pwmTimers/pwmTimers.c @@ -46,5 +46,5 @@ int main(void) { OCR1A = brightness; } /* End event loop */ - return (0); /* This line is never reached */ + return 0; /* This line is never reached */ } diff --git a/Chapter10_Pulse-Width-Modulation/pwm_cross-fading_cylons/cross-fading_cylons.c b/Chapter10_Pulse-Width-Modulation/pwm_cross-fading_cylons/cross-fading_cylons.c index 67a90261..439873ed 100644 --- a/Chapter10_Pulse-Width-Modulation/pwm_cross-fading_cylons/cross-fading_cylons.c +++ b/Chapter10_Pulse-Width-Modulation/pwm_cross-fading_cylons/cross-fading_cylons.c @@ -56,5 +56,5 @@ int main(void) { } /* End event loop */ - return (0); /* This line is never reached */ + return 0; /* This line is never reached */ } diff --git a/Chapter11_Driving-Servo-Motors/servoSundial/servoSundial.c b/Chapter11_Driving-Servo-Motors/servoSundial/servoSundial.c index d5283fa1..8c5f26f2 100644 --- a/Chapter11_Driving-Servo-Motors/servoSundial/servoSundial.c +++ b/Chapter11_Driving-Servo-Motors/servoSundial/servoSundial.c @@ -77,5 +77,5 @@ int main(void) { pollSerial(); } /* End event loop */ - return (0); /* This line is never reached */ + return 0; /* This line is never reached */ } diff --git a/Chapter11_Driving-Servo-Motors/servoWorkout/servoWorkout.c b/Chapter11_Driving-Servo-Motors/servoWorkout/servoWorkout.c index 30e6d40d..c6d7161c 100644 --- a/Chapter11_Driving-Servo-Motors/servoWorkout/servoWorkout.c +++ b/Chapter11_Driving-Servo-Motors/servoWorkout/servoWorkout.c @@ -67,7 +67,7 @@ int main(void) { DDRB &= ~(1 << PB1); /* disable output pin */ } /* End event loop */ - return (0); /* This line is never reached */ + return 0; /* This line is never reached */ } static inline uint16_t getNumber16(void) { diff --git a/Chapter12_Analog-to-Digital-Conversion-II/footstepDetector/footstepDetector.c b/Chapter12_Analog-to-Digital-Conversion-II/footstepDetector/footstepDetector.c index 97da6850..270bb36e 100644 --- a/Chapter12_Analog-to-Digital-Conversion-II/footstepDetector/footstepDetector.c +++ b/Chapter12_Analog-to-Digital-Conversion-II/footstepDetector/footstepDetector.c @@ -94,5 +94,5 @@ int main(void) { transmitByte((highValue >> 4) - 512 + 127); _delay_ms(CYCLE_DELAY); } /* End event loop */ - return (0); /* This line is never reached */ + return 0; /* This line is never reached */ } diff --git a/Chapter12_Analog-to-Digital-Conversion-II/voltmeter/voltmeter.c b/Chapter12_Analog-to-Digital-Conversion-II/voltmeter/voltmeter.c index c6ffc2d3..810ad9a1 100644 --- a/Chapter12_Analog-to-Digital-Conversion-II/voltmeter/voltmeter.c +++ b/Chapter12_Analog-to-Digital-Conversion-II/voltmeter/voltmeter.c @@ -81,5 +81,5 @@ int main(void) { _delay_ms(500); } /* End event loop */ - return (0); /* This line is never reached */ + return 0; /* This line is never reached */ } diff --git a/Chapter13_Advanced-PWM-Tricks/adsr/adsr.c b/Chapter13_Advanced-PWM-Tricks/adsr/adsr.c index a4215ec1..946adc2b 100644 --- a/Chapter13_Advanced-PWM-Tricks/adsr/adsr.c +++ b/Chapter13_Advanced-PWM-Tricks/adsr/adsr.c @@ -82,5 +82,5 @@ int main(void) { } /* End event loop */ - return (0); /* This line is never reached */ + return 0; /* This line is never reached */ } diff --git a/Chapter13_Advanced-PWM-Tricks/arpeggiator/arpeggiator.c b/Chapter13_Advanced-PWM-Tricks/arpeggiator/arpeggiator.c index 5efa35bc..d714194a 100644 --- a/Chapter13_Advanced-PWM-Tricks/arpeggiator/arpeggiator.c +++ b/Chapter13_Advanced-PWM-Tricks/arpeggiator/arpeggiator.c @@ -70,7 +70,7 @@ int main(void){ _delay_us(124); /* Aiming for 8kHz sample rate */ } /* End event loop */ - return(0); /* This line is never reached */ + return 0; /* This line is never reached */ } diff --git a/Chapter13_Advanced-PWM-Tricks/dds/dds.c b/Chapter13_Advanced-PWM-Tricks/dds/dds.c index ae1afedc..1a8ea583 100644 --- a/Chapter13_Advanced-PWM-Tricks/dds/dds.c +++ b/Chapter13_Advanced-PWM-Tricks/dds/dds.c @@ -52,5 +52,5 @@ int main(void) { } } /* End event loop */ - return (0); /* This line is never reached */ + return 0; /* This line is never reached */ } diff --git a/Chapter13_Advanced-PWM-Tricks/dds_interrupts/dds_interrupts.c b/Chapter13_Advanced-PWM-Tricks/dds_interrupts/dds_interrupts.c index c7f836cc..cdffa3e1 100644 --- a/Chapter13_Advanced-PWM-Tricks/dds_interrupts/dds_interrupts.c +++ b/Chapter13_Advanced-PWM-Tricks/dds_interrupts/dds_interrupts.c @@ -70,5 +70,5 @@ int main(void) { pollButton(); } /* End event loop */ - return (0); /* This line is never reached */ + return 0; /* This line is never reached */ } diff --git a/Chapter13_Advanced-PWM-Tricks/dds_saw15/dds_saw15.c b/Chapter13_Advanced-PWM-Tricks/dds_saw15/dds_saw15.c index b4345912..35216e0a 100644 --- a/Chapter13_Advanced-PWM-Tricks/dds_saw15/dds_saw15.c +++ b/Chapter13_Advanced-PWM-Tricks/dds_saw15/dds_saw15.c @@ -52,5 +52,5 @@ int main(void) { } } /* End event loop */ - return (0); /* This line is never reached */ + return 0; /* This line is never reached */ } diff --git a/Chapter13_Advanced-PWM-Tricks/dialTone/dialTone.c b/Chapter13_Advanced-PWM-Tricks/dialTone/dialTone.c index 1fe766e2..eb22e8a4 100644 --- a/Chapter13_Advanced-PWM-Tricks/dialTone/dialTone.c +++ b/Chapter13_Advanced-PWM-Tricks/dialTone/dialTone.c @@ -78,7 +78,7 @@ int main(void){ } /* End event loop */ - return(0); /* This line is never reached */ + return 0; /* This line is never reached */ } diff --git a/Chapter13_Advanced-PWM-Tricks/fatSaw/fatSaw.c b/Chapter13_Advanced-PWM-Tricks/fatSaw/fatSaw.c index 0fc60746..4b978b23 100644 --- a/Chapter13_Advanced-PWM-Tricks/fatSaw/fatSaw.c +++ b/Chapter13_Advanced-PWM-Tricks/fatSaw/fatSaw.c @@ -52,5 +52,5 @@ int main(void) { /* Dividing by bitshift is very fast. */ } /* End event loop */ - return (0); /* This line is never reached */ + return 0; /* This line is never reached */ } diff --git a/Chapter14_Switches/dcMotorWorkout/dcMotorWorkout.c b/Chapter14_Switches/dcMotorWorkout/dcMotorWorkout.c index a583435b..934040ed 100644 --- a/Chapter14_Switches/dcMotorWorkout/dcMotorWorkout.c +++ b/Chapter14_Switches/dcMotorWorkout/dcMotorWorkout.c @@ -57,5 +57,5 @@ int main(void) { LED_PORT = 0; /* all off */ } /* End event loop */ - return (0); /* This line is never reached */ + return 0; /* This line is never reached */ } diff --git a/Chapter15_Advanced-Motors/hBridgeWorkout/hBridgeWorkout.c b/Chapter15_Advanced-Motors/hBridgeWorkout/hBridgeWorkout.c index 792b2535..a1178d90 100644 --- a/Chapter15_Advanced-Motors/hBridgeWorkout/hBridgeWorkout.c +++ b/Chapter15_Advanced-Motors/hBridgeWorkout/hBridgeWorkout.c @@ -59,5 +59,5 @@ int main(void) { _delay_ms(2000); } /* End event loop */ - return (0); + return 0; } diff --git a/Chapter15_Advanced-Motors/stepperWorkout/stepperWorkout.c b/Chapter15_Advanced-Motors/stepperWorkout/stepperWorkout.c index a3f52c6a..c79d057e 100644 --- a/Chapter15_Advanced-Motors/stepperWorkout/stepperWorkout.c +++ b/Chapter15_Advanced-Motors/stepperWorkout/stepperWorkout.c @@ -133,5 +133,5 @@ int main(void) { _delay_ms(1000); } /* End event loop */ - return (0); /* This line is never reached */ + return 0; /* This line is never reached */ } diff --git a/Chapter16_SPI/spiEEPROMDemo/spiEEPROMDemo.c b/Chapter16_SPI/spiEEPROMDemo/spiEEPROMDemo.c index 1753553c..ba56d638 100644 --- a/Chapter16_SPI/spiEEPROMDemo/spiEEPROMDemo.c +++ b/Chapter16_SPI/spiEEPROMDemo/spiEEPROMDemo.c @@ -51,5 +51,5 @@ int main(void) { } /* End event loop */ - return (0); /* This line is never reached */ + return 0; /* This line is never reached */ } diff --git a/Chapter17_I2C/i2cThermometer/i2cThermometer.c b/Chapter17_I2C/i2cThermometer/i2cThermometer.c index fa0df180..c02a5149 100644 --- a/Chapter17_I2C/i2cThermometer/i2cThermometer.c +++ b/Chapter17_I2C/i2cThermometer/i2cThermometer.c @@ -56,5 +56,5 @@ int main(void) { _delay_ms(1000); } /* End event loop */ - return (0); /* This line is never reached */ + return 0; /* This line is never reached */ } diff --git a/Chapter17_I2C/loggingThermometer/loggingThermometer.c b/Chapter17_I2C/loggingThermometer/loggingThermometer.c index 0bd7fcdb..0efbb356 100644 --- a/Chapter17_I2C/loggingThermometer/loggingThermometer.c +++ b/Chapter17_I2C/loggingThermometer/loggingThermometer.c @@ -168,5 +168,5 @@ int main(void) { } } /* End event loop */ - return (0); /* This line is never reached */ + return 0; /* This line is never reached */ } diff --git a/Chapter18_Using-Flash-Program-Memory/progmemDemo1/progmemDemo1.c b/Chapter18_Using-Flash-Program-Memory/progmemDemo1/progmemDemo1.c index 6a3407c0..effff1bf 100644 --- a/Chapter18_Using-Flash-Program-Memory/progmemDemo1/progmemDemo1.c +++ b/Chapter18_Using-Flash-Program-Memory/progmemDemo1/progmemDemo1.c @@ -28,5 +28,5 @@ int main(void) { transmitByte('\n'); printWord(pgm_read_word(&sixteenBits)); } /* End event loop */ - return (0); /* This line is never reached */ + return 0; /* This line is never reached */ } diff --git a/Chapter18_Using-Flash-Program-Memory/progmemDemo2/progmemDemo2.c b/Chapter18_Using-Flash-Program-Memory/progmemDemo2/progmemDemo2.c index 1e0354f4..c2748d79 100644 --- a/Chapter18_Using-Flash-Program-Memory/progmemDemo2/progmemDemo2.c +++ b/Chapter18_Using-Flash-Program-Memory/progmemDemo2/progmemDemo2.c @@ -33,5 +33,5 @@ int main(void) { printWord(pgm_read_word(wordPointer)); } /* End event loop */ - return (0); /* This line is never reached */ + return 0; /* This line is never reached */ } diff --git a/Chapter18_Using-Flash-Program-Memory/progmemDemo3/progmemDemo3.c b/Chapter18_Using-Flash-Program-Memory/progmemDemo3/progmemDemo3.c index a5aeac48..31df8cba 100644 --- a/Chapter18_Using-Flash-Program-Memory/progmemDemo3/progmemDemo3.c +++ b/Chapter18_Using-Flash-Program-Memory/progmemDemo3/progmemDemo3.c @@ -29,5 +29,5 @@ int main(void) { printString_Progmem(myVeryLongString2); _delay_ms(1000); } /* End event loop */ - return (0); /* This line is never reached */ + return 0; /* This line is never reached */ } diff --git a/Chapter18_Using-Flash-Program-Memory/progmemDemo4/progmemDemo4.c b/Chapter18_Using-Flash-Program-Memory/progmemDemo4/progmemDemo4.c index 31954adc..46b62fda 100644 --- a/Chapter18_Using-Flash-Program-Memory/progmemDemo4/progmemDemo4.c +++ b/Chapter18_Using-Flash-Program-Memory/progmemDemo4/progmemDemo4.c @@ -32,5 +32,5 @@ int main(void) { printString("\r\n"); _delay_ms(1000); } /* End event loop */ - return (0); /* This line is never reached */ + return 0; /* This line is never reached */ } diff --git a/Chapter18_Using-Flash-Program-Memory/progmemDemo5/progmemDemo5.c b/Chapter18_Using-Flash-Program-Memory/progmemDemo5/progmemDemo5.c index 2d993924..98c7d0e2 100644 --- a/Chapter18_Using-Flash-Program-Memory/progmemDemo5/progmemDemo5.c +++ b/Chapter18_Using-Flash-Program-Memory/progmemDemo5/progmemDemo5.c @@ -64,5 +64,5 @@ int main(void) { printString("\r\n"); _delay_ms(1000); } /* End event loop */ - return (0); /* This line is never reached */ + return 0; /* This line is never reached */ } diff --git a/Chapter18_Using-Flash-Program-Memory/talkingVoltmeter/talkingVoltmeter.c b/Chapter18_Using-Flash-Program-Memory/talkingVoltmeter/talkingVoltmeter.c index 0464626a..f1f82e67 100644 --- a/Chapter18_Using-Flash-Program-Memory/talkingVoltmeter/talkingVoltmeter.c +++ b/Chapter18_Using-Flash-Program-Memory/talkingVoltmeter/talkingVoltmeter.c @@ -121,5 +121,5 @@ int main(void) { _delay_ms(SPEECH_DELAY); } /* end while */ - return (0); + return 0; } diff --git a/Chapter19_EEPROM/eememDemo/eememDemo.c b/Chapter19_EEPROM/eememDemo/eememDemo.c index 47291306..df219d17 100644 --- a/Chapter19_EEPROM/eememDemo/eememDemo.c +++ b/Chapter19_EEPROM/eememDemo/eememDemo.c @@ -35,5 +35,5 @@ int main(void) { counter++; eeprom_update_byte(&eepromCounter, counter); } - return (0); + return 0; } diff --git a/Chapter19_EEPROM/favoriteColor/favoriteColor.c b/Chapter19_EEPROM/favoriteColor/favoriteColor.c index 5d3aa360..53032f71 100644 --- a/Chapter19_EEPROM/favoriteColor/favoriteColor.c +++ b/Chapter19_EEPROM/favoriteColor/favoriteColor.c @@ -34,5 +34,5 @@ int main(void) { eeprom_update_word((uint16_t *) COUNTER_ADDRESS, counter); } - return (0); + return 0; } diff --git a/Chapter19_EEPROM/quickDemo/quickDemo.c b/Chapter19_EEPROM/quickDemo/quickDemo.c index f63e02ed..3184ee16 100644 --- a/Chapter19_EEPROM/quickDemo/quickDemo.c +++ b/Chapter19_EEPROM/quickDemo/quickDemo.c @@ -15,5 +15,5 @@ int main(void) { char myString[] = "hello world."; eeprom_update_block(myString, stringPointer, sizeof(myString)); - return (0); + return 0; } diff --git a/Chapter19_EEPROM/vigenereCipher/vigenereCipher.c b/Chapter19_EEPROM/vigenereCipher/vigenereCipher.c index 1d40c0ae..267aa152 100644 --- a/Chapter19_EEPROM/vigenereCipher/vigenereCipher.c +++ b/Chapter19_EEPROM/vigenereCipher/vigenereCipher.c @@ -142,5 +142,5 @@ int main(void) { break; } } /* End event loop */ - return (0); /* This line is never reached */ + return 0; /* This line is never reached */ } From 8a9ad403ccf2f6cceef955e3813e476da3df7f62 Mon Sep 17 00:00:00 2001 From: Elliot Williams Date: Sat, 25 Mar 2017 20:58:50 +0100 Subject: [PATCH 6/7] bug fix: one missing zero in blink.c code Thanks KaiserS0ze for pointing this out. --- Chapter02_Programming-AVRs/blinkLED/blinkLED.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Chapter02_Programming-AVRs/blinkLED/blinkLED.c b/Chapter02_Programming-AVRs/blinkLED/blinkLED.c index 1a128ba4..46a5e54c 100644 --- a/Chapter02_Programming-AVRs/blinkLED/blinkLED.c +++ b/Chapter02_Programming-AVRs/blinkLED/blinkLED.c @@ -8,7 +8,7 @@ int main(void) { // -------- Inits --------- // - DDRB |= 0b0000001; /* Data Direction Register B: + DDRB |= 0b00000001; /* Data Direction Register B: writing a one to the bit enables output. */ From ad2512ee6799e75e25e70043e8dcc8122cb4f5ab Mon Sep 17 00:00:00 2001 From: Elliot Williams Date: Mon, 11 Jan 2021 17:05:06 +0100 Subject: [PATCH 7/7] Updated some utilities to Python 3 Thanks dComposer! --- Chapter05_Serial-IO/serialOrgan/autoPlay.py | 37 ++++++-------- .../bossButton/bossButton.py | 8 +-- .../slowScope/serialScope.py | 25 +++------- .../capSense/serialScope.py | 50 +++++++------------ 4 files changed, 46 insertions(+), 74 deletions(-) diff --git a/Chapter05_Serial-IO/serialOrgan/autoPlay.py b/Chapter05_Serial-IO/serialOrgan/autoPlay.py index f1a4cb27..8b0caddc 100644 --- a/Chapter05_Serial-IO/serialOrgan/autoPlay.py +++ b/Chapter05_Serial-IO/serialOrgan/autoPlay.py @@ -8,16 +8,18 @@ def playString(noteString, serialPort): for letter in noteString: - print letter - serialPort.write(letter) + print(letter) + serialPort.write(letter.encode()) returnValue = serialPort.read(1) if __name__ == "__main__": - import time, urllib2 + import time + from urllib.request import urlopen ## Need to consider alternatives for Mac / Windows - PORT = "/dev/ttyUSB0" + ## list all serial ports being used: python -m serial.tools.list_ports + PORT = "/dev/ttyUSB0" # Change this to the current serial port being used BAUD = 9600 s = serial.Serial(PORT, BAUD) @@ -27,29 +29,22 @@ def playString(noteString, serialPort): ## An intentional example. You can use this for playing music on purpose. playString("f g h j k l ; ]'[", s) - raw_input("Press enter for next demo\n") + input("Press enter for next demo\n") ## A fun / stupid example. You can just type stuff and see what comes out. playString("hello there, this is a random string turned into 'music'", s) - raw_input("Press enter for next demo\n") + input("Press enter for next demo\n") + ## Website no longer alive... skipping: ## A really frivolous example. Play websites! ## Bonus points for first person to tweet themselves a song. - print ("Downloading song data from http://serialorgansongs.jottit.com/...") - import re - contentFilter = re.compile(r'

(.*?)

') - songSite = urllib2.urlopen("http://serialorgansongs.jottit.com/").read() - songText = contentFilter.findall(songSite)[0] - playString(songText, s) + #print ("Downloading song data from http://serialorgansongs.jottit.com/...") + #import re + #contentFilter = re.compile(r'

(.*?)

') + #songSite = urlopen("http://serialorgansongs.jottit.com/").read() + #songText = contentFilter.findall(songSite)[0] + #playString(songText, s) ## Or interactive - mySong = raw_input("\nType in your own song: ") + mySong = input("\nType in your own song: ") playString(mySong, s) - - - - - - - - diff --git a/Chapter06_Digital-Input/bossButton/bossButton.py b/Chapter06_Digital-Input/bossButton/bossButton.py index e9892d87..c33409a4 100644 --- a/Chapter06_Digital-Input/bossButton/bossButton.py +++ b/Chapter06_Digital-Input/bossButton/bossButton.py @@ -21,11 +21,11 @@ while(1): # Sit and wait forever response = sp.read(1) # get one byte if response == "O": - print "Got OK Byte. Waiting for button press." - elif response == "X": - print "Got Boss Byte! Alarm!" + print ("Got OK Byte. Waiting for button press.") + elif response == b"X": + print ("Got Boss Byte! Alarm!") webbrowser.open(BOSS_SITE) else: - print "Got nothing. Still waiting." + print ("Got nothing. Still waiting.") diff --git a/Chapter07_Analog-to-Digital-Conversion-I/slowScope/serialScope.py b/Chapter07_Analog-to-Digital-Conversion-I/slowScope/serialScope.py index fd98580e..3f8828b2 100755 --- a/Chapter07_Analog-to-Digital-Conversion-I/slowScope/serialScope.py +++ b/Chapter07_Analog-to-Digital-Conversion-I/slowScope/serialScope.py @@ -5,18 +5,18 @@ def readValue(serialPort): def plotValue(value): """ Displays the value on a scaled scrolling bargraph""" - leadingSpaces = " " * (value*(SCREEN_WIDTH-3) / 255) - print "%s%3i" % (leadingSpaces, value) + leadingSpaces = "-" * int(value*(SCREEN_WIDTH-3) / 255) + print(f"{leadingSpaces} {value:03}") def cheapoScope(serialPort): while(1): - newValue = readValue(serialPort) - plotValue(newValue) + newValue = readValue(serialPort) + plotValue(newValue) if __name__ == "__main__": - - PORT = '/dev/ttyUSB0' + ## list all serial ports being used: python -m serial.tools.list_ports + PORT = '/dev/ttyUSB0' # update to whatever port is listed in serial.tools.list_ports BAUDRATE = 9600 TIMEOUT = None SCREEN_WIDTH = 80 @@ -27,18 +27,9 @@ def cheapoScope(serialPort): port = sys.argv[1] baudrate = int(sys.argv[2]) else: # nothing passed, use defaults - print ("Optional arguments port, baudrate set to defaults.") - port, baudrate = (PORT, BAUDRATE) + print ("Optional arguments port, baudrate set to defaults.") + port, baudrate = (PORT, BAUDRATE) serialPort = serial.Serial(port, baudrate, timeout=TIMEOUT) serialPort.flush() cheapoScope(serialPort) - - - - - - - - - diff --git a/Chapter08_Hardware-Interrupts/capSense/serialScope.py b/Chapter08_Hardware-Interrupts/capSense/serialScope.py index 64dd38cf..3f8828b2 100755 --- a/Chapter08_Hardware-Interrupts/capSense/serialScope.py +++ b/Chapter08_Hardware-Interrupts/capSense/serialScope.py @@ -1,49 +1,35 @@ -#!/usr/bin/env python - import serial def readValue(serialPort): return(ord(serialPort.read(1))) -def plotValue(value, dashes): - """ - Displays the value on a scaled scrolling bargraph - """ - value = int(value) - if dashes: - print "%s%3i" % (("-"*(value*77 / 255)), value) - else: - print "%s%3i" % ((" "*(value*77 / 255)), value) +def plotValue(value): + """ Displays the value on a scaled scrolling bargraph""" + leadingSpaces = "-" * int(value*(SCREEN_WIDTH-3) / 255) + print(f"{leadingSpaces} {value:03}") -def cheapoScope(serialPort, smoothing, dashes=True): - runningValue = 0.0 +def cheapoScope(serialPort): while(1): - runningValue = float(readValue(serialPort)) + smoothing*runningValue - plotValue(runningValue*(1.0 - smoothing), dashes) + newValue = readValue(serialPort) + plotValue(newValue) if __name__ == "__main__": - - PORT = '/dev/ttyUSB0' + ## list all serial ports being used: python -m serial.tools.list_ports + PORT = '/dev/ttyUSB0' # update to whatever port is listed in serial.tools.list_ports BAUDRATE = 9600 - SMOOTHING = 0 + TIMEOUT = None + SCREEN_WIDTH = 80 ## Take command-line arguments to override defaults above import sys if len(sys.argv) == 3: - baudrate, smoothing = [float(x) for x in sys.argv[1:3]] - else: - baudrate, smoothing = (BAUDRATE, SMOOTHING) + port = sys.argv[1] + baudrate = int(sys.argv[2]) + else: # nothing passed, use defaults + print ("Optional arguments port, baudrate set to defaults.") + port, baudrate = (PORT, BAUDRATE) - serialPort = serial.Serial(PORT, baudrate, timeout=10) + serialPort = serial.Serial(port, baudrate, timeout=TIMEOUT) serialPort.flush() - cheapoScope(serialPort, smoothing, dashes=False) - - - - - - - - - + cheapoScope(serialPort)