diff --git a/README.md b/README.md index 4027b997..45dbc640 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,20 @@ -Arduino Libraries -================= +Arduino Cryptography Library +============================ -This distribution contains a bunch of libraries and example applications -that I have made for Arduino, covering a variety of tasks from blinking LED's -to LCD's and RTC-based alarm clocks. They are distributed under the +This distribution contains a libraries and example applications to perform +cryptography operations on Arduino devices. They are distributed under the terms of the MIT license. -The [documentation](http://rweather.github.com/arduinolibs/index.html) +The [documentation](http://rweather.github.com/arduinolibs/crypto.html) contains more information on the libraries and examples. +This repository used to contain a number of other examples and libraries +for other areas of Arduino functionality but most users are only interested +in the cryptography code. The other projects have been moved to a +separate [repository](https://github.com/rweather/arduino-projects) and +only the cryptography code remains in this repository. + For more information on these libraries, to report bugs, or to suggest improvements, please contact the author Rhys Weatherley via [email](mailto:rhys.weatherley@gmail.com). diff --git a/doc/Doxyfile b/doc/Doxyfile index 6c6e448d..62232722 100644 --- a/doc/Doxyfile +++ b/doc/Doxyfile @@ -26,7 +26,7 @@ DOXYFILE_ENCODING = UTF-8 # identify the project. Note that if you do not use Doxywizard you need # to put quotes around the project name if it contains spaces. -PROJECT_NAME = ArduinoLibs +PROJECT_NAME = "Arduino Cryptography Library" # The PROJECT_NUMBER tag can be used to enter a project or revision number. # This could be handy for archiving the generated documentation or @@ -655,19 +655,10 @@ WARN_LOGFILE = # directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT = ../libraries/LCD \ - ../libraries/BlinkLED \ - ../libraries/I2C \ - ../libraries/RTC \ - ../libraries/Melody \ - ../libraries/PowerSave \ - ../libraries/DMD \ - ../libraries/IR \ - ../libraries/Crypto \ +INPUT = ../libraries/Crypto \ ../libraries/NewHope \ ../libraries/RingOscillatorNoiseSource \ ../libraries/TransistorNoiseSource \ - ../libraries/Shell \ . # This tag can be used to specify the character encoding of the source files @@ -750,19 +741,8 @@ EXAMPLE_RECURSIVE = NO # directories that contain image that are included in the documentation (see # the \image command). -IMAGE_PATH = ../libraries/BlinkLED/examples/Cylon \ - ../libraries/BlinkLED/examples/Cylon4 \ - ../libraries/BlinkLED/examples/StarTrek \ - ../libraries/BlinkLED/examples/Charlieplex \ - ../libraries/LCD/examples/HelloWorld \ - ../libraries/LCD/examples/Form \ - ../libraries/RTC/examples/AlarmClock \ - ../libraries/Crypto \ - ../libraries/RingOscillatorNoiseSource \ - ../libraries/TransistorNoiseSource \ - ../libraries/DMD \ - ../libraries/IR \ - ../libraries/I2C +IMAGE_PATH = ../libraries/RingOscillatorNoiseSource \ + ../libraries/TransistorNoiseSource # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program diff --git a/doc/alarm-clock.dox b/doc/alarm-clock.dox deleted file mode 100644 index a3522d69..00000000 --- a/doc/alarm-clock.dox +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -/** -\file alarm-clock.dox -\page alarm_clock Alarm Clock - -\section clock_features Features - -The alarm clock described on this page is a large example application that -uses many of the classes in the provided libraries: LCD, Form, -Field, SoftI2C, DS1307RTC (or DS3232RTC), Melody and -\ref power_save "PowerSave". The clock has the following features: - -\li Displays both the time and date. -\li 12 hour and 24 hour time display modes. -\li Up to 4 configurable alarm times, plus a snooze alarm. -\li Three alarm sounds to choose from, plus an option to use a radio alarm. -\li Configurable alarm timeout between 2 and 10 seconds. -\li Alarms can be configured to only sound on Monday to Friday - or on Saturday and Sunday. -\li Single button to activate the back light and/or stop the alarm. -\li Up, down, left, and right buttons to change clock settings. -\li MOSFET that controls the power to a separate radio circuit. - -\section clock_main_circuit Main circuit - -The main clock circuit consists of an Arduino Uno compatible board, a 16x2 -LCD module, a realtime clock chip, a piezo buzzer for the alarm, and a -MOSFET for controlling the radio: - -\image html alarm_circuit.png - -Some of the components can be purchased ready-made as the -Freetronics -16x2 LCD Shield and the SparkFun -Realtime Clock Module. I used the ready-made realtime clock module, -but made my own equivalent to the LCD shield from parts to aid in spacing -out the LCD and pushbuttons on the exterior of the box. The value of the 33R -resistor may need to be adjusted for different types of back light LED's. -See \ref clock_ds3232 "below" for information on using a DS3232-based -clock module instead of a DS1307-based module. - -The whole circuit is built on a prototyping shield, with ribbon cables -connecting to the LCD. The Stop Alarm button, piezo buzzer, and radio -controller are not shown in this picture and some of the components are -soldered to the bottom of the shield: - -\image html clock_shield.jpg - -The clock module is based on the DS1307 chip and has an on-board coin battery -to keep the time and date ticking over even if the main circuit loses power. -The chip is I2C-based and has an auxillary SQW output that can be configured -to provide a 1 Hz squarewave signal. This signal is used by the software -running on the Arduino to detect when a new time or date is available for -display on the LCD. The DS1307RTC class takes care of the details of -talking to the chip via I2C. - -\section clock_arduino_board Arduino board - -To keep power consumption low, say for being powered by batteries, we don't -need a full Arduino Uno or similar board. The USB interface is unnecessary, -as is the on-board power supply if there is an external source of 5 volt power. -We also don't want the power and D13 status LED's to be draining power. -Therefore, a cut-down version of the Arduino is recommended. We used the -KitTen -kit from Freetronics, and didn't -solder up anything that wasn't strictly necessary. A -5v FTDI USB-to-Serial cable -is necessary for programming. Similar minimalistic built-it-yourself -Arduino designs should also work. - -\image html kitten_minimal.jpg - -\section clock_radio Controlling a radio - -The MOSFET connected to D11 can be used to control the power supply to a -separate radio circuit so that the radio can be used as an alarm. In the -following circuit, RadioV+ is the radio's power supply voltage (which may -be the Arduino's 5V supply if the radio can run off 5V): - -\image html radio_controller.png - -The output of the MOSFET can be used to control almost any kind of -circuit; for example an extremely loud mechanical alarm bell. It doesn't -have to be a radio. A 2N7000 or equivalent MOSFET is suitable for light -loads up to 200mA. For larger currents, a higher-rated MOSFET should be -used instead. - -Double-tapping the Stop Alarm button will turn the radio on. Single-tapping -the Stop Alarm button will turn the radio off. A settings field can also -be used to turn the radio on and off. - -\section clock_ds3232 Using DS3232 instead of DS1307 - -For clock modules based on the DS3232 chip, such as the -Freetronics Real Time Clock Module, change the \c Clock typedef -in Clock.h to the following: - -\code -typedef DS3232RTC Clock; -\endcode - -The pads on the Freetronics module should be connected to the Arduino -as follows: - -\li VCC and GND connected to 5V and GND on the Arduino. -\li SQI connected to A3. -\li SDA connected to A4. -\li SCL connected to A5. -\li BAT, 32K, and RST left unconnected. - -\section clock_completed Completed Clock - -The following picture shows the completed clock prototype, built into a -UB1 jiffy box with the radio. Being the prototype, it is a little rough -and ready, but rugged enough to take a pounding each morning as a bedside -alarm clock: - -\image html alarm_clock.jpg - -*/ diff --git a/doc/blink-blink.dox b/doc/blink-blink.dox deleted file mode 100644 index 028d900e..00000000 --- a/doc/blink-blink.dox +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -/** -\file blink-blink.dox -\page blink_blink Blinking LED Example - -The BlinkLED class provides support logic for blinking a LED connected -to an output pin. The traditional way to blink a LED uses a delay loop: - -\code -void loop() { - digitalWrite(13, HIGH); - delay(1000); - digitalWrite(13, LOW); - delay(1000); -} -\endcode - -The problem with this code is that the entire application is blocked -during the delay(). No other activities can be serviced. -BlinkLED provides a re-entrant timer-based implementation that is -simple to use in any application and which won't block other activities. - -We start this example by including the BlinkLED class and instantiating an -object instance: - -\dontinclude BlinkLED/examples/Blink/Blink.ino -\skip #include -\until statusBlink - -In this example we have specified that the LED is on pin D13, the LED -should be on for 70 milliseconds, and off for 930 milliseconds. This -will cause the status LED to "strobe" once per second. The LED will -be initially off for 930 milliseconds after device reset. To start -with the LED on, use the following initialization code instead: - -\code -BlinkLED statusBlink(13, 70, 930, true); -\endcode - -The remaining code we need is a call to BlinkLED::loop() every time around -the main application loop: - -\dontinclude BlinkLED/examples/Blink/Blink.ino -\skip loop() -\until } - -As can be seen, BlinkLED simplifies the process of blinking a LED quite -considerably. It is also possible to \ref BlinkLED::pause() "pause()" -and \ref BlinkLED::resume() "resume()" the blinking. This is useful in -applications where a blinking LED indicates a certain state such as -an error condition or a long-running operation that is in progress; -with the LED off at other times. The on/off blink rate can be modified at -runtime using BlinkLED::setBlinkRate(), and the LED can be set to a -specific value using BlinkLED::setState(). - -The full source code for the example follows: - -\include BlinkLED/examples/Blink/Blink.ino -*/ diff --git a/doc/blink-charlieplex.dox b/doc/blink-charlieplex.dox deleted file mode 100644 index 47c64d21..00000000 --- a/doc/blink-charlieplex.dox +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -/** -\file blink-charlieplex.dox -\page blink_charlieplex Charlieplexing Example - -Charlieplexing -is a technique for multiplexing large numbers of LED's on a small -number of microcontroller output pins. LED's are arranged in -complementary pairs and managed by the Charlieplex class. For this -example we are going to use 3 output pins to drive 6 LED's: - -\image html charlieplexeg.png - -The technique can be expanded to even larger numbers of LED's. -See the documentation for the Charlieplex class for a description of -how to connect up larger numbers of pins in a Charlieplexed arrangement. - -The first step is to initialize a Charlieplex object with the output -pins it needs to drive: - -\dontinclude BlinkLED/examples/Charlieplex/Charlieplex.ino -\skip #include -\until charlie - -Then in setup() we use Charlieplex::setLed() and -Charlieplex::setPwmLed() to set three of the six LED's to -the desired output values: - -\dontinclude BlinkLED/examples/Charlieplex/Charlieplex.ino -\skip setup -\until } - -Charlieplexing can only light a single LED at a time. It is therefore -necessary to constantly scan the entire LED array, alternatively turning -LED's on and off. The user's peristence of vision fills in the gaps. -To do this, we call Charlieplex::loop(): - -\dontinclude BlinkLED/examples/Charlieplex/Charlieplex.ino -\skip loop -\until } - -The downside of Charlieplexing is that when multiple LED's are lit, each LED -will appear to be dimmer than if only a single LED was lit. This can be -counteracted by using brighter LED's or smaller resistors. The danger with -smaller resistors is that if the program crashes or locks up for some reason, -a large amount of continuous current could be fed through a single LED and -cause it to exceed its maximum rating and burn out. - -The full source code for the example follows: - -\include BlinkLED/examples/Charlieplex/Charlieplex.ino - -A more complex example that performs a LED chase over the 6 LED's follows: - -\include BlinkLED/examples/CharlieplexChase/CharlieplexChase.ino -*/ diff --git a/doc/blink-cylon.dox b/doc/blink-cylon.dox deleted file mode 100644 index d1599812..00000000 --- a/doc/blink-cylon.dox +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -/** -\file blink-cylon.dox -\page blink_cylon Cylon Eyes Example - -This example shows how to use the ChaseLEDs class to simulate the Cylon -eye effect from Battlestar Galactica. Digital outputs are used to drive -six LED's in a back and forth motion, using the following schematic: - -\image html Cylon.png - -We start by including the ChaseLEDs class: - -\dontinclude BlinkLED/examples/Cylon/Cylon.ino -\skip ChaseLEDs.h -\until ChaseLEDs.h - -The next step is to define the pins that the chase will run over: - -\dontinclude BlinkLED/examples/Cylon/Cylon.ino -\skip byte pins -\until cylonEyes - -The chase runs from the first pin to the sixth pin and back again, -with each LED lit for 100 milliseconds before moving onto the next one. -To complete the example, we need to call ChaseLEDs::loop() each time -around our main loop to cause the chase to run: - -\dontinclude BlinkLED/examples/Cylon/Cylon.ino -\skip loop() -\until } - -While this example uses only six pins, it can be easily extended to any -number of pins by modifying the \c pins array and altering the schematic -accordingly. - -So far we are chasing only a single LED. We could change this to chase -two adjacent LED's instead by defining a new \c CylonChase class that -inherits from ChaseLEDs: - -\dontinclude BlinkLED/examples/Cylon2/Cylon2.ino -\skip class CylonChase -\until }; - -The important part is the implementation of the advance() method, -which overrides ChaseLEDs::advance() to provide our own scheme for lighting -the LED's each time the chase advances. We use ChaseLEDs::previousPin() to -get the pin that is 2 steps back in the sequence, set it to LOW, and then -set the previous pin (1 step back) and the next pin to HIGH. All that -remains is to change our chase initialization to use the new class: - -\dontinclude BlinkLED/examples/Cylon2/Cylon2.ino -\skip byte pins -\until cylonEyes - -We can do even better than this. Instead of fully lighting both LED's, -we could instead use the PWM outputs to dim the previous pin, creating a -kind of "trailing flame" effect: - -\dontinclude BlinkLED/examples/Cylon3/Cylon3.ino -\skip advance( -\until } - -The current chase is fixed at 100 milliseconds per LED, which takes a full -second to run the sequence. An alternative to hard-wiring the chase -rate is to hook up a 10K potentiometer to the A0 analog input: - -\image html Cylon4.png - -We then modify the advance() method to read the new chase rate -from the potentiometer each time the LED advances: - -\dontinclude BlinkLED/examples/Cylon4/Cylon4.ino -\skip advance( -\until } - -The full source code for the final version of the example follows: - -\include BlinkLED/examples/Cylon4/Cylon4.ino -*/ diff --git a/doc/blink-startrek.dox b/doc/blink-startrek.dox deleted file mode 100644 index fb0dfb59..00000000 --- a/doc/blink-startrek.dox +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -/** -\file blink-startrek.dox -\page blink_startrek Star Trek Example - -This example shows how to use the BlinkLED and ChaseLEDs classes to -simulate the running lights on the starship Enterprise from Star Trek. -This can be used as the basis for lighting a model kit. It is -recommended that you read the \ref blink_blink "Blink" and -\ref blink_cylon "Cylon" tutorials first. - -There are four categories of lights on the Enterprise: - -\li Static lights in windows, engines, and the deflector dish. -We don't handle those in this example as we assume that they are -connected directly to the power supply with no computer control. -\li Red and green navigation lights on the left and right of the saucer, -and on the left and right warp nacelles, typically with a 1 second period. -The red light is on the left as viewed from the back of the model. -\li White strobe light behind the bridge and on the warp nacelles -that comes on briefly every second. -\li Nacelle lights that perform a circular LED chase in the front of the -nacelles to create the warp engine twirl effect. - -Different models of the Enterprise have the lights in different places, -and the period of flashing can vary from TV show to show, and sometimes -from episode to episode. There isn't a definitive set of blink timings -or number of LED's in the nacelle chase. The sketch has a number of -configurable parameters that gives the user the freedom to choose which -show and/or episode they wish to treat as "canonical" for their model. - -We start by building a test circuit with a small number of LED's for -each of the three categories (navigation, strobe, and nacelles): - -\image html StarTrek.png - -This won't be the final circuit for the model, but building it on a -breadboard will help with the initial prototyping stages and choosing -the appropriate blink timings: - -\image html StarTrekBreadboard.png - -Alternatively, the test circuit can be built on a prototyping shield -with the chase LED's in a circular arrangement to simulate how they will -look when placed in the front of the model's warp nacelles: - -\image html StarTrekShield.png - -Now that we have a circuit, let's configure the red navigation LED on AOUT2 -using the BlinkLED class, to blink with a period of 1000 milliseconds on, -1000 milliseconds off: - -\dontinclude BlinkLED/examples/StarTrek/StarTrek.ino -\skip -\until -\skip NAV_LIGHTS -\until NAV_LIGHTS -\skip NAV_LIGHTS_ON -\until NAV_LIGHTS_OFF -\skip navLights -\until navLights - -We repeat the process for the strobe LED on AOUT3, with a period of -70 milliseconds on, and 830 milliseconds off: - -\dontinclude BlinkLED/examples/StarTrek/StarTrek.ino -\skip STROBE_LIGHT -\until STROBE_LIGHT -\skip STROBE_LIGHT_ON -\until STROBE_LIGHT_OFF -\skip strobeLight -\until strobeLight - -We also need to arrange for BlinkLED::loop() to be called from the -application's main loop() function: - -\code -void loop() { - navLights.loop(); - strobeLight.loop(); -} -\endcode - -If you run the sketch at this point, you should see the navigation and -strobe LED's blink with the selected rates. - -Next is the twirl effect in the warp nacelles, using the ChaseLEDs -class. We are actually going to inherit from ChaseLEDs to create a -custom LED chaser that reads the chase rate from AIN0 and uses PWM -outputs to create a trailing flame effect. See the -\ref blink_cylon "Cylon" example for more information on creating -custom effects with ChaseLEDs. - -\dontinclude BlinkLED/examples/StarTrek/StarTrek.ino -\skip NACELLE_CHASE_LEN -\until NacelleChaseLEDs nacelleChase - -We also need to add a call to ChaseLEDs::loop() to the application's -main loop: - -\dontinclude BlinkLED/examples/StarTrek/StarTrek.ino -\skip loop() -\until } - -Running the sketch now should cause the six LED's in the nacelle -sequence to chase, in addition to the navigation and strobe LED's. -The 10K potentiometer can be used to select the desired chase rate. -This completes the test circuit, and will allow you to fiddle with -the blink timings and chase rate until you are happy with the result. - -We've made provision in this sketch for six outputs in the chase, -but some models may only use three or five. The NACELLE_CHASE_LEN -parameter controls the length of the chase. - -With three outputs, the LED's can be arranged in opposite pairs, -lighting two LED's at a time. The following circuit demonstrates -how three outputs can be used to drive six LED's: - -\image html ThreeChase.png - -You will need two of these circuits, for the left and right warp nacelles. -The transistor drivers reduce the current load on the Arduino CPU and -provide the option to drive the LED's from 12V instead of 5V. - -It is recommended that you use transistor drivers for the navigation and -strobe lights as well as there will be multiple LED's on each output in a -real model. For example, there will be at least three each of the red -and green navigation lights: the top of the saucer section, the bottom of -the saucer section, and the top of the warp nacelle. Using a 12V supply -will make it easier to string lots of LED's together in series. - -Other nacelle effects are possible by modifying the advance() method -in the sketch. For example, the "opposite pairs" effect with 3 outputs -can also be done with 6 outputs and the following modification to the sketch: - -\dontinclude BlinkLED/examples/StarTrek2/StarTrek2.ino -\skip advance(byte -\until } - -The full source code for the example, including the "opposite pairs" -effect, follows: - -\include BlinkLED/examples/StarTrek2/StarTrek2.ino -*/ diff --git a/doc/crypto.dox b/doc/crypto.dox index 0f8f2d53..867615b5 100644 --- a/doc/crypto.dox +++ b/doc/crypto.dox @@ -22,7 +22,7 @@ /** \file crypto.dox -\page crypto Cryptographic Library +\page crypto Arduino Cryptography Library \section crypto_algorithms Supported Algorithms diff --git a/doc/dmd-demo.dox b/doc/dmd-demo.dox deleted file mode 100644 index 283fa151..00000000 --- a/doc/dmd-demo.dox +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -/** -\file dmd-demo.dox -\page dmd_demo Dot Matrix Display Demo - -This demo shows off various features of drawing with the Bitmap class -to a DMD display: - -\li Drawing circles, lines, and rectangles. -\li Filling the screen with a bitmap-based brick pattern. -\li Drawing bitmaps directly from program memory. -\li Drawing text in various fonts. -\li Scrolling text in a "marquee". - -\ref dmd_running_figure "RunningFigure" provides another example of -drawing and animating bitmaps. - -The full source code for the demo follows: - -\include DMD/examples/Demo/Demo.ino -*/ diff --git a/doc/dmd-running-figure.dox b/doc/dmd-running-figure.dox deleted file mode 100644 index e6e2fd51..00000000 --- a/doc/dmd-running-figure.dox +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -/** -\file dmd-running-figure.dox -\page dmd_running_figure Running figure example - -This example demonstrates how to draw animated bitmaps to -Freetronics Large Dot -Matrix Displays. These displays have 512 LED's arranged in a -32x16 matrix and controlled by an SPI interface. The displays are -available in red, blue, green, yellow, and white variations. - -The first step is to initialize the display: - -\dontinclude DMD/examples/RunningFigure/RunningFigure.ino -\skip #include -\until DMD display; - -We will also need some bitmaps to animate the running figure. We will use -static bitmaps stored in program memory. The first frame of the 10-frame -animation is: - -\dontinclude DMD/examples/RunningFigure/RunningFigure.ino -\skip run1 -\until }; - -As can be seen, the bitmap is made up of 0's and 1's; a 1 bit indicates that -the corresponding LED will be lit when it is drawn to the dot matrix display. -The first two bytes are the width and height of the bitmap in pixels. -In this case, the first frame is 16x16 pixels. Other frames in the animation -are 18x16 and 13x16. - -We store pointers to all of the frames in a common array: - -\dontinclude DMD/examples/RunningFigure/RunningFigure.ino -\skip frames[] -\until frame = 0 - -All that remains is to run the animation loop: - -\dontinclude DMD/examples/RunningFigure/RunningFigure.ino -\skip ADVANCE_MS -\until display.loop() -\until } - -Each time \c ADVANCE_MS milliseconds expires, we clear the display and -draw a bitmap centered on the screen. To help with the centering, we read -the width value from the bitmap for the current frame (the height is -always 16). We must also call DMD::loop() repeatedly from the application's -main loop() function to ensure that the display is kept refreshed. - -Sometimes it can be inconvenient to arrange for DMD::loop() to be called -regularly. An alternative is to use Timer1 or Timer2 and -\ref dmd_interrupts "interrupt-driven display refresh": - -\dontinclude DMD/examples/RunningFigureISR/RunningFigureISR.ino -\skip ADVANCE_MS -\until loop() -\until } - -In the case of Timer2, \c TIMER2_OVF_vect and \ref DMD::enableTimer2() "enableTimer2()" -would be used in place of \c TIMER1_OVF_vect and \ref DMD::enableTimer1() "enableTimer1()". - -The full source code for the example follows: - -\include DMD/examples/RunningFigure/RunningFigure.ino -*/ diff --git a/doc/ir-dumpir.dox b/doc/ir-dumpir.dox deleted file mode 100644 index 93e1d62a..00000000 --- a/doc/ir-dumpir.dox +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -/** -\file ir-dumpir.dox -\page ir_dumpir Dumping Infrared Remote Control Codes - -This example uses the IRreceiver class to dump commands that are received -from an infrared remote control that is compatible with the -Philips RC-5 protocol. -Commands are dumped to the serial port. The example needs a 3-pin -infrared receiver connected to D2, GND, and 5V: - -\image html irchip.jpg - -The full source code for the example follows: - -\include IR/examples/DumpIR/DumpIR.ino -*/ diff --git a/doc/ir-snake.dox b/doc/ir-snake.dox deleted file mode 100644 index 1f01e6ac..00000000 --- a/doc/ir-snake.dox +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -/** -\file ir-snake.dox -\page ir_snake Snake Video Game Using an Infrared Remote Control - -This example demonstrates the use of the DMD and IRreceiver classes. -The full source code follows: - -\include IR/examples/Snake/Snake.ino -*/ diff --git a/doc/lcd-form.dox b/doc/lcd-form.dox deleted file mode 100644 index 2aa5d6dc..00000000 --- a/doc/lcd-form.dox +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -/** -\file lcd-form.dox -\page lcd_form Form example for LCD displays - -The Form and Field classes simplify the process of building user interfaces -for Arduino projects that use a Freetronics LCD shield. That shield has a -16x2 LCD display and five buttons for Up, Down, Left, Right, and Select. - -The user interface is organised as a "form" which consists of one or more -"fields" that display or modify a single program parameter. The Left and -Right buttons are used to navigate between fields, and the Up and Down -buttons are used to modify the value of the currently-displayed field. - -\image html FormText.png - -We start by including the classes from the library that we will need: - -\dontinclude LCD/examples/Form/Form.ino -\skip LCD.h -\until BoolField.h - -Next, we initialize the LCD display, create the main form, and populate -it with fields: - -\dontinclude LCD/examples/Form/Form.ino -\skip lcd; -\until lcd; -\skip mainForm -\until durationField - -Each field has a specific type, which may be one of the following classes: - -\li BoolField displays a boolean on/off value with the Up and Down -buttons used to toggle its state. -\li IntField displays an integer value within a specified range, with the -Up and Down buttons used to modify the value. -\li TextField displays a read-only value, which is typically used for -status messages and program results. -\li TimeField displays a time in hours, minutes, and seconds. The field may -be either read-only or writable. Writable time fields can be modified with -the Up, Down, Left, and Right buttons to select a specific duration. - -Returning to our example, the above code creates the following fields: - -\li \c welcomeField to display the program's name and version. -\li \c timeField to display the number of seconds since reset, wrapping around -after 24 hours. This field is read-only. -\li \c volumeField which displays a volume between 0 and 100, with an Up/Down -step of 5, and a suffix of "%". -\li \c ledField which displays the current boolean state of the status LED on -D13; the LED will change state when the user toggles the field's value. -\li \c durationField which displays a read-write time field for selecting a -duration between 0 and 24 hours. - -Now that we have defined our form, we need to initialize the program and -show the form for the first time: - -\dontinclude LCD/examples/Form/Form.ino -\skip STATUS_LED -\until } - -An application can have multiple forms, but only one can be shown at any -given time. To switch to another form, call Form::hide() on the old -form and Form::show() on the new form. - -All that remains is to define our application's \c loop function which -retrieves button events from LCD::getButton() and dispatches them -to the form: - -\dontinclude LCD/examples/Form/Form.ino -\skip loop() -\until } -\until } -\until } - -The full source code for the example follows: - -\include LCD/examples/Form/Form.ino -*/ diff --git a/doc/lcd-helloworld.dox b/doc/lcd-helloworld.dox deleted file mode 100644 index efc0d386..00000000 --- a/doc/lcd-helloworld.dox +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -/** -\file lcd-helloworld.dox -\page lcd_hello_world Hello World for Freetronics LCD - -The LCD class provides an enhanced version of the standard -Arduino LiquidCrystal -library that supports the additional features of the -Freetronics LCD shield; -namely the back light and the Up, Down, Left, Right, and Select buttons. -This tutorial explains how to use the LCD class to perform -basic text output and to use the enhanced shield features. - -\image html HelloWorld.png - -We start by including the library and initializing it: - -\dontinclude LCD/examples/HelloWorld/HelloWorld.ino -\skip LCD.h -\until lcd - -Unlike the LiquidCrystal library we don't normally need to specify the pin -assignments for this shield. The one exception is when the shield is used -with the USBDroid and the D9 pin is reassigned as described on -this page. In that case, the initialization sequence -would look something like this instead: - -\code -LCD lcd(A1); -\endcode - -The next step is to enable the screen saver and print some text -in the \c setup function: - -\dontinclude LCD/examples/HelloWorld/HelloWorld.ino -\skip setup() -\until } - -The screen saver is a built-in feature of the LCD class that -turns off the display and the back light after a specific timeout -(the default is 10 seconds). Pressing any of the keys on the shield -or calling LCD::display() will wake up the screen again. - -In the program's \c loop function we print the number of seconds -since startup to the second line of the LCD display: - -\dontinclude LCD/examples/HelloWorld/HelloWorld.ino -\skip loop() -\until millis() - -We then print the name of the button that is currently pressed: - -\dontinclude LCD/examples/HelloWorld/HelloWorld.ino -\skip setCursor(8, 1) -\until } - -The LCD::getButton() function returns the key that has -been pressed or released, or LCD_BUTTON_NONE if no key has been -pressed or released this time through the loop. - -The full source code for the example follows: - -\include LCD/examples/HelloWorld/HelloWorld.ino -*/ diff --git a/doc/mainpage.dox b/doc/mainpage.dox index fb2de01f..b81821e8 100644 --- a/doc/mainpage.dox +++ b/doc/mainpage.dox @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. + * Copyright (C) 2018 Southern Storm Software, Pty Ltd. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -24,111 +24,21 @@ \file mainpage.dox \mainpage -This distribution contains a bunch of libraries and example applications -that I have made for Arduino, covering a variety of tasks from blinking LED's -to LCD's and RTC-based alarm clocks. They are distributed under the -terms of the MIT license, with the source code available from -github. +This distribution contains a libraries and example applications to perform +cryptography operations on Arduino devices. They are distributed under the +terms of the MIT license. + +See the main \ref crypto "documentation page" for more information on +the libraries and examples. + +This repository used to contain a number of other examples and libraries +for other areas of Arduino functionality but most users are only interested +in the cryptography code. The other projects have been moved to a +separate repository +and only the cryptography code remains in this repository. For more information on these libraries, to report bugs, or to suggest improvements, please contact the author Rhys Weatherley via email. -\section main_LCD LCD Shield - -\li LCD class to manage the extended features of the Freetronics -and DFRobot LCD shields. -\li Form and Field classes to build simple property sheet UI's on LCD displays. -\li \ref lcd_hello_world "Hello World" example for the Freetronics LCD shield. -\li \ref lcd_form "Form" example for LCD displays. - -\section main_DMD Freetronics Large Dot Matrix Display (DMD) - -\li DMD class to manage the initialize of the display. -\li Bitmap class to manage drawing to in-memory bitmaps and the DMD display. -\li \ref dmd_demo "Demo" that shows off various bitmap drawing features. -\li \ref dmd_running_figure "RunningFigure" example that demonstrates how -to draw and animate bitmaps. -\li \ref ir_snake "Snake" game that combines the dot matrix display with -IRreceiver to make a simple video game. - -\section main_BlinkLED BlinkLED Utility Library - -\li BlinkLED class that simplifies the process of blinking a LED connected -to a output pin. -\li ChaseLEDs class that simplifies the process of performing a LED chase -over several output pins. -\li Charlieplex class that manages a matrix of LED's arranged in a -Charlieplexing -arrangement. -\li \ref blink_blink "Blink" example of using BlinkLED. -\li \ref blink_cylon "Cylon" example of using ChaseLEDs to simulate -the Cylon eye effect from Battlestar Galactica. -\li \ref blink_startrek "StarTrek" example for lighting a starship -Enterprise model kit. -\li \ref blink_charlieplex "Charlieplex" example. - -\section main_I2C I2C Utility Library - -\li I2CMaster abstract class that provides an improved API for implementing an -I2C master. -\li SoftI2C class that implements the master side of the I2C protocol -in software on any arbitrary pair of pins for DATA and CLOCK. -This class supports both 7-bit and 10-bit I2C addresses. -\li EEPROM24 class for reading and writing 24LCXX family EEPROM's. - -\section main_RTC Realtime Clock Library - -\li RTC class that acts as a base for all realtime clock implementations, -including support for configuring alarms and storing clock settings. -The default implementation simulates the time and date based on the value of -millis(). -\li DS1307RTC class that talks to the DS1307 realtime clock chip via I2C. -\li DS3231RTC class that talks to the DS3231 realtime clock chip via I2C. -\li DS3232RTC class that talks to the DS3232 realtime clock chip via I2C. -\li \ref alarm_clock "Alarm Clock" example that uses the DS1307 or DS3232 -realtime clock and the LCD library to implement an alarm clock. - -\section main_Crypto Cryptographic Library - -\li Block ciphers: AES128, AES192, AES256, Speck -\li Block cipher modes: CTR, CFB, CBC, OFB, EAX, GCM, XTS -\li Stream ciphers: ChaCha -\li Authenticated encryption with associated data (AEAD): ChaChaPoly, EAX, GCM -\li Hash algorithms: SHA256, SHA512, SHA3_256, SHA3_512, BLAKE2s, BLAKE2b (regular and HMAC modes) -\li Extendable output functions (XOF's): SHAKE128, SHAKE256 -\li Message authenticators: Poly1305, GHASH, OMAC -\li Public key algorithms: Curve25519, Ed25519, P521 -\li Post-quantum algorithms: NewHope -\li Random number generation: \link RNGClass RNG\endlink, TransistorNoiseSource, RingOscillatorNoiseSource - -More information can be found on the \ref crypto "Cryptographic Library" page. - -\section main_Shell Shell Library - -\li Terminal class that extends Stream with functions suitable for -interfacing to a VT100-compatible terminal program like PuTTY. -\li Shell class that manages a Unix-like command-line shell for executing -commands via a serial port or telnet session. Shell is built on top of -the functionality of Terminal. -\li LoginShell class that extends Shell to provide a simple username and -password login mechanism. -\li \ref shell_serial "SerialShell" example that shows how to use Shell to -provide command-line access via a serial port. -\li \ref shell_telnet "TelnetServer" example that shows how to use -LoginShell to provide command-line access via the telnet protocol. - -\section main_IR Infrared Control Library - -\li IRreceiver class that receives incoming RC-5 commands from an -infrared remote control. -\li \ref ir_dumpir "DumpIR" example that dumps all incoming RC-5 commands. -\li \ref ir_snake "Snake" game that combines DMD with an infrared remote -control to make a simple video game. - -\section main_other Other - -\li Melody plays a melody on a digital output pin using tone(). -\li \ref power_save "Power saving utility functions" - */ diff --git a/doc/shell-serial.dox b/doc/shell-serial.dox deleted file mode 100644 index a54e5fd7..00000000 --- a/doc/shell-serial.dox +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (C) 2016 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -/** -\file shell-serial.dox -\page shell_serial Serial port Shell example - -The Shell class provides a Unix-like shell for issuing commands to -the Arduino. This example shows how to use Shell to provide command-line -access via a serial port. The example has one command "led" for turning -the status LED on D13 on and off. - -We start by including the shell library definitions and declaring a -variable of type Shell: - -\dontinclude Shell/examples/SerialShell/SerialShell.ino -\skip #include -\until Shell shell; - -Next we need to initialize the serial port and tell the shell object -to use it for communications: - -\dontinclude Shell/examples/SerialShell/SerialShell.ino -\skip void setup() -\until } - -The call to \link Shell::setPrompt() shell.setPrompt()\endlink specifies -the prompt to display whenever a new line of input is required. The -default value is "$ " but we have changed it to "Command: " in this example. -The string can be anything and can be changed later if necessary. - -The call to \link Shell::begin() shell.begin()\endlink starts the actual -shell. The first argument is the underlying stream to use for -communications, the Serial port in our case. The second argument sets the -size of the history stack so that Shell can remember previous commands -and let the user navigate back to them with the up/down arrow keys. - -The shell needs to regularly process input from the serial port and -handle commands. We accomplish this by calling -\link Shell::loop() shell.loop()\endlink from the application's main -loop() function: - -\dontinclude Shell/examples/SerialShell/SerialShell.ino -\skip void loop() -\until } - -At this point the application will have two builtin commands, "help" and -"exit". But we also want a command of our own. We do this by declaring a -command handler: - -\dontinclude Shell/examples/SerialShell/SerialShell.ino -\skip int ledPin -\until ShellCommand - -The ShellCommand() macro informs the shell of a new command with its name, -help string, and the name of the handler function. - -The full source code for the example follows: - -\include Shell/examples/SerialShell/SerialShell.ino -*/ diff --git a/doc/shell-telnet.dox b/doc/shell-telnet.dox deleted file mode 100644 index ee3afe53..00000000 --- a/doc/shell-telnet.dox +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2016 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -/** -\file shell-telnet.dox -\page shell_telnet Telnet server example - -The Shell class provides a Unix-like shell for issuing commands to -the Arduino. The LoginShell class extends Shell to also include login -functionality. The user is prompted for username and password before -access is granted to shell commands. - -This example shows how to use LoginShell to provide command-line access -over the Internet via the telnet protocol. The example has one command -"led" for turning the status LED on D13 on and off. - -The full source code for the example follows: - -\include Shell/examples/TelnetServer/TelnetServer.ino -*/ diff --git a/gen/genflip.c b/gen/genflip.c deleted file mode 100644 index 67f0f50b..00000000 --- a/gen/genflip.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#include - -int main(int argc, char *argv[]) -{ - int value; - printf("static const uint8_t flipBits[256] PROGMEM = {\n"); - for (value = 0; value < 256; ++value) { - int flipped = - ((value & 0x01) << 7) | ((value & 0x02) << 5) | - ((value & 0x04) << 3) | ((value & 0x08) << 1) | - ((value & 0x10) >> 1) | ((value & 0x20) >> 3) | - ((value & 0x40) >> 5) | ((value & 0x80) >> 7); - if ((value % 12) == 0) - printf(" "); - else - printf(" "); - if (value != 255) - printf("0x%02X,", flipped); - else - printf("0x%02X", flipped); - if ((value % 12) == 11) - printf("\n"); - } - printf("\n};\n"); - return 0; -} diff --git a/gen/genkeymap.cpp b/gen/genkeymap.cpp deleted file mode 100644 index 49ddb1e1..00000000 --- a/gen/genkeymap.cpp +++ /dev/null @@ -1,304 +0,0 @@ -/* - * Copyright (C) 2016 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -// Generates the keymap state machine table for the Terminal class. - -#include -#include -#include -#include "../libraries/Terminal/USBKeysExtra.h" - -typedef struct { - const char *sequence; - int code; -} EscKey; -static EscKey const escKeys[] = { - // Based on the key sequence tables from: - // http://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-PC-Style-Function-Keys - // http://aperiodic.net/phil/archives/Geekery/term-function-keys.html - // Also some miscellaneous codes from other sources like the Linux console. - - // Cursor control keys. - {"[A", KEY_UP_ARROW}, - {"OA", KEY_UP_ARROW}, - {"A", KEY_UP_ARROW}, - {"[B", KEY_DOWN_ARROW}, - {"OB", KEY_DOWN_ARROW}, - {"B", KEY_DOWN_ARROW}, - {"[C", KEY_RIGHT_ARROW}, - {"OC", KEY_RIGHT_ARROW}, - {"C", KEY_RIGHT_ARROW}, - {"[D", KEY_LEFT_ARROW}, - {"OD", KEY_LEFT_ARROW}, - {"D", KEY_LEFT_ARROW}, - {"[H", KEY_HOME}, - {"OH", KEY_HOME}, - {"[1~", KEY_HOME}, - {"[F", KEY_END}, - {"OF", KEY_END}, - {"[4~", KEY_END}, - {"[2~", KEY_INSERT}, - {"[3~", KEY_DELETE}, - {"[5~", KEY_PAGE_UP}, - {"[6~", KEY_PAGE_DOWN}, - - // Numeric keypad. Mostly mapped back to ASCII. - {"O ", ' '}, - {"? ", ' '}, - {"OI", KEY_TAB}, - {"?I", KEY_TAB}, - {"OM", KEY_RETURN}, - {"?M", KEY_RETURN}, - {"Oj", '*'}, - {"?j", '*'}, - {"Ok", '+'}, - {"?k", '+'}, - {"Ol", ','}, - {"?l", ','}, - {"Om", '-'}, - {"?m", '-'}, - {"On", '.'}, - {"?n", '.'}, - {"Oo", '/'}, - {"?o", '/'}, - {"Op", '0'}, - {"?p", '0'}, - {"Oq", '1'}, - {"?q", '1'}, - {"Or", '2'}, - {"?r", '2'}, - {"Os", '3'}, - {"?s", '3'}, - {"Ot", '4'}, - {"?t", '4'}, - {"Ou", '5'}, - {"?u", '5'}, - {"Ov", '6'}, - {"?v", '6'}, - {"Ow", '7'}, - {"?w", '7'}, - {"Ox", '8'}, - {"?x", '8'}, - {"Oy", '9'}, - {"?y", '9'}, - {"OX", '='}, - {"?X", '='}, - - // Function keys. - {"[11~", KEY_F1}, - {"P", KEY_F1}, - {"OP", KEY_F1}, - {"[[A", KEY_F1}, - {"[12~", KEY_F2}, - {"Q", KEY_F2}, - {"OQ", KEY_F2}, - {"[[B", KEY_F2}, - {"[13~", KEY_F3}, - {"R", KEY_F3}, - {"OR", KEY_F3}, - {"[[C", KEY_F3}, - {"[14~", KEY_F4}, - {"S", KEY_F4}, - {"OS", KEY_F4}, - {"[[D", KEY_F4}, - {"[15~", KEY_F5}, - {"[[E", KEY_F5}, - {"[17~", KEY_F6}, - {"[18~", KEY_F7}, - {"[19~", KEY_F8}, - {"[20~", KEY_F9}, - {"[21~", KEY_F10}, - {"[23~", KEY_F11}, - {"[24~", KEY_F12}, - {"[25~", KEY_F13}, - {"[11;2~", KEY_F13}, - {"O2P", KEY_F13}, - {"[26~", KEY_F14}, - {"[12;2~", KEY_F14}, - {"O2Q", KEY_F14}, - {"[28~", KEY_F15}, - {"[13;2~", KEY_F15}, - {"O2R", KEY_F15}, - {"[29~", KEY_F16}, - {"[14;2~", KEY_F16}, - {"O2S", KEY_F16}, - {"[31~", KEY_F17}, - {"[15;2~", KEY_F17}, - {"[32~", KEY_F18}, - {"[17;2~", KEY_F18}, - {"[33~", KEY_F19}, - {"[18;2~", KEY_F19}, - {"[34~", KEY_F20}, - {"[19;2~", KEY_F20}, - {"[20;2~", KEY_F21}, - {"[23$", KEY_F21}, - {"[21;2~", KEY_F22}, - {"[24$", KEY_F22}, - {"[23;2~", KEY_F23}, - {"[11^", KEY_F23}, - {"[24;2~", KEY_F24}, - {"[12^", KEY_F24}, - - // Other keys. - {"[Z", KEY_BACK_TAB}, - {"OZ", KEY_BACK_TAB}, - {"[P", KEY_PAUSE}, - {"[G", KEY_NUMPAD_5}, -}; -#define numEscKeys (sizeof(escKeys) / sizeof(escKeys[0])) - -class Node -{ -public: - explicit Node(Node *parent = 0); - ~Node(); - - void add(const char *str, int code); - void dumpRules(std::vector *vec); - - int ch; - int code; - int offset; - Node *firstChild; - Node *lastChild; - Node *nextChild; -}; - -Node::Node(Node *parent) - : ch(0) - , code(-1) - , offset(0) - , firstChild(0) - , lastChild(0) - , nextChild(0) -{ - if (parent) { - if (parent->lastChild) - parent->lastChild->nextChild = this; - else - parent->firstChild = this; - parent->lastChild = this; - } -} - -Node::~Node() -{ - Node *child = firstChild; - Node *next; - while (child != 0) { - next = child->nextChild; - delete child; - child = next; - } -} - -void Node::add(const char *str, int code) -{ - int ch = str[0] & 0xFF; - Node *child = firstChild; - while (child != 0) { - if (child->ch == ch) - break; - child = child->nextChild; - } - if (!child) { - child = new Node(this); - child->ch = ch; - } - if (str[1] == '\0') { - // Leaf node at the end of a string. - child->code = code; - } else { - // Interior node with more children. - child->add(str + 1, code); - } -} - -void Node::dumpRules(std::vector *vec) -{ - Node *child; - - // First pass: Output the recognizers for this level. - offset = vec->size(); - child = firstChild; - while (child != 0) { - if (child->firstChild) { - // Interior nodes need 3 bytes for the character and offset. - vec->push_back((uint8_t)(child->ch | 0x80)); - vec->push_back(0); - vec->push_back(0); - } else { - // Leaf nodes need 2 bytes for the character and code. - vec->push_back((uint8_t)(child->ch)); - vec->push_back((uint8_t)(child->code)); - if (child->code > 255) - printf("Code 0x%X exceeds 255 - need to change table format\n", child->code); - } - child = child->nextChild; - } - vec->push_back(0); // Terminate this level. - - // Second pass: Output the recognizers for the child levels. - child = firstChild; - while (child != 0) { - if (child->firstChild) - child->dumpRules(vec); - child = child->nextChild; - } - - // Third pass: Back-patch the links to the child recognizers. - int posn = offset; - child = firstChild; - while (child != 0) { - if (child->firstChild) { - int value = child->offset; - (*vec)[posn + 1] = (uint8_t)value; - (*vec)[posn + 2] = (uint8_t)(value >> 8); - posn += 3; - } else { - posn += 2; - } - child = child->nextChild; - } -} - -int main(int argc, char *argv[]) -{ - Node *root = new Node(); - for (unsigned index = 0; index < numEscKeys; ++index) - root->add(escKeys[index].sequence, escKeys[index].code); - std::vector vec; - root->dumpRules(&vec); - printf("static uint8_t const keymap[%d] PROGMEM = {\n", (int)vec.size()); - for (unsigned index = 0; index < vec.size(); ++index) { - if ((index % 12) == 0) - printf(" "); - printf("0x%02X", (int)(vec[index])); - if ((index % 12) == 11) - printf(",\n"); - else - printf(", "); - } - printf("};\n"); - delete root; - return 0; -} diff --git a/gen/genlookup.c b/gen/genlookup.c deleted file mode 100644 index dad4c91e..00000000 --- a/gen/genlookup.c +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -// Utility for generating the button mapping table in LCD.cpp. - -#include - -#define LCD_BUTTON_NONE 0 -#define LCD_BUTTON_LEFT 1 -#define LCD_BUTTON_RIGHT 2 -#define LCD_BUTTON_UP 3 -#define LCD_BUTTON_DOWN 4 -#define LCD_BUTTON_SELECT 5 - -#define LCD_BUTTON_VALUE_GAP 10 -#define LCD_BUTTON_RIGHT_VALUE 0 -#define LCD_BUTTON_UP_VALUE 145 -#define LCD_BUTTON_DOWN_VALUE 329 -#define LCD_BUTTON_LEFT_VALUE 505 -#define LCD_BUTTON_SELECT_VALUE 741 - -int main(int argc, char *argv[]) -{ - char rawTest[1024]; - int value, value2, value3, bits; - char button; - - // Determine the actual values for each of the 1024 inputs. - for (value = 0; value < 1024; ++value) { - if (value < (LCD_BUTTON_RIGHT_VALUE + LCD_BUTTON_VALUE_GAP)) - button = LCD_BUTTON_RIGHT; - else if (value >= (LCD_BUTTON_UP_VALUE - LCD_BUTTON_VALUE_GAP) && - value <= (LCD_BUTTON_UP_VALUE + LCD_BUTTON_VALUE_GAP)) - button = LCD_BUTTON_UP; - else if (value >= (LCD_BUTTON_DOWN_VALUE - LCD_BUTTON_VALUE_GAP) && - value <= (LCD_BUTTON_DOWN_VALUE + LCD_BUTTON_VALUE_GAP)) - button = LCD_BUTTON_DOWN; - else if (value >= (LCD_BUTTON_LEFT_VALUE - LCD_BUTTON_VALUE_GAP) && - value <= (LCD_BUTTON_LEFT_VALUE + LCD_BUTTON_VALUE_GAP)) - button = LCD_BUTTON_LEFT; - else if (value >= (LCD_BUTTON_SELECT_VALUE - LCD_BUTTON_VALUE_GAP) && - value <= (LCD_BUTTON_SELECT_VALUE + LCD_BUTTON_VALUE_GAP)) - button = LCD_BUTTON_SELECT; - else - button = LCD_BUTTON_NONE; - rawTest[value] = button; - } - - // Dump the accuracy of different bit truncations. - for (bits = 4; bits < 10; ++bits) { - int count = 0; - for (value = 0; value < 1024; ++value) { - value2 = value & (((1 << bits) - 1) << (10 - bits)); - if (rawTest[value] == rawTest[value2]) - ++count; - } - printf("bits = %d, accuracy = %g%%\n", bits, 100.0 * count / 1024.0); - } - printf("\n"); - - // Dump the button mapping table for the selected bit count. - bits = 5; - printf("static uint8_t const buttonMappings[] PROGMEM = {\n"); - for (value2 = 0; value2 < (1 << bits); ++value2) { - value = value2 << (10 - bits); - value3 = value + (1 << (10 - bits)) - 1; - button = 0; - while (!button && value <= value3) { - button = rawTest[value]; - ++value; - } - if ((value2 & 0x0F) != 0) - printf(", "); - else - printf(" "); - printf("%d", button); - if ((value2 & 0x0F) == 0x0F) { - if (value2 < ((1 << bits - 1))) - printf(",\n"); - else - printf("\n"); - } - } - printf("};\n"); - printf("#define mapButton(value) (pgm_read_byte(&(buttonMappings[(value) >> %d])))\n", 10 - bits); - - return 0; -} diff --git a/gen/genwcwidth.c b/gen/genwcwidth.c deleted file mode 100644 index 6dee23ca..00000000 --- a/gen/genwcwidth.c +++ /dev/null @@ -1,235 +0,0 @@ -/* - * Copyright (C) 2016 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -// Generates the Terminal::isWideCharacter() function from the data at: -// http://www.unicode.org/Public/UCD/latest/ucd/EastAsianWidth.txt -// http://www.unicode.org/reports/tr11/ - -#include -#include -#include - -#define MAX_UNICODE 0x10FFFF -#define NUM_UNICODE (MAX_UNICODE + 1) - -static unsigned char *masks; - -static void mark_range(long code1, long code2) -{ - while (code1 <= code2) { - if (code1 > MAX_UNICODE) - break; - masks[code1 / 8] |= (1 << (code1 % 8)); - ++code1; - } -} - -static void unmark_range(long code1, long code2) -{ - while (code1 <= code2) { - if (code1 > MAX_UNICODE) - break; - masks[code1 / 8] &= ~(1 << (code1 % 8)); - ++code1; - } -} - -static void dump_ranges(void) -{ - long code; - int index, sum; - unsigned char *prevptr = 0; - unsigned char *ptr; - int dotdot = 0; - for (code = 0; code <= MAX_UNICODE; code += 0x100) { - ptr = masks + (code / 8); - sum = 0; - for (index = 0; index < 32; ++index) - sum += ptr[index]; - if (sum == 0 || sum == (0xFF * 32)) { - if (prevptr && !memcmp(ptr, prevptr, 32)) { - if (!dotdot) { - dotdot = 1; - printf("..\n"); - } - continue; - } - } - dotdot = 0; - printf("%06lX: ", code); - for (index = 0; index < 32; ++index) - printf("%02X", ptr[index]); - printf("\n"); - prevptr = ptr; - } - printf("\n"); -} - -static void print_lookup_table(const char *name, long first, long last) -{ - long index, size; - unsigned char *ptr = masks + first / 8; - size = (last - first + 1) / 8; - printf(" static unsigned char const %s[%ld] PROGMEM = {\n", name, size); - for (index = 0; index < size; ++index) { - if ((index % 8) == 0) - printf(" "); - printf("0x%02X", ptr[index]); - if (index < (size - 1)) { - if ((index % 8) == 7) - printf(",\n"); - else - printf(", "); - } else { - printf("\n"); - } - } - printf(" };\n"); -} - -static void recognizer(void) -{ - long code; - int first = 1; - - printf("bool Terminal::isWideCharacter(long code)\n{\n"); - printf(" // This function was automatically generated by genwcwidth.c\n"); - print_lookup_table("range3000", 0x3000, 0x30FF); - print_lookup_table("rangeFE00", 0xFE00, 0xFFFF); - printf(" unsigned c;\n"); - - // Bail out early for Latin character sets. - printf(" if (code < 0x2300) {\n"); - printf(" return false;\n"); - - // Densely populated ranges. - printf(" } else if (code >= 0x3000 && code <= 0x30FF) {\n"); - printf(" c = (unsigned)(code - 0x3000);\n"); - printf(" return (pgm_read_byte(range3000 + (c / 8)) & (1 << (c %% 8))) != 0;\n"); - printf(" } else if (code >= 0xFE00 && code <= 0xFFFF) {\n"); - printf(" c = (unsigned)(code - 0xFE00);\n"); - printf(" return (pgm_read_byte(rangeFE00 + (c / 8)) & (1 << (c %% 8))) != 0;\n"); - - // Deal with the main wide character ranges. - printf(" } else if (code >= 0x3400 && code <= 0x4DBF) {\n"); - printf(" return true;\n"); - printf(" } else if (code >= 0x4E00 && code <= 0x9FFF) {\n"); - printf(" return true;\n"); - printf(" } else if (code >= 0xF900 && code <= 0xFAFF) {\n"); - printf(" return true;\n"); - printf(" } else if (code >= 0x20000 && code <= 0x2FFFD) {\n"); - printf(" return true;\n"); - printf(" } else if (code >= 0x30000 && code <= 0x3FFFD) {\n"); - printf(" return true;\n"); - printf(" } else if ("); - - // Deal with the left-overs. - unmark_range(0x3000, 0x30FF); - unmark_range(0xFE00, 0xFFFF); - for (code = 0; code <= MAX_UNICODE; ++code) { - if (masks[code / 8] & (1 << (code % 8))) { - if (!first) - printf(" ||\n "); - else - first = 0; - printf("code == 0x%04lX", code); - } - } - printf(") {\n"); - printf(" return true;\n"); - printf(" }\n"); - - printf(" return false;\n"); - printf("}\n"); -} - -int main(int argc, char *argv[]) -{ - FILE *file; - char buffer[BUFSIZ]; - - // Allocate memory for the "is this a wide character?" mask array. - masks = calloc(NUM_UNICODE / 8, sizeof(unsigned char)); - if (!masks) { - fprintf(stderr, "out of memory\n"); - return 1; - } - - // Load the contents of "EastAsianWidth.txt". - if (argc < 2) { - fprintf(stderr, "Usage: %s EastAsianWidth.txt\n", argv[0]); - return 1; - } - if ((file = fopen(argv[1], "r")) == NULL) { - perror(argv[1]); - return 1; - } - while (fgets(buffer, sizeof(buffer), file)) { - if ((buffer[0] >= '0' && buffer[0] <= '9') || - (buffer[0] >= 'A' && buffer[0] <= 'F')) { - long code1 = 0; - long code2 = 0; - char *endptr = NULL; - code1 = strtol(buffer, &endptr, 16); - if (endptr[0] == '.' && endptr[1] == '.') { - endptr += 2; - code2 = strtol(buffer, &endptr, 16); - } else { - code2 = code1; - } - if (endptr[0] == ';') { - // Recognise 'W' and 'F' as wide characters. It is possible - // that 'A' (ambiguous) characters may also be wide but only - // in East Asian contexts, which we assume we're not for now. - if (endptr[1] == 'W' || endptr[1] == 'F') { - mark_range(code1, code2); - } - } - } - } - fclose(file); - - // Some special ranges that are implicitly all-wide even if the - // code points aren't currently allocated by the Unicode standard. - mark_range(0x3400, 0x4DBF); - mark_range(0x4E00, 0x9FFF); - mark_range(0xF900, 0xFAFF); - mark_range(0x20000, 0x2FFFD); - mark_range(0x30000, 0x3FFFD); - - // Dump the ranges. - dump_ranges(); - - // Unmark the special ranges to make it easier to find the left-overs. - unmark_range(0x3400, 0x4DBF); - unmark_range(0x4E00, 0x9FFF); - unmark_range(0xF900, 0xFAFF); - unmark_range(0x20000, 0x2FFFD); - unmark_range(0x30000, 0x3FFFD); - - // Create the recognition tree. - recognizer(); - - // Clean up and exit. - free(masks); - return 0; -} diff --git a/libraries/BlinkLED/BlinkLED.cpp b/libraries/BlinkLED/BlinkLED.cpp deleted file mode 100644 index 85ca93b6..00000000 --- a/libraries/BlinkLED/BlinkLED.cpp +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#include "BlinkLED.h" -#if defined(ARDUINO) && ARDUINO >= 100 -#include -#else -#include -#endif - -/** - * \class BlinkLED BlinkLED.h - * \brief Blink a LED on a digital output pin. - * - * BlinkLED simplies the process of blinking a LED by encapsulating the - * control logic into a single class. The following example strobes the - * status LED on D13 with a period of 70 milliseconds on, 930 milliseconds off - * (the LED is initially off): - * - * \code - * #include - * - * BlinkLED statusBlink(13, 70, 930); - * - * void setup() {} - * - * void loop() { - * statusBlink.loop(); - * } - * \endcode - * - * The current state() of the LED can be changed immediately by calling - * setState(). The blink rate can be modified with setBlinkRate(). - * And the blink cycle can be suspended and restarted with pause() - * and resume(). - */ - -/** - * \brief Initialize a blinking LED on the specified \a pin. - * - * The LED will blink with a rate defined by \a onTime and \a offTime - * (in milliseconds). Initially the LED's state is given by \a initialState, - * where true means initially on and false means initially off. - */ -BlinkLED::BlinkLED(uint8_t pin, unsigned long onTime, unsigned long offTime, bool initialState) - : _pin(pin) - , _state(initialState) - , _paused(false) - , _onTime(onTime) - , _offTime(offTime) -{ - pinMode(pin, OUTPUT); - digitalWrite(pin, initialState ? HIGH : LOW); - _lastChange = millis(); -} - -/** - * Perform a single iteration of the blink loop for this LED. - */ -void BlinkLED::loop() -{ - if (_paused) - return; - unsigned long currentTime = millis(); - if (_state) { - if ((currentTime - _lastChange) >= _onTime) { - digitalWrite(_pin, LOW); - _lastChange += _onTime; - _state = false; - } - } else { - if ((currentTime - _lastChange) >= _offTime) { - digitalWrite(_pin, HIGH); - _lastChange += _offTime; - _state = true; - } - } -} - -/** - * \fn unsigned long BlinkLED::onTime() const - * \brief Returns the number of milliseconds the LED will be on. - * - * \sa offTime(), setBlinkRate() - */ - -/** - * \fn unsigned long BlinkLED::offTime() const - * \brief Returns the number of milliseconds the LED will be off. - * - * \sa onTime(), setBlinkRate() - */ - -/** - * \brief Sets the \a onTime and \a offTime (in milliseconds). - * - * The change takes effect immediately. If the current onTime() or - * offTime() has now expired, then the LED will immediately switch to - * the opposite state(). - * - * \sa onTime(), offTime() - */ -void BlinkLED::setBlinkRate(unsigned long onTime, unsigned long offTime) -{ - _onTime = onTime; - _offTime = offTime; -} - -/** - * \fn bool BlinkLED::state() const - * \brief Returns the current state of the LED; true is on, false is off. - * - * \sa setState() - */ - -/** - * \brief Sets the current \a state of the LED, where true is on, false is off. - * - * If the LED is already set to \a state, then it will complete its current - * cycle of onTime() or offTime(). Otherwise the LED is immediately set to - * \a state and a new cycle begins. - * - * \sa state() - */ - -void BlinkLED::setState(bool state) -{ - if (_state != state) { - digitalWrite(_pin, state ? HIGH : LOW); - _state = state; - _lastChange = millis(); - } -} - -/** - * \fn void BlinkLED::pause() - * \brief Pauses the LED blink cycle in its current state(). - * - * \sa resume(), isPaused() - */ - -/** - * \brief Resumes the LED blink cycle after a pause(). - * - * The LED will complete its current onTime() or offTime() and then - * will switch to the opposite state(). If onTime() or offTime() has - * already expired, then the LED will immediately switch state. - * - * \sa pause(), isPaused() - */ -void BlinkLED::resume() -{ - if (_paused) { - _paused = false; - unsigned long currentTime = millis(); - if (_state) { - if ((currentTime - _lastChange) >= _onTime) { - digitalWrite(_pin, LOW); - _lastChange = currentTime; - _state = false; - } - } else { - if ((currentTime - _lastChange) >= _offTime) { - digitalWrite(_pin, HIGH); - _lastChange = currentTime; - _state = true; - } - } - } -} - -/** - * \fn bool BlinkLED::isPaused() - * \brief Returns true if the LED blink cycle is paused; false otherwise. - * - * \sa pause(), resume() - */ diff --git a/libraries/BlinkLED/BlinkLED.h b/libraries/BlinkLED/BlinkLED.h deleted file mode 100644 index da5b6dfc..00000000 --- a/libraries/BlinkLED/BlinkLED.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#ifndef BlinkLED_h -#define BlinkLED_h - -#include - -class BlinkLED -{ -public: - BlinkLED(uint8_t pin, unsigned long onTime, unsigned long offTime, bool initialState = false); - - void loop(); - - unsigned long onTime() const { return _onTime; } - unsigned long offTime() const { return _offTime; } - void setBlinkRate(unsigned long onTime, unsigned long offTime); - - bool state() const { return _state; } - void setState(bool state); - - void pause() { _paused = true; } - void resume(); - bool isPaused() const { return _paused; } - -private: - uint8_t _pin; - bool _state; - bool _paused; - unsigned long _onTime; - unsigned long _offTime; - unsigned long _lastChange; -}; - -#endif diff --git a/libraries/BlinkLED/Charlieplex.cpp b/libraries/BlinkLED/Charlieplex.cpp deleted file mode 100644 index e7ae8000..00000000 --- a/libraries/BlinkLED/Charlieplex.cpp +++ /dev/null @@ -1,350 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#include "Charlieplex.h" -#if defined(ARDUINO) && ARDUINO >= 100 -#include -#else -#include -#endif -#include -#include - -/** - * \class Charlieplex Charlieplex.h - * \brief Manage an array of LED's in a charlieplexed arrangement. - * - * Charlieplexing - * is a technique for multiplexing large numbers of LED's on a small - * number of microcontroller output pins. LED's are arranged in - * complementary pairs; the simplest being for two output pins: - * - * \image html charlieplex2pin.png - * - * When Pin1 is 1 and Pin2 is 0, LED1 will be lit. When Pin1 is 0 and - * Pin2 is 1, then LED2 will be lit. The technique extends to 3 pins - * as follows: - * - * \image html charlieplex3pin.png - * - * In this case, LED5 is lit when Pin1 is 1, Pin3 is 0, and Pin2 is set - * to a high-impedance input to "disconnect" it. - * - * Charlieplex presents a simple array of led() values that indicate whether - * each LED is on, off, or in an intermediate PWM state (if setPwmLed() - * is used). The application must call loop() or refresh() on a regular - * basis to ensure that the multiplexed display is kept up to date. - * The following example drives 6 LED's connected to the output pins - * D9, D10, and D11: - * - * \dontinclude BlinkLED/examples/Charlieplex/Charlieplex.ino - * \skip #include - * \until charlie.loop - * \until } - * - * The following diagram extends the circuit for 4 output pins and 12 LED's: - * - * \image html charlieplex4pin.png - * - * The following diagram extends the circuit for 5 output pins and 20 LED's: - * - * \image html charlieplex5pin.png - * - * Circuits for higher numbers of LED's get increasingly complex. For those - * cases it can be easier to use traditional multiplexing matrix arrangements - * and shift registers. The DMD class does this for a specific kind of - * large dot matrix display. Otherwise, use the following pseudocode to - * determine how to connect the LED's for higher numbers of pins: - * - * \code - * n = 1 - * for Pass = 1 to NumPins-1: - * for Pin = 1 to NumPins-Pass: - * LED[n] is connected between Pin (anode) and Pin+Pass (cathode) - * LED[n+1] is connected between Pin+Pass (anode) and Pin (cathode) - * n = n + 2 - * \endcode - * - * Note: while the above circuit diagrams and psuedocode use 1-based - * numbering for LED's, Charlieplex uses 0-based numbering in the led(), - * setLed(), pwmLed(), and setPwmLed() functions. - * - * It isn't necessary to wire up all LED's. If you only need 10 LED's, - * then use the 4-output circuit and omit LED11 and LED12. Charlieplex - * only drives LED's that are lit; LED's that are unlit or unused will - * be skipped during the refresh scan. The maximum number of LED's that - * that can be driven by a specific number of pins is given by the - * following table: - * - * - * - * - * - * - * - * - * - * - * - * - * - *
Number of PinsNumber of LED's
22
36
412
520
630
742
856
972
1090
nn * (n - 1)
- */ - -/** - * \brief Constructs a new charliexplexing array where the output pins - * are specified by the \a numPins entries in \a pins. - * - * Note: \a numPins must be 2 or greater for correct operation. - * - * \sa count(), setLed() - */ -Charlieplex::Charlieplex(const uint8_t *pins, uint8_t numPins) - : _count(((int)numPins) * (numPins - 1)) - , _lastTime(micros()) - , _currentIndex(-1) - , _pwmPhase(0xC0) -{ - // Determine the best hold time for 50 Hz refresh when all LED's - // are lit. Divide it again by 4 (to get 200 Hz) to manage the - // simulated PWM in refresh(). - _holdTime = 20000 / _count / 4; - - // Allocate the pin arrays and populate them. Doing this now makes - // refresh() more efficient later, at the expense of some memory. - _pins1 = (uint8_t *)malloc(_count); - _pins2 = (uint8_t *)malloc(_count); - int n = 0; - for (uint8_t pass = 1; pass < numPins; ++pass) { - for (uint8_t pin = 0; pin < (numPins - pass); ++pin) { - _pins1[n] = _pins2[n + 1] = pins[pin]; - _pins2[n] = _pins1[n + 1] = pins[pin + pass]; - n += 2; - } - } - - // Allocate space for the LED value array and zero it. - _values = (uint8_t *)malloc(_count); - memset(_values, 0, _count); - - // Start with all pins configured as floating inputs (all LED's off). - for (uint8_t pin = 0; pin < numPins; ++pin) { - digitalWrite(pins[pin], LOW); - pinMode(pins[pin], INPUT); - } -} - -/** - * \brief Destroys this charlieplexed array. - */ -Charlieplex::~Charlieplex() -{ - free(_pins1); - free(_pins2); - free(_values); -} - -/** - * \fn int Charlieplex::count() const - * \brief Returns the number of LED's in this charlieplexed array based - * on the number of pins. - * - * - * - * - * - * - * - * - * - * - * - * - * - *
Number of PinsNumber of LED's
22
36
412
520
630
742
856
972
1090
nn * (n - 1)
- * - * \sa led() - */ - -/** - * \fn bool Charlieplex::led(int index) const - * \brief Returns the value of the LED at \a index in the charplexed array; - * true if lit; false if not lit. - * - * If the LED is displaying a PWM value, then this function will return - * true for any non-zero PWM value. - * - * \sa setLed(), pwmLed() - */ - -/** - * \fn void Charlieplex::setLed(int index, bool value) - * \brief Sets the \a value of the LED at \a index in the charliplexed array. - * - * The brightness of the LED will be proportional to the number of LED's - * that are currently lit, as the holdTime() refresh rate will cause the - * LED to appear to dim; the more LED's that are lit the less overall time - * each individual LED is held on. For best results, only a single LED should - * be lit at once or higher-brightness LED's should be used. - * - * \sa led(), setPwmLed() - */ - -/** - * \fn uint8_t Charlieplex::pwmLed(int index) const - * \brief Returns the PWM value of the LED at \a index in the charplexed array; - * between 0 and 255. - * - * \sa setPwmLed(), led() - */ - -/** - * \fn void Charlieplex::setPwmLed(int index, uint8_t value) - * \brief Sets the PWM \a value of the LED at \a index in the charliplexed - * array; between 0 and 255. - * - * If this function is used, then it is assumed that the output pins are - * capable of PWM output. - * - * The PWM-specified brightness of the LED will also be affected to the - * number of LED's that are currently lit, as the holdTime() refresh rate - * will cause the LED to appear to dim; the more LED's that are lit the - * less overall time each individual LED is held on. For best results, - * only a single LED should be lit at once or higher-brightness LED's - * should be used. - * - * \sa pwmLed(), setLed() - */ - -/** - * \fn unsigned long Charlieplex::holdTime() const - * \brief Returns the number of microseconds that each LED should be - * held on for before moving onto the next in loop(). - * - * The default value is calculated so that all LED's can be refreshed - * with a rate of at least 200 Hz, which is necessary for handling PWM - * output on multiple LED's. The less LED's that are lit at once, - * the faster the display will refresh. - * - * \sa setHoldTime(), loop() - */ - -/** - * \fn void Charlieplex::setHoldTime(unsigned long us) - * \brief Sets the number of microseconds that each LED should be - * held on for before moving onto the next in loop() to \a us. - * - * \sa holdTime(), loop() - */ - -/** - * \brief Runs the multiplexing loop, to display the LED states on - * the charlieplexed array. - * - * If holdTime() microseconds have elapsed since the last call to loop(), - * then the current LED is turned off and the next LED that needs to be - * lit is turned on. - * - * LED's that do not need to be lit are skipped. The total time for a - * single pass through all lit LED's may be very short if only a few - * LED's are lit at once. If all LED's are lit, then the total time for - * a single pass will be count() * holdTime() microseconds. - * - * If the application is using timer interrupts to drive the multiplexing - * process, then use refresh() instead of loop(). - * - * \sa led(), pwmLed(), holdTime(), refresh() - */ -void Charlieplex::loop() -{ - unsigned long us = micros(); - if ((us - _lastTime) >= _holdTime) { - _lastTime = us; - refresh(); - } -} - -/** - * \brief Refreshes the charlieplexed array by advancing to the next LED - * that needs to be lit. - * - * This function is intended to be called from a timer interrupt service - * routine to advance the multiplexing state without the main application - * having to explicitly call loop(). - * - * \sa loop() - */ -void Charlieplex::refresh() -{ - // Find the next LED to be lit. - int prevIndex = _currentIndex; - int limit = _count; - while (limit >= 0) { - _currentIndex = (_currentIndex + 1) % _count; - if (_values[_currentIndex] != 0) - break; - --limit; - } - if (limit < 0) { - // No LED's are lit. Turn off the previous LED and exit. - if (prevIndex != -1) { - digitalWrite(_pins1[prevIndex], LOW); - digitalWrite(_pins2[prevIndex], LOW); - pinMode(_pins1[prevIndex], INPUT); - pinMode(_pins2[prevIndex], INPUT); - } - _currentIndex = -1; - return; - } - - // Light the current LED. - uint8_t value = _values[_currentIndex]; - uint8_t pin1 = _pins1[_currentIndex]; - uint8_t pin2 = _pins2[_currentIndex]; - _pwmPhase += 0x40; - if (prevIndex != _currentIndex) { - // Turn off the previous LED. - if (prevIndex != -1) { - digitalWrite(_pins1[prevIndex], LOW); - digitalWrite(_pins2[prevIndex], LOW); - pinMode(_pins1[prevIndex], INPUT); - pinMode(_pins2[prevIndex], INPUT); - } - - // We simulate PWM using a phase counter because analogWrite() - // combined with holdTime() causes too much flickering if more - // than one LED is lit. This reduces the PWM resolution to 1 in 4. - pinMode(pin1, OUTPUT); - pinMode(pin2, OUTPUT); - if (value > _pwmPhase) - digitalWrite(pin1, HIGH); - else - digitalWrite(pin1, LOW); - } else { - // Same LED as previous. Since there is only a single LED - // that is lit, we can use analogWrite() to set the PWM state. - if (value == 255) - digitalWrite(pin1, HIGH); - else - analogWrite(pin1, value); - } -} diff --git a/libraries/BlinkLED/Charlieplex.h b/libraries/BlinkLED/Charlieplex.h deleted file mode 100644 index b3fbe881..00000000 --- a/libraries/BlinkLED/Charlieplex.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#ifndef Charlieplex_h -#define Charlieplex_h - -#include - -class Charlieplex -{ -public: - Charlieplex(const uint8_t *pins, uint8_t numPins); - ~Charlieplex(); - - int count() const { return _count; } - - bool led(int index) const { return _values[index] != 0; } - void setLed(int index, bool value) { _values[index] = (value ? 255 : 0); } - - uint8_t pwmLed(int index) const { return _values[index]; } - void setPwmLed(int index, uint8_t value) { _values[index] = value; } - - unsigned long holdTime() const { return _holdTime; } - void setHoldTime(unsigned long us) { _holdTime = us; } - - void loop(); - void refresh(); - -private: - int _count; - uint8_t *_pins1; - uint8_t *_pins2; - uint8_t *_values; - unsigned long _holdTime; - unsigned long _lastTime; - int _currentIndex; - uint8_t _pwmPhase; -}; - -#endif diff --git a/libraries/BlinkLED/ChaseLEDs.cpp b/libraries/BlinkLED/ChaseLEDs.cpp deleted file mode 100644 index 4a7bc0b4..00000000 --- a/libraries/BlinkLED/ChaseLEDs.cpp +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#include "ChaseLEDs.h" -#if defined(ARDUINO) && ARDUINO >= 100 -#include -#else -#include -#endif - -/** - * \class ChaseLEDs ChaseLEDs.h - * \brief Chase LED's on output pins in a defined sequence. - * - * The following example performs a LED chase over the 6 PWM outputs - * on the Arduino Uno, with a 150 millisecond delay between each LED: - * - * \code - * uint8_t pins[] = {3, 5, 6, 9, 10, 11}; - * ChaseLEDs chaser(pins, sizeof(pins), 150); - * - * void loop() { - * chaser.loop(); - * } - * \endcode - * - * After pin 11 is lit, the pattern will repeat at pin 3. To cause the - * chase to oscillate back and forth instead, extend the sequence as follows: - * - * \code - * uint8_t pins[] = {3, 5, 6, 9, 10, 11, 10, 9, 6, 5}; - * ChaseLEDs chaser(pins, sizeof(pins), 150); - * \endcode - * - * See the \ref blink_cylon "Cylon" example for more information on - * how to use the ChaseLEDs class in a practical application. - */ - -/** - * \brief Initializes the LED chaser. - * - * The chase sequence consists of \a num pins, whose names are given by - * the \a pins array. Each LED is lit for \a advanceTime milliseconds - * before advancing to the next LED. - * - * This constructor configures all of the pins for output and sets their - * state to be LOW. The first LED will be lit when the program first - * calls loop(). - * - * \sa loop() - */ -ChaseLEDs::ChaseLEDs(const uint8_t *pins, int num, unsigned long advanceTime) - : _pins(pins) - , _numPins(num) - , _currentIndex(-1) - , _advanceTime(advanceTime) - , _lastChange(millis()) -{ - for (uint8_t index = 0; index < _numPins; ++index) { - pinMode(_pins[index], OUTPUT); - digitalWrite(_pins[index], LOW); - } -} - -/** - * Perform a single iteration of the control loop for this LED chaser. - */ -void ChaseLEDs::loop() -{ - if (_currentIndex >= 0) { - if ((millis() - _lastChange) >= _advanceTime) { - // Advance to the next LED in sequence. - _currentIndex = (_currentIndex + 1) % _numPins; - _lastChange += _advanceTime; - advance(previousPin(1), _pins[_currentIndex]); - } - } else { - // First time - light the first LED. - _currentIndex = 0; - _lastChange = millis(); - advance(previousPin(1), _pins[_currentIndex]); - } -} - -/** - * \fn unsigned long ChaseLEDs::advanceTime() const - * \brief Returns the number of milliseconds that each LED will be - * lit in the chase sequence. - * - * \sa setAdvanceTime(), advance() - */ - -/** - * \fn void ChaseLEDs::setAdvanceTime(unsigned long advanceTime) - * \brief Sets the number of milliseconds to advance between LED's to - * \a advanceTime. - * - * \sa advanceTime(), advance() - */ - -/** - * \brief Advances to the next LED in sequence, turning off \a prevPin, - * and turning on \a nextPin. - * - * The default implementation is equivalent to the following code: - * - * \code - * digitalWrite(prevPin, LOW); - * digitalWrite(nextPin, HIGH); - * \endcode - * - * This method may be overridden in subclasses to provide special effects. - * See the documentation for previousPin() for some example effects. - * - * \sa previousPin() - */ -void ChaseLEDs::advance(uint8_t prevPin, uint8_t nextPin) -{ - digitalWrite(prevPin, LOW); - digitalWrite(nextPin, HIGH); -} - -/** - * \fn uint8_t ChaseLEDs::previousPin(int n) const - * \brief Returns the pin that is \a n steps back in the sequence. - * - * If \a n is zero, then the current pin is returned; if \a n is 1, - * then the previous pin is returned; and so on. - * - * This function may be called by subclasses in their advance() method - * to manipulate pins that are further back in the chase sequence than - * the immediately previous pin. - * - * For example, the following code implements a LED chaser that lights - * two pins at a time: - * - * \code - * void DoubleChaser::advance(uint8_t prevPin, uint8_t nextPin) - * { - * digitalWrite(previousPin(2), LOW); - * digitalWrite(prevPin, HIGH); - * digitalWrite(nextPin, HIGH); - * } - * \endcode - * - * As another exmaple, the following code uses PWM outputs to fade out - * the previous pin rather than turn it off immediately: - * - * \code - * void FadingChaser::advance(uint8_t prevPin, uint8_t nextPin) - * { - * digitalWrite(previousPin(2), LOW); - * analogWrite(prevPin, 32); - * digitalWrite(nextPin, HIGH); - * } - * \endcode - * - * Note: it is possible to retrieve the \em following pin in sequence using - * previousPin(-1). This could be used to fade in the LED that follows - * \a nextPin. - * - * \sa advance() - */ diff --git a/libraries/BlinkLED/ChaseLEDs.h b/libraries/BlinkLED/ChaseLEDs.h deleted file mode 100644 index 49dfc2f4..00000000 --- a/libraries/BlinkLED/ChaseLEDs.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#ifndef ChaseLEDs_h -#define ChaseLEDs_h - -#include - -class ChaseLEDs -{ -public: - ChaseLEDs(const uint8_t *pins, int num, unsigned long advanceTime); - - void loop(); - - unsigned long advanceTime() const { return _advanceTime; } - void setAdvanceTime(unsigned long advanceTime) { _advanceTime = advanceTime; } - -protected: - virtual void advance(uint8_t prevPin, uint8_t nextPin); - uint8_t previousPin(int n) const - { return _pins[(_currentIndex + _numPins - n) % _numPins]; } - -private: - const uint8_t *_pins; - int _numPins; - int _currentIndex; - unsigned long _advanceTime; - unsigned long _lastChange; -}; - -#endif diff --git a/libraries/BlinkLED/examples/Blink/Blink.ino b/libraries/BlinkLED/examples/Blink/Blink.ino deleted file mode 100644 index 4784455c..00000000 --- a/libraries/BlinkLED/examples/Blink/Blink.ino +++ /dev/null @@ -1,16 +0,0 @@ -/* -Blink the status LED using the BlinkLED utility class. - -This example is placed into the public domain. -*/ - -#include - -BlinkLED statusBlink(13, 70, 930); - -void setup() {} - -void loop() { - statusBlink.loop(); -} - diff --git a/libraries/BlinkLED/examples/Charlieplex/Charlieplex.ino b/libraries/BlinkLED/examples/Charlieplex/Charlieplex.ino deleted file mode 100644 index fd0b9d21..00000000 --- a/libraries/BlinkLED/examples/Charlieplex/Charlieplex.ino +++ /dev/null @@ -1,16 +0,0 @@ -/* This example is placed into the public domain */ - -#include - -byte pins[3] = {9, 10, 11}; -Charlieplex charlie(pins, sizeof(pins)); - -void setup() { - charlie.setLed(0, true); // Turn on LED1 - charlie.setLed(3, true); // Turn on LED4 - charlie.setPwmLed(5, 64); // Set LED6 to one-quarter on -} - -void loop() { - charlie.loop(); -} diff --git a/libraries/BlinkLED/examples/Charlieplex/charlieplex2pin.fig b/libraries/BlinkLED/examples/Charlieplex/charlieplex2pin.fig deleted file mode 100644 index 2ae9b2ee..00000000 --- a/libraries/BlinkLED/examples/Charlieplex/charlieplex2pin.fig +++ /dev/null @@ -1,87 +0,0 @@ -#FIG 3.2 Produced by xfig version 3.2.5b -Landscape -Center -Metric -A4 -100.00 -Single --2 -1200 2 -6 3825 3105 4275 3195 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 3920 3150 3825 3150 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 4185 3150 4158 3110 4104 3190 4050 3110 3996 3190 3942 3110 - 3915 3150 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4275 3150 4180 3150 --6 -6 4410 3375 4635 3735 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 4500 3600 4545 3510 4455 3510 4500 3600 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4500 3600 4500 3735 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4445 3600 4555 3600 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4635 3555 4590 3600 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 4635 3600 4635 3555 4590 3555 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 4635 3510 4635 3465 4590 3465 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4635 3465 4590 3510 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4500 3375 4500 3510 --6 -6 3825 4005 4275 4095 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 3920 4050 3825 4050 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 4185 4050 4158 4010 4104 4090 4050 4010 3996 4090 3942 4010 - 3915 4050 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4275 4050 4180 4050 --6 -6 4455 3105 4545 3195 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 4500 3150 30 30 4500 3150 4500 3180 --6 -6 4455 4005 4545 4095 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 4500 4050 30 30 4500 4050 4500 4080 --6 -6 5310 3375 5535 3735 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 5400 3510 5445 3600 5355 3600 5400 3510 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5400 3510 5400 3375 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5345 3510 5455 3510 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5535 3555 5490 3510 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 5535 3510 5535 3555 5490 3555 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 5535 3600 5535 3645 5490 3645 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5535 3645 5490 3600 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5400 3735 5400 3600 --6 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 4230 3150 5400 3150 5400 3420 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 4500 3420 4500 3150 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 4275 4050 5400 4050 5400 3690 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 4500 3735 4500 4050 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 - 8 1 1.00 60.00 120.00 - 3870 3150 3600 3150 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 - 8 1 1.00 60.00 120.00 - 3825 4050 3600 4050 -4 0 0 50 -1 0 12 0.0000 4 135 480 5625 3645 LED2\001 -4 0 0 50 -1 0 12 0.0000 4 135 480 4725 3645 LED1\001 -4 0 0 50 -1 0 12 0.0000 4 135 375 3105 3195 Pin1\001 -4 0 0 50 -1 0 12 0.0000 4 135 375 3105 4095 Pin2\001 diff --git a/libraries/BlinkLED/examples/Charlieplex/charlieplex2pin.png b/libraries/BlinkLED/examples/Charlieplex/charlieplex2pin.png deleted file mode 100644 index 838b30a3..00000000 Binary files a/libraries/BlinkLED/examples/Charlieplex/charlieplex2pin.png and /dev/null differ diff --git a/libraries/BlinkLED/examples/Charlieplex/charlieplex3pin.fig b/libraries/BlinkLED/examples/Charlieplex/charlieplex3pin.fig deleted file mode 100644 index 716c2f9a..00000000 --- a/libraries/BlinkLED/examples/Charlieplex/charlieplex3pin.fig +++ /dev/null @@ -1,210 +0,0 @@ -#FIG 3.2 Produced by xfig version 3.2.5b -Landscape -Center -Metric -A4 -100.00 -Single --2 -1200 2 -6 3825 3105 4275 3195 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 3920 3150 3825 3150 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 4185 3150 4158 3110 4104 3190 4050 3110 3996 3190 3942 3110 - 3915 3150 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4275 3150 4180 3150 --6 -6 4410 3375 4635 3735 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 4500 3600 4545 3510 4455 3510 4500 3600 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4500 3600 4500 3735 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4445 3600 4555 3600 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4635 3555 4590 3600 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 4635 3600 4635 3555 4590 3555 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 4635 3510 4635 3465 4590 3465 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4635 3465 4590 3510 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4500 3375 4500 3510 --6 -6 3825 4005 4275 4095 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 3920 4050 3825 4050 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 4185 4050 4158 4010 4104 4090 4050 4010 3996 4090 3942 4010 - 3915 4050 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4275 4050 4180 4050 --6 -6 4455 3105 4545 3195 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 4500 3150 30 30 4500 3150 4500 3180 --6 -6 4455 4005 4545 4095 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 4500 4050 30 30 4500 4050 4500 4080 --6 -6 3825 4905 4275 4995 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 3920 4950 3825 4950 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 4185 4950 4158 4910 4104 4990 4050 4910 3996 4990 3942 4910 - 3915 4950 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4275 4950 4180 4950 --6 -6 4410 4275 4635 4635 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 4500 4500 4545 4410 4455 4410 4500 4500 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4500 4500 4500 4635 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4445 4500 4555 4500 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4635 4455 4590 4500 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 4635 4500 4635 4455 4590 4455 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 4635 4410 4635 4365 4590 4365 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4635 4365 4590 4410 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4500 4275 4500 4410 --6 -6 6210 3915 6435 4275 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 6300 4140 6345 4050 6255 4050 6300 4140 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6300 4140 6300 4275 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6245 4140 6355 4140 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6435 4095 6390 4140 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 6435 4140 6435 4095 6390 4095 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 6435 4050 6435 4005 6390 4005 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6435 4005 6390 4050 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6300 3915 6300 4050 --6 -6 5310 3375 5535 3735 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 5400 3510 5445 3600 5355 3600 5400 3510 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5400 3510 5400 3375 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5345 3510 5455 3510 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5535 3555 5490 3510 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 5535 3510 5535 3555 5490 3555 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 5535 3600 5535 3645 5490 3645 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5535 3645 5490 3600 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5400 3735 5400 3600 --6 -6 5310 4275 5535 4635 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 5400 4410 5445 4500 5355 4500 5400 4410 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5400 4410 5400 4275 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5345 4410 5455 4410 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5535 4455 5490 4410 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 5535 4410 5535 4455 5490 4455 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 5535 4500 5535 4545 5490 4545 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5535 4545 5490 4500 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5400 4635 5400 4500 --6 -6 7110 3915 7335 4275 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 7200 4050 7245 4140 7155 4140 7200 4050 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7200 4050 7200 3915 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7145 4050 7255 4050 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7335 4095 7290 4050 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 7335 4050 7335 4095 7290 4095 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 7335 4140 7335 4185 7290 4185 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7335 4185 7290 4140 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7200 4275 7200 4140 --6 -6 5355 3105 5445 3195 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 5400 3150 30 30 5400 3150 5400 3180 --6 -6 6255 3105 6345 3195 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 6300 3150 30 30 6300 3150 6300 3180 --6 -6 6255 4905 6345 4995 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 6300 4950 30 30 6300 4950 6300 4980 --6 -6 5355 4905 5445 4995 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 5400 4950 30 30 5400 4950 5400 4980 --6 -6 4455 4905 4545 4995 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 4500 4950 30 30 4500 4950 4500 4980 --6 -6 5355 4005 5445 4095 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 5400 4050 30 30 5400 4050 5400 4080 --6 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 4230 3150 5400 3150 5400 3420 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 4500 3420 4500 3150 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 4275 4050 5400 4050 5400 3690 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 4500 3735 4500 4050 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 - 8 1 1.00 60.00 120.00 - 3870 3150 3600 3150 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 - 8 1 1.00 60.00 120.00 - 3825 4050 3600 4050 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 - 8 1 1.00 60.00 120.00 - 3825 4950 3600 4950 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 4500 4050 4500 4320 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 4500 4590 4500 4950 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5400 4365 5400 4005 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 4275 4950 5400 4950 5400 4590 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 5400 3150 6300 3150 6300 3960 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 6255 3150 7200 3150 7200 3960 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 5355 4950 6300 4950 6300 4230 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 6300 4950 7200 4950 7200 4185 -4 0 0 50 -1 0 12 0.0000 4 135 480 5625 3645 LED2\001 -4 0 0 50 -1 0 12 0.0000 4 135 480 4725 3645 LED1\001 -4 0 0 50 -1 0 12 0.0000 4 135 375 3105 3195 Pin1\001 -4 0 0 50 -1 0 12 0.0000 4 135 375 3105 4095 Pin2\001 -4 0 0 50 -1 0 12 0.0000 4 135 375 3105 4995 Pin3\001 -4 0 0 50 -1 0 12 0.0000 4 135 480 4725 4545 LED3\001 -4 0 0 50 -1 0 12 0.0000 4 135 480 5625 4545 LED4\001 -4 0 0 50 -1 0 12 0.0000 4 135 480 7425 4140 LED6\001 -4 0 0 50 -1 0 12 0.0000 4 135 480 6525 4140 LED5\001 diff --git a/libraries/BlinkLED/examples/Charlieplex/charlieplex3pin.png b/libraries/BlinkLED/examples/Charlieplex/charlieplex3pin.png deleted file mode 100644 index 4b0391b3..00000000 Binary files a/libraries/BlinkLED/examples/Charlieplex/charlieplex3pin.png and /dev/null differ diff --git a/libraries/BlinkLED/examples/Charlieplex/charlieplex4pin.fig b/libraries/BlinkLED/examples/Charlieplex/charlieplex4pin.fig deleted file mode 100644 index dc21c38c..00000000 --- a/libraries/BlinkLED/examples/Charlieplex/charlieplex4pin.fig +++ /dev/null @@ -1,394 +0,0 @@ -#FIG 3.2 Produced by xfig version 3.2.5b -Landscape -Center -Metric -A4 -100.00 -Single --2 -1200 2 -5 1 0 1 0 7 50 -1 -1 0.000 0 0 0 0 6300.000 4950.000 6300 4905 6345 4950 6300 4995 -6 3825 3105 4275 3195 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 3920 3150 3825 3150 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 4185 3150 4158 3110 4104 3190 4050 3110 3996 3190 3942 3110 - 3915 3150 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4275 3150 4180 3150 --6 -6 4410 3375 4635 3735 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 4500 3600 4545 3510 4455 3510 4500 3600 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4500 3600 4500 3735 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4445 3600 4555 3600 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4635 3555 4590 3600 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 4635 3600 4635 3555 4590 3555 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 4635 3510 4635 3465 4590 3465 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4635 3465 4590 3510 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4500 3375 4500 3510 --6 -6 3825 4005 4275 4095 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 3920 4050 3825 4050 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 4185 4050 4158 4010 4104 4090 4050 4010 3996 4090 3942 4010 - 3915 4050 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4275 4050 4180 4050 --6 -6 4455 3105 4545 3195 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 4500 3150 30 30 4500 3150 4500 3180 --6 -6 4455 4005 4545 4095 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 4500 4050 30 30 4500 4050 4500 4080 --6 -6 3825 4905 4275 4995 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 3920 4950 3825 4950 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 4185 4950 4158 4910 4104 4990 4050 4910 3996 4990 3942 4910 - 3915 4950 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4275 4950 4180 4950 --6 -6 4410 4275 4635 4635 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 4500 4500 4545 4410 4455 4410 4500 4500 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4500 4500 4500 4635 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4445 4500 4555 4500 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4635 4455 4590 4500 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 4635 4500 4635 4455 4590 4455 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 4635 4410 4635 4365 4590 4365 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4635 4365 4590 4410 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4500 4275 4500 4410 --6 -6 5310 3375 5535 3735 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 5400 3510 5445 3600 5355 3600 5400 3510 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5400 3510 5400 3375 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5345 3510 5455 3510 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5535 3555 5490 3510 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 5535 3510 5535 3555 5490 3555 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 5535 3600 5535 3645 5490 3645 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5535 3645 5490 3600 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5400 3735 5400 3600 --6 -6 5310 4275 5535 4635 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 5400 4410 5445 4500 5355 4500 5400 4410 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5400 4410 5400 4275 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5345 4410 5455 4410 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5535 4455 5490 4410 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 5535 4410 5535 4455 5490 4455 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 5535 4500 5535 4545 5490 4545 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5535 4545 5490 4500 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5400 4635 5400 4500 --6 -6 5355 3105 5445 3195 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 5400 3150 30 30 5400 3150 5400 3180 --6 -6 5355 4905 5445 4995 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 5400 4950 30 30 5400 4950 5400 4980 --6 -6 4455 4905 4545 4995 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 4500 4950 30 30 4500 4950 4500 4980 --6 -6 5355 4005 5445 4095 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 5400 4050 30 30 5400 4050 5400 4080 --6 -6 6660 3915 6885 4275 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 6750 4140 6795 4050 6705 4050 6750 4140 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6750 4140 6750 4275 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6695 4140 6805 4140 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6885 4095 6840 4140 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 6885 4140 6885 4095 6840 4095 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 6885 4050 6885 4005 6840 4005 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6885 4005 6840 4050 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6750 3915 6750 4050 --6 -6 7560 3915 7785 4275 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 7650 4050 7695 4140 7605 4140 7650 4050 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7650 4050 7650 3915 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7595 4050 7705 4050 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7785 4095 7740 4050 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 7785 4050 7785 4095 7740 4095 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 7785 4140 7785 4185 7740 4185 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7785 4185 7740 4140 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7650 4275 7650 4140 --6 -6 6705 3105 6795 3195 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 6750 3150 30 30 6750 3150 6750 3180 --6 -6 6705 4905 6795 4995 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 6750 4950 30 30 6750 4950 6750 4980 --6 -6 4410 5175 4635 5535 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 4500 5400 4545 5310 4455 5310 4500 5400 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4500 5400 4500 5535 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4445 5400 4555 5400 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4635 5355 4590 5400 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 4635 5400 4635 5355 4590 5355 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 4635 5310 4635 5265 4590 5265 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4635 5265 4590 5310 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4500 5175 4500 5310 --6 -6 3825 5805 4275 5895 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 3920 5850 3825 5850 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 4185 5850 4158 5810 4104 5890 4050 5810 3996 5890 3942 5810 - 3915 5850 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4275 5850 4180 5850 --6 -6 4455 5805 4545 5895 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 4500 5850 30 30 4500 5850 4500 5880 --6 -6 5310 5175 5535 5535 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 5400 5310 5445 5400 5355 5400 5400 5310 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5400 5310 5400 5175 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5345 5310 5455 5310 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5535 5355 5490 5310 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 5535 5310 5535 5355 5490 5355 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 5535 5400 5535 5445 5490 5445 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5535 5445 5490 5400 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5400 5535 5400 5400 --6 -6 5355 5805 5445 5895 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 5400 5850 30 30 5400 5850 5400 5880 --6 -6 6255 5040 6345 5130 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 6300 5085 30 30 6300 5085 6300 5115 --6 -6 6210 5175 6435 5535 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 6300 5400 6345 5310 6255 5310 6300 5400 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6300 5400 6300 5535 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6245 5400 6355 5400 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6435 5355 6390 5400 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 6435 5400 6435 5355 6390 5355 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 6435 5310 6435 5265 6390 5265 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6435 5265 6390 5310 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6300 5175 6300 5310 --6 -6 6255 5805 6345 5895 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 6300 5850 30 30 6300 5850 6300 5880 --6 -6 7110 5175 7335 5535 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 7200 5310 7245 5400 7155 5400 7200 5310 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7200 5310 7200 5175 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7145 5310 7255 5310 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7335 5355 7290 5310 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 7335 5310 7335 5355 7290 5355 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 7335 5400 7335 5445 7290 5445 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7335 5445 7290 5400 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7200 5535 7200 5400 --6 -6 8460 4275 8685 4635 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 8550 4500 8595 4410 8505 4410 8550 4500 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 8550 4500 8550 4635 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 8495 4500 8605 4500 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 8685 4455 8640 4500 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 8685 4500 8685 4455 8640 4455 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 8685 4410 8685 4365 8640 4365 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 8685 4365 8640 4410 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 8550 4275 8550 4410 --6 -6 9360 4275 9585 4635 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 9450 4410 9495 4500 9405 4500 9450 4410 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 9450 4410 9450 4275 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 9395 4410 9505 4410 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 9585 4455 9540 4410 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 9585 4410 9585 4455 9540 4455 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 9585 4500 9585 4545 9540 4545 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 9585 4545 9540 4500 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 9450 4635 9450 4500 --6 -6 8505 3105 8595 3195 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 8550 3150 30 30 8550 3150 8550 3180 --6 -6 7605 3105 7695 3195 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 7650 3150 30 30 7650 3150 7650 3180 --6 -6 7155 5805 7245 5895 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 7200 5850 30 30 7200 5850 7200 5880 --6 -6 8505 5805 8595 5895 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 8550 5850 30 30 8550 5850 8550 5880 --6 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 4230 3150 5400 3150 5400 3420 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 4500 3420 4500 3150 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 4275 4050 5400 4050 5400 3690 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 4500 3735 4500 4050 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 - 8 1 1.00 60.00 120.00 - 3870 3150 3600 3150 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 - 8 1 1.00 60.00 120.00 - 3825 4050 3600 4050 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 - 8 1 1.00 60.00 120.00 - 3825 4950 3600 4950 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 4500 4050 4500 4320 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 4500 4590 4500 4950 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5400 4365 5400 4005 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 4275 4950 5400 4950 5400 4590 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 4500 4950 4500 5220 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5400 5490 5400 5850 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5400 5220 5400 4950 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5400 3150 6795 3150 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 6750 3150 6750 3960 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5400 4950 6750 4950 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 6750 4230 6750 4950 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 5400 4050 6300 4050 6300 4905 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 6705 3150 7650 3150 7650 3960 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 6750 4950 7650 4950 7650 4185 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 4230 5850 4500 5850 4500 5490 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 - 8 1 1.00 60.00 120.00 - 3825 5850 3600 5850 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 4500 5850 5400 5850 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 6300 5085 7200 5085 7200 5220 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 6300 4995 6300 5220 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 6300 5490 6300 5850 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 5400 5850 7200 5850 7200 5490 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 7605 3150 8550 3150 8550 4275 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 7200 5850 8550 5850 8550 4590 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 8505 3150 9450 3150 9450 4275 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 8550 5850 9450 5850 9450 4590 -4 0 0 50 -1 0 12 0.0000 4 135 480 5625 3645 LED2\001 -4 0 0 50 -1 0 12 0.0000 4 135 480 4725 3645 LED1\001 -4 0 0 50 -1 0 12 0.0000 4 135 375 3105 3195 Pin1\001 -4 0 0 50 -1 0 12 0.0000 4 135 375 3105 4095 Pin2\001 -4 0 0 50 -1 0 12 0.0000 4 135 375 3105 4995 Pin3\001 -4 0 0 50 -1 0 12 0.0000 4 135 480 4725 4545 LED3\001 -4 0 0 50 -1 0 12 0.0000 4 135 480 5625 4545 LED4\001 -4 0 0 50 -1 0 12 0.0000 4 135 480 7875 4140 LED8\001 -4 0 0 50 -1 0 12 0.0000 4 135 480 6975 4140 LED7\001 -4 0 0 50 -1 0 12 0.0000 4 135 375 3105 5895 Pin4\001 -4 0 0 50 -1 0 12 0.0000 4 135 480 5625 5445 LED6\001 -4 0 0 50 -1 0 12 0.0000 4 135 480 4725 5445 LED5\001 -4 0 0 50 -1 0 12 0.0000 4 135 480 6525 5445 LED9\001 -4 0 0 50 -1 0 12 0.0000 4 135 585 7425 5445 LED10\001 -4 0 0 50 -1 0 12 0.0000 4 135 585 8730 4500 LED11\001 -4 0 0 50 -1 0 12 0.0000 4 135 585 9630 4500 LED12\001 diff --git a/libraries/BlinkLED/examples/Charlieplex/charlieplex4pin.png b/libraries/BlinkLED/examples/Charlieplex/charlieplex4pin.png deleted file mode 100644 index 9bbaa264..00000000 Binary files a/libraries/BlinkLED/examples/Charlieplex/charlieplex4pin.png and /dev/null differ diff --git a/libraries/BlinkLED/examples/Charlieplex/charlieplex5pin.fig b/libraries/BlinkLED/examples/Charlieplex/charlieplex5pin.fig deleted file mode 100644 index c50adb63..00000000 --- a/libraries/BlinkLED/examples/Charlieplex/charlieplex5pin.fig +++ /dev/null @@ -1,649 +0,0 @@ -#FIG 3.2 Produced by xfig version 3.2.5b -Landscape -Center -Metric -A4 -100.00 -Single --2 -1200 2 -5 1 0 1 0 7 50 -1 -1 0.000 0 0 0 0 4500.000 4950.000 4500 4905 4545 4950 4500 4995 -5 1 0 1 0 7 50 -1 -1 0.000 0 0 0 0 4950.000 4500.000 4905 4500 4950 4455 4995 4500 -5 1 0 1 0 7 50 -1 -1 0.000 0 0 0 0 5850.000 4500.000 5805 4500 5850 4455 5895 4500 -5 1 0 1 0 7 50 -1 -1 0.000 0 0 0 0 6750.000 4500.000 6750 4455 6795 4500 6750 4545 -5 1 0 1 0 7 50 -1 -1 0.000 0 0 0 0 6750.000 4950.000 6750 4905 6795 4950 6750 4995 -5 1 0 1 0 7 50 -1 -1 0.000 0 0 0 0 6300.000 5625.000 6255 5625 6300 5580 6345 5625 -6 2025 3105 2475 3195 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2120 3150 2025 3150 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 2385 3150 2358 3110 2304 3190 2250 3110 2196 3190 2142 3110 - 2115 3150 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2475 3150 2380 3150 --6 -6 2610 3375 2835 3735 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 2700 3600 2745 3510 2655 3510 2700 3600 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2700 3600 2700 3735 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2645 3600 2755 3600 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2835 3555 2790 3600 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 2835 3600 2835 3555 2790 3555 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 2835 3510 2835 3465 2790 3465 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2835 3465 2790 3510 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2700 3375 2700 3510 --6 -6 2025 4005 2475 4095 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2120 4050 2025 4050 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 2385 4050 2358 4010 2304 4090 2250 4010 2196 4090 2142 4010 - 2115 4050 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2475 4050 2380 4050 --6 -6 2655 3105 2745 3195 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 2700 3150 30 30 2700 3150 2700 3180 --6 -6 2655 4005 2745 4095 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 2700 4050 30 30 2700 4050 2700 4080 --6 -6 2025 4905 2475 4995 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2120 4950 2025 4950 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 2385 4950 2358 4910 2304 4990 2250 4910 2196 4990 2142 4910 - 2115 4950 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2475 4950 2380 4950 --6 -6 2610 4275 2835 4635 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 2700 4500 2745 4410 2655 4410 2700 4500 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2700 4500 2700 4635 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2645 4500 2755 4500 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2835 4455 2790 4500 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 2835 4500 2835 4455 2790 4455 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 2835 4410 2835 4365 2790 4365 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2835 4365 2790 4410 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2700 4275 2700 4410 --6 -6 3510 3375 3735 3735 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 3600 3510 3645 3600 3555 3600 3600 3510 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 3600 3510 3600 3375 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 3545 3510 3655 3510 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 3735 3555 3690 3510 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 3735 3510 3735 3555 3690 3555 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 3735 3600 3735 3645 3690 3645 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 3735 3645 3690 3600 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 3600 3735 3600 3600 --6 -6 3510 4275 3735 4635 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 3600 4410 3645 4500 3555 4500 3600 4410 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 3600 4410 3600 4275 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 3545 4410 3655 4410 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 3735 4455 3690 4410 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 3735 4410 3735 4455 3690 4455 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 3735 4500 3735 4545 3690 4545 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 3735 4545 3690 4500 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 3600 4635 3600 4500 --6 -6 3555 3105 3645 3195 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 3600 3150 30 30 3600 3150 3600 3180 --6 -6 3555 4905 3645 4995 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 3600 4950 30 30 3600 4950 3600 4980 --6 -6 2655 4905 2745 4995 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 2700 4950 30 30 2700 4950 2700 4980 --6 -6 3555 4005 3645 4095 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 3600 4050 30 30 3600 4050 3600 4080 --6 -6 4860 3915 5085 4275 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 4950 4140 4995 4050 4905 4050 4950 4140 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4950 4140 4950 4275 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4895 4140 5005 4140 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5085 4095 5040 4140 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 5085 4140 5085 4095 5040 4095 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 5085 4050 5085 4005 5040 4005 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5085 4005 5040 4050 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4950 3915 4950 4050 --6 -6 5760 3915 5985 4275 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 5850 4050 5895 4140 5805 4140 5850 4050 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5850 4050 5850 3915 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5795 4050 5905 4050 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5985 4095 5940 4050 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 5985 4050 5985 4095 5940 4095 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 5985 4140 5985 4185 5940 4185 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5985 4185 5940 4140 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5850 4275 5850 4140 --6 -6 4905 3105 4995 3195 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 4950 3150 30 30 4950 3150 4950 3180 --6 -6 4905 4905 4995 4995 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 4950 4950 30 30 4950 4950 4950 4980 --6 -6 2610 5175 2835 5535 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 2700 5400 2745 5310 2655 5310 2700 5400 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2700 5400 2700 5535 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2645 5400 2755 5400 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2835 5355 2790 5400 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 2835 5400 2835 5355 2790 5355 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 2835 5310 2835 5265 2790 5265 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2835 5265 2790 5310 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2700 5175 2700 5310 --6 -6 2025 5805 2475 5895 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2120 5850 2025 5850 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 2385 5850 2358 5810 2304 5890 2250 5810 2196 5890 2142 5810 - 2115 5850 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2475 5850 2380 5850 --6 -6 2655 5805 2745 5895 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 2700 5850 30 30 2700 5850 2700 5880 --6 -6 3510 5175 3735 5535 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 3600 5310 3645 5400 3555 5400 3600 5310 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 3600 5310 3600 5175 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 3545 5310 3655 5310 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 3735 5355 3690 5310 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 3735 5310 3735 5355 3690 5355 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 3735 5400 3735 5445 3690 5445 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 3735 5445 3690 5400 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 3600 5535 3600 5400 --6 -6 3555 5805 3645 5895 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 3600 5850 30 30 3600 5850 3600 5880 --6 -6 4455 5040 4545 5130 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 4500 5085 30 30 4500 5085 4500 5115 --6 -6 4410 5175 4635 5535 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 4500 5400 4545 5310 4455 5310 4500 5400 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4500 5400 4500 5535 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4445 5400 4555 5400 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4635 5355 4590 5400 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 4635 5400 4635 5355 4590 5355 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 4635 5310 4635 5265 4590 5265 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4635 5265 4590 5310 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4500 5175 4500 5310 --6 -6 4455 5805 4545 5895 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 4500 5850 30 30 4500 5850 4500 5880 --6 -6 5310 5175 5535 5535 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 5400 5310 5445 5400 5355 5400 5400 5310 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5400 5310 5400 5175 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5345 5310 5455 5310 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5535 5355 5490 5310 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 5535 5310 5535 5355 5490 5355 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 5535 5400 5535 5445 5490 5445 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5535 5445 5490 5400 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5400 5535 5400 5400 --6 -6 2025 6705 2475 6795 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2120 6750 2025 6750 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 2385 6750 2358 6710 2304 6790 2250 6710 2196 6790 2142 6710 - 2115 6750 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2475 6750 2380 6750 --6 -6 2655 6705 2745 6795 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 2700 6750 30 30 2700 6750 2700 6780 --6 -6 2610 6075 2835 6435 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 2700 6300 2745 6210 2655 6210 2700 6300 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2700 6300 2700 6435 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2645 6300 2755 6300 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2835 6255 2790 6300 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 2835 6300 2835 6255 2790 6255 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 2835 6210 2835 6165 2790 6165 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2835 6165 2790 6210 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2700 6075 2700 6210 --6 -6 3510 6075 3735 6435 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 3600 6210 3645 6300 3555 6300 3600 6210 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 3600 6210 3600 6075 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 3545 6210 3655 6210 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 3735 6255 3690 6210 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 3735 6210 3735 6255 3690 6255 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 3735 6300 3735 6345 3690 6345 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 3735 6345 3690 6300 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 3600 6435 3600 6300 --6 -6 7110 5715 7335 6075 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 7200 5850 7245 5940 7155 5940 7200 5850 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7200 5850 7200 5715 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7145 5850 7255 5850 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7335 5895 7290 5850 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 7335 5850 7335 5895 7290 5895 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 7335 5940 7335 5985 7290 5985 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7335 5985 7290 5940 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7200 6075 7200 5940 --6 -6 6210 5715 6435 6075 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 6300 5940 6345 5850 6255 5850 6300 5940 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6300 5940 6300 6075 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6245 5940 6355 5940 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6435 5895 6390 5940 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 6435 5940 6435 5895 6390 5895 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 6435 5850 6435 5805 6390 5805 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6435 5805 6390 5850 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6300 5715 6300 5850 --6 -6 5805 4905 5895 4995 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 5850 4950 30 30 5850 4950 5850 4980 --6 -6 6255 4905 6345 4995 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 6300 4950 30 30 6300 4950 6300 4980 --6 -6 6255 6705 6345 6795 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 6300 6750 30 30 6300 6750 6300 6780 --6 -6 3555 6705 3645 6795 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 3600 6750 30 30 3600 6750 3600 6780 --6 -6 8010 5715 8235 6075 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 8100 5940 8145 5850 8055 5850 8100 5940 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 8100 5940 8100 6075 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 8045 5940 8155 5940 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 8235 5895 8190 5940 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 8235 5940 8235 5895 8190 5895 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 8235 5850 8235 5805 8190 5805 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 8235 5805 8190 5850 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 8100 5715 8100 5850 --6 -6 8910 5715 9135 6075 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 9000 5850 9045 5940 8955 5940 9000 5850 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 9000 5850 9000 5715 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 8945 5850 9055 5850 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 9135 5895 9090 5850 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 9135 5850 9135 5895 9090 5895 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 9135 5940 9135 5985 9090 5985 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 9135 5985 9090 5940 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 9000 6075 9000 5940 --6 -6 4455 4455 4545 4545 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 4500 4500 30 30 4500 4500 4500 4530 --6 -6 8055 4455 8145 4545 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 8100 4500 30 30 8100 4500 8100 4530 --6 -6 7155 6705 7245 6795 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 7200 6750 30 30 7200 6750 7200 6780 --6 -6 8055 6705 8145 6795 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 8100 6750 30 30 8100 6750 8100 6780 --6 -6 6660 3915 6885 4275 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 6750 4140 6795 4050 6705 4050 6750 4140 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6750 4140 6750 4275 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6695 4140 6805 4140 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6885 4095 6840 4140 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 6885 4140 6885 4095 6840 4095 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 6885 4050 6885 4005 6840 4005 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6885 4005 6840 4050 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6750 3915 6750 4050 --6 -6 7560 3915 7785 4275 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 7650 4050 7695 4140 7605 4140 7650 4050 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7650 4050 7650 3915 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7595 4050 7705 4050 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7785 4095 7740 4050 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 7785 4050 7785 4095 7740 4095 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 7785 4140 7785 4185 7740 4185 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7785 4185 7740 4140 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7650 4275 7650 4140 --6 -6 5355 5805 5445 5895 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 5400 5850 30 30 5400 5850 5400 5880 --6 -6 6705 4320 6795 4410 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 6750 4365 30 30 6750 4365 6750 4395 --6 -6 6705 3105 6795 3195 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 6750 3150 30 30 6750 3150 6750 3180 --6 -6 5805 3105 5895 3195 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 5850 3150 30 30 5850 3150 5850 3180 --6 -6 9810 4725 10035 5085 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 9900 4950 9945 4860 9855 4860 9900 4950 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 9900 4950 9900 5085 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 9845 4950 9955 4950 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10035 4905 9990 4950 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 10035 4950 10035 4905 9990 4905 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 10035 4860 10035 4815 9990 4815 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10035 4815 9990 4860 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 9900 4725 9900 4860 --6 -6 10710 4725 10935 5085 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 10800 4860 10845 4950 10755 4950 10800 4860 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10800 4860 10800 4725 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10745 4860 10855 4860 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10935 4905 10890 4860 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 10935 4860 10935 4905 10890 4905 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 10935 4950 10935 4995 10890 4995 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10935 4995 10890 4950 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10800 5085 10800 4950 --6 -6 9855 3105 9945 3195 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 9900 3150 30 30 9900 3150 9900 3180 --6 -6 8955 6705 9045 6795 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 9000 6750 30 30 9000 6750 9000 6780 --6 -6 9855 6705 9945 6795 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 9900 6750 30 30 9900 6750 9900 6780 --6 -6 7605 3105 7695 3195 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 7650 3150 30 30 7650 3150 7650 3180 --6 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 2430 3150 3600 3150 3600 3420 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 2700 3420 2700 3150 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 2475 4050 3600 4050 3600 3690 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 2700 3735 2700 4050 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 - 8 1 1.00 60.00 120.00 - 2070 3150 1800 3150 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 - 8 1 1.00 60.00 120.00 - 2025 4050 1800 4050 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 - 8 1 1.00 60.00 120.00 - 2025 4950 1800 4950 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 2700 4050 2700 4320 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 2700 4590 2700 4950 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 3600 4365 3600 4005 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 2475 4950 3600 4950 3600 4590 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 2700 4950 2700 5220 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 3600 5490 3600 5850 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 3600 5220 3600 4950 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 3600 3150 4995 3150 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 4950 3150 4950 3960 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 3600 4950 4950 4950 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 4950 4230 4950 4950 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 3600 4050 4500 4050 4500 4905 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 4905 3150 5850 3150 5850 3960 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 4950 4950 5850 4950 5850 4185 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 2430 5850 2700 5850 2700 5490 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 - 8 1 1.00 60.00 120.00 - 2025 5850 1800 5850 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 2700 5850 3600 5850 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 4500 5085 5400 5085 5400 5220 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 4500 4995 4500 5220 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 4500 5490 4500 5850 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 3600 5850 5400 5850 5400 5490 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 - 8 1 1.00 60.00 120.00 - 2025 6750 1800 6750 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 2430 6750 2700 6750 2700 6390 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 2700 6750 3600 6750 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 3600 6390 3600 6750 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 2700 5850 2700 6120 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 3600 5850 3600 6120 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 5760 4950 7200 4950 7200 5715 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 6300 5715 6300 4950 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 3600 6750 7200 6750 7200 6030 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 6300 6030 6300 6750 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 4500 4500 4905 4500 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 4995 4500 5805 4500 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 5895 4500 8100 4500 8100 5760 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 8055 4500 9000 4500 9000 5760 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 8100 6075 8100 6750 7155 6750 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 8010 6750 9000 6750 9000 6030 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 4 - 5400 5850 6075 5850 6075 5625 6255 5625 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 6345 5625 6750 5625 6750 4995 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 6750 4905 6750 4545 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 6750 4455 6750 4230 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 6750 4365 7650 4365 7650 4230 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 5850 3150 6750 3150 6750 3915 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 6750 3150 7650 3150 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 7650 3150 7650 3960 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 7605 3150 10800 3150 10800 4770 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 9900 4770 9900 3150 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 8955 6750 10800 6750 10800 5085 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 9900 5040 9900 6750 -4 0 0 50 -1 0 12 0.0000 4 135 480 3825 3645 LED2\001 -4 0 0 50 -1 0 12 0.0000 4 135 480 2925 3645 LED1\001 -4 0 0 50 -1 0 12 0.0000 4 135 375 1305 3195 Pin1\001 -4 0 0 50 -1 0 12 0.0000 4 135 375 1305 4095 Pin2\001 -4 0 0 50 -1 0 12 0.0000 4 135 375 1305 4995 Pin3\001 -4 0 0 50 -1 0 12 0.0000 4 135 480 2925 4545 LED3\001 -4 0 0 50 -1 0 12 0.0000 4 135 480 3825 4545 LED4\001 -4 0 0 50 -1 0 12 0.0000 4 135 585 6075 4140 LED10\001 -4 0 0 50 -1 0 12 0.0000 4 135 480 5175 4140 LED9\001 -4 0 0 50 -1 0 12 0.0000 4 135 375 1305 5895 Pin4\001 -4 0 0 50 -1 0 12 0.0000 4 135 480 3825 5445 LED6\001 -4 0 0 50 -1 0 12 0.0000 4 135 480 2925 5445 LED5\001 -4 0 0 50 -1 0 12 0.0000 4 135 585 4725 5445 LED11\001 -4 0 0 50 -1 0 12 0.0000 4 135 585 5625 5445 LED12\001 -4 0 0 50 -1 0 12 0.0000 4 135 375 1305 6795 Pin5\001 -4 0 0 50 -1 0 12 0.0000 4 135 480 2925 6345 LED7\001 -4 0 0 50 -1 0 12 0.0000 4 135 480 3825 6345 LED8\001 -4 0 0 50 -1 0 12 0.0000 4 135 585 6480 5940 LED13\001 -4 0 0 50 -1 0 12 0.0000 4 135 585 7380 5940 LED14\001 -4 0 0 50 -1 0 12 0.0000 4 135 585 8280 5940 LED17\001 -4 0 0 50 -1 0 12 0.0000 4 135 585 9180 5940 LED18\001 -4 0 0 50 -1 0 12 0.0000 4 135 585 6930 4140 LED15\001 -4 0 0 50 -1 0 12 0.0000 4 135 585 7830 4140 LED16\001 -4 0 0 50 -1 0 12 0.0000 4 135 585 10080 4995 LED19\001 -4 0 0 50 -1 0 12 0.0000 4 135 585 10980 4995 LED20\001 diff --git a/libraries/BlinkLED/examples/Charlieplex/charlieplex5pin.png b/libraries/BlinkLED/examples/Charlieplex/charlieplex5pin.png deleted file mode 100644 index 05bc4bd1..00000000 Binary files a/libraries/BlinkLED/examples/Charlieplex/charlieplex5pin.png and /dev/null differ diff --git a/libraries/BlinkLED/examples/Charlieplex/charlieplexeg.fig b/libraries/BlinkLED/examples/Charlieplex/charlieplexeg.fig deleted file mode 100644 index 6e91d7e3..00000000 --- a/libraries/BlinkLED/examples/Charlieplex/charlieplexeg.fig +++ /dev/null @@ -1,215 +0,0 @@ -#FIG 3.2 Produced by xfig version 3.2.5b -Landscape -Center -Metric -A4 -100.00 -Single --2 -1200 2 -6 3825 3105 4275 3195 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 3920 3150 3825 3150 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 4185 3150 4158 3110 4104 3190 4050 3110 3996 3190 3942 3110 - 3915 3150 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4275 3150 4180 3150 --6 -6 4410 3375 4635 3735 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 4500 3600 4545 3510 4455 3510 4500 3600 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4500 3600 4500 3735 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4445 3600 4555 3600 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4635 3555 4590 3600 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 4635 3600 4635 3555 4590 3555 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 4635 3510 4635 3465 4590 3465 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4635 3465 4590 3510 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4500 3375 4500 3510 --6 -6 3825 4005 4275 4095 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 3920 4050 3825 4050 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 4185 4050 4158 4010 4104 4090 4050 4010 3996 4090 3942 4010 - 3915 4050 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4275 4050 4180 4050 --6 -6 4455 3105 4545 3195 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 4500 3150 30 30 4500 3150 4500 3180 --6 -6 4455 4005 4545 4095 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 4500 4050 30 30 4500 4050 4500 4080 --6 -6 3825 4905 4275 4995 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 3920 4950 3825 4950 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 4185 4950 4158 4910 4104 4990 4050 4910 3996 4990 3942 4910 - 3915 4950 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4275 4950 4180 4950 --6 -6 4410 4275 4635 4635 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 4500 4500 4545 4410 4455 4410 4500 4500 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4500 4500 4500 4635 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4445 4500 4555 4500 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4635 4455 4590 4500 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 4635 4500 4635 4455 4590 4455 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 4635 4410 4635 4365 4590 4365 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4635 4365 4590 4410 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4500 4275 4500 4410 --6 -6 6210 3915 6435 4275 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 6300 4140 6345 4050 6255 4050 6300 4140 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6300 4140 6300 4275 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6245 4140 6355 4140 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6435 4095 6390 4140 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 6435 4140 6435 4095 6390 4095 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 6435 4050 6435 4005 6390 4005 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6435 4005 6390 4050 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6300 3915 6300 4050 --6 -6 5310 3375 5535 3735 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 5400 3510 5445 3600 5355 3600 5400 3510 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5400 3510 5400 3375 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5345 3510 5455 3510 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5535 3555 5490 3510 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 5535 3510 5535 3555 5490 3555 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 5535 3600 5535 3645 5490 3645 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5535 3645 5490 3600 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5400 3735 5400 3600 --6 -6 5310 4275 5535 4635 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 5400 4410 5445 4500 5355 4500 5400 4410 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5400 4410 5400 4275 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5345 4410 5455 4410 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5535 4455 5490 4410 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 5535 4410 5535 4455 5490 4455 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 5535 4500 5535 4545 5490 4545 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5535 4545 5490 4500 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5400 4635 5400 4500 --6 -6 7110 3915 7335 4275 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 7200 4050 7245 4140 7155 4140 7200 4050 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7200 4050 7200 3915 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7145 4050 7255 4050 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7335 4095 7290 4050 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 7335 4050 7335 4095 7290 4095 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 7335 4140 7335 4185 7290 4185 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7335 4185 7290 4140 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7200 4275 7200 4140 --6 -6 5355 3105 5445 3195 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 5400 3150 30 30 5400 3150 5400 3180 --6 -6 6255 3105 6345 3195 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 6300 3150 30 30 6300 3150 6300 3180 --6 -6 6255 4905 6345 4995 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 6300 4950 30 30 6300 4950 6300 4980 --6 -6 5355 4905 5445 4995 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 5400 4950 30 30 5400 4950 5400 4980 --6 -6 4455 4905 4545 4995 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 4500 4950 30 30 4500 4950 4500 4980 --6 -6 5355 4005 5445 4095 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 5400 4050 30 30 5400 4050 5400 4080 --6 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 4230 3150 5400 3150 5400 3420 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 4500 3420 4500 3150 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 4275 4050 5400 4050 5400 3690 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 4500 3735 4500 4050 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 3870 3150 3600 3150 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 3825 4050 3600 4050 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 3825 4950 3600 4950 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 4500 4050 4500 4320 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 4500 4590 4500 4950 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5400 4365 5400 4005 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 4275 4950 5400 4950 5400 4590 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 5400 3150 6300 3150 6300 3960 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 6255 3150 7200 3150 7200 3960 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 5355 4950 6300 4950 6300 4230 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 6300 4950 7200 4950 7200 4185 -2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 - 1575 2475 3600 2475 3600 5625 1575 5625 1575 2475 -4 0 0 50 -1 0 12 0.0000 4 135 480 5625 3645 LED2\001 -4 0 0 50 -1 0 12 0.0000 4 135 480 4725 3645 LED1\001 -4 0 0 50 -1 0 12 0.0000 4 135 480 4725 4545 LED3\001 -4 0 0 50 -1 0 12 0.0000 4 135 480 5625 4545 LED4\001 -4 0 0 50 -1 0 12 0.0000 4 135 480 7425 4140 LED6\001 -4 0 0 50 -1 0 12 0.0000 4 135 480 6525 4140 LED5\001 -4 0 0 50 -1 0 12 0.0000 4 135 450 3825 3915 120R\001 -4 0 0 50 -1 0 12 0.0000 4 135 450 3825 4815 120R\001 -4 0 0 50 -1 0 12 0.0000 4 135 450 3825 3015 120R\001 -4 0 0 50 -1 0 12 0.0000 4 135 240 3240 3195 D9\001 -4 0 0 50 -1 0 12 0.0000 4 135 345 3195 4095 D10\001 -4 0 0 50 -1 0 12 0.0000 4 135 345 3195 4995 D11\001 -4 0 0 50 -1 0 12 0.0000 4 135 345 2205 4185 Uno\001 -4 0 0 50 -1 0 12 0.0000 4 135 675 2070 3915 Arduino\001 -4 0 0 50 -1 0 12 0.0000 4 135 1605 4590 5355 6 x 3mm Red LED's\001 diff --git a/libraries/BlinkLED/examples/Charlieplex/charlieplexeg.png b/libraries/BlinkLED/examples/Charlieplex/charlieplexeg.png deleted file mode 100644 index 48772ac8..00000000 Binary files a/libraries/BlinkLED/examples/Charlieplex/charlieplexeg.png and /dev/null differ diff --git a/libraries/BlinkLED/examples/CharlieplexChase/CharlieplexChase.ino b/libraries/BlinkLED/examples/CharlieplexChase/CharlieplexChase.ino deleted file mode 100644 index ee899de2..00000000 --- a/libraries/BlinkLED/examples/CharlieplexChase/CharlieplexChase.ino +++ /dev/null @@ -1,36 +0,0 @@ -/* This example is placed into the public domain */ - -#include - -byte pins[3] = {9, 10, 11}; -Charlieplex charlie(pins, sizeof(pins)); - -int previous = 1; -int current = 0; -int step = 1; -unsigned long lastTime; - -void setup() { - lastTime = millis(); - charlie.setLed(current, true); - charlie.setPwmLed(previous, 64); -} - -void loop() { - if ((millis() - lastTime) >= 100) { - charlie.setLed(previous, false); - charlie.setPwmLed(current, 64); - previous = current; - current += step; - if (current < 0) { - current = 1; - step = 1; - } else if (current >= charlie.count()) { - current = charlie.count() - 2; - step = -1; - } - charlie.setLed(current, true); - lastTime += 100; - } - charlie.loop(); -} diff --git a/libraries/BlinkLED/examples/Cylon/Cylon.fig b/libraries/BlinkLED/examples/Cylon/Cylon.fig deleted file mode 100644 index 9d61f269..00000000 --- a/libraries/BlinkLED/examples/Cylon/Cylon.fig +++ /dev/null @@ -1,238 +0,0 @@ -#FIG 3.2 Produced by xfig version 3.2.5b -Landscape -Center -Metric -A4 -100.00 -Single --2 -1200 2 -6 5175 1530 7200 2475 -6 5535 1755 5985 1845 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5630 1800 5535 1800 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 5895 1800 5868 1760 5814 1840 5760 1760 5706 1840 5652 1760 - 5625 1800 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5985 1800 5890 1800 --6 -6 6345 1665 6705 1890 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 6570 1800 6480 1755 6480 1845 6570 1800 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6570 1800 6705 1800 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6570 1855 6570 1745 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6525 1665 6570 1710 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 6570 1665 6525 1665 6525 1710 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 6480 1665 6435 1665 6435 1710 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6435 1665 6480 1710 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6345 1800 6480 1800 --6 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5535 1800 5175 1800 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5985 1800 6390 1800 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 6660 1800 7200 1800 7200 2475 -4 0 0 50 -1 0 12 0.0000 4 135 450 5535 1665 220R\001 --6 -6 5175 2205 7200 3150 -6 5535 2430 5985 2520 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5630 2475 5535 2475 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 5895 2475 5868 2435 5814 2515 5760 2435 5706 2515 5652 2435 - 5625 2475 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5985 2475 5890 2475 --6 -6 6345 2340 6705 2565 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 6570 2475 6480 2430 6480 2520 6570 2475 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6570 2475 6705 2475 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6570 2530 6570 2420 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6525 2340 6570 2385 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 6570 2340 6525 2340 6525 2385 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 6480 2340 6435 2340 6435 2385 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6435 2340 6480 2385 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6345 2475 6480 2475 --6 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5535 2475 5175 2475 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5985 2475 6390 2475 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 6660 2475 7200 2475 7200 3150 -4 0 0 50 -1 0 12 0.0000 4 135 450 5535 2340 220R\001 --6 -6 5175 2880 7200 3825 -6 5535 3105 5985 3195 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5630 3150 5535 3150 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 5895 3150 5868 3110 5814 3190 5760 3110 5706 3190 5652 3110 - 5625 3150 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5985 3150 5890 3150 --6 -6 6345 3015 6705 3240 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 6570 3150 6480 3105 6480 3195 6570 3150 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6570 3150 6705 3150 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6570 3205 6570 3095 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6525 3015 6570 3060 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 6570 3015 6525 3015 6525 3060 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 6480 3015 6435 3015 6435 3060 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6435 3015 6480 3060 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6345 3150 6480 3150 --6 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5535 3150 5175 3150 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5985 3150 6390 3150 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 6660 3150 7200 3150 7200 3825 -4 0 0 50 -1 0 12 0.0000 4 135 450 5535 3015 220R\001 --6 -6 5175 3555 7200 4500 -6 5535 3780 5985 3870 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5630 3825 5535 3825 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 5895 3825 5868 3785 5814 3865 5760 3785 5706 3865 5652 3785 - 5625 3825 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5985 3825 5890 3825 --6 -6 6345 3690 6705 3915 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 6570 3825 6480 3780 6480 3870 6570 3825 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6570 3825 6705 3825 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6570 3880 6570 3770 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6525 3690 6570 3735 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 6570 3690 6525 3690 6525 3735 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 6480 3690 6435 3690 6435 3735 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6435 3690 6480 3735 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6345 3825 6480 3825 --6 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5535 3825 5175 3825 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5985 3825 6390 3825 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 6660 3825 7200 3825 7200 4500 -4 0 0 50 -1 0 12 0.0000 4 135 450 5535 3690 220R\001 --6 -6 5175 4230 7200 5175 -6 5535 4455 5985 4545 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5630 4500 5535 4500 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 5895 4500 5868 4460 5814 4540 5760 4460 5706 4540 5652 4460 - 5625 4500 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5985 4500 5890 4500 --6 -6 6345 4365 6705 4590 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 6570 4500 6480 4455 6480 4545 6570 4500 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6570 4500 6705 4500 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6570 4555 6570 4445 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6525 4365 6570 4410 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 6570 4365 6525 4365 6525 4410 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 6480 4365 6435 4365 6435 4410 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6435 4365 6480 4410 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6345 4500 6480 4500 --6 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5535 4500 5175 4500 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5985 4500 6390 4500 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 6660 4500 7200 4500 7200 5175 -4 0 0 50 -1 0 12 0.0000 4 135 450 5535 4365 220R\001 --6 -6 5175 4905 7200 5850 -6 5535 5130 5985 5220 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5630 5175 5535 5175 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 5895 5175 5868 5135 5814 5215 5760 5135 5706 5215 5652 5135 - 5625 5175 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5985 5175 5890 5175 --6 -6 6345 5040 6705 5265 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 6570 5175 6480 5130 6480 5220 6570 5175 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6570 5175 6705 5175 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6570 5230 6570 5120 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6525 5040 6570 5085 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 6570 5040 6525 5040 6525 5085 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 6480 5040 6435 5040 6435 5085 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6435 5040 6480 5085 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6345 5175 6480 5175 --6 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5535 5175 5175 5175 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5985 5175 6390 5175 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 6660 5175 7200 5175 7200 5850 -4 0 0 50 -1 0 12 0.0000 4 135 450 5535 5040 220R\001 --6 -2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 - 2700 1350 5175 1350 5175 6300 2700 6300 2700 1350 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 7200 5850 5175 5850 -4 0 0 50 -1 0 12 0.0000 4 135 630 4275 2565 DOUT5\001 -4 0 0 50 -1 0 12 0.0000 4 135 1065 2880 3870 Arduino Uno\001 -4 0 0 50 -1 0 12 0.0000 4 135 630 4275 1845 DOUT3\001 -4 0 0 50 -1 0 12 0.0000 4 135 630 4275 3195 DOUT6\001 -4 0 0 50 -1 0 12 0.0000 4 135 630 4275 3870 DOUT9\001 -4 0 0 50 -1 0 12 0.0000 4 135 735 4275 4545 DOUT10\001 -4 0 0 50 -1 0 12 0.0000 4 135 735 4275 5220 DOUT11\001 -4 0 0 50 -1 0 12 0.0000 4 135 405 4500 5895 GND\001 -4 0 0 50 -1 0 12 0.0000 4 135 1560 7470 3510 6 x 3mm RED LED\001 diff --git a/libraries/BlinkLED/examples/Cylon/Cylon.ino b/libraries/BlinkLED/examples/Cylon/Cylon.ino deleted file mode 100644 index ea2e8324..00000000 --- a/libraries/BlinkLED/examples/Cylon/Cylon.ino +++ /dev/null @@ -1,18 +0,0 @@ -/* -Sketch that manipulates Arduino outputs to create the "Cylon Eyes" effect from -Battlestar Galactica. It uses the ChaseLEDs utility class. - -This example is placed into the public domain. -*/ - -#include - -byte pins[] = {3, 5, 6, 9, 10, 11, 10, 9, 6, 5}; -ChaseLEDs cylonEyes(pins, sizeof(pins), 100); - -void setup() {} - -void loop() { - cylonEyes.loop(); -} - diff --git a/libraries/BlinkLED/examples/Cylon/Cylon.png b/libraries/BlinkLED/examples/Cylon/Cylon.png deleted file mode 100644 index 231ccb78..00000000 Binary files a/libraries/BlinkLED/examples/Cylon/Cylon.png and /dev/null differ diff --git a/libraries/BlinkLED/examples/Cylon2/Cylon2.ino b/libraries/BlinkLED/examples/Cylon2/Cylon2.ino deleted file mode 100644 index 185e1596..00000000 --- a/libraries/BlinkLED/examples/Cylon2/Cylon2.ino +++ /dev/null @@ -1,32 +0,0 @@ -/* -Sketch that manipulates Arduino outputs to create the "Cylon Eyes" effect from -Battlestar Galactica. It uses the ChaseLEDs utility class. - -This example is placed into the public domain. -*/ - -#include - -class CylonChase : public ChaseLEDs -{ -public: - CylonChase(const byte *pins, int num, unsigned long advanceTime) - : ChaseLEDs(pins, num, advanceTime) {} - -protected: - void advance(byte prevPin, byte nextPin) { - digitalWrite(previousPin(2), LOW); - digitalWrite(prevPin, HIGH); - digitalWrite(nextPin, HIGH); - } -}; - -byte pins[] = {3, 5, 6, 9, 10, 11, 10, 9, 6, 5}; -CylonChase cylonEyes(pins, sizeof(pins), 100); - -void setup() {} - -void loop() { - cylonEyes.loop(); -} - diff --git a/libraries/BlinkLED/examples/Cylon3/Cylon3.ino b/libraries/BlinkLED/examples/Cylon3/Cylon3.ino deleted file mode 100644 index 007f45ce..00000000 --- a/libraries/BlinkLED/examples/Cylon3/Cylon3.ino +++ /dev/null @@ -1,32 +0,0 @@ -/* -Sketch that manipulates Arduino outputs to create the "Cylon Eyes" effect from -Battlestar Galactica. It uses the ChaseLEDs utility class. - -This example is placed into the public domain. -*/ - -#include - -class CylonChase : public ChaseLEDs -{ -public: - CylonChase(const byte *pins, int num, unsigned long advanceTime) - : ChaseLEDs(pins, num, advanceTime) {} - -protected: - void advance(byte prevPin, byte nextPin) { - digitalWrite(previousPin(2), LOW); - analogWrite(prevPin, 32); - digitalWrite(nextPin, HIGH); - } -}; - -byte pins[] = {3, 5, 6, 9, 10, 11, 10, 9, 6, 5}; -CylonChase cylonEyes(pins, sizeof(pins), 100); - -void setup() {} - -void loop() { - cylonEyes.loop(); -} - diff --git a/libraries/BlinkLED/examples/Cylon4/Cylon4.fig b/libraries/BlinkLED/examples/Cylon4/Cylon4.fig deleted file mode 100644 index 0b6ffbe5..00000000 --- a/libraries/BlinkLED/examples/Cylon4/Cylon4.fig +++ /dev/null @@ -1,261 +0,0 @@ -#FIG 3.2 Produced by xfig version 3.2.5b -Landscape -Center -Metric -A4 -100.00 -Single --2 -1200 2 -6 5175 1530 7200 2475 -6 5535 1755 5985 1845 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5630 1800 5535 1800 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 5895 1800 5868 1760 5814 1840 5760 1760 5706 1840 5652 1760 - 5625 1800 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5985 1800 5890 1800 --6 -6 6345 1665 6705 1890 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 6570 1800 6480 1755 6480 1845 6570 1800 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6570 1800 6705 1800 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6570 1855 6570 1745 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6525 1665 6570 1710 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 6570 1665 6525 1665 6525 1710 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 6480 1665 6435 1665 6435 1710 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6435 1665 6480 1710 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6345 1800 6480 1800 --6 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5535 1800 5175 1800 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5985 1800 6390 1800 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 6660 1800 7200 1800 7200 2475 -4 0 0 50 -1 0 12 0.0000 4 135 450 5535 1665 220R\001 --6 -6 5175 2205 7200 3150 -6 5535 2430 5985 2520 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5630 2475 5535 2475 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 5895 2475 5868 2435 5814 2515 5760 2435 5706 2515 5652 2435 - 5625 2475 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5985 2475 5890 2475 --6 -6 6345 2340 6705 2565 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 6570 2475 6480 2430 6480 2520 6570 2475 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6570 2475 6705 2475 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6570 2530 6570 2420 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6525 2340 6570 2385 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 6570 2340 6525 2340 6525 2385 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 6480 2340 6435 2340 6435 2385 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6435 2340 6480 2385 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6345 2475 6480 2475 --6 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5535 2475 5175 2475 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5985 2475 6390 2475 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 6660 2475 7200 2475 7200 3150 -4 0 0 50 -1 0 12 0.0000 4 135 450 5535 2340 220R\001 --6 -6 5175 2880 7200 3825 -6 5535 3105 5985 3195 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5630 3150 5535 3150 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 5895 3150 5868 3110 5814 3190 5760 3110 5706 3190 5652 3110 - 5625 3150 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5985 3150 5890 3150 --6 -6 6345 3015 6705 3240 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 6570 3150 6480 3105 6480 3195 6570 3150 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6570 3150 6705 3150 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6570 3205 6570 3095 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6525 3015 6570 3060 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 6570 3015 6525 3015 6525 3060 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 6480 3015 6435 3015 6435 3060 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6435 3015 6480 3060 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6345 3150 6480 3150 --6 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5535 3150 5175 3150 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5985 3150 6390 3150 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 6660 3150 7200 3150 7200 3825 -4 0 0 50 -1 0 12 0.0000 4 135 450 5535 3015 220R\001 --6 -6 5175 3555 7200 4500 -6 5535 3780 5985 3870 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5630 3825 5535 3825 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 5895 3825 5868 3785 5814 3865 5760 3785 5706 3865 5652 3785 - 5625 3825 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5985 3825 5890 3825 --6 -6 6345 3690 6705 3915 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 6570 3825 6480 3780 6480 3870 6570 3825 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6570 3825 6705 3825 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6570 3880 6570 3770 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6525 3690 6570 3735 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 6570 3690 6525 3690 6525 3735 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 6480 3690 6435 3690 6435 3735 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6435 3690 6480 3735 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6345 3825 6480 3825 --6 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5535 3825 5175 3825 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5985 3825 6390 3825 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 6660 3825 7200 3825 7200 4500 -4 0 0 50 -1 0 12 0.0000 4 135 450 5535 3690 220R\001 --6 -6 5175 4230 7200 5175 -6 5535 4455 5985 4545 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5630 4500 5535 4500 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 5895 4500 5868 4460 5814 4540 5760 4460 5706 4540 5652 4460 - 5625 4500 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5985 4500 5890 4500 --6 -6 6345 4365 6705 4590 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 6570 4500 6480 4455 6480 4545 6570 4500 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6570 4500 6705 4500 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6570 4555 6570 4445 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6525 4365 6570 4410 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 6570 4365 6525 4365 6525 4410 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 6480 4365 6435 4365 6435 4410 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6435 4365 6480 4410 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6345 4500 6480 4500 --6 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5535 4500 5175 4500 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5985 4500 6390 4500 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 6660 4500 7200 4500 7200 5175 -4 0 0 50 -1 0 12 0.0000 4 135 450 5535 4365 220R\001 --6 -6 5175 4905 7200 5850 -6 5535 5130 5985 5220 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5630 5175 5535 5175 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 5895 5175 5868 5135 5814 5215 5760 5135 5706 5215 5652 5135 - 5625 5175 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5985 5175 5890 5175 --6 -6 6345 5040 6705 5265 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 6570 5175 6480 5130 6480 5220 6570 5175 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6570 5175 6705 5175 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6570 5230 6570 5120 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6525 5040 6570 5085 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 6570 5040 6525 5040 6525 5085 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 6480 5040 6435 5040 6435 5085 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6435 5040 6480 5085 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6345 5175 6480 5175 --6 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5535 5175 5175 5175 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5985 5175 6390 5175 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 6660 5175 7200 5175 7200 5850 -4 0 0 50 -1 0 12 0.0000 4 135 450 5535 5040 220R\001 --6 -6 1305 3375 1530 3825 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 1395 3600 1465 3565 1465 3635 1395 3600 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 1350 3730 1350 3825 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 1350 3465 1390 3492 1310 3546 1390 3600 1310 3654 1390 3708 - 1350 3735 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 1350 3375 1350 3470 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 1530 3600 1440 3600 --6 -2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 - 2700 1350 5175 1350 5175 6300 2700 6300 2700 1350 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 7200 5850 5175 5850 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 1485 3600 2700 3600 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 1350 3375 1350 1800 2700 1800 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 1350 3780 1350 5850 2700 5850 -4 0 0 50 -1 0 12 0.0000 4 135 630 4275 2565 DOUT5\001 -4 0 0 50 -1 0 12 0.0000 4 135 630 4275 1845 DOUT3\001 -4 0 0 50 -1 0 12 0.0000 4 135 630 4275 3195 DOUT6\001 -4 0 0 50 -1 0 12 0.0000 4 135 630 4275 3870 DOUT9\001 -4 0 0 50 -1 0 12 0.0000 4 135 735 4275 4545 DOUT10\001 -4 0 0 50 -1 0 12 0.0000 4 135 735 4275 5220 DOUT11\001 -4 0 0 50 -1 0 12 0.0000 4 135 405 4500 5895 GND\001 -4 0 0 50 -1 0 12 0.0000 4 135 1560 7470 3510 6 x 3mm RED LED\001 -4 0 0 50 -1 0 12 0.0000 4 135 1065 3285 2880 Arduino Uno\001 -4 0 0 50 -1 0 12 0.0000 4 135 435 2835 3645 AIN0\001 -4 0 0 50 -1 0 12 0.0000 4 135 240 2835 1845 5V\001 -4 0 0 50 -1 0 12 0.0000 4 135 405 2790 5895 GND\001 -4 0 0 50 -1 0 12 0.0000 4 135 345 810 3645 10K\001 diff --git a/libraries/BlinkLED/examples/Cylon4/Cylon4.fig.bak b/libraries/BlinkLED/examples/Cylon4/Cylon4.fig.bak deleted file mode 100644 index 9d61f269..00000000 --- a/libraries/BlinkLED/examples/Cylon4/Cylon4.fig.bak +++ /dev/null @@ -1,238 +0,0 @@ -#FIG 3.2 Produced by xfig version 3.2.5b -Landscape -Center -Metric -A4 -100.00 -Single --2 -1200 2 -6 5175 1530 7200 2475 -6 5535 1755 5985 1845 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5630 1800 5535 1800 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 5895 1800 5868 1760 5814 1840 5760 1760 5706 1840 5652 1760 - 5625 1800 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5985 1800 5890 1800 --6 -6 6345 1665 6705 1890 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 6570 1800 6480 1755 6480 1845 6570 1800 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6570 1800 6705 1800 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6570 1855 6570 1745 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6525 1665 6570 1710 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 6570 1665 6525 1665 6525 1710 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 6480 1665 6435 1665 6435 1710 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6435 1665 6480 1710 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6345 1800 6480 1800 --6 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5535 1800 5175 1800 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5985 1800 6390 1800 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 6660 1800 7200 1800 7200 2475 -4 0 0 50 -1 0 12 0.0000 4 135 450 5535 1665 220R\001 --6 -6 5175 2205 7200 3150 -6 5535 2430 5985 2520 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5630 2475 5535 2475 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 5895 2475 5868 2435 5814 2515 5760 2435 5706 2515 5652 2435 - 5625 2475 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5985 2475 5890 2475 --6 -6 6345 2340 6705 2565 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 6570 2475 6480 2430 6480 2520 6570 2475 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6570 2475 6705 2475 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6570 2530 6570 2420 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6525 2340 6570 2385 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 6570 2340 6525 2340 6525 2385 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 6480 2340 6435 2340 6435 2385 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6435 2340 6480 2385 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6345 2475 6480 2475 --6 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5535 2475 5175 2475 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5985 2475 6390 2475 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 6660 2475 7200 2475 7200 3150 -4 0 0 50 -1 0 12 0.0000 4 135 450 5535 2340 220R\001 --6 -6 5175 2880 7200 3825 -6 5535 3105 5985 3195 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5630 3150 5535 3150 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 5895 3150 5868 3110 5814 3190 5760 3110 5706 3190 5652 3110 - 5625 3150 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5985 3150 5890 3150 --6 -6 6345 3015 6705 3240 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 6570 3150 6480 3105 6480 3195 6570 3150 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6570 3150 6705 3150 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6570 3205 6570 3095 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6525 3015 6570 3060 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 6570 3015 6525 3015 6525 3060 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 6480 3015 6435 3015 6435 3060 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6435 3015 6480 3060 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6345 3150 6480 3150 --6 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5535 3150 5175 3150 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5985 3150 6390 3150 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 6660 3150 7200 3150 7200 3825 -4 0 0 50 -1 0 12 0.0000 4 135 450 5535 3015 220R\001 --6 -6 5175 3555 7200 4500 -6 5535 3780 5985 3870 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5630 3825 5535 3825 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 5895 3825 5868 3785 5814 3865 5760 3785 5706 3865 5652 3785 - 5625 3825 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5985 3825 5890 3825 --6 -6 6345 3690 6705 3915 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 6570 3825 6480 3780 6480 3870 6570 3825 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6570 3825 6705 3825 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6570 3880 6570 3770 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6525 3690 6570 3735 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 6570 3690 6525 3690 6525 3735 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 6480 3690 6435 3690 6435 3735 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6435 3690 6480 3735 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6345 3825 6480 3825 --6 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5535 3825 5175 3825 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5985 3825 6390 3825 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 6660 3825 7200 3825 7200 4500 -4 0 0 50 -1 0 12 0.0000 4 135 450 5535 3690 220R\001 --6 -6 5175 4230 7200 5175 -6 5535 4455 5985 4545 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5630 4500 5535 4500 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 5895 4500 5868 4460 5814 4540 5760 4460 5706 4540 5652 4460 - 5625 4500 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5985 4500 5890 4500 --6 -6 6345 4365 6705 4590 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 6570 4500 6480 4455 6480 4545 6570 4500 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6570 4500 6705 4500 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6570 4555 6570 4445 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6525 4365 6570 4410 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 6570 4365 6525 4365 6525 4410 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 6480 4365 6435 4365 6435 4410 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6435 4365 6480 4410 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6345 4500 6480 4500 --6 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5535 4500 5175 4500 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5985 4500 6390 4500 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 6660 4500 7200 4500 7200 5175 -4 0 0 50 -1 0 12 0.0000 4 135 450 5535 4365 220R\001 --6 -6 5175 4905 7200 5850 -6 5535 5130 5985 5220 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5630 5175 5535 5175 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 5895 5175 5868 5135 5814 5215 5760 5135 5706 5215 5652 5135 - 5625 5175 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5985 5175 5890 5175 --6 -6 6345 5040 6705 5265 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 6570 5175 6480 5130 6480 5220 6570 5175 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6570 5175 6705 5175 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6570 5230 6570 5120 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6525 5040 6570 5085 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 6570 5040 6525 5040 6525 5085 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 6480 5040 6435 5040 6435 5085 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6435 5040 6480 5085 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6345 5175 6480 5175 --6 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5535 5175 5175 5175 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5985 5175 6390 5175 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 6660 5175 7200 5175 7200 5850 -4 0 0 50 -1 0 12 0.0000 4 135 450 5535 5040 220R\001 --6 -2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 - 2700 1350 5175 1350 5175 6300 2700 6300 2700 1350 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 7200 5850 5175 5850 -4 0 0 50 -1 0 12 0.0000 4 135 630 4275 2565 DOUT5\001 -4 0 0 50 -1 0 12 0.0000 4 135 1065 2880 3870 Arduino Uno\001 -4 0 0 50 -1 0 12 0.0000 4 135 630 4275 1845 DOUT3\001 -4 0 0 50 -1 0 12 0.0000 4 135 630 4275 3195 DOUT6\001 -4 0 0 50 -1 0 12 0.0000 4 135 630 4275 3870 DOUT9\001 -4 0 0 50 -1 0 12 0.0000 4 135 735 4275 4545 DOUT10\001 -4 0 0 50 -1 0 12 0.0000 4 135 735 4275 5220 DOUT11\001 -4 0 0 50 -1 0 12 0.0000 4 135 405 4500 5895 GND\001 -4 0 0 50 -1 0 12 0.0000 4 135 1560 7470 3510 6 x 3mm RED LED\001 diff --git a/libraries/BlinkLED/examples/Cylon4/Cylon4.ino b/libraries/BlinkLED/examples/Cylon4/Cylon4.ino deleted file mode 100644 index 9b38dff0..00000000 --- a/libraries/BlinkLED/examples/Cylon4/Cylon4.ino +++ /dev/null @@ -1,33 +0,0 @@ -/* -Sketch that manipulates Arduino outputs to create the "Cylon Eyes" effect from -Battlestar Galactica. It uses the ChaseLEDs utility class. - -This example is placed into the public domain. -*/ - -#include - -class CylonChase : public ChaseLEDs -{ -public: - CylonChase(const byte *pins, int num, unsigned long advanceTime) - : ChaseLEDs(pins, num, advanceTime) {} - -protected: - void advance(byte prevPin, byte nextPin) { - digitalWrite(previousPin(2), LOW); - analogWrite(prevPin, 32); - digitalWrite(nextPin, HIGH); - setAdvanceTime(map(analogRead(A0), 0, 1023, 25, 250)); - } -}; - -byte pins[] = {3, 5, 6, 9, 10, 11, 10, 9, 6, 5}; -CylonChase cylonEyes(pins, sizeof(pins), 100); - -void setup() {} - -void loop() { - cylonEyes.loop(); -} - diff --git a/libraries/BlinkLED/examples/Cylon4/Cylon4.png b/libraries/BlinkLED/examples/Cylon4/Cylon4.png deleted file mode 100644 index a4212868..00000000 Binary files a/libraries/BlinkLED/examples/Cylon4/Cylon4.png and /dev/null differ diff --git a/libraries/BlinkLED/examples/StarTrek/StarTrek.fig b/libraries/BlinkLED/examples/StarTrek/StarTrek.fig deleted file mode 100644 index a5096ce1..00000000 --- a/libraries/BlinkLED/examples/StarTrek/StarTrek.fig +++ /dev/null @@ -1,338 +0,0 @@ -#FIG 3.2 Produced by xfig version 3.2.5b -Landscape -Center -Metric -A4 -100.00 -Single --2 -1200 2 -6 6075 1530 8100 2475 -6 6435 1755 6885 1845 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6530 1800 6435 1800 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 6795 1800 6768 1760 6714 1840 6660 1760 6606 1840 6552 1760 - 6525 1800 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6885 1800 6790 1800 --6 -6 7245 1665 7605 1890 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 7470 1800 7380 1755 7380 1845 7470 1800 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7470 1800 7605 1800 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7470 1855 7470 1745 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7425 1665 7470 1710 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 7470 1665 7425 1665 7425 1710 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 7380 1665 7335 1665 7335 1710 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7335 1665 7380 1710 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7245 1800 7380 1800 --6 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 6435 1800 6075 1800 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 6885 1800 7290 1800 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 7560 1800 8100 1800 8100 2475 -4 0 0 50 -1 0 12 0.0000 4 135 450 6435 1665 220R\001 --6 -6 6075 2205 8100 3150 -6 6435 2430 6885 2520 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6530 2475 6435 2475 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 6795 2475 6768 2435 6714 2515 6660 2435 6606 2515 6552 2435 - 6525 2475 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6885 2475 6790 2475 --6 -6 7245 2340 7605 2565 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 7470 2475 7380 2430 7380 2520 7470 2475 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7470 2475 7605 2475 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7470 2530 7470 2420 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7425 2340 7470 2385 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 7470 2340 7425 2340 7425 2385 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 7380 2340 7335 2340 7335 2385 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7335 2340 7380 2385 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7245 2475 7380 2475 --6 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 6435 2475 6075 2475 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 6885 2475 7290 2475 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 7560 2475 8100 2475 8100 3150 -4 0 0 50 -1 0 12 0.0000 4 135 450 6435 2340 220R\001 --6 -6 6075 2880 8100 3825 -6 6435 3105 6885 3195 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6530 3150 6435 3150 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 6795 3150 6768 3110 6714 3190 6660 3110 6606 3190 6552 3110 - 6525 3150 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6885 3150 6790 3150 --6 -6 7245 3015 7605 3240 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 7470 3150 7380 3105 7380 3195 7470 3150 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7470 3150 7605 3150 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7470 3205 7470 3095 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7425 3015 7470 3060 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 7470 3015 7425 3015 7425 3060 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 7380 3015 7335 3015 7335 3060 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7335 3015 7380 3060 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7245 3150 7380 3150 --6 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 6435 3150 6075 3150 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 6885 3150 7290 3150 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 7560 3150 8100 3150 8100 3825 -4 0 0 50 -1 0 12 0.0000 4 135 450 6435 3015 220R\001 --6 -6 6075 3555 8100 4500 -6 6435 3780 6885 3870 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6530 3825 6435 3825 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 6795 3825 6768 3785 6714 3865 6660 3785 6606 3865 6552 3785 - 6525 3825 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6885 3825 6790 3825 --6 -6 7245 3690 7605 3915 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 7470 3825 7380 3780 7380 3870 7470 3825 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7470 3825 7605 3825 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7470 3880 7470 3770 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7425 3690 7470 3735 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 7470 3690 7425 3690 7425 3735 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 7380 3690 7335 3690 7335 3735 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7335 3690 7380 3735 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7245 3825 7380 3825 --6 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 6435 3825 6075 3825 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 6885 3825 7290 3825 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 7560 3825 8100 3825 8100 4500 -4 0 0 50 -1 0 12 0.0000 4 135 450 6435 3690 220R\001 --6 -6 6075 4230 8100 5175 -6 6435 4455 6885 4545 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6530 4500 6435 4500 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 6795 4500 6768 4460 6714 4540 6660 4460 6606 4540 6552 4460 - 6525 4500 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6885 4500 6790 4500 --6 -6 7245 4365 7605 4590 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 7470 4500 7380 4455 7380 4545 7470 4500 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7470 4500 7605 4500 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7470 4555 7470 4445 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7425 4365 7470 4410 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 7470 4365 7425 4365 7425 4410 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 7380 4365 7335 4365 7335 4410 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7335 4365 7380 4410 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7245 4500 7380 4500 --6 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 6435 4500 6075 4500 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 6885 4500 7290 4500 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 7560 4500 8100 4500 8100 5175 -4 0 0 50 -1 0 12 0.0000 4 135 450 6435 4365 220R\001 --6 -6 6075 4905 8100 5850 -6 6435 5130 6885 5220 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6530 5175 6435 5175 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 6795 5175 6768 5135 6714 5215 6660 5135 6606 5215 6552 5135 - 6525 5175 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6885 5175 6790 5175 --6 -6 7245 5040 7605 5265 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 7470 5175 7380 5130 7380 5220 7470 5175 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7470 5175 7605 5175 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7470 5230 7470 5120 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7425 5040 7470 5085 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 7470 5040 7425 5040 7425 5085 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 7380 5040 7335 5040 7335 5085 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7335 5040 7380 5085 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 7245 5175 7380 5175 --6 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 6435 5175 6075 5175 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 6885 5175 7290 5175 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 7560 5175 8100 5175 8100 5850 -4 0 0 50 -1 0 12 0.0000 4 135 450 6435 5040 220R\001 --6 -6 1530 2700 1755 3150 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 1620 2925 1690 2890 1690 2960 1620 2925 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 1575 3055 1575 3150 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 1575 2790 1615 2817 1535 2871 1615 2925 1535 2979 1615 3033 - 1575 3060 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 1575 2700 1575 2795 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 1755 2925 1665 2925 --6 -6 1575 3465 3600 3915 -6 2565 3780 3015 3870 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2660 3825 2565 3825 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 2925 3825 2898 3785 2844 3865 2790 3785 2736 3865 2682 3785 - 2655 3825 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 3015 3825 2920 3825 --6 -6 1890 3690 2250 3915 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 2025 3825 2115 3780 2115 3870 2025 3825 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2025 3825 1890 3825 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2025 3880 2025 3770 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2070 3690 2025 3735 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 2025 3690 2070 3690 2070 3735 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 2115 3690 2160 3690 2160 3735 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2160 3690 2115 3735 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2250 3825 2115 3825 --6 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 2970 3825 3600 3825 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 2160 3825 2610 3825 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 1935 3825 1575 3825 -4 0 0 50 -1 0 12 0.0000 4 135 450 2610 3600 220R\001 -4 0 0 50 -1 0 12 0.0000 4 135 390 1935 3600 RED\001 --6 -6 2565 4680 3015 4770 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2660 4725 2565 4725 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 2925 4725 2898 4685 2844 4765 2790 4685 2736 4765 2682 4685 - 2655 4725 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 3015 4725 2920 4725 --6 -6 1890 4590 2250 4815 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 2025 4725 2115 4680 2115 4770 2025 4725 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2025 4725 1890 4725 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2025 4780 2025 4670 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2070 4590 2025 4635 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 2025 4590 2070 4590 2070 4635 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 2115 4590 2160 4590 2160 4635 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2160 4590 2115 4635 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2250 4725 2115 4725 --6 -2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 - 3600 1350 6075 1350 6075 6300 3600 6300 3600 1350 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 8100 5850 6075 5850 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 1575 2700 1575 1800 3600 1800 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 1575 3150 1575 5850 3600 5850 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 1755 2925 3600 2925 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 2970 4725 3600 4725 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 2160 4725 2610 4725 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 1935 4725 1575 4725 -4 0 0 50 -1 0 12 0.0000 4 135 630 5175 2565 DOUT5\001 -4 0 0 50 -1 0 12 0.0000 4 135 630 5175 1845 DOUT3\001 -4 0 0 50 -1 0 12 0.0000 4 135 630 5175 3195 DOUT6\001 -4 0 0 50 -1 0 12 0.0000 4 135 630 5175 3870 DOUT9\001 -4 0 0 50 -1 0 12 0.0000 4 135 735 5175 4545 DOUT10\001 -4 0 0 50 -1 0 12 0.0000 4 135 735 5175 5220 DOUT11\001 -4 0 0 50 -1 0 12 0.0000 4 135 405 5400 5895 GND\001 -4 0 0 50 -1 0 12 0.0000 4 135 240 3735 1845 5V\001 -4 0 0 50 -1 0 12 0.0000 4 135 405 3690 5895 GND\001 -4 0 0 50 -1 0 12 0.0000 4 135 1065 4230 1215 Arduino Uno\001 -4 0 0 50 -1 0 12 0.0000 4 135 435 3735 3015 AIN0\001 -4 0 0 50 -1 0 12 0.0000 4 135 345 1080 3015 10K\001 -4 0 0 50 -1 0 12 0.0000 4 135 450 2610 4500 100R\001 -4 0 0 50 -1 0 12 0.0000 4 135 615 1800 4500 WHITE\001 -4 0 0 50 -1 0 12 0.0000 4 135 630 3690 4770 AOUT3\001 -4 0 0 50 -1 0 12 0.0000 4 135 630 3690 3870 AOUT2\001 -4 0 0 50 -1 0 12 0.0000 4 135 1110 8370 3510 6 x RED LED\001 -4 0 0 50 -1 0 12 0.0000 4 135 690 8505 4050 Nacelles\001 -4 0 0 50 -1 0 12 0.0000 4 180 915 495 3870 Navigation\001 -4 0 0 50 -1 0 12 0.0000 4 135 525 675 4770 Strobe\001 diff --git a/libraries/BlinkLED/examples/StarTrek/StarTrek.ino b/libraries/BlinkLED/examples/StarTrek/StarTrek.ino deleted file mode 100644 index 07b96216..00000000 --- a/libraries/BlinkLED/examples/StarTrek/StarTrek.ino +++ /dev/null @@ -1,59 +0,0 @@ -/* -Sketch that manipulates Arduino outputs to create Star Trek Enterprise style -running lights and LED chasers. - -This example is placed into the public domain. -*/ - -#include -#include - -#define NACELLE_RATE A0 // Analog input for reading the nacelle chase rate -#define NAV_LIGHTS A2 // Output pin for controlling the navigation lights -#define STROBE_LIGHT A3 // Output pin for controlling the strobe - -// Configurable parameters. -#define NAV_LIGHTS_ON 1000 // Time the navigation lights are on (milliseconds) -#define NAV_LIGHTS_OFF 1000 // Time the navigation lights are off (milliseconds) -#define STROBE_LIGHT_ON 70 // Time the strobe light is on (milliseconds) -#define STROBE_LIGHT_OFF 830 // Time the strobe light is off (milliseconds) -#define NACELLE_CHASE_LEN 6 // Length of nacelle chase, 1..6 -#define NACELLE_MIN_PERIOD 25 // Minimum time to advance the nacelle chase (milliseconds) -#define NACELLE_MAX_PERIOD 250 // Maximum time to advance the nacelle chase (milliseconds) -#define NACELLE_DIM_VALUE 32 // Value for dimming previous LED in chase, 0..255 - -// Output pins to use for the nacelle chase -byte nacelleChasePins[6] = {3, 5, 6, 9, 10, 11}; - -class NacelleChaseLEDs : public ChaseLEDs -{ -public: - NacelleChaseLEDs(const byte *pins, int num) - : ChaseLEDs(pins, num, 0) {} - -protected: - void advance(byte prevPin, byte nextPin) { - digitalWrite(previousPin(2), LOW); - analogWrite(prevPin, NACELLE_DIM_VALUE); - digitalWrite(nextPin, HIGH); - setAdvanceTime(map(analogRead(NACELLE_RATE), 0, 1023, NACELLE_MIN_PERIOD, NACELLE_MAX_PERIOD)); - } -}; - -NacelleChaseLEDs nacelleChase(nacelleChasePins, NACELLE_CHASE_LEN); - -BlinkLED navLights(NAV_LIGHTS, NAV_LIGHTS_ON, NAV_LIGHTS_OFF); -BlinkLED strobeLight(STROBE_LIGHT, STROBE_LIGHT_ON, STROBE_LIGHT_OFF); - -void setup() { - // Turn off the status LED on the Arduino board (we don't need it). - pinMode(13, OUTPUT); - digitalWrite(13, LOW); -} - -void loop() { - navLights.loop(); - strobeLight.loop(); - nacelleChase.loop(); -} - diff --git a/libraries/BlinkLED/examples/StarTrek/StarTrek.png b/libraries/BlinkLED/examples/StarTrek/StarTrek.png deleted file mode 100644 index 9588a9b2..00000000 Binary files a/libraries/BlinkLED/examples/StarTrek/StarTrek.png and /dev/null differ diff --git a/libraries/BlinkLED/examples/StarTrek/StarTrekBreadboard.png b/libraries/BlinkLED/examples/StarTrek/StarTrekBreadboard.png deleted file mode 100644 index 8a14f8eb..00000000 Binary files a/libraries/BlinkLED/examples/StarTrek/StarTrekBreadboard.png and /dev/null differ diff --git a/libraries/BlinkLED/examples/StarTrek/StarTrekShield.png b/libraries/BlinkLED/examples/StarTrek/StarTrekShield.png deleted file mode 100644 index 1ab21738..00000000 Binary files a/libraries/BlinkLED/examples/StarTrek/StarTrekShield.png and /dev/null differ diff --git a/libraries/BlinkLED/examples/StarTrek/ThreeChase.fig b/libraries/BlinkLED/examples/StarTrek/ThreeChase.fig deleted file mode 100644 index 06521855..00000000 --- a/libraries/BlinkLED/examples/StarTrek/ThreeChase.fig +++ /dev/null @@ -1,292 +0,0 @@ -#FIG 3.2 Produced by xfig version 3.2.5b -Landscape -Center -Metric -A4 -100.00 -Single --2 -1200 2 -6 10260 2025 10485 2385 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 10350 2250 10395 2160 10305 2160 10350 2250 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10350 2250 10350 2385 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10295 2250 10405 2250 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10485 2205 10440 2250 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 10485 2250 10485 2205 10440 2205 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 10485 2160 10485 2115 10440 2115 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10485 2115 10440 2160 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10350 2025 10350 2160 --6 -6 10260 3600 10485 3960 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 10350 3825 10395 3735 10305 3735 10350 3825 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10350 3825 10350 3960 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10295 3825 10405 3825 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10485 3780 10440 3825 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 10485 3825 10485 3780 10440 3780 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 10485 3735 10485 3690 10440 3690 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10485 3690 10440 3735 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10350 3600 10350 3735 --6 -6 9585 2475 9810 2835 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 9675 2700 9720 2610 9630 2610 9675 2700 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 9675 2700 9675 2835 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 9620 2700 9730 2700 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 9810 2655 9765 2700 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 9810 2700 9810 2655 9765 2655 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 9810 2610 9810 2565 9765 2565 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 9810 2565 9765 2610 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 9675 2475 9675 2610 --6 -6 10935 2475 11160 2835 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 11025 2700 11070 2610 10980 2610 11025 2700 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 11025 2700 11025 2835 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10970 2700 11080 2700 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 11160 2655 11115 2700 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 11160 2700 11160 2655 11115 2655 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 11160 2610 11160 2565 11115 2565 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 11160 2565 11115 2610 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 11025 2475 11025 2610 --6 -6 10935 3150 11160 3510 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 11025 3375 11070 3285 10980 3285 11025 3375 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 11025 3375 11025 3510 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10970 3375 11080 3375 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 11160 3330 11115 3375 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 11160 3375 11160 3330 11115 3330 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 11160 3285 11160 3240 11115 3240 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 11160 3240 11115 3285 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 11025 3150 11025 3285 --6 -6 9585 3150 9810 3510 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 9675 3375 9720 3285 9630 3285 9675 3375 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 9675 3375 9675 3510 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 9620 3375 9730 3375 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 9810 3330 9765 3375 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 9810 3375 9810 3330 9765 3330 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 9810 3285 9810 3240 9765 3240 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 9810 3240 9765 3285 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 9675 3150 9675 3285 --6 -6 10305 3915 10395 4365 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10350 4270 10350 4365 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 10350 4005 10310 4032 10390 4086 10310 4140 10390 4194 10310 4248 - 10350 4275 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10350 3915 10350 4010 --6 -6 9630 3915 9720 4365 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 9675 4270 9675 4365 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 9675 4005 9635 4032 9715 4086 9635 4140 9715 4194 9635 4248 - 9675 4275 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 9675 3915 9675 4010 --6 -6 10980 3915 11070 4365 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 11025 4270 11025 4365 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 11025 4005 10985 4032 11065 4086 10985 4140 11065 4194 10985 4248 - 11025 4275 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 11025 3915 11025 4010 --6 -6 9450 4365 9675 4635 -2 3 0 1 0 -1 0 0 20 0.000 0 0 0 0 0 4 - 9627 4584 9597 4519 9562 4554 9627 4584 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 9540 4500 9675 4635 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 9540 4500 9675 4365 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 9540 4410 9540 4590 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 9540 4500 9450 4500 --6 -6 10305 1710 10620 2025 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 1 0 2 - 1 1 1.00 45.00 90.00 - 10350 2025 10350 1710 -4 0 0 0 0 16 6 0.0000 4 75 225 10395 1845 VCC\001 --6 -6 9585 4635 9765 4905 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 9660 4905 9690 4905 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 9625 4860 9725 4860 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 9585 4815 9765 4815 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 9675 4635 9675 4815 --6 -6 10125 5175 10350 5445 -2 3 0 1 0 -1 0 0 20 0.000 0 0 0 0 0 4 - 10302 5394 10272 5329 10237 5364 10302 5394 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10215 5310 10350 5445 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10215 5310 10350 5175 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10215 5220 10215 5400 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10215 5310 10125 5310 --6 -6 10260 5445 10440 5715 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10335 5715 10365 5715 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10300 5670 10400 5670 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10260 5625 10440 5625 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10350 5445 10350 5625 --6 -6 8550 5265 9000 5355 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 8645 5310 8550 5310 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 8910 5310 8883 5270 8829 5350 8775 5270 8721 5350 8667 5270 - 8640 5310 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 9000 5310 8905 5310 --6 -6 8550 4455 9000 4545 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 8645 4500 8550 4500 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 8910 4500 8883 4460 8829 4540 8775 4460 8721 4540 8667 4460 - 8640 4500 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 9000 4500 8905 4500 --6 -6 10800 5985 11025 6255 -2 3 0 1 0 -1 0 0 20 0.000 0 0 0 0 0 4 - 10977 6204 10947 6139 10912 6174 10977 6204 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10890 6120 11025 6255 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10890 6120 11025 5985 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10890 6030 10890 6210 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10890 6120 10800 6120 --6 -6 8550 6075 9000 6165 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 8645 6120 8550 6120 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 8910 6120 8883 6080 8829 6160 8775 6080 8721 6160 8667 6080 - 8640 6120 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 9000 6120 8905 6120 --6 -6 10935 6255 11115 6525 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 11010 6525 11040 6525 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10975 6480 11075 6480 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10935 6435 11115 6435 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 11025 6255 11025 6435 --6 -1 4 1 1 0 7 50 -1 -1 4.000 1 0.0000 10350 2970 945 945 9405 2970 11295 2970 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 10350 2340 10350 3690 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 - 9675 2835 10215 2835 10215 3150 10260 3150 10305 3150 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 10395 3150 11025 3150 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 11025 2835 10665 2835 10665 3105 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 10665 3195 10665 3375 10395 3375 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 4 - 10305 3375 9990 3375 9990 3150 9675 3150 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 9675 3915 9675 3465 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 11025 3465 11025 3960 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 10350 4365 10350 5220 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 11025 4320 11025 5985 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 4 - 9675 2520 9675 2025 11025 2025 11025 2565 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 9495 4500 8955 4500 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 10125 5310 9000 5310 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 8550 4500 7875 4500 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 8550 5310 7875 5310 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 10845 6120 8955 6120 9000 6120 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 8595 6120 7875 6120 -4 0 0 50 -1 0 12 0.0000 4 135 345 8595 4365 10K\001 -4 0 0 50 -1 0 12 0.0000 4 135 345 8595 5130 10K\001 -4 0 0 50 -1 0 12 0.0000 4 135 345 8595 5940 10K\001 -4 0 0 50 -1 0 12 0.0000 4 135 630 7110 4590 DOUT3\001 -4 0 0 50 -1 0 12 0.0000 4 135 630 7110 5355 DOUT5\001 -4 0 0 50 -1 0 12 0.0000 4 135 630 7110 6165 DOUT6\001 -4 0 0 50 -1 0 12 0.0000 4 135 135 9810 4230 R\001 -4 0 0 50 -1 0 12 0.0000 4 135 135 10485 4230 R\001 -4 0 0 50 -1 0 12 0.0000 4 135 135 11160 4230 R\001 -4 0 0 50 -1 0 12 0.0000 4 135 2190 6930 3510 R = 120 ohms for Vcc = 5V\001 -4 0 0 50 -1 0 12 0.0000 4 135 2220 6930 3780 R = 1K ohms for Vcc = 12V\001 -4 0 0 50 -1 0 12 0.0000 4 135 585 9720 4590 BC548\001 -4 0 0 50 -1 0 12 0.0000 4 135 585 10395 5400 BC548\001 -4 0 0 50 -1 0 12 0.0000 4 135 585 11070 6210 BC548\001 diff --git a/libraries/BlinkLED/examples/StarTrek/ThreeChase.png b/libraries/BlinkLED/examples/StarTrek/ThreeChase.png deleted file mode 100644 index c460598c..00000000 Binary files a/libraries/BlinkLED/examples/StarTrek/ThreeChase.png and /dev/null differ diff --git a/libraries/BlinkLED/examples/StarTrek2/StarTrek2.ino b/libraries/BlinkLED/examples/StarTrek2/StarTrek2.ino deleted file mode 100644 index 85b13392..00000000 --- a/libraries/BlinkLED/examples/StarTrek2/StarTrek2.ino +++ /dev/null @@ -1,62 +0,0 @@ -/* -Sketch that manipulates Arduino outputs to create Star Trek Enterprise style -running lights and LED chasers. - -This example is placed into the public domain. -*/ - -#include -#include - -#define NACELLE_RATE A0 // Analog input for reading the nacelle chase rate -#define NAV_LIGHTS A2 // Output pin for controlling the navigation lights -#define STROBE_LIGHT A3 // Output pin for controlling the strobe - -// Configurable parameters. -#define NAV_LIGHTS_ON 1000 // Time the navigation lights are on (milliseconds) -#define NAV_LIGHTS_OFF 1000 // Time the navigation lights are off (milliseconds) -#define STROBE_LIGHT_ON 70 // Time the strobe light is on (milliseconds) -#define STROBE_LIGHT_OFF 830 // Time the strobe light is off (milliseconds) -#define NACELLE_CHASE_LEN 6 // Length of nacelle chase, 1..6 -#define NACELLE_MIN_PERIOD 25 // Minimum time to advance the nacelle chase (milliseconds) -#define NACELLE_MAX_PERIOD 250 // Maximum time to advance the nacelle chase (milliseconds) -#define NACELLE_DIM_VALUE 32 // Value for dimming previous LED in chase, 0..255 - -// Output pins to use for the nacelle chase -byte nacelleChasePins[6] = {3, 5, 6, 9, 10, 11}; - -class NacelleChaseLEDs : public ChaseLEDs -{ -public: - NacelleChaseLEDs(const byte *pins, int num) - : ChaseLEDs(pins, num, 0) {} - -protected: - void advance(byte prevPin, byte nextPin) { - digitalWrite(previousPin(5), LOW); - analogWrite(previousPin(4), NACELLE_DIM_VALUE); - digitalWrite(previousPin(3), HIGH); - digitalWrite(previousPin(2), LOW); - analogWrite(prevPin, NACELLE_DIM_VALUE); - digitalWrite(nextPin, HIGH); - setAdvanceTime(map(analogRead(NACELLE_RATE), 0, 1023, NACELLE_MIN_PERIOD, NACELLE_MAX_PERIOD)); - } -}; - -NacelleChaseLEDs nacelleChase(nacelleChasePins, NACELLE_CHASE_LEN); - -BlinkLED navLights(NAV_LIGHTS, NAV_LIGHTS_ON, NAV_LIGHTS_OFF); -BlinkLED strobeLight(STROBE_LIGHT, STROBE_LIGHT_ON, STROBE_LIGHT_OFF); - -void setup() { - // Turn off the status LED on the Arduino board (we don't need it). - pinMode(13, OUTPUT); - digitalWrite(13, LOW); -} - -void loop() { - navLights.loop(); - strobeLight.loop(); - nacelleChase.loop(); -} - diff --git a/libraries/BlinkLED/keywords.txt b/libraries/BlinkLED/keywords.txt deleted file mode 100644 index 9e23dc9e..00000000 --- a/libraries/BlinkLED/keywords.txt +++ /dev/null @@ -1,27 +0,0 @@ -BlinkLED KEYWORD1 -Charlieplex KEYWORD1 -ChaseLEDs KEYWORD1 - -onTime KEYWORD2 -offTime KEYWORD2 -setBlinkRate KEYWORD2 - -state KEYWORD2 -setState KEYWORD2 - -pause KEYWORD2 -resume KEYWORD2 -isPaused KEYWORD2 - -advanceTime KEYWORD2 -setAdvanceTime KEYWORD2 -previousPin KEYWORD2 - -count KEYWORD2 -led KEYWORD2 -setLed KEYWORD2 -pwmLed KEYWORD2 -setPwmLed KEYWORD2 -holdTime KEYWORD2 -setHoldTime KEYWORD2 -refresh KEYWORD2 diff --git a/libraries/DMD/Bitmap.cpp b/libraries/DMD/Bitmap.cpp deleted file mode 100644 index 0180b2a5..00000000 --- a/libraries/DMD/Bitmap.cpp +++ /dev/null @@ -1,966 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#include "Bitmap.h" -#include -#include -#include - -/** - * \class Bitmap Bitmap.h - * \brief Represents a monochrome bitmap within main memory. - * - * Bitmaps are a rectangular arrangement of width() x height() pixels, - * with each pixel set to either \ref Black or \ref White. The co-ordinate - * system has origin (0, 0) at the top-left of the bitmap. - * - * Functions within this class can be used to draw various shapes into - * the bitmap's data() buffer; e.g. drawLine(), drawRect(), drawBitmap(), - * drawText(), clear(), fill(), etc. - * - * \sa DMD - */ - -/** - * \typedef Bitmap::Color - * \brief Type that represents the color of a pixel in a bitmap. - * - * \sa Black, White - */ - -/** - * \typedef Bitmap::ProgMem - * \brief Type that represents a bitmap within program memory. - */ - -/** - * \typedef Bitmap::Font - * \brief Type that represents a font within program memory. - */ - -/** - * \var Bitmap::Black - * \brief Color value corresponding to "black". - */ - -/** - * \var Bitmap::White - * \brief Color value corresponding to "white". If the bitmap is - * displayed on a LED array, then it may have a different physical color. - * - * Note: while the value of this constant is 1, the bitmap itself stores - * white pixels as 0 and black as 1 because the DMD display uses 1 to - * indicate a pixel being off. - */ - -/** - * \var Bitmap::NoFill - * \brief Special color value that is used with drawRect() and drawCircle() - * to indicate that the interior of the shape should not be filled. - * For all other uses, \ref NoFill is equivalent to \ref White. - */ - -/** - * \brief Constructs a new in-memory bitmap that is \a width x \a height - * pixels in size. - * - * \sa width(), height(), isValid() - */ -Bitmap::Bitmap(int width, int height) - : _width(width) - , _height(height) - , _stride((width + 7) / 8) - , fb(0) - , _font(0) - , _textColor(White) -{ - // Allocate memory for the framebuffer and clear it (1 = pixel off). - unsigned int size = _stride * _height; - fb = (uint8_t *)malloc(size); - if (fb) - memset(fb, 0xFF, size); -} - -/** - * \brief Destroys this bitmap. - */ -Bitmap::~Bitmap() -{ - if (fb) - free(fb); -} - -/** - * \fn bool Bitmap::isValid() const - * \brief Returns true if the memory for this bitmap is valid; false otherwise. - * - * This function can be called just after the constructor to determine if - * the memory for the bitmap was allocated successfully. - */ - -/** - * \fn int Bitmap::width() const - * \brief Returns the width of the bitmap in pixels. - * - * \sa height(), stride(), bitsPerPixel() - */ - -/** - * \fn int Bitmap::height() const - * \brief Returns the height of the bitmap in pixels. - * - * \sa width(), bitsPerPixel() - */ - -/** - * \fn int Bitmap::stride() const - * \brief Returns the number of bytes in each line of the bitmap's data() buffer. - * - * \sa width(), bitsPerPixel(), data() - */ - -/** - * \fn int Bitmap::bitsPerPixel() const - * \brief Returns the number of bits per pixel for the bitmap; always 1. - * - * \sa width(), height() - */ - -/** - * \fn uint8_t *Bitmap::data() - * \brief Returns a pointer to the start of the bitmap's data buffer. - * - * The data is organized as height() lines of stride() bytes, laid out - * horizontally across the extent of width() pixels. The most significant - * bit in each byte has the lowest x value. - * - * Note: bits within the data are 1 for \ref Black and 0 for \ref White, - * which is the reverse of the constant values. This differs from pixel() - * which returns the correct constant. - * - * \sa pixel(), stride() - */ - -/** - * \fn const uint8_t *Bitmap::data() const - * \brief Returns a constant pointer to the start of the bitmap's data buffer. - * \overload - */ - -/** - * \brief Clears the entire bitmap to the specified \a color. - * - * \sa fill() - */ -void Bitmap::clear(Color color) -{ - unsigned int size = _stride * _height; - if (color == Black) - memset(fb, 0xFF, size); - else - memset(fb, 0x00, size); -} - -/** - * \brief Returns the color of the pixel at (\a x, \a y); either \ref Black - * or \ref White. - * - * Returns \a Black if \a x or \a y is out of range. - * - * \sa setPixel(), data() - */ -Bitmap::Color Bitmap::pixel(int x, int y) const -{ - if (((unsigned int)x) >= ((unsigned int)_width) || - ((unsigned int)y) >= ((unsigned int)_height)) - return Black; - uint8_t *ptr = fb + y * _stride + (x >> 3); - if (*ptr & ((uint8_t)0x80) >> (x & 0x07)) - return Black; - else - return White; -} - -/** - * \brief Sets the pixel at (\a x, \a y) to \a color. - * - * \sa pixel() - */ -void Bitmap::setPixel(int x, int y, Color color) -{ - if (((unsigned int)x) >= ((unsigned int)_width) || - ((unsigned int)y) >= ((unsigned int)_height)) - return; // Pixel is off-screen. - uint8_t *ptr = fb + y * _stride + (x >> 3); - if (color) - *ptr &= ~(((uint8_t)0x80) >> (x & 0x07)); - else - *ptr |= (((uint8_t)0x80) >> (x & 0x07)); -} - -/** - * \brief Draws a line from (\a x1, \a y1) to (\a x2, \a y2) in \a color. - * - * \sa drawRect(), drawCircle() - */ -void Bitmap::drawLine(int x1, int y1, int x2, int y2, Color color) -{ - // Midpoint line scan-conversion algorithm from "Computer Graphics: - // Principles and Practice", Second Edition, Foley, van Dam, et al. - int dx = x2 - x1; - int dy = y2 - y1; - int xstep, ystep; - int d, incrE, incrNE; - if (dx < 0) { - xstep = -1; - dx = -dx; - } else { - xstep = 1; - } - if (dy < 0) { - ystep = -1; - dy = -dy; - } else { - ystep = 1; - } - if (dx >= dy) { - d = 2 * dy - dx; - incrE = 2 * dy; - incrNE = 2 * (dy - dx); - setPixel(x1, y1, color); - while (x1 != x2) { - if (d <= 0) { - d += incrE; - } else { - d += incrNE; - y1 += ystep; - } - x1 += xstep; - setPixel(x1, y1, color); - } - } else { - d = 2 * dx - dy; - incrE = 2 * dx; - incrNE = 2 * (dx - dy); - setPixel(x1, y1, color); - while (y1 != y2) { - if (d <= 0) { - d += incrE; - } else { - d += incrNE; - x1 += xstep; - } - y1 += ystep; - setPixel(x1, y1, color); - } - } -} - -/** - * \brief Draws a rectangle from (\a x1, \a y1) to (\a x2, \a y2), with the - * outline in \a borderColor and the interior filled with \a fillColor. - * - * If \a fillColor is \ref NoFill, then the interior is not filled. - * - * \sa drawFilledRect(), drawLine(), drawCircle(), fill() - */ -void Bitmap::drawRect(int x1, int y1, int x2, int y2, Color borderColor, Color fillColor) -{ - int temp; - if (x1 > x2) { - temp = x1; - x1 = x2; - x2 = temp; - } - if (y1 > y2) { - temp = y1; - y1 = y2; - y2 = temp; - } - if (fillColor == borderColor) { - fill(x1, y1, x2 - x1 + 1, y2 - y1 + 1, fillColor); - } else { - drawLine(x1, y1, x2, y1, borderColor); - if (y1 < y2) - drawLine(x2, y1 + 1, x2, y2, borderColor); - if (x1 < x2) - drawLine(x2 - 1, y2, x1, y2, borderColor); - if (y1 < (y2 - 1)) - drawLine(x1, y2 - 1, x1, y1 + 1, borderColor); - if (fillColor != NoFill) - fill(x1 + 1, y1 + 1, x2 - x1 - 1, y2 - y1 - 1, fillColor); - } -} - -/** - * \fn void Bitmap::drawFilledRect(int x1, int y1, int x2, int y2, Color color) - * \brief Draws a filled rectangle from (\a x1, \a y1) to (\a x2, \a y2) - * in \a color. - * - * This is a convenience function that is equivalent to - * drawRect(\a x1, \a y1, \a x2, \a y2, \a color, \a color). - * - * \sa drawRect(), drawFilledCircle() - */ - -/** - * \brief Draws a circle with a specific center (\a centerX, \a centerY) - * and \a radius, with the outline in \a borderColor and the interior - * filled with \a fillColor. - * - * If \a fillColor is \ref NoFill, then the interior is not filled. - * - * \sa drawFilledCircle(), drawLine(), drawRect() - */ -void Bitmap::drawCircle(int centerX, int centerY, int radius, Color borderColor, Color fillColor) -{ - // Midpoint circle scan-conversion algorithm using second-order - // differences from "Computer Graphics: Principles and Practice", - // Second Edition, Foley, van Dam, et al. - if (radius < 0) - radius = -radius; - int x = 0; - int y = radius; - int d = 1 - radius; - int deltaE = 3; - int deltaSE = 5 - 2 * radius; - drawCirclePoints(centerX, centerY, radius, x, y, borderColor, fillColor); - while (y > x) { - if (d < 0) { - d += deltaE; - deltaE += 2; - deltaSE += 2; - } else { - d += deltaSE; - deltaE += 2; - deltaSE += 4; - --y; - } - ++x; - drawCirclePoints(centerX, centerY, radius, x, y, borderColor, fillColor); - } -} - -/** - * \fn void Bitmap::drawFilledCircle(int centerX, int centerY, int radius, Color color) - * \brief Draws a filled circle with a specific center (\a centerX, \a centerY) - * and \a radius in \a color. - * - * This is a convenience function that is equivalent to - * drawCircle(\a centerX, \a centerY, \a radius, \a color, \a color). - * - * \sa drawCircle(), drawFilledRect() - */ - -/** - * \brief Draws \a bitmap at (\a x, \a y) in \a color. - * - * Bits that are set to \ref White in the \a bitmap are drawn with \a color. - * Bits that are set to \ref Black in the \a bitmap are drawn with the - * inverse of \a color. The pixel at (\a x, \a y) will be the top-left - * corner of the drawn image. - * - * Note: \a bitmap must not be the same as this object or the behaviour will - * be undefined. To copy a region of a bitmap to elsewhere within the - * same bitmap, use copy() instead. - * - * \sa drawInvertedBitmap(), copy() - */ -void Bitmap::drawBitmap(int x, int y, const Bitmap &bitmap, Color color) -{ - int w = bitmap.width(); - int s = bitmap.stride(); - int h = bitmap.height(); - Color invColor = !color; - for (uint8_t by = 0; by < h; ++by) { - const uint8_t *line = bitmap.data() + by * s; - uint8_t mask = 0x80; - uint8_t value = *line++; - for (uint8_t bx = 0; bx < w; ++bx) { - if (value & mask) - setPixel(x + bx, y + by, invColor); - else - setPixel(x + bx, y + by, color); - mask >>= 1; - if (!mask) { - mask = 0x80; - value = *line++; - } - } - } -} - -/** - * \brief Draws \a bitmap at (\a x, \a y) in \a color. - * - * The \a bitmap must point to program memory. The first two bytes are the - * width and height of the bitmap in pixels. The rest of the data contains - * the pixels for the bitmap, with lines byte-aligned. - * - * Bits that are 1 in the \a bitmap are drawn with \a color. Bits that are - * 0 in the \a bitmap are drawn with the inverse of \a color. The pixel at - * (\a x, \a y) will be the top-left corner of the drawn image. - * - * \sa drawInvertedBitmap(), fill() - */ -void Bitmap::drawBitmap(int x, int y, Bitmap::ProgMem bitmap, Color color) -{ - uint8_t w = pgm_read_byte(bitmap); - uint8_t s = (w + 7) >> 3; - uint8_t h = pgm_read_byte(bitmap + 1); - Color invColor = !color; - for (uint8_t by = 0; by < h; ++by) { - const uint8_t *line = ((const uint8_t *)bitmap) + 2 + by * s; - uint8_t mask = 0x80; - uint8_t value = pgm_read_byte(line); - for (uint8_t bx = 0; bx < w; ++bx) { - if (value & mask) - setPixel(x + bx, y + by, color); - else - setPixel(x + bx, y + by, invColor); - mask >>= 1; - if (!mask) { - mask = 0x80; - ++line; - value = pgm_read_byte(line); - } - } - } -} - -/** - * \fn void Bitmap::drawInvertedBitmap(int x, int y, const Bitmap &bitmap) - * \brief Draws \a bitmap at (\a x, \a y) in inverted colors. - * - * This is a convenience function that is equivalent to - * drawBitmap(\a x, \a y, \a bitmap, \ref Black). - * - * \sa drawBitmap() - */ - -/** - * \fn void Bitmap::drawInvertedBitmap(int x, int y, Bitmap::ProgMem bitmap) - * \brief Draws \a bitmap at (\a x, \a y) in inverted colors. - * - * This is a convenience function that is equivalent to - * drawBitmap(\a x, \a y, \a bitmap, \ref Black). - * - * \sa drawBitmap() - */ - -/** - * \fn Font Bitmap::font() const - * \brief Returns the currently selected font, or null if none selected. - * - * \sa setFont(), drawText(), drawChar(), charWidth() - */ - -/** - * \fn void Bitmap::setFont(Font font) - * \brief Sets the \a font for use with drawText() and drawChar(). - * - * \code - * #include - * - * display.setFont(DejaVuSans9); - * display.drawText(0, 0, "Hello"); - * \endcode - * - * New fonts can be generated with GLCDFontCreator2. - * - * \sa font(), drawText(), drawChar() - */ - -/** - * \fn Color Bitmap::textColor() const - * \brief Returns the color that will be used for drawing text with - * drawText() and drawChar(). The default is \ref White. - * - * \sa setTextColor(), drawText(), drawChar() - */ - -/** - * \fn void Bitmap::setTextColor(Color textColor) - * \brief Sets the \a color that will be used for drawing text with - * drawText() and drawChar(). - * - * \sa textColor(), drawText(), drawChar() - */ - -#define fontIsFixed(font) (pgm_read_byte((font)) == 0 && \ - pgm_read_byte((font) + 1) == 0) -#define fontWidth(font) (pgm_read_byte((font) + 2)) -#define fontHeight(font) (pgm_read_byte((font) + 3)) -#define fontFirstChar(font) (pgm_read_byte((font) + 4)) -#define fontCharCount(font) (pgm_read_byte((font) + 5)) - -/** - * \brief Draws the \a len characters of \a str at (\a x, \a y). - * - * If \a len is less than zero, then the actual length of \a str will be used. - * - * The position (\a x, \a y) will be the upper-left pixel of the first - * character that is drawn. - * - * \sa drawChar(), textColor(), font() - */ -void Bitmap::drawText(int x, int y, const char *str, int len) -{ - if (!_font) - return; - uint8_t height = fontHeight(_font); - if (len < 0) - len = strlen(str); - while (len-- > 0) { - x += drawChar(x, y, *str++); - if (len > 0) { - fill(x, y, 1, height, !_textColor); - ++x; - } - if (x >= _width) - break; - } -} - -/** - * \brief Draws \a len characters starting at \a start from \a str to the - * screen at (\a x, \a y). - * - * If \a len is less than zero, then the actual length of \a str will be used. - * - * The position (\a x, \a y) will be the upper-left pixel of the first - * character that is drawn. - * - * \sa drawChar(), textColor(), font() - */ -void Bitmap::drawText(int x, int y, const String &str, int start, int len) -{ - if (!_font) - return; - uint8_t height = fontHeight(_font); - if (len < 0) - len = str.length() - start; - while (len-- > 0) { - x += drawChar(x, y, str[start++]); - if (len > 0) { - fill(x, y, 1, height, !_textColor); - ++x; - } - if (x >= _width) - break; - } -} - -/** - * \brief Draws a single character \a ch at (\a x, \a y). - * - * Returns the width of the character in pixels so that higher-order functions - * like drawText() can advance \a x to the location of the next character - * to be drawn. The width does not include inter-character spacing. - * - * The position (\a x, \a y) will be the upper-left pixel of the drawn - * character. - * - * \sa drawText(), textColor(), font(), charWidth() - */ -int Bitmap::drawChar(int x, int y, char ch) -{ - uint8_t height = fontHeight(_font); - if (ch == ' ') { - // Font may not have space, or it is zero-width. Calculate - // the real size and fill the space. - int spaceWidth = charWidth('n'); - fill(x, y, spaceWidth, height, !_textColor); - return spaceWidth; - } - uint8_t first = fontFirstChar(_font); - uint8_t count = fontCharCount(_font); - uint8_t index = (uint8_t)ch; - if (index < first || index >= (first + count)) - return 0; - index -= first; - uint8_t heightBytes = (height + 7) >> 3;; - uint8_t width; - const uint8_t *image; - if (fontIsFixed(_font)) { - // Fixed-width font. - width = fontWidth(_font); - image = ((const uint8_t *)_font) + 6 + index * heightBytes * width; - } else { - // Variable-width font. - width = pgm_read_byte(_font + 6 + index); - image = ((const uint8_t *)_font) + 6 + count; - for (uint8_t temp = 0; temp < index; ++temp) { - // Scan through all previous characters to find the starting - // location for this one. - image += pgm_read_byte(_font + 6 + temp) * heightBytes; - } - } - if ((x + width) <= 0 || (y + height) <= 0) - return width; // Character is off the top or left of the screen. - Color invColor = !_textColor; - for (uint8_t cx = 0; cx < width; ++cx) { - for (uint8_t cy = 0; cy < heightBytes; ++cy) { - uint8_t value = pgm_read_byte(image + cy * width + cx); - int posn; - if (heightBytes > 1 && cy == (heightBytes - 1)) - posn = height - 8; - else - posn = cy * 8; - for (uint8_t bit = 0; bit < 8; ++bit) { - if ((posn + bit) >= (cy * 8) && (posn + bit) <= height) { - if (value & 0x01) - setPixel(x + cx, y + posn + bit, _textColor); - else - setPixel(x + cx, y + posn + bit, invColor); - } - value >>= 1; - } - } - } - return width; -} - -/** - * \brief Returns the width in pixels of \a ch in the current font(). - * - * Returns zero if font() is not set, or \a ch is not present in font(). - * - * \sa drawChar(), font(), textWidth(), textHeight() - */ -int Bitmap::charWidth(char ch) const -{ - uint8_t index = (uint8_t)ch; - if (!_font) - return 0; - uint8_t first = fontFirstChar(_font); - uint8_t count = fontCharCount(_font); - if (index == ' ') - index = 'n'; // In case the font does not contain space. - if (index < first || index >= (first + count)) - return 0; - if (fontIsFixed(_font)) - return fontWidth(_font); - else - return pgm_read_byte(_font + 6 + (index - first)); -} - -/** - * \brief Returns the width in pixels of the \a len characters of \a str - * in the current font(), including inter-character spacing. - * - * If \a len is less than zero, then the actual length of \a str will be used. - * - * \sa drawText(), charWidth(), textHeight() - */ -int Bitmap::textWidth(const char *str, int len) const -{ - int width = 0; - if (len < 0) - len = strlen(str); - while (len-- > 0) { - width += charWidth(*str++); - if (len > 0) - ++width; - } - return width; -} - -/** - * \brief Returns the width in pixels of the \a len characters of \a str - * in the current font(), starting at \a start, including inter-character - * spacing. - * - * If \a len is less than zero, then the actual length of \a str will be used. - * - * \sa drawText(), charWidth(), textHeight() - */ -int Bitmap::textWidth(const String &str, int start, int len) const -{ - int width = 0; - if (len < 0) - len = str.length() - start; - while (len-- > 0) { - width += charWidth(str[start++]); - if (len > 0) - ++width; - } - return width; -} - -/** - * \brief Returns the height in pixels of the current text drawing font(); - * or zero if font() is not set. - * - * \sa font(), charWidth(), textWidth() - */ -int Bitmap::textHeight() const -{ - if (_font) - return fontHeight(_font); - else - return 0; -} - -/** - * \brief Copies the \a width x \a height pixels starting at top-left - * corner (\a x, \a y) to (\a destX, \a destY) in the bitmap \a dest. - * - * The \a dest bitmap can be the same as this object, in which case the copy - * will be performed in a manner that correctly handles overlapping regions. - * - * If some part of the source region is outside the bounds of this object, - * then the value \ref Black will be copied to \a dest for those pixels. - * This can be used to produce a behaviour similar to scroll() when - * \a bitmap is the same as this object. - * - * \sa drawBitmap(), fill(), scroll() - */ -void Bitmap::copy(int x, int y, int width, int height, Bitmap *dest, int destX, int destY) -{ - if (dest == this) { - // Copying to within the same bitmap, so copy in a direction - // that will prevent problems with overlap. - blit(x, y, x + width - 1, y + height - 1, destX, destY); - } else { - // Copying to a different bitmap. - while (height > 0) { - for (int tempx = 0; tempx < width; ++tempx) - dest->setPixel(destX + tempx, destY, pixel(x + tempx, y)); - ++y; - ++destY; - --height; - } - } -} - -/** - * \brief Fills the \a width x \a height pixels starting at top-left - * corner (\a x, \a y) with \a color. - * - * \sa copy(), clear(), invert(), drawRect() - */ -void Bitmap::fill(int x, int y, int width, int height, Color color) -{ - while (height > 0) { - for (int temp = 0; temp < width; ++temp) - setPixel(x + temp, y, color); - ++y; - --height; - } -} - -/** - * \brief Fills the \a width x \a height pixels starting at top-left - * corner (\a x, \a y) with the contents of \a pattern. - * - * The \a pattern must point to program memory. The first two bytes are the - * width and height of the pattern in pixels. The rest of the data contains - * the pixels for the pattern, with lines byte-aligned. - * - * Bits that are 1 in the \a pattern are drawn with \a color. Bits that are - * 0 in the \a pattern are drawn with the inverse of \a color. - * - * \sa drawBitmap(), clear(), invert() - */ -void Bitmap::fill(int x, int y, int width, int height, Bitmap::ProgMem pattern, Color color) -{ - uint8_t w = pgm_read_byte(pattern); - uint8_t s = (w + 7) >> 3; - uint8_t h = pgm_read_byte(pattern + 1); - if (!w || !h) - return; - Color invColor = !color; - for (int tempy = 0; tempy < height; ++tempy) { - const uint8_t *startLine = ((const uint8_t *)pattern) + 2 + (tempy % h) * s; - const uint8_t *line = startLine; - uint8_t mask = 0x80; - uint8_t value = pgm_read_byte(line++); - int bit = 0; - for (int tempx = 0; tempx < width; ++tempx) { - if (value & mask) - setPixel(x + tempx, y + tempy, color); - else - setPixel(x + tempx, y + tempy, invColor); - if (++bit >= w) { - mask = 0x80; - line = startLine; - value = pgm_read_byte(line++); - bit = 0; - } else { - mask >>= 1; - if (!mask) { - mask = 0x80; - value = pgm_read_byte(line++); - } - } - } - } -} - -/** - * \fn void Bitmap::scroll(int dx, int dy, Color fillColor) - * \brief Scrolls the entire contents of the bitmap by \a dx and \a dy. - * - * If \a dx is 2 and \a dy is -1, then the region will be scrolled two - * pixels to the right and one pixel up. Pixels that are uncovered - * by the scroll are filled with \a fillColor. - * - * \sa copy(), fill() - */ - -/** - * \brief Scrolls the \a width x \a height pixels starting at top-left - * corner (\a x, \a y) by \a dx and \a dy. - * - * If \a dx is 2 and \a dy is -1, then the region will be scrolled two - * pixels to the right and one pixel up. Pixels that are uncovered - * by the scroll are filled with \a fillColor. - * - * \sa copy(), fill() - */ -void Bitmap::scroll(int x, int y, int width, int height, int dx, int dy, Color fillColor) -{ - // Bail out if no scrolling at all. - if (!dx && !dy) - return; - - // Clamp the scroll region to the extents of the bitmap. - if (x < 0) { - width += x; - x = 0; - } - if (y < 0) { - height += y; - y = 0; - } - if ((x + width) > _width) - width = _width - x; - if ((y + height) > _height) - height = _height - y; - if (width <= 0 || height <= 0) - return; - - // Scroll the region in the specified direction. - if (dy < 0) { - if (dx < 0) - blit(x - dx, y - dy, x + width - 1 + dx, y + height - 1 + dy, x, y); - else - blit(x, y - dy, x + width - 1 - dx, y + height - 1 + dy, x + dx, y); - } else { - if (dx < 0) - blit(x - dx, y, x + width - 1 + dx, y + height - 1 - dy, x, y + dy); - else - blit(x, y, x + width - 1 - dx, y + height - 1 - dy, x + dx, y + dy); - } - - // Fill the pixels that were uncovered by the scroll. - if (dy < 0) { - fill(x, y + height + dy, width, -dy, fillColor); - if (dx < 0) - fill(x + width + dx, y, -dx, height + dy, fillColor); - else if (dx > 0) - fill(x, y, dx, height + dy, fillColor); - } else if (dy > 0) { - fill(x, y, width, -dy, fillColor); - if (dx < 0) - fill(x + width + dx, y + dy, -dx, height - dy, fillColor); - else if (dx > 0) - fill(x, y + dy, dx, height - dy, fillColor); - } else if (dx < 0) { - fill(x + width + dx, y, -dx, height, fillColor); - } else if (dx > 0) { - fill(x, y, dx, height, fillColor); - } -} - -/** - * \brief Inverts the \a width x \a height pixels starting at top-left - * corner (\a x, \a y). - * - * \sa fill() - */ -void Bitmap::invert(int x, int y, int width, int height) -{ - while (height > 0) { - for (int tempx = x + width - 1; tempx >= x; --tempx) - setPixel(tempx, y, !pixel(tempx, y)); - --height; - ++y; - } -} - -void Bitmap::blit(int x1, int y1, int x2, int y2, int x3, int y3) -{ - if (y3 < y1 || (y1 == y3 && x3 <= x1)) { - for (int tempy = y1; tempy <= y2; ++tempy) { - int y = y1 - tempy + y3; - int x = x3 - x1; - for (int tempx = x1; tempx <= x2; ++tempx) - setPixel(x + tempx, y, pixel(tempx, tempy)); - } - } else { - for (int tempy = y2; tempy >= y1; --tempy) { - int y = y1 - tempy + y3; - int x = x3 - x1; - for (int tempx = x2; tempx >= x1; --tempx) - setPixel(x + tempx, y, pixel(tempx, tempy)); - } - } -} - -void Bitmap::drawCirclePoints(int centerX, int centerY, int radius, int x, int y, Color borderColor, Color fillColor) -{ - if (x != y) { - setPixel(centerX + x, centerY + y, borderColor); - setPixel(centerX + y, centerY + x, borderColor); - setPixel(centerX + y, centerY - x, borderColor); - setPixel(centerX + x, centerY - y, borderColor); - setPixel(centerX - x, centerY - y, borderColor); - setPixel(centerX - y, centerY - x, borderColor); - setPixel(centerX - y, centerY + x, borderColor); - setPixel(centerX - x, centerY + y, borderColor); - if (fillColor != NoFill) { - if (radius > 1) { - drawLine(centerX - x + 1, centerY + y, centerX + x - 1, centerY + y, fillColor); - drawLine(centerX - y + 1, centerY + x, centerX + y - 1, centerY + x, fillColor); - drawLine(centerX - x + 1, centerY - y, centerX + x - 1, centerY - y, fillColor); - drawLine(centerX - y + 1, centerY - x, centerX + y - 1, centerY - x, fillColor); - } else if (radius == 1) { - setPixel(centerX, centerY, fillColor); - } - } - } else { - setPixel(centerX + x, centerY + y, borderColor); - setPixel(centerX + y, centerY - x, borderColor); - setPixel(centerX - x, centerY - y, borderColor); - setPixel(centerX - y, centerY + x, borderColor); - if (fillColor != NoFill) { - if (radius > 1) { - drawLine(centerX - x + 1, centerY + y, centerX + x - 1, centerY + y, fillColor); - drawLine(centerX - x + 1, centerY - y, centerX + x - 1, centerY - y, fillColor); - } else if (radius == 1) { - setPixel(centerX, centerY, fillColor); - } - } - } -} diff --git a/libraries/DMD/Bitmap.h b/libraries/DMD/Bitmap.h deleted file mode 100644 index db0a2be3..00000000 --- a/libraries/DMD/Bitmap.h +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#ifndef Bitmap_h -#define Bitmap_h - -#include -#include - -class DMD; -class String; - -class Bitmap -{ -public: - Bitmap(int width, int height); - ~Bitmap(); - - bool isValid() const { return fb != 0; } - - typedef uint8_t Color; - typedef PGM_VOID_P ProgMem; - typedef PGM_VOID_P Font; - - static const Color Black = 0; - static const Color White = 1; - static const Color NoFill = 2; - - int width() const { return _width; } - int height() const { return _height; } - int stride() const { return _stride; } - int bitsPerPixel() const { return 1; } - - uint8_t *data() { return fb; } - const uint8_t *data() const { return fb; } - - void clear(Color color = Black); - - Color pixel(int x, int y) const; - void setPixel(int x, int y, Color color); - - void drawLine(int x1, int y1, int x2, int y2, Color color = White); - void drawRect(int x1, int y1, int x2, int y2, Color borderColor = White, Color fillColor = NoFill); - void drawFilledRect(int x1, int y1, int x2, int y2, Color color = White); - void drawCircle(int centerX, int centerY, int radius, Color borderColor = White, Color fillColor = NoFill); - void drawFilledCircle(int centerX, int centerY, int radius, Color color = White); - - void drawBitmap(int x, int y, const Bitmap &bitmap, Color color = White); - void drawBitmap(int x, int y, Bitmap::ProgMem bitmap, Color color = White); - void drawInvertedBitmap(int x, int y, const Bitmap &bitmap); - void drawInvertedBitmap(int x, int y, Bitmap::ProgMem bitmap); - - Font font() const { return _font; } - void setFont(Font font) { _font = font; } - - Color textColor() const { return _textColor; } - void setTextColor(Color color) { _textColor = color; } - - void drawText(int x, int y, const char *str, int len = -1); - void drawText(int x, int y, const String &str, int start = 0, int len = -1); - - int drawChar(int x, int y, char ch); - - int charWidth(char ch) const; - int textWidth(const char *str, int len = -1) const; - int textWidth(const String &str, int start = 0, int len = -1) const; - int textHeight() const; - - void copy(int x, int y, int width, int height, Bitmap *dest, int destX, int destY); - void fill(int x, int y, int width, int height, Color color); - void fill(int x, int y, int width, int height, Bitmap::ProgMem pattern, Color color = White); - - void scroll(int dx, int dy, Color fillColor = Black); - void scroll(int x, int y, int width, int height, int dx, int dy, Color fillColor = Black); - - void invert(int x, int y, int width, int height); - -private: - // Disable copy constructor and operator=(). - Bitmap(const Bitmap &) {} - Bitmap &operator=(const Bitmap &) { return *this; } - - int _width; - int _height; - int _stride; - uint8_t *fb; - Font _font; - Color _textColor; - - friend class DMD; - - void blit(int x1, int y1, int x2, int y2, int x3, int y3); - void drawCirclePoints(int centerX, int centerY, int radius, int x, int y, Color borderColor, Color fillColor); -}; - -inline void Bitmap::drawFilledRect(int x1, int y1, int x2, int y2, Color color) -{ - drawRect(x1, y1, x2, y2, color, color); -} - -inline void Bitmap::drawFilledCircle(int centerX, int centerY, int radius, Color color) -{ - drawCircle(centerX, centerY, radius, color, color); -} - -inline void Bitmap::drawInvertedBitmap(int x, int y, const Bitmap &bitmap) -{ - drawBitmap(x, y, bitmap, Black); -} - -inline void Bitmap::drawInvertedBitmap(int x, int y, Bitmap::ProgMem bitmap) -{ - drawBitmap(x, y, bitmap, Black); -} - -inline void Bitmap::scroll(int dx, int dy, Color fillColor) -{ - scroll(0, 0, _width, _height, dx, dy, fillColor); -} - -#endif diff --git a/libraries/DMD/DMD.cpp b/libraries/DMD/DMD.cpp deleted file mode 100644 index 547c48d7..00000000 --- a/libraries/DMD/DMD.cpp +++ /dev/null @@ -1,696 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#include "DMD.h" -#if defined(ARDUINO) && ARDUINO >= 100 -#include -#else -#include -#endif -#include -#include -#include -#include -#include - -/** - * \class DMD DMD.h - * \brief Handle large dot matrix displays composed of LED's. - * - * This class is designed for use with - * Freetronics Large Dot Matrix - * Displays. These displays have 512 LED's arranged in a 32x16 matrix - * and controlled by an SPI interface. The displays are available in - * red, blue, green, yellow, and white variations (for which this class - * always uses the constant \ref White regardless of the physical color). - * - * \section dmd_drawing Drawing - * - * DMD inherits from Bitmap so that any of the drawing functions in that - * class can be used to draw directly to dot matrix displays. The following - * example initializes a single display panel and draws a rectangle and a - * circle into it at setup time: - * - * \code - * #include - * - * DMD display; - * - * void setup() { - * display.drawRect(5, 2, 27, 13); - * display.drawCircle(16, 8, 4); - * } - * \endcode - * - * The display must be updated frequently from the application's main loop: - * - * \code - * void loop() { - * display.loop(); - * } - * \endcode - * - * \section dmd_interrupts Interrupt-driven display refresh - * - * The loop() method simplifies updating the display from the application's - * main loop but it can sometimes be inconvenient to arrange for it to be - * called regularly, especially if the application wishes to use - * delay() or delayMicroseconds(). - * - * DMD provides an asynchronous display update mechanism using Timer1 - * interrupts. The application turns on interrupts using enableTimer1() - * and then calls refresh() from the interrupt service routine: - * - * \code - * #include - * - * DMD display; - * - * ISR(TIMER1_OVF_vect) - * { - * display.refresh(); - * } - * - * void setup() { - * display.enableTimer1(); - * } - * \endcode - * - * If Timer1 is already in use by some other part of your application, - * then Timer2 can be used as an alternative interrupt source: - * - * \code - * #include - * - * DMD display; - * - * ISR(TIMER2_OVF_vect) - * { - * display.refresh(); - * } - * - * void setup() { - * display.enableTimer2(); - * } - * \endcode - * - * DMD can also be used with third-party timer libraries such as - * TimerOne: - * - * \code - * #include - * #include - * - * DMD display; - * - * void refreshDisplay() - * { - * display.refresh(); - * } - * - * void setup() { - * Timer1.initialize(5000); - * Timer1.attachInterrupt(refreshDisplay); - * } - * \endcode - * - * \section dmd_double_buffer Double buffering - * - * When using interrupts, the system can sometimes exhibit "tearing" artifacts - * where half-finished images are displayed because an interrupt fired in - * the middle of a screen update. - * - * This problem can be alleviated using double buffering: all rendering is done - * to an off-screen buffer that is swapped onto the screen once it is ready - * for display. Rendering then switches to the other buffer that is now - * off-screen. The following example demonstrates this: - * - * \code - * #include - * - * DMD display; - * - * ISR(TIMER1_OVF_vect) - * { - * display.refresh(); - * } - * - * void setup() { - * display.setDoubleBuffer(true); - * display.enableTimer1(); - * } - * - * void loop() { - * updateDisplay(); - * display.swapBuffers(); - * delay(50); // Delay between frames. - * } - * - * void updateDisplay() { - * // Draw the new display contents into the off-screen buffer. - * display.clear(); - * ... - * } - * \endcode - * - * The downside of double buffering is that it uses twice as much main memory - * to manage the contents of the screen. - * - * \section dmd_multi Multiple panels - * - * Multiple panels can be daisy-chained together using ribbon cables. - * If there is a single row of panels, then they must be connected - * to the Arduino board as follows: - * - * \image html dmd-4x1.png - * - * If there are multiple rows of panels, then alternating rows are - * flipped upside-down so that the short ribbon cables provided by - * Freetronics reach (this technique is thanks to Chris Debenham; see - * http://www.adebenham.com/category/arduino/dmd/ for more details): - * - * \image html dmd-4x2.png - * - * This technique can be repeated for as many rows as required, with the - * bottom row always right-way-up: - * - * \image html dmd-4x3.png - * - * DMD automatically takes care of flipping the data for panels in the - * alternating rows. No special action is required by the user except - * to physically connect the panels as shown and to initialize the DMD - * class appropriately: - * - * \code - * #include - * - * DMD display(4, 2); // 4 panels wide, 2 panels high - * \endcode - */ - -// Pins on the DMD connector board. -#define DMD_PIN_PHASE_LSB 6 // A -#define DMD_PIN_PHASE_MSB 7 // B -#define DMD_PIN_LATCH 8 // SCLK -#define DMD_PIN_OUTPUT_ENABLE 9 // nOE -#define DMD_PIN_SPI_SS SS // SPI Slave Select -#define DMD_PIN_SPI_MOSI MOSI // SPI Master Out, Slave In (R) -#define DMD_PIN_SPI_MISO MISO // SPI Master In, Slave Out -#define DMD_PIN_SPI_SCK SCK // SPI Serial Clock (CLK) - -// Dimension information for the display. -#define DMD_NUM_COLUMNS 32 // Number of columns in a panel. -#define DMD_NUM_ROWS 16 // Number of rows in a panel. - -// Refresh times. -#define DMD_REFRESH_MS 5 -#define DMD_REFRESH_US 5000 - -/** - * \brief Constructs a new dot matrix display handler for a display that - * is \a widthPanels x \a heightPanels in size. - * - * Note: the parameters to this constructor are specified in panels, - * whereas width() and height() are specified in pixels. - * - * \sa width(), height() - */ -DMD::DMD(int widthPanels, int heightPanels) - : Bitmap(widthPanels * DMD_NUM_COLUMNS, heightPanels * DMD_NUM_ROWS) - , _doubleBuffer(false) - , phase(0) - , fb0(0) - , fb1(0) - , displayfb(0) - , lastRefresh(millis()) -{ - // Both rendering and display are to fb0 initially. - fb0 = displayfb = fb; - - // Initialize SPI to MSB-first, mode 0, clock divider = 2. - pinMode(DMD_PIN_SPI_SCK, OUTPUT); - pinMode(DMD_PIN_SPI_MOSI, OUTPUT); - pinMode(DMD_PIN_SPI_SS, OUTPUT); - digitalWrite(DMD_PIN_SPI_SCK, LOW); - digitalWrite(DMD_PIN_SPI_MOSI, LOW); - digitalWrite(DMD_PIN_SPI_SS, HIGH); - SPCR |= _BV(MSTR); - SPCR |= _BV(SPE); - SPCR &= ~(_BV(DORD)); // MSB-first - SPCR &= ~0x0C; // Mode 0 - SPCR &= ~0x03; // Clock divider rate 2 - SPSR |= 0x01; // MSB of clock divider rate - - // Initialize the DMD-specific pins. - pinMode(DMD_PIN_PHASE_LSB, OUTPUT); - pinMode(DMD_PIN_PHASE_MSB, OUTPUT); - pinMode(DMD_PIN_LATCH, OUTPUT); - pinMode(DMD_PIN_OUTPUT_ENABLE, OUTPUT); - digitalWrite(DMD_PIN_PHASE_LSB, LOW); - digitalWrite(DMD_PIN_PHASE_MSB, LOW); - digitalWrite(DMD_PIN_LATCH, LOW); - digitalWrite(DMD_PIN_OUTPUT_ENABLE, LOW); - digitalWrite(DMD_PIN_SPI_MOSI, HIGH); -} - -/** - * \brief Destroys this dot matrix display handler. - */ -DMD::~DMD() -{ - if (fb0) - free(fb0); - if (fb1) - free(fb1); - fb = 0; // Don't free the buffer again in the base class. -} - -/** - * \fn bool DMD::doubleBuffer() const - * \brief Returns true if the display is double-buffered; false if - * single-buffered. The default is false. - * - * \sa setDoubleBuffer(), swapBuffers(), refresh() - */ - -/** - * \brief Enables or disables double-buffering according to \a doubleBuffer. - * - * When double-buffering is enabled, rendering operations are sent to a - * memory buffer that isn't currently displayed on-screen. Once the - * application has completed the screen update, it calls swapBuffers() - * to display the current buffer and switch rendering to the other - * now invisible buffer. - * - * Double-buffering is recommended if refresh() is being called from an - * interrupt service routine, to prevent "tearing" artifacts that result - * from simultaneous update of a single shared buffer. - * - * This function will allocate memory for the extra buffer when - * \a doubleBuffer is true. If there is insufficient memory for the - * second screen buffer, then this class will revert to single-buffered mode. - * - * \sa doubleBuffer(), swapBuffers(), refresh() - */ -void DMD::setDoubleBuffer(bool doubleBuffer) -{ - if (doubleBuffer != _doubleBuffer) { - _doubleBuffer = doubleBuffer; - if (doubleBuffer) { - // Allocate a new back buffer. - unsigned int size = _stride * _height; - fb1 = (uint8_t *)malloc(size); - - // Clear the new back buffer and then switch to it, leaving - // the current contents of fb0 on the screen. - if (fb1) { - memset(fb1, 0xFF, size); - cli(); - fb = fb1; - displayfb = fb0; - sei(); - } else { - // Failed to allocate the memory, so revert to single-buffered. - _doubleBuffer = false; - } - } else if (fb1) { - // Disabling double-buffering, so forcibly switch to fb0. - cli(); - fb = fb0; - displayfb = fb0; - sei(); - - // Free the unnecessary buffer. - free(fb1); - fb1 = 0; - } - } -} - -/** - * \brief Swaps the buffers that are used for rendering to the display. - * - * When doubleBuffer() is false, this function does nothing. - * Otherwise the front and back rendering buffers are swapped. - * See the description of setDoubleBuffer() for more information. - * - * The new rendering back buffer will have undefined contents and will - * probably need to be re-inialized with clear() or fill() before - * drawing to it. The swapBuffersAndCopy() function can be used instead - * to preserve the screen contents from one frame to the next. - * - * \sa swapBuffersAndCopy(), setDoubleBuffer() - */ -void DMD::swapBuffers() -{ - if (_doubleBuffer) { - // Turn off interrupts while swapping buffers so that we don't - // accidentally try to refresh() in the middle of this code. - cli(); - if (fb == fb0) { - fb = fb1; - displayfb = fb0; - } else { - fb = fb0; - displayfb = fb1; - } - sei(); - } -} - -/** - * \brief Swaps the buffers that are used for rendering to the display - * and copies the former back buffer contents to the new back buffer. - * - * Normally when swapBuffers() is called, the new rendering back buffer - * will have undefined contents from two frames prior and must be cleared - * with clear() or fill() before writing new contents to it. - * This function instead copies the previous frame into the new - * rendering buffer so that it can be updated in-place. - * - * This function is useful if the screen does not change much from one - * frame to the next. If the screen changes a lot between frames, then it - * is usually better to explicitly clear() or fill() the new back buffer. - * - * \sa swapBuffers(), setDoubleBuffer() - */ -void DMD::swapBuffersAndCopy() -{ - swapBuffers(); - if (_doubleBuffer) - memcpy(fb, displayfb, _stride * _height); -} - -/** - * \brief Performs regular display refresh activities from the - * application's main loop. - * - * \code - * DMD display; - * - * void loop() { - * display.loop(); - * } - * \endcode - * - * If you are using a timer interrupt service routine, then call - * refresh() in response to the interrupt instead of calling loop(). - * - * \sa refresh() - */ -void DMD::loop() -{ - unsigned long currentTime = millis(); - if ((currentTime - lastRefresh) >= DMD_REFRESH_MS) { - lastRefresh = currentTime; - refresh(); - } -} - -// Send a single byte via SPI. -static inline void spiSend(byte value) -{ - SPDR = value; - while (!(SPSR & _BV(SPIF))) - ; // Wait for the transfer to complete. -} - -// Flip the bits in a byte. Table generated by genflip.c -static const uint8_t flipBits[256] PROGMEM = { - 0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0, 0x10, 0x90, 0x50, 0xD0, - 0x30, 0xB0, 0x70, 0xF0, 0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8, - 0x18, 0x98, 0x58, 0xD8, 0x38, 0xB8, 0x78, 0xF8, 0x04, 0x84, 0x44, 0xC4, - 0x24, 0xA4, 0x64, 0xE4, 0x14, 0x94, 0x54, 0xD4, 0x34, 0xB4, 0x74, 0xF4, - 0x0C, 0x8C, 0x4C, 0xCC, 0x2C, 0xAC, 0x6C, 0xEC, 0x1C, 0x9C, 0x5C, 0xDC, - 0x3C, 0xBC, 0x7C, 0xFC, 0x02, 0x82, 0x42, 0xC2, 0x22, 0xA2, 0x62, 0xE2, - 0x12, 0x92, 0x52, 0xD2, 0x32, 0xB2, 0x72, 0xF2, 0x0A, 0x8A, 0x4A, 0xCA, - 0x2A, 0xAA, 0x6A, 0xEA, 0x1A, 0x9A, 0x5A, 0xDA, 0x3A, 0xBA, 0x7A, 0xFA, - 0x06, 0x86, 0x46, 0xC6, 0x26, 0xA6, 0x66, 0xE6, 0x16, 0x96, 0x56, 0xD6, - 0x36, 0xB6, 0x76, 0xF6, 0x0E, 0x8E, 0x4E, 0xCE, 0x2E, 0xAE, 0x6E, 0xEE, - 0x1E, 0x9E, 0x5E, 0xDE, 0x3E, 0xBE, 0x7E, 0xFE, 0x01, 0x81, 0x41, 0xC1, - 0x21, 0xA1, 0x61, 0xE1, 0x11, 0x91, 0x51, 0xD1, 0x31, 0xB1, 0x71, 0xF1, - 0x09, 0x89, 0x49, 0xC9, 0x29, 0xA9, 0x69, 0xE9, 0x19, 0x99, 0x59, 0xD9, - 0x39, 0xB9, 0x79, 0xF9, 0x05, 0x85, 0x45, 0xC5, 0x25, 0xA5, 0x65, 0xE5, - 0x15, 0x95, 0x55, 0xD5, 0x35, 0xB5, 0x75, 0xF5, 0x0D, 0x8D, 0x4D, 0xCD, - 0x2D, 0xAD, 0x6D, 0xED, 0x1D, 0x9D, 0x5D, 0xDD, 0x3D, 0xBD, 0x7D, 0xFD, - 0x03, 0x83, 0x43, 0xC3, 0x23, 0xA3, 0x63, 0xE3, 0x13, 0x93, 0x53, 0xD3, - 0x33, 0xB3, 0x73, 0xF3, 0x0B, 0x8B, 0x4B, 0xCB, 0x2B, 0xAB, 0x6B, 0xEB, - 0x1B, 0x9B, 0x5B, 0xDB, 0x3B, 0xBB, 0x7B, 0xFB, 0x07, 0x87, 0x47, 0xC7, - 0x27, 0xA7, 0x67, 0xE7, 0x17, 0x97, 0x57, 0xD7, 0x37, 0xB7, 0x77, 0xF7, - 0x0F, 0x8F, 0x4F, 0xCF, 0x2F, 0xAF, 0x6F, 0xEF, 0x1F, 0x9F, 0x5F, 0xDF, - 0x3F, 0xBF, 0x7F, 0xFF -}; - -/** - * \brief Refresh the display. - * - * This function must be called at least once every 5 milliseconds - * for smooth non-flickering update of the display. It is usually - * called by loop(), but can also be called in response to a - * timer interrupt. - * - * If this function is called from an interrupt service routine, - * then it is recommended that double-buffering be enabled with - * setDoubleBuffer() to prevent "tearing" artifacts that result - * from simultaneous update of a single shared buffer. - * - * \sa loop(), setDoubleBuffer(), enableTimer1() - */ -void DMD::refresh() -{ - // Bail out if there is a conflict on the SPI bus. - if (!digitalRead(DMD_PIN_SPI_SS)) - return; - - // Transfer the data for the next group of interleaved rows. - int stride4 = _stride * 4; - uint8_t *data0; - uint8_t *data1; - uint8_t *data2; - uint8_t *data3; - bool flipRow = ((_height & 0x10) == 0); - for (int y = 0; y < _height; y += 16) { - if (!flipRow) { - // The panels in this row are the right way up. - data0 = displayfb + _stride * (y + phase); - data1 = data0 + stride4; - data2 = data1 + stride4; - data3 = data2 + stride4; - for (int x = _stride; x > 0; --x) { - spiSend(*data3++); - spiSend(*data2++); - spiSend(*data1++); - spiSend(*data0++); - } - flipRow = true; - } else { - // The panels in this row are upside-down and reversed. - data0 = displayfb + _stride * (y + 16 - phase) - 1; - data1 = data0 - stride4; - data2 = data1 - stride4; - data3 = data2 - stride4; - for (int x = _stride; x > 0; --x) { - spiSend(pgm_read_byte(&(flipBits[*data3--]))); - spiSend(pgm_read_byte(&(flipBits[*data2--]))); - spiSend(pgm_read_byte(&(flipBits[*data1--]))); - spiSend(pgm_read_byte(&(flipBits[*data0--]))); - } - flipRow = false; - } - } - - // Latch the data from the shift registers onto the actual display. - digitalWrite(DMD_PIN_OUTPUT_ENABLE, LOW); - digitalWrite(DMD_PIN_LATCH, HIGH); - digitalWrite(DMD_PIN_LATCH, LOW); - if (phase & 0x02) - digitalWrite(DMD_PIN_PHASE_MSB, HIGH); - else - digitalWrite(DMD_PIN_PHASE_MSB, LOW); - if (phase & 0x01) - digitalWrite(DMD_PIN_PHASE_LSB, HIGH); - else - digitalWrite(DMD_PIN_PHASE_LSB, LOW); - digitalWrite(DMD_PIN_OUTPUT_ENABLE, HIGH); - phase = (phase + 1) & 0x03; -} - -/** - * \brief Enables Timer1 overflow interrupts for updating this display. - * - * The application must also provide an interrupt service routine for - * Timer1 that calls refresh(): - * - * \code - * #include - * - * DMD display; - * - * ISR(TIMER1_OVF_vect) - * { - * display.refresh(); - * } - * - * void setup() { - * display.enableTimer1(); - * } - * \endcode - * - * If timer interrupts are being used to update the display, then it is - * unnecessary to call loop(). - * - * \sa refresh(), disableTimer1(), enableTimer2(), setDoubleBuffer() - */ -void DMD::enableTimer1() -{ - // Number of CPU cycles in the display's refresh period. - unsigned long numCycles = (F_CPU / 2000000) * DMD_REFRESH_US; - - // Determine the prescaler to be used. - #define TIMER1_RESOLUTION 65536UL - uint8_t prescaler; - if (numCycles < TIMER1_RESOLUTION) { - // No prescaling required. - prescaler = _BV(CS10); - } else if (numCycles < TIMER1_RESOLUTION * 8) { - // Prescaler = 8. - prescaler = _BV(CS11); - numCycles >>= 3; - } else if (numCycles < TIMER1_RESOLUTION * 64) { - // Prescaler = 64. - prescaler = _BV(CS11) | _BV(CS10); - numCycles >>= 6; - } else if (numCycles < TIMER1_RESOLUTION * 256) { - // Prescaler = 256. - prescaler = _BV(CS12); - numCycles >>= 8; - } else if (numCycles < TIMER1_RESOLUTION * 1024) { - // Prescaler = 1024. - prescaler = _BV(CS12) | _BV(CS10); - numCycles >>= 10; - } else { - // Too long, so set the maximum timeout. - prescaler = _BV(CS12) | _BV(CS10); - numCycles = TIMER1_RESOLUTION - 1; - } - - // Configure Timer1 for the period we want. - TCCR1A = 0; - TCCR1B = _BV(WGM13); - uint8_t saveSREG = SREG; - cli(); - ICR1 = numCycles; - SREG = saveSREG; // Implicit sei() if interrupts were on previously. - TCCR1B = (TCCR1B & ~(_BV(CS12) | _BV(CS11) | _BV(CS10))) | prescaler; - - // Turn on the Timer1 overflow interrupt. - TIMSK1 |= _BV(TOIE1); -} - -/** - * \brief Disables Timer1 overflow interrupts. - * - * \sa enableTimer1() - */ -void DMD::disableTimer1() -{ - // Turn off the Timer1 overflow interrupt. - TIMSK1 &= ~_BV(TOIE1); -} - -/** - * \brief Enables Timer2 overflow interrupts for updating this display. - * - * The application must also provide an interrupt service routine for - * Timer2 that calls refresh(): - * - * \code - * #include - * - * DMD display; - * - * ISR(TIMER2_OVF_vect) - * { - * display.refresh(); - * } - * - * void setup() { - * display.enableTimer2(); - * } - * \endcode - * - * If timer interrupts are being used to update the display, then it is - * unnecessary to call loop(). - * - * \sa refresh(), disableTimer2(), enableTimer1(), setDoubleBuffer() - */ -void DMD::enableTimer2() -{ - // Configure Timer2 for the period we want. With the prescaler set - // to 128, then 256 increments of Timer2 gives roughly 4 ms between - // overflows on a system with a 16 MHz clock. We adjust the prescaler - // accordingly for other clock frequencies. - TCCR2A = 0; - if (F_CPU >= 32000000) - TCCR2B = _BV(CS22) | _BV(CS21); // Prescaler = 256 - else if (F_CPU >= 16000000) - TCCR2B = _BV(CS22) | _BV(CS20); // Prescaler = 128 - else if (F_CPU >= 8000000) - TCCR2B = _BV(CS22); // Prescaler = 64 - else - TCCR2B = _BV(CS21) | _BV(CS20); // Prescaler = 32 - - // Reset Timer2 to kick off the process. - TCNT2 = 0; - - // Turn on the Timer2 overflow interrupt (also turn off OCIE2A and OCIE2B). - TIMSK2 = _BV(TOIE2); -} - -/** - * \brief Disables Timer2 overflow interrupts. - * - * \sa enableTimer2() - */ -void DMD::disableTimer2() -{ - // Turn off the Timer2 overflow interrupt. - TIMSK2 &= ~_BV(TOIE2); -} - -/** - * \brief Converts an RGB value into a pixel color value. - * - * Returns \ref White if any of \a r, \a g, or \a b are non-zero; - * otherwise returns \ref Black. - * - * This function is provided for upwards compatibility with future - * displays that support full color. Monochrome applications should - * use the \ref Black and \ref White constants directly. - */ -DMD::Color DMD::fromRGB(uint8_t r, uint8_t g, uint8_t b) -{ - if (r || g || b) - return White; - else - return Black; -} diff --git a/libraries/DMD/DMD.h b/libraries/DMD/DMD.h deleted file mode 100644 index e07a61c4..00000000 --- a/libraries/DMD/DMD.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#ifndef DMD_h -#define DMD_h - -#include "Bitmap.h" - -class DMD : public Bitmap -{ -public: - explicit DMD(int widthPanels = 1, int heightPanels = 1); - ~DMD(); - - bool doubleBuffer() const { return _doubleBuffer; } - void setDoubleBuffer(bool doubleBuffer); - void swapBuffers(); - void swapBuffersAndCopy(); - - void loop(); - void refresh(); - - void enableTimer1(); - void disableTimer1(); - - void enableTimer2(); - void disableTimer2(); - - static Color fromRGB(uint8_t r, uint8_t g, uint8_t b); - -private: - // Disable copy constructor and operator=(). - DMD(const DMD &other) : Bitmap(other) {} - DMD &operator=(const DMD &) { return *this; } - - bool _doubleBuffer; - uint8_t phase; - uint8_t *fb0; - uint8_t *fb1; - uint8_t *displayfb; - unsigned long lastRefresh; -}; - -#endif diff --git a/libraries/DMD/DejaVuSans9.h b/libraries/DMD/DejaVuSans9.h deleted file mode 100644 index 8ede679a..00000000 --- a/libraries/DMD/DejaVuSans9.h +++ /dev/null @@ -1,166 +0,0 @@ - - -/* - * - * DejaVuSans9 - * - * created with FontCreator - * written by F. Maximilian Thiele - * - * http://www.apetech.de/fontCreator - * me@apetech.de - * - * File Name : DejaVuSans9.h - * Date : 28.05.2012 - * Font size in bytes : 3962 - * Font width : 10 - * Font height : 10 - * Font first char : 32 - * Font last char : 128 - * Font used chars : 96 - * - * The font data are defined as - * - * struct _FONT_ { - * uint16_t font_Size_in_Bytes_over_all_included_Size_it_self; - * uint8_t font_Width_in_Pixel_for_fixed_drawing; - * uint8_t font_Height_in_Pixel_for_all_characters; - * unit8_t font_First_Char; - * uint8_t font_Char_Count; - * - * uint8_t font_Char_Widths[font_Last_Char - font_First_Char +1]; - * // for each character the separate width in pixels, - * // characters < 128 have an implicit virtual right empty row - * - * uint8_t font_data[]; - * // bit field of all characters - */ - -#include -#include - -#ifndef DEJAVUSANS9_H -#define DEJAVUSANS9_H - -#define DEJAVUSANS9_WIDTH 10 -#define DEJAVUSANS9_HEIGHT 10 - -static uint8_t const DejaVuSans9[] PROGMEM = { - 0x0F, 0x7A, // size - 0x0A, // width - 0x0A, // height - 0x20, // first char - 0x60, // char count - - // char widths - 0x00, 0x01, 0x03, 0x06, 0x05, 0x08, 0x06, 0x01, 0x02, 0x02, - 0x05, 0x05, 0x01, 0x02, 0x01, 0x03, 0x04, 0x03, 0x04, 0x04, - 0x05, 0x04, 0x04, 0x04, 0x04, 0x04, 0x01, 0x01, 0x06, 0x06, - 0x06, 0x04, 0x08, 0x06, 0x05, 0x05, 0x05, 0x04, 0x04, 0x05, - 0x05, 0x01, 0x02, 0x05, 0x04, 0x06, 0x05, 0x05, 0x04, 0x05, - 0x05, 0x05, 0x05, 0x05, 0x06, 0x07, 0x06, 0x05, 0x05, 0x02, - 0x03, 0x02, 0x04, 0x05, 0x02, 0x04, 0x04, 0x04, 0x04, 0x04, - 0x03, 0x04, 0x04, 0x01, 0x02, 0x04, 0x01, 0x07, 0x04, 0x04, - 0x04, 0x04, 0x03, 0x03, 0x04, 0x04, 0x05, 0x07, 0x05, 0x05, - 0x04, 0x03, 0x01, 0x03, 0x06, 0x05, - - // font data - 0xBE, 0x00, // 33 - 0x06, 0x00, 0x06, 0x00, 0x00, 0x00, // 34 - 0x28, 0xE8, 0x3E, 0xE8, 0x3E, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 35 - 0x98, 0x94, 0xFE, 0xA4, 0x64, 0x00, 0x00, 0x40, 0x00, 0x00, // 36 - 0x1E, 0x12, 0xDE, 0x30, 0x18, 0xF6, 0x90, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 37 - 0x60, 0x9C, 0x92, 0x62, 0xC4, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 38 - 0x06, 0x00, // 39 - 0x7E, 0x81, 0x00, 0x00, // 40 - 0xC3, 0x3C, 0x00, 0x00, // 41 - 0x12, 0x0C, 0x1E, 0x0C, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, // 42 - 0x20, 0x20, 0xF8, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, // 43 - 0x80, 0x40, // 44 - 0x20, 0x20, 0x00, 0x00, // 45 - 0x80, 0x00, // 46 - 0xC0, 0x38, 0x06, 0x00, 0x00, 0x00, // 47 - 0x7C, 0x82, 0x82, 0x7C, 0x00, 0x00, 0x00, 0x00, // 48 - 0x82, 0xFE, 0x80, 0x00, 0x00, 0x00, // 49 - 0xC4, 0xA2, 0x92, 0x8C, 0x00, 0x00, 0x00, 0x00, // 50 - 0x84, 0x92, 0x92, 0x6C, 0x00, 0x00, 0x00, 0x00, // 51 - 0x60, 0x58, 0x44, 0xFE, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, // 52 - 0x9E, 0x92, 0x92, 0x62, 0x00, 0x00, 0x00, 0x00, // 53 - 0x7C, 0x96, 0x92, 0x62, 0x00, 0x00, 0x00, 0x00, // 54 - 0x02, 0xC2, 0x3A, 0x06, 0x00, 0x00, 0x00, 0x00, // 55 - 0x6C, 0x92, 0x92, 0x6C, 0x00, 0x00, 0x00, 0x00, // 56 - 0x9C, 0x92, 0xD2, 0x7C, 0x00, 0x00, 0x00, 0x00, // 57 - 0x88, 0x00, // 58 - 0x88, 0x40, // 59 - 0x20, 0x20, 0x50, 0x50, 0x50, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 60 - 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 61 - 0x88, 0x50, 0x50, 0x50, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 62 - 0x02, 0xB2, 0x0A, 0x06, 0x00, 0x00, 0x00, 0x00, // 63 - 0x78, 0x84, 0x32, 0x4A, 0x4A, 0xFA, 0x44, 0x38, 0x00, 0x00, 0x40, 0x40, 0x40, 0x00, 0x00, 0x00, // 64 - 0xC0, 0x38, 0x26, 0x26, 0x38, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 65 - 0xFE, 0x92, 0x92, 0x92, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, // 66 - 0x7C, 0xC6, 0x82, 0x82, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, // 67 - 0xFE, 0x82, 0x82, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, // 68 - 0xFE, 0x92, 0x92, 0x92, 0x00, 0x00, 0x00, 0x00, // 69 - 0xFE, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, // 70 - 0x7C, 0xC6, 0x82, 0x92, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, // 71 - 0xFE, 0x10, 0x10, 0x10, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, // 72 - 0xFE, 0x00, // 73 - 0x00, 0xFE, 0x80, 0x40, // 74 - 0xFE, 0x10, 0x28, 0x44, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, // 75 - 0xFE, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, // 76 - 0xFE, 0x0C, 0x30, 0x30, 0x0C, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 77 - 0xFE, 0x0C, 0x10, 0x60, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, // 78 - 0x7C, 0xC6, 0x82, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, // 79 - 0xFE, 0x12, 0x12, 0x0C, 0x00, 0x00, 0x00, 0x00, // 80 - 0x7C, 0xC6, 0x82, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x40, 0x00, // 81 - 0xFE, 0x12, 0x32, 0x4E, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, // 82 - 0x4C, 0x92, 0x92, 0x92, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, // 83 - 0x02, 0x02, 0xFE, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, // 84 - 0x7E, 0x80, 0x80, 0x80, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, // 85 - 0x06, 0x38, 0xC0, 0xC0, 0x38, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 86 - 0x06, 0x38, 0xE0, 0x1E, 0xE0, 0x38, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 87 - 0x82, 0x46, 0x38, 0x38, 0xC6, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 88 - 0x02, 0x0C, 0xF0, 0x0C, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, // 89 - 0xC2, 0xA2, 0x92, 0x8A, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00, // 90 - 0xFE, 0x02, 0x40, 0x40, // 91 - 0x06, 0x38, 0xC0, 0x00, 0x00, 0x00, // 92 - 0x02, 0xFE, 0x40, 0x40, // 93 - 0x04, 0x02, 0x02, 0x04, 0x00, 0x00, 0x00, 0x00, // 94 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, // 95 - 0x01, 0x02, 0x00, 0x00, // 96 - 0xE0, 0xA8, 0xA8, 0xF8, 0x00, 0x00, 0x00, 0x00, // 97 - 0xFF, 0x88, 0x88, 0x70, 0x00, 0x00, 0x00, 0x00, // 98 - 0x70, 0x88, 0x88, 0x88, 0x00, 0x00, 0x00, 0x00, // 99 - 0x70, 0x88, 0x88, 0xFF, 0x00, 0x00, 0x00, 0x00, // 100 - 0x70, 0xA8, 0xA8, 0xB0, 0x00, 0x00, 0x00, 0x00, // 101 - 0x08, 0xFF, 0x09, 0x00, 0x00, 0x00, // 102 - 0x70, 0x88, 0x88, 0xF8, 0x00, 0x80, 0x80, 0x40, // 103 - 0xFF, 0x08, 0x08, 0xF8, 0x00, 0x00, 0x00, 0x00, // 104 - 0xFA, 0x00, // 105 - 0x00, 0xFA, 0x80, 0xC0, // 106 - 0xFF, 0x20, 0x50, 0x88, 0x00, 0x00, 0x00, 0x00, // 107 - 0xFF, 0x00, // 108 - 0xF8, 0x08, 0x08, 0xF8, 0x08, 0x08, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 109 - 0xF8, 0x08, 0x08, 0xF8, 0x00, 0x00, 0x00, 0x00, // 110 - 0x70, 0x88, 0x88, 0x70, 0x00, 0x00, 0x00, 0x00, // 111 - 0xF8, 0x88, 0x88, 0x70, 0xC0, 0x00, 0x00, 0x00, // 112 - 0x70, 0x88, 0x88, 0xF8, 0x00, 0x00, 0x00, 0xC0, // 113 - 0xF8, 0x08, 0x08, 0x00, 0x00, 0x00, // 114 - 0x98, 0xA8, 0xE8, 0x00, 0x00, 0x00, // 115 - 0x08, 0xFC, 0x88, 0x88, 0x00, 0x00, 0x00, 0x00, // 116 - 0xF8, 0x80, 0x80, 0xF8, 0x00, 0x00, 0x00, 0x00, // 117 - 0x18, 0x60, 0x80, 0x60, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, // 118 - 0x38, 0xC0, 0x30, 0x08, 0x30, 0xC0, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 119 - 0x88, 0x50, 0x20, 0x50, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, // 120 - 0x18, 0x60, 0x80, 0x60, 0x18, 0x80, 0x80, 0x40, 0x00, 0x00, // 121 - 0x88, 0xC8, 0xA8, 0x98, 0x00, 0x00, 0x00, 0x00, // 122 - 0x10, 0xEE, 0x02, 0x00, 0x40, 0x40, // 123 - 0xFE, 0xC0, // 124 - 0x02, 0xEE, 0x10, 0x40, 0x40, 0x00, // 125 - 0x20, 0x10, 0x10, 0x20, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 126 - 0xFC, 0x04, 0x04, 0x04, 0xFC, 0xC0, 0x80, 0x80, 0x80, 0xC0 // 127 - -}; - -#endif diff --git a/libraries/DMD/DejaVuSansBold9.h b/libraries/DMD/DejaVuSansBold9.h deleted file mode 100644 index d4d3721a..00000000 --- a/libraries/DMD/DejaVuSansBold9.h +++ /dev/null @@ -1,166 +0,0 @@ - - -/* - * - * DejaVuSansBold9 - * - * created with FontCreator - * written by F. Maximilian Thiele - * - * http://www.apetech.de/fontCreator - * me@apetech.de - * - * File Name : DejaVuSansBold9.h - * Date : 28.05.2012 - * Font size in bytes : 4662 - * Font width : 10 - * Font height : 10 - * Font first char : 32 - * Font last char : 128 - * Font used chars : 96 - * - * The font data are defined as - * - * struct _FONT_ { - * uint16_t font_Size_in_Bytes_over_all_included_Size_it_self; - * uint8_t font_Width_in_Pixel_for_fixed_drawing; - * uint8_t font_Height_in_Pixel_for_all_characters; - * unit8_t font_First_Char; - * uint8_t font_Char_Count; - * - * uint8_t font_Char_Widths[font_Last_Char - font_First_Char +1]; - * // for each character the separate width in pixels, - * // characters < 128 have an implicit virtual right empty row - * - * uint8_t font_data[]; - * // bit field of all characters - */ - -#include -#include - -#ifndef DEJAVUSANSBOLD9_H -#define DEJAVUSANSBOLD9_H - -#define DEJAVUSANSBOLD9_WIDTH 10 -#define DEJAVUSANSBOLD9_HEIGHT 10 - -static uint8_t const DejaVuSansBold9[] PROGMEM = { - 0x12, 0x36, // size - 0x0A, // width - 0x0A, // height - 0x20, // first char - 0x60, // char count - - // char widths - 0x00, 0x02, 0x03, 0x06, 0x05, 0x08, 0x07, 0x01, 0x03, 0x03, - 0x05, 0x05, 0x02, 0x03, 0x02, 0x03, 0x05, 0x05, 0x05, 0x05, - 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x02, 0x02, 0x06, 0x06, - 0x06, 0x04, 0x08, 0x07, 0x05, 0x06, 0x06, 0x05, 0x05, 0x06, - 0x07, 0x02, 0x03, 0x06, 0x05, 0x07, 0x06, 0x06, 0x05, 0x06, - 0x06, 0x05, 0x06, 0x06, 0x07, 0x09, 0x07, 0x06, 0x06, 0x03, - 0x03, 0x03, 0x04, 0x05, 0x02, 0x05, 0x05, 0x04, 0x05, 0x05, - 0x04, 0x05, 0x05, 0x02, 0x03, 0x05, 0x02, 0x08, 0x05, 0x05, - 0x05, 0x05, 0x03, 0x04, 0x03, 0x05, 0x06, 0x08, 0x06, 0x06, - 0x04, 0x04, 0x01, 0x04, 0x06, 0x05, - - // font data - 0xDE, 0xDE, 0x00, 0x00, // 33 - 0x06, 0x00, 0x06, 0x00, 0x00, 0x00, // 34 - 0x28, 0xF8, 0x2E, 0xF8, 0x2E, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 35 - 0x98, 0xB4, 0xFE, 0xB4, 0x64, 0x00, 0x00, 0x40, 0x00, 0x00, // 36 - 0x0C, 0x12, 0xD2, 0x7C, 0x78, 0x96, 0x90, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 37 - 0x60, 0xFC, 0x9E, 0xB2, 0x62, 0xE0, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 38 - 0x06, 0x00, // 39 - 0x3C, 0xFF, 0x81, 0x00, 0x00, 0x00, // 40 - 0x81, 0xFF, 0x3C, 0x00, 0x00, 0x00, // 41 - 0x14, 0x18, 0x3E, 0x18, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, // 42 - 0x20, 0x20, 0xF8, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, // 43 - 0xC0, 0xC0, 0x40, 0x00, // 44 - 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, // 45 - 0xC0, 0xC0, 0x00, 0x00, // 46 - 0xC0, 0x38, 0x06, 0x00, 0x00, 0x00, // 47 - 0x7C, 0xFE, 0x82, 0xFE, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, // 48 - 0x82, 0x82, 0xFE, 0xFE, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, // 49 - 0xC2, 0xE2, 0xB2, 0x9E, 0x8C, 0x00, 0x00, 0x00, 0x00, 0x00, // 50 - 0x82, 0x92, 0x92, 0xFE, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, // 51 - 0x60, 0x58, 0x44, 0xFE, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, // 52 - 0x9E, 0x9E, 0x92, 0xF2, 0x62, 0x00, 0x00, 0x00, 0x00, 0x00, // 53 - 0x7C, 0xFE, 0x96, 0xF2, 0x62, 0x00, 0x00, 0x00, 0x00, 0x00, // 54 - 0x82, 0xE2, 0x7A, 0x1E, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, // 55 - 0x6C, 0xEE, 0x92, 0xEE, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, // 56 - 0x8C, 0x9E, 0xD2, 0xFE, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, // 57 - 0xD8, 0xD8, 0x00, 0x00, // 58 - 0xD8, 0xD8, 0x40, 0x00, // 59 - 0x20, 0x50, 0x50, 0x50, 0xD8, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 60 - 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 61 - 0x88, 0xD8, 0x50, 0x50, 0x50, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 62 - 0x02, 0xDA, 0xDE, 0x0E, 0x00, 0x00, 0x00, 0x00, // 63 - 0x78, 0x84, 0x32, 0x4A, 0x4A, 0xFA, 0x44, 0x38, 0x00, 0x00, 0x40, 0x40, 0x40, 0x00, 0x00, 0x00, // 64 - 0x80, 0xF0, 0x7E, 0x4E, 0x7E, 0xF0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 65 - 0xFE, 0xFE, 0x92, 0xFE, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, // 66 - 0x38, 0x7C, 0xC6, 0x82, 0x82, 0xC6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 67 - 0xFE, 0xFE, 0x82, 0x82, 0xFE, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 68 - 0xFE, 0xFE, 0x92, 0x92, 0x92, 0x00, 0x00, 0x00, 0x00, 0x00, // 69 - 0xFE, 0xFE, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, // 70 - 0x78, 0xFC, 0x86, 0x92, 0xF2, 0xF6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 71 - 0xFE, 0xFE, 0x10, 0x10, 0x10, 0xFE, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 72 - 0xFE, 0xFE, 0x00, 0x00, // 73 - 0x00, 0xFE, 0xFE, 0x80, 0xC0, 0x40, // 74 - 0xFE, 0xFE, 0x38, 0x6C, 0xC6, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 75 - 0xFE, 0xFE, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, // 76 - 0xFE, 0xFE, 0x0C, 0x30, 0x0C, 0xFE, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 77 - 0xFE, 0xFE, 0x0C, 0x30, 0xFE, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 78 - 0x7C, 0xFE, 0x82, 0x82, 0xFE, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 79 - 0xFE, 0xFE, 0x12, 0x1E, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, // 80 - 0x7C, 0xFE, 0x82, 0x82, 0xFE, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, // 81 - 0xFE, 0xFE, 0x12, 0x7E, 0xEC, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 82 - 0xCC, 0x9E, 0x92, 0xF2, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, // 83 - 0x02, 0x02, 0xFE, 0xFE, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 84 - 0x7E, 0xFE, 0x80, 0x80, 0xFE, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 85 - 0x02, 0x1E, 0xF8, 0xC0, 0xF8, 0x1E, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 86 - 0x0E, 0xFE, 0xE0, 0x3C, 0x06, 0x3C, 0xE0, 0xFE, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 87 - 0x82, 0xC6, 0x7C, 0x10, 0x7C, 0xC6, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 88 - 0x06, 0x0E, 0xF8, 0xF8, 0x0E, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 89 - 0xC2, 0xE2, 0xB2, 0x9A, 0x8E, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 90 - 0xFF, 0xFF, 0x81, 0x00, 0x00, 0x00, // 91 - 0x06, 0x38, 0xC0, 0x00, 0x00, 0x00, // 92 - 0x81, 0xFF, 0xFF, 0x00, 0x00, 0x00, // 93 - 0x04, 0x02, 0x02, 0x04, 0x00, 0x00, 0x00, 0x00, // 94 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, // 95 - 0x01, 0x02, 0x00, 0x00, // 96 - 0xE8, 0xE8, 0xA8, 0xF8, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, // 97 - 0xFF, 0xFF, 0x88, 0xF8, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, // 98 - 0x70, 0xF8, 0x88, 0x88, 0x00, 0x00, 0x00, 0x00, // 99 - 0x70, 0xF8, 0x88, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, // 100 - 0x70, 0xF8, 0xA8, 0xB8, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, // 101 - 0x08, 0xFE, 0xFF, 0x09, 0x00, 0x00, 0x00, 0x00, // 102 - 0x70, 0xF8, 0x88, 0xF8, 0xF8, 0x00, 0x80, 0x80, 0xC0, 0x40, // 103 - 0xFF, 0xFF, 0x08, 0xF8, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, // 104 - 0xFB, 0xFB, 0x00, 0x00, // 105 - 0x00, 0xFB, 0xFB, 0x80, 0xC0, 0x40, // 106 - 0xFF, 0xFF, 0x70, 0xD8, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, // 107 - 0xFF, 0xFF, 0x00, 0x00, // 108 - 0xF8, 0xF8, 0x08, 0xF8, 0xF8, 0x08, 0xF8, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 109 - 0xF8, 0xF8, 0x08, 0xF8, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, // 110 - 0x70, 0xF8, 0x88, 0xF8, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, // 111 - 0xF8, 0xF8, 0x88, 0xF8, 0x70, 0xC0, 0xC0, 0x00, 0x00, 0x00, // 112 - 0x70, 0xF8, 0x88, 0xF8, 0xF8, 0x00, 0x00, 0x00, 0xC0, 0xC0, // 113 - 0xF8, 0xF8, 0x08, 0x00, 0x00, 0x00, // 114 - 0xB0, 0xB8, 0xE8, 0x68, 0x00, 0x00, 0x00, 0x00, // 115 - 0xFC, 0xFC, 0x88, 0x00, 0x00, 0x00, // 116 - 0xF8, 0xF8, 0x80, 0xF8, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, // 117 - 0x18, 0x78, 0xC0, 0xC0, 0x78, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 118 - 0x18, 0xF8, 0xE0, 0x38, 0x38, 0xE0, 0xF8, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 119 - 0x88, 0xD8, 0x70, 0x70, 0xD8, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 120 - 0x08, 0x38, 0xE0, 0xE0, 0x38, 0x08, 0x00, 0x80, 0xC0, 0x00, 0x00, 0x00, // 121 - 0xC8, 0xE8, 0xB8, 0x98, 0x00, 0x00, 0x00, 0x00, // 122 - 0x08, 0xFF, 0xF7, 0x81, 0x00, 0x00, 0x00, 0x00, // 123 - 0xFE, 0xC0, // 124 - 0x81, 0xF7, 0xFF, 0x08, 0x00, 0x00, 0x00, 0x00, // 125 - 0x20, 0x10, 0x10, 0x20, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 126 - 0xFC, 0x04, 0x04, 0x04, 0xFC, 0xC0, 0x80, 0x80, 0x80, 0xC0 // 127 - -}; - -#endif diff --git a/libraries/DMD/DejaVuSansItalic9.h b/libraries/DMD/DejaVuSansItalic9.h deleted file mode 100644 index ea36981d..00000000 --- a/libraries/DMD/DejaVuSansItalic9.h +++ /dev/null @@ -1,166 +0,0 @@ - - -/* - * - * DejaVuSansItalic9 - * - * created with FontCreator - * written by F. Maximilian Thiele - * - * http://www.apetech.de/fontCreator - * me@apetech.de - * - * File Name : DejaVuSansItalic9.h - * Date : 28.05.2012 - * Font size in bytes : 4572 - * Font width : 10 - * Font height : 10 - * Font first char : 32 - * Font last char : 128 - * Font used chars : 96 - * - * The font data are defined as - * - * struct _FONT_ { - * uint16_t font_Size_in_Bytes_over_all_included_Size_it_self; - * uint8_t font_Width_in_Pixel_for_fixed_drawing; - * uint8_t font_Height_in_Pixel_for_all_characters; - * unit8_t font_First_Char; - * uint8_t font_Char_Count; - * - * uint8_t font_Char_Widths[font_Last_Char - font_First_Char +1]; - * // for each character the separate width in pixels, - * // characters < 128 have an implicit virtual right empty row - * - * uint8_t font_data[]; - * // bit field of all characters - */ - -#include -#include - -#ifndef DEJAVUSANSITALIC9_H -#define DEJAVUSANSITALIC9_H - -#define DEJAVUSANSITALIC9_WIDTH 10 -#define DEJAVUSANSITALIC9_HEIGHT 10 - -static uint8_t const DejaVuSansItalic9[] PROGMEM = { - 0x11, 0xDC, // size - 0x0A, // width - 0x0A, // height - 0x20, // first char - 0x60, // char count - - // char widths - 0x00, 0x03, 0x03, 0x06, 0x04, 0x07, 0x06, 0x01, 0x03, 0x03, - 0x05, 0x05, 0x01, 0x03, 0x01, 0x03, 0x05, 0x04, 0x05, 0x05, - 0x05, 0x05, 0x04, 0x05, 0x05, 0x05, 0x02, 0x02, 0x06, 0x06, - 0x06, 0x04, 0x08, 0x06, 0x05, 0x06, 0x06, 0x05, 0x05, 0x06, - 0x07, 0x03, 0x03, 0x06, 0x04, 0x08, 0x07, 0x06, 0x05, 0x06, - 0x05, 0x06, 0x05, 0x06, 0x05, 0x08, 0x06, 0x05, 0x06, 0x04, - 0x02, 0x04, 0x04, 0x05, 0x02, 0x05, 0x05, 0x04, 0x06, 0x05, - 0x03, 0x05, 0x05, 0x03, 0x03, 0x05, 0x03, 0x08, 0x05, 0x05, - 0x05, 0x05, 0x04, 0x04, 0x03, 0x05, 0x05, 0x07, 0x05, 0x05, - 0x05, 0x04, 0x01, 0x05, 0x06, 0x05, - - // font data - 0x80, 0x38, 0x06, 0x00, 0x00, 0x00, // 33 - 0x06, 0x00, 0x06, 0x00, 0x00, 0x00, // 34 - 0x20, 0xF8, 0x2E, 0xF8, 0x2E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 35 - 0x98, 0xDC, 0xA6, 0x64, 0x00, 0x40, 0x00, 0x00, // 36 - 0x1C, 0xD2, 0x2E, 0x10, 0xEC, 0x92, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 37 - 0x60, 0x9C, 0x92, 0xA2, 0x64, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 38 - 0x06, 0x00, // 39 - 0xF8, 0x06, 0x01, 0x00, 0x00, 0x00, // 40 - 0x80, 0x61, 0x1E, 0x00, 0x00, 0x00, // 41 - 0x12, 0x0C, 0x1E, 0x0C, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, // 42 - 0x20, 0x20, 0xF8, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, // 43 - 0x80, 0x00, // 44 - 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, // 45 - 0x80, 0x00, // 46 - 0x60, 0x30, 0x0C, 0x00, 0x00, 0x00, // 47 - 0x78, 0x84, 0x82, 0x42, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, // 48 - 0x80, 0x82, 0xF2, 0x8E, 0x00, 0x00, 0x00, 0x00, // 49 - 0x80, 0xC4, 0xA2, 0x92, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, // 50 - 0x40, 0x84, 0x92, 0x92, 0x6E, 0x00, 0x00, 0x00, 0x00, 0x00, // 51 - 0x40, 0x70, 0xC8, 0x7C, 0x46, 0x00, 0x00, 0x00, 0x00, 0x00, // 52 - 0x80, 0x9C, 0x92, 0x92, 0x72, 0x00, 0x00, 0x00, 0x00, 0x00, // 53 - 0x78, 0x94, 0x92, 0x72, 0x00, 0x00, 0x00, 0x00, // 54 - 0x82, 0x42, 0x32, 0x0E, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, // 55 - 0x60, 0xAC, 0x92, 0x92, 0x6E, 0x00, 0x00, 0x00, 0x00, 0x00, // 56 - 0x80, 0x9C, 0x92, 0x72, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, // 57 - 0x80, 0x08, 0x00, 0x00, // 58 - 0x80, 0x08, 0x00, 0x00, // 59 - 0x20, 0x20, 0x50, 0x50, 0x50, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 60 - 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 61 - 0x88, 0x50, 0x50, 0x50, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 62 - 0x82, 0x32, 0x0A, 0x06, 0x00, 0x00, 0x00, 0x00, // 63 - 0xE0, 0x18, 0xE8, 0x94, 0x94, 0xF4, 0xCC, 0x78, 0x40, 0xC0, 0x80, 0x80, 0x80, 0x40, 0x00, 0x00, // 64 - 0x80, 0x60, 0x38, 0x24, 0x3E, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 65 - 0xC0, 0xB8, 0x96, 0x92, 0x6E, 0x00, 0x00, 0x00, 0x00, 0x00, // 66 - 0x78, 0x84, 0x82, 0x82, 0x82, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 67 - 0xC0, 0xB8, 0x86, 0x82, 0x42, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 68 - 0xC0, 0xB8, 0x96, 0x92, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, // 69 - 0xC0, 0x38, 0x16, 0x12, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, // 70 - 0x78, 0x84, 0x82, 0x82, 0x92, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 71 - 0xC0, 0x38, 0x16, 0x10, 0xD0, 0x38, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 72 - 0xC0, 0x38, 0x06, 0x00, 0x00, 0x00, // 73 - 0x00, 0xF0, 0x0E, 0xC0, 0x00, 0x00, // 74 - 0xC0, 0x38, 0x16, 0x68, 0x84, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 75 - 0xC0, 0xB8, 0x86, 0x80, 0x00, 0x00, 0x00, 0x00, // 76 - 0xC0, 0x38, 0x06, 0x38, 0x10, 0xC8, 0x3C, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 77 - 0xC0, 0x38, 0x06, 0x38, 0xC0, 0x38, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 78 - 0x78, 0x84, 0x82, 0x82, 0x42, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 79 - 0xC0, 0x38, 0x16, 0x12, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, // 80 - 0x78, 0x84, 0x82, 0x82, 0x42, 0x3C, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, // 81 - 0xC0, 0x38, 0x16, 0x72, 0x8E, 0x00, 0x00, 0x00, 0x00, 0x00, // 82 - 0x40, 0x8C, 0x92, 0x92, 0x62, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 83 - 0x02, 0xC2, 0x3A, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, // 84 - 0x78, 0x86, 0x80, 0x80, 0x78, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 85 - 0x0E, 0xF0, 0x40, 0x30, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, // 86 - 0xFE, 0x60, 0x1C, 0x02, 0xFE, 0x60, 0x1C, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 87 - 0x80, 0x42, 0x2C, 0x10, 0x6C, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 88 - 0x02, 0xCC, 0x30, 0x0C, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, // 89 - 0x80, 0xC2, 0xA2, 0x92, 0x8A, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 90 - 0xC0, 0xBC, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, // 91 - 0x1E, 0xE0, 0x00, 0x00, // 92 - 0x80, 0xC0, 0x3D, 0x03, 0x00, 0x00, 0x00, 0x00, // 93 - 0x04, 0x02, 0x02, 0x04, 0x00, 0x00, 0x00, 0x00, // 94 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, // 95 - 0x01, 0x02, 0x00, 0x00, // 96 - 0xC0, 0xA8, 0xA8, 0xE8, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, // 97 - 0xC0, 0x7C, 0x93, 0x88, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, // 98 - 0xF0, 0x98, 0x88, 0x08, 0x00, 0x00, 0x00, 0x00, // 99 - 0xF0, 0x98, 0x88, 0xC8, 0x3C, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 100 - 0x70, 0xB8, 0xA8, 0xA8, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, // 101 - 0xC8, 0x3E, 0x09, 0x00, 0x00, 0x00, // 102 - 0xF0, 0x98, 0x88, 0xC8, 0x38, 0x80, 0x80, 0x80, 0x40, 0x00, // 103 - 0xC0, 0x3C, 0x13, 0xC8, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, // 104 - 0xE0, 0x38, 0x01, 0x00, 0x00, 0x00, // 105 - 0xC0, 0x38, 0x01, 0xC0, 0x00, 0x00, // 106 - 0xC0, 0x3C, 0x23, 0xD0, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, // 107 - 0xC0, 0x3C, 0x03, 0x00, 0x00, 0x00, // 108 - 0xE0, 0x18, 0x08, 0xC8, 0x78, 0x10, 0xC8, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 109 - 0xE0, 0x38, 0x08, 0xC8, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, // 110 - 0x70, 0x98, 0x88, 0xC8, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, // 111 - 0xE0, 0x98, 0x88, 0xC8, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, // 112 - 0xF0, 0x88, 0x88, 0xF0, 0x18, 0x00, 0x00, 0xC0, 0x00, 0x00, // 113 - 0xE0, 0x38, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, // 114 - 0x80, 0xB8, 0xA8, 0xE8, 0x00, 0x00, 0x00, 0x00, // 115 - 0xF8, 0x8C, 0x08, 0x00, 0x00, 0x00, // 116 - 0xE0, 0x98, 0x80, 0xE0, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, // 117 - 0x38, 0xC0, 0x60, 0x10, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, // 118 - 0xF8, 0x60, 0x10, 0xF8, 0x40, 0x30, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 119 - 0x80, 0x48, 0x30, 0x50, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, // 120 - 0x00, 0xF8, 0x60, 0x10, 0x08, 0x80, 0x40, 0x00, 0x00, 0x00, // 121 - 0x80, 0xC8, 0xA8, 0x98, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, // 122 - 0x08, 0xF8, 0x87, 0x01, 0x00, 0x00, 0x00, 0x00, // 123 - 0xFE, 0xC0, // 124 - 0x80, 0x80, 0x71, 0x0F, 0x08, 0x00, 0x00, 0x40, 0x00, 0x00, // 125 - 0x20, 0x10, 0x10, 0x20, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 126 - 0xFC, 0x04, 0x04, 0x04, 0xFC, 0xC0, 0x80, 0x80, 0x80, 0xC0 // 127 - -}; - -#endif diff --git a/libraries/DMD/Mono5x7.h b/libraries/DMD/Mono5x7.h deleted file mode 100644 index 7e6de562..00000000 --- a/libraries/DMD/Mono5x7.h +++ /dev/null @@ -1,155 +0,0 @@ - - -/* - * - * Mono5x7 - * - * created with FontCreator - * written by F. Maximilian Thiele - * - * http://www.apetech.de/fontCreator - * me@apetech.de - * - * File Name : Mono5x7.h - * Date : 29.05.2012 - * Font size in bytes : 3462 - * Font width : 5 - * Font height : 7 - * Font first char : 32 - * Font last char : 128 - * Font used chars : 96 - * - * The font data are defined as - * - * struct _FONT_ { - * uint16_t font_Size_in_Bytes_over_all_included_Size_it_self; - * uint8_t font_Width_in_Pixel_for_fixed_drawing; - * uint8_t font_Height_in_Pixel_for_all_characters; - * unit8_t font_First_Char; - * uint8_t font_Char_Count; - * - * uint8_t font_Char_Widths[font_Last_Char - font_First_Char +1]; - * // for each character the separate width in pixels, - * // characters < 128 have an implicit virtual right empty row - * - * uint8_t font_data[]; - * // bit field of all characters - */ - -#include -#include - -#ifndef MONO5X7_H -#define MONO5X7_H - -#define MONO5X7_WIDTH 5 -#define MONO5X7_HEIGHT 7 - -static uint8_t const Mono5x7[] PROGMEM = { - 0x00, 0x00, // size - 0x05, // width - 0x07, // height - 0x20, // first char - 0x60, // char count - - // font data - 0x00, 0x00, 0x00, 0x00, 0x00, // 32 - 0x00, 0x00, 0x5F, 0x00, 0x00, // 33 - 0x00, 0x07, 0x00, 0x07, 0x00, // 34 - 0x14, 0x7F, 0x14, 0x7F, 0x14, // 35 - 0x24, 0x2A, 0x7F, 0x2A, 0x12, // 36 - 0x23, 0x13, 0x08, 0x64, 0x62, // 37 - 0x36, 0x49, 0x55, 0x22, 0x50, // 38 - 0x00, 0x05, 0x03, 0x00, 0x00, // 39 - 0x00, 0x1C, 0x22, 0x41, 0x00, // 40 - 0x00, 0x41, 0x22, 0x1C, 0x00, // 41 - 0x14, 0x08, 0x3E, 0x08, 0x14, // 42 - 0x08, 0x08, 0x3E, 0x08, 0x08, // 43 - 0x00, 0x50, 0x30, 0x00, 0x00, // 44 - 0x08, 0x08, 0x08, 0x08, 0x08, // 45 - 0x00, 0x60, 0x60, 0x00, 0x00, // 46 - 0x20, 0x10, 0x08, 0x04, 0x02, // 47 - 0x3E, 0x51, 0x49, 0x45, 0x3E, // 48 - 0x00, 0x42, 0x7F, 0x40, 0x00, // 49 - 0x42, 0x61, 0x51, 0x49, 0x46, // 50 - 0x21, 0x41, 0x45, 0x4B, 0x31, // 51 - 0x18, 0x14, 0x12, 0x7F, 0x10, // 52 - 0x27, 0x45, 0x45, 0x45, 0x39, // 53 - 0x3C, 0x4A, 0x49, 0x49, 0x30, // 54 - 0x01, 0x71, 0x09, 0x05, 0x03, // 55 - 0x36, 0x49, 0x49, 0x49, 0x36, // 56 - 0x06, 0x49, 0x49, 0x29, 0x1E, // 57 - 0x00, 0x36, 0x36, 0x00, 0x00, // 58 - 0x00, 0x56, 0x36, 0x00, 0x00, // 59 - 0x08, 0x14, 0x22, 0x41, 0x00, // 60 - 0x14, 0x14, 0x14, 0x14, 0x14, // 61 - 0x00, 0x41, 0x22, 0x14, 0x08, // 62 - 0x02, 0x01, 0x51, 0x09, 0x06, // 63 - 0x32, 0x49, 0x79, 0x41, 0x3E, // 64 - 0x7E, 0x11, 0x11, 0x11, 0x7E, // 65 - 0x7F, 0x49, 0x49, 0x49, 0x36, // 66 - 0x3E, 0x41, 0x41, 0x41, 0x22, // 67 - 0x7F, 0x41, 0x41, 0x22, 0x1C, // 68 - 0x7F, 0x49, 0x49, 0x49, 0x41, // 69 - 0x7F, 0x09, 0x09, 0x09, 0x01, // 70 - 0x3E, 0x41, 0x49, 0x49, 0x78, // 71 - 0x7F, 0x08, 0x08, 0x08, 0x7F, // 72 - 0x00, 0x41, 0x7F, 0x41, 0x00, // 73 - 0x20, 0x40, 0x41, 0x3F, 0x01, // 74 - 0x7F, 0x08, 0x14, 0x22, 0x41, // 75 - 0x7F, 0x40, 0x40, 0x40, 0x40, // 76 - 0x7F, 0x02, 0x0C, 0x02, 0x7F, // 77 - 0x7F, 0x04, 0x08, 0x10, 0x7F, // 78 - 0x3E, 0x41, 0x41, 0x41, 0x3E, // 79 - 0x7F, 0x09, 0x09, 0x09, 0x06, // 80 - 0x3E, 0x41, 0x51, 0x21, 0x5E, // 81 - 0x7F, 0x09, 0x19, 0x29, 0x46, // 82 - 0x46, 0x49, 0x49, 0x49, 0x31, // 83 - 0x01, 0x01, 0x7F, 0x01, 0x01, // 84 - 0x3F, 0x40, 0x40, 0x40, 0x3F, // 85 - 0x1F, 0x20, 0x40, 0x20, 0x1F, // 86 - 0x3F, 0x40, 0x38, 0x40, 0x3F, // 87 - 0x63, 0x14, 0x08, 0x14, 0x63, // 88 - 0x07, 0x08, 0x70, 0x08, 0x07, // 89 - 0x61, 0x51, 0x49, 0x45, 0x43, // 90 - 0x00, 0x7F, 0x41, 0x41, 0x00, // 91 - 0x02, 0x04, 0x08, 0x10, 0x20, // 92 - 0x00, 0x41, 0x41, 0x7F, 0x00, // 93 - 0x04, 0x02, 0x01, 0x02, 0x04, // 94 - 0x40, 0x40, 0x40, 0x40, 0x40, // 95 - 0x00, 0x02, 0x04, 0x08, 0x00, // 96 - 0x20, 0x54, 0x54, 0x54, 0x78, // 97 - 0x7F, 0x48, 0x44, 0x44, 0x38, // 98 - 0x38, 0x44, 0x44, 0x44, 0x20, // 99 - 0x38, 0x44, 0x44, 0x48, 0x7F, // 100 - 0x38, 0x54, 0x54, 0x54, 0x18, // 101 - 0x08, 0x7E, 0x09, 0x01, 0x02, // 102 - 0x0C, 0x52, 0x52, 0x52, 0x3E, // 103 - 0x7F, 0x08, 0x04, 0x04, 0x78, // 104 - 0x00, 0x44, 0x7D, 0x40, 0x00, // 105 - 0x20, 0x40, 0x44, 0x3D, 0x00, // 106 - 0x7F, 0x10, 0x28, 0x44, 0x00, // 107 - 0x00, 0x41, 0x7F, 0x40, 0x00, // 108 - 0x7C, 0x04, 0x18, 0x04, 0x78, // 109 - 0x7C, 0x08, 0x04, 0x04, 0x78, // 110 - 0x38, 0x44, 0x44, 0x44, 0x38, // 111 - 0x7C, 0x14, 0x14, 0x14, 0x08, // 112 - 0x08, 0x14, 0x14, 0x18, 0x7C, // 113 - 0x7C, 0x08, 0x04, 0x04, 0x08, // 114 - 0x48, 0x54, 0x54, 0x54, 0x20, // 115 - 0x04, 0x3F, 0x44, 0x40, 0x00, // 116 - 0x3C, 0x40, 0x40, 0x20, 0x7C, // 117 - 0x1C, 0x20, 0x40, 0x20, 0x1C, // 118 - 0x3C, 0x40, 0x30, 0x40, 0x3C, // 119 - 0x44, 0x28, 0x10, 0x28, 0x44, // 120 - 0x0C, 0x50, 0x50, 0x50, 0x3C, // 121 - 0x44, 0x64, 0x54, 0x4C, 0x44, // 122 - 0x00, 0x08, 0x36, 0x41, 0x00, // 123 - 0x00, 0x00, 0x7F, 0x00, 0x00, // 124 - 0x00, 0x41, 0x36, 0x08, 0x00, // 125 - 0x08, 0x04, 0x08, 0x10, 0x08, // 126 - 0x00, 0x00, 0x00, 0x00, 0x00 // 127 - -}; - -#endif diff --git a/libraries/DMD/dmd-4x1.fig b/libraries/DMD/dmd-4x1.fig deleted file mode 100644 index d0949c23..00000000 --- a/libraries/DMD/dmd-4x1.fig +++ /dev/null @@ -1,36 +0,0 @@ -#FIG 3.2 Produced by xfig version 3.2.5b -Landscape -Center -Metric -A4 -100.00 -Single --2 -1200 2 -2 2 0 1 0 7 50 -1 -1 0.000 1 0 -1 0 0 5 - 3375 2700 4500 2700 4500 3375 3375 3375 3375 2700 -2 2 0 1 0 7 50 -1 -1 0.000 1 0 -1 0 0 5 - 4950 2700 6075 2700 6075 3375 4950 3375 4950 2700 -2 2 0 1 0 7 50 -1 -1 0.000 1 0 -1 0 0 5 - 6525 2700 7650 2700 7650 3375 6525 3375 6525 2700 -2 2 0 1 0 7 50 -1 -1 0.000 1 0 -1 0 0 5 - 8100 2700 9225 2700 9225 3375 8100 3375 8100 2700 -2 1 0 4 11 7 50 -1 -1 0.000 0 0 -1 1 0 2 - 1 1 3.00 60.00 120.00 - 4950 3060 4500 3060 -2 1 0 4 11 7 50 -1 -1 0.000 0 0 -1 1 0 2 - 1 1 3.00 60.00 120.00 - 6525 3060 6075 3060 -2 1 0 4 11 7 50 -1 -1 0.000 0 0 -1 1 0 2 - 1 1 3.00 60.00 120.00 - 8100 3060 7650 3060 -2 1 0 4 11 7 50 -1 -1 0.000 0 0 -1 1 0 2 - 1 1 3.00 60.00 120.00 - 9900 3060 9225 3060 -2 2 0 1 0 26 50 -1 -1 0.000 1 0 -1 0 0 5 - 9900 2835 10800 2835 10800 3285 9900 3285 9900 2835 -4 0 0 50 -1 0 12 0.0000 4 135 675 10035 3105 Arduino\001 -4 0 0 50 -1 0 12 0.0000 4 135 600 8370 3105 Panel 4\001 -4 0 0 50 -1 0 12 0.0000 4 135 600 6795 3105 Panel 3\001 -4 0 0 50 -1 0 12 0.0000 4 135 600 5220 3105 Panel 2\001 -4 0 0 50 -1 0 12 0.0000 4 135 600 3645 3105 Panel 1\001 diff --git a/libraries/DMD/dmd-4x1.png b/libraries/DMD/dmd-4x1.png deleted file mode 100644 index f796bbd2..00000000 Binary files a/libraries/DMD/dmd-4x1.png and /dev/null differ diff --git a/libraries/DMD/dmd-4x2.fig b/libraries/DMD/dmd-4x2.fig deleted file mode 100644 index 233d939c..00000000 --- a/libraries/DMD/dmd-4x2.fig +++ /dev/null @@ -1,60 +0,0 @@ -#FIG 3.2 Produced by xfig version 3.2.5b -Landscape -Center -Metric -A4 -100.00 -Single --2 -1200 2 -2 1 0 4 11 7 50 -1 -1 0.000 0 0 -1 1 0 2 - 1 1 3.00 60.00 120.00 - 9900 3060 9225 3060 -2 2 0 1 0 26 50 -1 -1 0.000 1 0 -1 0 0 5 - 9900 2835 10800 2835 10800 3285 9900 3285 9900 2835 -2 2 0 1 0 7 50 -1 -1 0.000 1 0 -1 0 0 5 - 3375 1575 4500 1575 4500 2250 3375 2250 3375 1575 -2 2 0 1 0 7 50 -1 -1 0.000 1 0 -1 0 0 5 - 4950 1575 6075 1575 6075 2250 4950 2250 4950 1575 -2 2 0 1 0 7 50 -1 -1 0.000 1 0 -1 0 0 5 - 8100 1575 9225 1575 9225 2250 8100 2250 8100 1575 -2 1 0 4 11 7 50 -1 -1 0.000 0 0 -1 1 0 2 - 1 1 3.00 60.00 120.00 - 7650 1935 8100 1935 -2 2 0 1 0 7 50 -1 -1 0.000 1 0 -1 0 0 5 - 6525 1575 7650 1575 7650 2250 6525 2250 6525 1575 -2 1 0 4 11 7 50 -1 -1 0.000 0 0 -1 1 0 2 - 1 1 3.00 60.00 120.00 - 6075 1935 6525 1935 -2 1 0 4 11 7 50 -1 -1 0.000 0 0 -1 1 0 2 - 1 1 3.00 60.00 120.00 - 4500 1935 4950 1935 -2 1 0 4 11 7 50 -1 -1 0.000 0 0 -1 1 0 4 - 1 1 3.00 60.00 120.00 - 3375 3015 2925 3015 2925 1890 3375 1890 -2 2 0 1 0 7 50 -1 -1 0.000 1 0 -1 0 0 5 - 3375 2700 4500 2700 4500 3375 3375 3375 3375 2700 -2 2 0 1 0 7 50 -1 -1 0.000 1 0 -1 0 0 5 - 4950 2700 6075 2700 6075 3375 4950 3375 4950 2700 -2 2 0 1 0 7 50 -1 -1 0.000 1 0 -1 0 0 5 - 6525 2700 7650 2700 7650 3375 6525 3375 6525 2700 -2 2 0 1 0 7 50 -1 -1 0.000 1 0 -1 0 0 5 - 8100 2700 9225 2700 9225 3375 8100 3375 8100 2700 -2 1 0 4 11 7 50 -1 -1 0.000 0 0 -1 1 0 2 - 1 1 3.00 60.00 120.00 - 4950 3060 4500 3060 -2 1 0 4 11 7 50 -1 -1 0.000 0 0 -1 1 0 2 - 1 1 3.00 60.00 120.00 - 6525 3060 6075 3060 -2 1 0 4 11 7 50 -1 -1 0.000 0 0 -1 1 0 2 - 1 1 3.00 60.00 120.00 - 8100 3060 7650 3060 -4 0 0 50 -1 0 12 0.0000 4 135 675 10035 3105 Arduino\001 -4 0 0 50 -1 0 12 0.0000 4 135 600 8370 3105 Panel 8\001 -4 0 0 50 -1 0 12 0.0000 4 135 600 6795 3105 Panel 7\001 -4 0 0 50 -1 0 12 0.0000 4 135 600 5220 3105 Panel 6\001 -4 0 0 50 -1 0 12 0.0000 4 135 600 3645 3105 Panel 5\001 -4 0 0 50 -1 0 12 3.1416 4 135 600 4230 1845 Panel 4\001 -4 0 0 50 -1 0 12 3.1416 4 135 600 5805 1845 Panel 3\001 -4 0 0 50 -1 0 12 3.1416 4 135 600 7380 1845 Panel 2\001 -4 0 0 50 -1 0 12 3.1416 4 135 600 8955 1845 Panel 1\001 diff --git a/libraries/DMD/dmd-4x2.png b/libraries/DMD/dmd-4x2.png deleted file mode 100644 index ac0f3144..00000000 Binary files a/libraries/DMD/dmd-4x2.png and /dev/null differ diff --git a/libraries/DMD/dmd-4x3.fig b/libraries/DMD/dmd-4x3.fig deleted file mode 100644 index 78c111ae..00000000 --- a/libraries/DMD/dmd-4x3.fig +++ /dev/null @@ -1,84 +0,0 @@ -#FIG 3.2 Produced by xfig version 3.2.5b -Landscape -Center -Metric -A4 -100.00 -Single --2 -1200 2 -2 1 0 4 11 7 50 -1 -1 0.000 0 0 -1 1 0 2 - 1 1 3.00 60.00 120.00 - 9900 3060 9225 3060 -2 2 0 1 0 26 50 -1 -1 0.000 1 0 -1 0 0 5 - 9900 2835 10800 2835 10800 3285 9900 3285 9900 2835 -2 2 0 1 0 7 50 -1 -1 0.000 1 0 -1 0 0 5 - 3375 1575 4500 1575 4500 2250 3375 2250 3375 1575 -2 2 0 1 0 7 50 -1 -1 0.000 1 0 -1 0 0 5 - 4950 1575 6075 1575 6075 2250 4950 2250 4950 1575 -2 2 0 1 0 7 50 -1 -1 0.000 1 0 -1 0 0 5 - 8100 1575 9225 1575 9225 2250 8100 2250 8100 1575 -2 1 0 4 11 7 50 -1 -1 0.000 0 0 -1 1 0 2 - 1 1 3.00 60.00 120.00 - 7650 1935 8100 1935 -2 2 0 1 0 7 50 -1 -1 0.000 1 0 -1 0 0 5 - 6525 1575 7650 1575 7650 2250 6525 2250 6525 1575 -2 1 0 4 11 7 50 -1 -1 0.000 0 0 -1 1 0 2 - 1 1 3.00 60.00 120.00 - 6075 1935 6525 1935 -2 1 0 4 11 7 50 -1 -1 0.000 0 0 -1 1 0 2 - 1 1 3.00 60.00 120.00 - 4500 1935 4950 1935 -2 1 0 4 11 7 50 -1 -1 0.000 0 0 -1 1 0 4 - 1 1 3.00 60.00 120.00 - 3375 3015 2925 3015 2925 1890 3375 1890 -2 1 0 4 11 7 50 -1 -1 0.000 0 0 -1 1 0 4 - 1 1 3.00 60.00 120.00 - 9225 1890 9675 1890 9675 765 9225 765 -2 2 0 1 0 7 50 -1 -1 0.000 1 0 -1 0 0 5 - 3375 450 4500 450 4500 1125 3375 1125 3375 450 -2 2 0 1 0 7 50 -1 -1 0.000 1 0 -1 0 0 5 - 4950 450 6075 450 6075 1125 4950 1125 4950 450 -2 2 0 1 0 7 50 -1 -1 0.000 1 0 -1 0 0 5 - 6525 450 7650 450 7650 1125 6525 1125 6525 450 -2 2 0 1 0 7 50 -1 -1 0.000 1 0 -1 0 0 5 - 8100 450 9225 450 9225 1125 8100 1125 8100 450 -2 1 0 4 11 7 50 -1 -1 0.000 0 0 -1 1 0 2 - 1 1 3.00 60.00 120.00 - 4950 810 4500 810 -2 1 0 4 11 7 50 -1 -1 0.000 0 0 -1 1 0 2 - 1 1 3.00 60.00 120.00 - 6525 810 6075 810 -2 1 0 4 11 7 50 -1 -1 0.000 0 0 -1 1 0 2 - 1 1 3.00 60.00 120.00 - 8100 810 7650 810 -2 2 0 1 0 7 50 -1 -1 0.000 1 0 -1 0 0 5 - 3375 2700 4500 2700 4500 3375 3375 3375 3375 2700 -2 2 0 1 0 7 50 -1 -1 0.000 1 0 -1 0 0 5 - 4950 2700 6075 2700 6075 3375 4950 3375 4950 2700 -2 2 0 1 0 7 50 -1 -1 0.000 1 0 -1 0 0 5 - 6525 2700 7650 2700 7650 3375 6525 3375 6525 2700 -2 2 0 1 0 7 50 -1 -1 0.000 1 0 -1 0 0 5 - 8100 2700 9225 2700 9225 3375 8100 3375 8100 2700 -2 1 0 4 11 7 50 -1 -1 0.000 0 0 -1 1 0 2 - 1 1 3.00 60.00 120.00 - 4950 3060 4500 3060 -2 1 0 4 11 7 50 -1 -1 0.000 0 0 -1 1 0 2 - 1 1 3.00 60.00 120.00 - 6525 3060 6075 3060 -2 1 0 4 11 7 50 -1 -1 0.000 0 0 -1 1 0 2 - 1 1 3.00 60.00 120.00 - 8100 3060 7650 3060 -4 0 0 50 -1 0 12 0.0000 4 135 675 10035 3105 Arduino\001 -4 0 0 50 -1 0 12 0.0000 4 135 600 3645 3105 Panel 9\001 -4 0 0 50 -1 0 12 0.0000 4 135 705 5175 3105 Panel 10\001 -4 0 0 50 -1 0 12 0.0000 4 135 705 6750 3105 Panel 11\001 -4 0 0 50 -1 0 12 0.0000 4 135 705 8325 3105 Panel 12\001 -4 0 0 50 -1 0 12 3.1416 4 135 600 8955 1845 Panel 5\001 -4 0 0 50 -1 0 12 3.1416 4 135 600 7380 1845 Panel 6\001 -4 0 0 50 -1 0 12 3.1416 4 135 600 5805 1845 Panel 7\001 -4 0 0 50 -1 0 12 3.1416 4 135 600 4230 1845 Panel 8\001 -4 0 0 50 -1 0 12 0.0000 4 135 600 3645 855 Panel 1\001 -4 0 0 50 -1 0 12 0.0000 4 135 600 5220 855 Panel 2\001 -4 0 0 50 -1 0 12 0.0000 4 135 600 6795 855 Panel 3\001 -4 0 0 50 -1 0 12 0.0000 4 135 600 8370 855 Panel 4\001 diff --git a/libraries/DMD/dmd-4x3.png b/libraries/DMD/dmd-4x3.png deleted file mode 100644 index 7291057c..00000000 Binary files a/libraries/DMD/dmd-4x3.png and /dev/null differ diff --git a/libraries/DMD/dmd-info.txt b/libraries/DMD/dmd-info.txt deleted file mode 100644 index c1cca739..00000000 --- a/libraries/DMD/dmd-info.txt +++ /dev/null @@ -1,53 +0,0 @@ -Description of the interface to the Freetronics Dot Matrix Display (DMD) -======================================================================== - -Pins: - D6: A - interleave phase select LSB - D7: B - interleave phase select MSB (set the MSB first) - D8: SCLK - this is the "latch" pin that copies all previously transferred - data from the shift register to the actual display. Normally low, - then flip to high and then low again to latch the data. - D9: nOE - Output enable (when low). - D10: Conflict detect (if it goes low, something else is using SPI) - This is the standard SPI SS - Slave select - pin. - D11: R - this is the standard SPI MOSI - Master out, slave in - pin. - D12: MISO - master in, slave out - unused - D13: CLK - standard Serial Clock pin for SPI - -Initialisation: - SPI: bit order = MSB-first, data mode = 0, clock divider = 128 - (use a smaller clock divider, such as 2, for better performance - when driving multiple displays) - - Set A, B, CLK, SCLK, and nOE to LOW outputs - Set R to HIGH output - - phase = 0 - -Every 5ms, do the following to refresh the display: - Send the bytes for 4 interleaved rows based on phase, via SPI: - phase == 0: 0, 4, 8, 12 (actually sent in the order 12, 8, 4, 0) - phase == 1: 1, 5, 9, 13 - phase == 2: 2, 6, 10, 14 - phase == 3: 3, 7, 11, 15 - Then latch the data for the rows as follows: - Set nOE to LOW - Set SCLK to HIGH and then back to LOW - Set A and B to indicate the current phase - Set nOE to HIGH - Finally, increment the phase, wrapping around from 3 to 0 - The above code assumes the following memory organisation: - The display is W panels wide and H panels high. - Each panel is 32 pixels wide (4 bytes) and 16 pixels high. - Memory is organised as W * H * 4 bytes for each row, and 16 rows. - That is, the 2D arrangement of panels is flattened into 1D for - clocking the data out. - In addition, a 1 bit in memory is a LED that is *off*. - -Other things: - Multiple panels need to be daisy-chained in the order N, ..., 1 with N - plugged into the connector board on the Arduino and 1 at the end of - the daisy-chain. Because the shipped cables are short, multiple rows - can be oriented in alternating order with odd-numbered rows - (counting from 1) upside-down and reversed. More details here: - http://www.adebenham.com/category/arduino/dmd/ diff --git a/libraries/DMD/examples/Demo/Demo.ino b/libraries/DMD/examples/Demo/Demo.ino deleted file mode 100644 index e3b83655..00000000 --- a/libraries/DMD/examples/Demo/Demo.ino +++ /dev/null @@ -1,144 +0,0 @@ -/* -This example demonstrates how to use the DMD and related classes to -draw things on a Freetronics Large Dot Matrix Display. - -This example is placed into the public domain. -*/ - -#include -#include -#include -#include -#include - -DMD display; - -ISR(TIMER1_OVF_vect) -{ - display.refresh(); -} - -void setup() { - display.enableTimer1(); -} - -void loop() { - drawShapes(); - delay(1000); - - drawBricks(); - delay(1000); - - drawStickFigures(); - delay(1000); - - drawText(); - delay(1000); - - drawBoldText(); - delay(1000); - - drawItalicText(); - delay(1000); - - drawMonoText(); - delay(1000); - - drawMarquee(); - delay(500); -} - -void drawShapes() -{ - display.clear(); - display.drawCircle(6, 8, 3); - display.drawFilledCircle(16, 8, 3); - display.drawLine(22, 5, 28, 11); - display.drawLine(28, 5, 22, 11); - display.drawRect(0, 0, display.width() - 1, display.height() - 1); -} - -void drawBricks() -{ - static const uint8_t bricks[] PROGMEM = { - 16, 6, - B11111111, B11111111, - B10000000, B10000000, - B10000000, B10000000, - B11111111, B11111111, - B00001000, B00001000, - B00001000, B00001000 - }; - display.fill(0, 0, display.width(), display.height(), bricks); -} - -void drawStickFigures() -{ - static const uint8_t stickFigure[] PROGMEM = { - 9, 13, - B00111110, B00000000, - B01000001, B00000000, - B01000001, B00000000, - B00111110, B00000000, - B00001000, B00000000, - B00001000, B00000000, - B11111111, B10000000, - B00001000, B00000000, - B00001000, B00000000, - B00010100, B00000000, - B00100010, B00000000, - B01000001, B00000000, - B10000000, B10000000 - }; - display.clear(); - display.drawBitmap(2, 1, stickFigure); - display.drawInvertedBitmap(12, 1, stickFigure); - display.drawBitmap(22, 1, stickFigure); -} - -void drawText() -{ - display.clear(); - display.setFont(DejaVuSans9); - display.drawText(0, 0, "Hello"); - display.drawText(9, 8, "World"); -} - -void drawBoldText() -{ - display.clear(); - display.setFont(DejaVuSansBold9); - display.drawText(0, 0, "Hello"); - display.drawText(4, 8, "World"); -} - -void drawItalicText() -{ - display.clear(); - display.setFont(DejaVuSansItalic9); - display.drawText(0, 0, "Hello"); - display.drawText(2, 8, "World"); -} - -void drawMonoText() -{ - display.clear(); - display.setFont(Mono5x7); - display.drawText(0, 0, "Hello"); - display.drawText(3, 8, "World"); -} - -static const char message[] = "Eat at Joes!"; - -void drawMarquee() -{ - int width = display.width(); - display.setFont(DejaVuSans9); - int msgWidth = display.textWidth(message); - int fullScroll = msgWidth + width + 1; - for (int x = 0; x < fullScroll; ++x) { - display.clear(); - display.drawText(width - x, 3, message); - delay(50); - } -} diff --git a/libraries/DMD/examples/RunningFigure/RunningFigure.ino b/libraries/DMD/examples/RunningFigure/RunningFigure.ino deleted file mode 100644 index f517b7e3..00000000 --- a/libraries/DMD/examples/RunningFigure/RunningFigure.ino +++ /dev/null @@ -1,261 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#include - -DMD display; - -// Running stick figure pictures are loosely based on those from this tutorial: -// http://www.fluidanims.com/FAelite/phpBB3/viewtopic.php?f=10&t=102 - -byte const run1[] PROGMEM = { - 16, 16, - B00000000, B00001100, - B00000000, B00011110, - B00000111, B11111110, - B00001111, B11111110, - B00011100, B11111100, - B00000001, B11111100, - B00000001, B11110000, - B00000011, B11111000, - B00000111, B00011000, - B00001110, B01110000, - B00011100, B01100000, - B00111000, B00000000, - B01110000, B00000000, - B01100000, B00000000, - B01000000, B00000000, - B00000000, B00000000 -}; - -byte const run2[] PROGMEM = { - 18, 16, - B00000000, B01110011, B10000000, - B00000000, B11111111, B10000000, - B00000000, B00011111, B10000000, - B00000000, B00111111, B11000000, - B00000000, B01111011, B11000000, - B00000000, B11110011, B10000000, - B00000001, B11100000, B00000000, - B00000011, B11100000, B00000000, - B00000111, B01110000, B00000000, - B01111110, B00111000, B00000000, - B11111100, B00011100, B00000000, - B00000000, B00001110, B00000000, - B00000000, B00000111, B00000000, - B00000000, B00000011, B10000000, - B00000000, B00000001, B00000000, - B00000000, B00000000, B00000000 -}; - -byte const run3[] PROGMEM = { - 18, 16, - B00000000, B00110000, B00000000, - B00000000, B01111000, B00000000, - B00000000, B00011111, B00000000, - B00000000, B00011111, B00000000, - B00000000, B00111111, B10000000, - B00000000, B01111111, B11000000, - B00000000, B11100011, B10000000, - B00000001, B11000000, B00000000, - B00000011, B11100000, B00000000, - B11111111, B01110000, B00000000, - B11111110, B00111000, B00000000, - B00000000, B00011000, B00000000, - B00000000, B00011100, B00000000, - B00000000, B00001110, B00000000, - B00000000, B00000100, B00000000, - B00000000, B00000000, B00000000 -}; - -byte const run4[] PROGMEM = { - 16, 16, - B00000001, B11100000, - B00000011, B11111100, - B00000000, B00111110, - B00000000, B01111110, - B00000000, B11111100, - B00000001, B10011111, - B00000011, B00001110, - B00000011, B00000000, - B00000011, B10000000, - B11111111, B10000000, - B11111000, B11000000, - B00000001, B11000000, - B00000011, B10000000, - B00000111, B00000000, - B00000110, B00000000, - B00000100, B00000000 -}; - -byte const run5[] PROGMEM = { - 13, 16, - B00000000, B00000000, - B00000000, B00110000, - B00000111, B11111000, - B00000111, B11111000, - B00000111, B11110000, - B00001111, B11100000, - B00000111, B00000000, - B00001111, B00000000, - B00001111, B00000000, - B00001111, B10000000, - B00011100, B00000000, - B00111000, B00000000, - B01110000, B00000000, - B11100000, B00000000, - B11000000, B00000000, - B10000000, B00000000 -}; - -byte const run6[] PROGMEM = { - 16, 16, - B00000000, B00000000, - B00000000, B00011100, - B00000000, B00111110, - B00000001, B11111110, - B00000000, B11100000, - B00000001, B11100000, - B00000001, B11111000, - B00000011, B00011100, - B00000110, B00111000, - B00000110, B01110000, - B00001100, B00100000, - B00111000, B00000000, - B01100000, B00000000, - B11000000, B00000000, - B10000000, B00000000, - B10000000, B00000000 -}; - -byte const run7[] PROGMEM = { - 18, 16, - B00000000, B00000011, B10000000, - B00000000, B01111011, B10000000, - B00000000, B01111111, B10000000, - B00000000, B00001111, B00100000, - B00000000, B00011001, B11000000, - B00000000, B00110000, B11000000, - B00000000, B01110000, B00000000, - B00000001, B11110000, B00000000, - B11111111, B10111000, B00000000, - B11111111, B00011100, B00000000, - B00000000, B00001110, B00000000, - B00000000, B00000111, B00000000, - B00000000, B00000011, B10000000, - B00000000, B00000001, B11000000, - B00000000, B00000000, B01000000, - B00000000, B00000000, B00000000 -}; - -byte const run8[] PROGMEM = { - 18, 16, - B00000000, B00000110, B00000000, - B00000001, B11101111, B00000000, - B00000001, B11111111, B00000000, - B00000000, B00111110, B00000000, - B00000000, B01111111, B11000000, - B00000000, B11100011, B10000000, - B00000001, B11000000, B00000000, - B00000011, B11100000, B00000000, - B11111111, B01110000, B00000000, - B11111110, B00111000, B00000000, - B00000000, B00011100, B00000000, - B00000000, B00000110, B00000000, - B00000000, B00000110, B00000000, - B00000000, B00000111, B00000000, - B00000000, B00000011, B00000000, - B00000000, B00000001, B00000000 -}; - -byte const run9[] PROGMEM = { - 16, 16, - B00000000, B00000000, - B00000000, B01001110, - B00000001, B11101110, - B00000011, B11111110, - B00000011, B11111110, - B00000001, B10111100, - B00000011, B00000000, - B00000111, B00000000, - B11111111, B10000000, - B11111100, B11000000, - B00000000, B11000000, - B00000000, B11000000, - B00000000, B11000000, - B00000000, B11000000, - B00000000, B11000000, - B00000000, B11000000 -}; - -byte const run10[] PROGMEM = { - 13, 16, - B00000000, B00000000, - B00000000, B00110000, - B00000000, B01111000, - B00000111, B11111000, - B00001111, B11111000, - B00000111, B11000000, - B00001110, B00000000, - B00001100, B00000000, - B00001100, B00000000, - B01111100, B00000000, - B11111100, B00000000, - B00011000, B00000000, - B00110000, B00000000, - B01110000, B00000000, - B01100000, B00000000, - B01000000, B00000000 -}; - -Bitmap::ProgMem frames[] = { - run1, - run2, - run3, - run4, - run5, - run6, - run7, - run8, - run9, - run10 -}; -#define NUM_FRAMES (sizeof(frames) / sizeof(frames[0])) -unsigned int frame = 0; - -#define ADVANCE_MS (1000 / NUM_FRAMES) -unsigned long lastFrame; - -void setup() { - lastFrame = millis() - ADVANCE_MS; -} - -void loop() { - if ((millis() - lastFrame) >= ADVANCE_MS) { - display.clear(); - int x = (32 - pgm_read_byte(frames[frame])) / 2; - display.drawBitmap(x, 0, frames[frame]); - lastFrame += ADVANCE_MS; - frame = (frame + 1) % NUM_FRAMES; - } - display.loop(); -} diff --git a/libraries/DMD/examples/RunningFigureISR/RunningFigureISR.ino b/libraries/DMD/examples/RunningFigureISR/RunningFigureISR.ino deleted file mode 100644 index 7f52b652..00000000 --- a/libraries/DMD/examples/RunningFigureISR/RunningFigureISR.ino +++ /dev/null @@ -1,263 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#include - -DMD display; - -// Running stick figure pictures are loosely based on those from this tutorial: -// http://www.fluidanims.com/FAelite/phpBB3/viewtopic.php?f=10&t=102 - -byte const run1[] PROGMEM = { - 16, 16, - B00000000, B00001100, - B00000000, B00011110, - B00000111, B11111110, - B00001111, B11111110, - B00011100, B11111100, - B00000001, B11111100, - B00000001, B11110000, - B00000011, B11111000, - B00000111, B00011000, - B00001110, B01110000, - B00011100, B01100000, - B00111000, B00000000, - B01110000, B00000000, - B01100000, B00000000, - B01000000, B00000000, - B00000000, B00000000 -}; - -byte const run2[] PROGMEM = { - 18, 16, - B00000000, B01110011, B10000000, - B00000000, B11111111, B10000000, - B00000000, B00011111, B10000000, - B00000000, B00111111, B11000000, - B00000000, B01111011, B11000000, - B00000000, B11110011, B10000000, - B00000001, B11100000, B00000000, - B00000011, B11100000, B00000000, - B00000111, B01110000, B00000000, - B01111110, B00111000, B00000000, - B11111100, B00011100, B00000000, - B00000000, B00001110, B00000000, - B00000000, B00000111, B00000000, - B00000000, B00000011, B10000000, - B00000000, B00000001, B00000000, - B00000000, B00000000, B00000000 -}; - -byte const run3[] PROGMEM = { - 18, 16, - B00000000, B00110000, B00000000, - B00000000, B01111000, B00000000, - B00000000, B00011111, B00000000, - B00000000, B00011111, B00000000, - B00000000, B00111111, B10000000, - B00000000, B01111111, B11000000, - B00000000, B11100011, B10000000, - B00000001, B11000000, B00000000, - B00000011, B11100000, B00000000, - B11111111, B01110000, B00000000, - B11111110, B00111000, B00000000, - B00000000, B00011000, B00000000, - B00000000, B00011100, B00000000, - B00000000, B00001110, B00000000, - B00000000, B00000100, B00000000, - B00000000, B00000000, B00000000 -}; - -byte const run4[] PROGMEM = { - 16, 16, - B00000001, B11100000, - B00000011, B11111100, - B00000000, B00111110, - B00000000, B01111110, - B00000000, B11111100, - B00000001, B10011111, - B00000011, B00001110, - B00000011, B00000000, - B00000011, B10000000, - B11111111, B10000000, - B11111000, B11000000, - B00000001, B11000000, - B00000011, B10000000, - B00000111, B00000000, - B00000110, B00000000, - B00000100, B00000000 -}; - -byte const run5[] PROGMEM = { - 13, 16, - B00000000, B00000000, - B00000000, B00110000, - B00000111, B11111000, - B00000111, B11111000, - B00000111, B11110000, - B00001111, B11100000, - B00000111, B00000000, - B00001111, B00000000, - B00001111, B00000000, - B00001111, B10000000, - B00011100, B00000000, - B00111000, B00000000, - B01110000, B00000000, - B11100000, B00000000, - B11000000, B00000000, - B10000000, B00000000 -}; - -byte const run6[] PROGMEM = { - 16, 16, - B00000000, B00000000, - B00000000, B00011100, - B00000000, B00111110, - B00000001, B11111110, - B00000000, B11100000, - B00000001, B11100000, - B00000001, B11111000, - B00000011, B00011100, - B00000110, B00111000, - B00000110, B01110000, - B00001100, B00100000, - B00111000, B00000000, - B01100000, B00000000, - B11000000, B00000000, - B10000000, B00000000, - B10000000, B00000000 -}; - -byte const run7[] PROGMEM = { - 18, 16, - B00000000, B00000011, B10000000, - B00000000, B01111011, B10000000, - B00000000, B01111111, B10000000, - B00000000, B00001111, B00100000, - B00000000, B00011001, B11000000, - B00000000, B00110000, B11000000, - B00000000, B01110000, B00000000, - B00000001, B11110000, B00000000, - B11111111, B10111000, B00000000, - B11111111, B00011100, B00000000, - B00000000, B00001110, B00000000, - B00000000, B00000111, B00000000, - B00000000, B00000011, B10000000, - B00000000, B00000001, B11000000, - B00000000, B00000000, B01000000, - B00000000, B00000000, B00000000 -}; - -byte const run8[] PROGMEM = { - 18, 16, - B00000000, B00000110, B00000000, - B00000001, B11101111, B00000000, - B00000001, B11111111, B00000000, - B00000000, B00111110, B00000000, - B00000000, B01111111, B11000000, - B00000000, B11100011, B10000000, - B00000001, B11000000, B00000000, - B00000011, B11100000, B00000000, - B11111111, B01110000, B00000000, - B11111110, B00111000, B00000000, - B00000000, B00011100, B00000000, - B00000000, B00000110, B00000000, - B00000000, B00000110, B00000000, - B00000000, B00000111, B00000000, - B00000000, B00000011, B00000000, - B00000000, B00000001, B00000000 -}; - -byte const run9[] PROGMEM = { - 16, 16, - B00000000, B00000000, - B00000000, B01001110, - B00000001, B11101110, - B00000011, B11111110, - B00000011, B11111110, - B00000001, B10111100, - B00000011, B00000000, - B00000111, B00000000, - B11111111, B10000000, - B11111100, B11000000, - B00000000, B11000000, - B00000000, B11000000, - B00000000, B11000000, - B00000000, B11000000, - B00000000, B11000000, - B00000000, B11000000 -}; - -byte const run10[] PROGMEM = { - 13, 16, - B00000000, B00000000, - B00000000, B00110000, - B00000000, B01111000, - B00000111, B11111000, - B00001111, B11111000, - B00000111, B11000000, - B00001110, B00000000, - B00001100, B00000000, - B00001100, B00000000, - B01111100, B00000000, - B11111100, B00000000, - B00011000, B00000000, - B00110000, B00000000, - B01110000, B00000000, - B01100000, B00000000, - B01000000, B00000000 -}; - -Bitmap::ProgMem frames[] = { - run1, - run2, - run3, - run4, - run5, - run6, - run7, - run8, - run9, - run10 -}; -#define NUM_FRAMES (sizeof(frames) / sizeof(frames[0])) -unsigned int frame = 0; - -#define ADVANCE_MS (1000 / NUM_FRAMES) - -ISR(TIMER1_OVF_vect) -{ - display.refresh(); -} - -void setup() { - display.enableTimer1(); -} - -void loop() { - display.clear(); - int x = (32 - pgm_read_byte(frames[frame])) / 2; - display.drawBitmap(x, 0, frames[frame]); - frame = (frame + 1) % NUM_FRAMES; - - delay(ADVANCE_MS); -} diff --git a/libraries/DMD/keywords.txt b/libraries/DMD/keywords.txt deleted file mode 100644 index ce3266e9..00000000 --- a/libraries/DMD/keywords.txt +++ /dev/null @@ -1,43 +0,0 @@ -DMD KEYWORD1 -Bitmap KEYWORD1 - -doubleBuffer KEYWORD2 -setDoubleBuffer KEYWORD2 -swapBuffers KEYWORD2 -swapBuffersAndCopy KEYWORD2 -refresh KEYWORD2 -enableTimer1 KEYWORD2 -disableTimer1 KEYWORD2 - -isValid KEYWORD2 -width KEYWORD2 -height KEYWORD2 -stride KEYWORD2 -bitsPerPixel KEYWORD2 -clear KEYWORD2 -pixel KEYWORD2 -setPixel KEYWORD2 -drawLine KEYWORD2 -drawRect KEYWORD2 -drawFilledRect KEYWORD2 -drawCircle KEYWORD2 -drawFilledCircle KEYWORD2 -drawBitmap KEYWORD2 -drawInvertedBitmap KEYWORD2 -font KEYWORD2 -setFont KEYWORD2 -textColor KEYWORD2 -setTextColor KEYWORD2 -drawText KEYWORD2 -drawChar KEYWORD2 -charWidth KEYWORD2 -textWidth KEYWORD2 -textHeight KEYWORD2 -copy KEYWORD2 -fill KEYWORD2 -scroll KEYWORD2 -invert KEYWORD2 - -Black LITERAL1 -White LITERAL1 -NoFill LITERAL1 diff --git a/libraries/I2C/EEPROM24.cpp b/libraries/I2C/EEPROM24.cpp deleted file mode 100644 index dcd093a3..00000000 --- a/libraries/I2C/EEPROM24.cpp +++ /dev/null @@ -1,310 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#include "EEPROM24.h" -#include "I2CMaster.h" - -/** - * \class EEPROM24 EEPROM24.h - * \brief Reading and writing EEPROM's from the 24LCXX family. - * - * The 24LCXX family of EEPROM's provide a variety of memory sizes from - * 16 bytes up to 128 kBytes that can be accessed via the I2C protocol. - * These chips can be used to augment the 1 kByte or so of builtin EEPROM - * memory that is typical on Arduino boards. The EEPROM should be wired - * to an Arduino Uno as follows: - * - * \image html eeprom_circuit.png - * - * Access to a 24LCXX chip is initialized as follows: - * - * \code - * SoftI2C i2c(A4, A5); - * EEPROM24 eeprom(i2c, EEPROM_24LC256); - * \endcode - * - * Once initialized, read() and write() can be used to manipulate the - * contents of the EEPROM's memory. - * - * The following EEPROM types are supported by this class: - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
ChipTypeSize
24lc00\c EEPROM_24LC0016 bytes
24lc01\c EEPROM_24LC01128 bytes
24lc014\c EEPROM_24LC014128 bytes
24lc02\c EEPROM_24LC02256 bytes
24lc024\c EEPROM_24LC024256 bytes
24lc025\c EEPROM_24LC025256 bytes
24lc04\c EEPROM_24LC04512 bytes
24lc08\c EEPROM_24LC081 kByte
24lc16\c EEPROM_24LC162 kBytes
24lc32\c EEPROM_24LC324 kBytes
24lc64\c EEPROM_24LC648 kBytes
24lc128\c EEPROM_24LC12816 kBytes
24lc256\c EEPROM_24LC25632 kBytes
24lc512\c EEPROM_24LC51264 kBytes
24lc1025\c EEPROM_24LC1025128 kBytes
24lc1026\c EEPROM_24LC1026128 kBytes
- * - * There can be multiple 24LCXX chips on the same I2C bus, as long as their - * A0, A1, and A2 address pins are set to different values. For example, - * two 24LC256 chips can be used to provide the same memory capacity as a - * single 24LC512 chip. The optional bank parameter to the constructor - * is used to assign different bank addresses to each chip: - * - * \code - * SoftI2C i2c(A4, A5); - * EEPROM24 eeprom0(i2c, EEPROM_24LC256, 0); - * EEPROM24 eeprom1(i2c, EEPROM_24LC256, 1); - * \endcode - * - * \sa I2CMaster - */ - -/** - * \brief Constructs a new EEPROM access object on \a bus for an EEPROM - * of the specified \a type. - * - * The \a bank can be used to choose between multiple EEPROM's on - * \a bus of the specified \a type. The \a bank corresponds to the value - * that is set on the EEPROM's A0, A1, and A2 address pins. Note that - * some EEPROM's have less than 3 address pins; consult the datasheet - * for more information. - */ -EEPROM24::EEPROM24(I2CMaster &bus, unsigned long type, uint8_t bank) - : _bus(&bus) - , _size((type & 0xFFFF) * ((type >> 16) & 0x0FFF)) - , _pageSize((type >> 16) & 0x0FFF) - , _mode((uint8_t)((type >> 28) & 0x0F)) - , i2cAddress(0x50) -{ - // Adjust the I2C address for the memory bank of the chip. - switch (_mode) { - case EE_BSEL_NONE: - i2cAddress += (bank & 0x07); - break; - case EE_BSEL_8BIT_ADDR: { - uint8_t addrBits = 8; - unsigned long size = 0x0100; - while (size < _size) { - ++addrBits; - size <<= 1; - } - if (addrBits < 11) - i2cAddress += ((bank << (addrBits - 8)) & 0x07); - break; } - case EE_BSEL_17BIT_ADDR: - i2cAddress += ((bank << 1) & 0x06); - break; - case EE_BSEL_17BIT_ADDR_ALT: - i2cAddress += bank & 0x03; - break; - } -} - -/** - * \fn unsigned long EEPROM24::size() const - * \brief Returns the size of the EEPROM in bytes. - * - * \sa pageSize() - */ - -/** - * \fn unsigned long EEPROM24::pageSize() const - * \brief Returns the size of a single EEPROM page in bytes. - * - * Writes that are a multiple of the page size and aligned on a page - * boundary will typically be more efficient than non-aligned writes. - * - * \sa size() - */ - -/** - * \brief Returns true if the EEPROM is available on the I2C bus; - * false otherwise. - * - * This function can be used to probe the I2C bus to determine if the - * EEPROM is present or not. - * - * \sa read(), write() - */ -bool EEPROM24::available() -{ - // Perform a "Current Address Read" on the EEPROM. We don't care about - // the returned byte. We only care if the read request was ACK'ed or not. - if (!_bus->startRead(i2cAddress, 1)) - return false; - _bus->read(); - return true; -} - -/** - * \brief Reads a single byte from the EEPROM at \a address. - * - * \sa write() - */ -uint8_t EEPROM24::read(unsigned long address) -{ - if (address >= _size) - return 0; - writeAddress(address); - if (!_bus->startRead(i2cAddress, 1)) - return 0; - return _bus->read(); -} - -/** - * \brief Reads a block of \a length bytes from the EEPROM at \a address - * into the specified \a data buffer. - * - * Returns the number of bytes that were read, which may be short if - * \a address + \a length is greater than size() or the EEPROM is - * not available on the I2C bus. - * - * \sa write(), available() - */ -size_t EEPROM24::read(unsigned long address, void *data, size_t length) -{ - if (address >= _size || !length) - return 0; - if ((address + length) > _size) - length = (size_t)(_size - address); - writeAddress(address); - if (!_bus->startRead(i2cAddress, length)) - return 0; - uint8_t *d = (uint8_t *)data; - unsigned int count = 0; - while (_bus->available()) { - *d++ = _bus->read(); - ++count; - } - return count; -} - -/** - * \brief Writes a byte \a value to \a address in the EEPROM. - * - * Returns true if the byte was written successfully, or false if - * \a address is out of range or the EEPROM is not available on the I2C bus. - * - * \sa read(), available() - */ -bool EEPROM24::write(unsigned long address, uint8_t value) -{ - if (address >= _size) - return false; - writeAddress(address); - _bus->write(value); - return waitForWrite(); -} - -/** - * \brief Writes \a length bytes from a \a data buffer to \a address - * in the EEPROM. - * - * Returns the number of bytes that were written, which may be short if - * \a address + \a length is greater than size() or the EEPROM is not - * available on the I2C bus. - * - * Best performance will be achieved if \a address and \a length are a - * multiple of pageSize(). - * - * \sa read(), available(), pageSize() - */ -size_t EEPROM24::write(unsigned long address, const void *data, size_t length) -{ - if (address >= _size) - return 0; - if ((address + length) > _size) - length = (size_t)(_size - address); - bool needAddress = true; - size_t result = 0; - size_t page = 0; - const uint8_t *d = (const uint8_t *)data; - while (length > 0) { - if (needAddress) { - writeAddress(address); - needAddress = false; - } - _bus->write(*d++); - ++address; - ++page; - if ((address & (_pageSize - 1)) == 0) { - // At the end of a page, so perform a flush. - if (!waitForWrite()) - return result; // Could not write this page. - needAddress = true; - result += page; - page = 0; - } - --length; - } - if (!needAddress) { - if (!waitForWrite()) - return result; // Could not write the final page. - } - return result + page; -} - -void EEPROM24::writeAddress(unsigned long address) -{ - switch (_mode) { - case EE_BSEL_NONE: - _bus->startWrite(i2cAddress); - _bus->write((uint8_t)(address >> 8)); - _bus->write((uint8_t)address); - break; - case EE_BSEL_8BIT_ADDR: - _bus->startWrite(i2cAddress | (((uint8_t)(address >> 8)) & 0x07)); - _bus->write((uint8_t)address); - break; - case EE_BSEL_17BIT_ADDR: - _bus->startWrite(i2cAddress | (((uint8_t)(address >> 16)) & 0x01)); - _bus->write((uint8_t)(address >> 8)); - _bus->write((uint8_t)address); - break; - case EE_BSEL_17BIT_ADDR_ALT: - _bus->startWrite(i2cAddress | (((uint8_t)(address >> 14)) & 0x04)); - _bus->write((uint8_t)(address >> 8)); - _bus->write((uint8_t)address); - break; - } -} - -bool EEPROM24::waitForWrite() -{ - // 1000 iterations is going to be approximately 100ms when the I2C - // clock is 100 kHz. If there has been no response in that time - // then we assume that the write has failed and timeout. - if (!_bus->endWrite()) - return false; - unsigned count = 1000; - while (count > 0) { - _bus->startWrite(i2cAddress); - if (_bus->endWrite()) - return true; - --count; - } - return false; -} diff --git a/libraries/I2C/EEPROM24.h b/libraries/I2C/EEPROM24.h deleted file mode 100644 index 5f0a7d68..00000000 --- a/libraries/I2C/EEPROM24.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#ifndef EEPROM24_h -#define EEPROM24_h - -#include -#include - -class I2CMaster; - -// Block select modes. -#define EE_BSEL_NONE 0 -#define EE_BSEL_8BIT_ADDR 1 -#define EE_BSEL_17BIT_ADDR 2 -#define EE_BSEL_17BIT_ADDR_ALT 3 - -// Create an EEPROM descriptor from byte size, page size, and block select mode. -#define _EE24(byteSize, pageSize, mode) \ - (((byteSize) / (pageSize)) | (((unsigned long)(pageSize)) << 16) | \ - (((unsigned long)(mode)) << 28)) - -// Type descriptors for the 24LCXX range of EEPROM's. -#define EEPROM_24LC00 _EE24(16UL, 1, EE_BSEL_8BIT_ADDR) -#define EEPROM_24LC01 _EE24(128UL, 8, EE_BSEL_8BIT_ADDR) -#define EEPROM_24LC014 _EE24(128UL, 16, EE_BSEL_8BIT_ADDR) -#define EEPROM_24LC02 _EE24(256UL, 8, EE_BSEL_8BIT_ADDR) -#define EEPROM_24LC024 _EE24(256UL, 16, EE_BSEL_8BIT_ADDR) -#define EEPROM_24LC025 _EE24(256UL, 16, EE_BSEL_8BIT_ADDR) -#define EEPROM_24LC04 _EE24(512UL, 16, EE_BSEL_8BIT_ADDR) -#define EEPROM_24LC08 _EE24(1024UL, 16, EE_BSEL_8BIT_ADDR) -#define EEPROM_24LC16 _EE24(2048UL, 16, EE_BSEL_8BIT_ADDR) -#define EEPROM_24LC32 _EE24(4096UL, 32, EE_BSEL_NONE) -#define EEPROM_24LC64 _EE24(8192UL, 32, EE_BSEL_NONE) -#define EEPROM_24LC128 _EE24(16384UL, 32, EE_BSEL_NONE) -#define EEPROM_24LC256 _EE24(32768UL, 64, EE_BSEL_NONE) -#define EEPROM_24LC512 _EE24(65536UL, 128, EE_BSEL_NONE) -#define EEPROM_24LC1025 _EE24(131072UL, 128, EE_BSEL_17BIT_ADDR_ALT) -#define EEPROM_24LC1026 _EE24(131072UL, 128, EE_BSEL_17BIT_ADDR) - -class EEPROM24 -{ -public: - EEPROM24(I2CMaster &bus, unsigned long type, uint8_t bank = 0); - - unsigned long size() const { return _size; } - unsigned long pageSize() const { return _pageSize; } - - bool available(); - - uint8_t read(unsigned long address); - size_t read(unsigned long address, void *data, size_t length); - - bool write(unsigned long address, uint8_t value); - size_t write(unsigned long address, const void *data, size_t length); - -private: - I2CMaster *_bus; - unsigned long _size; - unsigned long _pageSize; - uint8_t _mode; - uint8_t i2cAddress; - - void writeAddress(unsigned long address); - bool waitForWrite(); -}; - -#endif diff --git a/libraries/I2C/I2CMaster.cpp b/libraries/I2C/I2CMaster.cpp deleted file mode 100644 index 7042aa90..00000000 --- a/libraries/I2C/I2CMaster.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#include "I2CMaster.h" - -/** - * \class I2CMaster I2CMaster.h - * \brief Abstract base class for I2C master implementations. - * - * \sa SoftI2C - */ - -/** - * \fn unsigned int I2CMaster::maxTransferSize() const - * \brief Returns the maximum number of bytes that can be read or written in a single request by this bus master. - */ - -/** - * \fn void I2CMaster::startWrite(unsigned int address) - * \brief Starts a write operation by sending a start condition and the I2C control byte. - * - * The \a address must be the 7-bit or 10-bit address of the I2C slave - * on the bus. - * - * \sa write(), endWrite(), startRead() - */ - -/** - * \fn void I2CMaster::write(uint8_t value) - * \brief Writes a single byte \a value on the I2C bus. - * - * \sa startWrite(), endWrite() - */ - -/** - * \fn bool I2CMaster::endWrite() - * \brief Ends the current write operation. - * - * Returns true if the write operation was acknowledged; false otherwise. - * - * \sa startWrite(), write() - */ - -/** - * \fn bool I2CMaster::startRead(unsigned int address, unsigned int count) - * \brief Starts a read operation for \a count bytes by sending the start condition and the I2C control byte. - * - * The \a address must be the 7-bit or 10-bit address of the I2C slave - * on the bus. - * - * Returns true if the read request was acknowledged by the I2C slave - * or false otherwise. If true, this function should be followed by - * \a count calls to read() to fetch the bytes. - * - * \sa available(), read(), startWrite() - */ - -/** - * \fn unsigned int I2CMaster::available() - * \brief Returns the number of bytes that are still available for reading. - * - * \sa startRead(), read() - */ - -/** - * \fn uint8_t I2CMaster::read() - * \brief Reads a single byte from the I2C bus. - * - * \sa startRead(), available() - */ diff --git a/libraries/I2C/I2CMaster.h b/libraries/I2C/I2CMaster.h deleted file mode 100644 index d5b28ac1..00000000 --- a/libraries/I2C/I2CMaster.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#ifndef I2CMaster_h -#define I2CMaster_h - -#include - -class I2CMaster { -public: - virtual unsigned int maxTransferSize() const = 0; - - virtual void startWrite(unsigned int address); - virtual void write(uint8_t value) = 0; - virtual bool endWrite() = 0; - - virtual bool startRead(unsigned int address, unsigned int count) = 0; - virtual unsigned int available() = 0; - virtual uint8_t read() = 0; -}; - -#endif diff --git a/libraries/I2C/SoftI2C.cpp b/libraries/I2C/SoftI2C.cpp deleted file mode 100644 index eaf4bd49..00000000 --- a/libraries/I2C/SoftI2C.cpp +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#include "SoftI2C.h" -#if defined(ARDUINO) && ARDUINO >= 100 -#include -#else -#include -#endif - -/** - * \class SoftI2C SoftI2C.h - * \brief Bit-banged implementation of an I2C master. - * - * This class implements the I2C master protocol on any arbitrary pair - * of data and clock pins. It is not restricted to pre-defined pins as - * is the case for the standard Arduino two-wire interface. - * - * This implementation only implements the master side of the protocol. - * It assumes that there is a single bus master, no arbitration, and - * no clock stretching. - * - * \sa I2CMaster - */ - -#define i2cDelay() delayMicroseconds(5) - -/** - * \brief Constructs a new software I2C master on \a dataPin and \a clockPin. - */ -SoftI2C::SoftI2C(uint8_t dataPin, uint8_t clockPin) - : _dataPin(dataPin) - , _clockPin(clockPin) - , started(false) - , acked(true) - , inWrite(false) - , readCount(0) -{ - // Initially set the CLOCK and DATA lines to be outputs in the high state. - pinMode(_clockPin, OUTPUT); - pinMode(_dataPin, OUTPUT); - digitalWrite(_clockPin, HIGH); - digitalWrite(_dataPin, HIGH); -} - -unsigned int SoftI2C::maxTransferSize() const -{ - return 0xFFFF; -} - -void SoftI2C::start() -{ - pinMode(_dataPin, OUTPUT); - if (started) { - // Already started, so send a restart condition. - digitalWrite(_dataPin, HIGH); - digitalWrite(_clockPin, HIGH); - i2cDelay(); - } - digitalWrite(_dataPin, LOW); - i2cDelay(); - digitalWrite(_clockPin, LOW); - i2cDelay(); - started = true; - acked = true; -} - -void SoftI2C::stop() -{ - pinMode(_dataPin, OUTPUT); - digitalWrite(_dataPin, LOW); - digitalWrite(_clockPin, HIGH); - i2cDelay(); - digitalWrite(_dataPin, HIGH); - i2cDelay(); - started = false; - inWrite = false; -} - -#define I2C_WRITE 0x00 -#define I2C_WRITE10 0xF0 -#define I2C_READ 0x01 -#define I2C_READ10 0xF1 - -void SoftI2C::startWrite(unsigned int address) -{ - start(); - inWrite = true; - if (address < 0x80) { - // 7-bit address. - write((uint8_t)((address << 1) | I2C_WRITE)); - } else { - // 10-bit address. - write((uint8_t)(((address >> 7) & 0x06)) | I2C_WRITE10); - write((uint8_t)address); - } -} - -void SoftI2C::write(uint8_t value) -{ - uint8_t mask = 0x80; - while (mask != 0) { - writeBit((value & mask) != 0); - mask >>= 1; - } - if (readBit()) // 0: ACK, 1: NACK - acked = false; -} - -bool SoftI2C::endWrite() -{ - stop(); - return acked; -} - -bool SoftI2C::startRead(unsigned int address, unsigned int count) -{ - start(); - inWrite = false; - if (address < 0x80) { - // 7-bit address. - write((uint8_t)((address << 1) | I2C_READ)); - } else { - // 10-bit address. - write((uint8_t)(((address >> 7) & 0x06)) | I2C_READ10); - write((uint8_t)address); - } - if (!acked) { - readCount = 0; - return false; - } - readCount = count; - return true; -} - -unsigned int SoftI2C::available() -{ - return readCount; -} - -uint8_t SoftI2C::read() -{ - uint8_t value = 0; - for (uint8_t bit = 0; bit < 8; ++bit) - value = (value << 1) | readBit(); - if (readCount > 1) { - // More bytes left to read - send an ACK. - writeBit(false); - --readCount; - } else { - // Last byte - send the NACK and a stop condition. - writeBit(true); - stop(); - readCount = 0; - } - return value; -} - -void SoftI2C::writeBit(bool bit) -{ - pinMode(_dataPin, OUTPUT); - if (bit) - digitalWrite(_dataPin, HIGH); - else - digitalWrite(_dataPin, LOW); - i2cDelay(); - digitalWrite(_clockPin, HIGH); - i2cDelay(); - digitalWrite(_clockPin, LOW); - i2cDelay(); -} - -bool SoftI2C::readBit() -{ - pinMode(_dataPin, INPUT); - digitalWrite(_dataPin, HIGH); - digitalWrite(_clockPin, HIGH); - bool bit = digitalRead(_dataPin); - i2cDelay(); - digitalWrite(_clockPin, LOW); - i2cDelay(); - return bit; -} diff --git a/libraries/I2C/SoftI2C.h b/libraries/I2C/SoftI2C.h deleted file mode 100644 index 0b69d061..00000000 --- a/libraries/I2C/SoftI2C.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#ifndef SoftI2C_h -#define SoftI2C_h - -#include "I2CMaster.h" - -class SoftI2C : public I2CMaster { -public: - SoftI2C(uint8_t dataPin, uint8_t clockPin); - - unsigned int maxTransferSize() const; - - void startWrite(unsigned int address); - void write(uint8_t value); - bool endWrite(); - - bool startRead(unsigned int address, unsigned int count); - unsigned int available(); - uint8_t read(); - -private: - uint8_t _dataPin; - uint8_t _clockPin; - bool started; - bool acked; - bool inWrite; - unsigned int readCount; - - void start(); - void stop(); - void writeBit(bool bit); - bool readBit(); -}; - -#endif diff --git a/libraries/I2C/eeprom_circuit.fig b/libraries/I2C/eeprom_circuit.fig deleted file mode 100644 index 9a721b1b..00000000 --- a/libraries/I2C/eeprom_circuit.fig +++ /dev/null @@ -1,100 +0,0 @@ -#FIG 3.2 Produced by xfig version 3.2.5b -Landscape -Center -Metric -A4 -100.00 -Single --2 -1200 2 -6 3105 3555 3195 3645 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 3150 3600 30 30 3150 3600 3150 3630 --6 -6 3105 3780 3195 3870 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 3150 3825 30 30 3150 3825 3150 3855 --6 -6 3105 4005 3195 4095 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 3150 4050 30 30 3150 4050 3150 4080 --6 -6 3060 4095 3240 4365 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 3135 4365 3165 4365 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 3100 4320 3200 4320 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 3060 4275 3240 4275 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 3150 4095 3150 4275 --6 -6 5400 3285 5715 3465 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5580 3375 5715 3375 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5535 3375 5400 3375 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5580 3285 5580 3465 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5535 3285 5535 3465 --6 -6 5760 3600 5940 3870 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5835 3870 5865 3870 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5800 3825 5900 3825 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5760 3780 5940 3780 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5850 3600 5850 3780 --6 -6 5130 3330 5220 3420 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 5175 3375 30 30 5175 3375 5175 3405 --6 -6 5805 3555 5895 3645 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 5850 3600 30 30 5850 3600 5850 3630 --6 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 3150 3600 3825 3600 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 3150 3825 3825 3825 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 3150 4050 3825 4050 -2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 - 3825 3150 4725 3150 4725 4275 3825 4275 3825 3150 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 3825 3375 3150 3375 3150 4140 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 3 - 1 1 1.00 60.00 120.00 - 4725 3375 5175 3375 5175 2700 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5400 3375 5085 3375 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 5850 3375 5670 3375 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 4725 3600 5850 3600 5850 3375 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 3 - 1 1 1.00 60.00 120.00 - 4725 4050 5175 4050 5175 4500 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 3 - 1 1 1.00 60.00 120.00 - 4725 3825 5625 3825 5625 4500 -4 0 0 50 -1 0 12 0.0000 4 135 105 3690 4005 4\001 -4 0 0 50 -1 0 12 0.0000 4 135 105 4770 4005 5\001 -4 0 0 50 -1 0 12 0.0000 4 135 105 4770 3780 6\001 -4 0 0 50 -1 0 12 0.0000 4 135 105 4770 3555 7\001 -4 0 0 50 -1 0 12 0.0000 4 135 105 4770 3330 8\001 -4 0 0 50 -1 0 12 0.0000 4 135 105 3690 3780 3\001 -4 0 0 50 -1 0 12 0.0000 4 135 105 3690 3555 2\001 -4 0 0 50 -1 0 12 0.0000 4 135 105 3690 3330 1\001 -4 0 0 50 -1 0 8 0.0000 4 90 180 3870 3420 A0\001 -4 0 0 50 -1 0 8 0.0000 4 90 180 3870 3645 A1\001 -4 0 0 50 -1 0 8 0.0000 4 90 180 3870 3870 A2\001 -4 0 0 50 -1 0 8 0.0000 4 90 315 3870 4095 GND\001 -4 0 0 50 -1 0 8 0.0000 4 90 210 4500 3645 WP\001 -4 0 0 50 -1 0 8 0.0000 4 90 285 4410 3420 VCC\001 -4 0 0 50 -1 0 8 0.0000 4 90 255 4455 3870 SCL\001 -4 0 0 50 -1 0 8 0.0000 4 90 285 4455 4095 SDA\001 -4 0 0 50 -1 0 12 0.0000 4 135 735 3915 3060 24LCXX\001 -4 0 0 50 -1 0 12 0.0000 4 135 240 5040 2610 5V\001 -4 0 0 50 -1 0 12 0.0000 4 135 525 5310 3195 100nF\001 -4 0 0 50 -1 0 12 0.0000 4 135 240 5040 4680 A4\001 -4 0 0 50 -1 0 12 0.0000 4 135 240 5490 4680 A5\001 diff --git a/libraries/I2C/eeprom_circuit.png b/libraries/I2C/eeprom_circuit.png deleted file mode 100644 index af6013ea..00000000 Binary files a/libraries/I2C/eeprom_circuit.png and /dev/null differ diff --git a/libraries/I2C/keywords.txt b/libraries/I2C/keywords.txt deleted file mode 100644 index 87f7259d..00000000 --- a/libraries/I2C/keywords.txt +++ /dev/null @@ -1,10 +0,0 @@ -I2CMaster KEYWORD1 -SoftI2C KEYWORD1 - -maxTransferSize KEYWORD2 -startWrite KEYWORD2 -write KEYWORD2 -endWrite KEYWORD2 -startRead KEYWORD2 -available KEYWORD2 -read KEYWORD2 diff --git a/libraries/IR/IRreceiver.cpp b/libraries/IR/IRreceiver.cpp deleted file mode 100644 index c03296d6..00000000 --- a/libraries/IR/IRreceiver.cpp +++ /dev/null @@ -1,373 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#include "IRreceiver.h" -#if defined(ARDUINO) && ARDUINO >= 100 -#include -#else -#include -#endif - -/** - * \class IRreceiver IRreceiver.h - * \brief Manages the reception of RC-5 commands from an infrared remote control. - * - * IRreceiver recognizes commands in the Philips RC-5 protocol. - * This is a fairly common infrared protocol, supported by most universal - * remote controls. Program the universal remote to simulate a Philips - * TV, VCR, CD player, etc. - * - * This class uses interrupts to process incoming bits from a standard 3-pin - * infrared receiver: - * - * \image html irchip.jpg - * - * Typically, pin 1 of the receiver should be connected to the Arduino - * interrupt pin (e.g. D2), pin 2 should be connected to GND, and pin 3 - * should be connected to 5V. Consult the datasheet for your receiver to - * be sure though; some receivers may have different pin assignments. - * - * The receiver is initialized by constructing an instance of the - * IRreceiver class: - * - * \code - * IRreceiver ir; - * \endcode - * - * By default, interrupt 0 on pin D2 is used. To change to another interrupt, - * pass its number to the constructor: - * - * \code - * IRreceiver ir(1); // Interrupt 1 on pin D3 - * \endcode - * - * Currently this class can only handle a single instance of IRreceiver being - * active in the application. It isn't possible to have separate IRreceiver - * instances on different pins. Usually this won't be a problem because - * the same receiver can process inputs from multiple remotes. - * - * The application retrieves incoming infrared commands by calling the - * command() function. The return value indicates the type of command: - * - * \code - * void loop() { - * switch (ir.command()) { - * case RC5_0: case RC5_1: case RC5_2: case RC5_3: case RC5_4: - * case RC5_5: case RC5_6: case RC5_7: case RC5_8: case RC5_9: - * // Process a digit - * ... - * break; - * - * case RC5_ERASE: - * // Backspace/erase last digit. - * ... - * break; - * - * case RC5_STANDBY: - * // Power on/off button. - * ... - * break; - * } - * } - * \endcode - * - * If the command is an auto-repeat of a previous button press, then the - * \ref AUTO_REPEAT flag will be set in the value returned from command(). - * The application can choose to ignore all auto-repeats, process all - * auto-repeats, or choose which button to auto-repeat based on its code: - * - * \code - * void loop() { - * switch (ir.command()) { - * case RC5_INC_VOLUME: - * case IRreceiver::AUTO_REPEAT | RC5_INC_VOLUME: - * // Volume increase button pressed or held. - * ... - * break; - * - * case RC5_DEC_VOLUME: - * case IRreceiver::AUTO_REPEAT | RC5_DEC_VOLUME: - * // Volume decrease button pressed or held. - * ... - * break; - * - * case RC5_MUTE: - * // Mute button (ignore auto-repeat). - * ... - * break; - * } - * } - * \endcode - * - * By default, command codes will be generated for every type of RC-5 remote - * control, be it a TV, VCR, CD player, or something else. The application - * can distinguish between the remote controls using system(); noting that - * command() must be called before system() for the system value to be valid. - * For example, the following code could be used in a two-player video game - * where the first player's remote is configured as a TV and the second - * player's remote is configured as a VCR: - * - * \code - * void loop() { - * int cmd = ir.command(); - * int sys = ir.system(); - * if (sys == RC5_SYS_TV) - * player1(cmd); - * else if (sys == RC5_SYS_VCR) - * player2(cmd); - * - * ... - * } - * \endcode - * - * If the application only cares about a single system and wishes to ignore - * all other systems, it can configure a system filter at startup: - * - * \code - * IRreceiver ir; - * - * void setup() { - * ir.setSystemFilter(RC5_SYS_VCR); - * } - * \endcode - * - * The complete list of RC-5 system numbers and command codes is given in - * the RC5.h header file. - * - * \sa \ref ir_dumpir "DumpIR Example" - */ - -static IRreceiver *receiver = 0; - -void _IR_receive_interrupt(void) -{ - receiver->handleInterrupt(); -} - -/** - * \var IRreceiver::AUTO_REPEAT - * \brief Flag that is added to the output of command() when the command - * is an auto-repeated button press rather than the original button press. - */ - -/** - * \brief Constructs a new infrared remote control receiver that is attached - * to \a interruptNumber. - */ -IRreceiver::IRreceiver(int interruptNumber) - : _system(0) - , _systemFilter(-1) - , started(false) - , halfChange(false) - , lastChange(0) - , bits(0) - , bitCount(0) - , buffer(0) - , lastBuffer(0) -{ - switch (interruptNumber) { - case 0: default: pin = 2; break; - case 1: pin = 3; break; - case 2: pin = 21; break; // Arduino Mega only - case 3: pin = 20; break; // Arduino Mega only - case 4: pin = 19; break; // Arduino Mega only - case 5: pin = 18; break; // Arduino Mega only - } - receiver = this; - attachInterrupt(interruptNumber, _IR_receive_interrupt, CHANGE); -} - -/** - * \brief Returns the next command from the remote control. - * - * Returns -1 if there is no new command, or the number between 0 and 127 - * corresponding to the command. If the command is an auto-repeat button - * press rather than an original button press, then the \ref AUTO_REPEAT - * flag will be set. - * - * The companion function system() will return the system number for the - * command indicating whether the command is for a TV, VCR, CD player, etc. - * By default, all systems are reported; use setSystemFilter() to filter - * out commands from all but a specific system. - * - * The next call to command() will return -1 or the code for the next - * button press. - * - * The header file RC5.h contains a list of command codes for - * common remote controls. - * - * \sa system(), setSystemFilter() - */ -int IRreceiver::command() -{ - unsigned buf; - - // Read the last-delivered sequence from the buffer and clear it. - cli(); - buf = buffer; - buffer = 0; - sei(); - - // Bail out if no sequence or it is not for us. - if (!buf) { - _system = -1; - return -1; - } - if (_systemFilter != -1) { - if (((buf >> 6) & 0x1F) != _systemFilter) { - _system = -1; - return -1; - } - } - - // Extract the command. - int cmd = buf & 0x3F; - if ((buf & 0x1000) == 0) - cmd += 64; - - // Is this a new command or an auto-repeat of the previous command? - // Bit 11 will toggle whenever a new button press is started. - if (lastBuffer == buf) - cmd += AUTO_REPEAT; - else - lastBuffer = buf; - _system = (buf >> 6) & 0x1F; - return cmd; -} - -/** - * \fn int IRreceiver::system() const - * \brief Returns the system number of the previous command(), indicating - * whether the command was for a TV, VCR, CD player, etc. - * - * The return value from this function is valid only after a call to - * command(). The next call to command() will clear the system value, - * possibly to -1 if there is no new command. - * - * The header file RC5.h contains a list of system numbers for - * common remote controls. - * - * \sa command(), setSystemFilter() - */ - -/** - * \fn int IRreceiver::systemFilter() const - * \brief Returns the system to filter commands against, or -1 if no - * filter is set. - * - * If this value is -1, then all received systems are returned via command() - * and system() irrespective of whether they are for a TV, VCR, CD player, - * or some other type of system. If this value is set to anything other - * than -1, then only commands for that system are returned via command(). - * - * \sa setSystemFilter(), system(), command() - */ - -/** - * \fn void IRreceiver::setSystemFilter(int system) - * \brief Sets the \a system to filter commands against, or -1 to turn - * off the system filter. - * - * If \a system is -1, then all received systems are returned via command() - * and system() irrespective of whether they are for a TV, VCR, CD player, - * or some other type of system. If \a system is set to anything other - * than -1, then only commands for that system are returned via command(). - * For example: - * - * \code - * IRreceiver ir; - * ir.setSystemFilter(RC5_SYS_VCR); - * \endcode - * - * \sa systemFilter(), system(), command() - */ - -// Number of microseconds that the signal is HIGH or LOW for -// indicating a bit. A 1 bit is transmitted as LOW for 889us -// followed by HIGH for 889us. A 0 bit is HIGH, then LOW. -#define IR_BIT_TIME 889 - -// Number of microseconds to detect a long gap in the coding -// corresponding to 2 time units HIGH or LOW. We actually check -// for at least 1.5 time units to allow for slight variations -// in timing on different remote controls. -#define IR_LONG_BIT_TIME (889 * 6 / 4) - -// Maximum timeout for a single bit. If we don't see a rising edge -// within this time, then we have lost sync and need to restart. -#define IR_MAX_TIME (IR_BIT_TIME * 4) - -// Protocol details from http://en.wikipedia.org/wiki/RC-5 -void IRreceiver::handleInterrupt() -{ - bool value = digitalRead(pin); - unsigned long currentTime = micros(); - if (!value) { - // Rising edge (input is active-LOW) - if (started && (currentTime - lastChange) > IR_MAX_TIME) { - // Too long since the last received bit, so restart the process. - started = false; - } - if (started) { - // We recognize bits on the falling edges, so merely - // adjust the "changed at last half-cycle" flag. - if ((currentTime - lastChange) > IR_LONG_BIT_TIME) { - // Long time since last falling edge indicates that the - // next bit will definitely be a 1. - halfChange = true; - } else { - halfChange = !halfChange; - } - lastChange = currentTime; - } else { - // Encountered the start bit - start receiving up to 14 bits. - lastChange = currentTime; - started = true; - halfChange = true; - bits = 0; - bitCount = 14; - } - } else if (started) { - // Falling edge - if ((currentTime - lastChange) > IR_LONG_BIT_TIME) { - // Long time since last rise indicates 1 followed by 0. - bits = (bits << 2) | 0x02; - --bitCount; - halfChange = true; - } else if (halfChange) { - // Rise was halfway through, so falling edge indicates a 1. - bits = (bits << 1) | 0x01; - halfChange = false; - } else { - // Rise was at the start, so falling edge indicates a 0. - bits <<= 1; - halfChange = true; - } - lastChange = currentTime; - --bitCount; - if (bitCount <= 0) { - // All 14 bits have been received, so deliver the value. - started = false; - buffer = bits; - } - } -} diff --git a/libraries/IR/IRreceiver.h b/libraries/IR/IRreceiver.h deleted file mode 100644 index 39f5cc26..00000000 --- a/libraries/IR/IRreceiver.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#ifndef IRreceiver_h -#define IRreceiver_h - -#include -#include "RC5.h" - -class IRreceiver -{ -public: - explicit IRreceiver(int interruptNumber = 0); - - static const int AUTO_REPEAT = 128; - - int command(); - int system() const { return _system; } - - int systemFilter() const { return _systemFilter; } - void setSystemFilter(int system) { _systemFilter = system; } - -private: - int _system; - int _systemFilter; - uint8_t pin; - bool started; - bool halfChange; // Value last changed half-way through bit cycle time. - unsigned long lastChange; - unsigned bits; - int8_t bitCount; - volatile unsigned buffer; - unsigned lastBuffer; - - void handleInterrupt(); - - friend void _IR_receive_interrupt(void); -}; - -#endif diff --git a/libraries/IR/RC5.h b/libraries/IR/RC5.h deleted file mode 100644 index 64897464..00000000 --- a/libraries/IR/RC5.h +++ /dev/null @@ -1,344 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#ifndef RC5_h -#define RC5_h - -// http://en.wikipedia.org/wiki/RC-5#System_Number_Allocations -#define RC5_SYS_TV 0 // TV receiver 1 -#define RC5_SYS_TV2 1 // TV receiver 2 -#define RC5_SYS_TXT 2 // Teletext -#define RC5_SYS_TV_EXT 3 // Extension to TV 1 & 2 -#define RC5_SYS_LV 4 // Laservision player -#define RC5_SYS_VCR 5 // VCR 1 -#define RC5_SYS_VCR2 6 // VCR 2 -#define RC5_SYS_SAT 8 // Satellite receiver 1 -#define RC5_SYS_VCR_EXT 9 // Extension to VCR 1 & 2 -#define RC5_SYS_SAT2 10 // Satellite receiver 2 -#define RC5_SYS_CD_VIDEO 12 // CD video player -#define RC5_SYS_CD_PHOTO 14 // CD photo player -#define RC5_SYS_PREAMP 16 // Audio preamplifier 1 -#define RC5_SYS_RADIO 17 // Radio tuner -#define RC5_SYS_REC 18 // Casette recorder 1 -#define RC5_SYS_PREAMP2 19 // Audio preamplifier 2 -#define RC5_SYS_CD 20 // CD player -#define RC5_SYS_COMBI 21 // Audio stack or record player -#define RC5_SYS_AUDIO_SAT 22 // Audio satellite -#define RC5_SYS_REC2 23 // Casette recorder 2 -#define RC5_SYS_CD_R 26 // CD recorder - -// http://en.wikipedia.org/wiki/RC-5#Command_Tables -// Table 2, Common commands: -#define RC5_0 0 // Digit 0 -#define RC5_1 1 // Digit 1 -#define RC5_2 2 // Digit 2 -#define RC5_3 3 // Digit 3 -#define RC5_4 4 // Digit 4 -#define RC5_5 5 // Digit 5 -#define RC5_6 6 // Digit 6 -#define RC5_7 7 // Digit 7 -#define RC5_8 8 // Digit 8 -#define RC5_9 9 // Digit 9 -#define RC5_INC_VOLUME 16 // Increase sound volume -#define RC5_DEC_VOLUME 17 // Decrease sound volume -#define RC5_INC_BRIGHTNESS 18 // Increase display brightness -#define RC5_DEC_BRIGHTNESS 19 // Decrease display brightness -#define RC5_INC_BASS 22 // Increase bass response -#define RC5_DEC_BASS 23 // Decrease bass response -#define RC5_INC_TREBLE 24 // Increase treble response -#define RC5_DEC_TREBLE 25 // Decrease treble response -#define RC5_BALANCE_LEFT 26 // Shift sound balance to left -#define RC5_BALANCE_RIGHT 27 // Shift sound balance to right -#define RC5_TRANSMIT_MODE 63 // Select remote transmit mode -#define RC5_DIM 71 // Dim local display -#define RC5_INC_LINEAR 77 // Increase linear control -#define RC5_DEC_LINEAR 78 // Decrease linear control -#define RC5_UP 80 // Move cursor up -#define RC5_DOWN 81 // Move cursor down -#define RC5_MENU_ON 82 // Switch display/screen menu on -#define RC5_MENU_OFF 83 // Switch display/screen menu off -#define RC5_AV_STATUS 84 // Display A/V system status -#define RC5_LEFT 85 // Move cursor left -#define RC5_RIGHT 86 // Move cursor right -#define RC5_OK 87 // Acknowledge function at cursor -#define RC5_SUBMODE 118 // Select sub-mode -#define RC5_OPTIONS 119 // Select options sub-mode -#define RC5_CONNECT_EURO 123 // Connect items via Euroconnector -#define RC5_DISCONNECT_EURO 124 // Disconnect items via Euroconnector - -// http://en.wikipedia.org/wiki/RC-5#Command_Tables -// Table 3, Common video system commands: -#define RC5_INC_SATURATION 20 // Increase color saturation -#define RC5_DEC_SATURATION 21 // Decrease color saturation -#define RC5_PIP 88 // Picture-in-picture on/off -#define RC5_PIP_SHIFT 89 // Picture-in-picture shift -#define RC5_PIP_SWAP 90 // Picture-in-picture swap -#define RC5_PIP_STROBE 91 // Strobe main picture on/off -#define RC5_PIP_MULTI_STROBE 92 // Multi-strobe -#define RC5_PIP_FREEZE_MAIN 93 // Main picture frame frozen -#define RC5_PIP_MULTI_SCAN 94 // 3/9 multi-scan -#define RC5_PIP_SOURCE 95 // Select picture-in-picture source -#define RC5_PIP_MOSAIC 96 // Mosaic/multi-PIP -#define RC5_PIP_NOISE 97 // Digital noise reduction of picture -#define RC5_PIP_STORE 98 // Store main picture -#define RC5_PIP_PHOTO_FINISH 99 // PIP strobe; display photo-finish -#define RC5_PIP_RECALL 100 // Recall main stored picture -#define RC5_PIP_FREEZE 101 // Freeze PIP -#define RC5_PIP_UP 102 // Step up PIP options/source -#define RC5_PIP_DOWN 103 // Step down PIP options/source - -// http://en.wikipedia.org/wiki/RC-5#Command_Tables -// Table 4a, TV and VCR commands: -#define RC5_123 10 // 1/2/3 digit entry -#define RC5_11 11 // Channel/program/frequency 11 -#define RC5_STANDBY 12 // Standby -#define RC5_MUTE 13 // Master mute/de-mute -#define RC5_PREFERENCES 14 // Personal preference settings -#define RC5_DISPLAY_INFO 15 // Display user info on screen -#define RC5_INC_CONTRAST 28 // Increase picture contrast -#define RC5_DEC_CONTRAST 29 // Decrease picture contrast -#define RC5_SEARCH_UP 30 // Search up -#define RC5_DEC_TINT 31 // Decrease tint/hue -#define RC5_CHANNEL_UP 32 // Channel/program up -#define RC5_CHANNEL_DOWN 33 // Channel/program down -#define RC5_CHANNEL_LAST 34 // Last viewed channel/program -#define RC5_STEREO_SELECT 35 // Select stereo channel/language -#define RC5_STEREO_SPATIAL 36 // Spatial stereo -#define RC5_STEREO_TOGGLE 37 // Toggle stereo/mono -#define RC5_SLEEP_TIMER 38 // Sleep timer -#define RC5_INC_TINT 39 // Increase tint/hue -#define RC5_SWITCH_RF 40 // Switch RF inputs -#define RC5_STORE 41 // Store/vote -#define RC5_TIME 42 // Display time -#define RC5_INC_SCAN 43 // Scan forward/increment -#define RC5_DEC_SCAN 44 // Scan backward/decrement -#define RC5_SECONDARY_MENU 46 // Secondary menu -#define RC5_CLOCK 47 // Show clock -#define RC5_PAUSE 48 // Pause -#define RC5_ERASE 49 // Erase/correct entry -#define RC5_REWIND 50 // Rewind -#define RC5_GOTO 51 // Go to -#define RC5_WIND 52 // Wind (fast forward) -#define RC5_PLAY 53 // Play -#define RC5_STOP 54 // Stop -#define RC5_RECORD 55 // Record -#define RC5_EXTERNAL1 56 // External 1 -#define RC5_EXTERNAL2 57 // External 2 -#define RC5_VIEW_DATA 59 // View data, advance -#define RC5_12 60 // Channel 12 (or TXT/TV toggle) -#define RC5_SYSTEM_STANDBY 61 // System standby -#define RC5_CRISP 62 // Picture crispener (coutour boost) -#define RC5_AUDIO_RESPONSE 70 // Audio response for speech/music -#define RC5_SOUND_FUNCTIONS 79 // Select sound functions in sequence -#define RC5_PIP_SIZE 104 // Alter PIP size step-by-step -#define RC5_VISION_FUNCTIONS 105 // Select vision functions in sequence -#define RC5_COLOR_KEY 106 // Colored or other special key -#define RC5_RED 107 // Red button -#define RC5_GREEN 108 // Green button -#define RC5_YELLOW 109 // Yellow button -#define RC5_CYAN 110 // Cyan button -#define RC5_INDEX 111 // Index page/white function -#define RC5_NEXT_OPTION 112 // Next option -#define RC5_PREVIOUS_OPTION 113 // Previous option -#define RC5_STORE_OPEN_CLOSE 122 // Store open/close -#define RC5_PARENTAL_ACCESS 123 // Parental access via PIN code - -// http://en.wikipedia.org/wiki/RC-5#Command_Tables -// Table 4b, TV1 and TV2 extension -#define RC5_DEFAULT_VIDEO 10 // Default video settings (TV1) -#define RC5_DEFAULT_AUDIO 11 // Default audio settings (TV1) -#define RC5_PAYTV_CHANNEL_UP 28 // Pay TV channel up (TV1) -#define RC5_PAYTV_CHANNEL_DOWN 29 // Pay TV channel down (TV1) -#define RC5_RADIO_CHANNEL_UP 30 // Radio channel up (TV1) -#define RC5_RADIO_CHANNEL_DOWN 31 // Radio channel down (TV1) -#define RC5_TILT_FORWARD 32 // Tilt cabinet forward (TV1) -#define RC5_TILT_BACKWARD 33 // Tilt cabinet backward (TV1) -#define RC5_EXTERNAL3 56 // External 3 (TV1) -#define RC5_EXTERNAL4 56 // External 4 (TV1) -#define RC5_PICTURE_FORMAT 62 // 4:3 vs 16:9 (TV1) -#define RC5_CHANNEL_10 67 // Channel 10 -#define RC5_CHANNEL_11 68 // Channel 11 -#define RC5_CHANNEL_12 69 // Channel 12 -#define RC5_DEFAULT_VIDEO2 72 // Default video settings (TV2) -#define RC5_DEFAULT_AUDIO2 73 // Default audio settings (TV2) -#define RC5_PAYTV_CHANNEL_UP2 88 // Pay TV channel up (TV2) -#define RC5_PAYTV_CHANNEL_DOWN2 89 // Pay TV channel down (TV2) -#define RC5_RADIO_CHANNEL_UP2 90 // Radio channel up (TV2) -#define RC5_RADIO_CHANNEL_DOWN2 91 // Radio channel down (TV2) -#define RC5_TILT_FORWARD2 104 // Tilt cabinet forward (TV2) -#define RC5_TILT_BACKWARD2 105 // Tilt cabinet backward (TV2) -#define RC5_EXTERNAL3_2 120 // External 3 (TV2) -#define RC5_EXTERNAL4_2 121 // External 4 (TV2) -#define RC5_CHANNEL_MENU 122 // Channel setting menu -#define RC5_PICTURE_FORMAT2 126 // 4:3 vs 16:9 (TV2) - -// http://en.wikipedia.org/wiki/RC-5#Command_Tables -// Table 5, Teletext commands -#define RC5_NEXT_PAGE 10 // Next page -#define RC5_PREVIOUS_PAGE 11 // Previous page -// RC5_STANDBY 12 // Standby -#define RC5_ENTER_PAGE_NUMBER 28 // Enter page number in memory -#define RC5_SEQ_DISPLAY 29 // Sequential display of pages -#define RC5_SEQ_DELETE 30 // Sequential display/deletion of pages -#define RC5_EXCHANGE 32 // Exchange (Antiope function) -#define RC5_MAIN_INDEX 33 // Main index -#define RC5_ROW_ZERO 34 // Row zero (Antiope function) -#define RC5_PRINT 38 // Print displayed page -#define RC5_MIX 39 // Mix Antiope/TV pictures -#define RC5_HOLD_PAGE 41 // Page hold -// RC5_TIME 42 // Display time -#define RC5_LARGE 43 // Large top/bottom/normal -#define RC5_REVEAL 44 // Reveal/conceal -#define RC5_TV_TXT 45 // TV/TXT -#define RC5_TV_TXT_SUBTITLE 46 // TV + TXT/subtitle -// RC5_ERASE 49 // Erase/correct entry -#define RC5_NEWS_FLASH 62 // News flash (Antiope function) - -// http://en.wikipedia.org/wiki/RC-5#Command_Tables -// Table 6, LaserVision commands -#define RC5_PICTURE_NUMBER 10 // Display picture number/time -#define RC5_CHAPTER_NUMBER 11 // Display chapter number -// RC5_STANDBY 12 // Standby -// RC5_MUTE 13 // Master mute/de-mute -// RC5_DISPLAY_INFO 15 // Display user info on screen -#define RC5_SHUFFLE 28 // Total shuffle play/repeat once -#define RC5_REPEAT 29 // Repeat continuously -#define RC5_SELECT_NEXT 30 // Select next option -#define RC5_FAST_REVERSE 31 // Fast run reverse -#define RC5_ENTRY 32 // Entry (prepare to program) -#define RC5_AUTO_STOP 33 // Auto-stop at pre-programmed point -#define RC5_SLOW_REVERSE 34 // Slow run reverse -#define RC5_STEREO_CHANNEL1 35 // Select stereo sound channel 1/language 1 -#define RC5_STEREO_CHANNEL2 36 // Select stereo sound channel 2/language 2 -#define RC5_DEC_STILL 37 // Still increment reverse -#define RC5_INC_SPEED 38 // Increase speed -#define RC5_DEC_SPEED 39 // Decrease speed -#define RC5_SLOW_FORWARD 40 // Slow run forward -#define RC5_INC_STILL 41 // Still increment forward -#define RC5_FAST_FORWARD 42 // Fast run forward -#define RC5_SEARCH_USER_CHOICE 43 // Automatic search for user choice -#define RC5_SEARCH_REVERSE 44 // Search in reverse -#define RC5_TRAY 45 // Open/close tray -#define RC5_SEARCH_FORWARD 46 // Search forward -#define RC5_PLAY_REVERSE 47 // Play reverse/play opposite sound track -// RC5_PAUSE 48 // Pause -// RC5_ERASE 49 // Erase/correct entry -// RC5_PLAY 53 // Play -// RC5_STOP 54 // Stop -#define RC5_CLEAR_MEMORY 58 // Clear memory all -#define RC5_FREEZE_SEGMENT 59 // Freeze segment(s) indicated by picture numbers. -#define RC5_TV_TXT_ALT 60 // TV/TXT toggle; RF switch (USA only) -#define RC5_CX 62 // CX 1, 2, 3; toggle for CX noise reduction - -// http://en.wikipedia.org/wiki/RC-5#Command_Tables -// Table 11, Preamplifier commands -#define RC5_GEQ_L 10 // Graphic equalizer left -#define RC5_GEQ_R 11 // Graphic equalizer right -// RC5_STANDBY 12 // Standby -// RC5_MUTE 13 // Master mute/de-mute -// RC5_PREFERENCES 14 // Personal preference settings -// RC5_DISPLAY_INFO 15 // Display user info on screen -#define RC5_GEQ_L_AND_R 28 // Graphic equalizer left and right -#define RC5_SPEAKER_SELECT 29 // Speaker select -#define RC5_SCRATCH_FILTER 30 // Scratch filter on/off -#define RC5_RUMBLE_FILTER 31 // Rumble filter on/off -#define RC5_INC_STEP 32 // Step function + -#define RC5_DEC_STEP 33 // Step function - -#define RC5_SIGNAL_PATH 34 // Signal path options -#define RC5_SPEAKER_A 35 // Speaker A on/off -#define RC5_SURROUND_OPTIONS 37 // Surround sound options -// RC5_SLEEP_TIMER 38 // Sleep timer -#define RC5_SPEAKER_B 39 // Speaker B on/off -#define RC5_SPEAKER_C 40 // Speaker C on/off -#define RC5_TIMER_PROGRAM 41 // Timer program mode -// RC5_TIME 42 // Display time -#define RC5_INC_TIMER 43 // Timer + -#define RC5_DEC_TIMER 44 // Timer - -#define RC5_TIMER_MEMORY 45 // Open timer memory -#define RC5_ACOUSTIC_CONTROL 46 // Open acoustic control setting memory -#define RC5_ACOUSTIC_SELECT 47 // Select acoustic settings in memory -// RC5_ERASE 49 // Erase/correct entry -// RC5_CLEAR_MEMORY 58 // Clear memory all -#define RC5_DYNAMIC_EXPAND 60 // Dynamic range expand -#define RC5_DYNAMIC_COMPRESS 62 // Dynamic range compress -#define RC5_SURROUND_SOUND 64 // Surround sound on/off -#define RC5_BALANCE_FRONT 65 // Balance front -#define RC5_BALANCE_REAR 66 // Balance rear -#define RC5_LINEAR_SOUND 79 // Scroll linear sound functions -#define RC5_RANDOM_NOISE 88 // Random noise generator on/off -#define RC5_TIMER 89 // Timer on/off -#define RC5_NEWS_TIMER 90 // News timer on/off -#define RC5_INC_CENTER_VOLUME 102 // Increase center channel volume -#define RC5_DEC_CENTER_VOLUME 103 // Decrease center channel volume -#define RC5_INC_DELAY_SURROUND 104 // Increase delay front to surround -#define RC5_DEC_DELAY_SURROUND 105 // Decrease delay front to surround -#define RC5_LINEAR_PHASE 106 // Linear phase -#define RC5_TAPE_MONITOR 122 // Tape monitor - -// http://en.wikipedia.org/wiki/RC-5#Command_Tables -// Table 14, Compact disc player commands -#define RC5_LOCAL_CURSOR 10 // Scroll local display cursor -#define RC5_LOCAL_FUNCTION 11 // Scroll local display function -// RC5_STANDBY 12 // Standby -// RC5_MUTE 13 // Master mute/de-mute -// RC5_DISPLAY_INFO 15 // Display user info on screen -// RC5_SHUFFLE 28 // Total shuffle play/repeat once -// RC5_REPEAT 29 // Repeat continuously -#define RC5_INC_SELECT 30 // Select increment -#define RC5_DEC_SELECT 31 // Select decrement -#define RC5_NEXT 32 // Next -#define RC5_PREVIOUS 33 // Previous -#define RC5_INDEX_NEXT 34 // Index next -#define RC5_INDEX_PREVIOUS 35 // Index previous -#define RC5_PLAY_PROGRAM 36 // Play/program -#define RC5_NOMINAL_SPEED 37 // Speed nominal -// RC5_INC_SPEED 38 // Increase speed -// RC5_DEC_SPEED 39 // Decrease speed -// RC5_STORE 41 // Store/vote -// RC5_INC_SCAN 43 // Scan forward/increment -// RC5_TRAY 45 // Open/close tray -#define RC5_CARTRIDGE 47 // Fast/select disc from catridge -// RC5_PAUSE 48 // Pause -// RC5_ERASE 49 // Erase/correct entry -// RC5_REWIND 50 // Rewind -// RC5_GOTO 51 // Go to -// RC5_WIND 52 // Wind (fast forward) -// RC5_PLAY 53 // Play -// RC5_STOP 54 // Stop -// RC5_CLEAR_MEMORY 58 // Clear memory all -#define RC5_REPEAT_AB 59 // Repeat program marked A/B -// RC5_DYNAMIC_EXPAND 60 // Dynamic range expand -// RC5_DYNAMIC_COMPRESS 62 // Dynamic range compress -#define RC5_DSP 91 // Digital signal processing on/off -#define RC5_DSP_MUSIC 92 // Music mode (DSP) -#define RC5_DSP_ACOUSTICS 93 // Select room acoustics (DSP) -#define RC5_DSP_JAZZ 94 // Jazz/s-hall effect (DSP) -#define RC5_DSP_POP 95 // Pop/s-hall effect (DSP) -#define RC5_DSP_CLASSIC 96 // Classic/church music for music/room mode (DSP) -#define RC5_DSP_EASY 97 // Easy/club music for music/room mode (DSP) -#define RC5_DSP_DISCO 98 // Disco/stadium music for music/room mode (DSP) -#define RC5_SECOND_FAVORITE 107 // Second favorite track selection -#define RC5_FAVORITE 108 // Favorite track selection -#define RC5_TITLE_INTO_MEMORY 109 // Title into memory -#define RC5_FADE 120 // Fade in/out audio - -#endif diff --git a/libraries/IR/examples/DumpIR/DumpIR.ino b/libraries/IR/examples/DumpIR/DumpIR.ino deleted file mode 100644 index a2ad9a2c..00000000 --- a/libraries/IR/examples/DumpIR/DumpIR.ino +++ /dev/null @@ -1,196 +0,0 @@ -/* This example is placed into the public domain */ - -#include - -IRreceiver ir; - -static const char *systems[32] = { - "TV", - "TV2", - "TXT", - "TV_EXT", - "LV", - "VCR", - "VCR2", - "Sys7", - "SAT", - "VCR_EXT", - "SAT2", - "Sys11", - "CD_VIDEO", - "Sys13", - "CD_PHOTO", - "Sys15", - "PREAMP", - "RADIO", - "REC", - "PREAMP2", - "CD", - "COMBI", - "AUDIO_SAT", - "REC2", - "Sys24", - "Sys25", - "CD_R", - "Sys27", - "Sys28", - "Sys29", - "Sys30", - "Sys31" -}; - -// Selection of TV, VCR, and CD commands to assist with command identification. -// May not be correct for all system types. -static const char *commands[128] = { - "0", - "1", - "2", - "3", - "4", - "5", - "6", - "7", - "8", - "9", - "123", - "11", - "STANDBY", - "MUTE", - "PREFERENCES", - "DISPLAY_INFO", - "INC_VOLUME", - "DEC_VOLUME", - "INC_BRIGHTNESS", - "DEC_BRIGHTNESS", - "INC_SATURATION", - "DEC_SATURATION", - "INC_BASS", - "DEC_BASS", - "INC_TREBLE", - "DEC_TREBLE", - "BALANCE_LEFT", - "BALANCE_RIGHT", - "INC_CONTRAST", - "DEC_CONTRAST", - "SEARCH_UP", - "DEC_TINT", - "CHANNEL_UP", - "CHANNEL_DOWN", - "CHANNEL_LAST", - "STEREO_SELECT", - "STEREO_SPATIAL", - "STEREO_TOGGLE", - "SLEEP_TIMER", - "INC_TINT", - "SWITCH_RF", - "STORE", - "TIME", - "INC_SCAN", - "DEC_SCAN", - "TRAY", - "SECONDARY_MENU", - "CLOCK", - "PAUSE", - "ERASE", - "REWIND", - "GOTO", - "WIND", - "PLAY", - "STOP", - "RECORD", - "EXTERNAL_1", - "EXTERNAL_2", - "CLEAR_MEMORY", - "VIEW_DATA", - "12", - "SYSTEM_STANDBY", - "CRISP", - "TRANSMIT_MODE", - "Cmd64", - "Cmd65", - "Cmd66", - "Cmd67", - "Cmd68", - "Cmd69", - "AUDIO_RESPONSE", - "DIM", - "Cmd72", - "Cmd73", - "Cmd74", - "Cmd75", - "Cmd76", - "INC_LINEAR", - "DEC_LINEAR", - "SOUND_FUNCTIONS", - "UP", - "DOWN", - "MENU_ON", - "MENU_OFF", - "AV_STATUS", - "LEFT", - "RIGHT", - "OK", - "PIP", - "PIP_SHIFT", - "PIP_SWAP", - "PIP_STROBE", - "PIP_MULTI_STROBE", - "PIP_FREEZE_MAIN", - "PIP_MULTI_SCAN", - "PIP_SOURCE", - "PIP_MOSAIC", - "PIP_NOISE", - "PIP_STORE", - "PIP_PHOTO_FINISH", - "PIP_RECALL", - "PIP_FREEZE", - "PIP_UP", - "PIP_DOWN", - "PIP_SIZE", - "VERSION_FUNCTIONS", - "COLOR_KEY", - "RED", - "GREEN", - "YELLOW", - "CYAN", - "INDEX", - "NEXT_OPTION", - "PREVIOUS_OPTION", - "Cmd114", - "Cmd115", - "Cmd116", - "Cmd117", - "SUBMODE", - "OPTIONS", - "FADE", - "Cmd121", - "STORE_OPEN_CLOSE", - "CONNECT_EURO", - "DISCONNECT_EURO", - "Cmd125", - "Cmd126", - "Cmd127" -}; - -void setup() { - Serial.begin(9600); -} - -void loop() { - int cmd = ir.command(); - if (cmd >= 0) { - Serial.print("IR system="); - Serial.print(ir.system()); - Serial.print(" (RC5_SYS_"); - Serial.print(systems[ir.system()]); - Serial.print("), command="); - Serial.print(cmd & 0x7F); - Serial.print(" (RC5_"); - Serial.print(commands[cmd & 0x7F]); - Serial.print(")"); - if (cmd & IRreceiver::AUTO_REPEAT) - Serial.println(", auto-repeat"); - else - Serial.println(); - } -} diff --git a/libraries/IR/examples/Snake/Snake.ino b/libraries/IR/examples/Snake/Snake.ino deleted file mode 100644 index 2b015b9b..00000000 --- a/libraries/IR/examples/Snake/Snake.ino +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#include -#include -#include - -#define SNAKE_ADVANCE_TIME 150 -#define SNAKE_BLINK_TIME 500 -#define SNAKE_INC_STEPS 5 -#define SNAKE_MAX_LENGTH 50 -#define SNAKE_START_LENGTH 10 - -struct Point -{ - int x, y; -}; - -DMD display; -IRreceiver ir; -bool paused; -bool gameOver; -bool waitForStart; -bool snakeDrawn; -unsigned long lastChange; -Point direction; -Point snakeParts[SNAKE_MAX_LENGTH]; -int snakeLength; -int incStep; - -ISR(TIMER1_OVF_vect) -{ - display.refresh(); -} - -void setup() { - display.enableTimer1(); - display.setFont(Mono5x7); - startGame(); -} - -void drawSnake(Bitmap::Color color) { - for (int index = 0; index < snakeLength; ++index) - display.setPixel(snakeParts[index].x, snakeParts[index].y, color); -} - -void loop() { - // Handle the "Game Over" state. Any key press starts a new game. - int cmd = ir.command(); - if (gameOver) { - if (cmd != -1 && (cmd & IRreceiver::AUTO_REPEAT) == 0) - startGame(); - return; - } - - // Pause the game if waiting for the first start. While waiting, - // blink the location of the snake to help the player get their bearings. - if (waitForStart) { - if (cmd == -1) { - if ((millis() - lastChange) >= SNAKE_BLINK_TIME) { - snakeDrawn = !snakeDrawn; - drawSnake(snakeDrawn ? Bitmap::White : Bitmap::Black); - lastChange += SNAKE_BLINK_TIME; - } - return; - } - drawSnake(Bitmap::White); - waitForStart = false; - snakeDrawn = true; - lastChange = millis(); - } - - // Process commands from the player. - switch (cmd) { - - // Both arrow keys and numbers can be used to control the direction, - // in case the remote control does not have arrow keys. - case RC5_LEFT: case RC5_4: - changeDirection(-1, 0); - break; - case RC5_RIGHT: case RC5_6: - changeDirection(1, 0); - break; - case RC5_UP: case RC5_2: - changeDirection(0, -1); - break; - case RC5_DOWN: case RC5_8: - changeDirection(0, 1); - break; - - case RC5_PAUSE: case RC5_PLAY: case RC5_0: - // Pause or resume the game. - paused = !paused; - lastChange = millis(); - break; - - case RC5_STOP: case RC5_STANDBY: - // Stop the game and start a new one. - startGame(); - break; - } - - // Advance the snake position if not paused and the timeout has expired. - if (!paused && (millis() - lastChange) >= SNAKE_ADVANCE_TIME) { - ++incStep; - advanceSnake(incStep >= SNAKE_INC_STEPS); - lastChange += SNAKE_ADVANCE_TIME; - } -} - -void startGame() { - randomSeed(micros() + analogRead(A0)); // Analog read adds some noise. - display.clear(); - display.drawRect(0, 0, display.width() - 1, display.height() - 1); - for (int count = 0; count < 10; ++count) { - int x, y; - if (random(0, 2) == 0) { - x = random(1, display.width() - 5); - y = random(1, display.height() - 1); - display.drawLine(x, y, x + 4, y); - } else { - x = random(1, display.width() - 1); - y = random(1, display.height() - 3); - display.drawLine(x, y, x, y + 2); - } - } - paused = false; - gameOver = false; - waitForStart = true; - snakeDrawn = true; - lastChange = millis(); - direction.x = 1; - direction.y = 0; - incStep = 0; - snakeLength = SNAKE_START_LENGTH; - for (int index = 0; index < snakeLength; ++index) { - snakeParts[index].x = 3 + index; - snakeParts[index].y = 4; - display.setPixel - (snakeParts[index].x, snakeParts[index].y, Bitmap::White); - } -} - -void changeDirection(int x, int y) { - direction.x = x; - direction.y = y; -} - -void advanceSnake(bool increase) { - int x = snakeParts[snakeLength - 1].x + direction.x; - int y = snakeParts[snakeLength - 1].y + direction.y; - if (display.pixel(x, y) == Bitmap::White) { - gameOver = true; - display.clear(); - display.drawText(5, 0, "Game"); - display.drawText(3, 8, "Over!"); - return; - } - if (!increase || snakeLength >= SNAKE_MAX_LENGTH) { - display.setPixel(snakeParts[0].x, snakeParts[0].y, Bitmap::Black); - for (int index = 0; index < snakeLength - 1; ++index) - snakeParts[index] = snakeParts[index + 1]; - } else { - ++snakeLength; - } - snakeParts[snakeLength - 1].x = x; - snakeParts[snakeLength - 1].y = y; - display.setPixel(x, y, Bitmap::White); - if (increase) - incStep = 0; -} diff --git a/libraries/IR/irchip.jpg b/libraries/IR/irchip.jpg deleted file mode 100644 index 912f86b6..00000000 Binary files a/libraries/IR/irchip.jpg and /dev/null differ diff --git a/libraries/IR/keywords.txt b/libraries/IR/keywords.txt deleted file mode 100644 index df7aab67..00000000 --- a/libraries/IR/keywords.txt +++ /dev/null @@ -1,8 +0,0 @@ -IRreceiver KEYWORD1 - -command KEYWORD2 -system KEYWORD2 -systemFilter KEYWORD2 -setSystemFilter KEYWORD2 - -AUTO_REPEAT LITERAL1 diff --git a/libraries/LCD/BoolField.cpp b/libraries/LCD/BoolField.cpp deleted file mode 100644 index defa9149..00000000 --- a/libraries/LCD/BoolField.cpp +++ /dev/null @@ -1,197 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#include "BoolField.h" - -/** - * \class BoolField BoolField.h - * \brief Field that manages the input of a boolean value. - * - * BoolField is intended for field values that are modifiable by the user. - * Pressing one of Up or Down will toggle the field's current value. - * - * The following example creates a boolean field that shows the state - * of the status LED on D13. When the LED is on (the default), the string - * "On" will be displayed on the LCD screen. When the LED is off, the - * string "Off" will be displayed instead. - * - * \code - * Form mainForm(lcd); - * BoolField ledField(mainForm, "Status LED", "On", "Off", true); - * \endcode - * - * \image html FormBool.png - * - * To actually toggle the LED, the application's main loop() function - * should contain the following code: - * - * \code - * int event = lcd.getButton(); - * if (mainForm.dispatch(event) == FORM_CHANGED) { - * if (mainForm.isCurrent(ledField)) { - * if (ledField.value()) - * digitalWrite(STATUS_LED, HIGH); - * else - * digitalWrite(STATUS_LED, LOW); - * } - * } - * \endcode - * - * Use TextField for read-only fields that report boolean values but - * which are not modifiable by the user. - * - * ListField can be used to select between more than two items. - * - * \sa Field, ListField, TextField - */ - -/** - * \brief Constructs a new boolean field with a specific \a label. - * - * The field is initially not associated with a Form. The field can be - * added to a form later using Form::addField(). - * - * The initial value() will be false. - * - * \sa Form::addField() - */ -BoolField::BoolField(const String &label) - : Field(label) - , _printLen(0) - , _value(false) -{ -} - -/** - * \brief Constructs a new boolean field with a specific \a label and - * attaches it to a \a form. - * - * The initial value() of the field is set to the parameter \a value. - * When value() is true, \a trueLabel will be displayed on the screen. - * When value() is false, \a falseLabel will be displayed on the screen. - * - * \sa value() - */ -BoolField::BoolField(Form &form, const String &label, const String &trueLabel, const String &falseLabel, bool value) - : Field(form, label) - , _trueLabel(trueLabel) - , _falseLabel(falseLabel) - , _printLen(0) - , _value(value) -{ -} - -int BoolField::dispatch(int event) -{ - if (event == LCD_BUTTON_UP || event == LCD_BUTTON_DOWN) { - setValue(!_value); - return FORM_CHANGED; - } else { - return -1; - } -} - -void BoolField::enterField(bool reverse) -{ - Field::enterField(reverse); - printValue(); -} - -/** - * \fn bool BoolField::value() const - * \brief Returns the current value of this field, true or false. - * - * \sa setValue() - */ - -/** - * \brief Sets the current value of this field to \a value. - * - * \sa value() - */ -void BoolField::setValue(bool value) -{ - if (value != _value) { - _value = value; - if (isCurrent()) - printValue(); - } -} - -/** - * \fn const String &BoolField::trueLabel() const - * \brief Returns the string that is displayed when value() is true. - * - * \sa setTrueLabel(), falseLabel() - */ - -/** - * \brief Sets the string that is displayed when value() is true to - * \a trueLabel. - * - * \sa trueLabel(), setFalseLabel() - */ -void BoolField::setTrueLabel(const String &trueLabel) -{ - _trueLabel = trueLabel; - if (isCurrent()) - printValue(); -} - -/** - * \fn const String &BoolField::falseLabel() const - * \brief Returns the string that is displayed when value() is false. - * - * \sa setFalseLabel(), trueLabel() - */ - -/** - * \brief Sets the string that is displayed when value() is false to - * \a falseLabel. - * - * \sa falseLabel(), setTrueLabel() - */ -void BoolField::setFalseLabel(const String &falseLabel) -{ - _falseLabel = falseLabel; - if (isCurrent()) - printValue(); -} - -void BoolField::printValue() -{ - unsigned int len; - lcd()->setCursor(0, 1); - if (_value) { - lcd()->print(_trueLabel); - len = _trueLabel.length(); - while (len++ < _printLen) - lcd()->write(' '); - _printLen = _trueLabel.length(); - } else { - lcd()->print(_falseLabel); - len = _falseLabel.length(); - while (len++ < _printLen) - lcd()->write(' '); - _printLen = _falseLabel.length(); - } -} diff --git a/libraries/LCD/BoolField.h b/libraries/LCD/BoolField.h deleted file mode 100644 index f7774d8d..00000000 --- a/libraries/LCD/BoolField.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#ifndef BoolField_h -#define BoolField_h - -#include "Field.h" - -class BoolField : public Field { -public: - explicit BoolField(const String &label); - BoolField(Form &form, const String &label, const String &trueLabel, const String &falseLabel, bool value); - - int dispatch(int event); - - void enterField(bool reverse); - - bool value() const { return _value; } - void setValue(bool value); - - const String &trueLabel() const { return _trueLabel; } - void setTrueLabel(const String &trueLabel); - - const String &falseLabel() const { return _falseLabel; } - void setFalseLabel(const String &falseLabel); - -private: - String _trueLabel; - String _falseLabel; - int _printLen; - bool _value; - - void printValue(); -}; - -#endif diff --git a/libraries/LCD/Field.cpp b/libraries/LCD/Field.cpp deleted file mode 100644 index edfa7715..00000000 --- a/libraries/LCD/Field.cpp +++ /dev/null @@ -1,194 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#include "Field.h" - -/** - * \class Field Field.h - * \brief Manages a single data input/output field within a Form. - * - * \sa Form, BoolField, IntField, ListField, TextField, TimeField - */ - -/** - * \brief Constructs a new field with a specific \a label. - * - * The field is initially not associated with a Form. The field can be - * added to a form later using Form::addField(). - * - * \sa Form::addField() - */ -Field::Field(const String &label) - : _label(label) - , _form(0) - , next(0) - , prev(0) -{ -} - -/** - * \brief Constructs a new field with a specific \a label and attaches - * it to a \a form. - */ -Field::Field(Form &form, const String &label) - : _label(label) - , _form(0) - , next(0) - , prev(0) -{ - form.addField(this); -} - -/** - * \brief Destroys this field and removes it from its owning Form. - * - * \sa Form::removeField() - */ -Field::~Field() -{ - if (_form) - _form->removeField(this); -} - -/** - * \fn Form *Field::form() const - * \brief Returns the Form that owns this field; null if not associated - * with a Form. - */ - -/** - * \brief Dispatches \a event via this field. - * - * The \a event is usually obtained from LCD::getButton(). - * - * Returns zero if the \a event has been handled and no further action - * is required. - * - * Returns FORM_CHANGED if the \a event has changed the value of this - * field in a manner that may require the application to take further - * action based on the new field value. - * - * Returns -1 if the \a event is not handled by this field, and should - * be handled by the Form itself (particularly for Left and Right buttons). - * The default implementation returns -1 for all events. - * - * \sa Form::dispatch(), LCD::getButton() - */ -int Field::dispatch(int event) -{ - // Nothing to do here. - return -1; -} - -/** - * \brief Enters the field due to form navigation. - * - * This function is typically called when the user presses Left and Right - * buttons to navigate to the field. If \a reverse is true, then navigation - * was due to the Left button being pressed. - * - * This function can assume that the display has been cleared and the - * cursor is positioned at (0, 0). - * - * The default implementation prints the label(). - * - * \sa exitField() - */ -void Field::enterField(bool reverse) -{ - lcd()->print(_label); -} - -/** - * \brief Exits the field due to form navigation. - * - * This function is typically called when the user presses Left and Right - * buttons to navigate from the field. - * - * \sa enterField() - */ -void Field::exitField() -{ - // Nothing to do here. -} - -/** - * \fn const String &Field::label() const - * \brief Returns the label to display in the first line of this field. - * - * \sa setLabel() - */ - -/** - * \brief Sets the \a label to display in the first line of this field. - * - * \sa label() - */ -void Field::setLabel(const String &label) -{ - if (isCurrent()) { - unsigned int prevLen = _label.length(); - unsigned int newLen = label.length(); - _label = label; - lcd()->setCursor(0, 0); - lcd()->print(label); - while (newLen++ < prevLen) - lcd()->write(' '); - updateCursor(); - } else { - _label = label; - } -} - -/** - * \brief Returns true if this field is the currently-displayed field in - * its owning form; false otherwise. - * - * This function should be called from property setters in subclasses to - * determine if the screen should be updated when a property is modified. - */ -bool Field::isCurrent() const -{ - if (!_form->isVisible()) - return false; - return _form->currentField() == this; -} - -/** - * \fn LiquidCrystal *Field::lcd() const - * \brief Returns the LCD that this field is being drawn on. - */ - -/** - * \brief Updates the cursor position after the label has been drawn - * by setLabel(). - * - * The default implementation does nothing. Subclasses that use an LCD - * cursor may override this to ensure that the cursor position stays - * valid after the label is modified. - * - * \sa setLabel() - */ -void Field::updateCursor() -{ - // Nothing to do here. -} diff --git a/libraries/LCD/Field.h b/libraries/LCD/Field.h deleted file mode 100644 index fdfe41e3..00000000 --- a/libraries/LCD/Field.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#ifndef Field_h -#define Field_h - -#include "Form.h" - -class Field { -public: - explicit Field(const String &label); - Field(Form &form, const String &label); - ~Field(); - - Form *form() const { return _form; } - - virtual int dispatch(int event); - - virtual void enterField(bool reverse); - virtual void exitField(); - - const String &label() const { return _label; } - void setLabel(const String &label); - - bool isCurrent() const; - -protected: - LiquidCrystal *lcd() const { return _form->_lcd; } - - virtual void updateCursor(); - -private: - String _label; - Form *_form; - Field *next; - Field *prev; - - friend class Form; -}; - -#endif diff --git a/libraries/LCD/Form.cpp b/libraries/LCD/Form.cpp deleted file mode 100644 index b957f1a8..00000000 --- a/libraries/LCD/Form.cpp +++ /dev/null @@ -1,308 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#include "Form.h" -#include "Field.h" - -/** - * \class Form Form.h - * \brief Manager for a form containing data input/output fields. - * - * See the \ref lcd_form "Form example" for more information on - * creating an application that uses forms and fields. - */ - -/** - * \brief Constructs a new form and associates it with \a lcd. - * - * This constructor is typically followed by calls to construct Field - * values for each of the fields on the form. For example: - * - * \code - * Form mainForm(lcd); - * TextField welcomeField(mainForm, "Form example", "v1.0"); - * \endcode - * - * \image html FormText.png - */ -Form::Form(LiquidCrystal &lcd) - : _lcd(&lcd) - , first(0) - , last(0) - , current(0) -{ -} - -/** - * \brief Detaches all remaining fields and destroys this form. - */ -Form::~Form() -{ - Field *field = first; - Field *next; - while (field != 0) { - next = field->next; - field->_form = 0; - field->next = 0; - field->prev = 0; - field = next; - } -} - -/** - * \brief Dispatches \a event to the currently active field using - * Field::dispatch(). - * - * The \a event is usually obtained from LCD::getButton(). - * - * Returns zero if the \a event has been handled and no further action - * is required. - * - * Returns FORM_CHANGED if one of the fields on the form has changed value - * due to the \a event, perhaps requiring the application to take further - * action based on the new field value. Use currentField() or isCurrent() - * to determine which field has changed. - * - * \code - * int event = lcd.getButton(); - * if (mainForm.dispatch(event) == FORM_CHANGED) { - * if (mainForm.isCurrent(volumeField)) { - * // Adjust the volume to match the field. - * setVolume(volumeField.value()); - * } - * } - * \endcode - * - * This function handles the Left and Right buttons to navigate between fields. - * - * \sa Field::dispatch(), LCD::getButton(), currentField(), isCurrent() - */ -int Form::dispatch(int event) -{ - if (current) { - int exitval = current->dispatch(event); - if (exitval >= 0) - return exitval; - } - if (event == LCD_BUTTON_LEFT) - prevField(); - else if (event == LCD_BUTTON_RIGHT) - nextField(); - return 0; -} - -/** - * \brief Changes to the next field in the "tab order". - * - * \sa prevField(), defaultField(), currentField() - */ -void Form::nextField() -{ - Field *field = current; - if (!field) - field = first; - if (field && field->next) - field = field->next; - else - field = first; - setCurrentField(field); -} - -/** - * \brief Changes to the previous field in the "tab order". - * - * \sa nextField(), defaultField(), currentField() - */ -void Form::prevField() -{ - Field *field = current; - if (!field) - field = last; - if (field && field->prev) - field = field->prev; - else - field = last; - setCurrentField(field); -} - -/** - * \brief Changes to default field (i.e., the first field). - * - * \sa nextField(), prevField(), currentField() - */ -void Form::defaultField() -{ - setCurrentField(first); -} - -/** - * \brief Adds \a field to this form. - * - * Usually this function is not required because the field's constructor - * will add the field to the form automatically. - * - * \sa removeField() - */ -void Form::addField(Field *field) -{ - if (field->_form) - return; // Already added to a form. - field->_form = this; - field->next = 0; - field->prev = last; - if (last) - last->next = field; - else - first = field; - last = field; -} - -/** - * \brief Removes \a field from this form. - * - * If \a field is the current field on-screen, then either the next or - * previous field will be made current. - * - * \sa addField() - */ -void Form::removeField(Field *field) -{ - if (field->_form != this) - return; // Not a member of this form. - if (current == field) { - if (field->next) - setCurrentField(field->next); - else if (field->prev) - setCurrentField(field->prev); - else - setCurrentField(0); - } - if (field->next) - field->next->prev = field->prev; - else - last = field->prev; - if (field->prev) - field->prev->next = field->next; - else - first = field->next; - field->_form = 0; - field->next = 0; - field->prev = 0; -} - -/** - * \fn Field *Form::currentField() const - * \brief Returns the current field that is displayed on-screen. - * - * Returns null if the form has no fields, or setCurrentField() explicitly - * set the current field to null. - * - * \sa setCurrentField(), isCurrent() - */ - -/** - * \brief Sets the current \a field that is displayed on-screen. - * - * Use this function to programmatically force the form to display a - * specific field on-screen. - * - * \sa currentField(), isCurrent() - */ -void Form::setCurrentField(Field *field) -{ - if (field && field->_form != this) - return; // Wrong form. - if (visible) { - bool reverse = false; - if (current) { - current->exitField(); - if (field->next == current) - reverse = true; - else if (!field->next && current == first) - reverse = true; - } - current = field; - _lcd->clear(); - if (current) - current->enterField(reverse); - } else { - current = field; - } -} - -/** - * \fn bool Form::isCurrent(Field &field) const - * \brief Returns true if \a field is currently displayed on-screen, false otherwise. - * - * This function is typically called after dispatch() returns FORM_CHANGED - * to determine which field has changed. - * - * \sa currentField(), setCurrentField() - */ - -/** - * \brief Shows the form, or does nothing if the form is already on-screen. - * - * When the form is shown, the screen will be cleared and the currentField() - * will be drawn. - * - * If the form was previously hidden, then the field that was previously - * current will be shown again. Call defaultField() before show() to reset - * the form to show the first field instead. - * - * \sa hide(), isVisible(), defaultField() - */ -void Form::show() -{ - if (!visible) { - if (!current) - current = first; - visible = true; - _lcd->clear(); - if (current) - current->enterField(false); - } -} - -/** - * \brief Hides the form, or does nothing if the form is not on-screen. - * - * The screen will be cleared to remove the contents of the current field. - * - * \sa show(), isVisible() - */ -void Form::hide() -{ - if (visible) { - if (current) - current->exitField(); - visible = false; - _lcd->clear(); - } -} - -/** - * \fn bool Form::isVisible() const - * \brief Returns true if the form is shown; false if the form is hidden. - * - * \sa show(), hide() - */ diff --git a/libraries/LCD/Form.h b/libraries/LCD/Form.h deleted file mode 100644 index 607b87cb..00000000 --- a/libraries/LCD/Form.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#ifndef Form_h -#define Form_h - -#include "LCD.h" - -class Field; - -#define FORM_CHANGED 1 - -class Form { -public: - explicit Form(LiquidCrystal &lcd); - ~Form(); - - int dispatch(int event); - - void nextField(); - void prevField(); - void defaultField(); - - void addField(Field *field); - void removeField(Field *field); - - Field *currentField() const { return current; } - void setCurrentField(Field *field); - - bool isCurrent(Field &field) const { return current == &field; } - - void show(); - void hide(); - bool isVisible() const { return visible; } - -private: - LiquidCrystal *_lcd; - Field *first; - Field *last; - Field *current; - bool visible; - - friend class Field; -}; - -#endif diff --git a/libraries/LCD/IntField.cpp b/libraries/LCD/IntField.cpp deleted file mode 100644 index 7e903915..00000000 --- a/libraries/LCD/IntField.cpp +++ /dev/null @@ -1,249 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#include "IntField.h" - -/** - * \class IntField IntField.h - * \brief Field that manages the input of an integer value. - * - * IntField is intended for field values that are modifiable by the user. - * Pressing Up adds stepValue() to the current value and pressing Down - * subtracts stepValue() from the current value. The value is clamped to - * the range minValue() to maxValue(). - * - * The following example creates an integer field with the label "Iterations", - * that ranges between 1 and 5, with a stepValue() of 1, and an initial - * default value() of 2: - * - * \code - * Form mainForm(lcd); - * IntField iterField(mainForm, "Iterations", 1, 5, 1, 2); - * \endcode - * - * IntField can be configured to show a suffix() on the screen after the - * integer value(). This is intended for communicating the units in which - * the value is expressed. For example: - * - * \code - * IntField volumeField(mainForm, "Volume", 0, 100, 5, 85, "%"); - * IntField speedField(mainForm, "Speed", 0, 2000, 15, 450, " rpm"); - * \endcode - * - * \image html FormInt.png - * - * Use TextField for read-only fields that report integer values but - * which are not modifiable by the user. - * - * \sa Field, TextField - */ - -/** - * \brief Constructs a new integer field with a specific \a label. - * - * The field is initially not associated with a Form. The field can be - * added to a form later using Form::addField(). - * - * Initially, value() is 0, minValue() is 0, maxValue() is 100, - * stepValue() is 1, and suffix() is an empty string. - * - * \sa Form::addField() - */ -IntField::IntField(const String &label) - : Field(label) - , _minValue(0) - , _maxValue(100) - , _stepValue(1) - , _value(0) - , _printLen(0) -{ -} - -/** - * \brief Constructs a new integer field with a specific \a label, - * \a minValue, \a maxValue, \a stepValue, and \a value, and attaches - * it to a \a form. - * - * The suffix() is initially set to an empty string. - */ -IntField::IntField(Form &form, const String &label, int minValue, int maxValue, int stepValue, int value) - : Field(form, label) - , _minValue(minValue) - , _maxValue(maxValue) - , _stepValue(stepValue) - , _value(value) - , _printLen(0) -{ -} - -/** - * \brief Constructs a new integer field with a specific \a label, - * \a minValue, \a maxValue, \a stepValue, \a value, and \a suffix - * and attaches it to a \a form. - */ -IntField::IntField(Form &form, const String &label, int minValue, int maxValue, int stepValue, int value, const String &suffix) - : Field(form, label) - , _minValue(minValue) - , _maxValue(maxValue) - , _stepValue(stepValue) - , _value(value) - , _printLen(0) - , _suffix(suffix) -{ -} - -int IntField::dispatch(int event) -{ - if (event == LCD_BUTTON_UP) { - setValue(_value + _stepValue); - return FORM_CHANGED; - } else if (event == LCD_BUTTON_DOWN) { - setValue(_value - _stepValue); - return FORM_CHANGED; - } - return -1; -} - -void IntField::enterField(bool reverse) -{ - Field::enterField(reverse); - printValue(); -} - -/** - * \fn int IntField::minValue() const - * \brief Returns the minimum value for the input field. - * - * \sa setMinValue(), maxValue(), stepValue(), value() - */ - -/** - * \fn void IntField::setMinValue(int value) - * \brief Sets the minimum \a value for the input field. - * - * The new minimum \a value will be used to clamp the field's value the - * next time setValue() is called. - * - * \sa minValue(), setMaxValue(), setStepValue(), setValue() - */ - -/** - * \fn int IntField::maxValue() const - * \brief Returns the maximum value for the input field. - * - * \sa setMaxValue(), minValue(), stepValue(), value() - */ - -/** - * \fn void IntField::setMaxValue(int value) - * \brief Sets the maximum \a value for the input field. - * - * The new maximum \a value will be used to clamp the field's value the - * next time setValue() is called. - * - * \sa maxValue(), setMinValue(), setStepValue(), setValue() - */ - -/** - * \fn int IntField::stepValue() const - * \brief Returns the step value to use when increasing or decreasing the - * value() due to Up and Down button presses. - * - * \sa setStepValue(), minValue(), maxValue(), value() - */ - -/** - * \fn void IntField::setStepValue(int value) - * \brief Sets the step value \a value to use when increasing or decreasing - * the value() due to Up and Down button presses. - * - * \sa stepValue(), setMinValue(), setMaxValue(), setValue() - */ - -/** - * \fn int IntField::value() const - * \brief Returns the current value of this field. - * - * \sa setValue(), minValue(), maxValue(), stepValue() - */ - -/** - * \fn void IntField::setValue(int value) - * \brief Sets the current \a value of this field. - * - * The \a value will be clamped to the range defined by minValue() - * and maxValue(). - * - * \sa value(), setMinValue(), setMaxValue(), setStepValue() - */ -void IntField::setValue(int value) -{ - if (value < _minValue) - value = _minValue; - else if (value > _maxValue) - value = _maxValue; - if (value != _value) { - _value = value; - if (isCurrent()) - printValue(); - } -} - -/** - * \fn const String &IntField::suffix() const - * \brief Returns the suffix string to be displayed after the field's value. - * - * \sa setSuffix() - */ - -/** - * \brief Sets the \a suffix string to be displayed after the field's value. - * - * Suffixes are typically used to indicate the units that the value() is - * expressed in. For example: - * - * \code - * field.setSuffix("%"); - * field.setSuffix(" rpm"); - * \endcode - * - * \sa suffix() - */ -void IntField::setSuffix(const String &suffix) -{ - _suffix = suffix; - if (isCurrent()) - printValue(); -} - -void IntField::printValue() -{ - String str(_value); - if (_suffix.length()) - str += _suffix; - lcd()->setCursor(0, 1); - lcd()->print(str); - unsigned int len = str.length(); - while (len++ < _printLen) - lcd()->write(' '); - _printLen = str.length(); -} diff --git a/libraries/LCD/IntField.h b/libraries/LCD/IntField.h deleted file mode 100644 index 592d89b8..00000000 --- a/libraries/LCD/IntField.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#ifndef IntField_h -#define IntField_h - -#include "Field.h" - -class IntField : public Field { -public: - explicit IntField(const String &label); - IntField(Form &form, const String &label, int minValue, int maxValue, int stepValue, int value); - IntField(Form &form, const String &label, int minValue, int maxValue, int stepValue, int value, const String &suffix); - - int dispatch(int event); - - void enterField(bool reverse); - - int minValue() const { return _minValue; } - void setMinValue(int value) { _minValue = value; } - - int maxValue() const { return _maxValue; } - void setMaxValue(int value) { _maxValue = value; } - - int stepValue() const { return _stepValue; } - void setStepValue(int value) { _stepValue = value; } - - int value() const { return _value; } - void setValue(int value); - - const String &suffix() const { return _suffix; } - void setSuffix(const String &suffix); - -private: - int _minValue; - int _maxValue; - int _stepValue; - int _value; - int _printLen; - String _suffix; - - void printValue(); -}; - -#endif diff --git a/libraries/LCD/LCD.cpp b/libraries/LCD/LCD.cpp deleted file mode 100644 index cd3e2b60..00000000 --- a/libraries/LCD/LCD.cpp +++ /dev/null @@ -1,427 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#include "LCD.h" -#include -#if defined(ARDUINO) && ARDUINO >= 100 -#include -#else -#include -#endif - -#define LCD_BACK_LIGHT 3 // Default LCD backlight is on D3 -#define LCD_BUTTON_PIN A0 // Button state is on A0 - -#define DEBOUNCE_DELAY 10 // Delay in ms to debounce buttons - -/** - * \class LCD LCD.h - * \brief Enhanced library for Freetronics 16x2 LCD shields - * - * This class extends the standard Arduino LiquidCrystal library with - * extra functionality for the Freetronics 16x2 LCD shield: - * - * http://www.freetronics.com/pages/16x2-lcd-shield-quickstart-guide - * - * The Freetronics LCD has an additional back light, which is turned - * on and off with the display() and noDisplay() functions. The user - * can also call enableScreenSaver() to cause the display and back light - * to automatically turn off after a specific timeout. - * The setScreenSaverMode() function controls which of the display and - * back light are disabled when the screen saver activates. - * - * The Freetronics LCD also has 5 push buttons for Left, Right, Up, Down, - * and Select, to assist with the creation of interactive sketches. - * The user can call getButton() to get the current button state. - * One of the following values may be returned: - * - * \li LCD_BUTTON_NONE - No button has been pressed, or a button has been - * pressed but not yet released. - * \li LCD_BUTTON_LEFT - Left button was pressed. - * \li LCD_BUTTON_RIGHT - Right button was pressed. - * \li LCD_BUTTON_UP - Up button was pressed. - * \li LCD_BUTTON_DOWN - Down button was pressed. - * \li LCD_BUTTON_SELECT - Select button was pressed. - * \li LCD_BUTTON_LEFT_RELEASED - Left button was released. - * \li LCD_BUTTON_RIGHT_RELEASED - Right button was released. - * \li LCD_BUTTON_UP_RELEASED - Up button was released. - * \li LCD_BUTTON_DOWN_RELEASED - Down button was released. - * \li LCD_BUTTON_SELECT_RELEASED - Select button was released. - * - * For convenience, all RELEASED button codes are the negation of their - * pressed counterparts. That is, LCD_BUTTON_LEFT_RELEASED == -LCD_BUTTON_LEFT. - * LCD_BUTTON_NONE is defined to be zero. Thus, you can check if a - * generic button has been pressed with button > 0 and if a - * generic button has been released with button < 0. - * - * \section lcd_dfrobot Support for DFRobot LCD Shield - * - * The DFRobot LCD Shield - * is almost identical to the Freetronics shield, except it uses pin 10 for - * the back light instead of pin 3. This can be specified in the - * application's setup() function: - * - * \code - * LCD lcd; - * - * void setup() { - * lcd.setBacklightPin(10); - * } - * \endcode - * - * The back light pin is configured for output the first time the - * application calls getButton(). - * - * \sa Form, \ref lcd_hello_world "Hello World Example" - */ - -/** - * \fn LCD::LCD() - * \brief Initialize the Freetronics LCD display with the default - * pin assignment. - * - * The following example shows how to initialize the Freetronics - * LCD shield: - * - * \code - * LCD lcd; - * \endcode - */ - -/** - * \fn LCD::LCD(uint8_t pin9) - * \brief Initialize the Freetronics LCD display for USBDroid. - * - * On the USBDroid, the D9 pin is used for USB Host functionality. - * Either the USB Host's use of D9 must be reassigned to another pin, - * or the Freetronics LCD shield must be modified. The following Web - * page describes the modifications that are necessary: - * http://www.freetronics.com/pages/combining-the-lcd-keypad-shield-and-the-usbdroid - * - * If you choose to modify the LCD shield, then you must use this version - * of the constructor to initialize the shield, passing the alternative - * pin as the \a pin9 parameter. Using the recommended pin from the above - * Web page of A1, you would initialize the LCD as follows: - * - * \code - * LCD lcd(A1); - * \endcode - */ - -/** - * \fn LCD::LCD(uint8_t rs, uint8_t enable, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3) - * \brief Initialize the Freetronics LCD display with custom pins. - * - * For compatibility with other shields, it may be desirable to rewire - * some of the pins entirely. This version of the constructor allows any - * pins to be reassigned from the defaults (which are rs = 8, enable = 9, - * d0 = 4, d1 = 5, d2 = 6, d3 = 7.) - * - * \code - * LCD lcd(8,9,4,5,10,11); - * \endcode - */ - - -void LCD::init() -{ - // The Freetronics display is 16x2. - begin(16, 2); - - // Configure the backlight pin, but don't activate it yet in - // case the application sets it to something else during setup(). - // Initialization will be forced in the first call to getButton(). - _backlightPin = LCD_BACK_LIGHT; - backlightInit = false; - - // Initialise button input. - pinMode(LCD_BUTTON_PIN, INPUT); - digitalWrite(LCD_BUTTON_PIN, LOW); - prevButton = LCD_BUTTON_NONE; - debounceButton = LCD_BUTTON_NONE; - lastDebounce = 0; - eatRelease = false; - - // Initialize screen saver. - timeout = 0; - lastRestore = millis(); - screenSaved = false; - mode = DisplayOff; -} - -/** - * \fn uint8_t LCD::backlightPin() const - * \brief Returns the pin that is being used to control the back light. - * The default is 3. - * - * \sa setBacklightPin() - */ - -/** - * \brief Sets the back light \a pin for the LCD shield. - * - * The DFRobot LCD Shield uses pin 10 for the back light instead of pin 3: - * - * \code - * LCD lcd; - * - * void setup() { - * lcd.setBacklightPin(10); - * } - * \endcode - * - * The back light pin is configured for output the next time the - * application calls getButton(). - * - * \sa backlightPin() - */ -void LCD::setBacklightPin(uint8_t pin) -{ - if (_backlightPin != pin) { - if (backlightInit) { - // Restore the previous backlight pin to input, floating. - pinMode(_backlightPin, INPUT); - digitalWrite(_backlightPin, LOW); - - // Need to re-initialize the backlight at the earliest opportunity. - backlightInit = false; - } - _backlightPin = pin; - } -} - -/** - * \brief Turns on the display of text on the LCD and the back light. - * - * If the screen saver is active, then calling this function will - * deactivate the screen saver and reset the timeout. Thus, this - * function can be called for force the screen to restore. - * - * \sa noDisplay(), enableScreenSaver(), setScreenSaverMode() - */ -void LCD::display() -{ - LiquidCrystal::display(); - pinMode(_backlightPin, OUTPUT); - digitalWrite(_backlightPin, HIGH); - screenSaved = false; - backlightInit = true; - lastRestore = millis(); -} - -/** - * \brief Turns off the display of text on the LCD and the back light. - * - * This function can be called to force the screen saver to activate. - * - * \sa display(), enableScreenSaver(), setScreenSaverMode() - */ -void LCD::noDisplay() -{ - if (mode == DisplayOff) - LiquidCrystal::noDisplay(); - pinMode(_backlightPin, OUTPUT); - digitalWrite(_backlightPin, LOW); - screenSaved = true; - backlightInit = true; -} - -/** - * \enum LCD::ScreenSaverMode - * \brief Screen saver mode that controls the display and back light. - */ - -/** - * \var LCD::DisplayOff - * \brief Turn off both the display and the backlight when the screen saver - * is activated. - */ - -/** - * \var LCD::BacklightOff - * \brief Turn off the back light but leave the display on when the screen - * saver is activated. - */ - -/** - * \var LCD::BacklightOnSelect - * \brief Same as BacklightOff but the screen saver is only deactivated when - * Select is pressed; other buttons have no effect. - */ - -/** - * \fn ScreenSaverMode LCD::screenSaverMode() const - * \brief Returns the current screen saver mode; default is DisplayOff. - * - * \sa setScreenSaverMode(), enableScreenSaver() - */ - -/** - * \brief Sets the current screen saver \a mode. - * - * \sa screenSaverMode(), enableScreenSaver() - */ -void LCD::setScreenSaverMode(ScreenSaverMode mode) -{ - if (this->mode != mode) { - this->mode = mode; - if (screenSaved) - noDisplay(); - else - display(); - } -} - -/** - * \brief Enables the screen saver and causes it to activate after - * \a timeoutSecs of inactivity on the buttons. - * - * If \a timeoutSecs is less than or equal to zero, then the call - * is equivalent to calling disableScreenSaver(). - * - * For the screen saver to work, the application must regularly call - * getButton() to fetch the LCD's button state even if no buttons - * are pressed. - * - * If the \a timeoutSecs parameter is not supplied, the default is 10 seconds. - * - * \sa disableScreenSaver(), display(), getButton(), isScreenSaved() - */ -void LCD::enableScreenSaver(int timeoutSecs) -{ - if (timeoutSecs < 0) - timeout = 0; - else - timeout = ((unsigned long)timeoutSecs) * 1000; - display(); -} - -/** - * \brief Disables the screen saver. - * - * \sa enableScreenSaver(), display(), isScreenSaved() - */ -void LCD::disableScreenSaver() -{ - timeout = 0; - display(); -} - -/** - * \fn bool LCD::isScreenSaved() const - * \brief Returns true if the screen has been saved; false otherwise. - * - * \sa enableScreenSaver() - */ - -// Button mapping table generated by genlookup.c -static unsigned char const buttonMappings[] PROGMEM = { - 2, 0, 0, 0, 3, 0, 0, 0, 0, 4, 4, 0, 0, 0, 0, 1, - 1, 0, 0, 0, 0, 0, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0 -}; -#define mapButton(value) (pgm_read_byte(&(buttonMappings[(value) >> 5]))) - -/** - * \brief Gets the next button press, release, or idle event. - * - * If no buttons are pressed, this function will return LCD_BUTTON_NONE. - * - * When a button is pressed, this function will return one of - * LCD_BUTTON_LEFT, LCD_BUTTON_RIGHT, LCD_BUTTON_UP, LCD_BUTTON_DOWN, - * or LCD_BUTTON_SELECT. While the button is pressed, this function - * will return LCD_BUTTON_NONE until the button is released. When the - * button is released, this function will return one of - * LCD_BUTTON_LEFT_RELEASED, LCD_BUTTON_RIGHT_RELEASED, - * LCD_BUTTON_UP_RELEAED, LCD_BUTTON_DOWN_RELEASED, - * or LCD_BUTTON_SELECT_RELEASED. - * - * If the screen saver is currently active, then it will be deactivated - * by this function whenever a button is pressed. If screenSaverMode() is - * DisplayOff, the function will "eat" the button press and return - * LCD_BUTTON_NONE. The scrren saver can also be deactivated under - * program control by calling display(). - * - * This function debounces the button state automatically so there is no - * need for the caller to worry about spurious button events. - * - * \sa enableScreenSaver(), display(), Form::dispatch() - */ -int LCD::getButton() -{ - // Initialize the backlight for the first time if necessary. - if (!backlightInit) - display(); - - // Read the currently pressed button. - int button = mapButton(analogRead(LCD_BUTTON_PIN)); - - // Debounce the button state. - unsigned long currentTime = millis(); - if (button != debounceButton) - lastDebounce = currentTime; - debounceButton = button; - if ((currentTime - lastDebounce) < DEBOUNCE_DELAY) - button = prevButton; - - // Process the button event if the state has changed. - if (prevButton == LCD_BUTTON_NONE && button != LCD_BUTTON_NONE) { - prevButton = button; - if (screenSaved) { - // Button pressed when screen saver active. - if (mode == BacklightOnSelect) { - // Turn on the back light only if Select was pressed. - if (button == LCD_BUTTON_SELECT) { - pinMode(_backlightPin, OUTPUT); - digitalWrite(_backlightPin, HIGH); - screenSaved = false; - backlightInit = true; - } - } else if (mode == DisplayOff) { - display(); - eatRelease = true; - return LCD_BUTTON_NONE; - } else { - display(); - } - } else if (mode == BacklightOnSelect && button != LCD_BUTTON_SELECT) { - eatRelease = false; - return button; - } - eatRelease = false; - lastRestore = currentTime; - return button; - } else if (prevButton != LCD_BUTTON_NONE && button == LCD_BUTTON_NONE) { - button = -prevButton; - prevButton = LCD_BUTTON_NONE; - lastRestore = currentTime; - if (eatRelease) { - eatRelease = false; - return LCD_BUTTON_NONE; - } - return button; - } else { - if (!screenSaved && prevButton == LCD_BUTTON_NONE && - timeout != 0 && (currentTime - lastRestore) >= timeout) - noDisplay(); // Activate screen saver. - return LCD_BUTTON_NONE; - } -} diff --git a/libraries/LCD/LCD.h b/libraries/LCD/LCD.h deleted file mode 100644 index 713abf0f..00000000 --- a/libraries/LCD/LCD.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#ifndef LCD_h -#define LCD_h - -// Extended version of the LiquidCrystal library that works specifically -// with Freetronics' 16x2 LCD display, including support for the back -// light and the Up/Down/Left/Right/Select buttons. More info: -// -// http://www.freetronics.com/pages/16x2-lcd-shield-quickstart-guide - -// Include a copy of the standard LiquidCrystal library so we can extend it. -#include "utility/LiquidCrystal.h" - -// Button event codes. -#define LCD_BUTTON_NONE 0 -#define LCD_BUTTON_LEFT 1 -#define LCD_BUTTON_RIGHT 2 -#define LCD_BUTTON_UP 3 -#define LCD_BUTTON_DOWN 4 -#define LCD_BUTTON_SELECT 5 -#define LCD_BUTTON_LEFT_RELEASED -1 -#define LCD_BUTTON_RIGHT_RELEASED -2 -#define LCD_BUTTON_UP_RELEASED -3 -#define LCD_BUTTON_DOWN_RELEASED -4 -#define LCD_BUTTON_SELECT_RELEASED -5 - -class LCD : public LiquidCrystal { -public: - LCD() : LiquidCrystal(8, 9, 4, 5, 6, 7) { init(); } - LCD(uint8_t pin9) : LiquidCrystal(8, pin9, 4, 5, 6, 7) { init(); } - LCD(uint8_t rs, uint8_t enable, - uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3) - : LiquidCrystal(rs, enable, d0, d1, d2, d3) { init(); } - - uint8_t backlightPin() const { return _backlightPin; } - void setBacklightPin(uint8_t pin); - - void display(); - void noDisplay(); - - enum ScreenSaverMode - { - DisplayOff, - BacklightOff, - BacklightOnSelect - }; - - ScreenSaverMode screenSaverMode() const { return mode; } - void setScreenSaverMode(ScreenSaverMode mode); - - void enableScreenSaver(int timeoutSecs = 10); - void disableScreenSaver(); - bool isScreenSaved() const { return screenSaved; } - - int getButton(); - -private: - uint8_t _backlightPin; - bool backlightInit; - int prevButton; - int debounceButton; - unsigned long timeout; - unsigned long lastRestore; - unsigned long lastDebounce; - bool screenSaved; - bool eatRelease; - ScreenSaverMode mode; - - void init(); -}; - -#endif diff --git a/libraries/LCD/ListField.cpp b/libraries/LCD/ListField.cpp deleted file mode 100644 index 04400ba3..00000000 --- a/libraries/LCD/ListField.cpp +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#include "ListField.h" -#include - -/** - * \class ListField ListField.h - * \brief Field that manages selection from a static list of items. - * - * ListField is intended for selecting an element from a list of items. - * Each items is represented by a string within program memory, with the - * list terminated by null. For example: - * - * \code - * const char item_Eggs[] PROGMEM = "Eggs"; - * const char item_Cheese[] PROGMEM = "Cheese"; - * const char item_Pumpkin[] PROGMEM = "Pumpkin"; - * ListItem const ingredients[] PROGMEM = { - * item_Eggs, - * item_Cheese, - * item_Pumpkin, - * 0 - * }; - * - * Form mainForm(lcd); - * ListField ingredient(mainForm, "Select ingredient", ingredients); - * \endcode - * - * If there are only two items in the list, then BoolField can be used instead. - * - * \sa Field, BoolField - */ - -/** - * \brief Constructs a new list field with a specific \a label. - * - * The field is initially not associated with a Form. The field can be - * added to a form later using Form::addField(). - * - * Initially, items() is null and value() is -1. - * - * \sa Form::addField() - */ -ListField::ListField(const String &label) - : Field(label) - , _items(0) - , _itemCount(0) - , _value(-1) - , _printLen(0) -{ -} - -/** - * \brief Constructs a new list field with a specific \a label, - * list of \a items, and \a value, and attaches it to a \a form. - */ -ListField::ListField(Form &form, const String &label, ListItems items, int value) - : Field(form, label) - , _items(0) - , _itemCount(0) - , _value(value) - , _printLen(0) -{ - setItems(items); -} - -int ListField::dispatch(int event) -{ - if (event == LCD_BUTTON_DOWN) { - if (_value >= (_itemCount - 1)) - setValue(0); - else - setValue(_value + 1); - return FORM_CHANGED; - } else if (event == LCD_BUTTON_UP) { - if (_value <= 0) - setValue(_itemCount - 1); - else - setValue(_value - 1); - return FORM_CHANGED; - } - return -1; -} - -void ListField::enterField(bool reverse) -{ - Field::enterField(reverse); - _printLen = 0; - printValue(); -} - -/** - * \fn ListItems ListField::items() const - * \brief Returns the array of items in this list. - * - * \sa setItems() - */ - -/** - * \brief Sets the array of \a items for this list. - * - * The \a items must be stored within program memory and terminated by null; - * for example: - * - * \code - * const char item_Eggs[] PROGMEM = "Eggs"; - * const char item_Cheese[] PROGMEM = "Cheese"; - * const char item_Pumpkin[] PROGMEM = "Pumpkin"; - * ListItem const ingredients[] PROGMEM = { - * item_Eggs, - * item_Cheese, - * item_Pumpkin, - * 0 - * }; - * - * list.setItems(ingredients); - * \endcode - * - * \sa items() - */ -void ListField::setItems(ListItems items) -{ - _items = items; - _itemCount = 0; - if (items) { - for (;;) { - ListItem item = (ListItem)pgm_read_word(items); - if (!item) - break; - ++items; - ++_itemCount; - } - } - if (_value >= _itemCount) - _value = _itemCount - 1; - if (isCurrent()) - printValue(); -} - -/** - * \fn int ListField::value() const - * \brief Returns the value of this list; i.e. the index within items() of the - * selected item. - * - * Returns -1 if the items() array is empty or null. - * - * \sa setValue(), items() - */ - -/** - * \brief Sets the \a value of this list; i.e. the index within items() of the - * selected item. - * - * The \a value will be clamped to the range of items(). - * - * \sa value(), items() - */ -void ListField::setValue(int value) -{ - if (_value != value) { - _value = value; - if (_value < 0) - _value = 0; - if (_value >= _itemCount) - _value = _itemCount - 1; - if (isCurrent()) - printValue(); - } -} - -void ListField::printValue() -{ - lcd()->setCursor(0, 1); - int len = 0; - if (_value >= 0) { - ListItem str = (ListItem)pgm_read_word(&(_items[_value])); - char ch; - while ((ch = pgm_read_byte(str)) != 0) { - lcd()->write(ch); - ++len; - ++str; - } - } - while (_printLen-- > len) - lcd()->write(' '); - _printLen = len; -} diff --git a/libraries/LCD/ListField.h b/libraries/LCD/ListField.h deleted file mode 100644 index 283985ff..00000000 --- a/libraries/LCD/ListField.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#ifndef ListField_h -#define ListField_h - -#include "Field.h" -#include - -typedef PGM_P ListItem; -typedef const PROGMEM ListItem *ListItems; - -class ListField : public Field { -public: - explicit ListField(const String &label); - ListField(Form &form, const String &label, ListItems items, int value = 0); - - int dispatch(int event); - - void enterField(bool reverse); - - ListItems items() const { return _items; } - void setItems(ListItems items); - - int value() const { return _value; } - void setValue(int value); - -private: - ListItems _items; - int _itemCount; - int _value; - int _printLen; - - void printValue(); -}; - -#endif diff --git a/libraries/LCD/TextField.cpp b/libraries/LCD/TextField.cpp deleted file mode 100644 index aa0bf0c6..00000000 --- a/libraries/LCD/TextField.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#include "TextField.h" - -/** - * \class TextField TextField.h - * \brief Field that displays a read-only text value. - * - * This following example displays a text field with the label - * "Form example" and a value() of "v1.0". - * - * \code - * Form mainForm(lcd); - * TextField welcomeField(mainForm, "Form example", "v1.0"); - * \endcode - * - * \image html FormText.png - * - * As well as static messages, TextField can be used to display read-only - * information that is computed at runtime: - * - * \code - * TextField timeField(mainForm, "Time since reset", "0"); - * - * void loop() { - * timeField.setValue(millis() / 1000); - * mainForm.dispatch(lcd.getButton()); - * } - * \endcode - * - * For writable fields, use BoolField, IntField, or TimeField. - * - * \sa Field - */ - -/** - * \brief Constructs a new text field with a specific \a label. - * - * The field is initially not associated with a Form. The field can be - * added to a form later using Form::addField(). - * - * The initial value() will be the empty string. - * - * \sa Form::addField() - */ -TextField::TextField(const String &label) - : Field(label) -{ -} - -/** - * \brief Constructs a new text field with a specific \a label and \a value - * attaches it to a \a form. - * - * \sa value() - */ -TextField::TextField(Form &form, const String &label, const String &value) - : Field(form, label) - , _value(value) -{ -} - -void TextField::enterField(bool reverse) -{ - Field::enterField(reverse); - lcd()->setCursor(0, 1); - lcd()->print(_value); -} - -/** - * \fn const String &TextField::value() const - * \brief Returns the text value that is currently displayed by this field. - * - * \sa setValue() - */ - -/** - * \brief Sets the text \a value that is displayed by this field. - * - * \sa value() - */ -void TextField::setValue(const String &value) -{ - if (isCurrent()) { - unsigned int prevLen = _value.length(); - unsigned int newLen = value.length(); - _value = value; - lcd()->setCursor(0, 1); - lcd()->print(value); - while (newLen++ < prevLen) - lcd()->write(' '); - } else { - _value = value; - } -} diff --git a/libraries/LCD/TextField.h b/libraries/LCD/TextField.h deleted file mode 100644 index 4e8a675c..00000000 --- a/libraries/LCD/TextField.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#ifndef TextField_h -#define TextField_h - -#include "Field.h" - -class TextField : public Field { -public: - explicit TextField(const String &label); - TextField(Form &form, const String &label, const String &value); - - void enterField(bool reverse); - - const String &value() const { return _value; } - void setValue(const String &value); - -private: - String _value; -}; - -#endif diff --git a/libraries/LCD/TimeField.cpp b/libraries/LCD/TimeField.cpp deleted file mode 100644 index 4bc71e45..00000000 --- a/libraries/LCD/TimeField.cpp +++ /dev/null @@ -1,330 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#include "TimeField.h" - -/** - * \class TimeField TimeField.h - * \brief Field that manages the display and editing of a time value. - * - * TimeField is suitable for displaying wall clock time in 24-hour format, - * or for displaying timeouts and durations in seconds. Times are specified - * in seconds as an unsigned long value. They are displayed - * as HH:MM:SS, for hours, minutes, and seconds. - * - * The time field can be either read-only or read-write. When read-write, - * the Up, Down, Left, and Right buttons can be used to modify the hour, - * minute, and second components of the time value. - * - * The following example displays the number of hours, minutes, and seconds - * since the device was reset, wrapping around after 24 hours: - * - * \code - * Form mainForm(lcd); - * TimeField timeField(mainForm, "Time since reset", 24, TIMEFIELD_READ_ONLY); - * - * void loop() { - * timeField.setValue(millis() / 1000); - * mainForm.dispatch(lcd.getButton()); - * } - * \endcode - * - * \image html FormTimeRO.png - * - * A read-write field can be used to ask the user for the duration of an - * application count-down timer: - * - * \code - * TimeField durationField(mainForm, "Timer duration", 24, TIMEFIELD_READ_WRITE); - * \endcode - * - * \image html FormTimeRW.png - * - * \sa Field - */ - -#define EDIT_HOUR 0 -#define EDIT_MINUTE_TENS 1 -#define EDIT_MINUTE 2 -#define EDIT_SECOND_TENS 3 -#define EDIT_SECOND 4 - -/** - * \brief Constructs a new time field with a specific \a label. - * - * The field is initially not associated with a Form. The field can be - * added to a form later using Form::addField(). - * - * Initially value() is 0, maxHours() is 24, and isReadOnly() is - * TIMEFIELD_READ_WRITE. - * - * \sa Form::addField() - */ -TimeField::TimeField(const String &label) - : Field(label) - , _value(0) - , _maxHours(24) - , _printLen(0) - , _readOnly(false) - , editField(EDIT_HOUR) -{ -} - -/** - * \brief Constructs a new boolean field with a specific \a label and - * attaches it to a \a form. - * - * The initial value() of the field will be 0. The value() will be limited - * to be less than \a maxHours * 60 * 60 seconds. - * - * If \a readOnly is TIMEFIELD_READ_ONLY, then the field will display times - * but not allow them to be modified by the user. If \a readOnly is - * TIMEFIELD_READ_WRITE, then the field will modifiable by the user. - * - * \sa value() - */ -TimeField::TimeField(Form &form, const String &label, int maxHours, bool readOnly) - : Field(form, label) - , _value(0) - , _maxHours(maxHours) - , _printLen(0) - , _readOnly(readOnly) - , editField(EDIT_HOUR) -{ -} - -int TimeField::dispatch(int event) -{ - unsigned long newValue; - if (_readOnly) - return -1; - if (event == LCD_BUTTON_UP) { - newValue = _value; - if (editField == EDIT_HOUR) { - newValue += 60 * 60; - } else if (editField == EDIT_MINUTE_TENS) { - if (((newValue / 60) % 60) >= 50) - newValue -= 50 * 60; - else - newValue += 10 * 60; - } else if (editField == EDIT_MINUTE) { - if (((newValue / 60) % 60) == 59) - newValue -= 59 * 60; - else - newValue += 60; - } else if (editField == EDIT_SECOND_TENS) { - if ((newValue % 60) >= 50) - newValue -= 50; - else - newValue += 10; - } else { - if ((newValue % 60) == 59) - newValue -= 59; - else - newValue += 1; - } - setValue(newValue); - return FORM_CHANGED; - } else if (event == LCD_BUTTON_DOWN) { - newValue = _value; - if (editField == EDIT_HOUR) { - if (newValue < 60 * 60) - newValue += ((unsigned long)(_maxHours - 1)) * 60 * 60; - else - newValue -= 60 * 60; - } else if (editField == EDIT_MINUTE_TENS) { - if (((newValue / 60) % 60) < 10) - newValue += 50 * 60; - else - newValue -= 10 * 60; - } else if (editField == EDIT_MINUTE) { - if (((newValue / 60) % 60) == 0) - newValue += 59 * 60; - else - newValue -= 60; - } else if (editField == EDIT_SECOND_TENS) { - if ((newValue % 60) < 10) - newValue += 50; - else - newValue -= 10; - } else { - if ((newValue % 60) == 0) - newValue += 59; - else - newValue -= 1; - } - setValue(newValue); - return FORM_CHANGED; - } else if (event == LCD_BUTTON_LEFT) { - if (editField != EDIT_HOUR) { - --editField; - printTime(); - return 0; - } - } else if (event == LCD_BUTTON_RIGHT) { - if (editField != EDIT_SECOND) { - ++editField; - printTime(); - return 0; - } - } - return -1; -} - -void TimeField::enterField(bool reverse) -{ - Field::enterField(reverse); - if (reverse) - editField = EDIT_SECOND; - else - editField = EDIT_HOUR; - printTime(); - if (!_readOnly) - lcd()->cursor(); -} - -void TimeField::exitField() -{ - if (!_readOnly) - lcd()->noCursor(); - Field::exitField(); -} - -/** - * \fn unsigned long TimeField::value() const - * \brief Returns the current value of this time field, in seconds. - * - * \sa setValue() - */ - -/** - * \brief Sets the \a value of this time field, in seconds. - * - * If \a value is greater than or equal to maxHours() * 60 * 60, - * then it will be wrapped around to fall within the valid range. - * - * \sa value(), maxHours() - */ -void TimeField::setValue(unsigned long value) -{ - unsigned long maxSecs = ((unsigned long)_maxHours) * 60 * 60; - value %= maxSecs; - if (value != _value) { - _value = value; - if (isCurrent()) - printTime(); - } -} - -/** - * \fn int TimeField::maxHours() const - * \brief Returns the maximum number of hours before the field wraps around. - * - * \sa setMaxHours(), setValue() - */ - -/** - * \fn void TimeField::setMaxHours(int maxHours) - * \brief Sets the maximum number of hours before the field wraps around - * to \a maxHours. - * - * \sa maxHours(), setValue() - */ - -/** - * \fn bool TimeField::readOnly() const - * \brief Returns TIMEFIELD_READ_ONLY (true) or TIMEFIELD_READ_WRITE (false). - * - * \sa setReadOnly() - */ - -/** - * \brief Sets the read-only state of this field to \a value. - * - * The \a value should be one of TIMEFIELD_READ_ONLY (true) or - * TIMEFIELD_READ_WRITE (false). Use of the named constants is recommended. - * - * \sa readOnly() - */ -void TimeField::setReadOnly(bool value) -{ - if (_readOnly != value) { - _readOnly = value; - printTime(); - if (isCurrent()) { - if (value) - lcd()->cursor(); - else - lcd()->noCursor(); - } - } -} - -void TimeField::printTime() -{ - lcd()->setCursor(0, 1); - int col = printField(_value / (60 * 60)); - int hourCol = col - 1; - lcd()->write(':'); - ++col; - col += printField((_value / 60) % 60); - int minuteCol = col - 1; - lcd()->write(':'); - ++col; - col += printField(_value % 60); - int secondCol = col - 1; - int tempCol = col; - while (tempCol++ < _printLen) - lcd()->write(' '); - _printLen = col; - if (!_readOnly) { - if (editField == EDIT_HOUR) - lcd()->setCursor(hourCol, 1); - else if (editField == EDIT_MINUTE_TENS) - lcd()->setCursor(minuteCol - 1, 1); - else if (editField == EDIT_MINUTE) - lcd()->setCursor(minuteCol, 1); - else if (editField == EDIT_SECOND_TENS) - lcd()->setCursor(secondCol - 1, 1); - else - lcd()->setCursor(secondCol, 1); - } -} - -int TimeField::printField(unsigned long value) -{ - if (value < 100) { - lcd()->write('0' + (int)(value / 10)); - lcd()->write('0' + (int)(value % 10)); - return 2; - } - unsigned long divisor = 100; - while ((value / divisor) >= 10) - divisor *= 10; - int digits = 0; - while (divisor > 0) { - lcd()->write('0' + (int)((value / divisor) % 10)); - divisor /= 10; - ++digits; - } - return digits; -} diff --git a/libraries/LCD/TimeField.h b/libraries/LCD/TimeField.h deleted file mode 100644 index 9f014b29..00000000 --- a/libraries/LCD/TimeField.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#ifndef TimeField_h -#define TimeField_h - -#include "Field.h" - -#define TIMEFIELD_READ_ONLY true -#define TIMEFIELD_READ_WRITE false - -class TimeField : public Field { -public: - explicit TimeField(const String &label); - TimeField(Form &form, const String &label, int maxHours, bool readOnly); - - int dispatch(int event); - - void enterField(bool reverse); - void exitField(); - - unsigned long value() const { return _value; } - void setValue(unsigned long value); - - int maxHours() const { return _maxHours; } - void setMaxHours(int maxHours) { _maxHours = maxHours; } - - bool readOnly() const { return _readOnly; } - void setReadOnly(bool value); - -private: - unsigned long _value; - int _maxHours; - int _printLen; - bool _readOnly; - uint8_t editField; - - void printTime(); - int printField(unsigned long value); -}; - -#endif diff --git a/libraries/LCD/examples/Form/Form.ino b/libraries/LCD/examples/Form/Form.ino deleted file mode 100644 index cceae209..00000000 --- a/libraries/LCD/examples/Form/Form.ino +++ /dev/null @@ -1,62 +0,0 @@ -/* -This example demonstrates how to use the Form and Field classes from the -LCD library to provide a simple UI on the 16x2 LCD display. - -This example is placed into the public domain. -*/ - -// include the library code: -#include -#include -#include -#include -#include -#include - -// Initialize the LCD -LCD lcd; - -// Note: if you are using the USBDroid and have reassigned pin D9 on the LCD shield to some -// other pin (e.g. A1), then you will need to initialize the shield with something like: -// LCD lcd(A1); -// See also: http://www.freetronics.com/pages/combining-the-lcd-keypad-shield-and-the-usbdroid - -// Create the main form and its fields. -Form mainForm(lcd); -TextField welcomeField(mainForm, "Form example", "v1.0"); -TimeField timeField(mainForm, "Time since reset", 24, TIMEFIELD_READ_ONLY); -IntField volumeField(mainForm, "Volume", 0, 100, 5, 85, "%"); -BoolField ledField(mainForm, "Status LED", "On", "Off", true); -TimeField durationField(mainForm, "Timer duration", 24, TIMEFIELD_READ_WRITE); - -#define STATUS_LED 13 - -void setup() { - // Status LED initially on. - pinMode(STATUS_LED, OUTPUT); - digitalWrite(STATUS_LED, HIGH); - - // Enable the screen saver, which will automatically blank the screen after 10 seconds. - // The screen will wake up again when a button is pressed or lcd.display() is called. - lcd.enableScreenSaver(); - - // Show the main form for the first time. - mainForm.show(); -} - -void loop() { - // Update the number of seconds since reset: - timeField.setValue(millis() / 1000); - - // Dispatch button events to the main form. - int event = lcd.getButton(); - if (mainForm.dispatch(event) == FORM_CHANGED) { - if (mainForm.isCurrent(ledField)) { - if (ledField.value()) - digitalWrite(STATUS_LED, HIGH); - else - digitalWrite(STATUS_LED, LOW); - } - } -} - diff --git a/libraries/LCD/examples/Form/FormBool.png b/libraries/LCD/examples/Form/FormBool.png deleted file mode 100644 index 7449a3cb..00000000 Binary files a/libraries/LCD/examples/Form/FormBool.png and /dev/null differ diff --git a/libraries/LCD/examples/Form/FormInt.png b/libraries/LCD/examples/Form/FormInt.png deleted file mode 100644 index 2fc9b6b1..00000000 Binary files a/libraries/LCD/examples/Form/FormInt.png and /dev/null differ diff --git a/libraries/LCD/examples/Form/FormText.png b/libraries/LCD/examples/Form/FormText.png deleted file mode 100644 index cb018bcf..00000000 Binary files a/libraries/LCD/examples/Form/FormText.png and /dev/null differ diff --git a/libraries/LCD/examples/Form/FormTimeRO.png b/libraries/LCD/examples/Form/FormTimeRO.png deleted file mode 100644 index e99c7b9a..00000000 Binary files a/libraries/LCD/examples/Form/FormTimeRO.png and /dev/null differ diff --git a/libraries/LCD/examples/Form/FormTimeRW.png b/libraries/LCD/examples/Form/FormTimeRW.png deleted file mode 100644 index 679c01ce..00000000 Binary files a/libraries/LCD/examples/Form/FormTimeRW.png and /dev/null differ diff --git a/libraries/LCD/examples/HelloWorld/HelloWorld.ino b/libraries/LCD/examples/HelloWorld/HelloWorld.ino deleted file mode 100644 index 7aec8994..00000000 --- a/libraries/LCD/examples/HelloWorld/HelloWorld.ino +++ /dev/null @@ -1,43 +0,0 @@ -/* -This example demonstrates how to use the LCD library, which extends the -standard LiquidCrystal library to provide support for the Freetronics back light -and Up/Down/Left/Right/Select buttons. More information on the shield here: - -http://www.freetronics.com/pages/16x2-lcd-shield-quickstart-guide - -This example is placed into the public domain. -*/ - -#include -LCD lcd; - -// Note: if you are using the USBDroid and have reassigned pin D9 on the LCD shield to some -// other pin (e.g. A1), then you will need to initialize the shield with something like: -// LCD lcd(A1); -// See also: http://www.freetronics.com/pages/combining-the-lcd-keypad-shield-and-the-usbdroid - -void setup() { - lcd.enableScreenSaver(); - lcd.print("hello, world!"); -} - -void loop() { - lcd.setCursor(0, 1); - lcd.print(millis() / 1000); - - lcd.setCursor(8, 1); - int button = lcd.getButton(); - if (button == LCD_BUTTON_LEFT) - lcd.print("LEFT"); - else if (button == LCD_BUTTON_RIGHT) - lcd.print("RIGHT"); - else if (button == LCD_BUTTON_UP) - lcd.print("UP"); - else if (button == LCD_BUTTON_DOWN) - lcd.print("DOWN"); - else if (button == LCD_BUTTON_SELECT) - lcd.print("SELECT"); - else if (button < 0) // button release - lcd.print(" "); -} - diff --git a/libraries/LCD/examples/HelloWorld/HelloWorld.png b/libraries/LCD/examples/HelloWorld/HelloWorld.png deleted file mode 100644 index 29ddaa52..00000000 Binary files a/libraries/LCD/examples/HelloWorld/HelloWorld.png and /dev/null differ diff --git a/libraries/LCD/keywords.txt b/libraries/LCD/keywords.txt deleted file mode 100644 index 9d7fedb9..00000000 --- a/libraries/LCD/keywords.txt +++ /dev/null @@ -1,21 +0,0 @@ -LCD KEYWORD1 -Form KEYWORD1 -Field KEYWORD1 -BoolField KEYWORD1 -IntField KEYWORD1 -TextField KEYWORD1 -TimeField KEYWORD1 - -getButton KEYWORD2 -enableScreenSaver KEYWORD2 -disableScreenSaver KEYWORD2 -isScreenSaved KEYWORD2 - -show KEYWORD2 -hide KEYWORD2 -dispatch KEYWORD2 -isCurrent KEYWORD2 - -setLabel KEYWORD2 -setValue KEYWORD2 -value KEYWORD2 diff --git a/libraries/LCD/utility/LiquidCrystal.cpp b/libraries/LCD/utility/LiquidCrystal.cpp deleted file mode 100644 index 81f3a5b2..00000000 --- a/libraries/LCD/utility/LiquidCrystal.cpp +++ /dev/null @@ -1,324 +0,0 @@ -#include "LiquidCrystal.h" - -#include -#include -#include -#if defined(ARDUINO) && ARDUINO >= 100 -#include -#else -#include -#endif - -// When the display powers up, it is configured as follows: -// -// 1. Display clear -// 2. Function set: -// DL = 1; 8-bit interface data -// N = 0; 1-line display -// F = 0; 5x8 dot character font -// 3. Display on/off control: -// D = 0; Display off -// C = 0; Cursor off -// B = 0; Blinking off -// 4. Entry mode set: -// I/D = 1; Increment by 1 -// S = 0; No shift -// -// Note, however, that resetting the Arduino doesn't reset the LCD, so we -// can't assume that its in that state when a sketch starts (and the -// LiquidCrystal constructor is called). - -LiquidCrystal::LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable, - uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, - uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7) -{ - init(0, rs, rw, enable, d0, d1, d2, d3, d4, d5, d6, d7); -} - -LiquidCrystal::LiquidCrystal(uint8_t rs, uint8_t enable, - uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, - uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7) -{ - init(0, rs, 255, enable, d0, d1, d2, d3, d4, d5, d6, d7); -} - -LiquidCrystal::LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable, - uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3) -{ - init(1, rs, rw, enable, d0, d1, d2, d3, 0, 0, 0, 0); -} - -LiquidCrystal::LiquidCrystal(uint8_t rs, uint8_t enable, - uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3) -{ - init(1, rs, 255, enable, d0, d1, d2, d3, 0, 0, 0, 0); -} - -void LiquidCrystal::init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t enable, - uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, - uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7) -{ - _rs_pin = rs; - _rw_pin = rw; - _enable_pin = enable; - - _data_pins[0] = d0; - _data_pins[1] = d1; - _data_pins[2] = d2; - _data_pins[3] = d3; - _data_pins[4] = d4; - _data_pins[5] = d5; - _data_pins[6] = d6; - _data_pins[7] = d7; - - pinMode(_rs_pin, OUTPUT); - // we can save 1 pin by not using RW. Indicate by passing 255 instead of pin# - if (_rw_pin != 255) { - pinMode(_rw_pin, OUTPUT); - } - pinMode(_enable_pin, OUTPUT); - - if (fourbitmode) - _displayfunction = LCD_4BITMODE | LCD_1LINE | LCD_5x8DOTS; - else - _displayfunction = LCD_8BITMODE | LCD_1LINE | LCD_5x8DOTS; - - begin(16, 1); -} - -void LiquidCrystal::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { - if (lines > 1) { - _displayfunction |= LCD_2LINE; - } - _numlines = lines; - _currline = 0; - - // for some 1 line displays you can select a 10 pixel high font - if ((dotsize != 0) && (lines == 1)) { - _displayfunction |= LCD_5x10DOTS; - } - - // SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION! - // according to datasheet, we need at least 40ms after power rises above 2.7V - // before sending commands. Arduino can turn on way befer 4.5V so we'll wait 50 - delayMicroseconds(50000); - // Now we pull both RS and R/W low to begin commands - digitalWrite(_rs_pin, LOW); - digitalWrite(_enable_pin, LOW); - if (_rw_pin != 255) { - digitalWrite(_rw_pin, LOW); - } - - //put the LCD into 4 bit or 8 bit mode - if (! (_displayfunction & LCD_8BITMODE)) { - // this is according to the hitachi HD44780 datasheet - // figure 24, pg 46 - - // we start in 8bit mode, try to set 4 bit mode - write4bits(0x03); - delayMicroseconds(4500); // wait min 4.1ms - - // second try - write4bits(0x03); - delayMicroseconds(4500); // wait min 4.1ms - - // third go! - write4bits(0x03); - delayMicroseconds(150); - - // finally, set to 4-bit interface - write4bits(0x02); - } else { - // this is according to the hitachi HD44780 datasheet - // page 45 figure 23 - - // Send function set command sequence - command(LCD_FUNCTIONSET | _displayfunction); - delayMicroseconds(4500); // wait more than 4.1ms - - // second try - command(LCD_FUNCTIONSET | _displayfunction); - delayMicroseconds(150); - - // third go - command(LCD_FUNCTIONSET | _displayfunction); - } - - // finally, set # lines, font size, etc. - command(LCD_FUNCTIONSET | _displayfunction); - - // turn the display on with no cursor or blinking default - _displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF; - display(); - - // clear it off - clear(); - - // Initialize to default text direction (for romance languages) - _displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT; - // set the entry mode - command(LCD_ENTRYMODESET | _displaymode); - -} - -/********** high level commands, for the user! */ -void LiquidCrystal::clear() -{ - command(LCD_CLEARDISPLAY); // clear display, set cursor position to zero - delayMicroseconds(2000); // this command takes a long time! -} - -void LiquidCrystal::home() -{ - command(LCD_RETURNHOME); // set cursor position to zero - delayMicroseconds(2000); // this command takes a long time! -} - -void LiquidCrystal::setCursor(uint8_t col, uint8_t row) -{ - int row_offsets[] = { 0x00, 0x40, 0x14, 0x54 }; - if ( row >= _numlines ) { - row = _numlines-1; // we count rows starting w/0 - } - - command(LCD_SETDDRAMADDR | (col + row_offsets[row])); -} - -// Turn the display on/off (quickly) -void LiquidCrystal::noDisplay() { - _displaycontrol &= ~LCD_DISPLAYON; - command(LCD_DISPLAYCONTROL | _displaycontrol); -} -void LiquidCrystal::display() { - _displaycontrol |= LCD_DISPLAYON; - command(LCD_DISPLAYCONTROL | _displaycontrol); -} - -// Turns the underline cursor on/off -void LiquidCrystal::noCursor() { - _displaycontrol &= ~LCD_CURSORON; - command(LCD_DISPLAYCONTROL | _displaycontrol); -} -void LiquidCrystal::cursor() { - _displaycontrol |= LCD_CURSORON; - command(LCD_DISPLAYCONTROL | _displaycontrol); -} - -// Turn on and off the blinking cursor -void LiquidCrystal::noBlink() { - _displaycontrol &= ~LCD_BLINKON; - command(LCD_DISPLAYCONTROL | _displaycontrol); -} -void LiquidCrystal::blink() { - _displaycontrol |= LCD_BLINKON; - command(LCD_DISPLAYCONTROL | _displaycontrol); -} - -// These commands scroll the display without changing the RAM -void LiquidCrystal::scrollDisplayLeft(void) { - command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVELEFT); -} -void LiquidCrystal::scrollDisplayRight(void) { - command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVERIGHT); -} - -// This is for text that flows Left to Right -void LiquidCrystal::leftToRight(void) { - _displaymode |= LCD_ENTRYLEFT; - command(LCD_ENTRYMODESET | _displaymode); -} - -// This is for text that flows Right to Left -void LiquidCrystal::rightToLeft(void) { - _displaymode &= ~LCD_ENTRYLEFT; - command(LCD_ENTRYMODESET | _displaymode); -} - -// This will 'right justify' text from the cursor -void LiquidCrystal::autoscroll(void) { - _displaymode |= LCD_ENTRYSHIFTINCREMENT; - command(LCD_ENTRYMODESET | _displaymode); -} - -// This will 'left justify' text from the cursor -void LiquidCrystal::noAutoscroll(void) { - _displaymode &= ~LCD_ENTRYSHIFTINCREMENT; - command(LCD_ENTRYMODESET | _displaymode); -} - -// Allows us to fill the first 8 CGRAM locations -// with custom characters -void LiquidCrystal::createChar(uint8_t location, uint8_t charmap[]) { - location &= 0x7; // we only have 8 locations 0-7 - command(LCD_SETCGRAMADDR | (location << 3)); - for (int i=0; i<8; i++) { - write(charmap[i]); - } -} - -/*********** mid level commands, for sending data/cmds */ - -inline void LiquidCrystal::command(uint8_t value) { - send(value, LOW); -} - -#if defined(ARDUINO) && ARDUINO >= 100 - -inline size_t LiquidCrystal::write(uint8_t value) { - send(value, HIGH); - return 1; // assume sucess -} - -#else - -inline void LiquidCrystal::write(uint8_t value) { - send(value, HIGH); -} - -#endif - -/************ low level data pushing commands **********/ - -// write either command or data, with automatic 4/8-bit selection -void LiquidCrystal::send(uint8_t value, uint8_t mode) { - digitalWrite(_rs_pin, mode); - - // if there is a RW pin indicated, set it low to Write - if (_rw_pin != 255) { - digitalWrite(_rw_pin, LOW); - } - - if (_displayfunction & LCD_8BITMODE) { - write8bits(value); - } else { - write4bits(value>>4); - write4bits(value); - } -} - -void LiquidCrystal::pulseEnable(void) { - digitalWrite(_enable_pin, LOW); - delayMicroseconds(1); - digitalWrite(_enable_pin, HIGH); - delayMicroseconds(1); // enable pulse must be >450ns - digitalWrite(_enable_pin, LOW); - delayMicroseconds(100); // commands need > 37us to settle -} - -void LiquidCrystal::write4bits(uint8_t value) { - for (int i = 0; i < 4; i++) { - pinMode(_data_pins[i], OUTPUT); - digitalWrite(_data_pins[i], (value >> i) & 0x01); - } - - pulseEnable(); -} - -void LiquidCrystal::write8bits(uint8_t value) { - for (int i = 0; i < 8; i++) { - pinMode(_data_pins[i], OUTPUT); - digitalWrite(_data_pins[i], (value >> i) & 0x01); - } - - pulseEnable(); -} diff --git a/libraries/LCD/utility/LiquidCrystal.h b/libraries/LCD/utility/LiquidCrystal.h deleted file mode 100644 index 984586e1..00000000 --- a/libraries/LCD/utility/LiquidCrystal.h +++ /dev/null @@ -1,110 +0,0 @@ -#ifndef LiquidCrystal_h -#define LiquidCrystal_h - -#include -#include "Print.h" - -// commands -#define LCD_CLEARDISPLAY 0x01 -#define LCD_RETURNHOME 0x02 -#define LCD_ENTRYMODESET 0x04 -#define LCD_DISPLAYCONTROL 0x08 -#define LCD_CURSORSHIFT 0x10 -#define LCD_FUNCTIONSET 0x20 -#define LCD_SETCGRAMADDR 0x40 -#define LCD_SETDDRAMADDR 0x80 - -// flags for display entry mode -#define LCD_ENTRYRIGHT 0x00 -#define LCD_ENTRYLEFT 0x02 -#define LCD_ENTRYSHIFTINCREMENT 0x01 -#define LCD_ENTRYSHIFTDECREMENT 0x00 - -// flags for display on/off control -#define LCD_DISPLAYON 0x04 -#define LCD_DISPLAYOFF 0x00 -#define LCD_CURSORON 0x02 -#define LCD_CURSOROFF 0x00 -#define LCD_BLINKON 0x01 -#define LCD_BLINKOFF 0x00 - -// flags for display/cursor shift -#define LCD_DISPLAYMOVE 0x08 -#define LCD_CURSORMOVE 0x00 -#define LCD_MOVERIGHT 0x04 -#define LCD_MOVELEFT 0x00 - -// flags for function set -#define LCD_8BITMODE 0x10 -#define LCD_4BITMODE 0x00 -#define LCD_2LINE 0x08 -#define LCD_1LINE 0x00 -#define LCD_5x10DOTS 0x04 -#define LCD_5x8DOTS 0x00 - -class LiquidCrystal : public Print { -public: - LiquidCrystal(uint8_t rs, uint8_t enable, - uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, - uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7); - LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable, - uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, - uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7); - LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable, - uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3); - LiquidCrystal(uint8_t rs, uint8_t enable, - uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3); - - void init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t enable, - uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, - uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7); - - void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS); - - void clear(); - void home(); - - void noDisplay(); - void display(); - void noBlink(); - void blink(); - void noCursor(); - void cursor(); - void scrollDisplayLeft(); - void scrollDisplayRight(); - void leftToRight(); - void rightToLeft(); - void autoscroll(); - void noAutoscroll(); - - void createChar(uint8_t, uint8_t[]); - void setCursor(uint8_t, uint8_t); -#if defined(ARDUINO) && ARDUINO >= 100 - virtual size_t write(uint8_t); -#else - virtual void write(uint8_t); -#endif - void command(uint8_t); - - using Print::write; -private: - void send(uint8_t, uint8_t); - void write4bits(uint8_t); - void write8bits(uint8_t); - void pulseEnable(); - - uint8_t _rs_pin; // LOW: command. HIGH: character. - uint8_t _rw_pin; // LOW: write to LCD. HIGH: read from LCD. - uint8_t _enable_pin; // activated by a HIGH pulse. - uint8_t _data_pins[8]; - - uint8_t _displayfunction; - uint8_t _displaycontrol; - uint8_t _displaymode; - - uint8_t _initialized; - - uint8_t _numlines,_currline; -}; - -#endif diff --git a/libraries/Melody/Melody.cpp b/libraries/Melody/Melody.cpp deleted file mode 100644 index b3552244..00000000 --- a/libraries/Melody/Melody.cpp +++ /dev/null @@ -1,239 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#include "Melody.h" -#if defined(ARDUINO) && ARDUINO >= 100 -#include -#else -#include -#endif - -/** - * \class Melody Melody.h - * \brief Plays a melody on a digital output pin using tone(). - * - * The following example plays a simple tone three times on digital pin 8: - * - * \code - * #include - * - * int notes[] = { - * NOTE_C4, NOTE_G3, NOTE_G3, NOTE_A3, NOTE_G3, - * NOTE_REST, NOTE_B3, NOTE_C4, NOTE_REST - * }; - * byte lengths[] = {4, 8, 8, 4, 4, 4, 4, 4, 2}; - * - * Melody melody(8); - * - * void setup() { - * melody.setMelody(notes, lengths, sizeof(lengths)); - * melody.setLoopCount(3); - * melody.play(); - * } - * - * void loop() { - * melody.run(); - * } - * \endcode - * - * The \c notes array contains the frequency of the notes to be played, - * with the special value \c NOTE_REST indicating a rest where no notes - * are playing. The \c lengths array contains the lengths of each of the - * notes; a value of 4 indicates a quarter note, a value of 8 indicates - * an eighth note, etc. - * - * The run() method must be called from the application's main - * loop() method to ensure that the melody advances from - * one note to the next. It will not block the application while - * notes are playing. - * - * The number of loops can also be specified with setLoopDuration() which - * sets a maximum amount of time that the melody will play before stopping. - * The following example plays the melody for no more than 60 seconds: - * - * \code - * void setup() { - * melody.setMelody(notes, lengths, sizeof(lengths)); - * melody.setLoopDuration(60000UL); - * melody.play(); - * } - * \endcode - */ - -/** - * \brief Constructs a new melody playing object for \a pin. - */ -Melody::Melody(uint8_t pin) - : _pin(pin) - , playing(false) - , _loopCount(0) - , loopsLeft(0) - , notes(0) - , lengths(0) - , size(0) - , posn(0) - , duration(0) - , startNote(0) -{ -} - -/** - * \fn bool Melody::isPlaying() const - * \brief Returns true if the melody is currently playing; false if not. - */ - -/** - * \fn int Melody::loopCount() const - * \brief Returns the number of times the melody should loop before stopping. - * - * The default value is zero, indicating that the melody will loop - * indefinitely. - * - * \sa setLoopCount(), setLoopDuration(), play() - */ - -/** - * \fn void Melody::setLoopCount(int count) - * \brief Sets the number of times the melody should loop to \a count. - * - * If \a count is zero, then the melody will loop indefinitely. - * - * \sa loopCount(), setLoopDuration() - */ - -/** - * \brief Sets the maximum number of loops to last no longer than \a ms milliseconds. - * - * This function must be called after the melody is specified with setMelody() - * as it uses the length of the melody and \a ms to determine the loopCount(). - * - * \sa loopCount(), setLoopCount() - */ -void Melody::setLoopDuration(unsigned long ms) -{ - unsigned long duration = 0; - for (unsigned int index = 0; index < size; ++index) - duration += (1000 / lengths[index]) * 13 / 10; - _loopCount = (int)(ms / duration); - if (!_loopCount) - _loopCount = 1; // Play the melody at least once. -} - -/** - * \brief Starts playing the melody, or restarts it if already playing. - * - * \sa playOnce(), setMelody(), stop(), loopCount() - */ -void Melody::play() -{ - stop(); - if (size == 0) - return; // No melody to play. - loopsLeft = _loopCount; - posn = 0; - playing = true; - nextNote(); -} - -/** - * \brief Plays the melody once and then stops. - * - * \sa play(), stop() - */ -void Melody::playOnce() -{ - stop(); - if (size == 0) - return; // No melody to play. - loopsLeft = 1; - posn = 0; - playing = true; - nextNote(); -} - -/** - * \brief Stops playing the melody. - * - * \sa play() - */ -void Melody::stop() -{ - if (!playing) - return; - playing = false; - noTone(_pin); -} - -/** - * \brief Sets the melody to the \a size elements of \a notes and \a lengths. - * - * If a melody is currently playing, then this function will stop playback. - * - * The \a notes array contains the frequency of the notes to be played, - * with the special value \c NOTE_REST indicating a rest where no notes - * are playing. The \a lengths array contains the lengths of each of the - * notes; a value of 4 indicates a quarter note, a value of 8 indicates - * an eighth note, etc. - * - * \sa play() - */ -void Melody::setMelody(const int *notes, const uint8_t *lengths, unsigned int size) -{ - stop(); - this->notes = notes; - this->lengths = lengths; - this->size = size; -} - -/** - * \brief Runs the melody control loop. - * - * This function must be called by the application's main loop() - * function to cause the melody to advance from note to note. It will not - * block the application while notes are playing. - */ -void Melody::run() -{ - if (!playing) - return; - if ((millis() - startNote) >= duration) { - noTone(_pin); - nextNote(); - } -} - -void Melody::nextNote() -{ - if (posn >= size) { - if (loopsLeft != 0 && --loopsLeft <= 0) { - stop(); - return; - } - posn = 0; - } - duration = 1000 / lengths[posn]; - if (notes[posn] != NOTE_REST) - tone(_pin, notes[posn], duration); - ++posn; - duration = duration * 13 / 10; // i.e., duration * 1.3 - startNote = millis(); -} diff --git a/libraries/Melody/Melody.h b/libraries/Melody/Melody.h deleted file mode 100644 index 2f1701a8..00000000 --- a/libraries/Melody/Melody.h +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#ifndef Melody_h -#define Melody_h - -#include - -// Note frequencies from http://arduino.cc/en/Tutorial/Tone -#define NOTE_B0 31 -#define NOTE_C1 33 -#define NOTE_CS1 35 -#define NOTE_D1 37 -#define NOTE_DS1 39 -#define NOTE_E1 41 -#define NOTE_F1 44 -#define NOTE_FS1 46 -#define NOTE_G1 49 -#define NOTE_GS1 52 -#define NOTE_A1 55 -#define NOTE_AS1 58 -#define NOTE_B1 62 -#define NOTE_C2 65 -#define NOTE_CS2 69 -#define NOTE_D2 73 -#define NOTE_DS2 78 -#define NOTE_E2 82 -#define NOTE_F2 87 -#define NOTE_FS2 93 -#define NOTE_G2 98 -#define NOTE_GS2 104 -#define NOTE_A2 110 -#define NOTE_AS2 117 -#define NOTE_B2 123 -#define NOTE_C3 131 -#define NOTE_CS3 139 -#define NOTE_D3 147 -#define NOTE_DS3 156 -#define NOTE_E3 165 -#define NOTE_F3 175 -#define NOTE_FS3 185 -#define NOTE_G3 196 -#define NOTE_GS3 208 -#define NOTE_A3 220 -#define NOTE_AS3 233 -#define NOTE_B3 247 -#define NOTE_C4 262 -#define NOTE_CS4 277 -#define NOTE_D4 294 -#define NOTE_DS4 311 -#define NOTE_E4 330 -#define NOTE_F4 349 -#define NOTE_FS4 370 -#define NOTE_G4 392 -#define NOTE_GS4 415 -#define NOTE_A4 440 -#define NOTE_AS4 466 -#define NOTE_B4 494 -#define NOTE_C5 523 -#define NOTE_CS5 554 -#define NOTE_D5 587 -#define NOTE_DS5 622 -#define NOTE_E5 659 -#define NOTE_F5 698 -#define NOTE_FS5 740 -#define NOTE_G5 784 -#define NOTE_GS5 831 -#define NOTE_A5 880 -#define NOTE_AS5 932 -#define NOTE_B5 988 -#define NOTE_C6 1047 -#define NOTE_CS6 1109 -#define NOTE_D6 1175 -#define NOTE_DS6 1245 -#define NOTE_E6 1319 -#define NOTE_F6 1397 -#define NOTE_FS6 1480 -#define NOTE_G6 1568 -#define NOTE_GS6 1661 -#define NOTE_A6 1760 -#define NOTE_AS6 1865 -#define NOTE_B6 1976 -#define NOTE_C7 2093 -#define NOTE_CS7 2217 -#define NOTE_D7 2349 -#define NOTE_DS7 2489 -#define NOTE_E7 2637 -#define NOTE_F7 2794 -#define NOTE_FS7 2960 -#define NOTE_G7 3136 -#define NOTE_GS7 3322 -#define NOTE_A7 3520 -#define NOTE_AS7 3729 -#define NOTE_B7 3951 -#define NOTE_C8 4186 -#define NOTE_CS8 4435 -#define NOTE_D8 4699 -#define NOTE_DS8 4978 - -// Special note value that indicates a rest. -#define NOTE_REST 0 - -class Melody { -public: - Melody(uint8_t pin); - - bool isPlaying() const { return playing; } - - int loopCount() const { return _loopCount; } - void setLoopCount(int count) { _loopCount = count; } - - void setLoopDuration(unsigned long ms); - - void play(); - void playOnce(); - void stop(); - - void setMelody(const int *notes, const uint8_t *lengths, unsigned int size); - - void run(); - -private: - uint8_t _pin; - bool playing; - int _loopCount; - int loopsLeft; - const int *notes; - const uint8_t *lengths; - unsigned int size; - unsigned int posn; - unsigned long duration; - unsigned long startNote; - - void nextNote(); -}; - -#endif diff --git a/libraries/Melody/examples/PlayTone/PlayTone.ino b/libraries/Melody/examples/PlayTone/PlayTone.ino deleted file mode 100644 index 98fd5890..00000000 --- a/libraries/Melody/examples/PlayTone/PlayTone.ino +++ /dev/null @@ -1,19 +0,0 @@ -#include - -int notes[] = { - NOTE_C4, NOTE_G3, NOTE_G3, NOTE_A3, NOTE_G3, - NOTE_REST, NOTE_B3, NOTE_C4, NOTE_REST -}; -byte lengths[] = {4, 8, 8, 4, 4, 4, 4, 4, 2}; - -Melody melody(8); - -void setup() { - melody.setMelody(notes, lengths, sizeof(lengths)); - melody.setLoopCount(3); - melody.play(); -} - -void loop() { - melody.run(); -} diff --git a/libraries/Melody/keywords.txt b/libraries/Melody/keywords.txt deleted file mode 100644 index cfd30942..00000000 --- a/libraries/Melody/keywords.txt +++ /dev/null @@ -1,8 +0,0 @@ -Melody KEYWORD1 - -play KEYWORD2 -stop KEYWORD2 -setMelody KEYWORD2 -loopCount KEYWORD2 -setLoopCount KEYWORD2 -isPlaying KEYWORD2 diff --git a/libraries/PowerSave/PowerSave.cpp b/libraries/PowerSave/PowerSave.cpp deleted file mode 100644 index f6fb4b0f..00000000 --- a/libraries/PowerSave/PowerSave.cpp +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#include "PowerSave.h" -#include -#include -#include -#include - -/** - * \defgroup power_save Power saving utility functions - * - * The functions in this module assist with reducing power consumption on - * Arduino boards by disabling features that are not used or putting the - * device to sleep when it is inactive. - */ -/*\@{*/ - -/** - * \fn void unusedPin(uint8_t pin) - * \brief Marks an I/O \a pin as unused. - * \ingroup power_save - * - * This function sets \a pin to be an input with pullups enabled, which will - * reduce power consumption compared to pins that are left floating. - */ - -/** @cond */ -ISR(WDT_vect) -{ - wdt_disable(); -} -/** @endcond */ - -/** - * \enum SleepDuration - * \brief Duration to put the CPU to sleep with sleepFor(). - * \ingroup power_save - * - * \sa sleepFor() - */ - -/** - * \var SLEEP_15_MS - * \brief Sleep for 15 milliseconds. - * \ingroup power_save - */ - -/** - * \var SLEEP_30_MS - * \brief Sleep for 30 milliseconds. - * \ingroup power_save - */ - -/** - * \var SLEEP_60_MS - * \brief Sleep for 60 milliseconds. - * \ingroup power_save - */ - -/** - * \var SLEEP_120_MS - * \brief Sleep for 120 milliseconds. - * \ingroup power_save - */ - -/** - * \var SLEEP_250_MS - * \brief Sleep for 250 milliseconds. - * \ingroup power_save - */ - -/** - * \var SLEEP_500_MS - * \brief Sleep for 500 milliseconds. - * \ingroup power_save - */ - -/** - * \var SLEEP_1_SEC - * \brief Sleep for 1 second. - * \ingroup power_save - */ - -/** - * \var SLEEP_2_SEC - * \brief Sleep for 2 seconds. - * \ingroup power_save - */ - -/** - * \var SLEEP_4_SEC - * \brief Sleep for 4 seconds. - * \ingroup power_save - */ - -/** - * \var SLEEP_8_SEC - * \brief Sleep for 8 seconds. - * \ingroup power_save - */ - -/** - * \brief Puts the CPU to sleep for a specific \a duration. - * \ingroup power_save - * - * The analog to digital converter and the brown out detector will - * be disabled during sleep mode. - * - * The \a mode parameter indicates the mode to use when the device is - * sleeping. The default is SLEEP_MODE_IDLE. - */ -void sleepFor(SleepDuration duration, uint8_t mode) -{ - // Turn off the analog to digital converter. - ADCSRA &= ~(1 << ADEN); - power_adc_disable(); - - // Turn on the watchdog timer for the desired duration. - wdt_enable(duration); - WDTCSR |= (1 << WDIE); - - // Put the device to sleep, including turning off the Brown Out Detector. - set_sleep_mode(mode); - cli(); - sleep_enable(); -#if defined(sleep_bod_disable) - sleep_bod_disable(); -#endif - sei(); - sleep_cpu(); - sleep_disable(); - sei(); - - // Turn the analog to digital converter back on. - power_adc_enable(); - ADCSRA |= (1 << ADEN); -} - -/*\@}*/ diff --git a/libraries/PowerSave/PowerSave.h b/libraries/PowerSave/PowerSave.h deleted file mode 100644 index 0cd9cd10..00000000 --- a/libraries/PowerSave/PowerSave.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#ifndef PowerSave_h -#define PowerSave_h - -#if defined(ARDUINO) && ARDUINO >= 100 -#include -#else -#include -#endif - -inline void unusedPin(uint8_t pin) -{ - pinMode(pin, INPUT); - digitalWrite(pin, HIGH); -} - -enum SleepDuration -{ - SLEEP_15_MS, - SLEEP_30_MS, - SLEEP_60_MS, - SLEEP_120_MS, - SLEEP_250_MS, - SLEEP_500_MS, - SLEEP_1_SEC, - SLEEP_2_SEC, - SLEEP_4_SEC, - SLEEP_8_SEC -}; - -void sleepFor(SleepDuration duration, uint8_t mode = 0); - -#endif diff --git a/libraries/PowerSave/keywords.txt b/libraries/PowerSave/keywords.txt deleted file mode 100644 index 6a6b6bc1..00000000 --- a/libraries/PowerSave/keywords.txt +++ /dev/null @@ -1,2 +0,0 @@ -unusedPin KEYWORD2 -sleepFor KEYWORD2 diff --git a/libraries/RTC/DS1307RTC.cpp b/libraries/RTC/DS1307RTC.cpp deleted file mode 100644 index 2fbbf1ee..00000000 --- a/libraries/RTC/DS1307RTC.cpp +++ /dev/null @@ -1,324 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#include "DS1307RTC.h" -#include "../I2C/I2CMaster.h" -#if defined(ARDUINO) && ARDUINO >= 100 -#include -#else -#include -#endif - -/** - * \class DS1307RTC DS1307RTC.h - * \brief Communicates with a DS1307 realtime clock chip via I2C. - * - * This class simplifies the process of reading and writing the time and - * date information in a DS1307 realtime clock chip. The class also - * provides support for reading and writing information about alarms - * and other clock settings. - * - * If there is no DS1307 chip on the I2C bus, this class will fall back to - * the RTC class to simulate the current time and date based on the value - * of millis(). - * - * The DS1307 uses a 2-digit year so this class is limited to dates between - * 2000 and 2099 inclusive. - * - * Note: if this class has not been used with the DS1307 chip before, - * then the contents of NVRAM will be cleared. Any previous contents - * will be lost. - * - * \sa RTC, DS3232RTC - */ - -// I2C address of the RTC chip (7-bit). -#define DS1307_I2C_ADDRESS 0x68 - -// Registers. -#define DS1307_SECOND 0x00 -#define DS1307_MINUTE 0x01 -#define DS1307_HOUR 0x02 -#define DS1307_DAY_OF_WEEK 0x03 -#define DS1307_DATE 0x04 -#define DS1307_MONTH 0x05 -#define DS1307_YEAR 0x06 -#define DS1307_CONTROL 0x07 -#define DS1307_NVRAM 0x08 - -// Alarm storage at the end of the RTC's NVRAM. -#define DS1307_ALARM_SIZE 3 -#define DS1307_ALARMS (64 - RTC::ALARM_COUNT * DS1307_ALARM_SIZE - 1) -#define DS1307_ALARM_MAGIC 63 - -/** - * \brief Attaches to a realtime clock slave device on \a bus. - * - * If \a oneHzPin is not 255, then it indicates a digital input pin - * that is connected to the 1 Hz square wave output on the realtime clock. - * This input is used by hasUpdates() to determine if the time information - * has changed in a non-trivial manner. - * - * \sa hasUpdates() - */ -DS1307RTC::DS1307RTC(I2CMaster &bus, uint8_t oneHzPin) - : _bus(&bus) - , _oneHzPin(oneHzPin) - , prevOneHz(false) - , _isRealTime(true) -{ - // Make sure the CH bit in register 0 is off or the clock won't update. - _bus->startWrite(DS1307_I2C_ADDRESS); - _bus->write(DS1307_SECOND); - if (_bus->startRead(DS1307_I2C_ADDRESS, 1)) { - uint8_t value = _bus->read(); - if ((value & 0x80) != 0) - writeRegister(DS1307_SECOND, value & 0x7F); - } else { - // Did not get an acknowledgement from the RTC chip. - _isRealTime = false; - } - - // Turn on the 1 Hz square wave signal if required. - if (oneHzPin != 255 && _isRealTime) { - pinMode(oneHzPin, INPUT); - digitalWrite(oneHzPin, HIGH); - writeRegister(DS1307_CONTROL, 0x10); - } - - // Initialize the alarms in the RTC chip's NVRAM. - if (_isRealTime) - initAlarms(); -} - -/** - * \fn bool DS1307RTC::isRealTime() const - * \brief Returns true if the realtime clock is on the I2C bus; false if the time and date are simulated. - */ - -bool DS1307RTC::hasUpdates() -{ - // If not using a 1 Hz pin or there is no RTC chip available, - // then assume that there is an update available. - if (_oneHzPin == 255 || !_isRealTime) - return true; - - // The DS1307 updates the internal registers on the falling edge of the - // 1 Hz clock. The values should be ready to read on the rising edge. - bool value = digitalRead(_oneHzPin); - if (value && !prevOneHz) { - prevOneHz = value; - return true; - } else { - prevOneHz = value; - return false; - } -} - -inline uint8_t fromBCD(uint8_t value) -{ - return (value >> 4) * 10 + (value & 0x0F); -} - -inline uint8_t fromHourBCD(uint8_t value) -{ - if ((value & 0x40) != 0) { - // 12-hour mode. - uint8_t result = ((value >> 4) & 0x01) * 10 + (value & 0x0F); - if ((value & 0x20) != 0) - return (result == 12) ? 12 : (result + 12); // PM - else - return (result == 12) ? 0 : result; // AM - } else { - // 24-hour mode. - return fromBCD(value); - } -} - -void DS1307RTC::readTime(RTCTime *value) -{ - if (_isRealTime) { - _bus->startWrite(DS1307_I2C_ADDRESS); - _bus->write(DS1307_SECOND); - if (_bus->startRead(DS1307_I2C_ADDRESS, 3)) { - value->second = fromBCD(_bus->read() & 0x7F); - value->minute = fromBCD(_bus->read()); - value->hour = fromHourBCD(_bus->read()); - } else { - // RTC chip is not responding. - value->second = 0; - value->minute = 0; - value->hour = 0; - } - } else { - RTC::readTime(value); - } -} - -void DS1307RTC::readDate(RTCDate *value) -{ - if (!_isRealTime) { - RTC::readDate(value); - return; - } - _bus->startWrite(DS1307_I2C_ADDRESS); - _bus->write(DS1307_DATE); - if (_bus->startRead(DS1307_I2C_ADDRESS, 3)) { - value->day = fromBCD(_bus->read()); - value->month = fromBCD(_bus->read()); - value->year = fromBCD(_bus->read()) + 2000; - } else { - // RTC chip is not responding. - value->day = 1; - value->month = 1; - value->year = 2000; - } -} - -inline uint8_t toBCD(uint8_t value) -{ - return ((value / 10) << 4) + (value % 10); -} - -void DS1307RTC::writeTime(const RTCTime *value) -{ - if (_isRealTime) { - _bus->startWrite(DS1307_I2C_ADDRESS); - _bus->write(DS1307_SECOND); - _bus->write(toBCD(value->second)); - _bus->write(toBCD(value->minute)); - _bus->write(toBCD(value->hour)); // Changes mode to 24-hour clock. - _bus->endWrite(); - } else { - RTC::writeTime(value); - } -} - -void DS1307RTC::writeDate(const RTCDate *value) -{ - if (_isRealTime) { - _bus->startWrite(DS1307_I2C_ADDRESS); - _bus->write(DS1307_DATE); - _bus->write(toBCD(value->day)); - _bus->write(toBCD(value->month)); - _bus->write(toBCD(value->year % 100)); - _bus->endWrite(); - } else { - RTC::writeDate(value); - } -} - -void DS1307RTC::readAlarm(uint8_t alarmNum, RTCAlarm *value) -{ - if (_isRealTime) { - _bus->startWrite(DS1307_I2C_ADDRESS); - _bus->write(DS1307_ALARMS + alarmNum * DS1307_ALARM_SIZE); - if (_bus->startRead(DS1307_I2C_ADDRESS, 3)) { - value->hour = fromBCD(_bus->read()); - value->minute = fromBCD(_bus->read()); - value->flags = _bus->read(); - } else { - // RTC chip is not responding. - value->hour = 0; - value->minute = 0; - value->flags = 0; - } - } else { - RTC::readAlarm(alarmNum, value); - } -} - -void DS1307RTC::writeAlarm(uint8_t alarmNum, const RTCAlarm *value) -{ - if (_isRealTime) { - _bus->startWrite(DS1307_I2C_ADDRESS); - _bus->write(DS1307_ALARMS + alarmNum * DS1307_ALARM_SIZE); - _bus->write(toBCD(value->hour)); - _bus->write(toBCD(value->minute)); - _bus->write(value->flags); - _bus->endWrite(); - } else { - RTC::writeAlarm(alarmNum, value); - } -} - -int DS1307RTC::byteCount() const -{ - return DS1307_ALARMS - DS1307_NVRAM; -} - -uint8_t DS1307RTC::readByte(uint8_t offset) -{ - if (_isRealTime) - return readRegister(DS1307_NVRAM + offset); - else - return RTC::readByte(offset); -} - -void DS1307RTC::writeByte(uint8_t offset, uint8_t value) -{ - if (_isRealTime) - writeRegister(DS1307_NVRAM + offset, value); - else - RTC::writeByte(offset, value); -} - -void DS1307RTC::initAlarms() -{ - uint8_t value = readRegister(DS1307_ALARM_MAGIC); - if (value != (0xB0 + ALARM_COUNT)) { - // This is the first time we have used this clock chip, - // so initialize all alarms to their default state. - RTCAlarm alarm; - alarm.hour = 6; // Default to 6am for alarms. - alarm.minute = 0; - alarm.flags = 0; - for (uint8_t index = 0; index < ALARM_COUNT; ++index) - writeAlarm(index, &alarm); - writeRegister(DS1307_ALARM_MAGIC, 0xB0 + ALARM_COUNT); - - // Also clear the rest of NVRAM so that it is in a known state. - // Otherwise we'll have whatever garbage was present at power-on. - _bus->startWrite(DS1307_I2C_ADDRESS); - _bus->write(DS1307_NVRAM); - for (uint8_t index = DS1307_NVRAM; index < DS1307_ALARMS; ++index) - _bus->write(0); - _bus->endWrite(); - } -} - -uint8_t DS1307RTC::readRegister(uint8_t reg) -{ - _bus->startWrite(DS1307_I2C_ADDRESS); - _bus->write(reg); - if (!_bus->startRead(DS1307_I2C_ADDRESS, 1)) - return 0; // RTC chip is not responding. - return _bus->read(); -} - -bool DS1307RTC::writeRegister(uint8_t reg, uint8_t value) -{ - _bus->startWrite(DS1307_I2C_ADDRESS); - _bus->write(reg); - _bus->write(value); - return _bus->endWrite(); -} diff --git a/libraries/RTC/DS1307RTC.h b/libraries/RTC/DS1307RTC.h deleted file mode 100644 index 97ea41fd..00000000 --- a/libraries/RTC/DS1307RTC.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#ifndef DS1307RTC_h -#define DS1307RTC_h - -#include "RTC.h" - -class I2CMaster; - -class DS1307RTC : public RTC { -public: - DS1307RTC(I2CMaster &bus, uint8_t oneHzPin = 255); - - bool isRealTime() const { return _isRealTime; } - - bool hasUpdates(); - - void readTime(RTCTime *value); - void readDate(RTCDate *value); - - void writeTime(const RTCTime *value); - void writeDate(const RTCDate *value); - - void readAlarm(uint8_t alarmNum, RTCAlarm *value); - void writeAlarm(uint8_t alarmNum, const RTCAlarm *value); - - int byteCount() const; - uint8_t readByte(uint8_t offset); - void writeByte(uint8_t offset, uint8_t value); - -private: - I2CMaster *_bus; - uint8_t _oneHzPin; - bool prevOneHz; - bool _isRealTime; - - void initAlarms(); - - uint8_t readRegister(uint8_t reg); - bool writeRegister(uint8_t reg, uint8_t value); -}; - -#endif diff --git a/libraries/RTC/DS3231RTC.cpp b/libraries/RTC/DS3231RTC.cpp deleted file mode 100644 index a4ba0c4a..00000000 --- a/libraries/RTC/DS3231RTC.cpp +++ /dev/null @@ -1,637 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -/* - * Adapted from DS3232RTC library for DS3231 RTC chip by Thijs Oppermann - * 2014-12-07 - */ - -#include "DS3231RTC.h" -#include "../I2C/I2CMaster.h" -#if defined(ARDUINO) && ARDUINO >= 100 -#include -#else -#include -#endif - -/** - * \class DS3231RTC DS3231RTC.h - * \brief Communicates with a DS3231 realtime clock chip via I2C. - * - * This class simplifies the process of reading and writing the time - * and date information in a DS3231 realtime clock chip. The class - * also provides support for reading and writing information about - * alarms and other clock settings. - * - * If there is no DS3231 chip on the I2C bus, this class will fall - * back to the RTC class to simulate the current time and date based - * on the value of millis(). - * - * Alarms 0 and 1 can be set to generate an interrupt when they fire - * using enableAlarmInterrupts(). The firedAlarm() function can be - * used to determine which alarm has fired. - * - * The DS3231 uses a 2-digit year so this class is limited to dates - * between 2000 and 2099 inclusive. - * - * The structure RTCAlarm is used to read and write the alarms. It has - * a flags field which is analogous to the alarm mask bits found in - * the DS3231 manual. Bit 7 signals whether this is an alarm structure - * with settings for alarm 0 or 1 (as these are different, see - * manual). - * - * \sa RTC, DS3232RTC, DS1307RTC - */ - -// I2C address of the RTC chip (7-bit). -#define DS3231_I2C_ADDRESS 0x68 - -// Registers. -#define DS3231_SECOND 0x00 -#define DS3231_MINUTE 0x01 -#define DS3231_HOUR 0x02 -#define DS3231_DAY_OF_WEEK 0x03 -#define DS3231_DATE 0x04 -#define DS3231_MONTH 0x05 -#define DS3231_YEAR 0x06 -#define DS3231_ALARM1_SEC 0x07 -#define DS3231_ALARM1_MIN 0x08 -#define DS3231_ALARM1_HOUR 0x09 -#define DS3231_ALARM1_DAY 0x0A -#define DS3231_ALARM2_MIN 0x0B -#define DS3231_ALARM2_HOUR 0x0C -#define DS3231_ALARM2_DAY 0x0D -#define DS3231_CONTROL 0x0E -#define DS3231_STATUS 0x0F -#define DS3231_AGING_OFFSET 0x10 -#define DS3231_TEMP_MSB 0x11 -#define DS3231_TEMP_LSB 0x12 - -// Bits in the DS3231_CONTROL register. -#define DS3231_EOSC 0x80 -#define DS3231_BBSQW 0x40 -#define DS3231_CONV 0x20 -#define DS3231_RS_1HZ 0x00 -#define DS3231_RS_1024HZ 0x08 -#define DS3231_RS_4096HZ 0x10 -#define DS3231_RS_8192HZ 0x18 -#define DS3231_INTCN 0x04 -#define DS3231_A2IE 0x02 -#define DS3231_A1IE 0x01 - -// Bits in the DS3231_STATUS register. -#define DS3231_OSF 0x80 -#define DS3231_BB32KHZ 0x40 -#define DS3231_EN32KHZ 0x08 -#define DS3231_BSY 0x04 -#define DS3231_A2F 0x02 -#define DS3231_A1F 0x01 - -// Alarms 0 and 1 -#define DS3231_ALARM_0 0x07 -#define DS3231_ALARM_1 0x0B - -/** - * \brief Attaches to a realtime clock slave device on \a bus. - * - * If \a oneHzPin is not 255, then it indicates a digital input pin - * that is connected to the 1 Hz square wave output on the realtime clock. - * This input is used by hasUpdates() to determine if the time information - * has changed in a non-trivial manner. - * - * If you wish to use enableAlarmInterrupts(), then \a oneHzPin must be 255. - * - * \sa hasUpdates(), enableAlarmInterrupts() - */ -DS3231RTC::DS3231RTC(I2CMaster &bus, uint8_t oneHzPin) - : _bus(&bus) - , _oneHzPin(oneHzPin) - , prevOneHz(false) - , _isRealTime(true) - , alarmInterrupts(false) { - // Probe the device and configure it for our use. - _bus->startWrite(DS3231_I2C_ADDRESS); - _bus->write(DS3231_CONTROL); - if ( _bus->startRead(DS3231_I2C_ADDRESS, 1) ) { - uint8_t value = _bus->read() & DS3231_CONV; - if ( oneHzPin != 255 ) { - value |= DS3231_BBSQW | DS3231_RS_1HZ; - } - _bus->startWrite(DS3231_I2C_ADDRESS); - _bus->write(DS3231_CONTROL); - _bus->write(value); - _bus->endWrite(); - } - else { - // Did not get an acknowledgement from the RTC chip. - _isRealTime = false; - } - - // Configure the 1 Hz square wave pin if required. - if ( ( oneHzPin != 255) && _isRealTime ) { - pinMode(oneHzPin, INPUT); - digitalWrite(oneHzPin, HIGH); - } -} - -/** - * \fn bool DS3231RTC::isRealTime() const - * \brief Returns true if the realtime clock is on the I2C bus; false if the time and date are simulated. - */ - -/** - * \fn bool DS3231RTC::hasUpdates() - * \brief Returns true if there are updates - */ - -bool DS3231RTC::hasUpdates() { - // If not using a 1 Hz pin or there is no RTC chip available, - // then assume that there is an update available. - if ( ( _oneHzPin == 255) || !_isRealTime ) { - return true; - } - - // The DS3231 updates the internal registers on the falling edge of the - // 1 Hz clock. The values should be ready to read on the rising edge. - bool value = digitalRead(_oneHzPin); - if ( value && !prevOneHz ) { - prevOneHz = value; - return true; - } - else { - prevOneHz = value; - return false; - } -} - -inline uint8_t fromBCD(uint8_t value) { - return (value >> 4) * 10 + (value & 0x0F); -} - -inline uint8_t fromHourBCD(uint8_t value) { - if ( (value & 0x40) != 0 ) { - // 12-hour mode. - uint8_t result = ( (value >> 4) & 0x01 ) * 10 + (value & 0x0F); - if ( (value & 0x20) != 0 ) { - return (result == 12) ? 12 : (result + 12); // PM - } - else { - return (result == 12) ? 0 : result; // AM - } - } - else { - // 24-hour mode. - return fromBCD(value); - } -} - -void DS3231RTC::readTime(RTCTime* value) { - if ( _isRealTime ) { - _bus->startWrite(DS3231_I2C_ADDRESS); - _bus->write(DS3231_SECOND); - if ( _bus->startRead(DS3231_I2C_ADDRESS, 3) ) { - value->second = fromBCD( _bus->read() ); - value->minute = fromBCD( _bus->read() ); - value->hour = fromHourBCD( _bus->read() ); - } - else { - // RTC chip is not responding. - value->second = 0; - value->minute = 0; - value->hour = 0; - } - } - else { - RTC::readTime(value); - } -} - -void DS3231RTC::readDate(RTCDate* value) { - if ( !_isRealTime ) { - RTC::readDate(value); - return; - } - _bus->startWrite(DS3231_I2C_ADDRESS); - _bus->write(DS3231_DATE); - if ( _bus->startRead(DS3231_I2C_ADDRESS, 3) ) { - value->day = fromBCD( _bus->read() ); - value->month = fromBCD(_bus->read() & 0x7F); // Strip century bit. - value->year = fromBCD( _bus->read() ) + 2000; - } - else { - // RTC chip is not responding. - value->day = 1; - value->month = 1; - value->year = 2000; - } -} - -inline uint8_t toBCD(uint8_t value) { - return ( (value / 10) << 4 ) + (value % 10); -} - -void DS3231RTC::writeTime(const RTCTime* value) { - if ( _isRealTime ) { - _bus->startWrite(DS3231_I2C_ADDRESS); - _bus->write(DS3231_SECOND); - _bus->write( toBCD(value->second) ); - _bus->write( toBCD(value->minute) ); - _bus->write( toBCD(value->hour) ); // Changes mode to 24-hour clock. - _bus->endWrite(); - } - else { - RTC::writeTime(value); - } -} - -void DS3231RTC::writeDate(const RTCDate* value) { - if ( _isRealTime ) { - _bus->startWrite(DS3231_I2C_ADDRESS); - _bus->write(DS3231_DATE); - _bus->write( toBCD(value->day) ); - _bus->write( toBCD(value->month) ); - _bus->write( toBCD(value->year % 100) ); - _bus->endWrite(); - } - else { - RTC::writeDate(value); - } -} - -void DS3231RTC::readAlarm(uint8_t alarmNum, RTCAlarm* value) { - if ( _isRealTime ) { - uint8_t reg_value = readRegister(DS3231_CONTROL); - _bus->startWrite(DS3231_I2C_ADDRESS); - if ( 0 == alarmNum ) { - _bus->write(DS3231_ALARM_0); - if ( _bus->startRead(DS3231_I2C_ADDRESS, 4) ) { - alarmSecondValues(_bus->read(), value); - alarmMinuteValues(_bus->read(), value); - alarmHourValues(_bus->read(), value); - alarmDayValues(_bus->read(), value); - value->flags &= ~0x80; - value->flags |= (reg_value & 0x01) << 6; - } - else { - // RTC chip is not responding. - value->day = 0; - value->hour = 0; - value->minute = 0; - value->second = 0; - } - } - else if ( 1 == alarmNum ) { - _bus->write(DS3231_ALARM_1); - if ( _bus->startRead(DS3231_I2C_ADDRESS, 3) ) { - value->second = 0; - alarmMinuteValues(_bus->read(), value); - alarmHourValues(_bus->read(), value); - alarmDayValues(_bus->read(), value); - value->flags |= 0x80; - value->flags |= (reg_value & 0x02) << 5; - } - else { - // RTC chip is not responding. - value->day = 0; - value->hour = 0; - value->minute = 0; - value->second = 0; - } - } - } - else { - RTC::readAlarm(alarmNum, value); - } -} - -void DS3231RTC::alarmSecondValues(uint8_t read_value, RTCAlarm* value) { - uint8_t mask_bit = (read_value & 0x80) ? 0x01 : 0x00; - - value->second = fromBCD(read_value & 0x7F); - value->flags |= mask_bit; -} - -void DS3231RTC::alarmMinuteValues(uint8_t read_value, RTCAlarm* value) { - uint8_t mask_bit = (read_value & 0x80) ? 0x02 : 0x00; - - value->minute = fromBCD(read_value & 0x7F); - value->flags |= mask_bit; -} - -void DS3231RTC::alarmHourValues(uint8_t read_value, RTCAlarm* value) { - uint8_t mask_bit = (read_value & 0x80) ? 0x04 : 0x00; - uint8_t is_ampm = read_value & 0x40; - - if ( is_ampm ) { - uint8_t hour = fromBCD(read_value & ~0xE0); - if ( read_value & 0x20 ) { - hour += 12; - } - value->hour = hour; - } - else { - value->hour = fromBCD(read_value & ~0xC0); - } - value->flags |= mask_bit; -} - -void DS3231RTC::alarmDayValues(uint8_t read_value, RTCAlarm* value) { - uint8_t mask_bit = (read_value & 0x80) ? 0x08 : 0x00; - uint8_t is_dow = read_value & 0x40; - - if ( is_dow ) { - value->day = 0; - value->dow = fromBCD(read_value & 0x0F); - value->flags |= 0x20; - } - else { - value->dow = 0; - value->day = fromBCD(read_value & 0x3F); - value->flags &= ~0x20; - } - value->flags |= mask_bit; -} - -void DS3231RTC::writeAlarm(uint8_t alarmNum, const RTCAlarm* value) { - setAlarm(alarmNum, value); - return; -} - -void DS3231RTC::clearAlarm(uint8_t alarmNum) { - if ( 0 == alarmNum ) { - _bus->startWrite(DS3231_I2C_ADDRESS); - _bus->write(DS3231_ALARM_0); - _bus->write(0); - _bus->write(0); - _bus->write(0); - _bus->write(0x41); - _bus->endWrite(); - } - else if ( 1 == alarmNum ) { - _bus->startWrite(DS3231_I2C_ADDRESS); - _bus->write(DS3231_ALARM_1); - _bus->write(0); - _bus->write(0); - _bus->write(0x41); - _bus->endWrite(); - } -} - -/** - * \brief Sets the alarm with index \a alarmNum from \a value. - * - * The \a alarmNum parameter must be between 0 and \ref ALARM_COUNT - 1. - * - * \return Returns true if the alarm was set; false otherwise. - * - * \sa writeAlarm() - */ -bool DS3231RTC::setAlarm(uint8_t alarmNum, const RTCAlarm* value) { - if ( _isRealTime ) { - uint8_t alarm_mask_bits = value->flags; - - if ( 0 == alarmNum ) { - if ( alarm_mask_bits & 0x80 ) { - return false; - } - - _bus->startWrite(DS3231_I2C_ADDRESS); - _bus->write(DS3231_ALARM_0); - _bus->write( toBCD(value->second) | ( ( alarm_mask_bits & 0x01 ) << 7 ) ); - _bus->write( toBCD(value->minute) | ( ( alarm_mask_bits & 0x02 ) << 6 ) ); - // only support writing 24h - _bus->write( toBCD(value->hour) | ( ( alarm_mask_bits & 0x04 ) << 5 ) ); - _bus->write( getAlarmDayValue(value) ); - _bus->endWrite(); - if ( value->flags & 0x40 ) { - enableAlarm(alarmNum); - } - } - else if ( 1 == alarmNum ) { - if ( !(alarm_mask_bits & 0x80) ) { - return false; - } - - _bus->startWrite(DS3231_I2C_ADDRESS); - _bus->write(DS3231_ALARM_1); - _bus->write( toBCD(value->minute) | ( ( alarm_mask_bits & 0x02 ) << 6 ) ); - // only support writing 24h - _bus->write( toBCD(value->hour) | ( ( alarm_mask_bits & 0x04 ) << 5 ) ); - _bus->write( getAlarmDayValue(value) ); - _bus->endWrite(); - if ( value->flags & 0x40 ) { - enableAlarm(alarmNum); - } - } - } - else { - RTC::writeAlarm(alarmNum, value); - return false; - } - - return true; -} - -uint8_t DS3231RTC::getAlarmDayValue(const RTCAlarm* value) { - uint8_t alarm_mask_bits = value->flags; - uint8_t day_value_mask = ( alarm_mask_bits & 0x08 ) << 4; - - if ( alarm_mask_bits & 0x20 ) { - // day of week - day_value_mask |= 0x40; - return (toBCD(value->dow) | day_value_mask); - } - else { - // date - day_value_mask &= ~0x40; - return (toBCD(value->day) | day_value_mask); - } -} - -int DS3231RTC::readTemperature() { - if ( _isRealTime ) { - return ( ( (int)(signed char)readRegister(DS3231_TEMP_MSB) ) << 2 ) | - (readRegister(DS3231_TEMP_LSB) >> 6); - } - else { - return NO_TEMPERATURE; - } -} - -/** - * \brief Enables the generation of interrupts for alarms 0 and 1. - * - * When the interrupt occurs, use firedAlarm() to determine which alarm - * has fired. The application is responsible for implementing the - * interrupt service routine to watch for the interrupt. - * - * Note: this function does nothing if the 1 Hz pin was enabled in the - * constructor, but firedAlarm() can still be used to determine which - * alarm has fired when hasUpdates() reports that there is an update - * available. - * - * \sa disableAlarmInterrupts(), firedAlarm() - */ -void DS3231RTC::enableAlarmInterrupts() { - if ( ( _oneHzPin == 255) && _isRealTime ) { - uint8_t value = readRegister(DS3231_CONTROL); - value |= DS3231_INTCN; - writeRegister(DS3231_CONTROL, value); - alarmInterrupts = true; - } -} - -/** - * \brief Disables the generation of interrupts for alarms 0 and 1. - * - * \sa enableAlarmInterrupts() - */ -void DS3231RTC::disableAlarmInterrupts() { - if ( alarmInterrupts ) { - uint8_t value = readRegister(DS3231_CONTROL); - value &= ~(DS3231_INTCN | DS3231_A2IE | DS3231_A1IE); - writeRegister(DS3231_CONTROL, value); - alarmInterrupts = false; - } -} - -/** - * \brief Determines which of alarms 0 or 1 have fired since the last call. - * - * Returns 0 if alarm 0 has fired, 1 if alarm 1 has fired, 2 if both alarms - * have fired, or -1 if neither alarm has fired. - * - * The fired alarm state will be cleared, ready for the next call. - * - * This function cannot be used to determine if alarms 2 or 3 have fired - * as they are stored in NVRAM and are not handled specially by the DS3231. - * - * \sa enableAlarmInterrupts() - */ -int DS3231RTC::firedAlarm() { - if ( !_isRealTime ) { - return -1; - } - uint8_t value = readRegister(DS3231_STATUS); - int alarm; - if ( value & DS3231_A1F ) { - if ( value & DS3231_A2F ) { - alarm = 2; - } - else { - alarm = 0; - } - } - else if ( value & DS3231_A2F ) { - alarm = 1; - } - else { - alarm = -1; - } - if ( alarm != -1 ) { - value &= ~(DS3231_A1F | DS3231_A2F); - writeRegister(DS3231_STATUS, value); - } - return alarm; -} - -/** - * \brief Enables the 32 kHz output on the DS3231 chip. - * - * \sa disable32kHzOutput() - */ -void DS3231RTC::enable32kHzOutput() { - if ( _isRealTime ) { - uint8_t value = readRegister(DS3231_STATUS); - value |= DS3231_BB32KHZ | DS3231_EN32KHZ; - writeRegister(DS3231_STATUS, value); - } -} - -/** - * \brief Disables the 32 kHz output on the DS3231 chip. - * - * \sa enable32kHzOutput() - */ -void DS3231RTC::disable32kHzOutput() { - if ( _isRealTime ) { - uint8_t value = readRegister(DS3231_STATUS); - value &= ~(DS3231_BB32KHZ | DS3231_EN32KHZ); - writeRegister(DS3231_STATUS, value); - } -} - -uint8_t DS3231RTC::readRegister(uint8_t reg) { - _bus->startWrite(DS3231_I2C_ADDRESS); - _bus->write(reg); - if ( !_bus->startRead(DS3231_I2C_ADDRESS, 1) ) { - return 0; // RTC chip is not responding. - } - return _bus->read(); -} - -bool DS3231RTC::writeRegister(uint8_t reg, uint8_t value) { - _bus->startWrite(DS3231_I2C_ADDRESS); - _bus->write(reg); - _bus->write(value); - return _bus->endWrite(); -} - -/** - * \brief Enables a specific alarm. - * - * \param alarmNum The alarm to enable. - * - * \sa disableAlarm() - */ -void DS3231RTC::enableAlarm(uint8_t alarmNum) { - uint8_t value = readRegister(DS3231_CONTROL); - - if ( 0 == alarmNum ) { - value |= DS3231_A1IE; - } - else if ( 1 == alarmNum ) { - value |= DS3231_A2IE; - } - writeRegister(DS3231_CONTROL, value); -} - -/** - * \brief Disables a specific alarm. - * - * \param alarmNum The alarm to disable. - * - * \sa enableAlarm() - */ -void DS3231RTC::disableAlarm(uint8_t alarmNum) { - uint8_t value = readRegister(DS3231_CONTROL); - - clearAlarm(alarmNum); - - if ( 0 == alarmNum ) { - value &= ~DS3231_A1IE; - } - else if ( 1 == alarmNum ) { - value &= ~DS3231_A2IE; - } - writeRegister(DS3231_CONTROL, value); -} diff --git a/libraries/RTC/DS3231RTC.h b/libraries/RTC/DS3231RTC.h deleted file mode 100644 index 17262cfa..00000000 --- a/libraries/RTC/DS3231RTC.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -/* - * Adapted from DS3232RTC library for DS3231 RTC chip by Thijs Oppermann - * 2014-12-07 - */ - -#ifndef DS3231RTC_h -#define DS3231RTC_h - -#include "RTC.h" - -class I2CMaster; - -class DS3231RTC : public RTC { - public: - DS3231RTC(I2CMaster &bus, uint8_t oneHzPin = 255); - - bool isRealTime() const { - return _isRealTime; - } - - bool hasUpdates(); - - void readTime(RTCTime* value); - void readDate(RTCDate* value); - - void writeTime(const RTCTime* value); - void writeDate(const RTCDate* value); - - void readAlarm(uint8_t alarmNum, RTCAlarm* value); - void writeAlarm(uint8_t alarmNum, const RTCAlarm* value); - bool setAlarm(uint8_t alarmNum, const RTCAlarm* value); - - int readTemperature(); - - void enableAlarmInterrupts(); - void disableAlarmInterrupts(); - int firedAlarm(); - - void enable32kHzOutput(); - void disable32kHzOutput(); - - void enableAlarm(uint8_t alarmNum); - void disableAlarm(uint8_t alarmNum); - - private: - I2CMaster* _bus; - uint8_t _oneHzPin; - bool prevOneHz; - bool _isRealTime; - bool alarmInterrupts; - - void alarmSecondValues(uint8_t read_value, RTCAlarm* value); - void alarmMinuteValues(uint8_t read_value, RTCAlarm* value); - void alarmHourValues(uint8_t read_value, RTCAlarm* value); - void alarmDayValues(uint8_t read_value, RTCAlarm* value); - - uint8_t getAlarmDayValue(const RTCAlarm* value); - - void clearAlarm(uint8_t alarmNum); - - uint8_t readRegister(uint8_t reg); - bool writeRegister(uint8_t reg, uint8_t value); -}; - -#endif diff --git a/libraries/RTC/DS3232RTC.cpp b/libraries/RTC/DS3232RTC.cpp deleted file mode 100644 index ef31a767..00000000 --- a/libraries/RTC/DS3232RTC.cpp +++ /dev/null @@ -1,526 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#include "DS3232RTC.h" -#include "../I2C/I2CMaster.h" -#if defined(ARDUINO) && ARDUINO >= 100 -#include -#else -#include -#endif - -/** - * \class DS3232RTC DS3232RTC.h - * \brief Communicates with a DS3232 realtime clock chip via I2C. - * - * This class simplifies the process of reading and writing the time and - * date information in a DS3232 realtime clock chip. The class also - * provides support for reading and writing information about alarms - * and other clock settings. - * - * If there is no DS3232 chip on the I2C bus, this class will fall back to - * the RTC class to simulate the current time and date based on the value - * of millis(). - * - * Alarms 0 and 1 can be set to generate an interrupt when they fire using - * enableAlarmInterrupts(). The firedAlarm() function can be used to - * determine which alarm has fired. Alarms 2 and 3 cannot be monitored - * with interrupts. - * - * The DS3232 uses a 2-digit year so this class is limited to dates between - * 2000 and 2099 inclusive. - * - * Note: if this class has not been used with the DS3232 chip before, - * then the contents of NVRAM will be cleared. Any previous contents - * will be lost. - * - * \sa RTC, DS1307RTC - */ - -// I2C address of the RTC chip (7-bit). -#define DS3232_I2C_ADDRESS 0x68 - -// Registers. -#define DS3232_SECOND 0x00 -#define DS3232_MINUTE 0x01 -#define DS3232_HOUR 0x02 -#define DS3232_DAY_OF_WEEK 0x03 -#define DS3232_DATE 0x04 -#define DS3232_MONTH 0x05 -#define DS3232_YEAR 0x06 -#define DS3232_ALARM1_SEC 0x07 -#define DS3232_ALARM1_MIN 0x08 -#define DS3232_ALARM1_HOUR 0x09 -#define DS3232_ALARM1_DAY 0x0A -#define DS3232_ALARM2_MIN 0x0B -#define DS3232_ALARM2_HOUR 0x0C -#define DS3232_ALARM2_DAY 0x0D -#define DS3232_CONTROL 0x0E -#define DS3232_STATUS 0x0F -#define DS3232_AGING_OFFSET 0x10 -#define DS3232_TEMP_MSB 0x11 -#define DS3232_TEMP_LSB 0x12 -#define DS3232_RESERVED 0x13 -#define DS3232_NVRAM 0x14 - -// Bits in the DS3232_CONTROL register. -#define DS3232_EOSC 0x80 -#define DS3232_BBSQW 0x40 -#define DS3232_CONV 0x20 -#define DS3232_RS_1HZ 0x00 -#define DS3232_RS_1024HZ 0x08 -#define DS3232_RS_4096HZ 0x10 -#define DS3232_RS_8192HZ 0x18 -#define DS3232_INTCN 0x04 -#define DS3232_A2IE 0x02 -#define DS3232_A1IE 0x01 - -// Bits in the DS3232_STATUS register. -#define DS3232_OSF 0x80 -#define DS3232_BB32KHZ 0x40 -#define DS3232_CRATE_64 0x00 -#define DS3232_CRATE_128 0x10 -#define DS3232_CRATE_256 0x20 -#define DS3232_CRATE_512 0x30 -#define DS3232_EN32KHZ 0x08 -#define DS3232_BSY 0x04 -#define DS3232_A2F 0x02 -#define DS3232_A1F 0x01 - -// Alarm storage at the end of the RTC's NVRAM. -#define DS3232_ALARM_SIZE 3 -#define DS3232_ALARMS (256 - RTC::ALARM_COUNT * DS3232_ALARM_SIZE - 1) -#define DS3232_ALARM_MAGIC 255 - -/** - * \brief Attaches to a realtime clock slave device on \a bus. - * - * If \a oneHzPin is not 255, then it indicates a digital input pin - * that is connected to the 1 Hz square wave output on the realtime clock. - * This input is used by hasUpdates() to determine if the time information - * has changed in a non-trivial manner. - * - * If you wish to use enableAlarmInterrupts(), then \a oneHzPin must be 255. - * - * \sa hasUpdates(), enableAlarmInterrupts() - */ -DS3232RTC::DS3232RTC(I2CMaster &bus, uint8_t oneHzPin) - : _bus(&bus) - , _oneHzPin(oneHzPin) - , prevOneHz(false) - , _isRealTime(true) - , alarmInterrupts(false) -{ - // Probe the device and configure it for our use. - _bus->startWrite(DS3232_I2C_ADDRESS); - _bus->write(DS3232_CONTROL); - if (_bus->startRead(DS3232_I2C_ADDRESS, 1)) { - uint8_t value = _bus->read() & DS3232_CONV; - if (oneHzPin != 255) - value |= DS3232_BBSQW | DS3232_RS_1HZ; - _bus->startWrite(DS3232_I2C_ADDRESS); - _bus->write(DS3232_CONTROL); - _bus->write(value); - _bus->write(DS3232_CRATE_64); - _bus->endWrite(); - } else { - // Did not get an acknowledgement from the RTC chip. - _isRealTime = false; - } - - // Configure the 1 Hz square wave pin if required. - if (oneHzPin != 255 && _isRealTime) { - pinMode(oneHzPin, INPUT); - digitalWrite(oneHzPin, HIGH); - } - - // Initialize the alarms in the RTC chip's NVRAM. - if (_isRealTime) - initAlarms(); -} - -/** - * \fn bool DS3232RTC::isRealTime() const - * \brief Returns true if the realtime clock is on the I2C bus; false if the time and date are simulated. - */ - -bool DS3232RTC::hasUpdates() -{ - // If not using a 1 Hz pin or there is no RTC chip available, - // then assume that there is an update available. - if (_oneHzPin == 255 || !_isRealTime) - return true; - - // The DS3232 updates the internal registers on the falling edge of the - // 1 Hz clock. The values should be ready to read on the rising edge. - bool value = digitalRead(_oneHzPin); - if (value && !prevOneHz) { - prevOneHz = value; - return true; - } else { - prevOneHz = value; - return false; - } -} - -inline uint8_t fromBCD(uint8_t value) -{ - return (value >> 4) * 10 + (value & 0x0F); -} - -inline uint8_t fromHourBCD(uint8_t value) -{ - if ((value & 0x40) != 0) { - // 12-hour mode. - uint8_t result = ((value >> 4) & 0x01) * 10 + (value & 0x0F); - if ((value & 0x20) != 0) - return (result == 12) ? 12 : (result + 12); // PM - else - return (result == 12) ? 0 : result; // AM - } else { - // 24-hour mode. - return fromBCD(value); - } -} - -void DS3232RTC::readTime(RTCTime *value) -{ - if (_isRealTime) { - _bus->startWrite(DS3232_I2C_ADDRESS); - _bus->write(DS3232_SECOND); - if (_bus->startRead(DS3232_I2C_ADDRESS, 3)) { - value->second = fromBCD(_bus->read()); - value->minute = fromBCD(_bus->read()); - value->hour = fromHourBCD(_bus->read()); - } else { - // RTC chip is not responding. - value->second = 0; - value->minute = 0; - value->hour = 0; - } - } else { - RTC::readTime(value); - } -} - -void DS3232RTC::readDate(RTCDate *value) -{ - if (!_isRealTime) { - RTC::readDate(value); - return; - } - _bus->startWrite(DS3232_I2C_ADDRESS); - _bus->write(DS3232_DATE); - if (_bus->startRead(DS3232_I2C_ADDRESS, 3)) { - value->day = fromBCD(_bus->read()); - value->month = fromBCD(_bus->read() & 0x7F); // Strip century bit. - value->year = fromBCD(_bus->read()) + 2000; - } else { - // RTC chip is not responding. - value->day = 1; - value->month = 1; - value->year = 2000; - } -} - -inline uint8_t toBCD(uint8_t value) -{ - return ((value / 10) << 4) + (value % 10); -} - -void DS3232RTC::writeTime(const RTCTime *value) -{ - if (_isRealTime) { - _bus->startWrite(DS3232_I2C_ADDRESS); - _bus->write(DS3232_SECOND); - _bus->write(toBCD(value->second)); - _bus->write(toBCD(value->minute)); - _bus->write(toBCD(value->hour)); // Changes mode to 24-hour clock. - _bus->endWrite(); - } else { - RTC::writeTime(value); - } -} - -void DS3232RTC::writeDate(const RTCDate *value) -{ - if (_isRealTime) { - _bus->startWrite(DS3232_I2C_ADDRESS); - _bus->write(DS3232_DATE); - _bus->write(toBCD(value->day)); - _bus->write(toBCD(value->month)); - _bus->write(toBCD(value->year % 100)); - _bus->endWrite(); - } else { - RTC::writeDate(value); - } -} - -void DS3232RTC::readAlarm(uint8_t alarmNum, RTCAlarm *value) -{ - if (_isRealTime) { - _bus->startWrite(DS3232_I2C_ADDRESS); - _bus->write(DS3232_ALARMS + alarmNum * DS3232_ALARM_SIZE); - if (_bus->startRead(DS3232_I2C_ADDRESS, 3)) { - value->hour = fromBCD(_bus->read()); - value->minute = fromBCD(_bus->read()); - value->flags = _bus->read(); - } else { - // RTC chip is not responding. - value->hour = 0; - value->minute = 0; - value->flags = 0; - } - } else { - RTC::readAlarm(alarmNum, value); - } -} - -void DS3232RTC::writeAlarm(uint8_t alarmNum, const RTCAlarm *value) -{ - if (_isRealTime) { - // Write the alarm details to NVRAM. - _bus->startWrite(DS3232_I2C_ADDRESS); - _bus->write(DS3232_ALARMS + alarmNum * DS3232_ALARM_SIZE); - _bus->write(toBCD(value->hour)); - _bus->write(toBCD(value->minute)); - _bus->write(value->flags); - _bus->endWrite(); - - // Keep the DS3232's built-in alarms in sync with the first two alarms. - if (alarmNum == 0) { - _bus->startWrite(DS3232_I2C_ADDRESS); - _bus->write(DS3232_ALARM1_SEC); - _bus->write(0); - _bus->write(toBCD(value->minute)); - _bus->write(toBCD(value->hour)); - _bus->write(0x81); // Match hours, mins, secs; day = 1 - _bus->endWrite(); - if (alarmInterrupts) - updateAlarmInterrupts(); - } else if (alarmNum == 1) { - _bus->startWrite(DS3232_I2C_ADDRESS); - _bus->write(DS3232_ALARM2_MIN); - _bus->write(toBCD(value->minute)); - _bus->write(toBCD(value->hour)); - _bus->write(0x81); // Match hours, mins; day = 1 - _bus->endWrite(); - if (alarmInterrupts) - updateAlarmInterrupts(); - } - } else { - RTC::writeAlarm(alarmNum, value); - } -} - -int DS3232RTC::byteCount() const -{ - return DS3232_ALARMS - DS3232_NVRAM; -} - -uint8_t DS3232RTC::readByte(uint8_t offset) -{ - if (_isRealTime) - return readRegister(DS3232_NVRAM + offset); - else - return RTC::readByte(offset); -} - -void DS3232RTC::writeByte(uint8_t offset, uint8_t value) -{ - if (_isRealTime) - writeRegister(DS3232_NVRAM + offset, value); - else - RTC::writeByte(offset, value); -} - -int DS3232RTC::readTemperature() -{ - if (_isRealTime) { - return (((int)(signed char)readRegister(DS3232_TEMP_MSB)) << 2) | - (readRegister(DS3232_TEMP_LSB) >> 6); - } else { - return NO_TEMPERATURE; - } -} - -/** - * \brief Enables the generation of interrupts for alarms 0 and 1. - * - * When the interrupt occurs, use firedAlarm() to determine which alarm - * has fired. The application is responsible for implementing the - * interrupt service routine to watch for the interrupt. - * - * Note: this function does nothing if the 1 Hz pin was enabled in the - * constructor, but firedAlarm() can still be used to determine which - * alarm has fired when hasUpdates() reports that there is an update - * available. - * - * \sa disableAlarmInterrupts(), firedAlarm() - */ -void DS3232RTC::enableAlarmInterrupts() -{ - if (_oneHzPin == 255 && _isRealTime) { - updateAlarmInterrupts(); - alarmInterrupts = true; - } -} - -/** - * \brief Disables the generation of interrupts for alarms 0 and 1. - * - * \sa enableAlarmInterrupts() - */ -void DS3232RTC::disableAlarmInterrupts() -{ - if (alarmInterrupts) { - uint8_t value = readRegister(DS3232_CONTROL); - value &= ~(DS3232_INTCN | DS3232_A2IE | DS3232_A1IE); - writeRegister(DS3232_CONTROL, value); - alarmInterrupts = false; - } -} - -/** - * \brief Determines which of alarms 0 or 1 have fired since the last call. - * - * Returns 0 if alarm 0 has fired, 1 if alarm 1 has fired, 2 if both alarms - * have fired, or -1 if neither alarm has fired. - * - * The fired alarm state will be cleared, ready for the next call. - * - * This function cannot be used to determine if alarms 2 or 3 have fired - * as they are stored in NVRAM and are not handled specially by the DS3232. - * - * \sa enableAlarmInterrupts() - */ -int DS3232RTC::firedAlarm() -{ - if (!_isRealTime) - return -1; - uint8_t value = readRegister(DS3232_STATUS); - int alarm; - if (value & DS3232_A1F) { - if (value & DS3232_A2F) - alarm = 2; - else - alarm = 0; - } else if (value & DS3232_A2F) { - alarm = 1; - } else { - alarm = -1; - } - if (alarm != -1) { - value &= ~(DS3232_A1F | DS3232_A2F); - writeRegister(DS3232_STATUS, value); - } - return alarm; -} - -/** - * \brief Enables the 32 kHz output on the DS3232 chip. - * - * \sa disable32kHzOutput() - */ -void DS3232RTC::enable32kHzOutput() -{ - if (_isRealTime) { - uint8_t value = readRegister(DS3232_STATUS); - value |= DS3232_BB32KHZ | DS3232_EN32KHZ; - writeRegister(DS3232_STATUS, value); - } -} - -/** - * \brief Disables the 32 kHz output on the DS3232 chip. - * - * \sa enable32kHzOutput() - */ -void DS3232RTC::disable32kHzOutput() -{ - if (_isRealTime) { - uint8_t value = readRegister(DS3232_STATUS); - value &= ~(DS3232_BB32KHZ | DS3232_EN32KHZ); - writeRegister(DS3232_STATUS, value); - } -} - -void DS3232RTC::initAlarms() -{ - uint8_t value = readRegister(DS3232_ALARM_MAGIC); - if (value != (0xB0 + ALARM_COUNT)) { - // This is the first time we have used this clock chip, - // so initialize all alarms to their default state. - RTCAlarm alarm; - alarm.hour = 6; // Default to 6am for alarms. - alarm.minute = 0; - alarm.flags = 0; - for (uint8_t index = 0; index < ALARM_COUNT; ++index) - writeAlarm(index, &alarm); - writeRegister(DS3232_ALARM_MAGIC, 0xB0 + ALARM_COUNT); - - // Also clear the rest of NVRAM so that it is in a known state. - // Otherwise we'll have whatever garbage was present at power-on. - _bus->startWrite(DS3232_I2C_ADDRESS); - _bus->write(DS3232_NVRAM); - for (uint8_t index = DS3232_NVRAM; index < DS3232_ALARMS; ++index) - _bus->write(0); - _bus->endWrite(); - } -} - -uint8_t DS3232RTC::readRegister(uint8_t reg) -{ - _bus->startWrite(DS3232_I2C_ADDRESS); - _bus->write(reg); - if (!_bus->startRead(DS3232_I2C_ADDRESS, 1)) - return 0; // RTC chip is not responding. - return _bus->read(); -} - -bool DS3232RTC::writeRegister(uint8_t reg, uint8_t value) -{ - _bus->startWrite(DS3232_I2C_ADDRESS); - _bus->write(reg); - _bus->write(value); - return _bus->endWrite(); -} - -#define DS3232_ALARM1_FLAGS (DS3232_ALARMS + 2) -#define DS3232_ALARM2_FLAGS (DS3232_ALARMS + DS3232_ALARM_SIZE + 2) - -void DS3232RTC::updateAlarmInterrupts() -{ - bool alarm1Enabled = ((readRegister(DS3232_ALARM1_FLAGS) & 0x01) != 0); - bool alarm2Enabled = ((readRegister(DS3232_ALARM2_FLAGS) & 0x01) != 0); - uint8_t value = readRegister(DS3232_CONTROL); - value |= DS3232_INTCN; - if (alarm1Enabled) - value |= DS3232_A1IE; - else - value &= ~DS3232_A1IE; - if (alarm2Enabled) - value |= DS3232_A2IE; - else - value &= ~DS3232_A2IE; - writeRegister(DS3232_CONTROL, value); -} diff --git a/libraries/RTC/DS3232RTC.h b/libraries/RTC/DS3232RTC.h deleted file mode 100644 index 40fcf246..00000000 --- a/libraries/RTC/DS3232RTC.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#ifndef DS3232RTC_h -#define DS3232RTC_h - -#include "RTC.h" - -class I2CMaster; - -class DS3232RTC : public RTC { -public: - DS3232RTC(I2CMaster &bus, uint8_t oneHzPin = 255); - - bool isRealTime() const { return _isRealTime; } - - bool hasUpdates(); - - void readTime(RTCTime *value); - void readDate(RTCDate *value); - - void writeTime(const RTCTime *value); - void writeDate(const RTCDate *value); - - void readAlarm(uint8_t alarmNum, RTCAlarm *value); - void writeAlarm(uint8_t alarmNum, const RTCAlarm *value); - - int byteCount() const; - uint8_t readByte(uint8_t offset); - void writeByte(uint8_t offset, uint8_t value); - - int readTemperature(); - - void enableAlarmInterrupts(); - void disableAlarmInterrupts(); - int firedAlarm(); - - void enable32kHzOutput(); - void disable32kHzOutput(); - -private: - I2CMaster *_bus; - uint8_t _oneHzPin; - bool prevOneHz; - bool _isRealTime; - bool alarmInterrupts; - - void initAlarms(); - - uint8_t readRegister(uint8_t reg); - bool writeRegister(uint8_t reg, uint8_t value); - - void updateAlarmInterrupts(); -}; - -#endif diff --git a/libraries/RTC/RTC.cpp b/libraries/RTC/RTC.cpp deleted file mode 100644 index 670078f1..00000000 --- a/libraries/RTC/RTC.cpp +++ /dev/null @@ -1,501 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#include "RTC.h" -#if defined(ARDUINO) && ARDUINO >= 100 -#include -#else -#include -#endif -#include -#include - -/** - * \class RTC RTC.h - * \brief Base class for realtime clock handlers. - * - * This class simplifies the process of reading and writing the time and - * date information in a realtime clock chip. The class also provides - * support for reading and writing information about alarms and other - * clock settings. - * - * It is intended that the application will instantiate a subclass of this - * class to handle the specific realtime clock chip in the system. The default - * implementation in RTC simulates a clock based on the value of millis(), - * with alarms and clock settings stored in main memory. - * - * Because the common DS1307 and DS3232 realtime clock chips use a - * 2-digit year, this class is also limited to dates between 2000 - * and 2099 inclusive. - * - * \sa RTCTime, RTCDate, RTCAlarm, DS1307RTC, DS3232RTC - */ - -/** - * \var RTC::ALARM_COUNT - * \brief Number of alarms that are supported by RTC::readAlarm() and RTC::writeAlarm(). - */ - -#define DEFAULT_BYTE_COUNT 43 // Default simulates DS1307 NVRAM size. - -#define MILLIS_PER_DAY 86400000UL -#define MILLIS_PER_SECOND 1000UL -#define MILLIS_PER_MINUTE 60000UL -#define MILLIS_PER_HOUR 3600000UL - -static uint8_t monthLengths[] = { - 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 -}; - -static unsigned int monthOffsets[] = { - 0, - 31, - 31 + 28, - 31 + 28 + 31, - 31 + 28 + 31 + 30, - 31 + 28 + 31 + 30 + 31, - 31 + 28 + 31 + 30 + 31 + 30, - 31 + 28 + 31 + 30 + 31 + 30 + 31, - 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31, - 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30, - 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31, - 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 -}; - -inline bool isLeapYear(unsigned int year) -{ - if ((year % 100) == 0) - return (year % 400) == 0; - else - return (year % 4) == 0; -} - -inline uint8_t monthLength(const RTCDate *date) -{ - if (date->month != 2 || !isLeapYear(date->year)) - return monthLengths[date->month - 1]; - else - return 29; -} - -/** - * \brief Constructs a new realtime clock handler. - * - * \sa hasUpdates() - */ -RTC::RTC() - : midnight(millis() - 9 * MILLIS_PER_HOUR) // Simulated clock starts at 9am - , nvram(0) -{ - // Start the simulated date at 1 Jan, 2000. - date.day = 1; - date.month = 1; - date.year = 2000; - - // Set all simulated alarms to 6am by default. - for (uint8_t index = 0; index < ALARM_COUNT; ++index) { - alarms[index].hour = 6; - alarms[index].minute = 0; - alarms[index].flags = 0; - } -} - -RTC::~RTC() -{ - if (nvram) - free(nvram); -} - -/** - * \brief Returns true if the realtime clock has updated since the last call to this function. - * - * The default implementation returns true, indicating that an update is - * always available to be read. - */ -bool RTC::hasUpdates() -{ - return true; -} - -/** - * \brief Reads the current time from the realtime clock into \a value. - * - * \sa writeTime(), readDate() - */ -void RTC::readTime(RTCTime *value) -{ - // Determine the number of seconds since the last midnight event. - unsigned long sinceMidnight = millis() - midnight; - if (sinceMidnight >= MILLIS_PER_DAY) { - // We have overflowed into the next day. Readjust midnight. - midnight += MILLIS_PER_DAY; - sinceMidnight -= MILLIS_PER_DAY; - - // Increment the simulated date. - adjustDays(&date, INCREMENT); - } - value->second = (uint8_t)(((sinceMidnight / MILLIS_PER_SECOND) % 60)); - value->minute = (uint8_t)(((sinceMidnight / MILLIS_PER_MINUTE) % 60)); - value->hour = (uint8_t)(sinceMidnight / MILLIS_PER_HOUR); -} - -/** - * \brief Reads the current date from the realtime clock into \a value. - * - * The time should be read first with readTime() as the default implementation - * only advances the date when the time is read and it crosses midnight. - * - * \sa writeDate(), readTime() - */ -void RTC::readDate(RTCDate *value) -{ - *value = date; -} - -/** - * \brief Updates the time in the realtime clock to match \a value. - * - * \sa readTime(), writeDate() - */ -void RTC::writeTime(const RTCTime *value) -{ - // Adjust the position of the last simulated midnight event. - unsigned long sinceMidnight = - value->second * MILLIS_PER_SECOND + - value->minute * MILLIS_PER_MINUTE + - value->hour * MILLIS_PER_HOUR; - midnight = millis() - sinceMidnight; -} - -/** - * \brief Updates the date in the realtime clock to match \a value. - * - * \sa readDate(), writeTime() - */ -void RTC::writeDate(const RTCDate *value) -{ - date = *value; -} - -/** - * \brief Reads the details of the alarm with index \a alarmNum into \a value. - * - * The \a alarmNum parameter must be between 0 and \ref ALARM_COUNT - 1. - * - * Alarm details are stored at the end of the realtime clock's non-volatile - * memory. - * - * \sa writeAlarm(), alarmCount() - */ -void RTC::readAlarm(uint8_t alarmNum, RTCAlarm *value) -{ - *value = alarms[alarmNum]; -} - -/** - * \brief Updates the details of the alarm with index \a alarmNum from \a value. - * - * The \a alarmNum parameter must be between 0 and \ref ALARM_COUNT - 1. - * - * Alarm details are stored at the end of the realtime clock's non-volatile - * memory. - * - * \sa readAlarm(), alarmCount() - */ -void RTC::writeAlarm(uint8_t alarmNum, const RTCAlarm *value) -{ - alarms[alarmNum] = *value; -} - -/** - * \brief Returns the number of bytes of non-volatile memory that can be - * used for storage of arbitrary settings, excluding storage used by alarms. - * - * \sa readByte(), writeByte() - */ -int RTC::byteCount() const -{ - return DEFAULT_BYTE_COUNT; -} - -/** - * \brief Reads the byte at \a offset within the realtime clock's non-volatile memory. - * - * The \a offset parameter must be between 0 and byteCount() - 1. - * - * \sa writeByte(), byteCount() - */ -uint8_t RTC::readByte(uint8_t offset) -{ - if (nvram) - return nvram[offset]; - else - return 0; -} - -/** - * \brief Writes \a value to \a offset within the realtime clock's non-volatile memory. - * - * The \a offset parameter must be between 0 and byteCount() - 1. - * - * \sa readByte(), byteCount() - */ -void RTC::writeByte(uint8_t offset, uint8_t value) -{ - if (nvram) { - nvram[offset] = value; - } else { - nvram = (uint8_t *)malloc(DEFAULT_BYTE_COUNT); - if (nvram) { - memset(nvram, 0, DEFAULT_BYTE_COUNT); - nvram[offset] = value; - } - } -} - -/** - * \var RTC::NO_TEMPERATURE - * \brief Value that is returned from readTemperature() if the realtime - * clock chip cannot determine the temperature. - */ - -/** - * \brief Reads the value of the temperature sensor and returns the - * temperature in quarters of a degree celcius. - * - * Returns the value NO_TEMPERATURE if the realtime clock chip cannot - * determine the temperature. - */ -int RTC::readTemperature() -{ - return NO_TEMPERATURE; -} - -/** - * \var RTC::INCREMENT - * \brief Increment the day, month, or year in a call to adjustDays(), adjustMonths(), or adjustYears(). - */ - -/** - * \var RTC::DECREMENT - * \brief Decrement the day, month, or year in a call to adjustDays(), adjustMonths(), or adjustYears(). - */ - -/** - * \var RTC::WRAP - * \brief Wrap around to the beginning of the current month/year rather than advance to the next one. - */ - -/** - * \brief Adjusts \a date up or down one day according to \a flags. - * - * \sa adjustMonths(), adjustYears() - */ -void RTC::adjustDays(RTCDate *date, uint8_t flags) -{ - if (flags & DECREMENT) { - --(date->day); - if (date->day == 0) { - if (!(flags & WRAP)) { - --(date->month); - if (date->month == 0) - date->month = 12; - } - date->day = monthLength(date); - } - } else { - ++(date->day); - if (date->day > monthLength(date)) { - if (!(flags & WRAP)) { - ++(date->month); - if (date->month == 13) - date->month = 1; - } - date->day = 1; - } - } -} - -/** - * \brief Adjusts \a date up or down one month according to \a flags. - * - * \sa adjustDays(), adjustYears() - */ -void RTC::adjustMonths(RTCDate *date, uint8_t flags) -{ - if (flags & DECREMENT) { - --(date->month); - if (date->month == 0) { - date->month = 12; - if (!(flags & WRAP) && date->year > 2000) - --(date->year); - } - } else { - ++(date->month); - if (date->month == 13) { - date->month = 1; - if (!(flags & WRAP) && date->year < 2099) - ++(date->year); - } - } - uint8_t len = monthLength(date); - if (date->day > len) - date->day = len; -} - -/** - * \brief Adjusts \a date up or down one year according to \a flags. - * - * \sa adjustDays(), adjustMonths() - */ -void RTC::adjustYears(RTCDate *date, uint8_t flags) -{ - if (flags & DECREMENT) { - --(date->year); - if (date->year < 2000) - date->year = 2000; - } else { - ++(date->year); - if (date->year > 2099) - date->year = 2099; - } - uint8_t len = monthLength(date); - if (date->day > len) - date->day = len; -} - -/** - * \enum RTC::DayOfWeek - * \brief Day of the week corresponding to a date. - * - * \sa dayOfWeek() - */ - -/** - * \brief Returns the day of the week corresponding to \a date. - * - * This function is only guaranteed to produce meaningful values - * for years between 2000 and 2099. - */ -RTC::DayOfWeek RTC::dayOfWeek(const RTCDate *date) -{ - // The +4 here adjusts for Jan 1, 2000 being a Saturday. - unsigned long daynum = date->day + 4; - daynum += monthOffsets[date->month - 1]; - if (date->month > 2 && isLeapYear(date->year)) - ++daynum; - daynum += 365UL * (date->year - 2000); - if (date->year > 2000) - daynum += ((date->year - 2001) / 4) + 1; - return (DayOfWeek)((daynum % 7) + 1); -} - -/** - * \class RTCTime RTC.h - * \brief Stores time information from a realtime clock chip. - * - * \sa RTCDate, RTCAlarm, RTC - */ - -/** - * \var RTCTime::hour - * \brief Hour of the day (0-23) - */ - -/** - * \var RTCTime::minute - * \brief Minute within the hour (0-59) - */ - -/** - * \var RTCTime::second - * \brief Second within the minute (0-59) - */ - -/** - * \class RTCDate RTC.h - * \brief Stores date information from a realtime clock chip. - * - * \sa RTCTime, RTCAlarm, RTC - */ - -/** - * \var RTCDate::year - * \brief Year (4-digit) - */ - -/** - * \var RTCDate::month - * \brief Month of the year (1-12) - */ - -/** - * \var RTCDate::day - * \brief Day of the month (1-31) - */ - -/** - * \class RTCAlarm RTC.h - * \brief Stores alarm information from a realtime clock chip. - * - * \sa RTCTime, RTCDate, RTC - */ - -/** - * \var RTCAlarm::day - * \brief Day of the month for the alarm if not zero. - * - * \note Currently this field only works with the DS3231RTC class. - */ - -/** - * \var RTCAlarm::dow - * \brief Day of the week for the alarm if not zero. - * - * \note Currently this field only works with the DS3231RTC class. - */ - -/** - * \var RTCAlarm::hour - * \brief Hour of the day for the alarm (0-23). - */ - -/** - * \var RTCAlarm::minute - * \brief Minute of the hour for the alarm (0-59). - */ - -/** - * \var RTCAlarm::second - * \brief Second of the minute for the alarm (0-59). - * - * \note Currently this field only works with the DS3231RTC class. - */ - -/** - * \var RTCAlarm::flags - * \brief Additional flags for the alarm. - * - * The least significant bit will be 0 if the alarm is disabled or - * 1 if the alarm is enabled. Other bits can be used by the application - * for any purpose. - */ diff --git a/libraries/RTC/RTC.h b/libraries/RTC/RTC.h deleted file mode 100644 index 7d18a057..00000000 --- a/libraries/RTC/RTC.h +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#ifndef RTC_h -#define RTC_h - -#include - -struct RTCTime -{ - uint8_t hour; - uint8_t minute; - uint8_t second; -}; - -struct RTCDate -{ - unsigned int year; - uint8_t month; - uint8_t day; -}; - -struct RTCAlarm -{ - uint8_t day; - uint8_t dow; - uint8_t hour; - uint8_t minute; - uint8_t second; - uint8_t flags; -}; - -class RTC -{ -public: - RTC(); - ~RTC(); - - enum DayOfWeek - { - Monday = 1, - Tuesday, - Wednesday, - Thursday, - Friday, - Saturday, - Sunday, - }; - - virtual bool hasUpdates(); - - virtual void readTime(RTCTime *value); - virtual void readDate(RTCDate *value); - - virtual void writeTime(const RTCTime *value); - virtual void writeDate(const RTCDate *value); - - static const uint8_t ALARM_COUNT = 4; - - virtual void readAlarm(uint8_t alarmNum, RTCAlarm *value); - virtual void writeAlarm(uint8_t alarmNum, const RTCAlarm *value); - - virtual int byteCount() const; - virtual uint8_t readByte(uint8_t offset); - virtual void writeByte(uint8_t offset, uint8_t value); - - static const int NO_TEMPERATURE = 32767; - - virtual int readTemperature(); - - // Flags for adjustDays(), adjustMonths(), and adjustYears(). - static const uint8_t INCREMENT = 0x0000; - static const uint8_t DECREMENT = 0x0001; - static const uint8_t WRAP = 0x0002; - - static void adjustDays(RTCDate *date, uint8_t flags); - static void adjustMonths(RTCDate *date, uint8_t flags); - static void adjustYears(RTCDate *date, uint8_t flags); - - static DayOfWeek dayOfWeek(const RTCDate *date); - -private: - unsigned long midnight; - RTCDate date; - RTCAlarm alarms[ALARM_COUNT]; - uint8_t *nvram; -}; - -#endif diff --git a/libraries/RTC/examples/AlarmClock/AlarmClock.ino b/libraries/RTC/examples/AlarmClock/AlarmClock.ino deleted file mode 100644 index 3eeca523..00000000 --- a/libraries/RTC/examples/AlarmClock/AlarmClock.ino +++ /dev/null @@ -1,332 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -// include the library code: -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "Clock.h" -#include "FrontScreen.h" -#include "SetAlarm.h" -#include "SetTime.h" -#include "SetDate.h" -#include "SetMelody.h" -#include "LowPowerMelody.h" - -// I/O pins that are used by this sketch. -#define RADIO 11 -#define BUZZER 12 -#define RTC_DATA A4 -#define RTC_CLOCK A5 -#define RTC_ONE_HZ A3 - -// Offsets of settings in the realtime clock's NVRAM. -#define SETTING_24HOUR 0 // 0: 12 hour, 1: 24 hour -#define SETTING_ALARM_TIMEOUT 1 // Timeout in minutes for the alarm -#define SETTING_SNOOZE 2 // 0: no snooze, 1: snooze -#define SETTING_MELODY 3 // Melody to play for the alarm - -// Initialize the LCD -LCD lcd; - -// Activate the realtime clock chip. -SoftI2C bus(RTC_DATA, RTC_CLOCK); -Clock rtc(bus, RTC_ONE_HZ); - -// Melody to play when the alarm sounds. -int defaultMelodyNotes[5] = {NOTE_C6, NOTE_C6, NOTE_C6, NOTE_C6, NOTE_REST}; -byte defaultMelodyLengths[5] = {8, 8, 8, 8, 2}; -LowPowerMelody alarmMelody(BUZZER); - -uint8_t prevHour = 24; -bool is24HourClock = false; -RTCAlarm nextAlarm; -bool isRadioPlaying = false; -bool sawFirstClick = false; -unsigned long firstClickTime; - -// Create the main form and its fields. -Form mainForm(lcd); -FrontScreenField frontScreen(mainForm); -SetAlarm alarm1(mainForm, "Alarm 1", 0); -SetAlarm alarm2(mainForm, "Alarm 2", 1); -SetAlarm alarm3(mainForm, "Alarm 3", 2); -SetAlarm alarm4(mainForm, "Alarm 4", 3); -IntField alarmTimeout(mainForm, "Alarm timeout", 2, 10, 1, 2, " minutes"); -BoolField snooze(mainForm, "Snooze alarm", "On", "Off", false); -SetMelody alarmSound(mainForm, "Alarm sound"); -SetTime setTime(mainForm, "Set current time"); -SetDate setDate(mainForm, "Set current date"); -BoolField hourMode(mainForm, "Hour display", "24 hour clock", "12 hour clock", false); -BoolField radioActive(mainForm, "Radio", "On", "Off", false); - -void setup() { - // Reduce power consumption on I/O pins we don't need. - unusedPin(A1); - unusedPin(A2); - unusedPin(0); - unusedPin(1); - unusedPin(2); - unusedPin(10); - unusedPin(13); - - // Turn off peripherals we don't need. - power_spi_disable(); - power_usart0_disable(); - power_twi_disable(); - power_timer1_disable(); - - // Enable the screen saver. - lcd.setScreenSaverMode(LCD::BacklightOnSelect); - lcd.enableScreenSaver(3); - - // Initialize the alarm melody. - alarmMelody.setMelody(defaultMelodyNotes, defaultMelodyLengths, sizeof(defaultMelodyLengths)); - alarmMelody.stop(); // Force Timer2 to be disabled. - - // Read the clock settings from the realtime clock's NVRAM. - is24HourClock = rtc.readByte(SETTING_24HOUR) != 0; - hourMode.setValue(is24HourClock); - frontScreen.set24HourMode(is24HourClock); - alarmTimeout.setValue(rtc.readByte(SETTING_ALARM_TIMEOUT)); - alarmMelody.setLoopDuration(60000UL * alarmTimeout.value()); - snooze.setValue(rtc.readByte(SETTING_SNOOZE) != 0); - alarmSound.setValue(rtc.readByte(SETTING_MELODY)); - alarmSound.updateMelody(); - - // Set the initial time and date and find the next alarm to be triggered. - RTCTime time; - RTCDate date; - rtc.readTime(&time); - rtc.readDate(&date); - frontScreen.setTime(time); - frontScreen.setDate(date); - findNextAlarm(); - - // The radio is turned on or off with a relay connected to an output pin. - // Configure the pin and turn the radio off initially. - digitalWrite(RADIO, LOW); - pinMode(RADIO, OUTPUT); - - // Show the main form for the first time. - mainForm.show(); -} - -void loop() { - // Update the time and date every second based on the 1 Hz RTC output. - if (rtc.hasUpdates() || prevHour >= 24) { - RTCTime time; - rtc.readTime(&time); - frontScreen.setTime(time); - if (time.hour < prevHour) { - // Time has wrapped around, or date update has been forced. - RTCDate date; - rtc.readDate(&date); - frontScreen.setDate(date); - setDate.updateCurrentDate(); - } - prevHour = time.hour; - setTime.updateCurrentTime(); - - // Trigger an alarm if necessary. - if (time.second == 0 && (nextAlarm.flags & 0x01) && !alarmMelody.isPlaying()) { - if (time.hour == nextAlarm.hour && time.minute == nextAlarm.minute) { - // We have a match on time; now check the day of week. - RTCDate date = frontScreen.date(); - RTC::DayOfWeek day = RTC::dayOfWeek(&date); - SetAlarm::Days matchDays = SetAlarm::days(&nextAlarm); - bool matched; - if (matchDays == SetAlarm::AnyDay) - matched = true; - else if (matchDays == SetAlarm::MondayToFriday && - day >= RTC::Monday && day <= RTC::Friday) - matched = true; - else if (matchDays == SetAlarm::SaturdayAndSunday && - day >= RTC::Saturday && day <= RTC::Sunday) - matched = true; - else - matched = false; - findNextAlarm(); - if (matched) - alarmMelody.play(); - } - } - } - - // Dispatch button events to the main form. - int event = lcd.getButton(); - if (mainForm.dispatch(event) == FORM_CHANGED) { - if (hourMode.isCurrent()) { - is24HourClock = hourMode.value(); - frontScreen.set24HourMode(is24HourClock); - rtc.writeByte(SETTING_24HOUR, (byte)is24HourClock); - } else if (alarmTimeout.isCurrent()) { - rtc.writeByte(SETTING_ALARM_TIMEOUT, (byte)alarmTimeout.value()); - alarmMelody.setLoopDuration(60000UL * alarmTimeout.value()); - } else if (snooze.isCurrent()) { - rtc.writeByte(SETTING_SNOOZE, (byte)snooze.value()); - } else if (alarmSound.isCurrent()) { - rtc.writeByte(SETTING_MELODY, (byte)alarmSound.value()); - } else if (radioActive.isCurrent()) { - isRadioPlaying = radioActive.value(); - if (isRadioPlaying) - digitalWrite(RADIO, HIGH); - else - digitalWrite(RADIO, LOW); - frontScreen.setRadioOn(isRadioPlaying); - } - prevHour = 24; // Force an update of the main screen. - findNextAlarm(); // Update the time of the next alarm event. - } else if (event == LCD_BUTTON_SELECT) { - // Pressing select will quickly return to the front screen. - mainForm.setCurrentField(&frontScreen); - } - - // If the alarm is playing and a button was pressed, then turn it off. - if (alarmMelody.isPlaying()) { - if (event > 0) - alarmMelody.stop(); - alarmMelody.run(); - } else { - // No alarm playing, so put the device to sleep to save power. - sleepFor(SLEEP_15_MS); - } - - // Select once means radio off, double-click select means radio on. - if (event == LCD_BUTTON_SELECT) { - unsigned long ms = millis(); - if (sawFirstClick && (ms - firstClickTime) > 500) - sawFirstClick = false; - if (sawFirstClick) { - sawFirstClick = false; - turnRadioOn(); - } else { - firstClickTime = ms; - sawFirstClick = true; - turnRadioOff(); - } - } -} - -inline int timeToAlarm(const RTCTime ¤tTime, const RTCAlarm &alarm) -{ - int mins1 = currentTime.hour * 60 + currentTime.minute; - int mins2 = alarm.hour * 60 + alarm.minute; - if (mins1 <= mins2) - return mins2 - mins1; - else - return 24 * 60 + mins2 - mins1; -} - -// Add 9 minutes to an alarm to get its snooze time. -RTCAlarm adjustForSnooze(const RTCAlarm &alarm) -{ - if (!(alarm.flags & 0x01)) - return alarm; - RTCAlarm snooze; - snooze.hour = alarm.hour; - snooze.minute = alarm.minute + 9; - if (snooze.minute >= 60) { - snooze.hour = (snooze.hour + 1) % 24; - snooze.minute %= 60; - } - snooze.flags = alarm.flags; - return snooze; -} - -// Find the time of the next alarm to be triggered. -void findNextAlarm() -{ - // Get the current time plus 1 minute, to avoid repeating the same alarm. - RTCTime currentTime = frontScreen.time(); - if (++(currentTime.minute) >= 60) { - currentTime.minute = 0; - currentTime.hour = (currentTime.hour + 1) % 24; - } - - // Process each of the alarms to find the closest. - nextAlarm.hour = 0; - nextAlarm.minute = 0; - nextAlarm.flags = 0; - findNextAlarm(currentTime, alarm1.value()); - findNextAlarm(currentTime, alarm2.value()); - findNextAlarm(currentTime, alarm3.value()); - findNextAlarm(currentTime, alarm4.value()); - if (snooze.value()) { - findNextAlarm(currentTime, adjustForSnooze(alarm1.value())); - findNextAlarm(currentTime, adjustForSnooze(alarm2.value())); - findNextAlarm(currentTime, adjustForSnooze(alarm3.value())); - findNextAlarm(currentTime, adjustForSnooze(alarm4.value())); - } - - // Set the alarm indicator on the front screen. - if (nextAlarm.flags & 0x01) { - if (snooze.value()) - frontScreen.setAlarmMode(FrontScreenField::Snooze); - else - frontScreen.setAlarmMode(FrontScreenField::AlarmOn); - } else { - frontScreen.setAlarmMode(FrontScreenField::AlarmOff); - } -} -void findNextAlarm(const RTCTime ¤tTime, const RTCAlarm &alarm) -{ - if (!(alarm.flags & 0x01)) - return; // Alarm is disabled. - if (!(nextAlarm.flags & 0x01)) { - // First valid alarm. - nextAlarm = alarm; - return; - } - int timeToNext = timeToAlarm(currentTime, nextAlarm); - int timeToCurr = timeToAlarm(currentTime, alarm); - if (timeToNext > timeToCurr) { - // Found an alarm that is closer in time. - nextAlarm = alarm; - } else if (timeToNext == timeToCurr) { - // Same time; combine the day indicators. - SetAlarm::combineDays(&nextAlarm, &alarm); - } -} - -void turnRadioOn() -{ - isRadioPlaying = true; - digitalWrite(RADIO, HIGH); - radioActive.setValue(true); - frontScreen.setRadioOn(true); -} - -void turnRadioOff() -{ - isRadioPlaying = false; - digitalWrite(RADIO, LOW); - radioActive.setValue(false); - frontScreen.setRadioOn(false); -} diff --git a/libraries/RTC/examples/AlarmClock/Clock.h b/libraries/RTC/examples/AlarmClock/Clock.h deleted file mode 100644 index 814493da..00000000 --- a/libraries/RTC/examples/AlarmClock/Clock.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#ifndef Clock_h -#define Clock_h - -#include -#include - -// Select the specific type of realtime clock chip to use. -typedef DS1307RTC Clock; -//typedef DS3232RTC Clock; - -extern Clock rtc; - -#endif diff --git a/libraries/RTC/examples/AlarmClock/FrontScreen.cpp b/libraries/RTC/examples/AlarmClock/FrontScreen.cpp deleted file mode 100644 index ea583e4b..00000000 --- a/libraries/RTC/examples/AlarmClock/FrontScreen.cpp +++ /dev/null @@ -1,230 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#include "FrontScreen.h" -#if defined(ARDUINO) && ARDUINO >= 100 -#include -#else -#include -#endif - -// Special characters for indicators. -#define IND_RADIO_ON 0 -#define IND_ALARM_SNOOZE 5 -#define IND_ALARM_ACTIVE1 6 -#define IND_ALARM_ACTIVE2 7 - -FrontScreenField::FrontScreenField(Form &form) - : Field(form, "") - , _alarmMode(FrontScreenField::AlarmOff) - , _hourMode(false) - , _radioOn(false) -{ - _date.day = 1; - _date.month = 1; - _date.year = 2012; - _time.hour = 9; - _time.minute = 0; - _time.second = 0; - registerIndicators(); -} - -FrontScreenField::~FrontScreenField() -{ -} - -void FrontScreenField::enterField(bool reverse) -{ - updateDate(); - updateTime(); - updateIndicators(); -} - -const char *days[] = { - "Mon, ", "Tue, ", "Wed, ", "Thu, ", "Fri, ", "Sat, ", "Sun, " -}; - -const char *months[] = { - " Jan ", " Feb ", " Mar ", " Apr ", " May ", " Jun ", - " Jul ", " Aug ", " Sep ", " Oct ", " Nov ", " Dec " -}; - -void FrontScreenField::setDate(const RTCDate &date) -{ - if (date.day != _date.day || date.month != _date.month || - date.year != _date.year) { - _date = date; - if (isCurrent()) - updateDate(); - } -} - -void FrontScreenField::setTime(const RTCTime &time) -{ - if (time.hour != _time.hour || time.minute != _time.minute || - time.second != _time.second) { - _time = time; - if (isCurrent()) - updateTime(); - } -} - -static uint8_t alarmActive1[8] = { - B00100, - B01001, - B10010, - B00000, - B10010, - B01001, - B00100, - B00000 -}; -static uint8_t alarmActive2[8] = { - B11000, - B10100, - B10011, - B10011, - B10011, - B10100, - B11000, - B00000 -}; -static uint8_t alarmSnooze[8] = { - B11110, - B00100, - B01000, - B11110, - B00000, - B00000, - B00000, - B00000 -}; -static uint8_t radioIndicator[8] = { - B11111, - B10101, - B01110, - B00100, - B00100, - B00100, - B00100, - B00000 -}; - -void FrontScreenField::setAlarmMode(AlarmMode mode) -{ - if (_alarmMode != mode) { - _alarmMode = mode; - if (isCurrent()) - updateIndicators(); - } -} - -void FrontScreenField::set24HourMode(bool value) -{ - if (_hourMode != value) { - _hourMode = value; - if (isCurrent()) - updateTime(); - } -} - -void FrontScreenField::setRadioOn(bool value) -{ - if (_radioOn != value) { - _radioOn = value; - if (isCurrent()) - updateIndicators(); - } -} - -void FrontScreenField::updateDate() -{ - lcd()->setCursor(0, 0); - lcd()->write(days[RTC::dayOfWeek(&_date) - 1]); - if (_date.day < 10) { - lcd()->write('0' + _date.day); - } else { - lcd()->write('0' + _date.day / 10); - lcd()->write('0' + _date.day % 10); - } - lcd()->print(months[_date.month - 1]); - lcd()->print(_date.year); - lcd()->write(' '); -} - -void FrontScreenField::updateTime() -{ - lcd()->setCursor(0, 1); - bool pm; - if (_hourMode) { - lcd()->write('0' + _time.hour / 10); - lcd()->write('0' + _time.hour % 10); - pm = false; - } else if (_time.hour == 0 || _time.hour == 12) { - lcd()->write('1'); - lcd()->write('2'); - pm = (_time.hour == 12); - } else if (_time.hour < 12) { - lcd()->write('0' + _time.hour / 10); - lcd()->write('0' + _time.hour % 10); - pm = false; - } else { - int hour = _time.hour - 12; - lcd()->write('0' + hour / 10); - lcd()->write('0' + hour % 10); - pm = true; - } - lcd()->write(':'); - lcd()->write('0' + _time.minute / 10); - lcd()->write('0' + _time.minute % 10); - lcd()->write(':'); - lcd()->write('0' + _time.second / 10); - lcd()->write('0' + _time.second % 10); - if (!_hourMode) - lcd()->print(pm ? "pm" : "am"); -} - -void FrontScreenField::updateIndicators() -{ - lcd()->setCursor(13, 1); - lcd()->print(" "); - int col = 16; - if (_radioOn) { - --col; - lcd()->setCursor(col, 1); - lcd()->write((uint8_t)IND_RADIO_ON); - } - if (_alarmMode != AlarmOff) { - col -= 2; - lcd()->setCursor(col, 1); - lcd()->write(_alarmMode == Snooze ? IND_ALARM_SNOOZE : IND_ALARM_ACTIVE1); - lcd()->write(IND_ALARM_ACTIVE2); - } -} - -void FrontScreenField::registerIndicators() -{ - lcd()->createChar(IND_RADIO_ON, radioIndicator); - lcd()->createChar(IND_ALARM_SNOOZE, alarmSnooze); - lcd()->createChar(IND_ALARM_ACTIVE1, alarmActive1); - lcd()->createChar(IND_ALARM_ACTIVE2, alarmActive2); -} diff --git a/libraries/RTC/examples/AlarmClock/FrontScreen.h b/libraries/RTC/examples/AlarmClock/FrontScreen.h deleted file mode 100644 index 12cf5646..00000000 --- a/libraries/RTC/examples/AlarmClock/FrontScreen.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#ifndef FrontScreen_h -#define FrontScreen_h - -#include -#include - -class FrontScreenField : public Field -{ -public: - explicit FrontScreenField(Form &form); - ~FrontScreenField(); - - void enterField(bool reverse); - - RTCDate date() const { return _date; } - void setDate(const RTCDate &date); - - RTCTime time() const { return _time; } - void setTime(const RTCTime &time); - - enum AlarmMode - { - AlarmOff, - AlarmOn, - Snooze - }; - - AlarmMode isAlarmMode() const { return _alarmMode; } - void setAlarmMode(AlarmMode mode); - - bool is24HourMode() const { return _hourMode; } - void set24HourMode(bool value); - - bool isRadioOn() const { return _radioOn; } - void setRadioOn(bool value); - -private: - RTCDate _date; - RTCTime _time; - AlarmMode _alarmMode; - bool _hourMode; - bool _radioOn; - - void updateDate(); - void updateTime(); - void updateIndicators(); - - void registerIndicators(); -}; - -#endif diff --git a/libraries/RTC/examples/AlarmClock/LowPowerMelody.cpp b/libraries/RTC/examples/AlarmClock/LowPowerMelody.cpp deleted file mode 100644 index 492db727..00000000 --- a/libraries/RTC/examples/AlarmClock/LowPowerMelody.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#include "LowPowerMelody.h" -#include - -extern void findNextAlarm(); -extern void turnRadioOn(); -extern void turnRadioOff(); - -bool LowPowerMelody::isPlaying() const -{ - if (radioMode) - return radioAlarmActive; - else - return Melody::isPlaying(); -} - -void LowPowerMelody::play() -{ - if (radioMode) { - turnRadioOn(); - radioAlarmActive = true; - return; - } - - // Turn on Timer2. - power_timer2_enable(); - - // Start the melody playing. - Melody::play(); -} - -void LowPowerMelody::playOnce() -{ - if (radioMode) - return; - - // Turn on Timer2. - power_timer2_enable(); - - // Start the melody playing. - Melody::playOnce(); -} - -void LowPowerMelody::stop() -{ - if (radioMode) { - turnRadioOff(); - radioAlarmActive = false; - return; - } - - // Stop the melody playing. - Melody::stop(); - - // Turn off Timer2. - power_timer2_disable(); - - // Find the next alarm to be triggered. - findNextAlarm(); -} diff --git a/libraries/RTC/examples/AlarmClock/LowPowerMelody.h b/libraries/RTC/examples/AlarmClock/LowPowerMelody.h deleted file mode 100644 index 4583382d..00000000 --- a/libraries/RTC/examples/AlarmClock/LowPowerMelody.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#ifndef LowPowerMelody_h -#define LowPowerMelody_h - -#include - -class LowPowerMelody : public Melody { -public: - LowPowerMelody(uint8_t pin) - : Melody(pin), radioMode(false), radioAlarmActive(false) {} - - bool isPlaying() const; - void play(); - void playOnce(); - void stop(); - - bool isRadioMode() const { return radioMode; } - void setRadioMode(bool mode) { radioMode = mode; } - -private: - bool radioMode; - bool radioAlarmActive; -}; - -#endif diff --git a/libraries/RTC/examples/AlarmClock/SetAlarm.cpp b/libraries/RTC/examples/AlarmClock/SetAlarm.cpp deleted file mode 100644 index bddee885..00000000 --- a/libraries/RTC/examples/AlarmClock/SetAlarm.cpp +++ /dev/null @@ -1,238 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#include "SetAlarm.h" -#include "Clock.h" - -#define EDIT_ENABLED 0 -#define EDIT_HOUR 1 -#define EDIT_MINUTE_TENS 2 -#define EDIT_MINUTE 3 -#define EDIT_DAYS 4 - -extern bool is24HourClock; - -SetAlarm::SetAlarm(Form &form, const String &label, uint8_t alarmNum) - : Field(form, label) - , _alarmNum(alarmNum) -{ - RTCAlarm alarm; - rtc.readAlarm(_alarmNum, &_value); -} - -int SetAlarm::dispatch(int event) -{ - RTCAlarm newValue; - if (event == LCD_BUTTON_UP) { - newValue = _value; - if (editField == EDIT_HOUR) { - newValue.hour = (newValue.hour + 1) % 24; - } else if (editField == EDIT_MINUTE_TENS) { - newValue.minute = (newValue.minute + 10) % 60; - } else if (editField == EDIT_MINUTE) { - newValue.minute = (newValue.minute + 1) % 60; - } else if (editField == EDIT_ENABLED) { - newValue.flags ^= 0x01; - if (newValue.flags & 0x01) - editField = EDIT_HOUR; - setValue(newValue); - return FORM_CHANGED; - } else if (editField == EDIT_DAYS) { - Days d = days(); - switch (d) { - case AnyDay: d = SaturdayAndSunday; break; - case MondayToFriday: d = AnyDay; break; - case SaturdayAndSunday: d = MondayToFriday; break; - } - setDays(d); - return FORM_CHANGED; - } - setValue(newValue); - return FORM_CHANGED; - } else if (event == LCD_BUTTON_DOWN) { - newValue = _value; - if (editField == EDIT_HOUR) { - newValue.hour = (newValue.hour + 23) % 24; - } else if (editField == EDIT_MINUTE_TENS) { - newValue.minute = (newValue.minute + 50) % 60; - } else if (editField == EDIT_MINUTE) { - newValue.minute = (newValue.minute + 59) % 60; - } else if (editField == EDIT_ENABLED) { - newValue.flags ^= 0x01; - if (newValue.flags & 0x01) - editField = EDIT_HOUR; - setValue(newValue); - return FORM_CHANGED; - } else if (editField == EDIT_DAYS) { - Days d = days(); - switch (d) { - case AnyDay: d = MondayToFriday; break; - case MondayToFriday: d = SaturdayAndSunday; break; - case SaturdayAndSunday: d = AnyDay; break; - } - setDays(d); - return FORM_CHANGED; - } - setValue(newValue); - return FORM_CHANGED; - } else if (event == LCD_BUTTON_LEFT) { - if (editField != EDIT_ENABLED) { - --editField; - printAlarm(); - return 0; - } - } else if (event == LCD_BUTTON_RIGHT) { - if (isEnabled() && editField != EDIT_DAYS) { - ++editField; - printAlarm(); - return 0; - } - } - return -1; -} - -void SetAlarm::enterField(bool reverse) -{ - Field::enterField(reverse); - if (isEnabled()) { - if (reverse) - editField = EDIT_DAYS; - else - editField = EDIT_ENABLED; - } else { - editField = EDIT_ENABLED; - } - printAlarm(); - lcd()->cursor(); -} - -void SetAlarm::exitField() -{ - lcd()->noCursor(); - Field::exitField(); -} - -void SetAlarm::setValue(const RTCAlarm &value) -{ - _value = value; - rtc.writeAlarm(_alarmNum, &_value); - if (isCurrent()) - printAlarm(); -} - -SetAlarm::Days SetAlarm::days() const -{ - return days(&_value); -} - -void SetAlarm::setDays(Days days) -{ - _value.flags &= 0xE1; - _value.flags |= (((uint8_t)days) << 1); - rtc.writeAlarm(_alarmNum, &_value); - if (isCurrent()) - printAlarm(); -} - -SetAlarm::Days SetAlarm::days(const RTCAlarm *alarm) -{ - // 4 bits are allocated for day indicators, to allow for later expansion. - uint8_t d = (alarm->flags >> 1) & 0x0F; - if (d > SaturdayAndSunday) - d = AnyDay; - return (Days)d; -} - -// Combine the day flags for two alarms; e.g., if one is Mon-Fri and -// the other is Sat,Sun, then the result is AnyDay. -void SetAlarm::combineDays(RTCAlarm *alarm1, const RTCAlarm *alarm2) -{ - uint8_t d1 = (alarm1->flags >> 1) & 0x0F; - if (d1 > SaturdayAndSunday) - d1 = AnyDay; - uint8_t d2 = (alarm2->flags >> 1) & 0x0F; - if (d2 > SaturdayAndSunday) - d2 = AnyDay; - if (d1 != d2) - d1 = AnyDay; - alarm1->flags &= 0xE1; - alarm1->flags |= (((uint8_t)d1) << 1); -} - -static const char *daysShort[] = {" Mo-Su", " Mo-Fr", " Sa,Su"}; -static const char *daysLong[] = {" Any day", " Mon-Fri", " Sat,Sun"}; - -void SetAlarm::printAlarm() -{ - lcd()->setCursor(0, 1); - int hour = _value.hour; - int minute = _value.minute; - int timeCol = 3; - int dayCol; - bool pm; - if (isEnabled()) { - lcd()->print("On "); - } else { - lcd()->print("Off "); - lcd()->setCursor(0, 1); - return; - } - if (is24HourClock) { - lcd()->write('0' + hour / 10); - lcd()->write('0' + hour % 10); - pm = false; - } else if (hour == 0 || hour == 12) { - lcd()->write('1'); - lcd()->write('2'); - pm = (hour == 12); - } else if (hour < 12) { - lcd()->write('0' + hour / 10); - lcd()->write('0' + hour % 10); - pm = false; - } else { - hour -= 12; - lcd()->write('0' + hour / 10); - lcd()->write('0' + hour % 10); - pm = true; - } - lcd()->write(':'); - lcd()->write('0' + minute / 10); - lcd()->write('0' + minute % 10); - if (is24HourClock) { - dayCol = timeCol + 6; - lcd()->print(daysLong[days()]); - } else { - lcd()->print(pm ? "pm" : "am"); - lcd()->print(daysShort[days()]); - dayCol = timeCol + 8; - } - if (editField == EDIT_ENABLED) - lcd()->setCursor(0, 1); - else if (editField == EDIT_HOUR) - lcd()->setCursor(timeCol + 1, 1); - else if (editField == EDIT_MINUTE_TENS) - lcd()->setCursor(timeCol + 3, 1); - else if (editField == EDIT_MINUTE) - lcd()->setCursor(timeCol + 4, 1); - else if (editField == EDIT_DAYS) - lcd()->setCursor(dayCol, 1); -} diff --git a/libraries/RTC/examples/AlarmClock/SetAlarm.h b/libraries/RTC/examples/AlarmClock/SetAlarm.h deleted file mode 100644 index 51ad1202..00000000 --- a/libraries/RTC/examples/AlarmClock/SetAlarm.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#ifndef SetAlarm_h -#define SetAlarm_h - -#include "Field.h" -#include - -class SetAlarm : public Field { -public: - SetAlarm(Form &form, const String &label, uint8_t alarmNum); - - int dispatch(int event); - - void enterField(bool reverse); - void exitField(); - - RTCAlarm value() const { return _value; } - void setValue(const RTCAlarm &value); - - enum Days - { - AnyDay, - MondayToFriday, - SaturdayAndSunday - }; - - Days days() const; - void setDays(Days days); - - static Days days(const RTCAlarm *alarm); - - static void combineDays(RTCAlarm *alarm1, const RTCAlarm *alarm2); - -private: - uint8_t _alarmNum; - RTCAlarm _value; - uint8_t editField; - - bool isEnabled() const { return (_value.flags & 0x01) != 0; } - - void printAlarm(); -}; - -#endif diff --git a/libraries/RTC/examples/AlarmClock/SetDate.cpp b/libraries/RTC/examples/AlarmClock/SetDate.cpp deleted file mode 100644 index 54214e43..00000000 --- a/libraries/RTC/examples/AlarmClock/SetDate.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#include "SetDate.h" -#include "Clock.h" - -#define EDIT_DAY 0 -#define EDIT_MONTH 1 -#define EDIT_YEAR 2 - -SetDate::SetDate(Form &form, const String &label) - : Field(form, label) - , editField(EDIT_DAY) -{ - _value.day = 1; - _value.month = 1; - _value.year = 2012; -} - -int SetDate::dispatch(int event) -{ - RTCDate newValue; - if (event == LCD_BUTTON_UP) { - newValue = _value; - if (editField == EDIT_DAY) - RTC::adjustDays(&newValue, RTC::INCREMENT | RTC::WRAP); - else if (editField == EDIT_MONTH) - RTC::adjustMonths(&newValue, RTC::INCREMENT | RTC::WRAP); - else if (editField == EDIT_YEAR) - RTC::adjustYears(&newValue, RTC::INCREMENT | RTC::WRAP); - _value = newValue; - printDate(); - rtc.writeDate(&_value); - return FORM_CHANGED; - } else if (event == LCD_BUTTON_DOWN) { - newValue = _value; - if (editField == EDIT_DAY) - RTC::adjustDays(&newValue, RTC::DECREMENT | RTC::WRAP); - else if (editField == EDIT_MONTH) - RTC::adjustMonths(&newValue, RTC::DECREMENT | RTC::WRAP); - else if (editField == EDIT_YEAR) - RTC::adjustYears(&newValue, RTC::DECREMENT | RTC::WRAP); - _value = newValue; - printDate(); - rtc.writeDate(&_value); - return FORM_CHANGED; - } else if (event == LCD_BUTTON_LEFT) { - if (editField != EDIT_DAY) { - --editField; - printDate(); - return 0; - } - } else if (event == LCD_BUTTON_RIGHT) { - if (editField != EDIT_YEAR) { - ++editField; - printDate(); - return 0; - } - } - return -1; -} - -void SetDate::enterField(bool reverse) -{ - rtc.readDate(&_value); - Field::enterField(reverse); - if (reverse) - editField = EDIT_YEAR; - else - editField = EDIT_DAY; - printDate(); - lcd()->cursor(); -} - -void SetDate::exitField() -{ - lcd()->noCursor(); - Field::exitField(); -} - -void SetDate::setValue(const RTCDate &value) -{ - _value = value; - if (isCurrent()) - printDate(); -} - -void SetDate::updateCurrentDate() -{ - if (isCurrent()) { - rtc.readDate(&_value); - printDate(); - } -} - -extern const char *days[]; // Table of day names; e.g. "Mon, ". -extern const char *months[]; // Table of month names; e.g. " Jan ". - -void SetDate::printDate() -{ - lcd()->setCursor(0, 1); - int dayCol; - int monthCol; - int yearCol; - int col = 0; - lcd()->write(days[RTC::dayOfWeek(&_value) - 1]); - col += 5; - dayCol = col; - if (_value.day < 10) { - lcd()->write('0' + _value.day); - ++col; - } else { - lcd()->write('0' + _value.day / 10); - lcd()->write('0' + _value.day % 10); - col += 2; - } - monthCol = col + 1; - lcd()->print(months[_value.month - 1]); - col += 5; - yearCol = col; - lcd()->write('0' + _value.year / 1000); - lcd()->write('0' + (_value.year / 100) % 10); - lcd()->write('0' + (_value.year / 10) % 10); - lcd()->write('0' + _value.year % 10); - lcd()->write(' '); - if (editField == EDIT_DAY) - lcd()->setCursor(dayCol, 1); - else if (editField == EDIT_MONTH) - lcd()->setCursor(monthCol, 1); - else - lcd()->setCursor(yearCol, 1); -} diff --git a/libraries/RTC/examples/AlarmClock/SetDate.h b/libraries/RTC/examples/AlarmClock/SetDate.h deleted file mode 100644 index 177c6b8a..00000000 --- a/libraries/RTC/examples/AlarmClock/SetDate.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#ifndef SetDate_h -#define SetDate_h - -#include "Field.h" -#include - -class SetDate : public Field { -public: - SetDate(Form &form, const String &label); - - int dispatch(int event); - - void enterField(bool reverse); - void exitField(); - - RTCDate value() const { return _value; } - void setValue(const RTCDate &value); - - void updateCurrentDate(); - -private: - RTCDate _value; - uint8_t editField; - - void printDate(); -}; - -#endif diff --git a/libraries/RTC/examples/AlarmClock/SetMelody.cpp b/libraries/RTC/examples/AlarmClock/SetMelody.cpp deleted file mode 100644 index 33068593..00000000 --- a/libraries/RTC/examples/AlarmClock/SetMelody.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#include "SetMelody.h" -#include "LowPowerMelody.h" -#if defined(ARDUINO) && ARDUINO >= 100 -#include -#else -#include -#endif - -extern LowPowerMelody alarmMelody; -extern int defaultMelodyNotes[5]; -extern byte defaultMelodyLengths[5]; - -static int haircutNotes[] = { - NOTE_C4, NOTE_G3, NOTE_G3, NOTE_A3, NOTE_G3, - NOTE_REST, NOTE_B3, NOTE_C4, NOTE_REST -}; -static byte haircutLengths[] = {4, 8, 8, 4, 4, 4, 4, 4, 2}; - -static int sosNotes[] = { - NOTE_C6, NOTE_C6, NOTE_C6, NOTE_REST, - NOTE_C6, NOTE_C6, NOTE_C6, NOTE_REST, - NOTE_C6, NOTE_C6, NOTE_C6, NOTE_REST -}; -static byte sosLengths[] = {8, 8, 8, 8, 4, 4, 4, 8, 8, 8, 8, 2}; - -static const char item_FourBeeps[] PROGMEM = "Four beeps"; -static const char item_Haircut[] PROGMEM = "Shave 'n haircut"; -static const char item_SOS[] PROGMEM = "S.O.S."; -static const char item_Radio[] PROGMEM = "Radio"; -static ListItem const melodyNames[] PROGMEM = { - item_FourBeeps, - item_Haircut, - item_SOS, - item_Radio, - 0 -}; - -SetMelody::SetMelody(Form &form, const String &label) - : ListField(form, label, melodyNames) - , needsPlay(false) -{ -} - -int SetMelody::dispatch(int event) -{ - int result = ListField::dispatch(event); - if (result == FORM_CHANGED) { - updateMelody(); - needsPlay = true; // Play when we see the button release event. - } else if (needsPlay && event < 0) { - needsPlay = false; - alarmMelody.playOnce(); - } - return result; -} - -void SetMelody::updateMelody() -{ - switch (value()) { - case 0: default: - alarmMelody.setMelody(defaultMelodyNotes, defaultMelodyLengths, sizeof(defaultMelodyLengths)); - alarmMelody.setRadioMode(false); - break; - case 1: - alarmMelody.setMelody(haircutNotes, haircutLengths, sizeof(haircutLengths)); - alarmMelody.setRadioMode(false); - break; - case 2: - alarmMelody.setMelody(sosNotes, sosLengths, sizeof(sosLengths)); - alarmMelody.setRadioMode(false); - break; - case 3: - alarmMelody.setMelody(defaultMelodyNotes, defaultMelodyLengths, sizeof(defaultMelodyLengths)); - alarmMelody.setRadioMode(true); - break; - } -} diff --git a/libraries/RTC/examples/AlarmClock/SetMelody.h b/libraries/RTC/examples/AlarmClock/SetMelody.h deleted file mode 100644 index f2e49f43..00000000 --- a/libraries/RTC/examples/AlarmClock/SetMelody.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#ifndef SetMelody_h -#define SetMelody_h - -#include - -class SetMelody : public ListField { -public: - SetMelody(Form &form, const String &label); - - int dispatch(int event); - - void updateMelody(); - -private: - bool needsPlay; -}; - -#endif diff --git a/libraries/RTC/examples/AlarmClock/SetTime.cpp b/libraries/RTC/examples/AlarmClock/SetTime.cpp deleted file mode 100644 index 92ca0ec8..00000000 --- a/libraries/RTC/examples/AlarmClock/SetTime.cpp +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#include "SetTime.h" -#include "Clock.h" - -#define EDIT_HOUR 0 -#define EDIT_MINUTE_TENS 1 -#define EDIT_MINUTE 2 - -extern bool is24HourClock; - -SetTime::SetTime(Form &form, const String &label) - : Field(form, label) - , editField(EDIT_HOUR) -{ - _value.hour = 0; - _value.minute = 0; - _value.second = 0; -} - -int SetTime::dispatch(int event) -{ - RTCTime newValue; - if (event == LCD_BUTTON_UP) { - newValue = _value; - if (editField == EDIT_HOUR) { - newValue.hour = (newValue.hour + 1) % 24; - } else if (editField == EDIT_MINUTE_TENS) { - newValue.minute = (newValue.minute + 10) % 60; - } else if (editField == EDIT_MINUTE) { - newValue.minute = (newValue.minute + 1) % 60; - } - newValue.second = 0; - setValue(newValue); - return FORM_CHANGED; - } else if (event == LCD_BUTTON_DOWN) { - newValue = _value; - if (editField == EDIT_HOUR) { - newValue.hour = (newValue.hour + 23) % 24; - } else if (editField == EDIT_MINUTE_TENS) { - newValue.minute = (newValue.minute + 50) % 60; - } else if (editField == EDIT_MINUTE) { - newValue.minute = (newValue.minute + 59) % 60; - } - newValue.second = 0; - setValue(newValue); - return FORM_CHANGED; - } else if (event == LCD_BUTTON_LEFT) { - if (editField != EDIT_HOUR) { - --editField; - printTime(); - return 0; - } - } else if (event == LCD_BUTTON_RIGHT) { - if (editField != EDIT_MINUTE) { - ++editField; - printTime(); - return 0; - } - } - return -1; -} - -void SetTime::enterField(bool reverse) -{ - Field::enterField(reverse); - rtc.readTime(&_value); - if (reverse) - editField = EDIT_MINUTE; - else - editField = EDIT_HOUR; - printTime(); - lcd()->cursor(); -} - -void SetTime::exitField() -{ - lcd()->noCursor(); - Field::exitField(); -} - -void SetTime::setValue(const RTCTime &value) -{ - _value = value; - rtc.writeTime(&_value); - if (isCurrent()) - printTime(); -} - -void SetTime::updateCurrentTime() -{ - if (isCurrent()) { - RTCTime time; - rtc.readTime(&time); - if (time.hour != _value.hour || time.minute != _value.minute) { - _value = time; - printTime(); - } - } -} - -void SetTime::printTime() -{ - lcd()->setCursor(0, 1); - int hour = _value.hour; - int minute = _value.minute; - int timeCol = 0; - bool pm; - if (is24HourClock) { - lcd()->write('0' + hour / 10); - lcd()->write('0' + hour % 10); - pm = false; - } else if (hour == 0 || hour == 12) { - lcd()->write('1'); - lcd()->write('2'); - pm = (hour == 12); - } else if (hour < 12) { - lcd()->write('0' + hour / 10); - lcd()->write('0' + hour % 10); - pm = false; - } else { - hour -= 12; - lcd()->write('0' + hour / 10); - lcd()->write('0' + hour % 10); - pm = true; - } - lcd()->write(':'); - lcd()->write('0' + minute / 10); - lcd()->write('0' + minute % 10); - if (!is24HourClock) - lcd()->print(pm ? "pm" : "am"); - if (editField == EDIT_HOUR) - lcd()->setCursor(timeCol + 1, 1); - else if (editField == EDIT_MINUTE_TENS) - lcd()->setCursor(timeCol + 3, 1); - else if (editField == EDIT_MINUTE) - lcd()->setCursor(timeCol + 4, 1); -} diff --git a/libraries/RTC/examples/AlarmClock/SetTime.h b/libraries/RTC/examples/AlarmClock/SetTime.h deleted file mode 100644 index 5dffe31a..00000000 --- a/libraries/RTC/examples/AlarmClock/SetTime.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#ifndef SetTime_h -#define SetTime_h - -#include "Field.h" -#include - -class SetTime : public Field { -public: - SetTime(Form &form, const String &label); - - int dispatch(int event); - - void enterField(bool reverse); - void exitField(); - - RTCTime value() const { return _value; } - void setValue(const RTCTime &value); - - void updateCurrentTime(); - -protected: - RTCTime _value; - uint8_t editField; - - void printTime(); -}; - -#endif diff --git a/libraries/RTC/examples/AlarmClock/alarm_circuit.fig b/libraries/RTC/examples/AlarmClock/alarm_circuit.fig deleted file mode 100644 index f23bd985..00000000 --- a/libraries/RTC/examples/AlarmClock/alarm_circuit.fig +++ /dev/null @@ -1,641 +0,0 @@ -#FIG 3.2 Produced by xfig version 3.2.5b -Landscape -Center -Metric -A4 -100.00 -Single --2 -1200 2 -5 1 0 1 0 7 50 -1 -1 0.000 0 0 0 0 11475.000 2700.000 11430 2700 11475 2655 11520 2700 -6 11430 3510 11520 3960 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 11475 3865 11475 3960 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 11475 3600 11435 3627 11515 3681 11435 3735 11515 3789 11435 3843 - 11475 3870 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 11475 3510 11475 3605 --6 -6 11385 4500 11565 4770 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 11460 4770 11490 4770 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 11425 4725 11525 4725 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 11385 4680 11565 4680 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 11475 4500 11475 4680 --6 -6 3960 1125 4140 1440 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4050 1260 4050 1125 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4050 1305 4050 1440 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 3960 1260 4140 1260 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 3960 1305 4140 1305 --6 -6 4005 1620 4095 1710 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 4050 1665 30 30 4050 1665 4050 1695 --6 -6 10800 2520 11250 2745 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 11025 2655 11060 2585 10990 2585 11025 2655 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10895 2700 10800 2700 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 11160 2700 11133 2660 11079 2740 11025 2660 10971 2740 10917 2660 - 10890 2700 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 11250 2700 11155 2700 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 11025 2520 11025 2610 --6 -6 10485 2925 10665 3195 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10560 3195 10590 3195 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10525 3150 10625 3150 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10485 3105 10665 3105 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10575 2925 10575 3105 --6 -6 11655 2655 11745 2745 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 11700 2700 30 30 11700 2700 11700 2730 --6 -6 10530 2655 10620 2745 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 10575 2700 30 30 10575 2700 10575 2730 --6 -6 9000 5580 9450 5670 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 9095 5625 9000 5625 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 9360 5625 9333 5585 9279 5665 9225 5585 9171 5665 9117 5585 - 9090 5625 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 9450 5625 9355 5625 --6 -6 8325 5580 8775 5670 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 8420 5625 8325 5625 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 8685 5625 8658 5585 8604 5665 8550 5585 8496 5665 8442 5585 - 8415 5625 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 8775 5625 8680 5625 --6 -6 9675 5580 10125 5670 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 9770 5625 9675 5625 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 10035 5625 10008 5585 9954 5665 9900 5585 9846 5665 9792 5585 - 9765 5625 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10125 5625 10030 5625 --6 -6 10350 5580 10800 5670 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10445 5625 10350 5625 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 10710 5625 10683 5585 10629 5665 10575 5585 10521 5665 10467 5585 - 10440 5625 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10800 5625 10705 5625 --6 -6 10845 5850 11070 6390 -1 3 0 1 0 -1 0 0 -1 0.000 1 1.5708 11025 6255 38 38 11025 6255 11025 6217 -1 3 0 1 0 -1 0 0 -1 0.000 1 1.5708 11025 5985 38 38 11025 5985 11025 5947 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 11025 6300 11025 6390 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 11025 5940 11025 5850 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10935 6120 10845 6120 -2 1 0 1 0 -1 0 0 -1 0.000 0 1 -1 0 0 2 - 10935 6255 10935 5985 -2 1 0 1 0 -1 0 0 -1 0.000 0 1 -1 0 0 2 - 10845 6165 10845 6075 --6 -6 10935 6345 11115 6615 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 11010 6615 11040 6615 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10975 6570 11075 6570 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10935 6525 11115 6525 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 11025 6345 11025 6525 --6 -6 9360 5850 9585 6390 -1 3 0 1 0 -1 0 0 -1 0.000 1 1.5708 9540 6255 38 38 9540 6255 9540 6217 -1 3 0 1 0 -1 0 0 -1 0.000 1 1.5708 9540 5985 38 38 9540 5985 9540 5947 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 9540 6300 9540 6390 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 9540 5940 9540 5850 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 9450 6120 9360 6120 -2 1 0 1 0 -1 0 0 -1 0.000 0 1 -1 0 0 2 - 9450 6255 9450 5985 -2 1 0 1 0 -1 0 0 -1 0.000 0 1 -1 0 0 2 - 9360 6165 9360 6075 --6 -6 8730 5850 8955 6390 -1 3 0 1 0 -1 0 0 -1 0.000 1 1.5708 8910 6255 38 38 8910 6255 8910 6217 -1 3 0 1 0 -1 0 0 -1 0.000 1 1.5708 8910 5985 38 38 8910 5985 8910 5947 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 8910 6300 8910 6390 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 8910 5940 8910 5850 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 8820 6120 8730 6120 -2 1 0 1 0 -1 0 0 -1 0.000 0 1 -1 0 0 2 - 8820 6255 8820 5985 -2 1 0 1 0 -1 0 0 -1 0.000 0 1 -1 0 0 2 - 8730 6165 8730 6075 --6 -6 8820 6345 9000 6615 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 8895 6615 8925 6615 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 8860 6570 8960 6570 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 8820 6525 9000 6525 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 8910 6345 8910 6525 --6 -6 9450 6345 9630 6615 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 9525 6615 9555 6615 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 9490 6570 9590 6570 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 9450 6525 9630 6525 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 9540 6345 9540 6525 --6 -6 10035 5850 10260 6390 -1 3 0 1 0 -1 0 0 -1 0.000 1 1.5708 10215 6255 38 38 10215 6255 10215 6217 -1 3 0 1 0 -1 0 0 -1 0.000 1 1.5708 10215 5985 38 38 10215 5985 10215 5947 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10215 6300 10215 6390 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10215 5940 10215 5850 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10125 6120 10035 6120 -2 1 0 1 0 -1 0 0 -1 0.000 0 1 -1 0 0 2 - 10125 6255 10125 5985 -2 1 0 1 0 -1 0 0 -1 0.000 0 1 -1 0 0 2 - 10035 6165 10035 6075 --6 -6 10125 6345 10305 6615 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10200 6615 10230 6615 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10165 6570 10265 6570 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10125 6525 10305 6525 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10215 6345 10215 6525 --6 -6 8550 4905 9000 4995 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 8645 4950 8550 4950 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 8910 4950 8883 4910 8829 4990 8775 4910 8721 4990 8667 4910 - 8640 4950 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 9000 4950 8905 4950 --6 -6 8055 5850 8280 6390 -1 3 0 1 0 -1 0 0 -1 0.000 1 1.5708 8235 6255 38 38 8235 6255 8235 6217 -1 3 0 1 0 -1 0 0 -1 0.000 1 1.5708 8235 5985 38 38 8235 5985 8235 5947 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 8235 6300 8235 6390 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 8235 5940 8235 5850 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 8145 6120 8055 6120 -2 1 0 1 0 -1 0 0 -1 0.000 0 1 -1 0 0 2 - 8145 6255 8145 5985 -2 1 0 1 0 -1 0 0 -1 0.000 0 1 -1 0 0 2 - 8055 6165 8055 6075 --6 -6 8145 6345 8325 6615 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 8220 6615 8250 6615 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 8185 6570 8285 6570 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 8145 6525 8325 6525 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 8235 6345 8235 6525 --6 -6 8190 4905 8280 4995 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 8235 4950 30 30 8235 4950 8235 4980 --6 -6 8190 5580 8280 5670 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 8235 5625 30 30 8235 5625 8235 5655 --6 -6 8865 5580 8955 5670 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 8910 5625 30 30 8910 5625 8910 5655 --6 -6 9495 5580 9585 5670 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 9540 5625 30 30 9540 5625 9540 5655 --6 -6 10170 5580 10260 5670 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 10215 5625 30 30 10215 5625 10215 5655 --6 -6 2610 1485 3150 1710 -1 3 0 1 0 -1 0 0 -1 0.000 1 0.0000 2745 1665 38 38 2745 1665 2783 1665 -1 3 0 1 0 -1 0 0 -1 0.000 1 0.0000 3015 1665 38 38 3015 1665 3053 1665 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2700 1665 2610 1665 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 3060 1665 3150 1665 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2880 1575 2880 1485 -2 1 0 1 0 -1 0 0 -1 0.000 0 1 -1 0 0 2 - 2745 1575 3015 1575 -2 1 0 1 0 -1 0 0 -1 0.000 0 1 -1 0 0 2 - 2835 1485 2925 1485 --6 -6 2160 1665 2340 1935 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2235 1935 2265 1935 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2200 1890 2300 1890 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2160 1845 2340 1845 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2250 1665 2250 1845 --6 -6 450 2250 4185 5625 -5 1 0 1 0 7 50 -1 -1 0.000 0 0 0 0 3825.000 3375.000 3825 3330 3870 3375 3825 3420 -5 1 0 1 0 7 50 -1 -1 0.000 0 0 0 0 3825.000 3690.000 3825 3645 3870 3690 3825 3735 -5 1 0 1 0 7 50 -1 -1 0.000 0 0 0 0 3825.000 4050.000 3825 4005 3870 4050 3825 4095 -6 1665 2925 1935 3375 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 1800 3240 1800 3375 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 1710 3240 1890 3240 -2 2 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 5 - 1690 3105 1910 3105 1910 3195 1690 3195 1690 3105 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 1710 3060 1890 3060 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 1800 3060 1800 2925 --6 -6 1665 3600 1935 4140 -2 1 0 1 0 -1 0 0 0 0.000 0 0 -1 0 0 2 - 1800 3915 1800 4140 -2 2 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 5 - 1710 3870 1890 3870 1890 3915 1710 3915 1710 3870 -2 1 0 1 0 -1 0 0 0 0.000 0 0 -1 0 0 2 - 1665 3825 1935 3825 -2 1 0 1 0 -1 0 0 0 0.000 0 0 -1 0 0 2 - 1800 3825 1800 3600 --6 -6 1755 4095 1845 4185 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 1800 4140 30 30 1800 4140 1800 4170 --6 -6 2655 4635 2970 4815 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2835 4725 2970 4725 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2790 4725 2655 4725 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2835 4635 2835 4815 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 2790 4635 2790 4815 --6 -6 1710 4860 1890 5130 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 1785 5130 1815 5130 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 1750 5085 1850 5085 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 1710 5040 1890 5040 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 1800 4860 1800 5040 --6 -6 3780 2880 3870 2970 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 3825 2925 30 30 3825 2925 3825 2955 --6 -6 1755 4680 1845 4770 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 1800 4725 30 30 1800 4725 1800 4755 --6 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 1800 3375 2250 3375 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 1800 2925 2250 2925 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 1800 3600 2250 3600 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 1800 4140 2250 4140 -2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 - 2250 2700 3375 2700 3375 4275 2250 4275 2250 2700 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 3 - 1 1 1.00 60.00 120.00 - 3375 2925 3825 2925 3825 2475 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 3825 2925 3825 3330 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 3825 3420 3825 3645 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 3825 3735 3825 4005 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 3825 4095 3825 4725 2970 4725 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 1800 4140 1800 4860 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 2700 4725 1800 4725 -2 2 1 1 0 7 50 -1 -1 3.000 0 0 -1 0 0 5 - 450 2250 4185 2250 4185 5625 450 5625 450 2250 -4 0 0 50 -1 0 12 0.0000 4 135 105 2115 2880 1\001 -4 0 0 50 -1 0 12 0.0000 4 135 105 2115 3330 2\001 -4 0 0 50 -1 0 12 0.0000 4 135 900 630 3195 32.768kHz\001 -4 0 0 50 -1 0 12 0.0000 4 135 390 1080 3870 3.3V\001 -4 0 0 50 -1 0 12 0.0000 4 165 810 855 4095 (CR1225)\001 -4 0 0 50 -1 0 12 0.0000 4 135 105 2115 4095 4\001 -4 0 0 50 -1 0 12 0.0000 4 135 105 2115 3555 3\001 -4 0 0 50 -1 0 12 0.0000 4 135 240 3690 2430 5V\001 -4 0 0 50 -1 0 12 0.0000 4 135 240 2295 2970 X1\001 -4 0 0 50 -1 0 12 0.0000 4 135 240 2295 3420 X2\001 -4 0 0 50 -1 0 12 0.0000 4 135 420 2295 3645 VBat\001 -4 0 0 50 -1 0 12 0.0000 4 135 405 2295 4185 GND\001 -4 0 0 50 -1 0 12 0.0000 4 135 405 2925 2970 VCC\001 -4 0 0 50 -1 0 12 0.0000 4 135 105 3420 3645 6\001 -4 0 0 50 -1 0 12 0.0000 4 135 105 3420 3330 7\001 -4 0 0 50 -1 0 12 0.0000 4 135 105 3420 2880 8\001 -4 0 0 50 -1 0 12 0.0000 4 135 375 2925 4095 SDA\001 -4 0 0 50 -1 0 12 0.0000 4 135 360 2925 3735 SCL\001 -4 0 0 50 -1 0 12 0.0000 4 165 420 2880 3420 SQW\001 -4 0 0 50 -1 0 12 0.0000 4 135 525 2565 4995 100nF\001 -4 0 0 50 -1 0 12 0.0000 4 135 105 3420 4005 5\001 -4 0 0 50 -1 0 12 0.0000 4 180 2790 585 5490 SparkFun Realtime Clock Module\001 -4 0 0 50 -1 0 12 0.0000 4 135 660 2520 2565 DS1307\001 --6 -6 6615 5625 6885 6075 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6750 5940 6750 6075 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6660 5940 6840 5940 -2 2 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 5 - 6640 5805 6860 5805 6860 5895 6640 5895 6640 5805 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6660 5760 6840 5760 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6750 5760 6750 5625 --6 -6 6660 6075 6840 6345 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6735 6345 6765 6345 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6700 6300 6800 6300 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6660 6255 6840 6255 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 6750 6075 6750 6255 --6 -6 11025 4050 11520 4500 -1 3 0 1 0 -1 0 0 -1 0.000 1 0.0000 11295 4275 186 186 11295 4275 11340 4455 -2 1 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 4 - 11395 4420 11350 4330 11305 4375 11395 4420 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 11250 4275 11475 4500 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 11250 4275 11475 4050 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 11250 4140 11250 4410 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 11250 4275 11025 4275 --6 -6 10125 4230 10575 4320 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10220 4275 10125 4275 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 10485 4275 10458 4235 10404 4315 10350 4235 10296 4315 10242 4235 - 10215 4275 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 10575 4275 10480 4275 --6 -6 4680 5985 4770 6435 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4725 6340 4725 6435 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 4725 6075 4685 6102 4765 6156 4685 6210 4765 6264 4685 6318 - 4725 6345 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4725 5985 4725 6080 --6 -6 5400 7425 5580 7695 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5475 7695 5505 7695 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5440 7650 5540 7650 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5400 7605 5580 7605 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5490 7425 5490 7605 --6 -6 5175 6525 5625 7065 -1 3 0 1 0 -1 0 0 -1 0.000 1 6.2832 5410 6795 191 191 5410 6795 5601 6795 -2 3 0 1 0 -1 0 0 20 0.000 0 0 0 0 0 4 - 5410 6795 5455 6815 5455 6775 5410 6795 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 5400 6885 5490 6885 5490 7065 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 5400 6795 5490 6795 5490 6885 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 5400 6705 5490 6705 5490 6525 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 5355 6660 5355 6930 5175 6930 -2 1 0 1 0 -1 0 0 -1 0.000 0 1 -1 0 0 2 - 5400 6860 5400 6915 -2 1 0 1 0 -1 0 0 -1 0.000 0 1 -1 0 0 2 - 5400 6766 5400 6827 -2 1 0 1 0 -1 0 0 -1 0.000 0 1 -1 0 0 2 - 5400 6674 5400 6733 --6 -6 4680 6885 4770 6975 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 4725 6930 30 30 4725 6930 4725 6960 --6 -6 5445 7380 5535 7470 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 5490 7425 30 30 5490 7425 5490 7455 --6 -6 4860 7380 5310 7470 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4955 7425 4860 7425 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 5220 7425 5193 7385 5139 7465 5085 7385 5031 7465 4977 7385 - 4950 7425 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5310 7425 5215 7425 --6 -2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 - 4500 1350 7425 1350 7425 5400 4500 5400 4500 1350 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 8775 2250 8775 2475 7425 2475 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 9000 2250 9000 2700 7425 2700 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 9225 2250 9225 2925 7425 2925 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 9450 2250 9450 3150 7425 3150 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 9675 2250 9675 3375 7425 3375 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 9900 2250 9900 3600 7425 3600 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 10125 2248 10125 3825 7425 3823 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 10350 2250 10350 4050 7425 4050 -2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 - 8550 1350 11925 1350 11925 2250 8550 2250 8550 1350 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 4 - 1 1 1.00 60.00 120.00 - 11700 2250 11700 2700 12375 2700 12375 2025 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 11475 2250 11475 3510 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 10170 4275 7425 4275 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 4050 1665 4050 1395 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 - 1 1 1.00 60.00 120.00 - 4050 1170 4050 900 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 11025 2565 11025 2250 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 10800 2700 10575 2700 10575 2925 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 11250 2700 11430 2700 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 11520 2700 11700 2700 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 10575 2700 10575 2250 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 7425 4950 8235 4950 8235 5895 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 8730 5625 9045 5625 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 9450 5625 9675 5625 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 10125 5625 10350 5625 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 10755 5625 11025 5625 11025 5850 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 8910 5850 8910 5625 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 9540 5895 9540 5625 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 10215 5895 10215 5625 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 8595 4950 8190 4950 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 3 - 1 1 1.00 60.00 120.00 - 8955 4950 9225 4950 9225 4725 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 8370 5625 8235 5625 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 3375 3375 4500 3375 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 3375 3690 4500 3690 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 3375 4050 4500 4050 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 4500 1665 3150 1665 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 2610 1665 2250 1665 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 6750 5670 6750 5400 -2 2 1 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 5 - 7740 1125 13050 1125 13050 7425 7740 7425 7740 1125 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 11475 3960 11475 4050 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 10575 4275 11115 4275 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 - 4725 5985 4725 5400 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 4725 6435 4725 6930 5220 6930 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 4905 7425 4725 7425 4725 6885 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 5310 7425 5490 7425 5490 7020 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 - 1 1 1.00 60.00 120.00 - 5490 6075 5490 5895 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 - 1 1 1.00 60.00 120.00 - 5490 6075 5985 6075 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 - 1 1 1.00 60.00 120.00 - 5490 6525 5985 6525 -4 0 0 50 -1 0 12 0.0000 4 135 450 4590 1710 Reset\001 -4 0 0 50 -1 0 12 4.7124 4 135 405 8730 1710 GND\001 -4 0 0 50 -1 0 12 4.7124 4 135 240 8955 1890 5V\001 -4 0 0 50 -1 0 12 0.0000 4 135 240 6975 2745 5V\001 -4 0 0 50 -1 0 12 0.0000 4 135 405 6930 2520 GND\001 -4 0 0 50 -1 0 12 0.0000 4 135 240 6975 2970 D9\001 -4 0 0 50 -1 0 12 0.0000 4 135 240 6975 3195 D8\001 -4 0 0 50 -1 0 12 0.0000 4 135 240 6975 3420 D7\001 -4 0 0 50 -1 0 12 0.0000 4 135 240 6975 3645 D6\001 -4 0 0 50 -1 0 12 0.0000 4 135 240 6975 3870 D5\001 -4 0 0 50 -1 0 12 0.0000 4 135 240 6975 4095 D4\001 -4 0 0 50 -1 0 12 4.7124 4 135 120 9180 2025 E\001 -4 0 0 50 -1 0 12 4.7124 4 135 240 9405 1935 RS\001 -4 0 0 50 -1 0 12 0.0000 4 135 1545 9495 1665 16x2 LCD Module\001 -4 0 0 50 -1 0 12 4.7124 4 135 240 9630 1935 D7\001 -4 0 0 50 -1 0 12 4.7124 4 135 240 9855 1935 D6\001 -4 0 0 50 -1 0 12 4.7124 4 135 240 10080 1935 D5\001 -4 0 0 50 -1 0 12 4.7124 4 135 240 10305 1935 D4\001 -4 0 0 50 -1 0 12 0.0000 4 135 240 12285 1935 5V\001 -4 0 0 50 -1 0 12 0.0000 4 135 240 6975 4320 D3\001 -4 0 0 50 -1 0 12 0.0000 4 135 240 3960 765 5V\001 -4 0 0 50 -1 0 12 0.0000 4 135 525 3330 1350 100nF\001 -4 0 0 50 -1 0 12 4.7124 4 135 315 11430 1845 BL-\001 -4 0 0 50 -1 0 12 4.7124 4 135 360 11655 1845 BL+\001 -4 0 0 50 -1 0 12 0.0000 4 135 345 10845 2925 10K\001 -4 0 0 50 -1 0 12 4.7124 4 135 405 10980 1800 Cont\001 -4 0 0 50 -1 0 12 4.7124 4 135 375 10530 1845 R/W\001 -4 0 0 50 -1 0 12 0.0000 4 135 450 8370 5490 330R\001 -4 0 0 50 -1 0 12 0.0000 4 135 450 9000 5490 620R\001 -4 0 0 50 -1 0 12 0.0000 4 135 240 9765 5490 1K\001 -4 0 0 50 -1 0 12 0.0000 4 135 345 10395 5490 3K3\001 -4 0 0 50 -1 0 12 4.7124 4 135 480 9495 6750 Down\001 -4 0 0 50 -1 0 12 4.7124 4 135 330 10125 6750 Left\001 -4 0 0 50 -1 0 12 4.7124 4 180 240 8820 6750 Up\001 -4 0 0 50 -1 0 12 0.0000 4 180 375 11250 6075 Stop\001 -4 0 0 50 -1 0 12 0.0000 4 135 495 11250 6300 Alarm\001 -4 0 0 50 -1 0 12 0.0000 4 135 240 9135 4635 5V\001 -4 0 0 50 -1 0 12 0.0000 4 135 240 8640 4815 2K\001 -4 0 0 50 -1 0 12 4.7124 4 180 465 8145 6750 Right\001 -4 0 0 50 -1 0 12 0.0000 4 135 1590 11250 5175 If 1/4 watt resistors:\001 -4 0 0 50 -1 0 12 0.0000 4 135 1110 11250 5400 2K = 1K + 1K\001 -4 0 0 50 -1 0 12 0.0000 4 135 1740 11250 5625 620R = 470R + 150R\001 -4 0 0 50 -1 0 12 0.0000 4 135 240 6975 4995 A0\001 -4 0 0 50 -1 0 12 0.0000 4 135 240 4545 3420 A3\001 -4 0 0 50 -1 0 12 0.0000 4 165 1410 4545 3735 A5 (I2C CLOCK)\001 -4 0 0 50 -1 0 12 0.0000 4 165 1275 4545 4095 A4 (I2C DATA)\001 -4 0 0 50 -1 0 12 0.0000 4 135 345 6570 5310 D12\001 -4 0 0 50 -1 0 12 0.0000 4 135 2370 10440 7290 Freetronics 16x2 LCD Shield\001 -4 0 0 50 -1 0 12 0.0000 4 135 450 6975 5805 Piezo\001 -4 0 0 50 -1 0 12 0.0000 4 135 570 6975 6030 Buzzer\001 -4 0 0 50 -1 0 12 0.0000 4 135 390 10170 4545 4.7K\001 -4 0 0 50 -1 0 12 0.0000 4 135 585 11610 4320 BC548\001 -4 0 0 50 -1 0 12 0.0000 4 180 1215 11610 3735 33R (adjust for\001 -4 0 0 50 -1 0 12 0.0000 4 180 840 11745 3960 LED type)\001 -4 0 0 50 -1 0 12 0.0000 4 135 675 5535 2655 Arduino\001 -4 0 0 50 -1 0 12 0.0000 4 135 345 4680 5265 D11\001 -4 0 0 50 -1 0 12 0.0000 4 135 735 5220 5805 RadioV+\001 -4 0 0 50 -1 0 12 0.0000 4 135 765 5580 6345 To Radio\001 -4 0 0 50 -1 0 12 0.0000 4 135 345 4905 7695 10K\001 -4 0 0 50 -1 0 12 0.0000 4 135 240 4320 6255 1K\001 -4 0 0 50 -1 0 12 0.0000 4 105 105 6075 6120 +\001 -4 0 0 50 -1 0 12 0.0000 4 15 60 6075 6570 -\001 -4 0 0 50 -1 0 12 0.0000 4 135 660 5715 6930 2N7000\001 diff --git a/libraries/RTC/examples/AlarmClock/alarm_circuit.pdf b/libraries/RTC/examples/AlarmClock/alarm_circuit.pdf deleted file mode 100644 index c57a422d..00000000 Binary files a/libraries/RTC/examples/AlarmClock/alarm_circuit.pdf and /dev/null differ diff --git a/libraries/RTC/examples/AlarmClock/alarm_circuit.png b/libraries/RTC/examples/AlarmClock/alarm_circuit.png deleted file mode 100644 index 1a277032..00000000 Binary files a/libraries/RTC/examples/AlarmClock/alarm_circuit.png and /dev/null differ diff --git a/libraries/RTC/examples/AlarmClock/alarm_clock.jpg b/libraries/RTC/examples/AlarmClock/alarm_clock.jpg deleted file mode 100644 index 721c7174..00000000 Binary files a/libraries/RTC/examples/AlarmClock/alarm_clock.jpg and /dev/null differ diff --git a/libraries/RTC/examples/AlarmClock/clock_shield.jpg b/libraries/RTC/examples/AlarmClock/clock_shield.jpg deleted file mode 100644 index 0d4673d4..00000000 Binary files a/libraries/RTC/examples/AlarmClock/clock_shield.jpg and /dev/null differ diff --git a/libraries/RTC/examples/AlarmClock/kitten_minimal.jpg b/libraries/RTC/examples/AlarmClock/kitten_minimal.jpg deleted file mode 100644 index 1c3fff74..00000000 Binary files a/libraries/RTC/examples/AlarmClock/kitten_minimal.jpg and /dev/null differ diff --git a/libraries/RTC/examples/AlarmClock/radio_controller.fig b/libraries/RTC/examples/AlarmClock/radio_controller.fig deleted file mode 100644 index 5530a1b1..00000000 --- a/libraries/RTC/examples/AlarmClock/radio_controller.fig +++ /dev/null @@ -1,88 +0,0 @@ -#FIG 3.2 Produced by xfig version 3.2.5b -Landscape -Center -Metric -A4 -100.00 -Single --2 -1200 2 -6 4455 2655 4545 3105 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4500 3010 4500 3105 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 4500 2745 4460 2772 4540 2826 4460 2880 4540 2934 4460 2988 - 4500 3015 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4500 2655 4500 2750 --6 -6 5175 4095 5355 4365 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5250 4365 5280 4365 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5215 4320 5315 4320 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5175 4275 5355 4275 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5265 4095 5265 4275 --6 -6 4950 3195 5400 3735 -1 3 0 1 0 -1 0 0 -1 0.000 1 0.0000 5185 3465 191 191 5185 3465 5376 3465 -2 3 0 1 0 -1 0 0 20 0.000 0 0 0 0 0 4 - 5185 3465 5230 3485 5230 3445 5185 3465 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 5175 3555 5265 3555 5265 3735 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 5175 3465 5265 3465 5265 3555 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 5175 3375 5265 3375 5265 3195 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 3 - 5130 3330 5130 3600 4950 3600 -2 1 0 1 0 -1 0 0 -1 0.000 0 1 -1 0 0 2 - 5175 3530 5175 3585 -2 1 0 1 0 -1 0 0 -1 0.000 0 1 -1 0 0 2 - 5175 3436 5175 3497 -2 1 0 1 0 -1 0 0 -1 0.000 0 1 -1 0 0 2 - 5175 3344 5175 3403 --6 -6 4455 3555 4545 3645 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 4500 3600 30 30 4500 3600 4500 3630 --6 -6 5220 4050 5310 4140 -1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 5265 4095 30 30 5265 4095 5265 4125 --6 -6 4635 4050 5085 4140 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 4730 4095 4635 4095 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 7 - 4995 4095 4968 4055 4914 4135 4860 4055 4806 4135 4752 4055 - 4725 4095 -2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2 - 5085 4095 4990 4095 --6 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 - 1 1 1.00 60.00 120.00 - 4500 2655 4500 2250 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 4500 3105 4500 3600 4995 3600 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 4680 4095 4500 4095 4500 3555 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3 - 5085 4095 5265 4095 5265 3690 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 - 1 1 1.00 60.00 120.00 - 5265 2745 5265 2250 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 - 1 1 1.00 60.00 120.00 - 5265 2745 5760 2745 -2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 - 1 1 1.00 60.00 120.00 - 5265 3195 5760 3195 -4 0 0 50 -1 0 12 0.0000 4 135 765 5355 3015 To Radio\001 -4 0 0 50 -1 0 12 0.0000 4 135 345 4680 4365 10K\001 -4 0 0 50 -1 0 12 0.0000 4 135 240 4095 2925 1K\001 -4 0 0 50 -1 0 12 0.0000 4 105 105 5850 2790 +\001 -4 0 0 50 -1 0 12 0.0000 4 15 60 5850 3240 -\001 -4 0 0 50 -1 0 12 0.0000 4 135 660 5490 3600 2N7000\001 -4 0 0 50 -1 0 12 0.0000 4 135 345 4365 2160 D11\001 -4 0 0 50 -1 0 12 0.0000 4 135 735 4995 2160 RadioV+\001 diff --git a/libraries/RTC/examples/AlarmClock/radio_controller.png b/libraries/RTC/examples/AlarmClock/radio_controller.png deleted file mode 100644 index 6325bf40..00000000 Binary files a/libraries/RTC/examples/AlarmClock/radio_controller.png and /dev/null differ diff --git a/libraries/RTC/examples/DumpRTC/DumpRTC.ino b/libraries/RTC/examples/DumpRTC/DumpRTC.ino deleted file mode 100644 index b2aa3645..00000000 --- a/libraries/RTC/examples/DumpRTC/DumpRTC.ino +++ /dev/null @@ -1,83 +0,0 @@ -/* -This example demonstrates how to read time, date, and other information -from the DS3232 realtime clock chip. - -This example is placed into the public domain. -*/ - -#include -#include - -SoftI2C i2c(A4, A5); -DS3232RTC rtc(i2c); - -const char *days[] = { - "Mon, ", "Tue, ", "Wed, ", "Thu, ", "Fri, ", "Sat, ", "Sun, " -}; - -const char *months[] = { - " Jan ", " Feb ", " Mar ", " Apr ", " May ", " Jun ", - " Jul ", " Aug ", " Sep ", " Oct ", " Nov ", " Dec " -}; - -void setup() { - Serial.begin(9600); - - RTCAlarm alarm; - for (byte alarmNum = 0; alarmNum < RTC::ALARM_COUNT; ++alarmNum) { - rtc.readAlarm(alarmNum, &alarm); - Serial.print("Alarm "); - Serial.print(alarmNum + 1, DEC); - Serial.print(": "); - if (alarm.flags & 0x01) { - printDec2(alarm.hour); - Serial.print(':'); - printDec2(alarm.minute); - Serial.println(); - } else { - Serial.println("Off"); - } - } - Serial.println(); -} - -void loop() { - RTCTime time; - RTCDate date; - rtc.readTime(&time); - rtc.readDate(&date); - - Serial.print("Time: "); - printDec2(time.hour); - Serial.print(':'); - printDec2(time.minute); - Serial.print(':'); - printDec2(time.second); - Serial.println(); - - Serial.print("Date: "); - Serial.print(days[RTC::dayOfWeek(&date) - 1]); - Serial.print(date.day, DEC); - Serial.print(months[date.month - 1]); - Serial.print(date.year); - Serial.println(); - - Serial.print("Temp: "); - int temp = rtc.readTemperature(); - if (temp != RTC::NO_TEMPERATURE) { - Serial.print(temp / 4.0); - Serial.println(" celcius"); - } else { - Serial.println("not available"); - } - - Serial.println(); - - delay(1000); -} - -void printDec2(int value) -{ - Serial.print((char)('0' + (value / 10))); - Serial.print((char)('0' + (value % 10))); -} diff --git a/libraries/RTC/examples/TestRTC/TestRTC.ino b/libraries/RTC/examples/TestRTC/TestRTC.ino deleted file mode 100644 index 7f38aa66..00000000 --- a/libraries/RTC/examples/TestRTC/TestRTC.ino +++ /dev/null @@ -1,440 +0,0 @@ -/* - * Copyright (C) 2012 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -/* -This example demonstrates how to read and write time, date, and other -information from the DS3232 realtime clock chip. The application is -controlled from the Serial Monitor in the Arduino IDE using a simple -command and response system. Configure the Serial Monitor to use -"Newline" line endings. Type "HELP" to get a list of commands. -*/ - -#include -#include -#include -#include - -SoftI2C i2c(A4, A5); -DS3232RTC rtc(i2c); -char buffer[64]; -size_t buflen; - -const char *days[] = { - "Mon, ", "Tue, ", "Wed, ", "Thu, ", "Fri, ", "Sat, ", "Sun, " -}; - -const char *months[] = { - " Jan ", " Feb ", " Mar ", " Apr ", " May ", " Jun ", - " Jul ", " Aug ", " Sep ", " Oct ", " Nov ", " Dec " -}; - -static uint8_t monthLengths[] = { - 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 -}; - -inline bool isLeapYear(unsigned int year) -{ - if ((year % 100) == 0) - return (year % 400) == 0; - else - return (year % 4) == 0; -} - -inline uint8_t monthLength(const RTCDate *date) -{ - if (date->month != 2 || !isLeapYear(date->year)) - return monthLengths[date->month - 1]; - else - return 29; -} - -void setup() { - Serial.begin(9600); - buflen = 0; - cmdHelp(0); -} - -void loop() { - if (Serial.available()) { - // Process serial input for commands from the host. - int ch = Serial.read(); - if (ch == 0x0A || ch == 0x0D) { - // End of the current command. Blank lines are ignored. - if (buflen > 0) { - buffer[buflen] = '\0'; - buflen = 0; - processCommand(buffer); - } - } else if (ch == 0x08) { - // Backspace over the last character. - if (buflen > 0) - --buflen; - } else if (buflen < (sizeof(buffer) - 1)) { - // Add the character to the buffer after forcing to upper case. - if (ch >= 'a' && ch <= 'z') - buffer[buflen++] = ch - 'a' + 'A'; - else - buffer[buflen++] = ch; - } - } -} - -void printDec2(int value) -{ - Serial.print((char)('0' + (value / 10))); - Serial.print((char)('0' + (value % 10))); -} - -void printProgString(PGM_P str) -{ - for (;;) { - char ch = (char)(pgm_read_byte(str)); - if (ch == '\0') - break; - Serial.print(ch); - ++str; - } -} - -byte readField(const char *args, int &posn, int maxValue) -{ - int value = -1; - if (args[posn] == ':' && posn != 0) - ++posn; - while (args[posn] >= '0' && args[posn] <= '9') { - if (value == -1) - value = 0; - value = (value * 10) + (args[posn++] - '0'); - if (value > 99) - return 99; - } - if (value == -1 || value > maxValue) - return 99; - else - return value; -} - -// "TIME" command. -void cmdTime(const char *args) -{ - RTCTime time; - if (*args != '\0') { - // Set the current time. - int posn = 0; - time.hour = readField(args, posn, 23); - time.minute = readField(args, posn, 59); - if (args[posn] != '\0') - time.second = readField(args, posn, 59); - else - time.second = 0; - if (time.hour == 99 || time.minute == 99 || time.second == 99) { - Serial.println("Invalid time format; use HH:MM:SS"); - return; - } - rtc.writeTime(&time); - Serial.print("Time has been set to: "); - } - - // Read the current time. - rtc.readTime(&time); - printDec2(time.hour); - Serial.print(':'); - printDec2(time.minute); - Serial.print(':'); - printDec2(time.second); - Serial.println(); -} - -// "DATE" command. -void cmdDate(const char *args) -{ - RTCDate date; - if (*args != '\0') { - // Set the current date. - unsigned long value = 0; - while (*args >= '0' && *args <= '9') - value = value * 10 + (*args++ - '0'); - if (value < 20000000 || value >= 21000000) { - Serial.println("Year must be between 2000 and 2099"); - return; - } - date.day = (byte)(value % 100); - date.month = (byte)((value / 100) % 100); - date.year = (unsigned int)(value / 10000); - if (date.month < 1 || date.month > 12) { - Serial.println("Month must be between 1 and 12"); - return; - } - uint8_t len = monthLength(&date); - if (date.day < 1 || date.day > len) { - Serial.print("Day must be between 1 and "); - Serial.println(len, DEC); - return; - } - rtc.writeDate(&date); - Serial.print("Date has been set to: "); - } - - // Read the current date. - rtc.readDate(&date); - Serial.print(days[RTC::dayOfWeek(&date) - 1]); - Serial.print(date.day, DEC); - Serial.print(months[date.month - 1]); - Serial.println(date.year, DEC); -} - -// "TEMP" command. -void cmdTemp(const char *args) -{ - int temp = rtc.readTemperature(); - if (temp != RTC::NO_TEMPERATURE) { - Serial.print(temp / 4.0); - Serial.println(" degrees celcius"); - } else { - Serial.println("Temperature is not available"); - } -} - -void printAlarm(byte alarmNum, const RTCAlarm *alarm) -{ - Serial.print("Alarm "); - Serial.print(alarmNum + 1, DEC); - Serial.print(": "); - if (alarm->flags & 0x01) { - printDec2(alarm->hour); - Serial.print(':'); - printDec2(alarm->minute); - Serial.println(); - } else { - Serial.println("Off"); - } -} - -// "ALARMS" command. -void cmdAlarms(const char *args) -{ - RTCAlarm alarm; - for (byte alarmNum = 0; alarmNum < RTC::ALARM_COUNT; ++alarmNum) { - rtc.readAlarm(alarmNum, &alarm); - printAlarm(alarmNum, &alarm); - } -} - -const char s_ON[] PROGMEM = "ON"; -const char s_OFF[] PROGMEM = "OFF"; - -// "ALARM" command. -void cmdAlarm(const char *args) -{ - RTCAlarm alarm; - int posn = 0; - byte alarmNum = readField(args, posn, RTC::ALARM_COUNT); - if (!alarmNum || alarmNum == 99) { - Serial.print("Alarm number must be between 1 and "); - Serial.println(RTC::ALARM_COUNT, DEC); - return; - } - --alarmNum; - while (args[posn] == ' ' || args[posn] == '\t') - ++posn; - if (args[posn] != '\0') { - // Set the alarm to a new value. - if (matchString(s_ON, args + posn, strlen(args + posn))) { - rtc.readAlarm(alarmNum, &alarm); - alarm.flags = 1; - } else if (matchString(s_OFF, args + posn, strlen(args + posn))) { - rtc.readAlarm(alarmNum, &alarm); - alarm.flags = 0; - } else { - alarm.hour = readField(args, posn, 23); - alarm.minute = readField(args, posn, 59); - if (alarm.hour == 99 || alarm.minute == 99) { - Serial.println("Invalid alarm time format; use HH:MM"); - return; - } - alarm.flags = 1; - } - rtc.writeAlarm(alarmNum, &alarm); - } - - // Print the current state of the alarm. - rtc.readAlarm(alarmNum, &alarm); - printAlarm(alarmNum, &alarm); -} - -// "NVRAM" command. -void cmdNvram(const char *args) -{ - static const char hexchars[] = "0123456789ABCDEF"; - int count = rtc.byteCount(); - for (int offset = 0; offset < count; ++offset) { - if ((offset % 16) == 0) { - if (offset) - Serial.println(); - Serial.print(hexchars[(offset >> 12) & 0x0F]); - Serial.print(hexchars[(offset >> 8) & 0x0F]); - Serial.print(hexchars[(offset >> 4) & 0x0F]); - Serial.print(hexchars[offset & 0x0F]); - Serial.print(':'); - Serial.print(' '); - } - byte value = rtc.readByte(offset); - Serial.print(hexchars[(value >> 4) & 0x0F]); - Serial.print(hexchars[value & 0x0F]); - Serial.print(' '); - } - Serial.println(); -} - -// List of all commands that are understood by the sketch. -typedef void (*commandFunc)(const char *args); -typedef struct -{ - PGM_P name; - commandFunc func; - PGM_P desc; - PGM_P args; -} command_t; -const char s_cmdTime[] PROGMEM = "TIME"; -const char s_cmdTimeDesc[] PROGMEM = - "Read or write the current time"; -const char s_cmdTimeArgs[] PROGMEM = "[HH:MM:SS]"; -const char s_cmdDate[] PROGMEM = "DATE"; -const char s_cmdDateDesc[] PROGMEM = - "Read or write the current date"; -const char s_cmdDateArgs[] PROGMEM = "[YYYYMMDD]"; -const char s_cmdTemp[] PROGMEM = "TEMP"; -const char s_cmdTempDesc[] PROGMEM = - "Read the current temperature"; -const char s_cmdAlarms[] PROGMEM = "ALARMS"; -const char s_cmdAlarmsDesc[] PROGMEM = - "Print the status of all alarms"; -const char s_cmdAlarm[] PROGMEM = "ALARM"; -const char s_cmdAlarmDesc[] PROGMEM = - "Read or write a specific alarm"; -const char s_cmdAlarmArgs[] PROGMEM = "NUM [HH:MM|ON|OFF]"; -const char s_cmdNvram[] PROGMEM = "NVRAM"; -const char s_cmdNvramDesc[] PROGMEM = - "Print the contents of NVRAM, excluding alarms"; -const char s_cmdHelp[] PROGMEM = "HELP"; -const char s_cmdHelpDesc[] PROGMEM = - "Prints this help message"; -const command_t commands[] PROGMEM = { - {s_cmdTime, cmdTime, s_cmdTimeDesc, s_cmdTimeArgs}, - {s_cmdDate, cmdDate, s_cmdDateDesc, s_cmdDateArgs}, - {s_cmdTemp, cmdTemp, s_cmdTempDesc, 0}, - {s_cmdAlarms, cmdAlarms, s_cmdAlarmsDesc, 0}, - {s_cmdAlarm, cmdAlarm, s_cmdAlarmDesc, s_cmdAlarmArgs}, - {s_cmdNvram, cmdNvram, s_cmdNvramDesc, 0}, - {s_cmdHelp, cmdHelp, s_cmdHelpDesc, 0}, - {0, 0} -}; - -// "HELP" command. -void cmdHelp(const char *) -{ - int index = 0; - for (;;) { - PGM_P name = (PGM_P)(pgm_read_word(&(commands[index].name))); - if (!name) - break; - PGM_P desc = (PGM_P)(pgm_read_word(&(commands[index].desc))); - PGM_P args = (PGM_P)(pgm_read_word(&(commands[index].args))); - printProgString(name); - if (args) { - Serial.print(' '); - printProgString(args); - } - Serial.println(); - Serial.print(" "); - printProgString(desc); - Serial.println(); - ++index; - } -} - -// Match a data-space string where the name comes from PROGMEM. -bool matchString(PGM_P name, const char *str, int len) -{ - for (;;) { - char ch1 = (char)(pgm_read_byte(name)); - if (ch1 == '\0') - return len == 0; - else if (len == 0) - break; - if (ch1 >= 'a' && ch1 <= 'z') - ch1 = ch1 - 'a' + 'A'; - char ch2 = *str; - if (ch2 >= 'a' && ch2 <= 'z') - ch2 = ch2 - 'a' + 'A'; - if (ch1 != ch2) - break; - ++name; - ++str; - --len; - } - return false; -} - -// Process commands from the host. -void processCommand(const char *buf) -{ - // Skip white space at the start of the command. - while (*buf == ' ' || *buf == '\t') - ++buf; - if (*buf == '\0') - return; // Ignore blank lines. - - // Extract the command portion of the line. - const char *cmd = buf; - int len = 0; - for (;;) { - char ch = *buf; - if (ch == '\0' || ch == ' ' || ch == '\t') - break; - ++buf; - ++len; - } - - // Skip white space after the command name and before the arguments. - while (*buf == ' ' || *buf == '\t') - ++buf; - - // Find the command and execute it. - int index = 0; - for (;;) { - PGM_P name = (PGM_P)(pgm_read_word(&(commands[index].name))); - if (!name) - break; - if (matchString(name, cmd, len)) { - commandFunc func = - (commandFunc)(pgm_read_word(&(commands[index].func))); - (*func)(buf); - return; - } - ++index; - } - - // Unknown command. - Serial.println("Unknown command, valid commands are:"); - cmdHelp(0); -} diff --git a/libraries/RTC/keywords.txt b/libraries/RTC/keywords.txt deleted file mode 100644 index 5fa101a4..00000000 --- a/libraries/RTC/keywords.txt +++ /dev/null @@ -1,15 +0,0 @@ -DS1307RTC KEYWORD1 -DS3232RTC KEYWORD1 -RTC KEYWORD1 - -isRealTime KEYWORD2 -hasUpdates KEYWORD2 -readTime KEYWORD2 -readDate KEYWORD2 -writeTime KEYWORD2 -writeDate KEYWORD2 -alarmCount KEYWORD2 -readAlarm KEYWORD2 -writeAlarm KEYWORD2 -readByte KEYWORD2 -writeByte KEYWORD2 diff --git a/libraries/Shell/LoginShell.cpp b/libraries/Shell/LoginShell.cpp deleted file mode 100644 index acc2968f..00000000 --- a/libraries/Shell/LoginShell.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2016 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#include "LoginShell.h" - -/** - * \class LoginShell LoginShell.h - * \brief Command-line shell access via a login shell. - * - * This class provides a command-line shell with login support. - * The user is prompted for username and password when they connect - * and other commands will not be available until the correct credentials - * have been supplied. - * - * \sa Shell - */ - -/** - * \typedef ShellPasswordCheckFunc - * \brief Password checking function for login shells. - * - * \param username Points to the user name that was supplied at login. - * \param password Points to the password that was supplied at login. - * - * \return Returns zero or greater if the username and password combination - * is correct, negative if incorrect. - * - * The return value is reported to the application as Shell::userid(), - * which can be used by the application to restrict the set of commands - * that are available to the user, or to restrict the behaviour of - * those commands when acting on critical resources. - * - * Timing can be very important: the check should take the same amount of - * time for valid and invalid user identifiers or passwords so that an - * attacker cannot gain knowledge about the valid users on the system - * based on failed login attempts. - * - * \relates LoginShell - * \sa Shell::userid() - */ - -/** - * \brief Constructs a new login shell. - * - * This constructor must be followed by a call to begin() to specify - * the underlying I/O stream. - */ -LoginShell::LoginShell() - : machName(0) - , checkFunc(0) -{ -} - -/** - * \brief Destroys this login shell. - */ -LoginShell::~LoginShell() -{ -} diff --git a/libraries/Shell/LoginShell.h b/libraries/Shell/LoginShell.h deleted file mode 100644 index 1811fe05..00000000 --- a/libraries/Shell/LoginShell.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2016 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#ifndef LOGIN_SHELL_h -#define LOGIN_SHELL_h - -#include "Shell.h" - -typedef int (*ShellPasswordCheckFunc)(const char *username, const char *password); - -class LoginShell : public Shell -{ -public: - LoginShell(); - virtual ~LoginShell(); - - const char *machineName() const { return machName; } - void setMachineName(const char *machineName) { machName = machineName; } - - ShellPasswordCheckFunc passwordCheckFunction() const { return checkFunc; } - void setPasswordCheckFunction(ShellPasswordCheckFunc function) { checkFunc = function; } - -protected: - virtual void beginSession(); - virtual void printPrompt(); - virtual void execute(); - -private: - const char *machName; - ShellPasswordCheckFunc checkFunc; -}; - -#endif diff --git a/libraries/Shell/Shell.cpp b/libraries/Shell/Shell.cpp deleted file mode 100644 index e4c10f94..00000000 --- a/libraries/Shell/Shell.cpp +++ /dev/null @@ -1,1092 +0,0 @@ -/* - * Copyright (C) 2016 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#include "Shell.h" -#include "LoginShell.h" -#include -#include - -/** - * \class Shell Shell.h - * \brief Command-line shell access. - * - * This class provides a command-line shell via serial ports, TCP connections, - * or any other type of Stream. - * - * The following example is the minimal setup for a command-line shell - * on a serial port. The application calls begin() to set the underlying - * Stream, and periodically calls loop() to manage shell-related events. - * - * \code - * Shell shell; - * - * void setup() { - * Serial.begin(9600); - * shell.setPrompt("$ "); - * shell.begin(Serial); - * } - * - * void loop() { - * shell.loop(); - * } - * \endcode - * - * Commands can be registered with the shell by the application to be - * invoked when the user types in the corresponding command. Each - * command is associated with a handler function: - * - * \code - * void cmdMotor(Shell &shell, int argc, const ShellArguments &argv) - * { - * ... - * } - * - * ShellCommand(motor, "Turn the motor on or off", cmdMotor); - * \endcode - * - * There are two standard commands built into Shell: "help" and "exit". - * The "help" command provides a list of all registered commands with - * the short help string from the ShellCommand() registration. - * The "exit" command logs the user out and returns to the login prompt, - * or stops the underlying connection in the case of TCP streams. - * - * The F1 key can be used as a synonym for "help" and CTRL-D can be used - * as a synonym for "exit". - * - * Shell provides some limited history editing for scrolling back through - * previous commands. The size of the history stack is provided in the - * second argument to begin(): - * - * \code - * shell.begin(Serial, 5); - * \endcode - * - * \sa LoginShell, Terminal - */ - -/** - * \def SHELL_MAX_CMD_LEN - * \brief Maximum command length for the shell, including the terminating NUL. - */ - -/** - * \typedef ShellCommandFunc - * \brief Type of functions that provide shell command handlers. - * - * \param shell Points to the shell instance that executed the command, - * which can be used to print command results or read more input. - * \param argc Number of arguments to the command, including the - * command's name. - * \param argv The arguments to the command. - * - * \sa ShellCommand() - * \relates Shell - */ - -// Modes for line editing (flags). -#define LINEMODE_NORMAL 0x01 -#define LINEMODE_ECHO 0x02 -#define LINEMODE_USERNAME 0x04 -#define LINEMODE_PASSWORD 0x08 -#define LINEMODE_PROMPT 0x10 -#define LINEMODE_DELAY 0x20 - -// Delay to insert after a failed login to slow down brute force attacks (ms). -#define LOGIN_SHELL_DELAY 3000 - -/** - * \brief Constructs a new Shell instance. - * - * This constructor must be followed by a call to begin() to specify - * the underlying I/O stream. - */ -Shell::Shell() - : curStart(0) - , curLen(0) - , curMax(sizeof(buffer)) - , history(0) - , historyWrite(0) - , historyRead(0) - , historySize(0) - , prom("$ ") - , isClient(false) - , lineMode(LINEMODE_NORMAL | LINEMODE_ECHO) - , uid(-1) - , timer(0) -{ -} - -/** - * \brief Destroys this Shell object. - */ -Shell::~Shell() -{ - clearHistory(); - delete [] history; -} - -/** - * \brief Begin shell handling on an underlying character stream. - * - * \param stream The stream to apply the shell to. Usually this is a - * serial port or TCP network connection. - * \param maxHistory The number of commands to allocate in the history - * stack for scrolling back through using Up/Down arrow keys. - * \param mode The terminal mode to operate in, Terminal::Serial or - * Terminal::Telnet. Default is Terminal::Serial. - * \return Returns false if there is insufficient memory for the history - * stack. The session will continue but without command history. - * - * This function will print the prompt() in preparation for entry of - * the first command. The default prompt is "$ "; call setPrompt() - * before begin() to change this: - * - * \code - * Serial.begin(9600); - * shell.setPrompt("Command: "); - * shell.begin(Serial); - * \endcode - * - * The \a maxHistory parameter indicates the number of commands of - * maximum length that can be stored in the history. If the actual - * entered commands are shorter, then more commands can be stored in - * the history. - * - * \sa end(), setPrompt() - */ -bool Shell::begin(Stream &stream, size_t maxHistory, Terminal::Mode mode) -{ - if (!beginShell(stream, maxHistory, mode)) - return false; - isClient = false; - return true; -} - -/** - * \brief Begin shell handling on a connected TCP client. - * - * \param client The client to apply the shell to. This must be a - * connected TCP client. - * \param maxHistory The number of commands to allocate in the history - * stack for scrolling back through using Up/Down arrow keys. - * \param mode The terminal mode to operate in, Terminal::Serial or - * Terminal::Telnet. Default is Terminal::Telnet. - * \return Returns true if the shell was initialized, or false if there - * is insufficient memory for the history stack. - * - * This override is provided as a convenience for starting a shell on a - * TCP connection. This function also modifies the behaviour of the - * builtin "exit" command to forcibly stop the TCP connection rather - * than returning to the login prompt. - * - * The \a maxHistory parameter indicates the number of commands of - * maximum length that can be stored in the history. If the actual - * entered commands are shorter, then more commands can be stored in - * the history. - * - * \sa end(), setPrompt() - */ -bool Shell::begin(Client &client, size_t maxHistory, Terminal::Mode mode) -{ - if (!beginShell(client, maxHistory, mode)) - return false; - isClient = true; - return true; -} - -/** - * \brief Internal implementation of begin(). - */ -bool Shell::beginShell(Stream &stream, size_t maxHistory, Terminal::Mode mode) -{ - // Initialize the Terminal base class with the underlying stream. - Terminal::begin(stream, mode); - - // Create the history buffer. - bool ok = true; - delete [] history; - historySize = sizeof(buffer) * maxHistory; - if (maxHistory) { - history = new char [historySize]; - if (history) { - memset(history, 0, historySize); - } else { - maxHistory = 0; - historySize = 0; - ok = false; - } - } else { - history = 0; - } - - // Clear other variables. - curStart = 0; - curLen = 0; - curMax = sizeof(buffer); - historyWrite = 0; - historyRead = 0; - uid = -1; - - // Begins the login session. - beginSession(); - return ok; -} - -/** - * \brief Ends shell processing on the underlying stream. - * - * This function is intended to be called when a TCP network connection - * is closed to clean up the shell state that was in use by the connection. - * - * \sa begin() - */ -void Shell::end() -{ - Terminal::end(); - clearHistory(); - delete [] history; - curStart = 0; - curLen = 0; - curMax = sizeof(buffer); - history = 0; - historyWrite = 0; - historyRead = 0; - historySize = 0; - isClient = false; - lineMode = LINEMODE_NORMAL | LINEMODE_ECHO; - uid = -1; -} - -/** @cond */ - -// Standard builtin command names. -static char const builtin_cmd_exit[] PROGMEM = "exit"; -static char const builtin_cmd_help[] PROGMEM = "help"; -static char const builtin_cmd_help_alt[] PROGMEM = "?"; - -/** @endcond */ - -/** - * \brief Performs regular activities on the shell. - * - * This function must be called regularly from the application's main loop - * to process input for the shell. - */ -void Shell::loop() -{ - // If the stream is a TCP client, then check for disconnection. - if (isClient && !((Client *)stream())->connected()) { - end(); - return; - } - - // If the login delay is active, then suppress all input. - if (lineMode & LINEMODE_DELAY) { - if ((millis() - timer) >= LOGIN_SHELL_DELAY) { - lineMode &= ~LINEMODE_DELAY; - timer = 0; - } else { - readKey(); - return; - } - } - - // Print the prompt if necessary. - if (lineMode & LINEMODE_PROMPT) - printPrompt(); - - // Read the next key and bail out if none. We only process a single - // key each time we enter this function to prevent other tasks in the - // system from becoming starved of time resources if the bytes are - // arriving rapidly from the underyling stream. - int key = readKey(); - if (key == -1) - return; - - // Process the key. - switch (key) { - case KEY_BACKSPACE: - // Backspace over the last character. - clearCharacters(1); - break; - - case KEY_RETURN: - // CR, LF, or CRLF pressed, so execute the current command. - execute(); - break; - - case 0x15: - // CTRL-U - clear the entire command. - clearCharacters(curLen); - break; - - case 0x04: - // CTRL-D - equivalent to the "exit" command. - if (lineMode & LINEMODE_NORMAL) - executeBuiltin(builtin_cmd_exit); - break; - - case KEY_UP_ARROW: - // Go back one item in the command history. - if ((lineMode & LINEMODE_NORMAL) != 0 && - history && historyRead > 0) { - changeHistory(true); - } - break; - - case KEY_DOWN_ARROW: - // Go forward one item in the command history. - if ((lineMode & LINEMODE_NORMAL) != 0 && - history && historyRead < historyWrite) { - changeHistory(false); - } - break; - - case KEY_F1: - // F1 is equivalent to the "help" command. - if (lineMode & LINEMODE_NORMAL) - executeBuiltin(builtin_cmd_help); - break; - - case KEY_UNICODE: { - // Add the Unicode code point to the buffer if it will fit. - long code = unicodeKey(); - size_t size = Terminal::utf8Length(code); - if (size && (curLen + size) < (curMax - 1)) { - Terminal::utf8Format((uint8_t *)(buffer + curLen), code); - if (lineMode & LINEMODE_ECHO) - write((uint8_t *)(buffer + curLen), size); - curLen += size; - } - } break; - - default: - if (key >= 0x20 && key <= 0x7E) { - // Printable ASCII character - echo and add it to the buffer. - if (curLen < (curMax - 1)) { - if (lineMode & LINEMODE_ECHO) - write((uint8_t)key); - buffer[curLen++] = (char)key; - } - } - break; - } -} - -#if defined(__AVR__) - -// String compare of two strings in program memory. -static int progmem_strcmp(const char *str1, const char *str2) -{ - uint8_t ch1, ch2; - for (;;) { - ch1 = pgm_read_byte((const uint8_t *)str1); - ch2 = pgm_read_byte((const uint8_t *)str2); - if (!ch1) { - if (ch2) - return -1; - else - break; - } else if (!ch2) { - return 1; - } else if (ch1 != ch2) { - return ((int)ch1) - ((int)ch2); - } - ++str1; - ++str2; - } - return 0; -} - -#else - -#define progmem_strcmp(str1,str2) (strcmp((str1), (str2))) - -#endif - -// Reads the "name" field from a command information block in program memory. -static const char *readInfoName(const ShellCommandInfo *info) -{ -#if defined(__AVR__) - return (const char *)pgm_read_word - (((const uint8_t *)info) + offsetof(ShellCommandInfo, name)); -#else - return info->name; -#endif -} - -// Reads the "help" field from a command information block in program memory. -static const char *readInfoHelp(const ShellCommandInfo *info) -{ -#if defined(__AVR__) - return (const char *)pgm_read_word - (((const uint8_t *)info) + offsetof(ShellCommandInfo, help)); -#else - return info->help; -#endif -} - -// Reads the "func" field from a command information block in program memory. -static ShellCommandFunc readInfoFunc(const ShellCommandInfo *info) -{ -#if defined(__AVR__) - if (sizeof(ShellCommandFunc) == 2) { - return (ShellCommandFunc)pgm_read_word - (((const uint8_t *)info) + offsetof(ShellCommandInfo, func)); - } else { - return (ShellCommandFunc)pgm_read_dword - (((const uint8_t *)info) + offsetof(ShellCommandInfo, func)); - } -#else - return info->func; -#endif -} - -static ShellCommandRegister *firstCmd = 0; - -/** - * \brief Registers a command with the shell. - * - * \note This function is internal. The ShellCommand() macro should be - * used instead. - */ -void Shell::registerCommand(ShellCommandRegister *cmd) -{ - // Insert the command into the list in alphanumeric order. - // We cannot rely upon the construction order to sort the list for us. - ShellCommandRegister *prev = 0; - ShellCommandRegister *current = firstCmd; - while (current != 0) { - if (progmem_strcmp(readInfoName(cmd->info), readInfoName(current->info)) < 0) - break; - prev = current; - current = current->next; - } - if (prev) - prev->next = cmd; - else - firstCmd = cmd; - cmd->next = current; -} - -/** - * \fn const char *Shell::prompt() const - * \brief Gets the prompt string to display in the shell. - * - * \return The current prompt. The default is "$ ". - * - * \sa setPrompt() - */ - -/** - * \fn void Shell::setPrompt(const char *prompt) - * \brief Sets the prompt string to display in the shell. - * - * \param prompt The new prompt string. The caller is responsible to ensure - * that the string persists after this call returns. The Shell class does - * not make a copy of the string. - * - * Calling this function will change the prompt for the next line of input. - * - * \sa prompt() - */ - -/** - * \fn int Shell::userid() const - * \brief Gets the user identifier for the currently logged in user, - * or -1 if there is no user logged in currently. - * - * The user identifier can be used by applications to restrict the set of - * commands that are available to the user, or to restrict the behaviour - * of those commands when acting on critical resources. - * - * \sa setUserid(), ShellPasswordCheckFunc - */ - -/** - * \fn void Shell::setUserid(int userid) - * \brief Sets the user identifier for the currently logged in user. - * - * \param userid The new user identifier to set, or -1 if there is no - * user logged in currently. - * - * Normally the user identifier is set when LoginShell detects a - * successful login. This function can be used to alter the access - * rights of the logged-in user after login. - * - * \sa userid(), ShellPasswordCheckFunc - */ - -/** - * \brief Displays help for all supported commands. - */ -void Shell::help() -{ - // Find the command with the maximum length. - ShellCommandRegister *current = firstCmd; - size_t maxLen = 0; - size_t len; - while (current != 0) { - len = strlen_P(readInfoName(current->info)); - if (len > maxLen) - maxLen = len; - current = current->next; - } - maxLen += 2; - - // Print the commands with the help strings aligned on the right. - current = firstCmd; - while (current != 0) { - writeProgMem(readInfoName(current->info)); - len = maxLen - strlen_P(readInfoName(current->info)); - while (len > 0) { - write(' '); - --len; - } - writeProgMem(readInfoHelp(current->info)); - println(); - current = current->next; - } -} - -/** - * \brief Exit from the shell back to the login prompt. - * - * If the underlying stream is a TCP client, then this function will - * stop the client, causing disconnection. - */ -void Shell::exit() -{ - Stream *stream = this->stream(); - uid = -1; - if (isClient) { - end(); - ((Client *)stream)->stop(); - } else { - clearHistory(); - println(); - beginSession(); - } -} - -/** - * \brief Begins a login session. - */ -void Shell::beginSession() -{ - // No login support in the base class, so enter normal mode immediately. - lineMode = LINEMODE_NORMAL | LINEMODE_ECHO | LINEMODE_PROMPT; -} - -/** - * \brief Prints the current prompt string. - */ -void Shell::printPrompt() -{ - if (prom) - print(prom); - lineMode &= ~LINEMODE_PROMPT; -} - -/** - * \brief Executes the command in the buffer. - */ -void Shell::execute() -{ - // Terminate the current line. - println(); - - // Make sure the command is properly NUL-terminated. - buffer[curLen] = '\0'; - - // If we have a history stack and the new command is different from - // the previous command, then copy the command into the stack. - if (history && curLen > curStart) { - char *prevCmd; - bool newCmd = true; - if (historyWrite > 0) { - prevCmd = (char *)memrchr(history, '\0', historyWrite - 1); - if (prevCmd) - ++prevCmd; - else - prevCmd = history; - if (strcmp(prevCmd, buffer + curStart) == 0) - newCmd = false; - } - if (newCmd) { - size_t len = curLen - curStart; - while ((len + 1) > (historySize - historyWrite)) { - // History stack is full. Pop older entries to get some room. - prevCmd = (char *)memchr(history, '\0', historyWrite); - if (prevCmd) { - size_t histLen = historyWrite - ((prevCmd + 1) - history); - memmove(history, prevCmd + 1, histLen); - historyWrite = histLen; - } else { - historyWrite = 0; - break; - } - } - memcpy(history + historyWrite, buffer + curStart, len); - historyWrite += len; - history[historyWrite++] = '\0'; - } - } - - // Reset the history read position to the top of the stack. - historyRead = historyWrite; - - // Break the command up into arguments and populate the argument array. - ShellArguments argv(buffer + curStart, curLen - curStart); - - // Clear the line buffer. - curLen = curStart; - - // Execute the command. - if (argv.count() > 0) { - if (!execute(argv)) { - // Could not find a matching command, try the builtin "help". - const char *argv0 = argv[0]; - if (!strcmp_P(argv0, builtin_cmd_help) || - !strcmp_P(argv0, builtin_cmd_help_alt)) { - help(); - } else if (!strcmp_P(argv0, builtin_cmd_exit)) { - exit(); - } else { - static char const unknown_cmd[] PROGMEM = "Unknown command: "; - writeProgMem(unknown_cmd); - print(argv0); - println(); - } - } - } - - // Prepare to print the prompt for the next command. - lineMode |= LINEMODE_PROMPT; -} - -/** - * \brief Executes a command that has been parsed into arguments. - * - * \param argv The arguments. - * - * \return Returns true if the command was found; false if not found. - */ -bool Shell::execute(const ShellArguments &argv) -{ - const char *argv0 = argv[0]; - ShellCommandRegister *current = firstCmd; - while (current != 0) { - if (!strcmp_P(argv0, readInfoName(current->info))) { - ShellCommandFunc func = readInfoFunc(current->info); - (*func)(*this, argv.count(), argv); - return true; - } - current = current->next; - } - return false; -} - -/** - * \brief Executes a builtin command like "exit" or "help". - * - * \param cmd The command to execute, which must point to program memory. - */ -void Shell::executeBuiltin(const char *cmd) -{ - clearCharacters(curLen); - curLen = strlen_P(cmd); - strncpy_P(buffer + curStart, cmd, curLen); - write((const uint8_t *)(buffer + curStart), curLen); - curLen += curStart; - execute(); -} - -/** - * \brief Clears characters from the input line by backspacing over them. - * - * \param len The number of characters to clear. - */ -void Shell::clearCharacters(size_t len) -{ - // If the characters are hidden, then there's nothing to backspace over. - if (!(lineMode & LINEMODE_ECHO)) - return; - - // Backspace over all characters in the buffer. - while (len > 0 && curLen > curStart) { - uint8_t ch = (uint8_t)(buffer[curLen - 1]); - if (ch < 0x80) { - backspace(); - } else { - // UTF-8 character sequence. Back up some more and - // determine the value of the Unicode code point. - long code = (ch & 0x3F); - uint8_t shift = 6; - while (curLen > 1) { - --curLen; - ch = (uint8_t)(buffer[curLen - 1]); - if ((ch & 0xC0) != 0x80) - break; - code |= ((long)(ch & 0x3F)) << shift; - shift += 6; - } - if ((ch & 0xE0) == 0xC0) - ch &= 0x1F; - else if ((ch & 0xF0) == 0xE0) - ch &= 0x0F; - else - ch &= 0x07; - code |= ((long)ch) << shift; - - // If the character is wide, we need to emit two backspaces. - if (isWideCharacter(code)) - backspace(); - backspace(); - } - --len; - --curLen; - } -} - -/** - * \brief Changes the current command to reflect a different position - * in the history stack. - * - * \param up Set to true to go up in the history, false to go down. - */ -void Shell::changeHistory(bool up) -{ - char *cmd; - if (up) { - cmd = (char *)memrchr(history, '\0', historyRead - 1); - if (cmd) - historyRead = (size_t)(cmd - history + 1); - else - historyRead = 0; - } else { - cmd = (char *)memchr(history + historyRead, '\0', historyWrite - historyRead); - if (cmd) - historyRead = (size_t)(cmd - history + 1); - else - historyRead = historyWrite; - } - clearCharacters(curLen); - if (historyRead < historyWrite) { - cmd = history + historyRead; - curLen = strlen(cmd); - if (curLen > (curMax - curStart)) - curLen = curMax - curStart; - memcpy(buffer + curStart, cmd, curLen); - write((uint8_t *)cmd, curLen); - curLen += curStart; - } -} - -/** - * \brief Clears the command buffer and history. - * - * This clears the history so that commands from one login session do - * not leak into the next login session. - */ -void Shell::clearHistory() -{ - if (history) - memset(history, 0, historySize); - historyRead = 0; - historyWrite = 0; - memset(buffer, 0, sizeof(buffer)); -} - -/** - * \fn ShellCommand(name,help,function) - * \brief Registers a command with the shell. - * - * \param name The name of the command. - * \param help Help string to display that describes the command. - * \param function The function to call to handle the command. - * - * The \a name and \a help parameters must be constant strings that can - * be placed into program memory. - * - * \code - * void cmdMotor(Shell &shell, int argc, const ShellArguments &argv) - * { - * ... - * } - * - * ShellCommand(motor, "Turn the motor on or off", cmdMotor); - * \endcode - * - * If there are multiple Shell instances active in the system, then the - * command will be registered with all of them. - * - * \relates Shell - */ - -/** - * \brief Constructs a new argument array. - * - * \param buffer Points to the command buffer to parse into arguments. - * \param len The length of the command buffer in bytes, excluding the - * terminating NUL. - */ -ShellArguments::ShellArguments(char *buffer, size_t len) - : line(buffer) - , size(0) - , argc(0) - , currentIndex(0) - , currentPosn(0) -{ - // Break the command up into arguments and add NUL terminators. - size_t posn = 0; - size_t outposn = 0; - char quote = 0; - while (posn < len) { - char ch = buffer[posn]; - if (ch == ' ') { - ++posn; - continue; - } - ++argc; - do { - ch = buffer[posn]; - if (ch == '"' || ch == '\'') { - if (quote == ch) { - quote = 0; - ++posn; - continue; - } else if (!quote) { - quote = ch; - ++posn; - continue; - } - } else if (!quote && ch == ' ') { - break; - } - buffer[outposn++] = ch; - ++posn; - } while (posn < len); - buffer[outposn++] = '\0'; - if (posn < len) - ++posn; - } - size = outposn; -} - -/** - * \class ShellArguments Shell.h - * \brief Convenience class that encapsulates an array of shell - * command arguments. - * - * \sa Shell - */ - -/** - * \fn ShellArguments::~ShellArguments() - * \brief Destroys this argument array. - */ - -/** - * \fn int ShellArguments::count() const - * \brief Returns the number of arguments, including the name of the command. - * - * \sa operator[] - */ - -/** - * \brief Gets a specific argument for the command. - * - * \param index The argument index between 0 and count() - 1. - * \return The argument, or NULL if \a index is out of range. - * - * The name of the command is argument 0. The command's remaining - * arguments are numbered 1 to count() - 1. - * - * \sa count() - */ -const char *ShellArguments::operator[](int index) const -{ - if (index < 0 || index >= argc) { - // Argument index is out of range. - return 0; - } else if (index == currentIndex) { - // We already found this argument last time. - return line + currentPosn; - } else { - // Search forwards or backwards for the next argument. - const char *temp; - while (index > currentIndex) { - temp = (const char *)memchr - (line + currentPosn, '\0', size - currentPosn); - if (!temp) - return 0; - currentPosn = ((size_t)(temp - line)) + 1; - ++currentIndex; - } - while (index < currentIndex) { - temp = (const char *)memrchr(line, '\0', currentPosn - 1); - if (temp) - currentPosn = ((size_t)(temp - line)) + 1; - else - currentPosn = 0; - --currentIndex; - } - return line + currentPosn; - } -} - -void LoginShell::beginSession() -{ - lineMode = LINEMODE_USERNAME | LINEMODE_ECHO | LINEMODE_PROMPT; - curStart = 0; - curLen = 0; - curMax = sizeof(buffer) / 2; -} - -/** - * \fn const char *LoginShell::machineName() const - * \brief Gets the name of the machine to display in the login prompt. - * - * The default value is NULL, indicating that no machine name should be shown. - * - * \sa setMachineName() - */ - -/** - * \fn void LoginShell::setMachineName(const char *machineName) - * \brief Sets the name of the machine to display in the login prompt. - * - * \param machineName The machine name, or NULL for no machine name. - * - * \sa machineName() - */ - -/** - * \fn ShellPasswordCheckFunc LoginShell::passwordCheckFunction() const - * \brief Gets the current password checking function, or NULL if the - * function has not been set yet. - * - * \sa setPasswordCheckFunction() - */ - -/** - * \fn void LoginShell::setPasswordCheckFunction(ShellPasswordCheckFunc function) - * \brief Sets the password checking function. - * - * \param function The password checking function to set, or NULL to return - * to the default rules. - * - * If no function is set, then LoginShell will check for a username of - * "root" and a password of "arduino" (both values are case-sensitive). - * This is of course not very secure. Realistic applications should set a - * proper password checking function. - * - * \sa passwordCheckFunction() - */ - -void LoginShell::printPrompt() -{ - static char const loginString[] PROGMEM = "login: "; - static char const passwordString[] PROGMEM = "Password: "; - if (lineMode & LINEMODE_NORMAL) { - // Print the prompt for normal command entry. - if (prom) - print(prom); - - // Normal commands occupy the full command buffer. - curStart = 0; - curLen = 0; - curMax = sizeof(buffer); - } else if (lineMode & LINEMODE_USERNAME) { - // Print the machine name and the login prompt. - if (machName) { - print(machName); - write((uint8_t)' '); - } - writeProgMem(loginString); - - // Login name is placed into the first half of the line buffer. - curStart = 0; - curLen = 0; - curMax = sizeof(buffer) / 2; - } else if (lineMode & LINEMODE_PASSWORD) { - // Print the password prompt. - writeProgMem(passwordString); - - // Password is placed into the second half of the line buffer. - curStart = sizeof(buffer) / 2; - curLen = curStart; - curMax = sizeof(buffer); - } - lineMode &= ~LINEMODE_PROMPT; -} - -// Default password checking function. This is not a very good security check! -static int defaultPasswordCheckFunc(const char *username, const char *password) -{ - static char const defaultUsername[] PROGMEM = "root"; - static char const defaultPassword[] PROGMEM = "arduino"; - if (!strcmp_P(username, defaultUsername) && - !strcmp_P(password, defaultPassword)) { - return 0; - } else { - return -1; - } -} - -void LoginShell::execute() -{ - if (lineMode & LINEMODE_NORMAL) { - // Normal command execution. - Shell::execute(); - } else if (lineMode & LINEMODE_USERNAME) { - // Prompting for the login username. - buffer[curLen] = '\0'; - lineMode = LINEMODE_PASSWORD | LINEMODE_PROMPT; - println(); - } else if (lineMode & LINEMODE_PASSWORD) { - // Prompting for the login password. - buffer[curLen] = '\0'; - println(); - - // Check the user name and password. - int userid; - if (checkFunc) - userid = checkFunc(buffer, buffer + sizeof(buffer) / 2); - else - userid = defaultPasswordCheckFunc(buffer, buffer + sizeof(buffer) / 2); - - // Clear the user name and password from memory after they are checked. - memset(buffer, 0, sizeof(buffer)); - - // Go to either normal mode or back to username mode. - if (userid >= 0) { - uid = userid; - lineMode = LINEMODE_NORMAL | LINEMODE_ECHO | LINEMODE_PROMPT; - } else { - lineMode = LINEMODE_USERNAME | LINEMODE_ECHO | - LINEMODE_PROMPT | LINEMODE_DELAY; - timer = millis(); - } - } -} diff --git a/libraries/Shell/Shell.h b/libraries/Shell/Shell.h deleted file mode 100644 index 16f6c99b..00000000 --- a/libraries/Shell/Shell.h +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright (C) 2016 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#ifndef SHELL_h -#define SHELL_h - -#include "Terminal.h" -#include - -class Shell; -class ShellArguments; -class LoginShell; - -#if defined(__arm__) -#define SHELL_MAX_CMD_LEN 256 -#else -#define SHELL_MAX_CMD_LEN 64 -#endif - -typedef void (*ShellCommandFunc)(Shell &shell, int argc, const ShellArguments &argv); - -/** @cond */ - -typedef struct -{ - const char *name; - const char *help; - ShellCommandFunc func; - -} ShellCommandInfo; - -class ShellCommandRegister -{ -public: - inline ShellCommandRegister(const ShellCommandInfo *_info); - - const ShellCommandInfo *info; - ShellCommandRegister *next; -}; - -/** @endcond */ - -class Shell : public Terminal -{ -public: - Shell(); - virtual ~Shell(); - - bool begin(Stream &stream, size_t maxHistory = 0, Terminal::Mode mode = Serial); - bool begin(Client &client, size_t maxHistory = 0, Terminal::Mode mode = Telnet); - void end(); - - void loop(); - - static void registerCommand(ShellCommandRegister *cmd); - - const char *prompt() const { return prom; } - void setPrompt(const char *prompt) { prom = prompt; } - - int userid() const { return uid; } - void setUserid(int userid) { uid = userid; } - - void help(); - void exit(); - -protected: - virtual void beginSession(); - virtual void printPrompt(); - virtual void execute(); - -private: - char buffer[SHELL_MAX_CMD_LEN]; - size_t curStart; - size_t curLen; - size_t curMax; - char *history; - size_t historyWrite; - size_t historyRead; - size_t historySize; - const char *prom; - bool isClient; - uint8_t lineMode; - int uid; - unsigned long timer; - - // Disable copy constructor and operator=(). - Shell(const Shell &other) {} - Shell &operator=(const Shell &) { return *this; } - - bool beginShell(Stream &stream, size_t maxHistory, Terminal::Mode mode); - bool execute(const ShellArguments &argv); - void executeBuiltin(const char *cmd); - void clearCharacters(size_t len); - void changeHistory(bool up); - void clearHistory(); - - friend class LoginShell; -}; - -class ShellArguments -{ - friend class Shell; -private: - ShellArguments(char *buffer, size_t len); - ~ShellArguments() {} -public: - - int count() const { return argc; } - const char *operator[](int index) const; - -private: - const char *line; - size_t size; - int argc; - mutable int currentIndex; - mutable size_t currentPosn; - - // Disable copy constructor and operator=(). - ShellArguments(const ShellArguments &other) {} - ShellArguments &operator=(const ShellArguments &) { return *this; } -}; - -/** @cond */ - -inline ShellCommandRegister::ShellCommandRegister(const ShellCommandInfo *_info) - : info(_info) - , next(0) -{ - Shell::registerCommand(this); -} - -/** @endcond */ - -#define ShellCommand(name,help,function) \ - static char const shell_id_##name[] PROGMEM = #name; \ - static char const shell_help_##name[] PROGMEM = help; \ - static ShellCommandInfo const shell_info_##name PROGMEM = { \ - shell_id_##name, \ - shell_help_##name, \ - (function) \ - }; \ - static ShellCommandRegister shell_cmd_##name(&shell_info_##name) - -#endif diff --git a/libraries/Shell/TelnetDefs.h b/libraries/Shell/TelnetDefs.h deleted file mode 100644 index 7762b8aa..00000000 --- a/libraries/Shell/TelnetDefs.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (C) 2016 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#ifndef TELNET_DEFS_h -#define TELNET_DEFS_h - -// References: -// https://tools.ietf.org/html/rfc854 -// http://www.iana.org/assignments/telnet-options/telnet-options.xhtml - -namespace TelnetDefs -{ - -/** Telnet commands */ -enum Command -{ - EndOfFile = 236, /**< EOF */ - Suspend = 237, /**< Suspend process */ - Abort = 238, /**< Abort process */ - EndOfRecord = 239, /**< End of record command */ - SubEnd = 240, /**< End option sub-negotiation */ - NOP = 241, /**< No operation */ - DataMark = 242, /**< Data mark */ - Break = 243, /**< Break */ - Interrupt = 244, /**< Interrupt process */ - AbortOutput = 245, /**< Abort output */ - AreYouThere = 246, /**< Are you there? */ - EraseChar = 247, /**< Erase character */ - EraseLine = 248, /**< Erase line */ - GoAhead = 249, /**< Go ahead in half-duplex mode */ - SubStart = 250, /**< Option sub-negotiation */ - WILL = 251, /**< Will use option */ - WONT = 252, /**< Won't use option */ - DO = 253, /**< Do use option */ - DONT = 254, /**< Don't use option */ - IAC = 255 /**< Interpret As Command */ -}; - -/** Telnet options used in sub-negotiations */ -enum Option -{ - Binary = 0, /**< Binary transmission */ - Echo = 1, /**< Echo */ - Reconnection = 2, /**< Reconnection */ - SuppressGoAhead = 3, /**< Suppress half-duplex go ahead signals */ - ApproxMsgSize = 4, /**< Approx message size negotiation */ - Status = 5, /**< Give status on prevailing options */ - TimingMark = 6, /**< Timing mark */ - RemoteTransmitEcho = 7, /**< Remote controlled transmit and echo */ - LineWidth = 8, /**< Line width */ - PageSize = 9, /**< Page size */ - CarriageReturn = 10, /**< Carriage return disposition */ - HorzTabStops = 11, /**< Horizontal tab stops */ - HorzTabStopDisp = 12, /**< Horizontal tab stop disposition */ - FormFeed = 13, /**< Form feed disposition */ - VertTabStops = 14, /**< Vertical tab stops */ - VertTabStopDisp = 15, /**< Vertical tab stop disposition */ - LineFeed = 16, /**< Line feed disposition */ - ExtendedASCII = 17, /**< Extended ASCII */ - Logout = 18, /**< Force logout */ - ByteMacro = 19, /**< Byte macro */ - DataEntryTerminal = 20, /**< Data entry terminal */ - SUPDUP = 21, /**< SUPDUP protocol */ - SUPDUPOutput = 22, /**< SUPDUP output */ - SendLocation = 23, /**< Send the user's location */ - TerminalType = 24, /**< Terminal type */ - EndOfRecordOption = 25, /**< End of record option */ - TACACSUserId = 26, /**< TACACS user identification */ - OutputMarking = 27, /**< Output marking */ - TerminalLocation = 28, /**< Terminal location number */ - Telnet3270Regime = 29, /**< Telnet 3270 regime */ - X3Pad = 30, /**< X.3 PAD */ - WindowSize = 31, /**< Window size */ - Speed = 32, /**< Terminal speed */ - RemoteFlowControl = 33, /**< Remote flow control */ - Linemode = 34, /**< Linemode option */ - XDisplay = 35, /**< X display location */ - EnvironmentOld = 36, /**< Environment variables (old version) */ - Authentication = 37, /**< Authentication */ - Encryption = 38, /**< Encryption */ - Environment = 39, /**< Environment variables (new version) */ - TN3270E = 40, /**< TN3270E */ - XAUTH = 41, /**< XAUTH */ - Charset = 42, /**< Character set */ - RemoteSerialPort = 43, /**< Remote serial port */ - ComPortControl = 44, /**< COM port control */ - SuppressLocalEcho = 45, /**< Suppress local echo */ - StartTLS = 46, /**< Start TLS session */ - Kermit = 47, /**< KERMIT protocol */ - SendURL = 48, /**< Send URL */ - ForwardX = 49, /**< Forward X protocol */ - Extended = 255 /**< Extended options list */ -}; - -}; - -#endif diff --git a/libraries/Shell/Terminal.cpp b/libraries/Shell/Terminal.cpp deleted file mode 100644 index 82da2b52..00000000 --- a/libraries/Shell/Terminal.cpp +++ /dev/null @@ -1,1464 +0,0 @@ -/* - * Copyright (C) 2016 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#include "Terminal.h" -#include "TelnetDefs.h" - -/** - * \class Terminal Terminal.h - * \brief Extended stream interface for terminal operations. - * - * This class extends the standard Arduino Stream class with functions that - * are suitable for interfacing to VT100 terminal applications like PuTTY. - * - * The following example initializes a terminal running on the primary - * Arduino serial port: - * - * \code - * Terminal term; - * void setup() { - * Serial.begin(9600); - * term.begin(Serial); - * } - * \endcode - * - * The readKey() function reads input from the underlying stream, decodes - * any VT100 key escape sequences that it finds, and reports them to the - * application using USB, ASCII, or Unicode key codes. This is typically - * used in the application's main loop as follows: - * - * \code - * void loop() { - * int key = term.readKey(); - * switch (key) { - * case -1: break; // No key available. - * - * case KEY_LEFT_ARROW: - * // Left arrow key has been pressed. - * ... - * break; - * - * case KEY_RIGHT_ARROW: - * // Right arrow key has been pressed. - * ... - * break; - * - * case KEY_ESC: - * // Escape key has been pressed. - * ... - * break; - * - * default: - * if (key >= 0x20 && key <= 7E) { - * // Visible ASCII character has been typed. - * ... - * } - * break; - * } - * } - * \endcode - * - * This class understands extended characters in the UTF-8 encoding, - * allowing the full Unicode character set to be used in applications. - * Extended Unicode characters are reported by readKey() with the key code - * KEY_UNICODE, with the actual code point returned via unicodeKey(). - * - * On the output side, UTF-8 strings can be written to the terminal - * using write(), or writeUnicode() can be used to write a single - * Unicode character in UTF-8. - * - * \note This class does not have any special support for right-to-left - * scripts or composed characters. Unicode characters are read and written - * in the order in which they arrive. Applications may need to alter - * strings to display them correctly in such scripts. Patches are - * welcome to fix this. - * - * \sa Shell - */ - -/** @cond */ - -// States for the key recognition state machine. -#define STATE_INIT 0 // Initial state. -#define STATE_CR 1 // Last character was CR, eat following LF. -#define STATE_ESC 2 // Last character was ESC. -#define STATE_MATCH 3 // Matching an escape sequence. -#define STATE_UTF8 4 // Recognizing a UTF-8 sequence. -#define STATE_IAC 5 // Recognizing telnet command after IAC (0xFF). -#define STATE_WILL 6 // Waiting for option code for WILL command. -#define STATE_WONT 7 // Waiting for option code for WONT command. -#define STATE_DO 8 // Waiting for option code for DO command. -#define STATE_DONT 9 // Waiting for option code for DONT command. -#define STATE_SB 10 // Option sub-negotiation. -#define STATE_SB_IAC 11 // Option sub-negotiation, byte after IAC. - -// Number of milliseconds to wait after an ESC character before -// concluding that it is KEY_ESC rather than an escape sequence. -#define ESC_TIMEOUT_MS 40 - -// Number of milliseconds to wait for a new character within an -// escape sequence before concluding that the sequence was invalid -// or truncated, or not actually an escape sequence at all. -#define SEQ_TIMEOUT_MS 200 - -/** @endcond */ - -/** - * \brief Constructs a terminal object. - * - * This constructor must be followed by a call to begin() to specify - * the underlying stream to use for reading and writing. - * - * \sa begin() - */ -Terminal::Terminal() - : _stream(0) - , ucode(-1) - , ncols(80) - , nrows(24) - , timer(0) - , offset(0) - , state(STATE_INIT) - , utf8len(0) - , mod(Terminal::Serial) - , flags(0) -{ -} - -/** - * \brief Destroys this terminal object. - */ -Terminal::~Terminal() -{ -} - -/** - * \enum Terminal::Mode - * \brief Mode to operate in, Serial or Telnet. - */ - -/** - * \var Terminal::Serial - * \brief Operates the terminal in serial mode. - */ - -/** - * \var Terminal::Telnet - * \brief Operates the terminal in telnet mode. - */ - -/** - * \brief Begins terminal operations on an underlying stream. - * - * \param stream The underlying stream, whether a serial port, TCP connection, - * or some other stream. - * \param mode The mode to operate in, either Serial or Telnet. - * - * If Telnet mode is selected, then embedded commands and options from the - * telnet protocol (RFC 854) - * will be interpreted. This is useful if the underlying \a stream is a TCP - * connection on port 23. The mode operates as a telnet server. - * - * \sa end(), stream(), mode() - */ -void Terminal::begin(Stream &stream, Mode mode) -{ - _stream = &stream; - ucode = -1; - state = STATE_INIT; - flags = 0; - mod = mode; -} - -/** - * \brief Ends terminal operations on an underlying stream. - * - * This function may be useful if you want to detach the terminal from - * the underlying stream so that it can be used for something else. - */ -void Terminal::end() -{ - _stream = 0; -} - -/** - * \fn Stream *Terminal::stream() const - * \brief Returns a pointer to the underlying Stream, or NULL if the - * stream has not been set with begin() yet. - * - * \sa begin() - */ - -/** - * \fn Terminal::Mode Terminal::mode() const - * \brief Returns the mode this terminal is operating in, Serial or Telnet. - * - * \sa begin() - */ - -/** - * \brief Returns the number of bytes that are available for reading. - * - * \note It is possible for this function to return a positive value - * while readKey() does not produce a new key. This can happen with - * VT100 key escape sequences and UTF-8 characters that extend over - * multiple bytes. - * - * \sa readKey() - */ -int Terminal::available() -{ - return _stream ? _stream->available() : 0; -} - -/** - * \brief Peeks at the next byte from the underlying stream. - * - * \return The next byte or -1 if no bytes are available yet. - * - * \sa read() - */ -int Terminal::peek() -{ - return _stream ? _stream->peek() : -1; -} - -/** - * \brief Reads the next byte from the underlying stream. - * - * \return Returns 0x00 to 0xFF if a byte is ready, or -1 if none available. - * - * This function performs a low-level read on the underlying byte stream - * without applying any specific interpretation to the byte. In particular, - * escape sequences corresponding to arrow and function keys will not - * be recognized. - * - * Applications will usually want to call readKey() instead to handle - * escape sequences for arrow and function keys. This function is provided - * as a convenience to implement the parent Stream interface. - * - * \sa readKey() - */ -int Terminal::read() -{ - // Clear the key recognition state because we are bypassing readKey(). - state = STATE_INIT; - ucode = -1; - - // Read the next byte from the underlying stream. - return _stream ? _stream->read() : -1; -} - -/** - * \brief Flushes all data in the underlying stream. - */ -void Terminal::flush() -{ - if (_stream) - _stream->flush(); -} - -/** - * \brief Writes a single byte to the underlying stream. - * - * \param c The byte to write. - * \return The number of bytes written, zero on error. - */ -size_t Terminal::write(uint8_t c) -{ - return _stream ? _stream->write(c) : 0; -} - -/** - * \brief Writes a buffer of data to the underlying stream. - * - * \param buffer Points to the buffer to write. - * \param size The number of bytes in the \a buffer. - * - * \return The number of bytes written, which may be short on error. - */ -size_t Terminal::write(const uint8_t *buffer, size_t size) -{ - return _stream ? _stream->write(buffer, size) : 0; -} - -/** - * \brief Writes a static string that is stored in program memory. - * - * \param str Points to the NUL-terminated string in program memory. - * - * This is a convenience function for printing static strings that - * are stored in program memory. - * - * \sa write() - */ -void Terminal::writeProgMem(const char *str) -{ - uint8_t buffer[16]; - uint8_t posn; - uint8_t ch; - if (!_stream || !str) - return; - posn = 0; - while ((ch = pgm_read_byte((const uint8_t *)str)) != 0) { - buffer[posn++] = ch; - if (posn == sizeof(buffer)) { - _stream->write(buffer, posn); - posn = 0; - } - ++str; - } - if (posn != 0) - _stream->write(buffer, posn); -} - -/** - * \brief Determine if a character starts an escape sequence after ESC. - * - * \param ch The character to test. - * - * \return Returns true if \a ch starts an escape sequence; false otherwise. - */ -static bool escapeSequenceStart(int ch) -{ - if (ch == '[' || ch == '?') - return true; - else if (ch >= 'A' && ch <= 'Z') - return true; - else - return false; -} - -/** - * \brief Reads the next key that was typed on this terminal. - * - * \return Returns -1 if there is no key ready yet; 0x00 to 0x7F for - * an ASCII character; KEY_UNICODE for an extended Unicode code point, - * or a USB keyboard code for special arrow or function keys. - * - * For example, if the user types the Home key, then this function - * will return KEY_HOME. If the user types the capital letter A, - * then this function will return 0x41. - * - * If the user types an extended Unicode character (U+0080 and higher), - * then this function will return KEY_UNICODE. The application should - * call unicodeKey() to retrieve the actual code point. All Unicode - * characters are assumed to be in the UTF-8 encoding on the stream. - * - * Some ASCII control characters correspond to special keys and will - * be mapped appropriately: - * - * \li 0x08 (CTRL-H) and 0x7F (DEL) are mapped to KEY_BACKSPACE - * \li 0x0D (CTRL-M) and 0x0A (CTRL-J) are mapped to KEY_RETURN - * \li 0x09 (CTRL-I) is mapped to KEY_TAB - * \li 0x1B (CTRL-[) is mapped to KEY_ESCAPE - * - * In all of these cases, the original ASCII code will be reported - * by unicodeKey(). As a special case, if 0x0D is immediately followed - * by 0x0A (that is, CRLF) then KEY_RETURN will be reported only once - * with unicodeKey() set to 0x0D. This ensures that all line ending - * types are mapped to a single KEY_RETURN report. - * - * If the window size has changed due to a remote event, then KEY_WINSIZE - * will be returned. This can allow the caller to clear and redraw the - * window in the new size. - * - * \sa unicodeKey(), read() - */ -int Terminal::readKey() -{ - int ch; - - // Bail out if there is no underlying stream. - if (!_stream) - return -1; - - // Read the next character and bail out if nothing yet. Some special - // peek-ahead handling is needed just after the ESC character. - if (state == STATE_ESC) { - ch = _stream->peek(); - if (ch < 0) { - // We just saw an ESC. If there has been a timeout - // then the key is KEY_ESC rather than the start of a - // VT100 escape sequence. - if ((millis() - timer) >= ESC_TIMEOUT_MS) { - state = STATE_INIT; - ucode = 0x1B; - return KEY_ESC; - } - ucode = -1; - return -1; - } else if (!escapeSequenceStart(ch)) { - // The next character is not legitimate as the start of - // an escape sequence, so the ESC must have been KEY_ESC. - state = STATE_INIT; - ucode = 0x1B; - return KEY_ESC; - } else { - // Part of an escape sequence. Read the character properly. - ch = _stream->read(); - } - } else { - // Read the next character without any peek-ahead. - ch = _stream->read(); - } - if (ch < 0) { - if (state == STATE_MATCH && (millis() - timer) >= SEQ_TIMEOUT_MS) { - // Timeout while waiting for the next character in an - // escape sequence. Abort and return to the initial state. - state = STATE_INIT; - } - ucode = -1; - return -1; - } - - // Determine what to do based on the key recognition state. - switch (state) { - case STATE_CR: - // We just saw a CR, so check for CRLF and eat the LF. - state = STATE_INIT; - if (ch == 0x0A) { - ucode = -1; - return -1; - } else if (ch == 0x00 && mod == Telnet) { - // In telnet mode, CR NUL is a literal carriage return, - // separate from the newline sequence CRLF. Eat the NUL. - // We already reported KEY_RETURN for the CR character. - ucode = -1; - return -1; - } - // Fall through to the next case. - - case STATE_INIT: - if (ch >= 0x20 && ch <= 0x7E) { - // Printable ASCII character. - state = STATE_INIT; - ucode = ch; - return ch; - } else if (ch == 0x1B) { - // Start of an escape sequence, or the escape character itself. - state = STATE_ESC; - timer = millis(); - } else if (ch == 0x0D) { - // CR which may be followed by an LF. - state = STATE_CR; - ucode = ch; - return KEY_RETURN; - } else if (ch == 0x0A) { - // LF on its own without a preceding CR. - ucode = ch; - return KEY_RETURN; - } else if (ch == 0x08 || ch == 0x7F) { - // Backspace or DEL character. - state = STATE_INIT; - ucode = ch; - return KEY_BACKSPACE; - } else if (ch == 0x09) { - // TAB character. - state = STATE_INIT; - ucode = ch; - return KEY_TAB; - } else if (ch < 0x80) { - // Some other ASCII control character. - state = STATE_INIT; - ucode = ch; - return ch; - } else if (ch >= 0xC1 && ch <= 0xDF) { - // Two-byte UTF-8 sequence. - offset = ch & 0x1F; - utf8len = 2; - state = STATE_UTF8; - } else if (ch >= 0xE1 && ch <= 0xEF) { - // Three-byte UTF-8 sequence. - offset = ch & 0x0F; - utf8len = 3; - state = STATE_UTF8; - } else if (ch >= 0xF1 && ch <= 0xF7) { - // Four-byte UTF-8 sequence. - offset = ch & 0x07; - utf8len = 4; - state = STATE_UTF8; - } else if (ch == 0xFF && mod == Telnet) { - // Start of a telnet command (IAC byte). - state = STATE_IAC; - } - break; - - case STATE_ESC: - // Next character just after the ESC. Start the escape - // sequence matching engine at offset zero in the keymap table. - state = STATE_MATCH; - offset = 0; - // Fall through to the next case. - - case STATE_MATCH: - // In the middle of matching an escape sequence. - if (ch == 0x1B) { - // ESC character seen in the middle of an escape sequence. - // The previous escape sequence is invalid so abort and restart. - state = STATE_ESC; - timer = millis(); - break; - } - ch = matchEscape(ch); - if (ch == -1) { - // Need more characters before knowing what this is. - timer = millis(); - } else if (ch == -2) { - // Invalid escape sequence so abort and restart. - state = STATE_INIT; - } else if (ch < 0x80) { - // Escape sequence corresponds to a normal ASCII character. - state = STATE_INIT; - ucode = ch; - return ch; - } else { - // Extended keycode for an arrow or function key. - state = STATE_INIT; - ucode = -1; - return ch; - } - break; - - case STATE_UTF8: - // Recognize a multi-byte UTF-8 character encoding. - if ((ch & 0xC0) == 0x80) { - if (utf8len <= 2) { - // Final character in the sequence. - ucode = (((long)offset) << 6) | (ch & 0x3F); - state = STATE_INIT; - if (ucode > 0x10FFFFL) - break; // The code point is out of range. - return KEY_UNICODE; - } else { - // More characters still yet to come. - --utf8len; - offset = (offset << 6) | (ch & 0x3F); - } - } else { - // This character is invalid as part of a UTF-8 sequence. - state = STATE_INIT; - } - break; - - case STATE_IAC: - // Telnet command byte just after an IAC (0xFF) character. - switch (ch) { - case TelnetDefs::EndOfFile: - // Convert EOF into CTRL-D. - state = STATE_INIT; - ucode = 0x04; - return 0x04; - - case TelnetDefs::EndOfRecord: - // Convert end of record markers into CR. - state = STATE_INIT; - ucode = 0x0D; - return KEY_RETURN; - - case TelnetDefs::Interrupt: - // Convert interrupt into CTRL-C. - state = STATE_INIT; - ucode = 0x03; - return 0x03; - - case TelnetDefs::EraseChar: - // Convert erase character into DEL. - state = STATE_INIT; - ucode = 0x7F; - return KEY_BACKSPACE; - - case TelnetDefs::EraseLine: - // Convert erase line into CTRL-U. - state = STATE_INIT; - ucode = 0x15; - return 0x15; - - case TelnetDefs::SubStart: - // Option sub-negotiation. - utf8len = 0; - state = STATE_SB; - break; - - case TelnetDefs::WILL: - // Option negotiation, WILL command. - state = STATE_WILL; - break; - - case TelnetDefs::WONT: - // Option negotiation, WONT command. - state = STATE_WONT; - break; - - case TelnetDefs::DO: - // Option negotiation, DO command. - state = STATE_DO; - break; - - case TelnetDefs::DONT: - // Option negotiation, DONT command. - state = STATE_DONT; - break; - - case TelnetDefs::IAC: - // IAC followed by IAC is the literal byte 0xFF, - // but that isn't valid UTF-8 so we just drop it. - state = STATE_INIT; - break; - - default: - // Everything else is treated as a NOP. - state = STATE_INIT; - break; - } - break; - - case STATE_WILL: - // Telnet option negotiation, WILL command. Note: We don't do any - // loop detection. We assume that the client will eventually break - // the loop as it probably has more memory than us to store state. - if (ch == TelnetDefs::WindowSize || - ch == TelnetDefs::RemoteFlowControl) { - // Send a DO command in response - we accept this option. - telnetCommand(TelnetDefs::DO, ch); - } else { - // Send a DONT command in response - we don't accept this option. - telnetCommand(TelnetDefs::DONT, ch); - } - if (!(flags & 0x01)) { - // The first time we see a WILL command from the client we - // send a request back saying that we will handle echoing. - flags |= 0x01; - telnetCommand(TelnetDefs::WILL, TelnetDefs::Echo); - } - state = STATE_INIT; - break; - - case STATE_WONT: - case STATE_DONT: - // Telnet option negotiation, WONT/DONT command. The other side - // is telling us that it does not understand this option or wants - // us to stop using it. For now there is nothing to do. - state = STATE_INIT; - break; - - case STATE_DO: - // Telnet option negotiation, DO command. Note: Other than Echo - // we don't do any loop detection. We assume that the client will - // break the loop as it probably has more memory than us to store state. - if (ch == TelnetDefs::Echo) { - // Special handling needed for Echo - don't say WILL again - // when the client acknowledges us with a DO command. - } else if (ch == TelnetDefs::SuppressGoAhead) { - // Send a WILL command in response - we accept this option. - telnetCommand(TelnetDefs::WILL, ch); - } else { - // Send a WONT command in response - we don't accept this option. - telnetCommand(TelnetDefs::WONT, ch); - } - state = STATE_INIT; - break; - - case STATE_SB: - // Telnet option sub-negotiation. Collect up all bytes and - // then execute the option once "IAC SubEnd" is seen. - if (ch == TelnetDefs::IAC) { - // IAC byte, which will be followed by either IAC or SubEnd. - state = STATE_SB_IAC; - break; - } - if (utf8len < sizeof(sb)) - sb[utf8len++] = ch; - break; - - case STATE_SB_IAC: - // Telnet option sub-negotiation, byte after IAC. - if (ch == TelnetDefs::IAC) { - // Two IAC bytes in a row is a single escaped 0xFF byte. - if (utf8len < sizeof(sb)) - sb[utf8len++] = 0xFF; - state = STATE_SB; - break; - } else if (ch == TelnetDefs::SubEnd) { - // End of the sub-negotiation field. Handle window size changes. - if (utf8len >= 5 && sb[0] == TelnetDefs::WindowSize) { - int width = (((int)(sb[1])) << 8) | sb[2]; - int height = (((int)(sb[3])) << 8) | sb[4]; - if (!width) // Zero width or height means "unspecified". - width = ncols; - if (!height) - height = nrows; - if (setWindowSize(width, height)) { - // The window size has changed; notify the caller. - ucode = -1; - state = STATE_INIT; - return KEY_WINSIZE; - } - } - } - state = STATE_INIT; - break; - } - - // If we get here, then we're still waiting for a full sequence. - ucode = -1; - return -1; -} - -/** - * \fn long Terminal::unicodeKey() const - * \brief Gets the Unicode version of the last key returned by readKey(). - * - * If readKey() returned an ASCII character (0x00 to 0x7F) or KEY_UNICODE, - * then this function can be used to query the full Unicode code point for - * the key that was typed. If some other key is typed, or no key was - * typed, then this function will return -1. - * - * Unicode code points range between 0 and 0x10FFFF. - * - * \sa readKey(), writeUnicode() - */ - -/** - * \brief Writes a Unicode code point to the output in UTF-8 encoding. - * - * \param code The code point to be written between 0 and 0x10FFFF. - * \return The number of bytes that were written to the underlying stream - * to represent \a code. Returns zero if \a code is not a valid code point. - * - * This function is useful when a specific Unicode character is desired; - * for example the code point 0x2264 corresponds to the less than or - * equal to operator "≤". See the Unicode standard for more information. - * - * Unicode characters between 0x00 and 0x7F and strings that are already - * in the UTF-8 encoding can also be written using write(). - * - * \sa write() - */ -size_t Terminal::writeUnicode(long code) -{ - uint8_t utf8[4]; - size_t size = utf8Format(utf8, code); - if (size > 0) - write(utf8, size); - return size; -} - -/** - * \fn int Terminal::columns() const - * \brief Gets the number of columns in the window; defaults to 80. - * - * \sa rows(), setWindowSize(), cursorMove() - */ - -/** - * \fn int Terminal::rows() const - * \brief Gets the number of rows in the window; defaults to 24. - * - * \sa columns(), setWindowSize(), cursorMove() - */ - -/** - * \brief Sets the number of columns and rows in the window. - * - * \param columns The number of columns between 1 and 10000. - * \param rows The number of rows between 1 and 10000. - * - * \return Returns true if the window size has changed. - * - * This function should be used if the application has some information - * about the actual window size. For serial ports, this usually isn't - * available but telnet and ssh sessions can get the window size from - * the remote host. - * - * The window size defaults to 80x24 which is the standard default for - * terminal programs like PuTTY that emulate a VT100. - * - * If the window size changes due to a remote event, readKey() will - * return KEY_WINSIZE to inform the application. - * - * \sa columns(), rows(), readKey() - */ -bool Terminal::setWindowSize(int columns, int rows) -{ - // Sanity-check the range first. - if (columns < 1) - columns = 1; - else if (columns > 10000) - columns = 10000; - if (rows < 1) - rows = 1; - else if (rows > 10000) - rows = 10000; - if (ncols != columns || nrows != rows) { - ncols = columns; - nrows = rows; - return true; - } else { - return false; - } -} - -/** - * \brief Move the cursor to the top-left position and clear the screen. - */ -void Terminal::clear() -{ - static char const escape[] PROGMEM = "\033[H\033[J"; - writeProgMem(escape); -} - -/** - * \brief Clears from the current cursor position to the end of the line. - */ -void Terminal::clearToEOL() -{ - static char const escape[] PROGMEM = "\033[K"; - writeProgMem(escape); -} - -// Writes a decimal number to a buffer. -static void writeNumber(uint8_t *buf, uint8_t &posn, int value) -{ - int divisor = 10000; - bool haveDigits = false; - while (divisor >= 1) { - int digit = value / divisor; - if (digit || haveDigits) { - buf[posn++] = '0' + digit; - haveDigits = true; - } - value %= divisor; - divisor /= 10; - } - if (!haveDigits) { - buf[posn++] = '0'; - } -} - -/** - * \brief Moves the cursor to a specific location in the window. - * - * \param x The x position for the cursor between 0 and columns() - 1. - * \param y The y position for the cursor between 0 and rows() - 1. - * - * \sa cursorLeft(), columns(), rows(), setWindowSize() - */ -void Terminal::cursorMove(int x, int y) -{ - if (!_stream) - return; - - // Range check the arguments. - if (x < 0) - x = 0; - else if (x >= ncols) - x = ncols - 1; - if (y < 0) - y = 0; - else if (y >= nrows) - y = nrows - 1; - - // Format the command "ESC[row;colH" and send it. - uint8_t buffer[16]; - uint8_t posn = 0; - buffer[posn++] = 0x1B; - buffer[posn++] = '['; - writeNumber(buffer, posn, y + 1); - buffer[posn++] = ';'; - writeNumber(buffer, posn, x + 1); - buffer[posn++] = 'H'; - _stream->write(buffer, posn); -} - -/** - * \brief Moves the cursor left by one character. - * - * \sa cursorRight(), cursorUp(), cursorDown(), cursorMove() - */ -void Terminal::cursorLeft() -{ - static char const escape[] PROGMEM = "\033[D"; - writeProgMem(escape); -} - -/** - * \brief Moves the cursor right by one character. - * - * \sa cursorLeft(), cursorUp(), cursorDown(), cursorMove() - */ -void Terminal::cursorRight() -{ - static char const escape[] PROGMEM = "\033[C"; - writeProgMem(escape); -} - -/** - * \brief Moves the cursor up by one line. - * - * \sa cursorDown(), cursorLeft(), cursorRight(), cursorMove() - */ -void Terminal::cursorUp() -{ - static char const escape[] PROGMEM = "\033[A"; - writeProgMem(escape); -} - -/** - * \brief Moves the cursor down by one line. - * - * \sa cursorUp(), cursorLeft(), cursorRight(), cursorMove() - */ -void Terminal::cursorDown() -{ - static char const escape[] PROGMEM = "\033[B"; - writeProgMem(escape); -} - -/** - * \brief Backspaces over the last character. - * - * This function prints CTRL-H, a space, and another CTRL-H to backspace - * over and erase the last character on the current line. - * - * If the last character was a wide Unicode character, then two calls to - * this function are required to erase it. See isWideCharacter() for - * more information. - * - * \sa isWideCharacter() - */ -void Terminal::backspace() -{ - static char const escape[] PROGMEM = "\b \b"; - writeProgMem(escape); -} - -/** - * \brief Inserts a line at the cursor position. - * - * \sa insertChar(), deleteLine() - */ -void Terminal::insertLine() -{ - static char const escape[] PROGMEM = "\033[L"; - writeProgMem(escape); -} - -/** - * \brief Inserts a blank character at the cursor position. - * - * \sa insertLine(), deleteChar() - */ -void Terminal::insertChar() -{ - static char const escape[] PROGMEM = "\033[@"; - writeProgMem(escape); -} - -/** - * \brief Deletes a line at the cursor position. - * - * \sa deleteChar(), insertLine() - */ -void Terminal::deleteLine() -{ - static char const escape[] PROGMEM = "\033[M"; - writeProgMem(escape); -} - -/** - * \brief Deletes the character at the cursor position. - * - * \sa deleteLine(), insertChar() - */ -void Terminal::deleteChar() -{ - static char const escape[] PROGMEM = "\033[P"; - writeProgMem(escape); -} - -/** - * \brief Scrolls the contents of the window up one line. - * - * \sa scrollDown() - */ -void Terminal::scrollUp() -{ - static char const escape[] PROGMEM = "\033[S"; - writeProgMem(escape); -} - -/** - * \brief Scrolls the contents of the window down one line. - * - * \sa scrollUp() - */ -void Terminal::scrollDown() -{ - static char const escape[] PROGMEM = "\033[T"; - writeProgMem(escape); -} - -/** - * \brief Selects normal text with all attributes and colors off. - * - * \sa color(), bold(), underline(), blink(), reverse() - */ -void Terminal::normal() -{ - static char const escape[] PROGMEM = "\033[0m"; - writeProgMem(escape); -} - -/** - * \brief Enables bold text. - * - * \sa normal() - */ -void Terminal::bold() -{ - static char const escape[] PROGMEM = "\033[1m"; - writeProgMem(escape); -} - -/** - * \brief Enables underlined text. - */ -void Terminal::underline() -{ - static char const escape[] PROGMEM = "\033[4m"; - writeProgMem(escape); -} - -/** - * \brief Enables blinking text. - */ -void Terminal::blink() -{ - static char const escape[] PROGMEM = "\033[5m"; - writeProgMem(escape); -} - -/** - * \brief Reverse the foreground and background colors for inverted text. - */ -void Terminal::reverse() -{ - static char const escape[] PROGMEM = "\033[7m"; - writeProgMem(escape); -} - -/** - * \enum Terminal::Color - * \brief Terminal foreground or background colors. - */ - -/** - * \var Terminal::Black - * \brief Color is black. - */ - -/** - * \var Terminal::DarkRed - * \brief Color is dark red. - */ - -/** - * \var Terminal::DarkGreen - * \brief Color is dark green. - */ - -/** - * \var Terminal::DarkYellow - * \brief Color is dark yellow. - */ - -/** - * \var Terminal::DarkBlue - * \brief Color is dark blue. - */ - -/** - * \var Terminal::DarkMagenta - * \brief Color is dark magenta. - */ - -/** - * \var Terminal::DarkCyan - * \brief Color is dark cyan. - */ - -/** - * \var Terminal::LightGray - * \brief Color is light gray. - */ - -/** - * \var Terminal::DarkGray - * \brief Color is dark gray. - */ - -/** - * \var Terminal::Red - * \brief Color is light red. - */ - -/** - * \var Terminal::Green - * \brief Color is light green. - */ - -/** - * \var Terminal::Yellow - * \brief Color is light yellow. - */ - -/** - * \var Terminal::Blue - * \brief Color is light blue. - */ - -/** - * \var Terminal::Magenta - * \brief Color is light magenta. - */ - -/** - * \var Terminal::Cyan - * \brief Color is light cyan. - */ - -/** - * \var Terminal::White - * \brief Color is white. - */ - -/** - * \brief Selects a text foreground color with the default background color. - * - * \param fg The foreground color to select. - * - * All other text attributes (reverse, underline, etc) are disabled. - * - * The following example displays a warning string with the initial - * word in red and all following words in normal text: - * - * \code - * term.color(Terminal::Red); - * term.print("WARNING: "); - * term.normal(); - * term.println("All files on the SD card will be deleted!"); - * \endcode - * - * \sa normal() - */ -void Terminal::color(Color fg) -{ - uint8_t code = (fg & 0x07); - uint8_t bold = (fg & 0x08) ? 1 : 0; - if (!_stream) - return; - uint8_t buffer[16]; - uint8_t posn = 0; - buffer[posn++] = 0x1B; - buffer[posn++] = '['; - buffer[posn++] = '0'; // reset all attributes first - buffer[posn++] = ';'; - buffer[posn++] = '3'; - buffer[posn++] = '0' + code; - if (bold) { - buffer[posn++] = ';'; - buffer[posn++] = '1'; - } - buffer[posn++] = 'm'; - _stream->write(buffer, posn); -} - -/** - * \brief Selects text foreground and background colors. - * - * \param fg The foreground color to select. - * \param bg The background color to select. - * - * All other text attributes (reverse, underline, etc) are disabled. - * - * \sa normal() - */ -void Terminal::color(Color fg, Color bg) -{ - uint8_t codefg = (fg & 0x07); - uint8_t boldfg = (fg & 0x08) ? 1 : 0; - uint8_t codebg = (bg & 0x07); - if (!_stream) - return; - uint8_t buffer[16]; - uint8_t posn = 0; - buffer[posn++] = 0x1B; - buffer[posn++] = '['; - buffer[posn++] = '0'; // reset all attributes first - buffer[posn++] = ';'; - buffer[posn++] = '3'; - buffer[posn++] = '0' + codefg; - if (boldfg) { - buffer[posn++] = ';'; - buffer[posn++] = '1'; - } - buffer[posn++] = ';'; - buffer[posn++] = '4'; - buffer[posn++] = '0' + codebg; - buffer[posn++] = 'm'; - _stream->write(buffer, posn); -} - -/** - * \brief Determine if a Unicode character is wide. - * - * \param code The code point for the Unicode character. - * \return Returns true if \a code is a wide character, false otherwise. - * - * Wide characters typically come from East Asian languages and occupy - * two spaces in a terminal. Two calls to backspace() are required to - * erase such characters. - * - * References: http://www.unicode.org/reports/tr11/, - * http://www.unicode.org/Public/UCD/latest/ucd/EastAsianWidth.txt - * - * \sa backspace(), writeUnicode() - */ -bool Terminal::isWideCharacter(long code) -{ - // This function was automatically generated by genwcwidth.c - static unsigned char const range3000[32] PROGMEM = { - 0xF1, 0xFF, 0xF3, 0x3F, 0x01, 0x00, 0x01, 0x78, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88 - }; - static unsigned char const rangeFE00[64] PROGMEM = { - 0x00, 0x00, 0x80, 0x03, 0x00, 0x00, 0xE1, 0xFF, - 0x9F, 0x01, 0x00, 0x7F, 0x0C, 0x03, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x10, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, - 0x01, 0x00, 0x00, 0xF8, 0x01, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00 - }; - unsigned c; - if (code < 0x2300) { - return false; - } else if (code >= 0x3000 && code <= 0x30FF) { - c = (unsigned)(code - 0x3000); - return (pgm_read_byte(range3000 + (c / 8)) & (1 << (c % 8))) != 0; - } else if (code >= 0xFE00 && code <= 0xFFFF) { - c = (unsigned)(code - 0xFE00); - return (pgm_read_byte(rangeFE00 + (c / 8)) & (1 << (c % 8))) != 0; - } else if (code >= 0x3400 && code <= 0x4DBF) { - return true; - } else if (code >= 0x4E00 && code <= 0x9FFF) { - return true; - } else if (code >= 0xF900 && code <= 0xFAFF) { - return true; - } else if (code >= 0x20000 && code <= 0x2FFFD) { - return true; - } else if (code >= 0x30000 && code <= 0x3FFFD) { - return true; - } else if (code == 0x2329 || - code == 0x232A || - code == 0x3250 || - code == 0xA015) { - return true; - } - return false; -} -/** - * \brief Determines the length of a Unicode code point in the UTF-8 encoding. - * - * \param code The code point to be written between 0 and 0x10FFFF. - * \return The number of bytes that makes up the UTF-8 encoding of \a code. - * Returns zero if \a code is not a valid code point. - * - * \sa utf8Format(), writeUnicode() - */ -size_t Terminal::utf8Length(long code) -{ - // Reference: https://tools.ietf.org/html/rfc3629 - if (code < 0) { - return 0; - } else if (code <= 0x7FL) { - return 1; - } else if (code <= 0x07FFL) { - return 2; - } else if (code >= 0xD800L && code <= 0xDFFF) { - // UTF-16 surrogate pairs are not valid in UTF-8. - return 0; - } else if (code <= 0xFFFFL) { - return 3; - } else if (code <= 0x10FFFFL) { - return 4; - } else { - return 0; - } -} - -/** - * \brief Formats a Unicode code point in a buffer in the UTF-8 encoding. - * - * \param buffer The buffer to write the UTF-8 encoding to. At most 4 - * bytes will be written to this buffer. - * \param code The code point to be written between 0 and 0x10FFFF. - * \return The number of bytes that were written to \a buffer to represent - * \a code. Returns zero if \a code is not a valid code point. - * - * \sa utf8Length(), writeUnicode() - */ -size_t Terminal::utf8Format(uint8_t *buffer, long code) -{ - // Reference: https://tools.ietf.org/html/rfc3629 - if (code < 0) { - return 0; - } else if (code <= 0x7FL) { - buffer[0] = (uint8_t)code; - return 1; - } else if (code <= 0x07FFL) { - buffer[0] = 0xC0 | (uint8_t)(code >> 6); - buffer[1] = 0x80 | (((uint8_t)code) & 0x3F); - return 2; - } else if (code >= 0xD800L && code <= 0xDFFF) { - // UTF-16 surrogate pairs are not valid in UTF-8. - return 0; - } else if (code <= 0xFFFFL) { - buffer[0] = 0xE0 | (uint8_t)(code >> 12); - buffer[1] = 0x80 | (((uint8_t)(code >> 6)) & 0x3F); - buffer[2] = 0x80 | (((uint8_t)code) & 0x3F); - return 3; - } else if (code <= 0x10FFFFL) { - buffer[0] = 0xF0 | (uint8_t)(code >> 18); - buffer[1] = 0x80 | (((uint8_t)(code >> 12)) & 0x3F); - buffer[2] = 0x80 | (((uint8_t)(code >> 6)) & 0x3F); - buffer[3] = 0x80 | (((uint8_t)code) & 0x3F); - return 4; - } else { - return 0; - } -} - -// Keymap rule table. Compact representation of a recognition tree. -// Each tree node is an array of entries of the following forms: -// 0 End of this tree level. -// ch code Leaf node: ASCII character (bit 7 clear) plus 8-bit keycode. -// ch offset Interior node: ASCII character with the high bit set -// plus a 16-bit offset to the first child node. -// This table was generated with the "genkeymap" tool. Do not edit this -// table but rather edit the tool and rebuild the table from it. -static uint8_t const keymap[459] PROGMEM = { - 0xDB, 0x1A, 0x00, 0xCF, 0x57, 0x01, 0x41, 0xDA, 0x42, 0xD9, 0x43, 0xD7, - 0x44, 0xD8, 0xBF, 0xA2, 0x01, 0x50, 0xC2, 0x51, 0xC3, 0x52, 0xC4, 0x53, - 0xC5, 0x00, 0x41, 0xDA, 0x42, 0xD9, 0x43, 0xD7, 0x44, 0xD8, 0x48, 0xD2, - 0xB1, 0x42, 0x00, 0x46, 0xD5, 0xB4, 0xC9, 0x00, 0xB2, 0xCC, 0x00, 0xB3, - 0x2B, 0x01, 0xB5, 0x46, 0x01, 0xB6, 0x49, 0x01, 0xDB, 0x4C, 0x01, 0x5A, - 0x0B, 0x50, 0xD0, 0x47, 0xE5, 0x00, 0x7E, 0xD2, 0xB1, 0x5D, 0x00, 0xB2, - 0x6C, 0x00, 0xB3, 0x7B, 0x00, 0xB4, 0x88, 0x00, 0xB5, 0x95, 0x00, 0xB7, - 0xA2, 0x00, 0xB8, 0xAF, 0x00, 0xB9, 0xBC, 0x00, 0x00, 0x7E, 0xC2, 0xBB, - 0x65, 0x00, 0x5E, 0xFA, 0x00, 0xB2, 0x69, 0x00, 0x00, 0x7E, 0xF0, 0x00, - 0x7E, 0xC3, 0xBB, 0x74, 0x00, 0x5E, 0xFB, 0x00, 0xB2, 0x78, 0x00, 0x00, - 0x7E, 0xF1, 0x00, 0x7E, 0xC4, 0xBB, 0x81, 0x00, 0x00, 0xB2, 0x85, 0x00, - 0x00, 0x7E, 0xF2, 0x00, 0x7E, 0xC5, 0xBB, 0x8E, 0x00, 0x00, 0xB2, 0x92, - 0x00, 0x00, 0x7E, 0xF3, 0x00, 0x7E, 0xC6, 0xBB, 0x9B, 0x00, 0x00, 0xB2, - 0x9F, 0x00, 0x00, 0x7E, 0xF4, 0x00, 0x7E, 0xC7, 0xBB, 0xA8, 0x00, 0x00, - 0xB2, 0xAC, 0x00, 0x00, 0x7E, 0xF5, 0x00, 0x7E, 0xC8, 0xBB, 0xB5, 0x00, - 0x00, 0xB2, 0xB9, 0x00, 0x00, 0x7E, 0xF6, 0x00, 0x7E, 0xC9, 0xBB, 0xC2, - 0x00, 0x00, 0xB2, 0xC6, 0x00, 0x00, 0x7E, 0xF7, 0x00, 0x7E, 0xD5, 0x00, - 0x7E, 0xD1, 0xB0, 0xE7, 0x00, 0xB1, 0xF4, 0x00, 0xB3, 0x01, 0x01, 0xB4, - 0x10, 0x01, 0xB5, 0x1F, 0x01, 0xB6, 0x22, 0x01, 0xB8, 0x25, 0x01, 0xB9, - 0x28, 0x01, 0x00, 0x7E, 0xCA, 0xBB, 0xED, 0x00, 0x00, 0xB2, 0xF1, 0x00, - 0x00, 0x7E, 0xF8, 0x00, 0x7E, 0xCB, 0xBB, 0xFA, 0x00, 0x00, 0xB2, 0xFE, - 0x00, 0x00, 0x7E, 0xF9, 0x00, 0x7E, 0xCC, 0x24, 0xF8, 0xBB, 0x09, 0x01, - 0x00, 0xB2, 0x0D, 0x01, 0x00, 0x7E, 0xFA, 0x00, 0x7E, 0xCD, 0x24, 0xF9, - 0xBB, 0x18, 0x01, 0x00, 0xB2, 0x1C, 0x01, 0x00, 0x7E, 0xFB, 0x00, 0x7E, - 0xF0, 0x00, 0x7E, 0xF1, 0x00, 0x7E, 0xF2, 0x00, 0x7E, 0xF3, 0x00, 0x7E, - 0xD4, 0xB1, 0x3A, 0x01, 0xB2, 0x3D, 0x01, 0xB3, 0x40, 0x01, 0xB4, 0x43, - 0x01, 0x00, 0x7E, 0xF4, 0x00, 0x7E, 0xF5, 0x00, 0x7E, 0xF6, 0x00, 0x7E, - 0xF7, 0x00, 0x7E, 0xD3, 0x00, 0x7E, 0xD6, 0x00, 0x41, 0xC2, 0x42, 0xC3, - 0x43, 0xC4, 0x44, 0xC5, 0x45, 0xC6, 0x00, 0x41, 0xDA, 0x42, 0xD9, 0x43, - 0xD7, 0x44, 0xD8, 0x48, 0xD2, 0x46, 0xD5, 0x20, 0x20, 0x49, 0xB3, 0x4D, - 0xB0, 0x6A, 0x2A, 0x6B, 0x2B, 0x6C, 0x2C, 0x6D, 0x2D, 0x6E, 0x2E, 0x6F, - 0x2F, 0x70, 0x30, 0x71, 0x31, 0x72, 0x32, 0x73, 0x33, 0x74, 0x34, 0x75, - 0x35, 0x76, 0x36, 0x77, 0x37, 0x78, 0x38, 0x79, 0x39, 0x58, 0x3D, 0x50, - 0xC2, 0x51, 0xC3, 0x52, 0xC4, 0x53, 0xC5, 0xB2, 0x99, 0x01, 0x5A, 0x0B, - 0x00, 0x50, 0xF0, 0x51, 0xF1, 0x52, 0xF2, 0x53, 0xF3, 0x00, 0x20, 0x20, - 0x49, 0xB3, 0x4D, 0xB0, 0x6A, 0x2A, 0x6B, 0x2B, 0x6C, 0x2C, 0x6D, 0x2D, - 0x6E, 0x2E, 0x6F, 0x2F, 0x70, 0x30, 0x71, 0x31, 0x72, 0x32, 0x73, 0x33, - 0x74, 0x34, 0x75, 0x35, 0x76, 0x36, 0x77, 0x37, 0x78, 0x38, 0x79, 0x39, - 0x58, 0x3D, 0x00 -}; - -/** - * \brief Matches the next character in an escape sequence. - * - * \param ch The next character to match. - * \return -1 if more characters are required, -2 if the escape sequence - * is invalid, or a positive key code if the match is complete. - */ -int Terminal::matchEscape(int ch) -{ - uint8_t kch; - for (;;) { - kch = pgm_read_byte(keymap + offset); - if (!kch) { - // No match at this level, so the escape sequence is invalid. - break; - } else if (kch & 0x80) { - // Interior node. - if ((kch & 0x7F) == ch) { - // Interior node matches. Go down one tree level. - offset = ((int)(pgm_read_byte(keymap + offset + 1))) | - (((int)(pgm_read_byte(keymap + offset + 2))) << 8); - return -1; - } - offset += 3; - } else { - // Leaf node. - if (kch == (uint8_t)ch) { - // We have found a match on a full escape sequence. - return pgm_read_byte(keymap + offset + 1); - } - offset += 2; - } - } - return -2; -} - -/** - * \brief Sends a telnet command to the client. - * - * \param type The type of command: WILL, WONT, DO, or DONT. - * \param option The telnet option the command applies to. - */ -void Terminal::telnetCommand(uint8_t type, uint8_t option) -{ - uint8_t buf[3]; - buf[0] = (uint8_t)TelnetDefs::IAC; - buf[1] = type; - buf[2] = option; - _stream->write(buf, 3); -} diff --git a/libraries/Shell/Terminal.h b/libraries/Shell/Terminal.h deleted file mode 100644 index b60a8f71..00000000 --- a/libraries/Shell/Terminal.h +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (C) 2016 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#ifndef TERMINAL_h -#define TERMINAL_h - -#include -#include -#include "USBKeysExtra.h" - -// Special key code that indicates that unicodeKey() contains the actual code. -#define KEY_UNICODE 0x1000 - -// Special key code that indicates that the window size has changed. -#define KEY_WINSIZE 0x1001 - -class Terminal : public Stream -{ -public: - Terminal(); - virtual ~Terminal(); - - enum Mode - { - Serial, - Telnet - }; - - void begin(Stream &stream, Mode mode = Serial); - void end(); - - Stream *stream() const { return _stream; } - Terminal::Mode mode() const { return (Terminal::Mode)mod; } - - virtual int available(); - virtual int peek(); - virtual int read(); - - virtual void flush(); - - virtual size_t write(uint8_t c); - virtual size_t write(const uint8_t *buffer, size_t size); - using Stream::write; - - void writeProgMem(const char *str); - - int readKey(); - - long unicodeKey() const { return ucode; } - - size_t writeUnicode(long code); - - int columns() const { return ncols; } - int rows() const { return nrows; } - - bool setWindowSize(int columns, int rows); - - void clear(); - void clearToEOL(); - - void cursorMove(int x, int y); - void cursorLeft(); - void cursorRight(); - void cursorUp(); - void cursorDown(); - - void backspace(); - - void insertLine(); - void insertChar(); - void deleteLine(); - void deleteChar(); - - void scrollUp(); - void scrollDown(); - - void normal(); - void bold(); - void underline(); - void blink(); - void reverse(); - - enum Color - { - Black = 0x00, - DarkRed = 0x01, - DarkGreen = 0x02, - DarkYellow = 0x03, - DarkBlue = 0x04, - DarkMagenta = 0x05, - DarkCyan = 0x06, - LightGray = 0x07, - DarkGray = 0x08, - Red = 0x09, - Green = 0x0A, - Yellow = 0x0B, - Blue = 0x0C, - Magenta = 0x0D, - Cyan = 0x0E, - White = 0x0F - }; - - void color(Color fg); - void color(Color fg, Color bg); - - static bool isWideCharacter(long code); - - static size_t utf8Length(long code); - static size_t utf8Format(uint8_t *buffer, long code); - -private: - Stream *_stream; - long ucode; - int ncols, nrows; - unsigned long timer; - uint16_t offset; - uint8_t state; - uint8_t utf8len; - uint8_t mod; - uint8_t sb[8]; - uint8_t flags; - - int matchEscape(int ch); - void telnetCommand(uint8_t type, uint8_t option); -}; - -#endif diff --git a/libraries/Shell/USBKeysExtra.h b/libraries/Shell/USBKeysExtra.h deleted file mode 100644 index 69d592ac..00000000 --- a/libraries/Shell/USBKeysExtra.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (C) 2016 Southern Storm Software, Pty Ltd. - * - * 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. - */ - -#ifndef USBKEYSEXTRA_h -#define USBKEYSEXTRA_h - -// Extra key codes that are not included in the standard USBAPI.h header. -// Reference: http://www.usb.org/developers/hidpage/Hut1_12v2.pdf -// Note: USBAPI.h shifts the Hut codes by adding 136 (0x88) so that -// they don't intersect with ASCII. We do that here as well so -// that these codes can be used with Keyboard.press(). We use #ifndef -// here in case the core Arduino libraries add these in the future. - -#ifndef KEY_PRINT_SCREEN -#define KEY_PRINT_SCREEN (0x46 + 0x88) -#endif -#ifndef KEY_SCROLL_LOCK -#define KEY_SCROLL_LOCK (0x47 + 0x88) -#endif -#ifndef KEY_PAUSE -#define KEY_PAUSE (0x48 + 0x88) -#endif -#ifndef KEY_NUM_LOCK -#define KEY_NUM_LOCK (0x53 + 0x88) -#endif -#ifndef KEY_NUMPAD_5 -#define KEY_NUMPAD_5 (0x5D + 0x88) -#endif -#ifndef KEY_F13 -#define KEY_F13 (0x68 + 0x88) -#endif -#ifndef KEY_F14 -#define KEY_F14 (0x69 + 0x88) -#endif -#ifndef KEY_F15 -#define KEY_F15 (0x6A + 0x88) -#endif -#ifndef KEY_F16 -#define KEY_F16 (0x6B + 0x88) -#endif -#ifndef KEY_F17 -#define KEY_F17 (0x6C + 0x88) -#endif -#ifndef KEY_F18 -#define KEY_F18 (0x6D + 0x88) -#endif -#ifndef KEY_F19 -#define KEY_F19 (0x6E + 0x88) -#endif -#ifndef KEY_F20 -#define KEY_F20 (0x6F + 0x88) -#endif -#ifndef KEY_F21 -#define KEY_F21 (0x70 + 0x88) -#endif -#ifndef KEY_F22 -#define KEY_F22 (0x71 + 0x88) -#endif -#ifndef KEY_F23 -#define KEY_F23 (0x72 + 0x88) -#endif -#ifndef KEY_F24 -#define KEY_F24 (0x73 + 0x88) -#endif - -// USB does not have a code for "Back Tab" as it is usually Shift-TAB. -// For convenience, we map it to the ASCII vertical tab character (0x0B). -#define KEY_BACK_TAB 0x0B - -#ifndef KEY_RETURN - -// If the Arduino variant does not support USB, then USBAPI.h will not -// define the key codes that we need. So we define them here instead. - -#define KEY_RETURN (0x28 + 0x88) -#define KEY_ESC (0x29 + 0x88) -#define KEY_BACKSPACE (0x2A + 0x88) -#define KEY_TAB (0x2B + 0x88) -#define KEY_CAPS_LOCK (0x39 + 0x88) -#define KEY_F1 (0x3A + 0x88) -#define KEY_F2 (0x3B + 0x88) -#define KEY_F3 (0x3C + 0x88) -#define KEY_F4 (0x3D + 0x88) -#define KEY_F5 (0x3E + 0x88) -#define KEY_F6 (0x3F + 0x88) -#define KEY_F7 (0x40 + 0x88) -#define KEY_F8 (0x41 + 0x88) -#define KEY_F9 (0x42 + 0x88) -#define KEY_F10 (0x43 + 0x88) -#define KEY_F11 (0x44 + 0x88) -#define KEY_F12 (0x45 + 0x88) -#define KEY_INSERT (0x49 + 0x88) -#define KEY_HOME (0x4A + 0x88) -#define KEY_PAGE_UP (0x4B + 0x88) -#define KEY_DELETE (0x4C + 0x88) -#define KEY_END (0x4D + 0x88) -#define KEY_PAGE_DOWN (0x4E + 0x88) -#define KEY_RIGHT_ARROW (0x4F + 0x88) -#define KEY_LEFT_ARROW (0x50 + 0x88) -#define KEY_DOWN_ARROW (0x51 + 0x88) -#define KEY_UP_ARROW (0x52 + 0x88) - -#endif - -#endif diff --git a/libraries/Shell/examples/Keys/Keys.ino b/libraries/Shell/examples/Keys/Keys.ino deleted file mode 100644 index 8bb8e7f9..00000000 --- a/libraries/Shell/examples/Keys/Keys.ino +++ /dev/null @@ -1,127 +0,0 @@ -/* -This example tests the Terminal class by displaying the VT100 keys that -are pressed. A real terminal program like PuTTY will be needed. - -This example is placed into the public domain. -*/ - -#include -#include - -Terminal term; - -#define K(name) {name, #name} -struct KeyInfo -{ - uint8_t code; - char name[19]; -}; -struct KeyInfo const keys[] PROGMEM = { - K(KEY_RETURN), - K(KEY_ESC), - K(KEY_BACKSPACE), - K(KEY_TAB), - K(KEY_BACK_TAB), - K(KEY_CAPS_LOCK), - K(KEY_F1), - K(KEY_F2), - K(KEY_F3), - K(KEY_F4), - K(KEY_F5), - K(KEY_F6), - K(KEY_F7), - K(KEY_F8), - K(KEY_F9), - K(KEY_F10), - K(KEY_F11), - K(KEY_F12), - K(KEY_F13), - K(KEY_F14), - K(KEY_F15), - K(KEY_F16), - K(KEY_F17), - K(KEY_F18), - K(KEY_F19), - K(KEY_F20), - K(KEY_F21), - K(KEY_F22), - K(KEY_F23), - K(KEY_F24), - K(KEY_INSERT), - K(KEY_HOME), - K(KEY_PAGE_UP), - K(KEY_DELETE), - K(KEY_END), - K(KEY_PAGE_DOWN), - K(KEY_RIGHT_ARROW), - K(KEY_LEFT_ARROW), - K(KEY_DOWN_ARROW), - K(KEY_UP_ARROW), - K(KEY_PRINT_SCREEN), - K(KEY_SCROLL_LOCK), - K(KEY_PAUSE), - K(KEY_NUM_LOCK), - K(KEY_NUMPAD_5), - {0, ""} -}; - -void setup() -{ - Serial.begin(9600); - term.begin(Serial); - - term.println("Press keys to see their codes ..."); - term.println(); -} - -void loop() -{ - int key = term.readKey(); - if (key >= 0x21 && key <= 0x7E) { - // Printable ASCII character. - term.print("ASCII: "); - term.write((uint8_t)key); - term.println(); - } else if (key == 0x20) { - // Space. - term.println("ASCII: SPACE"); - } else if (key == KEY_UNICODE) { - // Extended Unicode character. - term.print("Unicode: U+"); - term.print(term.unicodeKey(), 16); - term.println(); - } else if (key == KEY_WINSIZE) { - // Change in window size. - term.print("New window size: "); - term.print(term.columns()); - term.print("x"); - term.println(term.rows()); - } else if (key >= 0 && key <= 0xFF) { - // Special arrow or function key. - const uint8_t *table = (const uint8_t *)keys; - int code; - while ((code = pgm_read_byte(table)) != 0) { - if (code == key) { - term.print("Special: "); - term.writeProgMem((const char *)(table + 1)); - term.println(); - break; - } - table += sizeof(struct KeyInfo); - } - if (!code) { - // Non-printable ASCII or unknown key. - if (key < 0x20) - term.print("ASCII: 0x"); - else - term.print("Unknown: 0x"); - term.print(key, 16); - term.println(); - } - } else if (key >= 0) { - // Unknown keycode. Print in hex. - term.print("Unknown: 0x"); - term.print(key, 16); - term.println(); - } -} diff --git a/libraries/Shell/examples/SerialShell/SerialShell.ino b/libraries/Shell/examples/SerialShell/SerialShell.ino deleted file mode 100644 index 0fddb1d4..00000000 --- a/libraries/Shell/examples/SerialShell/SerialShell.ino +++ /dev/null @@ -1,35 +0,0 @@ -/* -This example demonstrates how to create a simple shell on the serial port. - -This example is placed into the public domain. -*/ - -#include - -Shell shell; - -int ledPin = 13; - -void cmdLed(Shell &shell, int argc, const ShellArguments &argv) -{ - if (argc > 1 && !strcmp(argv[1], "on")) - digitalWrite(ledPin, HIGH); - else - digitalWrite(ledPin, LOW); -} - -ShellCommand(led, "Turns the status LED on or off", cmdLed); - -void setup() -{ - pinMode(ledPin, OUTPUT); - - Serial.begin(9600); - shell.setPrompt("Command: "); - shell.begin(Serial, 5); -} - -void loop() -{ - shell.loop(); -} diff --git a/libraries/Shell/examples/TelnetServer/TelnetServer.ino b/libraries/Shell/examples/TelnetServer/TelnetServer.ino deleted file mode 100644 index bf4e1b60..00000000 --- a/libraries/Shell/examples/TelnetServer/TelnetServer.ino +++ /dev/null @@ -1,80 +0,0 @@ - -/* -This example demonstrates how to create a simple telnet server. - -This example is placed into the public domain. -*/ - -#include -#include -#include -#include - -byte macAddress[6] = { - 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED -}; - -int ledPin = 13; - -EthernetServer server(23); -EthernetClient client; -bool haveClient = false; - -LoginShell shell; - -void cmdLed(Shell &shell, int argc, const ShellArguments &argv) -{ - if (argc > 1 && !strcmp(argv[1], "on")) - digitalWrite(ledPin, HIGH); - else - digitalWrite(ledPin, LOW); -} - -ShellCommand(led, "Turns the status LED on or off", cmdLed); - -void setup() -{ - // Configure I/O. - pinMode(ledPin, OUTPUT); - digitalWrite(ledPin, LOW); - - // Start the serial port for status messages. - Serial.begin(9600); - Serial.println(); - Serial.print("Acquiring IP address ... "); - - // Start Ethernet running and get an IP address via DHCP. - if (Ethernet.begin(macAddress)) - Serial.println(Ethernet.localIP()); - else - Serial.println("failed"); - - // Listen on port 23 for incoming telnet connections. - server.begin(); - shell.setMachineName("Arduino"); -} - -void loop() -{ - // Maintain the DHCP lease over time. - Ethernet.maintain(); - - // Handle new/disconnecting clients. - if (!haveClient) { - // Check for new client connections. - client = server.available(); - if (client) { - haveClient = true; - shell.begin(client, 5); - } - } else if (!client.connected()) { - // The current client has been disconnected. Shut down the shell. - shell.end(); - client.stop(); - client = EthernetClient(); - haveClient = false; - } - - // Perform periodic shell processing on the active client. - shell.loop(); -} diff --git a/libraries/Shell/keywords.txt b/libraries/Shell/keywords.txt deleted file mode 100644 index cf6882e8..00000000 --- a/libraries/Shell/keywords.txt +++ /dev/null @@ -1,4 +0,0 @@ -Shell KEYWORD1 -LoginShell KEYWORD1 -Terminal KEYWORD1 -loop KEYWORD2