├── Firmware └── pong │ ├── makefile │ ├── sparklibs.h │ ├── spi │ ├── spi.h │ ├── spi_port_edison.cpp │ └── spi_device_edison.cpp │ ├── gpio │ ├── gpio.h │ ├── gpio_edison.h │ └── gpio_edison.cpp │ ├── oled │ ├── Edison_OLED.h │ ├── edison_fonts.h │ ├── Edison_OLED.cpp │ └── gpl-3.0.txt │ └── oled_pong.cpp ├── .gitattributes ├── .gitignore ├── README.md └── LICENSE.md /Firmware/pong/makefile: -------------------------------------------------------------------------------- 1 | CC=g++ 2 | CFLAGS=-c -Wall 3 | LDFLAGS= 4 | SOURCES=spi/spi_port_edison.cpp spi/spi_device_edison.cpp oled_pong.cpp oled/Edison_OLED.cpp gpio/gpio_edison.cpp 5 | OBJECTS=$(SOURCES:.cpp=.o) 6 | EXECUTABLE=oled_pong 7 | 8 | all: $(SOURCES) $(EXECUTABLE) 9 | 10 | $(EXECUTABLE): $(OBJECTS) 11 | $(CC) $(LDFLAGS) $(OBJECTS) -o $@ 12 | 13 | .cpp.o: 14 | $(CC) $(CFLAGS) $< -o $@ 15 | 16 | clean: 17 | rm -rf *.o $(EXECUTABLE) -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore list for Eagle, a PCB layout tool 2 | 3 | # Backup files 4 | *.s#? 5 | *.b#? 6 | *.l#? 7 | 8 | # Eagle project file 9 | # It contains a serial number and references to the file structure 10 | # on your computer. 11 | # comment the following line if you want to have your project file included. 12 | eagle.epf 13 | 14 | # CAM files 15 | *.$$$ 16 | *.cmp 17 | *.ly2 18 | *.l15 19 | *.sol 20 | *.plc 21 | *.stc 22 | *.sts 23 | *.crc 24 | *.crs 25 | 26 | *.dri 27 | *.drl 28 | *.gpi 29 | *.pls 30 | 31 | *.drd 32 | *.drd.* 33 | 34 | *.info 35 | 36 | *.eps 37 | 38 | 39 | # C++ files 40 | *.o 41 | 42 | # Example builds 43 | oled_pong 44 | -------------------------------------------------------------------------------- /Firmware/pong/sparklibs.h: -------------------------------------------------------------------------------- 1 | #ifndef __sparklibs_h_ 2 | #define __sparklibs_h_ 3 | 4 | enum exceptions { 5 | GPIO_NO_PIN = 0x10, // No GPIO file exists for that GPIO ID. 6 | GPIO_BAD_MODE, // Selected GPIO cannot take that mode. 7 | GPIO_BAD_VALUE, // Selected GPIO cannot take that value. 8 | I2C_NO_DEV = 0x30, // No I2C device with that ID can be accessed. 9 | SPI_NO_DEV = 0x50, // No SPI device at that location. 10 | PWM_NO_DEV = 0x70, // No PWM function at that location. 11 | PWM_BAD_PERIOD, // Period value is outside the acceptable limit. 12 | PWM_BAD_DUTY, // Duty cycle value is outside the acceptable limit. 13 | 14 | }; 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /Firmware/pong/spi/spi.h: -------------------------------------------------------------------------------- 1 | #ifndef __spi_h__ 2 | #define __spi_h__ 3 | 4 | #include 5 | #include 6 | 7 | struct spi_ioc_transfer; 8 | class spiDevice; 9 | class gpio; 10 | 11 | class spiPort 12 | { 13 | public: 14 | spiPort(int spiDriver=5); 15 | ~spiPort(); 16 | bool doIOwn(spiDevice *curiousDevice); 17 | void takeOwnership(spiDevice *bossyDevice); 18 | void transferData(spi_ioc_transfer *xfer); 19 | 20 | private: 21 | void configurePort(); 22 | void configurePins(int spiDriver); 23 | 24 | int _spiFile; 25 | spiDevice *_portOwner; 26 | gpio *_MOSI; 27 | gpio *_MISO; 28 | gpio *_SCK; 29 | gpio *_CS; 30 | }; 31 | 32 | class spiDevice 33 | { 34 | public: 35 | spiDevice(){}; 36 | spiDevice(spiPort *port, \ 37 | unsigned char spiMode = SPI_MODE_0, \ 38 | long speed = 1000000, \ 39 | bool lsbFirst = false, \ 40 | gpio *csPin = NULL); 41 | void transferData(unsigned char *outData, \ 42 | unsigned char *inData = NULL, \ 43 | unsigned int len = 1, \ 44 | bool deselect = true); 45 | bool customCS(); 46 | void CSLow(); 47 | void CSHigh(); 48 | bool doLSBFirst(); 49 | int getSPIMode(); 50 | gpio* getCSPin(); 51 | protected: 52 | gpio *_csPin; 53 | bool _customCS; 54 | spiPort *_port; 55 | unsigned char _spiMode; 56 | long _speed; 57 | bool _lsbFirst; 58 | 59 | }; 60 | 61 | #endif 62 | 63 | -------------------------------------------------------------------------------- /Firmware/pong/gpio/gpio.h: -------------------------------------------------------------------------------- 1 | #ifndef __gpio_h__ 2 | #define __gpio_h__ 3 | 4 | /* Values that can be taken by a pin. LOW and HIGH are obvious, and NONE is 5 | provided as a useful alternative that may never be used. */ 6 | enum PIN_VALUE 7 | { 8 | LOW, 9 | HIGH, 10 | NONE, 11 | }; 12 | 13 | /* Pin modes. InPUT and OUTPUT should be nearly universal; the others may or 14 | may not be needed depending on platform. On platforms where a particular 15 | value isn't allowed, an exception will be thrown. */ 16 | enum PIN_MODE 17 | { 18 | INPUT, 19 | OUTPUT, 20 | INPUT_PU, 21 | INPUT_PD, 22 | SPI, 23 | I2C, 24 | PWM, 25 | ADC, 26 | UART, 27 | }; 28 | 29 | /* This is the top-level class for a gpio pin. It should be suitable for all 30 | platforms, since it provides the minimum needed for a GPIO pin. All 31 | functions will throw exceptions defined in the sparklibs.h file. */ 32 | class gpio 33 | { 34 | public: 35 | gpio(int pinID, PIN_MODE initMode, PIN_VALUE initVal=LOW); 36 | ~gpio(); 37 | void pinMode(PIN_MODE newMode); 38 | void pinWrite(PIN_VALUE newLevel); 39 | PIN_VALUE pinRead(); 40 | 41 | private: 42 | /* The gpioHelper is provided to provide a place to hide the 43 | down-and-dirty implementation details that vary from one architecture 44 | to the next; that way, this class doesn't need to provide functions 45 | for, say, file IO which wouldn't get used in an environment without a 46 | filesystem. */ 47 | class gpioHelper *helper; 48 | int _pinNumber; 49 | gpio(); 50 | }; 51 | 52 | #endif 53 | 54 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | SparkFun Edison OLED Block 2 | =========================== 3 | 4 | ![SparkFun Edison OLED Block](https://cdn.sparkfun.com//assets/parts/1/0/0/3/6/13035-01.jpg) 5 | 6 | [*SparkFun Edison OLED Block(DEV-13035)*](https://www.sparkfun.com/products/13035) 7 | 8 | Equip your Edison with a graphic display using the Edison OLED board! This board features a 0.66", 64x48 pixel monochrome OLED. 9 | 10 | To add some control over your Edison and the OLED, this board also includes a small joystick and a pair of push-buttons. Use them to create a game, file navigator, or more! 11 | 12 | Repository Contents 13 | ------------------- 14 | * **/Firmware** - Example Pong sketch to demonstrate OLED Functionality. 15 | * **/Hardware** - All Eagle design files (.brd, .sch) 16 | * **/Production** - Test bed files and production panel files 17 | 18 | Documentation 19 | -------------- 20 | * **[Hookup Guide](https://learn.sparkfun.com/tutorials/sparkfun-blocks-for-intel-edison---oled-block)** - Basic hookup guide for the OLED Block. 21 | * **[SparkFun Fritzing repo](https://github.com/sparkfun/Fritzing_Parts)** - Fritzing diagrams for SparkFun products. 22 | * **[SparkFun 3D Model repo](https://github.com/sparkfun/3D_Models)** - 3D models of SparkFun products. 23 | * **[SparkFun Graphical Datasheets](https://github.com/sparkfun/Graphical_Datasheets)** -Graphical Datasheets for various SparkFun products. 24 | 25 | 26 | License Information 27 | ------------------- 28 | 29 | This product is _**open source**_! 30 | 31 | Please review the LICENSE.md file for license information. 32 | 33 | If you have any questions or concerns on licensing, please contact techsupport@sparkfun.com. 34 | 35 | Distributed as-is; no warranty is given. 36 | 37 | - Your friends at SparkFun. 38 | -------------------------------------------------------------------------------- /Firmware/pong/spi/spi_port_edison.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "../sparklibs.h" 9 | #include "../gpio/gpio.h" 10 | #include "spi.h" 11 | 12 | 13 | spiPort::~spiPort() 14 | { 15 | close(_spiFile); 16 | } 17 | 18 | spiPort::spiPort(int spiDriver) 19 | 20 | { 21 | const char *path = "/dev/spidev5.1"; 22 | _spiFile = open(path, O_RDWR); 23 | if (_spiFile < 0) throw SPI_NO_DEV; 24 | _portOwner = NULL; 25 | 26 | } 27 | 28 | // configurePort() only handles the parts which must be handled apart from 29 | // the message struct. 30 | void spiPort::configurePort() 31 | { 32 | if (_portOwner == NULL) 33 | { 34 | return; 35 | } 36 | 37 | // We'll make a little temp variable to transmit the various mode info to 38 | // the SPI driver. 39 | int temp = 0; 40 | 41 | // The boolean lsbfirst is a rare case where the bit order should be 42 | // reversed during transmission; it corresponds to the SPI_LSB_FIRST 43 | // constant in the spidev.h file. 44 | if (_portOwner->doLSBFirst()) 45 | { 46 | temp = SPI_LSB_FIRST; 47 | ioctl(_spiFile, SPI_IOC_WR_LSB_FIRST, &temp); 48 | } 49 | else 50 | { 51 | temp = 0; 52 | ioctl(_spiFile, SPI_IOC_WR_LSB_FIRST, &temp); 53 | } 54 | 55 | temp = _portOwner->getSPIMode(); 56 | ioctl(_spiFile, SPI_IOC_WR_MODE, &temp); 57 | } 58 | 59 | void spiPort::transferData(spi_ioc_transfer *xfer) 60 | { 61 | ioctl(_spiFile, SPI_IOC_MESSAGE(1), xfer); 62 | } 63 | 64 | bool spiPort::doIOwn(spiDevice *curiousDevice) 65 | { 66 | return (curiousDevice == _portOwner); 67 | } 68 | 69 | void spiPort::takeOwnership(spiDevice *bossyDevice) 70 | { 71 | _portOwner = bossyDevice; 72 | configurePort(); 73 | } 74 | 75 | -------------------------------------------------------------------------------- /Firmware/pong/spi/spi_device_edison.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "../gpio/gpio.h" 9 | #include "spi.h" 10 | 11 | spiDevice::spiDevice(spiPort *port, \ 12 | unsigned char spiMode, \ 13 | long speed, \ 14 | bool lsbFirst, \ 15 | gpio *csPin) 16 | { 17 | _port = port; 18 | _port->takeOwnership(this); 19 | _spiMode = spiMode; 20 | _speed = speed; 21 | _lsbFirst = lsbFirst; 22 | _csPin = csPin; 23 | if (csPin == NULL) 24 | { 25 | _customCS = false; 26 | } 27 | else 28 | { 29 | _customCS = true; 30 | } 31 | } 32 | 33 | void spiDevice::transferData(unsigned char *dataOut, \ 34 | unsigned char *dataIn, \ 35 | unsigned int len, 36 | bool deselect) 37 | { 38 | spi_ioc_transfer xfer; 39 | xfer.tx_buf =(unsigned long)dataOut; 40 | xfer.rx_buf =(unsigned long)dataIn; 41 | xfer.len = len; 42 | xfer.speed_hz = _speed; 43 | xfer.bits_per_word = 8; 44 | if (deselect) 45 | { 46 | xfer.cs_change = 1; 47 | } 48 | else 49 | { 50 | xfer.cs_change = 0; 51 | } 52 | if (_port->doIOwn(this)) 53 | { 54 | _port->takeOwnership(this); 55 | } 56 | _port->transferData(&xfer); 57 | } 58 | 59 | gpio* spiDevice::getCSPin() 60 | { 61 | return this->_csPin; 62 | } 63 | 64 | bool spiDevice::customCS() 65 | { 66 | return this->_customCS; 67 | } 68 | void spiDevice::CSLow() 69 | { 70 | if (_csPin != NULL) 71 | _csPin->pinWrite(LOW); 72 | } 73 | 74 | void spiDevice::CSHigh() 75 | { 76 | if (_csPin != NULL) 77 | _csPin->pinWrite(HIGH); 78 | } 79 | 80 | bool spiDevice::doLSBFirst() 81 | { 82 | return _lsbFirst; 83 | } 84 | 85 | int spiDevice::getSPIMode() 86 | { 87 | return _spiMode; 88 | } 89 | 90 | -------------------------------------------------------------------------------- /Firmware/pong/gpio/gpio_edison.h: -------------------------------------------------------------------------------- 1 | #ifndef __gpio_edison_h__ 2 | #define __gpio_edison_h__ 3 | 4 | // gpioHelper is defined independently in a platform-specific file, and 5 | // abstracts the nitty-gritty details of how a GPIO pin is actually accessed 6 | // for a given platform. Sometimes it'll be via file descriptors, other 7 | // times, it'll be via register access. 8 | 9 | // In the Edison, GPIO pins can be multiplexed to different functions. While 10 | // *can* access them via the /sys/class/gpio route, it's more useful (although 11 | // more verbose) to go through /sys/kernel/debug/gpio_debug. 12 | 13 | // One of the main reasons for using the debug route is that the Edison has some 14 | // internal muxing going on that you need to adjust to enable alternate 15 | // functions on the GPIO pins (things like PWM and SPI, for instance). 16 | 17 | // This directory contains *all* valid native GPIO pins. Pins provided via the 18 | // I/O expanders are not in this folder, however; to access them, you'll need 19 | // to go through the /sys/class/gpio/ interface. 20 | #define GPIO_ROOT "/sys/kernel/debug/gpio_debug/" 21 | 22 | // Each GPIO has a directory associated with it. Each directory has a number of 23 | // super useful files inside. These strings link to those files. 24 | 25 | // This file is read/write for current value of the pin. Write a string of "low" 26 | // or "high" to it, or read it to get "low" or "high" back. 27 | #define GPIO_VALUE GPIO_ROOT "gpio%u/current_value" 28 | 29 | // Current pin direction. This is *only* for input/output mode: more advanced 30 | // modes, like I2C et al, are set via the next file, current_pinmux. 31 | #define GPIO_DIRECTION GPIO_ROOT "gpio%u/current_direction" 32 | 33 | // Current pin mux mode. There are, generally, 8 modes, denoted by strings 34 | // "mode0", etc. "mode0" indicates GPIO mode; others are something else and 35 | // we'll cover that in appropriate places. 36 | #define GPIO_MODE GPIO_ROOT "gpio%u/current_pinmux" 37 | 38 | // If we want to have a pullup or pulldown on the pin, we need to write 39 | // "pullup" or "pulldown" to this file. 40 | #define GPIO_PULLMODE GPIO_ROOT "gpio%u/current_pullmode" 41 | 42 | class gpioHelper 43 | { 44 | friend class gpio; 45 | private: 46 | int _valueFileID; 47 | int _modeFileID; 48 | int _dirFileID; 49 | int _pullmodeFileID; 50 | void writeFile(int fileID, const char *value); 51 | }; 52 | 53 | #endif 54 | 55 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | SparkFun License Information 2 | ============================ 3 | 4 | SparkFun uses two different licenses for our files — one for hardware and one for code. 5 | 6 | Hardware 7 | --------- 8 | 9 | **SparkFun hardware is released under [Creative Commons Share-alike 4.0 International](http://creativecommons.org/licenses/by-sa/4.0/).** 10 | 11 | Note: This is a human-readable summary of (and not a substitute for) the [license](http://creativecommons.org/licenses/by-sa/4.0/legalcode). 12 | 13 | You are free to: 14 | 15 | Share — copy and redistribute the material in any medium or format 16 | Adapt — remix, transform, and build upon the material 17 | for any purpose, even commercially. 18 | The licensor cannot revoke these freedoms as long as you follow the license terms. 19 | Under the following terms: 20 | 21 | Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use. 22 | ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original. 23 | No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits. 24 | Notices: 25 | 26 | You do not have to comply with the license for elements of the material in the public domain or where your use is permitted by an applicable exception or limitation. 27 | No warranties are given. The license may not give you all of the permissions necessary for your intended use. For example, other rights such as publicity, privacy, or moral rights may limit how you use the material. 28 | 29 | 30 | Code 31 | -------- 32 | 33 | **SparkFun code, firmware, and software is released under the MIT License(http://opensource.org/licenses/MIT).** 34 | 35 | The MIT License (MIT) 36 | 37 | Copyright (c) 2016 SparkFun Electronics 38 | 39 | Permission is hereby granted, free of charge, to any person obtaining a copy 40 | of this software and associated documentation files (the "Software"), to deal 41 | in the Software without restriction, including without limitation the rights 42 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 43 | copies of the Software, and to permit persons to whom the Software is 44 | furnished to do so, subject to the following conditions: 45 | 46 | The above copyright notice and this permission notice shall be included in all 47 | copies or substantial portions of the Software. 48 | 49 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 50 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 51 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 52 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 53 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 54 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 55 | SOFTWARE. 56 | -------------------------------------------------------------------------------- /Firmware/pong/oled/Edison_OLED.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Edison_OLED.h 3 | Header file for the Edison OLED Block C++ Library 4 | 5 | Jim Lindblom @ SparkFun Electronics 6 | January 8, 2014 7 | https://github.com/sparkfun/Edison_OLED_Block/tree/master/Firmware/ 8 | 9 | This file defines the hardware interface for the Edison OLED Block 10 | 11 | This code was heavily based around the MicroView library, written by GeekAmmo 12 | (https://github.com/geekammo/MicroView-Arduino-Library), and released under 13 | the terms of the GNU General Public License as published by the Free Software 14 | Foundation, either version 3 of the License, or (at your option) any later 15 | version. 16 | 17 | This program is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | GNU General Public License for more details. 21 | 22 | You should have received a copy of the GNU General Public License 23 | along with this program. If not, see . 24 | ******************************************************************************/ 25 | 26 | #ifndef EDISON_OLED_H 27 | #define EDISON_OLED_H 28 | 29 | #define swapOLED(a, b) { unsigned char t = a; a = b; b = t; } 30 | 31 | #define BLACK 0 32 | #define WHITE 1 33 | 34 | #define LCDWIDTH 64 35 | #define LCDHEIGHT 48 36 | #define FONTHEADERSIZE 6 37 | 38 | #define NORM 0 39 | #define XOR 1 40 | 41 | #define PAGE 0 42 | #define ALL 1 43 | 44 | #define SETCONTRAST 0x81 45 | #define DISPLAYALLONRESUME 0xA4 46 | #define DISPLAYALLON 0xA5 47 | #define NORMALDISPLAY 0xA6 48 | #define INVERTDISPLAY 0xA7 49 | #define DISPLAYOFF 0xAE 50 | #define DISPLAYON 0xAF 51 | #define SETDISPLAYOFFSET 0xD3 52 | #define SETCOMPINS 0xDA 53 | #define SETVCOMDESELECT 0xDB 54 | #define SETDISPLAYCLOCKDIV 0xD5 55 | #define SETPRECHARGE 0xD9 56 | #define SETMULTIPLEX 0xA8 57 | #define SETLOWCOLUMN 0x00 58 | #define SETHIGHCOLUMN 0x10 59 | #define SETSTARTLINE 0x40 60 | #define MEMORYMODE 0x20 61 | #define COMSCANINC 0xC0 62 | #define COMSCANDEC 0xC8 63 | #define SEGREMAP 0xA0 64 | #define CHARGEPUMP 0x8D 65 | #define EXTERNALVCC 0x01 66 | #define SWITCHCAPVCC 0x02 67 | 68 | // Scroll 69 | #define ACTIVATESCROLL 0x2F 70 | #define DEACTIVATESCROLL 0x2E 71 | #define SETVERTICALSCROLLAREA 0xA3 72 | #define RIGHTHORIZONTALSCROLL 0x26 73 | #define LEFT_HORIZONTALSCROLL 0x27 74 | #define VERTICALRIGHTHORIZONTALSCROLL 0x29 75 | #define VERTICALLEFTHORIZONTALSCROLL 0x2A 76 | 77 | typedef enum CMD { 78 | CMD_CLEAR, //0 79 | CMD_INVERT, //1 80 | CMD_CONTRAST, //2 81 | CMD_DISPLAY, //3 82 | CMD_SETCURSOR, //4 83 | CMD_PIXEL, //5 84 | CMD_LINE, //6 85 | CMD_LINEH, //7 86 | CMD_LINEV, //8 87 | CMD_RECT, //9 88 | CMD_RECTFILL, //10 89 | CMD_CIRCLE, //11 90 | CMD_CIRCLEFILL, //12 91 | CMD_DRAWCHAR, //13 92 | CMD_DRAWBITMAP, //14 93 | CMD_GETLCDWIDTH, //15 94 | CMD_GETLCDHEIGHT, //16 95 | CMD_SETCOLOR, //17 96 | CMD_SETDRAWMODE //18 97 | } commCommand_t; 98 | 99 | class edOLED { 100 | public: 101 | edOLED(); 102 | 103 | void begin(void); 104 | 105 | unsigned char write(unsigned char); 106 | void print(const char * c); 107 | void print(int d); 108 | void print(float f); 109 | 110 | // RAW LCD functions 111 | void command(unsigned char c); 112 | void data(unsigned char c); 113 | void setColumnAddress(unsigned char add); 114 | void setPageAddress(unsigned char add); 115 | 116 | // LCD Draw functions 117 | void clear(unsigned char mode); 118 | void clear(unsigned char mode, unsigned char c); 119 | void invert(unsigned char inv); 120 | void contrast(unsigned char contrast); 121 | void display(void); 122 | void setCursor(unsigned char x, unsigned char y); 123 | void pixel(unsigned char x, unsigned char y); 124 | void pixel(unsigned char x, unsigned char y, unsigned char color, unsigned char mode); 125 | void line(unsigned char x0, unsigned char y0, unsigned char x1, unsigned char y1); 126 | void line(unsigned char x0, unsigned char y0, unsigned char x1, unsigned char y1, unsigned char color, unsigned char mode); 127 | void lineH(unsigned char x, unsigned char y, unsigned char width); 128 | void lineH(unsigned char x, unsigned char y, unsigned char width, unsigned char color, unsigned char mode); 129 | void lineV(unsigned char x, unsigned char y, unsigned char height); 130 | void lineV(unsigned char x, unsigned char y, unsigned char height, unsigned char color, unsigned char mode); 131 | void rect(unsigned char x, unsigned char y, unsigned char width, unsigned char height); 132 | void rect(unsigned char x, unsigned char y, unsigned char width, unsigned char height, unsigned char color , unsigned char mode); 133 | void rectFill(unsigned char x, unsigned char y, unsigned char width, unsigned char height); 134 | void rectFill(unsigned char x, unsigned char y, unsigned char width, unsigned char height, unsigned char color , unsigned char mode); 135 | void circle(unsigned char x, unsigned char y, unsigned char radius); 136 | void circle(unsigned char x, unsigned char y, unsigned char radius, unsigned char color, unsigned char mode); 137 | void circleFill(unsigned char x0, unsigned char y0, unsigned char radius); 138 | void circleFill(unsigned char x0, unsigned char y0, unsigned char radius, unsigned char color, unsigned char mode); 139 | void drawChar(unsigned char x, unsigned char y, unsigned char c); 140 | void drawChar(unsigned char x, unsigned char y, unsigned char c, unsigned char color, unsigned char mode); 141 | void drawBitmap(void); 142 | unsigned char getLCDWidth(void); 143 | unsigned char getLCDHeight(void); 144 | void setColor(unsigned char color); 145 | void setDrawMode(unsigned char mode); 146 | 147 | // Font functions 148 | unsigned char getFontWidth(void); 149 | unsigned char getFontHeight(void); 150 | unsigned char getTotalFonts(void); 151 | unsigned char getFontType(void); 152 | unsigned char setFontType(unsigned char type); 153 | unsigned char getFontStartChar(void); 154 | unsigned char getFontTotalChar(void); 155 | 156 | // LCD Rotate Scroll functions 157 | void scrollRight(unsigned char start, unsigned char stop); 158 | void scrollLeft(unsigned char start, unsigned char stop); 159 | void scrollVertRight(unsigned char start, unsigned char stop); 160 | void scrollVertLeft(unsigned char start, unsigned char stop); 161 | void scrollStop(void); 162 | void flipVertical(unsigned char flip); 163 | void flipHorizontal(unsigned char flip); 164 | 165 | //void doCmd(unsigned char index); 166 | 167 | private: 168 | unsigned char foreColor,drawMode,fontWidth, fontHeight, fontType, fontStartChar, fontTotalChar, cursorX, cursorY; 169 | unsigned int fontMapWidth; 170 | static const unsigned char *fontsPointer[]; 171 | 172 | // Communication 173 | void spiTransfer(unsigned char data); 174 | void spiSetup(); 175 | }; 176 | #endif 177 | -------------------------------------------------------------------------------- /Firmware/pong/gpio/gpio_edison.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "gpio.h" 7 | #include "gpio_edison.h" 8 | #include "../sparklibs.h" 9 | 10 | // Class constructor. initVal can be omitted; defaults to LOW. 11 | gpio::gpio(int pinID, PIN_MODE initMode, PIN_VALUE initVal) 12 | { 13 | /* We'll want to remember the pin number associated with this object, so we 14 | can provide the user with useful information when we throw exceptions. */ 15 | this->_pinNumber = pinID; 16 | 17 | char tBuffer[75]; 18 | 19 | /* GPIO functions are handled through accessing a resource in the filesystem. 20 | It's possible that these resources may not exist; in that case, we'll 21 | throw an exception, because creating a GPIO object with no resource to 22 | back it up makes no sense. */ 23 | 24 | /* A few words here on the role of gpioHelper: since this library is 25 | meant to be platform agnostic, we want to divorce the filesystem-related 26 | elements of the GPIO from the main GPIO object. After all, not all of the 27 | target architectures this will work for will have a filesystem! */ 28 | helper = new gpioHelper(); 29 | 30 | /* Create the path for the direction setting file and open it. This file 31 | handles GPIO direction only. */ 32 | sprintf(tBuffer, GPIO_DIRECTION, pinID); 33 | helper->_dirFileID = open(tBuffer, O_RDWR); 34 | 35 | /* The mode file (aka pinmux) handles some weird internal logic on the Edison 36 | which routes the various IO peripherals (SPI, PWM) to the physical pin on 37 | the Edison connector. */ 38 | sprintf(tBuffer, GPIO_MODE, pinID); 39 | helper->_modeFileID = open(tBuffer, O_RDWR); 40 | 41 | // Same process for the "value" file, same caveat.. 42 | sprintf(tBuffer, GPIO_VALUE, pinID); 43 | helper->_valueFileID = open(tBuffer, O_RDWR); 44 | 45 | // And for pullmode. 46 | sprintf(tBuffer, GPIO_PULLMODE, pinID); 47 | helper->_pullmodeFileID = open(tBuffer, O_RDWR); 48 | 49 | /* It's not hard to imagine a case where the user would pass a bogus pin ID, 50 | so let's just make sure we handle that gracefully by throwing an 51 | exception. */ 52 | if ((helper->_modeFileID == -1) || 53 | (helper->_dirFileID == -1) || 54 | (helper->_pullmodeFileID == -1) || 55 | (helper->_valueFileID == -1)) 56 | { 57 | throw (GPIO_NO_PIN << 16) + pinID; 58 | return; 59 | } 60 | 61 | // Write the initial value to the pin. 62 | this->pinWrite(initVal); 63 | 64 | // Write the initial mode to the pin. 65 | this->pinMode(initMode); 66 | 67 | // If we make it here without throwing any exceptions, we have a pin object! 68 | } 69 | 70 | // Destructor. Nothing special here. 71 | gpio::~gpio() 72 | { 73 | close(helper->_modeFileID); 74 | close(helper->_valueFileID); 75 | close(helper->_dirFileID); 76 | close(helper->_pullmodeFileID); 77 | delete helper; 78 | } 79 | 80 | // Mode setting function. Throws exception GPIO_BAD_MODE if you pass it an 81 | // invalid mode value. 82 | void gpio::pinMode(PIN_MODE newMode) 83 | { 84 | char tBuffer[10]; 85 | switch (newMode) 86 | { 87 | // For an input or output, we write to the direction file ("in" or "out"), 88 | // and to the pinmux file ("mode0"). We can assume that this is valid for 89 | // all possible pins. 90 | case INPUT: 91 | sprintf(tBuffer, "in"); 92 | helper->writeFile(helper->_dirFileID, tBuffer); 93 | sprintf(tBuffer, "mode0"); 94 | helper->writeFile(helper->_modeFileID, tBuffer); 95 | sprintf(tBuffer, "nopull"); 96 | helper->writeFile(helper->_pullmodeFileID, tBuffer); 97 | break; 98 | case OUTPUT: 99 | sprintf(tBuffer, "out"); 100 | helper->writeFile(helper->_dirFileID, tBuffer); 101 | sprintf(tBuffer, "mode0"); 102 | helper->writeFile(helper->_modeFileID, tBuffer); 103 | sprintf(tBuffer, "nopull"); 104 | helper->writeFile(helper->_pullmodeFileID, tBuffer); 105 | break; 106 | case SPI: 107 | // We need to make sure we're on a valid SPI pin; that's pins 109, 111, 108 | // 114 and 115. Any other pin throws an exception. To activate SPI mode, 109 | // we need to set pinmux to mode1. 110 | switch (this->_pinNumber) 111 | { 112 | case 109: // SPI clock. 113 | case 111: // SPI CS 114 | case 115: // SPI MOSI 115 | sprintf(tBuffer, "out"); 116 | helper->writeFile(helper->_dirFileID, tBuffer); 117 | sprintf(tBuffer, "mode1"); 118 | helper->writeFile(helper->_modeFileID, tBuffer); 119 | sprintf(tBuffer, "nopull"); 120 | helper->writeFile(helper->_pullmodeFileID, tBuffer); 121 | break; 122 | case 114: // SPI MISO 123 | sprintf(tBuffer, "in"); 124 | helper->writeFile(helper->_dirFileID, tBuffer); 125 | sprintf(tBuffer, "mode1"); 126 | helper->writeFile(helper->_modeFileID, tBuffer); 127 | sprintf(tBuffer, "nopull"); 128 | helper->writeFile(helper->_pullmodeFileID, tBuffer); 129 | break; 130 | default: 131 | throw (GPIO_BAD_MODE << 16) + this->_pinNumber; 132 | return; 133 | } 134 | break; 135 | case PWM: 136 | // We need to make sure we're on a valid PWM pin; that's pins 12, 13, 182 137 | // and 183, as PWM0-3 respectively. We're going to assume that the user 138 | // took care of exporting the PWM pin elsewhere in their code (really, 139 | // that just means that they created a PWMPin object); otherwise, they 140 | // can set the pin to PWM mode but not really use it. 141 | switch(this->_pinNumber) 142 | { 143 | case 12: 144 | case 13: 145 | case 182: 146 | case 183: 147 | sprintf(tBuffer, "out"); 148 | helper->writeFile(helper->_dirFileID, tBuffer); 149 | sprintf(tBuffer, "mode1"); 150 | helper->writeFile(helper->_modeFileID, tBuffer); 151 | sprintf(tBuffer, "nopull"); 152 | helper->writeFile(helper->_pullmodeFileID, tBuffer); 153 | break; 154 | default: 155 | throw (GPIO_BAD_MODE << 16) + this->_pinNumber; 156 | return; 157 | } 158 | break; 159 | case INPUT_PU: 160 | sprintf(tBuffer, "in"); 161 | helper->writeFile(helper->_dirFileID, tBuffer); 162 | sprintf(tBuffer, "mode0"); 163 | helper->writeFile(helper->_modeFileID, tBuffer); 164 | sprintf(tBuffer, "pullup"); 165 | helper->writeFile(helper->_pullmodeFileID, tBuffer); 166 | break; 167 | case INPUT_PD: 168 | sprintf(tBuffer, "in"); 169 | helper->writeFile(helper->_dirFileID, tBuffer); 170 | sprintf(tBuffer, "mode0"); 171 | helper->writeFile(helper->_modeFileID, tBuffer); 172 | sprintf(tBuffer, "pulldown"); 173 | helper->writeFile(helper->_pullmodeFileID, tBuffer); 174 | break; 175 | case I2C: 176 | case UART: 177 | case ADC: 178 | default: 179 | throw (GPIO_BAD_MODE<<16) + this->_pinNumber; 180 | return; 181 | } 182 | } 183 | 184 | // Pin value write function. Throws exception GPIO_BAD_VALUE if you pass it a 185 | // bad level value. 186 | void gpio::pinWrite(PIN_VALUE newLevel) 187 | { 188 | char tBuffer[5]; 189 | // Writing to /sys/class/gpio#/value, we'd write '1' or '0'. To the debug 190 | // file, we write 'low' or 'high'. 191 | if (newLevel == LOW) 192 | { 193 | sprintf(tBuffer, "low"); 194 | } 195 | else if (newLevel == HIGH) 196 | { 197 | sprintf(tBuffer, "high"); 198 | } 199 | else 200 | { 201 | throw (GPIO_BAD_VALUE<<16) + _pinNumber; 202 | return; 203 | } 204 | 205 | helper->writeFile(helper->_valueFileID, tBuffer); 206 | } 207 | 208 | PIN_VALUE gpio::pinRead() 209 | { 210 | lseek(helper->_valueFileID, 0, SEEK_SET); 211 | char buffer[4]; 212 | read(helper->_valueFileID, &buffer, 4); 213 | if (buffer[0] == 'h') 214 | { 215 | return HIGH; 216 | } 217 | else 218 | { 219 | //printf("IT'S LOW\n\r"); 220 | return LOW; 221 | } 222 | } 223 | 224 | // writeFile() is made a function so we don't need to explicitly do the lseek() 225 | // to get to the top of the file before every write. It feels derpy to me that 226 | // a file like this needs you to seek to the top, but there it is. 227 | void gpioHelper::writeFile(int fileID, const char *buffer) 228 | { 229 | lseek(fileID, 0, SEEK_SET); // Make sure we're at the top of the file! 230 | write(fileID, buffer, strlen(buffer)); 231 | } 232 | 233 | -------------------------------------------------------------------------------- /Firmware/pong/oled_pong.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * pong.cpp 3 | * Play a game of pong on the Edison OLED Block! 4 | * Jim Lindblom @ SparkFun Electronics 5 | * Original Creation Date: January 8, 2014 6 | * 7 | * This sketch uses the Edison OLED library to draw a 3-D projected 8 | * cube, and rotate it along all three axes. 9 | * 10 | * This code is beerware; if you see me (or any other SparkFun employee) at the 11 | * local, and you've found our code helpful, please buy us a round! 12 | * 13 | * Distributed as-is; no warranty is given. 14 | ******************************************************************************/ 15 | 16 | #include 17 | #include "oled/Edison_OLED.h" 18 | #include "gpio/gpio.h" 19 | #include "math.h" 20 | #include // for usleep 21 | #include // Gives us atoi 22 | #include 23 | 24 | using namespace std; 25 | 26 | // Function prototypes: 27 | void setupOLED(); 28 | void startScreen(); 29 | void updatePaddlePositions(); 30 | float constrainPosition(float position); 31 | void moveBall(); 32 | void drawGame(); 33 | void drawScore(int player1, int player2); 34 | void drawPaddle(int x, int y); 35 | void drawBall(int x, int y); 36 | int checkWin(); 37 | void drawWin(int player); 38 | void cleanUp(); 39 | 40 | // Define an edOLED object: 41 | edOLED oled; 42 | 43 | // Pin definitions: 44 | // All buttons have pull-up resistors on-board, so just declare 45 | // them as regular INPUT's 46 | gpio BUTTON_UP(47, INPUT); 47 | gpio BUTTON_DOWN(44, INPUT); 48 | gpio BUTTON_LEFT(165, INPUT); 49 | gpio BUTTON_RIGHT(45, INPUT); 50 | gpio BUTTON_SELECT(48, INPUT); 51 | gpio BUTTON_A(49, INPUT); 52 | gpio BUTTON_B(46, INPUT); 53 | 54 | // Game Variables: 55 | int scoreToWin = 10; 56 | int playerScore = 0; 57 | int player2Score = 0; 58 | 59 | const float paddleWidth = LCDWIDTH/16.0; 60 | const float paddleHeight = LCDHEIGHT/3.0; 61 | const float halfPaddleWidth = paddleWidth/2.0; 62 | const float halfPaddleHeight = paddleHeight/2.0; 63 | 64 | float player1PosX = 1.0 + halfPaddleWidth; 65 | float player1PosY = 0.0; 66 | float player2PosX = LCDWIDTH - 1.0 - halfPaddleWidth; 67 | float player2PosY = 0.0; 68 | float enemyVelY = 0.5; 69 | 70 | const float ballRadius = 2.0; 71 | const float ballSpeedX = 1.0; 72 | float ballPosX = LCDWIDTH/2.0; 73 | float ballPosY = LCDHEIGHT/2.0; 74 | float ballVelX = -1.0 * ballSpeedX; 75 | float ballVelY = 0; 76 | 77 | enum { 78 | PLAYER_1_WIN = 1, 79 | PLAYER_2_WIN = 2 80 | }; 81 | enum { 82 | SINGLE_PLAYER, 83 | MULTI_PLAYER 84 | }; 85 | int playMode = SINGLE_PLAYER; 86 | 87 | int main(int argc, char * argv[]) 88 | { 89 | if (argc == 2) 90 | { 91 | scoreToWin = atoi(argv[1]); 92 | } 93 | printf("Playing to %d\r\n", scoreToWin); 94 | 95 | setupOLED(); 96 | startScreen(); 97 | 98 | while (1) 99 | { 100 | updatePaddlePositions(); 101 | moveBall(); 102 | drawGame(); 103 | if (checkWin()) 104 | { 105 | drawWin(checkWin()); 106 | cleanUp(); 107 | return 0; 108 | } 109 | } 110 | } 111 | 112 | void setupOLED() 113 | { 114 | oled.begin(); 115 | oled.clear(PAGE); 116 | oled.display(); 117 | oled.setFontType(0); 118 | } 119 | 120 | void startScreen() 121 | { 122 | // Reset all game variables: 123 | player2Score = 0; 124 | playerScore = 0; 125 | player2PosY = 0.0; 126 | ballPosX = LCDWIDTH/2.0; 127 | ballPosY = LCDHEIGHT/2.0; 128 | ballVelX = -1.0 * ballSpeedX; 129 | ballVelY = 0.0; 130 | 131 | // Draw the splash screen: 132 | oled.clear(PAGE); 133 | oled.setCursor(14, 5); 134 | oled.print("Press A"); 135 | oled.setCursor(2, 13); 136 | oled.print("for single"); 137 | oled.setCursor(14, 30); 138 | oled.print("Press B"); 139 | oled.setCursor(6, 38); 140 | oled.print("for multi"); 141 | // Call display to actually draw it on the OLED: 142 | oled.display(); 143 | 144 | // Wait for either button A or B to be pressed: 145 | while ((BUTTON_A.pinRead() == HIGH) && (BUTTON_B.pinRead() == HIGH)) 146 | ; 147 | // If button A is pressed, play single player 148 | if (BUTTON_A.pinRead() == LOW) 149 | playMode = SINGLE_PLAYER; 150 | // If button B is pressed, play mutli-player 151 | else if (BUTTON_B.pinRead() == LOW) 152 | playMode = MULTI_PLAYER; 153 | } 154 | 155 | // Update the positions of the paddles: 156 | void updatePaddlePositions() 157 | { 158 | // Update player 1's paddle: 159 | if (BUTTON_UP.pinRead() == LOW) 160 | { 161 | player1PosY--; 162 | } 163 | if (BUTTON_DOWN.pinRead() == LOW) 164 | { 165 | player1PosY++; 166 | } 167 | player1PosY = constrainPosition(player1PosY); 168 | 169 | // Move player 2 paddle: 170 | if (playMode == SINGLE_PLAYER) 171 | { 172 | // Update AI's paddle: 173 | // Follow along with the ball's position: 174 | if (player2PosY < ballPosY) 175 | { 176 | player2PosY += enemyVelY; 177 | } 178 | else if(player2PosY > ballPosY) 179 | { 180 | player2PosY -= enemyVelY; 181 | } 182 | } 183 | else if (playMode == MULTI_PLAYER) 184 | { 185 | if (BUTTON_A.pinRead() == LOW) 186 | { 187 | player2PosY--; 188 | } 189 | if (BUTTON_B.pinRead() == LOW) 190 | { 191 | player2PosY++; 192 | } 193 | } 194 | player2PosY = constrainPosition(player2PosY); 195 | } 196 | 197 | // Constrain a paddle's position to within the display's border 198 | float constrainPosition(float position) 199 | { 200 | float newPaddlePosY = position; 201 | 202 | if (position - halfPaddleHeight < 0) 203 | { 204 | newPaddlePosY = halfPaddleHeight; 205 | } 206 | else if (position + halfPaddleHeight > LCDHEIGHT) 207 | { 208 | newPaddlePosY = LCDHEIGHT - halfPaddleHeight; 209 | } 210 | 211 | return newPaddlePosY; 212 | } 213 | 214 | // Move the ball and re-calculate its position: 215 | void moveBall() 216 | { 217 | ballPosY += ballVelY; 218 | ballPosX += ballVelX; 219 | 220 | // Top and bottom wall collisions 221 | if (ballPosY < ballRadius) 222 | { 223 | ballPosY = ballRadius; 224 | ballVelY *= -1.0; 225 | } 226 | else if (ballPosY > LCDHEIGHT - ballRadius) 227 | { 228 | ballPosY = LCDHEIGHT - ballRadius; 229 | ballVelY *= -1.0; 230 | } 231 | 232 | // Left and right wall collisions 233 | if (ballPosX < ballRadius) 234 | { 235 | ballPosX = ballRadius; 236 | ballVelX = ballSpeedX; 237 | player2Score++; 238 | } 239 | else if (ballPosX > LCDWIDTH - ballRadius) 240 | { 241 | ballPosX = LCDWIDTH - ballRadius; 242 | ballVelX *= -1.0 * ballSpeedX; 243 | playerScore++; 244 | } 245 | 246 | // Paddle collisions 247 | if (ballPosX < player1PosX + ballRadius + halfPaddleWidth) 248 | { 249 | if (ballPosY > player1PosY - halfPaddleHeight - ballRadius && 250 | ballPosY < player1PosY + halfPaddleHeight + ballRadius) 251 | { 252 | ballVelX = ballSpeedX; 253 | ballVelY = 2.0 * (ballPosY - player1PosY) / halfPaddleHeight; 254 | } 255 | } 256 | else if (ballPosX > player2PosX - ballRadius - halfPaddleWidth) 257 | { 258 | if (ballPosY > player2PosY - halfPaddleHeight - ballRadius && 259 | ballPosY < player2PosY + halfPaddleHeight + ballRadius) 260 | { 261 | ballVelX = -1.0 * ballSpeedX; 262 | ballVelY = 2.0 * (ballPosY - player2PosY) / halfPaddleHeight; 263 | } 264 | } 265 | } 266 | 267 | // Draw the paddles, ball and score: 268 | void drawGame() 269 | { 270 | oled.clear(PAGE); 271 | 272 | drawScore(playerScore, player2Score); 273 | drawPaddle(player1PosX, player1PosY); 274 | drawPaddle(player2PosX, player2PosY); 275 | drawBall(ballPosX, ballPosY); 276 | 277 | oled.display(); 278 | } 279 | 280 | // Draw the two score integers on the screen 281 | void drawScore(int player1, int player2) 282 | { 283 | oled.setCursor(10, 2); 284 | oled.print(player1); 285 | oled.setCursor(50, 2); 286 | oled.print(player2); 287 | } 288 | 289 | // Draw a paddle, given it's x and y coord's 290 | void drawPaddle(int x, int y) 291 | { 292 | oled.rect(x - halfPaddleWidth, 293 | y - halfPaddleHeight, 294 | paddleWidth, 295 | paddleHeight); 296 | } 297 | 298 | // Draw a ball, give it's x and y coords 299 | void drawBall(int x, int y) 300 | { 301 | oled.circle(x, y, 2); 302 | } 303 | 304 | // Check if either player has won. 305 | // Returns: 306 | // 0 - Neither player has won. 307 | // 1 - Player 1 has won 308 | // 2 - Player 2 has won 309 | int checkWin() 310 | { 311 | if (playerScore >= scoreToWin) 312 | { 313 | return PLAYER_1_WIN; 314 | } 315 | else if (player2Score >= scoreToWin) 316 | { 317 | return PLAYER_2_WIN; 318 | } 319 | 320 | return 0; 321 | } 322 | 323 | // Draw the win screen. 324 | // Keep it up for 5 seconds. 325 | // Then go back to the splash screen. 326 | void drawWin(int player) 327 | { 328 | oled.setCursor(10, 2); 329 | oled.clear(PAGE); 330 | if (player == PLAYER_1_WIN) 331 | { 332 | oled.print("Player 1"); 333 | } 334 | else if (player == PLAYER_2_WIN) 335 | { 336 | oled.print("Player 2"); 337 | } 338 | oled.setCursor(20, 12); 339 | oled.print("Wins!"); 340 | oled.display(); 341 | 342 | usleep(5000000); 343 | } 344 | 345 | void cleanUp() 346 | { 347 | oled.clear(PAGE); 348 | oled.display(); 349 | } 350 | -------------------------------------------------------------------------------- /Firmware/pong/oled/edison_fonts.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * fonts.h 3 | * 4 | * Definition for all four default fonts. 5 | * 6 | * This file was imported from the MicroView library, written by GeekAmmo 7 | * (https://github.com/geekammo/MicroView-Arduino-Library), and released under 8 | * the terms of the GNU General Public License as published by the Free Software 9 | * Foundation, either version 3 of the License, or (at your option) any later 10 | * version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | ******************************************************************************/ 20 | 21 | #ifndef OLED_FONTS_H 22 | #define OLED_FONTS_H 23 | 24 | // Standard ASCII 5x7 font 25 | static const unsigned char font5x7[] = { 26 | // first row defines - FONTWIDTH, FONTHEIGHT, ASCII START CHAR, TOTAL CHARACTERS, FONT MAP WIDTH HIGH, FONT MAP WIDTH LOW (2,56 meaning 256) 27 | 5,8,0,255,12,75, 28 | 0x00, 0x00, 0x00, 0x00, 0x00, 29 | 0x3E, 0x5B, 0x4F, 0x5B, 0x3E, 30 | 0x3E, 0x6B, 0x4F, 0x6B, 0x3E, 31 | 0x1C, 0x3E, 0x7C, 0x3E, 0x1C, 32 | 0x18, 0x3C, 0x7E, 0x3C, 0x18, 33 | 0x1C, 0x57, 0x7D, 0x57, 0x1C, 34 | 0x1C, 0x5E, 0x7F, 0x5E, 0x1C, 35 | 0x00, 0x18, 0x3C, 0x18, 0x00, 36 | 0xFF, 0xE7, 0xC3, 0xE7, 0xFF, 37 | 0x00, 0x18, 0x24, 0x18, 0x00, 38 | 0xFF, 0xE7, 0xDB, 0xE7, 0xFF, 39 | 0x30, 0x48, 0x3A, 0x06, 0x0E, 40 | 0x26, 0x29, 0x79, 0x29, 0x26, 41 | 0x40, 0x7F, 0x05, 0x05, 0x07, 42 | 0x40, 0x7F, 0x05, 0x25, 0x3F, 43 | 0x5A, 0x3C, 0xE7, 0x3C, 0x5A, 44 | 0x7F, 0x3E, 0x1C, 0x1C, 0x08, 45 | 0x08, 0x1C, 0x1C, 0x3E, 0x7F, 46 | 0x14, 0x22, 0x7F, 0x22, 0x14, 47 | 0x5F, 0x5F, 0x00, 0x5F, 0x5F, 48 | 0x06, 0x09, 0x7F, 0x01, 0x7F, 49 | 0x00, 0x66, 0x89, 0x95, 0x6A, 50 | 0x60, 0x60, 0x60, 0x60, 0x60, 51 | 0x94, 0xA2, 0xFF, 0xA2, 0x94, 52 | 0x08, 0x04, 0x7E, 0x04, 0x08, 53 | 0x10, 0x20, 0x7E, 0x20, 0x10, 54 | 0x08, 0x08, 0x2A, 0x1C, 0x08, 55 | 0x08, 0x1C, 0x2A, 0x08, 0x08, 56 | 0x1E, 0x10, 0x10, 0x10, 0x10, 57 | 0x0C, 0x1E, 0x0C, 0x1E, 0x0C, 58 | 0x30, 0x38, 0x3E, 0x38, 0x30, 59 | 0x06, 0x0E, 0x3E, 0x0E, 0x06, 60 | 0x00, 0x00, 0x00, 0x00, 0x00, 61 | 0x00, 0x00, 0x5F, 0x00, 0x00, 62 | 0x00, 0x07, 0x00, 0x07, 0x00, 63 | 0x14, 0x7F, 0x14, 0x7F, 0x14, 64 | 0x24, 0x2A, 0x7F, 0x2A, 0x12, 65 | 0x23, 0x13, 0x08, 0x64, 0x62, 66 | 0x36, 0x49, 0x56, 0x20, 0x50, 67 | 0x00, 0x08, 0x07, 0x03, 0x00, 68 | 0x00, 0x1C, 0x22, 0x41, 0x00, 69 | 0x00, 0x41, 0x22, 0x1C, 0x00, 70 | 0x2A, 0x1C, 0x7F, 0x1C, 0x2A, 71 | 0x08, 0x08, 0x3E, 0x08, 0x08, 72 | 0x00, 0x80, 0x70, 0x30, 0x00, 73 | 0x08, 0x08, 0x08, 0x08, 0x08, 74 | 0x00, 0x00, 0x60, 0x60, 0x00, 75 | 0x20, 0x10, 0x08, 0x04, 0x02, 76 | 0x3E, 0x51, 0x49, 0x45, 0x3E, 77 | 0x00, 0x42, 0x7F, 0x40, 0x00, 78 | 0x72, 0x49, 0x49, 0x49, 0x46, 79 | 0x21, 0x41, 0x49, 0x4D, 0x33, 80 | 0x18, 0x14, 0x12, 0x7F, 0x10, 81 | 0x27, 0x45, 0x45, 0x45, 0x39, 82 | 0x3C, 0x4A, 0x49, 0x49, 0x31, 83 | 0x41, 0x21, 0x11, 0x09, 0x07, 84 | 0x36, 0x49, 0x49, 0x49, 0x36, 85 | 0x46, 0x49, 0x49, 0x29, 0x1E, 86 | 0x00, 0x00, 0x14, 0x00, 0x00, 87 | 0x00, 0x40, 0x34, 0x00, 0x00, 88 | 0x00, 0x08, 0x14, 0x22, 0x41, 89 | 0x14, 0x14, 0x14, 0x14, 0x14, 90 | 0x00, 0x41, 0x22, 0x14, 0x08, 91 | 0x02, 0x01, 0x59, 0x09, 0x06, 92 | 0x3E, 0x41, 0x5D, 0x59, 0x4E, 93 | 0x7C, 0x12, 0x11, 0x12, 0x7C, 94 | 0x7F, 0x49, 0x49, 0x49, 0x36, 95 | 0x3E, 0x41, 0x41, 0x41, 0x22, 96 | 0x7F, 0x41, 0x41, 0x41, 0x3E, 97 | 0x7F, 0x49, 0x49, 0x49, 0x41, 98 | 0x7F, 0x09, 0x09, 0x09, 0x01, 99 | 0x3E, 0x41, 0x41, 0x51, 0x73, 100 | 0x7F, 0x08, 0x08, 0x08, 0x7F, 101 | 0x00, 0x41, 0x7F, 0x41, 0x00, 102 | 0x20, 0x40, 0x41, 0x3F, 0x01, 103 | 0x7F, 0x08, 0x14, 0x22, 0x41, 104 | 0x7F, 0x40, 0x40, 0x40, 0x40, 105 | 0x7F, 0x02, 0x1C, 0x02, 0x7F, 106 | 0x7F, 0x04, 0x08, 0x10, 0x7F, 107 | 0x3E, 0x41, 0x41, 0x41, 0x3E, 108 | 0x7F, 0x09, 0x09, 0x09, 0x06, 109 | 0x3E, 0x41, 0x51, 0x21, 0x5E, 110 | 0x7F, 0x09, 0x19, 0x29, 0x46, 111 | 0x26, 0x49, 0x49, 0x49, 0x32, 112 | 0x03, 0x01, 0x7F, 0x01, 0x03, 113 | 0x3F, 0x40, 0x40, 0x40, 0x3F, 114 | 0x1F, 0x20, 0x40, 0x20, 0x1F, 115 | 0x3F, 0x40, 0x38, 0x40, 0x3F, 116 | 0x63, 0x14, 0x08, 0x14, 0x63, 117 | 0x03, 0x04, 0x78, 0x04, 0x03, 118 | 0x61, 0x59, 0x49, 0x4D, 0x43, 119 | 0x00, 0x7F, 0x41, 0x41, 0x41, 120 | 0x02, 0x04, 0x08, 0x10, 0x20, 121 | 0x00, 0x41, 0x41, 0x41, 0x7F, 122 | 0x04, 0x02, 0x01, 0x02, 0x04, 123 | 0x40, 0x40, 0x40, 0x40, 0x40, 124 | 0x00, 0x03, 0x07, 0x08, 0x00, 125 | 0x20, 0x54, 0x54, 0x78, 0x40, 126 | 0x7F, 0x28, 0x44, 0x44, 0x38, 127 | 0x38, 0x44, 0x44, 0x44, 0x28, 128 | 0x38, 0x44, 0x44, 0x28, 0x7F, 129 | 0x38, 0x54, 0x54, 0x54, 0x18, 130 | 0x00, 0x08, 0x7E, 0x09, 0x02, 131 | 0x18, 0xA4, 0xA4, 0x9C, 0x78, 132 | 0x7F, 0x08, 0x04, 0x04, 0x78, 133 | 0x00, 0x44, 0x7D, 0x40, 0x00, 134 | 0x20, 0x40, 0x40, 0x3D, 0x00, 135 | 0x7F, 0x10, 0x28, 0x44, 0x00, 136 | 0x00, 0x41, 0x7F, 0x40, 0x00, 137 | 0x7C, 0x04, 0x78, 0x04, 0x78, 138 | 0x7C, 0x08, 0x04, 0x04, 0x78, 139 | 0x38, 0x44, 0x44, 0x44, 0x38, 140 | 0xFC, 0x18, 0x24, 0x24, 0x18, 141 | 0x18, 0x24, 0x24, 0x18, 0xFC, 142 | 0x7C, 0x08, 0x04, 0x04, 0x08, 143 | 0x48, 0x54, 0x54, 0x54, 0x24, 144 | 0x04, 0x04, 0x3F, 0x44, 0x24, 145 | 0x3C, 0x40, 0x40, 0x20, 0x7C, 146 | 0x1C, 0x20, 0x40, 0x20, 0x1C, 147 | 0x3C, 0x40, 0x30, 0x40, 0x3C, 148 | 0x44, 0x28, 0x10, 0x28, 0x44, 149 | 0x4C, 0x90, 0x90, 0x90, 0x7C, 150 | 0x44, 0x64, 0x54, 0x4C, 0x44, 151 | 0x00, 0x08, 0x36, 0x41, 0x00, 152 | 0x00, 0x00, 0x77, 0x00, 0x00, 153 | 0x00, 0x41, 0x36, 0x08, 0x00, 154 | 0x02, 0x01, 0x02, 0x04, 0x02, 155 | 0x3C, 0x26, 0x23, 0x26, 0x3C, 156 | 0x1E, 0xA1, 0xA1, 0x61, 0x12, 157 | 0x3A, 0x40, 0x40, 0x20, 0x7A, 158 | 0x38, 0x54, 0x54, 0x55, 0x59, 159 | 0x21, 0x55, 0x55, 0x79, 0x41, 160 | 0x21, 0x54, 0x54, 0x78, 0x41, 161 | 0x21, 0x55, 0x54, 0x78, 0x40, 162 | 0x20, 0x54, 0x55, 0x79, 0x40, 163 | 0x0C, 0x1E, 0x52, 0x72, 0x12, 164 | 0x39, 0x55, 0x55, 0x55, 0x59, 165 | 0x39, 0x54, 0x54, 0x54, 0x59, 166 | 0x39, 0x55, 0x54, 0x54, 0x58, 167 | 0x00, 0x00, 0x45, 0x7C, 0x41, 168 | 0x00, 0x02, 0x45, 0x7D, 0x42, 169 | 0x00, 0x01, 0x45, 0x7C, 0x40, 170 | 0xF0, 0x29, 0x24, 0x29, 0xF0, 171 | 0xF0, 0x28, 0x25, 0x28, 0xF0, 172 | 0x7C, 0x54, 0x55, 0x45, 0x00, 173 | 0x20, 0x54, 0x54, 0x7C, 0x54, 174 | 0x7C, 0x0A, 0x09, 0x7F, 0x49, 175 | 0x32, 0x49, 0x49, 0x49, 0x32, 176 | 0x32, 0x48, 0x48, 0x48, 0x32, 177 | 0x32, 0x4A, 0x48, 0x48, 0x30, 178 | 0x3A, 0x41, 0x41, 0x21, 0x7A, 179 | 0x3A, 0x42, 0x40, 0x20, 0x78, 180 | 0x00, 0x9D, 0xA0, 0xA0, 0x7D, 181 | 0x39, 0x44, 0x44, 0x44, 0x39, 182 | 0x3D, 0x40, 0x40, 0x40, 0x3D, 183 | 0x3C, 0x24, 0xFF, 0x24, 0x24, 184 | 0x48, 0x7E, 0x49, 0x43, 0x66, 185 | 0x2B, 0x2F, 0xFC, 0x2F, 0x2B, 186 | 0xFF, 0x09, 0x29, 0xF6, 0x20, 187 | 0xC0, 0x88, 0x7E, 0x09, 0x03, 188 | 0x20, 0x54, 0x54, 0x79, 0x41, 189 | 0x00, 0x00, 0x44, 0x7D, 0x41, 190 | 0x30, 0x48, 0x48, 0x4A, 0x32, 191 | 0x38, 0x40, 0x40, 0x22, 0x7A, 192 | 0x00, 0x7A, 0x0A, 0x0A, 0x72, 193 | 0x7D, 0x0D, 0x19, 0x31, 0x7D, 194 | 0x26, 0x29, 0x29, 0x2F, 0x28, 195 | 0x26, 0x29, 0x29, 0x29, 0x26, 196 | 0x30, 0x48, 0x4D, 0x40, 0x20, 197 | 0x38, 0x08, 0x08, 0x08, 0x08, 198 | 0x08, 0x08, 0x08, 0x08, 0x38, 199 | 0x2F, 0x10, 0xC8, 0xAC, 0xBA, 200 | 0x2F, 0x10, 0x28, 0x34, 0xFA, 201 | 0x00, 0x00, 0x7B, 0x00, 0x00, 202 | 0x08, 0x14, 0x2A, 0x14, 0x22, 203 | 0x22, 0x14, 0x2A, 0x14, 0x08, 204 | 0xAA, 0x00, 0x55, 0x00, 0xAA, 205 | 0xAA, 0x55, 0xAA, 0x55, 0xAA, 206 | 0x00, 0x00, 0x00, 0xFF, 0x00, 207 | 0x10, 0x10, 0x10, 0xFF, 0x00, 208 | 0x14, 0x14, 0x14, 0xFF, 0x00, 209 | 0x10, 0x10, 0xFF, 0x00, 0xFF, 210 | 0x10, 0x10, 0xF0, 0x10, 0xF0, 211 | 0x14, 0x14, 0x14, 0xFC, 0x00, 212 | 0x14, 0x14, 0xF7, 0x00, 0xFF, 213 | 0x00, 0x00, 0xFF, 0x00, 0xFF, 214 | 0x14, 0x14, 0xF4, 0x04, 0xFC, 215 | 0x14, 0x14, 0x17, 0x10, 0x1F, 216 | 0x10, 0x10, 0x1F, 0x10, 0x1F, 217 | 0x14, 0x14, 0x14, 0x1F, 0x00, 218 | 0x10, 0x10, 0x10, 0xF0, 0x00, 219 | 0x00, 0x00, 0x00, 0x1F, 0x10, 220 | 0x10, 0x10, 0x10, 0x1F, 0x10, 221 | 0x10, 0x10, 0x10, 0xF0, 0x10, 222 | 0x00, 0x00, 0x00, 0xFF, 0x10, 223 | 0x10, 0x10, 0x10, 0x10, 0x10, 224 | 0x10, 0x10, 0x10, 0xFF, 0x10, 225 | 0x00, 0x00, 0x00, 0xFF, 0x14, 226 | 0x00, 0x00, 0xFF, 0x00, 0xFF, 227 | 0x00, 0x00, 0x1F, 0x10, 0x17, 228 | 0x00, 0x00, 0xFC, 0x04, 0xF4, 229 | 0x14, 0x14, 0x17, 0x10, 0x17, 230 | 0x14, 0x14, 0xF4, 0x04, 0xF4, 231 | 0x00, 0x00, 0xFF, 0x00, 0xF7, 232 | 0x14, 0x14, 0x14, 0x14, 0x14, 233 | 0x14, 0x14, 0xF7, 0x00, 0xF7, 234 | 0x14, 0x14, 0x14, 0x17, 0x14, 235 | 0x10, 0x10, 0x1F, 0x10, 0x1F, 236 | 0x14, 0x14, 0x14, 0xF4, 0x14, 237 | 0x10, 0x10, 0xF0, 0x10, 0xF0, 238 | 0x00, 0x00, 0x1F, 0x10, 0x1F, 239 | 0x00, 0x00, 0x00, 0x1F, 0x14, 240 | 0x00, 0x00, 0x00, 0xFC, 0x14, 241 | 0x00, 0x00, 0xF0, 0x10, 0xF0, 242 | 0x10, 0x10, 0xFF, 0x10, 0xFF, 243 | 0x14, 0x14, 0x14, 0xFF, 0x14, 244 | 0x10, 0x10, 0x10, 0x1F, 0x00, 245 | 0x00, 0x00, 0x00, 0xF0, 0x10, 246 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 247 | 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 248 | 0xFF, 0xFF, 0xFF, 0x00, 0x00, 249 | 0x00, 0x00, 0x00, 0xFF, 0xFF, 250 | 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 251 | 0x38, 0x44, 0x44, 0x38, 0x44, 252 | 0x7C, 0x2A, 0x2A, 0x3E, 0x14, 253 | 0x7E, 0x02, 0x02, 0x06, 0x06, 254 | 0x02, 0x7E, 0x02, 0x7E, 0x02, 255 | 0x63, 0x55, 0x49, 0x41, 0x63, 256 | 0x38, 0x44, 0x44, 0x3C, 0x04, 257 | 0x40, 0x7E, 0x20, 0x1E, 0x20, 258 | 0x06, 0x02, 0x7E, 0x02, 0x02, 259 | 0x99, 0xA5, 0xE7, 0xA5, 0x99, 260 | 0x1C, 0x2A, 0x49, 0x2A, 0x1C, 261 | 0x4C, 0x72, 0x01, 0x72, 0x4C, 262 | 0x30, 0x4A, 0x4D, 0x4D, 0x30, 263 | 0x30, 0x48, 0x78, 0x48, 0x30, 264 | 0xBC, 0x62, 0x5A, 0x46, 0x3D, 265 | 0x3E, 0x49, 0x49, 0x49, 0x00, 266 | 0x7E, 0x01, 0x01, 0x01, 0x7E, 267 | 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 268 | 0x44, 0x44, 0x5F, 0x44, 0x44, 269 | 0x40, 0x51, 0x4A, 0x44, 0x40, 270 | 0x40, 0x44, 0x4A, 0x51, 0x40, 271 | 0x00, 0x00, 0xFF, 0x01, 0x03, 272 | 0xE0, 0x80, 0xFF, 0x00, 0x00, 273 | 0x08, 0x08, 0x6B, 0x6B, 0x08, 274 | 0x36, 0x12, 0x36, 0x24, 0x36, 275 | 0x06, 0x0F, 0x09, 0x0F, 0x06, 276 | 0x00, 0x00, 0x18, 0x18, 0x00, 277 | 0x00, 0x00, 0x10, 0x10, 0x00, 278 | 0x30, 0x40, 0xFF, 0x01, 0x01, 279 | 0x00, 0x1F, 0x01, 0x01, 0x1E, 280 | 0x00, 0x19, 0x1D, 0x17, 0x12, 281 | 0x00, 0x3C, 0x3C, 0x3C, 0x3C, 282 | 0x00, 0x00, 0x00, 0x00, 0x00 283 | }; 284 | 285 | static const unsigned char font8x16[] = { 286 | // first row defines - FONTWIDTH, FONTHEIGHT, ASCII START CHAR, TOTAL CHARACTERS, FONT MAP WIDTH HIGH, FONT MAP WIDTH LOW (2,56 meaning 256) 287 | 8,16,32,96,2,56, 288 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 289 | 0x00, 0x00, 0x0E, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, 0xD0, 0xBE, 0x90, 0xD0, 0xBE, 0x90, 0x00, 290 | 0x00, 0x1C, 0x62, 0xFF, 0xC2, 0x80, 0x00, 0x00, 0x0C, 0x12, 0x92, 0x4C, 0xB0, 0x88, 0x06, 0x00, 291 | 0x80, 0x7C, 0x62, 0xB2, 0x1C, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x0E, 0x00, 0x00, 0x00, 0x00, 292 | 0x00, 0xE0, 0x18, 0x04, 0x02, 0x02, 0x00, 0x00, 0x00, 0x02, 0x02, 0x04, 0x18, 0xE0, 0x00, 0x00, 293 | 0x00, 0x24, 0x18, 0x7E, 0x18, 0x24, 0x00, 0x00, 0x80, 0x80, 0x80, 0xF0, 0x80, 0x80, 0x80, 0x00, 294 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 295 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x60, 0x18, 0x06, 0x00, 0x00, 296 | 0xF8, 0x04, 0xC2, 0x32, 0x0C, 0xF8, 0x00, 0x00, 0x00, 0x04, 0x04, 0xFE, 0x00, 0x00, 0x00, 0x00, 297 | 0x00, 0x02, 0x82, 0x42, 0x22, 0x1C, 0x00, 0x00, 0x00, 0x02, 0x22, 0x22, 0x22, 0xDC, 0x00, 0x00, 298 | 0xC0, 0xA0, 0x98, 0x84, 0xFE, 0x80, 0x80, 0x00, 0x00, 0x1E, 0x12, 0x12, 0x22, 0xC2, 0x00, 0x00, 299 | 0xF8, 0x44, 0x22, 0x22, 0x22, 0xC0, 0x00, 0x00, 0x00, 0x02, 0x02, 0xC2, 0x32, 0x0A, 0x06, 0x00, 300 | 0x00, 0x8C, 0x52, 0x22, 0x52, 0x8C, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x42, 0x26, 0xF8, 0x00, 0x00, 301 | 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 302 | 0x80, 0x80, 0x40, 0x40, 0x20, 0x20, 0x10, 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00, 303 | 0x10, 0x20, 0x20, 0x40, 0x40, 0x80, 0x80, 0x00, 0x00, 0x02, 0x82, 0x42, 0x22, 0x1C, 0x00, 0x00, 304 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 305 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 306 | 0x00, 0x04, 0x04, 0x0F, 0x04, 0x03, 0x00, 0x00, 0x04, 0x02, 0x01, 0x03, 0x04, 0x04, 0x03, 0x00, 307 | 0x03, 0x04, 0x04, 0x04, 0x05, 0x03, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 308 | 0x00, 0x03, 0x06, 0x08, 0x10, 0x10, 0x00, 0x00, 0x00, 0x10, 0x10, 0x08, 0x06, 0x03, 0x00, 0x00, 309 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 310 | 0x00, 0x00, 0x16, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 311 | 0x00, 0x00, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0x04, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 312 | 0x01, 0x03, 0x04, 0x04, 0x02, 0x01, 0x00, 0x00, 0x00, 0x04, 0x04, 0x07, 0x04, 0x04, 0x00, 0x00, 313 | 0x00, 0x07, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 314 | 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 315 | 0x01, 0x02, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 316 | 0x00, 0x03, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x02, 0x01, 0x00, 0x00, 317 | 0x00, 0x00, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x0E, 0x00, 0x00, 0x00, 0x00, 318 | 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x04, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 319 | 0x04, 0x02, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 320 | 0xF8, 0x04, 0x72, 0x8A, 0xFA, 0x84, 0x78, 0x00, 0x00, 0xC0, 0x38, 0x06, 0x38, 0xC0, 0x00, 0x00, 321 | 0x00, 0xFE, 0x22, 0x22, 0x22, 0xDC, 0x00, 0x00, 0xF8, 0x04, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 322 | 0xFE, 0x02, 0x02, 0x02, 0x04, 0xF8, 0x00, 0x00, 0x00, 0xFE, 0x22, 0x22, 0x22, 0x22, 0x00, 0x00, 323 | 0x00, 0xFE, 0x22, 0x22, 0x22, 0x22, 0x00, 0x00, 0xF8, 0x04, 0x02, 0x02, 0x22, 0xE2, 0x00, 0x00, 324 | 0xFE, 0x20, 0x20, 0x20, 0x20, 0xFE, 0x00, 0x00, 0x00, 0x02, 0x02, 0xFE, 0x02, 0x02, 0x00, 0x00, 325 | 0x00, 0x00, 0x00, 0x02, 0x02, 0xFE, 0x00, 0x00, 0xFE, 0x40, 0xB0, 0x08, 0x04, 0x02, 0x00, 0x00, 326 | 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x0C, 0x70, 0x80, 0x70, 0x0C, 0xFE, 0x00, 327 | 0xFE, 0x0C, 0x30, 0xC0, 0x00, 0xFE, 0x00, 0x00, 0xF8, 0x04, 0x02, 0x02, 0x04, 0xF8, 0x00, 0x00, 328 | 0xFE, 0x42, 0x42, 0x42, 0x22, 0x1C, 0x00, 0x00, 0xF8, 0x04, 0x02, 0x02, 0x04, 0xF8, 0x00, 0x00, 329 | 0x00, 0xFE, 0x42, 0x42, 0xA2, 0x1C, 0x00, 0x00, 0x00, 0x1C, 0x22, 0x42, 0x42, 0x80, 0x00, 0x00, 330 | 0x02, 0x02, 0x02, 0xFE, 0x02, 0x02, 0x02, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 331 | 0x06, 0x38, 0xC0, 0x00, 0xC0, 0x38, 0x06, 0x00, 0x3E, 0xC0, 0xF0, 0x0E, 0xF0, 0xC0, 0x3E, 0x00, 332 | 0x00, 0x06, 0x98, 0x60, 0x98, 0x06, 0x00, 0x00, 0x00, 0x06, 0x18, 0xE0, 0x18, 0x06, 0x00, 0x00, 333 | 0x02, 0x02, 0xC2, 0x32, 0x0A, 0x06, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x02, 0x02, 0x02, 0x02, 0x00, 334 | 0x00, 0x06, 0x18, 0x60, 0x80, 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0xFE, 0x00, 0x00, 0x00, 335 | 0x40, 0x30, 0x0C, 0x0C, 0x30, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 336 | 0x01, 0x02, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x06, 0x01, 0x01, 0x01, 0x01, 0x01, 0x06, 0x00, 337 | 0x00, 0x07, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 0x01, 0x02, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 338 | 0x07, 0x04, 0x04, 0x04, 0x02, 0x01, 0x00, 0x00, 0x00, 0x07, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 339 | 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x04, 0x04, 0x04, 0x07, 0x00, 0x00, 340 | 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x04, 0x04, 0x07, 0x04, 0x04, 0x00, 0x00, 341 | 0x00, 0x04, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 0x07, 0x00, 0x00, 0x01, 0x02, 0x04, 0x00, 0x00, 342 | 0x00, 0x07, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x07, 0x00, 0x00, 0x01, 0x00, 0x00, 0x07, 0x00, 343 | 0x07, 0x00, 0x00, 0x00, 0x03, 0x07, 0x00, 0x00, 0x01, 0x02, 0x04, 0x04, 0x02, 0x01, 0x00, 0x00, 344 | 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x04, 0x0C, 0x12, 0x11, 0x10, 0x00, 345 | 0x00, 0x07, 0x00, 0x00, 0x01, 0x06, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 346 | 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 347 | 0x00, 0x00, 0x01, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 348 | 0x00, 0x06, 0x01, 0x00, 0x01, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 349 | 0x06, 0x05, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x10, 0x10, 0x10, 0x10, 0x00, 350 | 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x04, 0x00, 0x10, 0x10, 0x10, 0x10, 0x1F, 0x00, 0x00, 0x00, 351 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 352 | 0x00, 0x00, 0x02, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x10, 0x10, 0x10, 0xF0, 0x00, 0x00, 353 | 0x00, 0xFE, 0x20, 0x10, 0x10, 0xE0, 0x00, 0x00, 0x00, 0xE0, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 354 | 0x00, 0xE0, 0x10, 0x10, 0x10, 0xFE, 0x00, 0x00, 0x00, 0xE0, 0x90, 0x90, 0x90, 0xE0, 0x00, 0x00, 355 | 0x00, 0x20, 0xFC, 0x22, 0x22, 0x22, 0x02, 0x00, 0x00, 0xE0, 0x10, 0x10, 0x10, 0xF0, 0x00, 0x00, 356 | 0x00, 0xFE, 0x20, 0x10, 0x10, 0xE0, 0x00, 0x00, 0x10, 0x10, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x00, 357 | 0x00, 0x10, 0x10, 0x10, 0xF2, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x80, 0x40, 0x20, 0x10, 0x00, 0x00, 358 | 0x00, 0x02, 0x02, 0xFE, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x20, 0x10, 0xF0, 0x20, 0x10, 0xF0, 0x00, 359 | 0x00, 0xF0, 0x20, 0x10, 0x10, 0xE0, 0x00, 0x00, 0x00, 0xE0, 0x10, 0x10, 0x10, 0xE0, 0x00, 0x00, 360 | 0x00, 0xF0, 0x20, 0x10, 0x10, 0xE0, 0x00, 0x00, 0x00, 0xE0, 0x10, 0x10, 0x10, 0xF0, 0x00, 0x00, 361 | 0x00, 0xF0, 0x20, 0x10, 0x10, 0x70, 0x00, 0x00, 0x00, 0x60, 0x90, 0x90, 0x90, 0x20, 0x00, 0x00, 362 | 0x00, 0x20, 0x20, 0xFC, 0x20, 0x20, 0x20, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 363 | 0x00, 0x70, 0x80, 0x00, 0x80, 0x70, 0x00, 0x00, 0xF0, 0x00, 0xC0, 0x30, 0xC0, 0x00, 0xF0, 0x00, 364 | 0x00, 0x30, 0xC0, 0xC0, 0x30, 0x00, 0x00, 0x00, 0x00, 0x30, 0xC0, 0x00, 0x80, 0x70, 0x00, 0x00, 365 | 0x00, 0x10, 0x10, 0x90, 0x50, 0x30, 0x00, 0x00, 0x00, 0x80, 0x80, 0x7E, 0x02, 0x02, 0x00, 0x00, 366 | 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x7E, 0x80, 0x80, 0x00, 0x00, 367 | 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 368 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x02, 0x07, 0x00, 0x00, 369 | 0x00, 0x07, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 370 | 0x00, 0x03, 0x04, 0x04, 0x02, 0x07, 0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 371 | 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x24, 0x24, 0x22, 0x1F, 0x00, 0x00, 372 | 0x00, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x04, 0x04, 0x00, 0x00, 0x00, 373 | 0x20, 0x20, 0x20, 0x20, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x01, 0x02, 0x04, 0x00, 0x00, 374 | 0x00, 0x00, 0x00, 0x07, 0x04, 0x04, 0x00, 0x00, 0x07, 0x00, 0x00, 0x07, 0x00, 0x00, 0x07, 0x00, 375 | 0x00, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 376 | 0x00, 0x3F, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x02, 0x3F, 0x00, 0x00, 377 | 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x04, 0x04, 0x04, 0x03, 0x00, 0x00, 378 | 0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x04, 0x00, 0x00, 0x03, 0x04, 0x04, 0x02, 0x07, 0x00, 0x00, 379 | 0x00, 0x00, 0x03, 0x04, 0x03, 0x00, 0x00, 0x00, 0x01, 0x06, 0x01, 0x00, 0x01, 0x06, 0x01, 0x00, 380 | 0x00, 0x06, 0x01, 0x01, 0x06, 0x00, 0x00, 0x00, 0x20, 0x20, 0x31, 0x0E, 0x03, 0x00, 0x00, 0x00, 381 | 0x00, 0x06, 0x05, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x10, 0x10, 0x00, 0x00, 382 | 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x1F, 0x00, 0x00, 0x00, 0x00, 383 | 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 384 | }; 385 | 386 | static const unsigned char sevensegment [] = { 387 | // first row defines - FONTWIDTH, FONTHEIGHT, ASCII START CHAR, TOTAL CHARACTERS, FONT MAP WIDTH HIGH, FONT MAP WIDTH LOW (2,56 meaning 256) 388 | 10,16,46,12,1,20, 389 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 390 | 0x00, 0x00, 0x00, 0x00, 0x78, 0xFC, 0x02, 0x03, 0x03, 0x03, 0x03, 0x02, 0xFC, 0x78, 0x00, 0x00, 391 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x7E, 0x00, 0x00, 0x02, 0x83, 0x83, 0x83, 0x83, 0x02, 392 | 0xFC, 0x78, 0x00, 0x00, 0x02, 0x83, 0x83, 0x83, 0x83, 0x02, 0xFC, 0x78, 0x7E, 0xFF, 0x00, 0x80, 393 | 0x80, 0x80, 0x80, 0x00, 0xFF, 0x7E, 0x78, 0xFC, 0x02, 0x83, 0x83, 0x83, 0x83, 0x02, 0x00, 0x00, 394 | 0x78, 0xFC, 0x02, 0x83, 0x83, 0x83, 0x83, 0x02, 0x00, 0x00, 0x00, 0x02, 0x03, 0x03, 0x03, 0x03, 395 | 0x03, 0x02, 0xFC, 0x78, 0x78, 0xFC, 0x02, 0x83, 0x83, 0x83, 0x83, 0x02, 0xFC, 0x78, 0x78, 0xFC, 396 | 0x02, 0x83, 0x83, 0x83, 0x83, 0x02, 0xFC, 0x78, 0x00, 0x00, 0x00, 0x60, 0xF0, 0xF0, 0x60, 0x00, 397 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x3F, 0x40, 0xC0, 398 | 0xC0, 0xC0, 0xC0, 0x40, 0x3F, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x7E, 399 | 0x1C, 0x3E, 0x41, 0xC1, 0xC1, 0xC1, 0xC1, 0x41, 0x00, 0x00, 0x00, 0x00, 0x41, 0xC1, 0xC1, 0xC1, 400 | 0xC1, 0x41, 0x3E, 0x1C, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0xFF, 0x7E, 0x00, 0x00, 401 | 0x41, 0xC1, 0xC1, 0xC1, 0xC1, 0x41, 0x3E, 0x1C, 0x1C, 0x3E, 0x41, 0xC1, 0xC1, 0xC1, 0xC1, 0x41, 402 | 0x3E, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x7E, 0x1C, 0x3E, 0x41, 0xC1, 403 | 0xC1, 0xC1, 0xC1, 0x41, 0x3E, 0x1C, 0x00, 0x00, 0x41, 0xC1, 0xC1, 0xC1, 0xC1, 0x41, 0x3E, 0x1C 404 | }; 405 | 406 | static const unsigned char fontlargenumber[] = { 407 | // first row defines - FONTWIDTH, FONTHEIGHT, ASCII START CHAR, TOTAL CHARACTERS, FONT MAP WIDTH HIGH, FONT MAP WIDTH LOW (2,56 meaning 256) 408 | 12,48,48,11,1,32, 409 | 0x00, 0xC0, 0xF8, 0x7C, 0x3E, 0x3E, 0xFC, 0xF8, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xE0, 410 | 0x78, 0xFE, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x7C, 0x3C, 0x3E, 0x3E, 0xFE, 0xFC, 411 | 0xE0, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x3E, 0x3E, 0x3E, 0xFE, 0xF8, 0xC0, 0x00, 0x00, 0x00, 0x00, 412 | 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFE, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFE, 0x3E, 413 | 0x3E, 0x3E, 0x3E, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF0, 0xFC, 0x3E, 0x3E, 0x3E, 414 | 0xFC, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0xFE, 0xFE, 0x00, 0x00, 415 | 0x00, 0x00, 0xC0, 0xF8, 0xFE, 0x3E, 0x7E, 0xFC, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFC, 416 | 0x7E, 0x3E, 0xFE, 0xF8, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xC0, 0x00, 417 | 0x00, 0x00, 0x00, 0x00, 0xF0, 0xFF, 0x0F, 0x00, 0x00, 0x00, 0xF9, 0xFF, 0xFF, 0xF0, 0x00, 0x00, 418 | 0x00, 0x00, 0x07, 0x03, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 419 | 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 420 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 421 | 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0x3F, 422 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xFC, 423 | 0x7F, 0x03, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 424 | 0x00, 0xFE, 0xFF, 0x03, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 425 | 0x3F, 0x7F, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 426 | 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 427 | 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFE, 0x1F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xF8, 428 | 0xFC, 0xFF, 0xC7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xFE, 0x3F, 0x03, 0x00, 0xFF, 0xFF, 429 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x3F, 0x3E, 0x7E, 0xFC, 0xF8, 0xE0, 0x00, 0x00, 0x00, 0x00, 430 | 0x00, 0xFF, 0xFF, 0x80, 0xF0, 0x7C, 0x7C, 0xF8, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 431 | 0x80, 0xF8, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x9F, 0xFF, 0xF8, 0xFE, 0x1F, 432 | 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x80, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 433 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xC0, 0xFC, 434 | 0x7F, 0x03, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 435 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFE, 0x0F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 436 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0F, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0xE7, 0xE0, 437 | 0xE0, 0xE0, 0xFF, 0xFF, 0xE0, 0xE0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xFF, 438 | 0xFE, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x03, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0x00, 0x00, 439 | 0x00, 0x00, 0x00, 0xF0, 0xFF, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xFC, 0x3F, 440 | 0x03, 0x03, 0x1F, 0xFF, 0xFC, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x1F, 0x3E, 0x3E, 0x0F, 0x01, 441 | 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 442 | 0x07, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 443 | 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFE, 0x0F, 0x00, 0x00, 0x00, 0x00, 444 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xFF, 0x7F, 0x00, 0x00, 0x00, 445 | 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0xFF, 0xFF, 0x03, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 446 | 0x00, 0x00, 0xC0, 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x80, 447 | 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 448 | 0x00, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x80, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 449 | 0x00, 0x00, 0x80, 0xFC, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 450 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x1F, 0x3F, 0x7C, 0x7C, 0x3F, 0x1F, 0x03, 0x00, 0x00, 0x00, 451 | 0x00, 0x00, 0x7C, 0x7C, 0x7C, 0x7F, 0x7F, 0x7C, 0x7C, 0x7C, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x7C, 452 | 0x7C, 0x7C, 0x7C, 0x7C, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x7E, 0x7C, 0x7C, 0x7E, 0x1F, 0x07, 453 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x00, 0x00, 0x00, 0x00, 454 | 0x00, 0x1F, 0x3E, 0x7C, 0x7C, 0x3E, 0x1F, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x1F, 455 | 0x7F, 0x7C, 0x7C, 0x3F, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x00, 0x00, 0x00, 0x00, 456 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x1F, 0x3F, 0x7E, 0x7C, 0x7E, 0x3F, 0x1F, 0x01, 0x00, 0x00, 457 | 0x00, 0x00, 0x3E, 0x7C, 0x7C, 0x7E, 0x3F, 0x0F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 458 | 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 459 | }; 460 | 461 | #endif -------------------------------------------------------------------------------- /Firmware/pong/oled/Edison_OLED.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Edison_OLED.cpp 3 | Main source code for the Edison OLED Block C++ Library 4 | 5 | Jim Lindblom @ SparkFun Electronics 6 | January 8, 2014 7 | https://github.com/sparkfun/Edison_OLED_Block/tree/master/Firmware/ 8 | 9 | This file defines the hardware interface for the Edison OLED Block 10 | 11 | This code was heavily based around the MicroView library, written by GeekAmmo 12 | (https://github.com/geekammo/MicroView-Arduino-Library), and released under 13 | the terms of the GNU General Public License as published by the Free Software 14 | Foundation, either version 3 of the License, or (at your option) any later 15 | version. 16 | 17 | This program is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | GNU General Public License for more details. 21 | 22 | You should have received a copy of the GNU General Public License 23 | along with this program. If not, see . 24 | ******************************************************************************/ 25 | #include "Edison_OLED.h" 26 | #include "../spi/spi.h" 27 | #include "../gpio/gpio.h" 28 | #include "edison_fonts.h" // External file to store font bit-map arrays 29 | #include 30 | #include // for memset 31 | #include // for sprintf 32 | #include // for usleep 33 | 34 | // Change the total fonts included 35 | #define TOTALFONTS 4 36 | #define recvLEN 100 37 | char serInStr[recvLEN]; 38 | unsigned char serCmd[recvLEN]; 39 | 40 | // Add the font name as declared in the header file 41 | const unsigned char *edOLED::fontsPointer[]={ 42 | font5x7 43 | ,font8x16 44 | ,sevensegment 45 | ,fontlargenumber 46 | }; 47 | 48 | /** \brief edOLED screen buffer. 49 | 50 | Page buffer 64 x 48 divided by 8 = 384 unsigned chars 51 | Page buffer is required because in SPI mode, the host cannot read the SSD1306's 52 | GDRAM of the controller. This page buffer serves as a scratch RAM for graphical 53 | functions. All drawing function will first be drawn on this page buffer, only 54 | upon calling display() function will transfer the page buffer to the actual LCD 55 | controller's memory. 56 | */ 57 | static unsigned char screenmemory [] = { 58 | /* LCD Memory organised in 64 horizontal pixel and 6 rows of unsigned char 59 | B B .............B ----- 60 | y y .............y \ 61 | t t .............t \ 62 | e e .............e \ 63 | 0 1 .............63 \ 64 | \ 65 | D0 D0.............D0 \ 66 | D1 D1.............D1 / ROW 0 67 | D2 D2.............D2 / 68 | D3 D3.............D3 / 69 | D4 D4.............D4 / 70 | D5 D5.............D5 / 71 | D6 D6.............D6 / 72 | D7 D7.............D7 ---- 73 | */ 74 | //SparkFun Electronics LOGO 75 | 76 | // ROW0, unsigned char0 to unsigned char63 77 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 78 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xF8, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 79 | 0xFF, 0xFF, 0xFF, 0x0F, 0x07, 0x07, 0x06, 0x06, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 80 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 81 | 82 | // ROW1, unsigned char64 to unsigned char127 83 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 84 | 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x81, 0x07, 0x0F, 0x3F, 0x3F, 0xFF, 0xFF, 0xFF, 85 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFC, 0xFC, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFC, 0xF8, 0xE0, 86 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 87 | 88 | // ROW2, unsigned char128 to unsigned char191 89 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 90 | 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF1, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xF0, 0xFD, 0xFF, 91 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 92 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 93 | 94 | // ROW3, unsigned char192 to unsigned char255 95 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 96 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 97 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0x07, 0x01, 98 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 99 | 100 | // ROW4, unsigned char256 to unsigned char319 101 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 102 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0x1F, 0x0F, 0x0F, 0x0F, 0x0F, 103 | 0x0F, 0x0F, 0x0F, 0x0F, 0x07, 0x07, 0x07, 0x03, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 104 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 105 | 106 | // ROW5, unsigned char320 to unsigned char383 107 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 108 | 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 109 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 110 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 111 | }; 112 | 113 | // Pin definitions: 114 | gpio CS_PIN(111, OUTPUT, HIGH); 115 | gpio RST_PIN(15, OUTPUT, HIGH); 116 | gpio DC_PIN(14, OUTPUT, HIGH); 117 | gpio SCLK_PIN(109, SPI, HIGH); 118 | gpio MOSI_PIN(115, SPI, HIGH); 119 | 120 | // SPI set up: 121 | spiPort *spi5 = new spiPort(); 122 | //spiDevice oledSPI(spi5); 123 | spiDevice oledSPI(spi5, SPI_MODE_0, 10000000, false, &CS_PIN); 124 | #define pgm_read_byte(x) (*(x)) 125 | 126 | edOLED::edOLED() 127 | { 128 | 129 | } 130 | 131 | /** \brief Initialization of edOLED Library. 132 | 133 | Setup IO pins for SPI port then send initialization commands to the 134 | SSD1306 controller inside the OLED. 135 | */ 136 | void edOLED::begin() 137 | { 138 | // default 5x7 font 139 | setFontType(0); 140 | setColor(WHITE); 141 | setDrawMode(NORM); 142 | setCursor(0,0); 143 | 144 | spiSetup(); 145 | 146 | RST_PIN.pinWrite(HIGH); //(digitalWrite(rstPin, HIGH); 147 | usleep(5000); // VDD (3.3V) goes high at start, lets just chill for 5 ms 148 | RST_PIN.pinWrite(LOW); // bring reset low 149 | usleep(10000); // wait 10ms 150 | RST_PIN.pinWrite(HIGH); //digitalWrite(rstPin, HIGH); 151 | 152 | // Init sequence for 64x48 OLED module 153 | command(DISPLAYOFF); // 0xAE 154 | 155 | command(SETDISPLAYCLOCKDIV); // 0xD5 156 | command(0x80); // the suggested ratio 0x80 157 | 158 | command(SETMULTIPLEX); // 0xA8 159 | command(0x2F); 160 | 161 | command(SETDISPLAYOFFSET); // 0xD3 162 | command(0x0); // no offset 163 | 164 | command(SETSTARTLINE | 0x0); // line #0 165 | 166 | command(CHARGEPUMP); // enable charge pump 167 | command(0x14); 168 | 169 | command(NORMALDISPLAY); // 0xA6 170 | command(DISPLAYALLONRESUME); // 0xA4 171 | 172 | command(SEGREMAP | 0x1); 173 | command(COMSCANDEC); 174 | 175 | command(SETCOMPINS); // 0xDA 176 | command(0x12); 177 | 178 | command(SETCONTRAST); // 0x81 179 | command(0x8F); 180 | 181 | command(SETPRECHARGE); // 0xd9 182 | command(0xF1); 183 | 184 | command(SETVCOMDESELECT); // 0xDB 185 | command(0x40); 186 | 187 | command(DISPLAYON); //--turn on oled panel 188 | clear(ALL); // Erase hardware memory inside the OLED 189 | } 190 | 191 | /** \brief SPI command. 192 | 193 | Setup DC and SS pins, then send command via SPI to SSD1306 controller. 194 | */ 195 | void edOLED::command(unsigned char c) 196 | { 197 | DC_PIN.pinWrite(LOW); // DC pin LOW 198 | spiTransfer(c); 199 | } 200 | 201 | /** \brief SPI data. 202 | 203 | Setup DC and SS pins, then send data via SPI to SSD1306 controller. 204 | */ 205 | void edOLED::data(unsigned char c) 206 | { 207 | DC_PIN.pinWrite(HIGH); // DC HIGH 208 | spiTransfer(c); 209 | } 210 | 211 | /** \brief Set SSD1306 page address. 212 | 213 | Send page address command and address to the SSD1306 OLED controller. 214 | */ 215 | void edOLED::setPageAddress(unsigned char add) 216 | { 217 | add=0xb0|add; 218 | command(add); 219 | return; 220 | } 221 | 222 | /** \brief Set SSD1306 column address. 223 | 224 | Send column address command and address to the SSD1306 OLED controller. 225 | */ 226 | void edOLED::setColumnAddress(unsigned char add) 227 | { 228 | command((0x10|(add>>4))+0x02); 229 | command((0x0f&add)); 230 | return; 231 | } 232 | 233 | /** \brief Clear screen buffer or SSD1306's memory. 234 | 235 | To clear GDRAM inside the LCD controller, pass in the variable mode = 236 | ALL and to clear screen page buffer pass in the variable mode = PAGE. 237 | */ 238 | void edOLED::clear(unsigned char mode) 239 | { 240 | // unsigned char page=6, col=0x40; 241 | if (mode==ALL) 242 | { 243 | for (int i=0;i<8; i++) 244 | { 245 | setPageAddress(i); 246 | setColumnAddress(0); 247 | for (int j=0; j<0x80; j++) 248 | { 249 | data(0); 250 | } 251 | } 252 | } 253 | else 254 | { 255 | memset(screenmemory,0,384); // (64 x 48) / 8 = 384 256 | } 257 | } 258 | 259 | /** \brief Clear or replace screen buffer or SSD1306's memory with a character. 260 | 261 | To clear GDRAM inside the LCD controller, pass in the variable mode = ALL 262 | with c character and to clear screen page buffer, pass in the variable 263 | mode = PAGE with c character. 264 | */ 265 | void edOLED::clear(unsigned char mode, unsigned char c) 266 | { 267 | //unsigned char page=6, col=0x40; 268 | if (mode==ALL) 269 | { 270 | for (int i=0;i<8; i++) 271 | { 272 | setPageAddress(i); 273 | setColumnAddress(0); 274 | for (int j=0; j<0x80; j++) 275 | { 276 | data(c); 277 | } 278 | } 279 | } 280 | else 281 | { 282 | memset(screenmemory,c,384); // (64 x 48) / 8 = 384 283 | display(); 284 | } 285 | } 286 | 287 | /** \brief Invert display. 288 | 289 | The WHITE color of the display will turn to BLACK and the BLACK will turn 290 | to WHITE. 291 | */ 292 | void edOLED::invert(unsigned char inv) 293 | { 294 | if (inv) 295 | command(INVERTDISPLAY); 296 | else 297 | command(NORMALDISPLAY); 298 | } 299 | 300 | /** \brief Set contrast. 301 | 302 | OLED contract value from 0 to 255. Note: Contrast level is not very obvious. 303 | */ 304 | void edOLED::contrast(unsigned char contrast) 305 | { 306 | command(SETCONTRAST); // 0x81 307 | command(contrast); 308 | } 309 | 310 | /** \brief Transfer display memory. 311 | 312 | Bulk move the screen buffer to the SSD1306 controller's memory so that images/graphics drawn on the screen buffer will be displayed on the OLED. 313 | */ 314 | void edOLED::display(void) 315 | { 316 | unsigned char i, j; 317 | 318 | for (i=0; i<6; i++) 319 | { 320 | setPageAddress(i); 321 | setColumnAddress(0); 322 | for (j=0;j<0x40;j++) 323 | { 324 | data(screenmemory[i*0x40+j]); 325 | } 326 | } 327 | } 328 | 329 | /** \brief write a character to the display 330 | 331 | */ 332 | unsigned char edOLED::write(unsigned char c) 333 | { 334 | if (c == '\n') 335 | { 336 | cursorY += fontHeight; 337 | cursorX = 0; 338 | } 339 | else if (c == '\r') 340 | { 341 | // skip 342 | } 343 | else 344 | { 345 | drawChar(cursorX, cursorY, c, foreColor, drawMode); 346 | cursorX += fontWidth+1; 347 | if ((cursorX > (LCDWIDTH - fontWidth))) 348 | { 349 | cursorY += fontHeight; 350 | cursorX = 0; 351 | } 352 | } 353 | 354 | return 1; 355 | } 356 | 357 | 358 | void edOLED::print(const char * c) 359 | { 360 | int len = strlen(c); 361 | 362 | for (int i=0; i=LCDWIDTH) || (y<0) || (y>=LCDHEIGHT)) 408 | return; 409 | 410 | if (mode==XOR) 411 | { 412 | if (color==WHITE) 413 | screenmemory[x+ (y/8)*LCDWIDTH] ^= (1<<(y%8)); 414 | } 415 | else 416 | { 417 | if (color==WHITE) 418 | screenmemory[x+ (y/8)*LCDWIDTH] |= (1<<(y%8)); 419 | else 420 | screenmemory[x+ (y/8)*LCDWIDTH] &= ~(1<<(y%8)); 421 | } 422 | } 423 | 424 | /** \brief Draw line. 425 | 426 | Draw line using current fore color and current draw mode from x0,y0 to x1,y1 of the screen buffer. 427 | */ 428 | void edOLED::line(unsigned char x0, unsigned char y0, unsigned char x1, unsigned char y1) 429 | { 430 | line(x0,y0,x1,y1,foreColor,drawMode); 431 | } 432 | 433 | /** \brief Draw line with color and mode. 434 | 435 | Draw line using color and mode from x0,y0 to x1,y1 of the screen buffer. 436 | */ 437 | void edOLED::line(unsigned char x0, unsigned char y0, unsigned char x1, unsigned char y1, unsigned char color, unsigned char mode) 438 | { 439 | unsigned char steep = abs(y1 - y0) > abs(x1 - x0); 440 | if (steep) 441 | { 442 | swapOLED(x0, y0); 443 | swapOLED(x1, y1); 444 | } 445 | 446 | if (x0 > x1) 447 | { 448 | swapOLED(x0, x1); 449 | swapOLED(y0, y1); 450 | } 451 | 452 | unsigned char dx, dy; 453 | dx = x1 - x0; 454 | dy = abs(y1 - y0); 455 | 456 | int8_t err = dx / 2; 457 | int8_t ystep; 458 | 459 | if (y0 < y1) 460 | { 461 | ystep = 1; 462 | } 463 | else 464 | { 465 | ystep = -1; 466 | } 467 | 468 | for (; x0= 0) 603 | { 604 | y--; 605 | ddF_y += 2; 606 | f += ddF_y; 607 | } 608 | x++; 609 | ddF_x += 2; 610 | f += ddF_x; 611 | 612 | pixel(x0 + x, y0 + y, color, mode); 613 | pixel(x0 - x, y0 + y, color, mode); 614 | pixel(x0 + x, y0 - y, color, mode); 615 | pixel(x0 - x, y0 - y, color, mode); 616 | 617 | pixel(x0 + y, y0 + x, color, mode); 618 | pixel(x0 - y, y0 + x, color, mode); 619 | pixel(x0 + y, y0 - x, color, mode); 620 | pixel(x0 - y, y0 - x, color, mode); 621 | 622 | } 623 | } 624 | 625 | /** \brief Draw filled circle. 626 | 627 | Draw filled circle with radius using current fore color and current draw mode at x,y of the screen buffer. 628 | */ 629 | void edOLED::circleFill(unsigned char x0, unsigned char y0, unsigned char radius) 630 | { 631 | circleFill(x0,y0,radius,foreColor,drawMode); 632 | } 633 | 634 | /** \brief Draw filled circle with color and mode. 635 | 636 | Draw filled circle with radius using color and mode at x,y of the screen buffer. 637 | */ 638 | void edOLED::circleFill(unsigned char x0, unsigned char y0, unsigned char radius, unsigned char color, unsigned char mode) 639 | { 640 | int8_t f = 1 - radius; 641 | int8_t ddF_x = 1; 642 | int8_t ddF_y = -2 * radius; 643 | int8_t x = 0; 644 | int8_t y = radius; 645 | 646 | // Temporary disable fill circle for XOR mode. 647 | if (mode==XOR) return; 648 | 649 | for (unsigned char i=y0-radius; i<=y0+radius; i++) 650 | { 651 | pixel(x0, i, color, mode); 652 | } 653 | 654 | while (x= 0) 657 | { 658 | y--; 659 | ddF_y += 2; 660 | f += ddF_y; 661 | } 662 | x++; 663 | ddF_x += 2; 664 | f += ddF_x; 665 | 666 | for (unsigned char i=y0-y; i<=y0+y; i++) 667 | { 668 | pixel(x0+x, i, color, mode); 669 | pixel(x0-x, i, color, mode); 670 | } 671 | for (unsigned char i=y0-x; i<=y0+x; i++) 672 | { 673 | pixel(x0+y, i, color, mode); 674 | pixel(x0-y, i, color, mode); 675 | } 676 | } 677 | } 678 | 679 | /** \brief Get LCD height. 680 | 681 | The height of the LCD return as unsigned char. 682 | */ 683 | unsigned char edOLED::getLCDHeight(void) 684 | { 685 | return LCDHEIGHT; 686 | } 687 | 688 | /** \brief Get LCD width. 689 | 690 | The width of the LCD return as unsigned char. 691 | */ 692 | unsigned char edOLED::getLCDWidth(void) 693 | { 694 | return LCDWIDTH; 695 | } 696 | 697 | /** \brief Get font width. 698 | 699 | The cucrrent font's width return as unsigned char. 700 | */ 701 | unsigned char edOLED::getFontWidth(void) 702 | { 703 | return fontWidth; 704 | } 705 | 706 | /** \brief Get font height. 707 | 708 | The current font's height return as unsigned char. 709 | */ 710 | unsigned char edOLED::getFontHeight(void) 711 | { 712 | return fontHeight; 713 | } 714 | 715 | /** \brief Get font starting character. 716 | 717 | Return the starting ASCII character of the currnet font, not all fonts start with ASCII character 0. Custom fonts can start from any ASCII character. 718 | */ 719 | unsigned char edOLED::getFontStartChar(void) 720 | { 721 | return fontStartChar; 722 | } 723 | 724 | /** \brief Get font total characters. 725 | 726 | Return the total characters of the current font. 727 | */ 728 | unsigned char edOLED::getFontTotalChar(void) 729 | { 730 | return fontTotalChar; 731 | } 732 | 733 | /** \brief Get total fonts. 734 | 735 | Return the total number of fonts loaded into the edOLED's flash memory. 736 | */ 737 | unsigned char edOLED::getTotalFonts(void) 738 | { 739 | return TOTALFONTS; 740 | } 741 | 742 | /** \brief Get font type. 743 | 744 | Return the font type number of the current font. 745 | */ 746 | unsigned char edOLED::getFontType(void) 747 | { 748 | return fontType; 749 | } 750 | 751 | /** \brief Set font type. 752 | 753 | Set the current font type number, ie changing to different fonts base on the type provided. 754 | */ 755 | unsigned char edOLED::setFontType(unsigned char type) 756 | { 757 | if ((type>=TOTALFONTS) || (type<0)) 758 | return false; 759 | 760 | fontType=type; 761 | fontWidth=pgm_read_byte(fontsPointer[fontType]+0); 762 | fontHeight=pgm_read_byte(fontsPointer[fontType]+1); 763 | fontStartChar=pgm_read_byte(fontsPointer[fontType]+2); 764 | fontTotalChar=pgm_read_byte(fontsPointer[fontType]+3); 765 | fontMapWidth=(pgm_read_byte(fontsPointer[fontType]+4)*100)+pgm_read_byte(fontsPointer[fontType]+5); // two unsigned chars values into integer 16 766 | return true; 767 | } 768 | 769 | /** \brief Set color. 770 | 771 | Set the current draw's color. Only WHITE and BLACK available. 772 | */ 773 | void edOLED::setColor(unsigned char color) 774 | { 775 | foreColor=color; 776 | } 777 | 778 | /** \brief Set draw mode. 779 | 780 | Set current draw mode with NORM or XOR. 781 | */ 782 | void edOLED::setDrawMode(unsigned char mode) 783 | { 784 | drawMode=mode; 785 | } 786 | 787 | /** \brief Draw character. 788 | 789 | Draw character c using current color and current draw mode at x,y. 790 | */ 791 | void edOLED::drawChar(unsigned char x, unsigned char y, unsigned char c) 792 | { 793 | drawChar(x,y,c,foreColor,drawMode); 794 | } 795 | 796 | /** \brief Draw character with color and mode. 797 | 798 | Draw character c using color and draw mode at x,y. 799 | */ 800 | void edOLED::drawChar(unsigned char x, unsigned char y, unsigned char c, unsigned char color, unsigned char mode) 801 | { 802 | unsigned char rowsToDraw,row, tempC; 803 | unsigned char i,j,temp; 804 | unsigned int charPerBitmapRow,charColPositionOnBitmap,charRowPositionOnBitmap,charBitmapStartPosition; 805 | 806 | if ((c(fontStartChar+fontTotalChar-1))) // no bitmap for the required c 807 | return; 808 | 809 | tempC=c-fontStartChar; 810 | 811 | // each row (in datasheet is call page) is 8 bits high, 16 bit high character will have 2 rows to be drawn 812 | rowsToDraw=fontHeight/8; // 8 is LCD's page size, see SSD1306 datasheet 813 | if (rowsToDraw<=1) rowsToDraw=1; 814 | 815 | // the following draw function can draw anywhere on the screen, but SLOW pixel by pixel draw 816 | if (rowsToDraw==1) 817 | { 818 | for (i=0;i>=1; 837 | } 838 | } 839 | return; 840 | } 841 | 842 | // font height over 8 bit 843 | // take character "0" ASCII 48 as example 844 | charPerBitmapRow=fontMapWidth/fontWidth; // 256/8 =32 char per row 845 | charColPositionOnBitmap=tempC % charPerBitmapRow; // =16 846 | charRowPositionOnBitmap=int(tempC/charPerBitmapRow); // =1 847 | charBitmapStartPosition=(charRowPositionOnBitmap * fontMapWidth * (fontHeight/8)) + (charColPositionOnBitmap * fontWidth) ; 848 | 849 | // each row on LCD is 8 bit height (see datasheet for explanation) 850 | for(row=0;row>=1; 866 | } 867 | } 868 | } 869 | 870 | } 871 | 872 | /** \brief Stop scrolling. 873 | 874 | Stop the scrolling of graphics on the OLED. 875 | */ 876 | void edOLED::scrollStop(void) 877 | { 878 | command(DEACTIVATESCROLL); 879 | } 880 | 881 | /** \brief Right scrolling. 882 | 883 | Set row start to row stop on the OLED to scroll right. Refer to http://learn.edOLED.io/intro/general-overview-of-edOLED.html for explanation of the rows. 884 | */ 885 | void edOLED::scrollRight(unsigned char start, unsigned char stop) 886 | { 887 | if (stop=0; i--) 956 | { 957 | if (data & (1< 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------