hadif azli
/
TEST123
BLYNK TEST
Revision 5:8a3cf73d7ed3, committed 2021-01-26
- Comitter:
- kenobi
- Date:
- Tue Jan 26 08:23:29 2021 +0000
- Parent:
- 4:e5018e5ba340
- Commit message:
- bLYNK
Changed in this revision
diff -r e5018e5ba340 -r 8a3cf73d7ed3 AM2321.cpp --- a/AM2321.cpp Thu Jun 16 08:12:33 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,202 +0,0 @@ -// -// AM2321 Temperature & Humidity Sensor library for Arduino -// -// The MIT License (MIT) -// -// Copyright (c) 2013 Wang Dong -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// - -#include "AM2321.h" -#include "mbed.h" -extern I2C g_i2c; -extern Serial pc; - -#define I2C_ADDR_AM2321 (0xB8 >> 1) //AM2321温湿度计I2C地址 -#define PARAM_AM2321_READ 0x03 //读寄存器命令 -#define REG_AM2321_HUMIDITY_MSB 0x00 //湿度寄存器高位 -#define REG_AM2321_HUMIDITY_LSB 0x01 //湿度寄存器低位 -#define REG_AM2321_TEMPERATURE_MSB 0x02 //温度寄存器高位 -#define REG_AM2321_TEMPERATURE_LSB 0x03 //温度寄存器低位 -#define REG_AM2321_DEVICE_ID_BIT_24_31 0x0B //32位设备ID高8位 - -template<int I2CADDR, int COMMAND, int REGADDR, int REGCOUNT> -class DataReader -{ -protected: - enum { len = 32 }; - uint8_t buf[len]; - -protected: - DataReader() { - memset(buf, 0, len); - } - bool readRaw() { - // - // Wakeup - // - //Wire.beginTransmission(I2CADDR); - //Wire.endTransmission(); - g_i2c.write(I2CADDR<<1, (char*)&buf[0], 1); - - // - // Read Command - // -#if 0 - Wire.beginTransmission(I2CADDR); - Wire.write(COMMAND); - Wire.write(REGADDR); - Wire.write(REGCOUNT); - Wire.endTransmission(); -#else - char bu[3] = {COMMAND, REGADDR, REGCOUNT}; - g_i2c.write(I2CADDR<<1, bu, 3); -#endif - - // - // Waiting - // - //delayMicroseconds(1600); //>1.5ms - wait_ms(1.6); - - // - // Read - // -#if 0 - Wire.requestFrom(I2CADDR, 2 + REGCOUNT + 2); // COMMAND + REGCOUNT + DATA + CRCLSB + CRCMSB - int i = 0; - for (; i < 2 + REGCOUNT; ++i) - buf[i] = Wire.read(); - - unsigned short crc = 0; - crc = Wire.read(); //CRC LSB - crc |= Wire.read() << 8;//CRC MSB - - if (crc == crc16(buf, i)) - return true; - return false; -#else - uint8_t realAddr = (I2CADDR << 1) | 0x01; - //pc.printf("realAddr = 0x%x\r\n", realAddr); - g_i2c.read(realAddr, (char*)buf, 2 + REGCOUNT + 2); - unsigned short crc = 0; - crc = buf[2+REGCOUNT]; //CRC LSB - crc |= buf[2+REGCOUNT+1] << 8;//CRC MSB -#if 0 - for (int i = 0; i < 2 + REGCOUNT + 2; i++) { - pc.printf("0x%X ", buf[i]); - } - pc.printf("\r\n"); -#endif - if (crc == crc16(buf, 2 + REGCOUNT)) - return true; - return false; -#endif - } - -private: - unsigned short crc16(unsigned char *ptr, unsigned char len) { - unsigned short crc = 0xFFFF; - unsigned char i = 0; - while(len--) { - crc ^= *ptr++; - for(i = 0 ; i < 8 ; i++) { - if(crc & 0x01) { - crc >>= 1; - crc ^= 0xA001; - } else { - crc >>= 1; - } - } - } - return crc; - } -}; - -class UidReader : public DataReader<I2C_ADDR_AM2321, PARAM_AM2321_READ, REG_AM2321_DEVICE_ID_BIT_24_31, 4> -{ -public: - unsigned int uid; -public: - bool read() { - if(!readRaw()) - return false; - uid = buf[2] << 24; - uid += buf[3] << 16; - uid += buf[4] << 8; - uid += buf[5]; - return true; - } -}; - -class AirConditionReader : public DataReader<I2C_ADDR_AM2321, PARAM_AM2321_READ, REG_AM2321_HUMIDITY_MSB, 4> -{ -public: - unsigned int humidity; - int temperature; -public: - bool read() { - if(!readRaw()) - return false; - humidity = buf[2] << 8; - humidity += buf[3]; - temperature = (buf[4]&0x7F) << 8; - temperature += buf[5]; - if((buf[4]&0x80) == 0x80) - temperature = -temperature; - return true; - } -}; - - -AM2321::AM2321() -{ - //Wire.begin(); - temperature = 0; - humidity = 0; -} - -unsigned long AM2321::uid() -{ - UidReader reader; - if (reader.read()) - return reader.uid; - return -1; -} - - -bool AM2321::available() -{ - return !(temperature == 0 && humidity == 0); -} - -bool AM2321::read() -{ - AirConditionReader reader; - if (reader.read()) { - temperature = reader.temperature; - humidity = reader.humidity; - return true; - } - return false; -} -// -// END OF FILE -//
diff -r e5018e5ba340 -r 8a3cf73d7ed3 AM2321.h --- a/AM2321.h Thu Jun 16 08:12:33 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -// -// AM2321 Temperature & Humidity Sensor library for Arduino -// VERSION: 0.1.0 -// -// The MIT License (MIT) -// -// Copyright (c) 2013 Wang Dong -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// - -#ifndef __ARDUINO_AM2321_H__ -#define __ARDUINO_AM2321_H__ - -#define LIBAM2321_VERSION "0.1.0" - -class AM2321 -{ -public: - int temperature; - unsigned int humidity; -public: - bool read(); - bool available(); -public: - unsigned long uid(); - -public: - AM2321(); -}; - -#endif - -// -// END OF FILE -//
diff -r e5018e5ba340 -r 8a3cf73d7ed3 Adafruit_GFX/Adafruit_GFX.cpp --- a/Adafruit_GFX/Adafruit_GFX.cpp Thu Jun 16 08:12:33 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,454 +0,0 @@ -/*********************************** -This is a our graphics core library, for all our displays. -We'll be adapting all the -existing libaries to use this core to make updating, support -and upgrading easier! - -Adafruit invests time and resources providing this open source code, -please support Adafruit and open-source hardware by purchasing -products from Adafruit! - -Written by Limor Fried/Ladyada for Adafruit Industries. -BSD license, check license.txt for more information -All text above must be included in any redistribution -****************************************/ - -/* - * Modified by Neal Horman 7/14/2012 for use in mbed - */ - -#include "mbed.h" - -#include "Adafruit_GFX.h" -#include "glcdfont.h" - -#if defined(GFX_WANT_ABSTRACTS) -// draw a circle outline -void Adafruit_GFX::drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color) -{ - int16_t f = 1 - r; - int16_t ddF_x = 1; - int16_t ddF_y = -2 * r; - int16_t x = 0; - int16_t y = r; - - drawPixel(x0, y0+r, color); - drawPixel(x0, y0-r, color); - drawPixel(x0+r, y0, color); - drawPixel(x0-r, y0, color); - - while (x<y) - { - if (f >= 0) - { - y--; - ddF_y += 2; - f += ddF_y; - } - x++; - ddF_x += 2; - f += ddF_x; - - drawPixel(x0 + x, y0 + y, color); - drawPixel(x0 - x, y0 + y, color); - drawPixel(x0 + x, y0 - y, color); - drawPixel(x0 - x, y0 - y, color); - drawPixel(x0 + y, y0 + x, color); - drawPixel(x0 - y, y0 + x, color); - drawPixel(x0 + y, y0 - x, color); - drawPixel(x0 - y, y0 - x, color); - } -} - -void Adafruit_GFX::drawCircleHelper( int16_t x0, int16_t y0, int16_t r, uint8_t cornername, uint16_t color) -{ - int16_t f = 1 - r; - int16_t ddF_x = 1; - int16_t ddF_y = -2 * r; - int16_t x = 0; - int16_t y = r; - - while (x<y) - { - if (f >= 0) - { - y--; - ddF_y += 2; - f += ddF_y; - } - x++; - ddF_x += 2; - f += ddF_x; - - if (cornername & 0x4) - { - drawPixel(x0 + x, y0 + y, color); - drawPixel(x0 + y, y0 + x, color); - } - - if (cornername & 0x2) - { - drawPixel(x0 + x, y0 - y, color); - drawPixel(x0 + y, y0 - x, color); - } - - if (cornername & 0x8) - { - drawPixel(x0 - y, y0 + x, color); - drawPixel(x0 - x, y0 + y, color); - } - - if (cornername & 0x1) - { - drawPixel(x0 - y, y0 - x, color); - drawPixel(x0 - x, y0 - y, color); - } - } -} - -void Adafruit_GFX::fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color) -{ - drawFastVLine(x0, y0-r, 2*r+1, color); - fillCircleHelper(x0, y0, r, 3, 0, color); -} - -// used to do circles and roundrects! -void Adafruit_GFX::fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, int16_t delta, uint16_t color) -{ - int16_t f = 1 - r; - int16_t ddF_x = 1; - int16_t ddF_y = -2 * r; - int16_t x = 0; - int16_t y = r; - - while (x<y) - { - if (f >= 0) - { - y--; - ddF_y += 2; - f += ddF_y; - } - x++; - ddF_x += 2; - f += ddF_x; - - if (cornername & 0x1) - { - drawFastVLine(x0+x, y0-y, 2*y+1+delta, color); - drawFastVLine(x0+y, y0-x, 2*x+1+delta, color); - } - - if (cornername & 0x2) - { - drawFastVLine(x0-x, y0-y, 2*y+1+delta, color); - drawFastVLine(x0-y, y0-x, 2*x+1+delta, color); - } - } -} -#endif - -#if defined(GFX_WANT_ABSTRACTS) || defined(GFX_SIZEABLE_TEXT) -// bresenham's algorithm - thx wikpedia -void Adafruit_GFX::drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color) -{ - int16_t steep = abs(y1 - y0) > abs(x1 - x0); - - if (steep) - { - swap(x0, y0); - swap(x1, y1); - } - - if (x0 > x1) - { - swap(x0, x1); - swap(y0, y1); - } - - int16_t dx, dy; - dx = x1 - x0; - dy = abs(y1 - y0); - - int16_t err = dx / 2; - int16_t ystep; - - if (y0 < y1) - ystep = 1; - else - ystep = -1; - - for (; x0<=x1; x0++) - { - if (steep) - drawPixel(y0, x0, color); - else - drawPixel(x0, y0, color); - - err -= dy; - if (err < 0) - { - y0 += ystep; - err += dx; - } - } -} - -void Adafruit_GFX::drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color) -{ - // stupidest version - update in subclasses if desired! - drawLine(x, y, x, y+h-1, color); -} - -void Adafruit_GFX::fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color) -{ - // stupidest version - update in subclasses if desired! - for (int16_t i=x; i<x+w; i++) - drawFastVLine(i, y, h, color); -} -#endif - -#if defined(GFX_WANT_ABSTRACTS) -// draw a rectangle -void Adafruit_GFX::drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color) -{ - drawFastHLine(x, y, w, color); - drawFastHLine(x, y+h-1, w, color); - drawFastVLine(x, y, h, color); - drawFastVLine(x+w-1, y, h, color); -} - -void Adafruit_GFX::drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color) -{ - // stupidest version - update in subclasses if desired! - drawLine(x, y, x+w-1, y, color); -} - -void Adafruit_GFX::fillScreen(uint16_t color) -{ - fillRect(0, 0, _width, _height, color); -} - -// draw a rounded rectangle! -void Adafruit_GFX::drawRoundRect(int16_t x, int16_t y, int16_t w, int16_t h, int16_t r, uint16_t color) -{ - // smarter version - drawFastHLine(x+r , y , w-2*r, color); // Top - drawFastHLine(x+r , y+h-1, w-2*r, color); // Bottom - drawFastVLine( x , y+r , h-2*r, color); // Left - drawFastVLine( x+w-1, y+r , h-2*r, color); // Right - // draw four corners - drawCircleHelper(x+r , y+r , r, 1, color); - drawCircleHelper(x+w-r-1, y+r , r, 2, color); - drawCircleHelper(x+w-r-1, y+h-r-1, r, 4, color); - drawCircleHelper(x+r , y+h-r-1, r, 8, color); -} - -// fill a rounded rectangle! -void Adafruit_GFX::fillRoundRect(int16_t x, int16_t y, int16_t w, int16_t h, int16_t r, uint16_t color) -{ - // smarter version - fillRect(x+r, y, w-2*r, h, color); - - // draw four corners - fillCircleHelper(x+w-r-1, y+r, r, 1, h-2*r-1, color); - fillCircleHelper(x+r , y+r, r, 2, h-2*r-1, color); -} - -// draw a triangle! -void Adafruit_GFX::drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color) -{ - drawLine(x0, y0, x1, y1, color); - drawLine(x1, y1, x2, y2, color); - drawLine(x2, y2, x0, y0, color); -} - -// fill a triangle! -void Adafruit_GFX::fillTriangle ( int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color) -{ - int16_t a, b, y, last; - - // Sort coordinates by Y order (y2 >= y1 >= y0) - if (y0 > y1) - swap(y0, y1); swap(x0, x1); - - if (y1 > y2) - swap(y2, y1); swap(x2, x1); - - if (y0 > y1) - swap(y0, y1); swap(x0, x1); - - - if(y0 == y2) - { // Handle awkward all-on-same-line case as its own thing - a = b = x0; - if(x1 < a) - a = x1; - else if(x1 > b) - b = x1; - - if(x2 < a) - a = x2; - else if(x2 > b) b = x2; - drawFastHLine(a, y0, b-a+1, color); - return; - } - - int16_t - dx01 = x1 - x0, - dy01 = y1 - y0, - dx02 = x2 - x0, - dy02 = y2 - y0, - dx12 = x2 - x1, - dy12 = y2 - y1, - sa = 0, - sb = 0; - - // For upper part of triangle, find scanline crossings for segments - // 0-1 and 0-2. If y1=y2 (flat-bottomed triangle), the scanline y1 - // is included here (and second loop will be skipped, avoiding a /0 - // error there), otherwise scanline y1 is skipped here and handled - // in the second loop...which also avoids a /0 error here if y0=y1 - // (flat-topped triangle). - if(y1 == y2) - last = y1; // Include y1 scanline - else - last = y1-1; // Skip it - - for(y=y0; y<=last; y++) - { - a = x0 + sa / dy01; - b = x0 + sb / dy02; - sa += dx01; - sb += dx02; - /* longhand: - a = x0 + (x1 - x0) * (y - y0) / (y1 - y0); - b = x0 + (x2 - x0) * (y - y0) / (y2 - y0); - */ - if(a > b) - swap(a,b); - drawFastHLine(a, y, b-a+1, color); - } - - // For lower part of triangle, find scanline crossings for segments - // 0-2 and 1-2. This loop is skipped if y1=y2. - sa = dx12 * (y - y1); - sb = dx02 * (y - y0); - for(; y<=y2; y++) - { - a = x1 + sa / dy12; - b = x0 + sb / dy02; - sa += dx12; - sb += dx02; - /* longhand: - a = x1 + (x2 - x1) * (y - y1) / (y2 - y1); - b = x0 + (x2 - x0) * (y - y0) / (y2 - y0); - */ - if(a > b) - swap(a,b); - drawFastHLine(a, y, b-a+1, color); - } -} - -void Adafruit_GFX::drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color) -{ - for (int16_t j=0; j<h; j++) - { - for (int16_t i=0; i<w; i++ ) - { - if (bitmap[i + (j/8)*w] & _BV(j%8)) - drawPixel(x+i, y+j, color); - } - } -} -#endif - -size_t Adafruit_GFX::writeChar(uint8_t c) -{ - if (c == '\n') - { - cursor_y += textsize*8; - cursor_x = 0; - } - else if (c == '\r') - cursor_x = 0; - else - { - drawChar(cursor_x, cursor_y, c, textcolor, textbgcolor, textsize); - cursor_x += textsize*6; - if (wrap && (cursor_x > (_width - textsize*6))) - { - cursor_y += textsize*8; - cursor_x = 0; - } - } - return 1; -} - -// draw a character -void Adafruit_GFX::drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color, uint16_t bg, uint8_t size) -{ - if( - (x >= _width) || // Clip right - (y >= _height) || // Clip bottom - ((x + 5 * size - 1) < 0) || // Clip left - ((y + 8 * size - 1) < 0) // Clip top - ) - return; - - for (int8_t i=0; i<6; i++ ) - { - uint8_t line = 0; - - if (i == 5) - line = 0x0; - else - line = font[(c*5)+i]; - - for (int8_t j = 0; j<8; j++) - { - if (line & 0x1) - { -#if defined(GFX_WANT_ABSTRACTS) || defined(GFX_SIZEABLE_TEXT) - if (size == 1) // default size - drawPixel(x+i, y+j, color); - else // big size - fillRect(x+(i*size), y+(j*size), size, size, color); -#else - drawPixel(x+i, y+j, color); -#endif - } - else if (bg != color) - { -#if defined(GFX_WANT_ABSTRACTS) || defined(GFX_SIZEABLE_TEXT) - if (size == 1) // default size - drawPixel(x+i, y+j, bg); - else // big size - fillRect(x+i*size, y+j*size, size, size, bg); -#else - drawPixel(x+i, y+j, bg); -#endif - } - line >>= 1; - } - } -} - -void Adafruit_GFX::setRotation(uint8_t x) -{ - x %= 4; // cant be higher than 3 - rotation = x; - switch (x) - { - case 0: - case 2: - _width = _rawWidth; - _height = _rawHeight; - break; - case 1: - case 3: - _width = _rawHeight; - _height = _rawWidth; - break; - } -}
diff -r e5018e5ba340 -r 8a3cf73d7ed3 Adafruit_GFX/Adafruit_GFX.h --- a/Adafruit_GFX/Adafruit_GFX.h Thu Jun 16 08:12:33 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,183 +0,0 @@ -/*********************************** -This is a our graphics core library, for all our displays. -We'll be adapting all the -existing libaries to use this core to make updating, support -and upgrading easier! - -Adafruit invests time and resources providing this open source code, -please support Adafruit and open-source hardware by purchasing -products from Adafruit! - -Written by Limor Fried/Ladyada for Adafruit Industries. -BSD license, check license.txt for more information -All text above must be included in any redistribution -****************************************/ - -/* - * Modified by Neal Horman 7/14/2012 for use in mbed - */ - -#ifndef _ADAFRUIT_GFX_H_ -#define _ADAFRUIT_GFX_H_ - -#include "Adafruit_GFX_Config.h" - -static inline void swap(int16_t &a, int16_t &b) -{ - int16_t t = a; - - a = b; - b = t; -} - -#ifndef _BV -#define _BV(bit) (1<<(bit)) -#endif - -#define BLACK 0 -#define WHITE 1 - -/** - * This is a Text and Graphics element drawing class. - * These functions draw to the display buffer. - * - * Display drivers should be derived from here. - * The Display drivers push the display buffer to the - * hardware based on application control. - * - */ -class Adafruit_GFX : public Stream -{ - public: - Adafruit_GFX(int16_t w, int16_t h) - : _rawWidth(w) - , _rawHeight(h) - , _width(w) - , _height(h) - , cursor_x(0) - , cursor_y(0) - , textcolor(WHITE) - , textbgcolor(BLACK) - , textsize(1) - , rotation(0) - , wrap(true) - {}; - - /// Paint one BLACK or WHITE pixel in the display buffer - // this must be defined by the subclass - virtual void drawPixel(int16_t x, int16_t y, uint16_t color) = 0; - // this is optional - virtual void invertDisplay(bool i) {}; - - // Stream implementation - provides printf() interface - // You would otherwise be forced to use writeChar() - virtual int _putc(int value) { return writeChar(value); }; - virtual int _getc() { return -1; }; - -#ifdef GFX_WANT_ABSTRACTS - // these are 'generic' drawing functions, so we can share them! - - /** Draw a Horizontal Line - * @note GFX_WANT_ABSTRACTS must be defined in Adafruit_GFX_config.h - */ - virtual void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color); - /** Draw a rectangle - * @note GFX_WANT_ABSTRACTS must be defined in Adafruit_GFX_config.h - */ - virtual void drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color); - /** Fill the entire display - * @note GFX_WANT_ABSTRACTS must be defined in Adafruit_GFX_config.h - */ - virtual void fillScreen(uint16_t color); - - /** Draw a circle - * @note GFX_WANT_ABSTRACTS must be defined in Adafruit_GFX_config.h - */ - void drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color); - void drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, uint16_t color); - - /** Draw and fill a circle - * @note GFX_WANT_ABSTRACTS must be defined in Adafruit_GFX_config.h - */ - void fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color); - void fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, int16_t delta, uint16_t color); - - /** Draw a triangle - * @note GFX_WANT_ABSTRACTS must be defined in Adafruit_GFX_config.h - */ - void drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color); - /** Draw and fill a triangle - * @note GFX_WANT_ABSTRACTS must be defined in Adafruit_GFX_config.h - */ - void fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color); - - /** Draw a rounded rectangle - * @note GFX_WANT_ABSTRACTS must be defined in Adafruit_GFX_config.h - */ - void drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color); - /** Draw and fill a rounded rectangle - * @note GFX_WANT_ABSTRACTS must be defined in Adafruit_GFX_config.h - */ - void fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color); - /** Draw a bitmap - * @note GFX_WANT_ABSTRACTS must be defined in Adafruit_GFX_config.h - */ - void drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color); -#endif - -#if defined(GFX_WANT_ABSTRACTS) || defined(GFX_SIZEABLE_TEXT) - /** Draw a line - * @note GFX_WANT_ABSTRACTS or GFX_SIZEABLE_TEXT must be defined in Adafruit_GFX_config.h - */ - virtual void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color); - /** Draw a vertical line - * @note GFX_WANT_ABSTRACTS or GFX_SIZEABLE_TEXT must be defined in Adafruit_GFX_config.h - */ - virtual void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color); - /** Draw and fill a rectangle - * @note GFX_WANT_ABSTRACTS or GFX_SIZEABLE_TEXT must be defined in Adafruit_GFX_config.h - */ - virtual void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color); -#endif - - /// Draw a text character at a specified pixel location - void drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color, uint16_t bg, uint8_t size); - /// Draw a text character at the text cursor location - size_t writeChar(uint8_t); - - /// Get the width of the display in pixels - inline int16_t width(void) { return _width; }; - /// Get the height of the display in pixels - inline int16_t height(void) { return _height; }; - - /// Set the text cursor location, based on the size of the text - inline void setTextCursor(int16_t x, int16_t y) { cursor_x = x; cursor_y = y; }; -#if defined(GFX_WANT_ABSTRACTS) || defined(GFX_SIZEABLE_TEXT) - /** Set the size of the text to be drawn - * @note Make sure to enable either GFX_SIZEABLE_TEXT or GFX_WANT_ABSTRACTS - */ - inline void setTextSize(uint8_t s) { textsize = (s > 0) ? s : 1; }; -#endif - /// Set the text foreground and background colors to be the same - inline void setTextColor(uint16_t c) { textcolor = c; textbgcolor = c; } - /// Set the text foreground and background colors independantly - inline void setTextColor(uint16_t c, uint16_t b) { textcolor = c; textbgcolor = b; }; - /// Set text wraping mode true or false - inline void setTextWrap(bool w) { wrap = w; }; - - /// Set the display rotation, 1, 2, 3, or 4 - void setRotation(uint8_t r); - /// Get the current rotation - inline uint8_t getRotation(void) { rotation %= 4; return rotation; }; - -protected: - int16_t _rawWidth, _rawHeight; // this is the 'raw' display w/h - never changes - int16_t _width, _height; // dependent on rotation - int16_t cursor_x, cursor_y; - uint16_t textcolor, textbgcolor; - uint8_t textsize; - uint8_t rotation; - bool wrap; // If set, 'wrap' text at right edge of display -}; - -#endif
diff -r e5018e5ba340 -r 8a3cf73d7ed3 Adafruit_GFX/Adafruit_GFX_Config.h --- a/Adafruit_GFX/Adafruit_GFX_Config.h Thu Jun 16 08:12:33 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -#ifndef _ADAFRUIT_GFX_CONFIG_H_ -#define _ADAFRUIT_GFX_CONFIG_H_ - -// Uncomment this to turn off the builtin splash -//#define NO_SPLASH_ADAFRUIT - -// Uncomment this to enable all functionality -#define GFX_WANT_ABSTRACTS - -// Uncomment this to enable only runtime font scaling, without all the rest of the Abstracts -#define GFX_SIZEABLE_TEXT - - -#endif \ No newline at end of file
diff -r e5018e5ba340 -r 8a3cf73d7ed3 Adafruit_GFX/Adafruit_SSD1306.cpp --- a/Adafruit_GFX/Adafruit_SSD1306.cpp Thu Jun 16 08:12:33 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,279 +0,0 @@ -/********************************************************************* -This is a library for our Monochrome OLEDs based on SSD1306 drivers - - Pick one up today in the adafruit shop! - ------> http://www.adafruit.com/category/63_98 - -These displays use SPI to communicate, 4 or 5 pins are required to -interface - -Adafruit invests time and resources providing this open source code, -please support Adafruit and open-source hardware by purchasing -products from Adafruit! - -Written by Limor Fried/Ladyada for Adafruit Industries. -BSD license, check license.txt for more information -All text above, and the splash screen below must be included in any redistribution -*********************************************************************/ - -/* - * Modified by Neal Horman 7/14/2012 for use in mbed - */ - -#include "mbed.h" -#include "Adafruit_SSD1306.h" - -#define SSD1306_SETCONTRAST 0x81 -#define SSD1306_DISPLAYALLON_RESUME 0xA4 -#define SSD1306_DISPLAYALLON 0xA5 -#define SSD1306_NORMALDISPLAY 0xA6 -#define SSD1306_INVERTDISPLAY 0xA7 -#define SSD1306_DISPLAYOFF 0xAE -#define SSD1306_DISPLAYON 0xAF -#define SSD1306_SETDISPLAYOFFSET 0xD3 -#define SSD1306_SETCOMPINS 0xDA -#define SSD1306_SETVCOMDETECT 0xDB -#define SSD1306_SETDISPLAYCLOCKDIV 0xD5 -#define SSD1306_SETPRECHARGE 0xD9 -#define SSD1306_SETMULTIPLEX 0xA8 -#define SSD1306_SETLOWCOLUMN 0x00 -#define SSD1306_SETHIGHCOLUMN 0x10 -#define SSD1306_SETSTARTLINE 0x40 -#define SSD1306_MEMORYMODE 0x20 -#define SSD1306_COMSCANINC 0xC0 -#define SSD1306_COMSCANDEC 0xC8 -#define SSD1306_SEGREMAP 0xA0 -#define SSD1306_CHARGEPUMP 0x8D - -//0xAE, 0xD5, 0x80, 0xA8, _rawHeight-1, 0xD3, 0x00, 0x40, 0x8D, 0x10, 0x20, 0x00, 0xA1, 0xC8, 0xDA, 0x12, 0x81, 0x9F, 0xD9, 0x22, 0xDB, 0x40, 0xA4, 0xA6, 0xAF -#if 1 -void Adafruit_SSD1306::begin(uint8_t vccstate) -{ - //printf("begin: vccstate = %d\r\n", vccstate); - rst = 1; - // VDD (3.3V) goes high at start, lets just chill for a ms - wait_ms(1); - // bring reset low - rst = 0; - // wait 10ms - wait_ms(10); - // bring out of reset - rst = 1; - // turn on VCC (9V?) - - command(SSD1306_DISPLAYOFF); - command(SSD1306_SETDISPLAYCLOCKDIV); - command(0x80); // the suggested ratio 0x80 - - command(SSD1306_SETMULTIPLEX); - command(_rawHeight-1); - - command(SSD1306_SETDISPLAYOFFSET); - command(0x0); // no offset - - command(SSD1306_SETSTARTLINE | 0x0); // line #0 - - command(SSD1306_CHARGEPUMP); - command((vccstate == SSD1306_EXTERNALVCC) ? 0x10 : 0x14); - - command(SSD1306_MEMORYMODE); - command(0x00); // 0x0 act like ks0108 - - command(SSD1306_SEGREMAP | 0x1); - - command(SSD1306_COMSCANDEC); - - command(SSD1306_SETCOMPINS); - command(_rawHeight == 32 ? 0x02 : 0x12); // TODO - calculate based on _rawHieght ? - - command(SSD1306_SETCONTRAST); - command(_rawHeight == 32 ? 0x8F : ((vccstate == SSD1306_EXTERNALVCC) ? 0x9F : 0xCF) ); - - command(SSD1306_SETPRECHARGE); - command((vccstate == SSD1306_EXTERNALVCC) ? 0x22 : 0xF1); - - command(SSD1306_SETVCOMDETECT); - command(0x40); - - command(SSD1306_DISPLAYALLON_RESUME); - - command(SSD1306_NORMALDISPLAY); - - command(SSD1306_DISPLAYON); -} -#else -void Adafruit_SSD1306::begin(uint8_t vccstate) -{ - command(0xAE); - command(0xD5); - command(0x80); // the suggested ratio 0x80 - - command(0xA8); - command(_rawHeight-1); - - command(0xD3); - command(0x0); // no offset - - command(0x40); // line #0 - - command(0x8D); - command(0x14); - - command(0x20); - command(0x00); // 0x0 act like ks0108 - - command(0xA1); - - command(0xC8); - - command(0xDA); - command(0x12); // TODO - calculate based on _rawHieght ? - - command(0x8a); - command(0xCF); - - command(0xD9); - command(0xF1); - - command(0xDB); - command(0x40); - - command(0x2E);//??? - command(SSD1306_DISPLAYALLON_RESUME); - - command(SSD1306_NORMALDISPLAY); - - command(SSD1306_DISPLAYON); -} -#endif - -// Set a single pixel -void Adafruit_SSD1306::drawPixel(int16_t x, int16_t y, uint16_t color) -{ - if ((x < 0) || (x >= width()) || (y < 0) || (y >= height())) - return; - - // check rotation, move pixel around if necessary - switch (getRotation()) - { - case 1: - swap(x, y); - x = _rawWidth - x - 1; - break; - case 2: - x = _rawWidth - x - 1; - y = _rawHeight - y - 1; - break; - case 3: - swap(x, y); - y = _rawHeight - y - 1; - break; - } - - // x is which column - if (color == WHITE) - buffer[x+ (y/8)*_rawWidth] |= _BV((y%8)); - else // else black - buffer[x+ (y/8)*_rawWidth] &= ~_BV((y%8)); -} - -void Adafruit_SSD1306::invertDisplay(bool i) -{ - command(i ? SSD1306_INVERTDISPLAY : SSD1306_NORMALDISPLAY); -} - -// Send the display buffer out to the display -void Adafruit_SSD1306::display(void) -{ - //printf("display\r\n"); - command(SSD1306_SETLOWCOLUMN | 0x0); // low col = 0 - command(SSD1306_SETHIGHCOLUMN | 0x0); // hi col = 0 - command(SSD1306_SETSTARTLINE | 0x0); // line #0 - sendDisplayBuffer(); -} - -// Clear the display buffer. Requires a display() call at some point afterwards -void Adafruit_SSD1306::clearDisplay(void) -{ - std::fill(buffer.begin(),buffer.end(),0); -} - -void Adafruit_SSD1306::splash(void) -{ -#ifndef NO_SPLASH_ADAFRUIT - uint8_t adaFruitLogo[64 * 128 / 8] = - { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, - 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x80, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xF8, 0xE0, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0xFF, - 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, - 0x80, 0xFF, 0xFF, 0x80, 0x80, 0x00, 0x80, 0x80, 0x00, 0x80, 0x80, 0x80, 0x80, 0x00, 0x80, 0x80, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x8C, 0x8E, 0x84, 0x00, 0x00, 0x80, 0xF8, - 0xF8, 0xF8, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xE0, 0xE0, 0xC0, 0x80, - 0x00, 0xE0, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xC7, 0x01, 0x01, - 0x01, 0x01, 0x83, 0xFF, 0xFF, 0x00, 0x00, 0x7C, 0xFE, 0xC7, 0x01, 0x01, 0x01, 0x01, 0x83, 0xFF, - 0xFF, 0xFF, 0x00, 0x38, 0xFE, 0xC7, 0x83, 0x01, 0x01, 0x01, 0x83, 0xC7, 0xFF, 0xFF, 0x00, 0x00, - 0x01, 0xFF, 0xFF, 0x01, 0x01, 0x00, 0xFF, 0xFF, 0x07, 0x01, 0x01, 0x01, 0x00, 0x00, 0x7F, 0xFF, - 0x80, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x7F, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x01, 0xFF, - 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x03, 0x0F, 0x3F, 0x7F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE7, 0xC7, 0xC7, 0x8F, - 0x8F, 0x9F, 0xBF, 0xFF, 0xFF, 0xC3, 0xC0, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xFC, 0xFC, - 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xF8, 0xF8, 0xF0, 0xF0, 0xE0, 0xC0, 0x00, 0x01, 0x03, 0x03, 0x03, - 0x03, 0x03, 0x01, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01, - 0x03, 0x01, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01, 0x03, 0x03, 0x00, 0x00, - 0x00, 0x03, 0x03, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, - 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x00, 0x00, 0x00, 0x01, 0x03, 0x01, 0x00, 0x00, 0x00, 0x03, - 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - // 128x32^^^ 128x64vvv - 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF9, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x1F, 0x0F, - 0x87, 0xC7, 0xF7, 0xFF, 0xFF, 0x1F, 0x1F, 0x3D, 0xFC, 0xF8, 0xF8, 0xF8, 0xF8, 0x7C, 0x7D, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x0F, 0x07, 0x00, 0x30, 0x30, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFE, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xC0, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xC0, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x3F, 0x1F, - 0x0F, 0x07, 0x1F, 0x7F, 0xFF, 0xFF, 0xF8, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xF8, 0xE0, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFE, 0x00, 0x00, - 0x00, 0xFC, 0xFE, 0xFC, 0x0C, 0x06, 0x06, 0x0E, 0xFC, 0xF8, 0x00, 0x00, 0xF0, 0xF8, 0x1C, 0x0E, - 0x06, 0x06, 0x06, 0x0C, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFE, 0xFE, 0x00, 0x00, 0x00, 0x00, 0xFC, - 0xFE, 0xFC, 0x00, 0x18, 0x3C, 0x7E, 0x66, 0xE6, 0xCE, 0x84, 0x00, 0x00, 0x06, 0xFF, 0xFF, 0x06, - 0x06, 0xFC, 0xFE, 0xFC, 0x0C, 0x06, 0x06, 0x06, 0x00, 0x00, 0xFE, 0xFE, 0x00, 0x00, 0xC0, 0xF8, - 0xFC, 0x4E, 0x46, 0x46, 0x46, 0x4E, 0x7C, 0x78, 0x40, 0x18, 0x3C, 0x76, 0xE6, 0xCE, 0xCC, 0x80, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x01, 0x07, 0x0F, 0x1F, 0x1F, 0x3F, 0x3F, 0x3F, 0x3F, 0x1F, 0x0F, 0x03, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, - 0x00, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x03, 0x07, 0x0E, 0x0C, - 0x18, 0x18, 0x0C, 0x06, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x01, 0x0F, 0x0E, 0x0C, 0x18, 0x0C, 0x0F, - 0x07, 0x01, 0x00, 0x04, 0x0E, 0x0C, 0x18, 0x0C, 0x0F, 0x07, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, - 0x00, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x07, - 0x07, 0x0C, 0x0C, 0x18, 0x1C, 0x0C, 0x06, 0x06, 0x00, 0x04, 0x0E, 0x0C, 0x18, 0x0C, 0x0F, 0x07, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; - - std::copy( - &adaFruitLogo[0] - , &adaFruitLogo[0] + (_rawHeight == 32 ? sizeof(adaFruitLogo)/2 : sizeof(adaFruitLogo)) - , buffer.begin() - ); -#endif -}
diff -r e5018e5ba340 -r 8a3cf73d7ed3 Adafruit_GFX/Adafruit_SSD1306.h --- a/Adafruit_GFX/Adafruit_SSD1306.h Thu Jun 16 08:12:33 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,220 +0,0 @@ -/********************************************************************* -This is a library for our Monochrome OLEDs based on SSD1306 drivers - - Pick one up today in the adafruit shop! - ------> http://www.adafruit.com/category/63_98 - -These displays use SPI to communicate, 4 or 5 pins are required to -interface - -Adafruit invests time and resources providing this open source code, -please support Adafruit and open-source hardware by purchasing -products from Adafruit! - -Written by Limor Fried/Ladyada for Adafruit Industries. -BSD license, check license.txt for more information -All text above, and the splash screen must be included in any redistribution -*********************************************************************/ - -/* - * Modified by Neal Horman 7/14/2012 for use in mbed - */ - -#ifndef _ADAFRUIT_SSD1306_H_ -#define _ADAFRUIT_SSD1306_H_ - -#include "mbed.h" -#include "Adafruit_GFX.h" - -#include <vector> -#include <algorithm> - -// A DigitalOut sub-class that provides a constructed default state -class DigitalOut2 : public DigitalOut -{ -public: - DigitalOut2(PinName pin, bool active = false) : DigitalOut(pin) { write(active); }; - DigitalOut2& operator= (int value) { write(value); return *this; }; - DigitalOut2& operator= (DigitalOut2& rhs) { write(rhs.read()); return *this; }; - operator int() { return read(); }; -}; - -#define SSD1306_EXTERNALVCC 0x1 -#define SSD1306_SWITCHCAPVCC 0x2 - -/** The pure base class for the SSD1306 display driver. - * - * You should derive from this for a new transport interface type, - * such as the SPI and I2C drivers. - */ -class Adafruit_SSD1306 : public Adafruit_GFX -{ -public: - Adafruit_SSD1306(PinName RST, uint8_t rawHeight = 32, uint8_t rawWidth = 128) - : Adafruit_GFX(rawWidth,rawHeight) - , rst(RST,false) - { - buffer.resize(rawHeight * rawWidth / 8); - }; - - void begin(uint8_t switchvcc = SSD1306_SWITCHCAPVCC); - - // These must be implemented in the derived transport driver - virtual void command(uint8_t c) = 0; - virtual void data(uint8_t c) = 0; - virtual void drawPixel(int16_t x, int16_t y, uint16_t color); - - /// Clear the display buffer - void clearDisplay(void); - virtual void invertDisplay(bool i); - - /// Cause the display to be updated with the buffer content. - void display(); - /// Fill the buffer with the AdaFruit splash screen. - virtual void splash(); - -protected: - virtual void sendDisplayBuffer() = 0; - DigitalOut2 rst; - - // the memory buffer for the LCD - std::vector<uint8_t> buffer; -}; - - -/** This is the SPI SSD1306 display driver transport class - * - */ -class Adafruit_SSD1306_Spi : public Adafruit_SSD1306 -{ -public: - /** Create a SSD1306 SPI transport display driver instance with the specified DC, RST, and CS pins, as well as the display dimentions - * - * Required parameters - * @param spi - a reference to an initialized SPI object - * @param DC (Data/Command) pin name - * @param RST (Reset) pin name - * @param CS (Chip Select) pin name - * - * Optional parameters - * @param rawHeight - the vertical number of pixels for the display, defaults to 32 - * @param rawWidth - the horizonal number of pixels for the display, defaults to 128 - */ - Adafruit_SSD1306_Spi(SPI &spi, PinName DC, PinName RST, PinName CS, uint8_t rawHieght = 32, uint8_t rawWidth = 128) - : Adafruit_SSD1306(RST, rawHieght, rawWidth) - , cs(CS,true) - , dc(DC,false) - , mspi(spi) - { - begin(); - splash(); - display(); - }; - - virtual void command(uint8_t c) - { - cs = 1; - dc = 0; - cs = 0; - mspi.write(c); - cs = 1; - }; - - virtual void data(uint8_t c) - { - cs = 1; - dc = 1; - cs = 0; - mspi.write(c); - cs = 1; - }; - -protected: - virtual void sendDisplayBuffer() - { - cs = 1; - dc = 1; - cs = 0; - - for(uint16_t i=0, q=buffer.size(); i<q; i++) - mspi.write(buffer[i]); - - if(height() == 32) - { - for(uint16_t i=0, q=buffer.size(); i<q; i++) - mspi.write(0); - } - - cs = 1; - }; - - DigitalOut2 cs, dc; - SPI &mspi; -}; - -/** This is the I2C SSD1306 display driver transport class - * - */ -class Adafruit_SSD1306_I2c : public Adafruit_SSD1306 -{ -public: - #define SSD_I2C_ADDRESS 0x78 - /** Create a SSD1306 I2C transport display driver instance with the specified RST pin name, the I2C address, as well as the display dimensions - * - * Required parameters - * @param i2c - A reference to an initialized I2C object - * @param RST - The Reset pin name - * - * Optional parameters - * @param i2cAddress - The i2c address of the display - * @param rawHeight - The vertical number of pixels for the display, defaults to 32 - * @param rawWidth - The horizonal number of pixels for the display, defaults to 128 - */ - Adafruit_SSD1306_I2c(I2C &i2c, PinName RST, uint8_t i2cAddress = SSD_I2C_ADDRESS, uint8_t rawHeight = 32, uint8_t rawWidth = 128) - : Adafruit_SSD1306(RST, rawHeight, rawWidth) - , mi2c(i2c) - , mi2cAddress(i2cAddress) - { - begin(); - splash(); - display(); - }; - - virtual void command(uint8_t c) - { - char buff[2]; - buff[0] = 0; // Command Mode - buff[1] = c; - mi2c.write(mi2cAddress, buff, sizeof(buff)); - } - - virtual void data(uint8_t c) - { - char buff[2]; - buff[0] = 0x40; // Data Mode - buff[1] = c; - mi2c.write(mi2cAddress, buff, sizeof(buff)); - }; - -protected: - virtual void sendDisplayBuffer() - { - char buff[17]; - buff[0] = 0x40; // Data Mode - - // send display buffer in 16 byte chunks - for(uint16_t i=0, q=buffer.size(); i<q; i+=16 ) - { uint8_t x ; - - // TODO - this will segfault if buffer.size() % 16 != 0 - for(x=1; x<sizeof(buff); x++) - buff[x] = buffer[i+x-1]; - mi2c.write(mi2cAddress, buff, sizeof(buff)); - } - }; - - I2C &mi2c; - uint8_t mi2cAddress; -}; - -#endif \ No newline at end of file
diff -r e5018e5ba340 -r 8a3cf73d7ed3 Adafruit_GFX/glcdfont.h --- a/Adafruit_GFX/glcdfont.h Thu Jun 16 08:12:33 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,285 +0,0 @@ -/********************************************************************* -This is a library for our Monochrome OLEDs based on SSD1306 drivers - - Pick one up today in the adafruit shop! - ------> http://www.adafruit.com/category/63_98 - -These displays use SPI to communicate, 4 or 5 pins are required to -interface - -Adafruit invests time and resources providing this open source code, -please support Adafruit and open-source hardware by purchasing -products from Adafruit! - -Written by Limor Fried/Ladyada for Adafruit Industries. -BSD license, check license.txt for more information -All text above, and the splash screen must be included in any redistribution -*********************************************************************/ - -/* - * Modified by Neal Horman 7/14/2012 for use in LPC1768 - */ - -#ifndef FONT5X7_H -#define FONT5X7_H - -// standard ascii 5x7 font - -static unsigned char font[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, - 0x3E, 0x5B, 0x4F, 0x5B, 0x3E, - 0x3E, 0x6B, 0x4F, 0x6B, 0x3E, - 0x1C, 0x3E, 0x7C, 0x3E, 0x1C, - 0x18, 0x3C, 0x7E, 0x3C, 0x18, - 0x1C, 0x57, 0x7D, 0x57, 0x1C, - 0x1C, 0x5E, 0x7F, 0x5E, 0x1C, - 0x00, 0x18, 0x3C, 0x18, 0x00, - 0xFF, 0xE7, 0xC3, 0xE7, 0xFF, - 0x00, 0x18, 0x24, 0x18, 0x00, - 0xFF, 0xE7, 0xDB, 0xE7, 0xFF, - 0x30, 0x48, 0x3A, 0x06, 0x0E, - 0x26, 0x29, 0x79, 0x29, 0x26, - 0x40, 0x7F, 0x05, 0x05, 0x07, - 0x40, 0x7F, 0x05, 0x25, 0x3F, - 0x5A, 0x3C, 0xE7, 0x3C, 0x5A, - 0x7F, 0x3E, 0x1C, 0x1C, 0x08, - 0x08, 0x1C, 0x1C, 0x3E, 0x7F, - 0x14, 0x22, 0x7F, 0x22, 0x14, - 0x5F, 0x5F, 0x00, 0x5F, 0x5F, - 0x06, 0x09, 0x7F, 0x01, 0x7F, - 0x00, 0x66, 0x89, 0x95, 0x6A, - 0x60, 0x60, 0x60, 0x60, 0x60, - 0x94, 0xA2, 0xFF, 0xA2, 0x94, - 0x08, 0x04, 0x7E, 0x04, 0x08, - 0x10, 0x20, 0x7E, 0x20, 0x10, - 0x08, 0x08, 0x2A, 0x1C, 0x08, - 0x08, 0x1C, 0x2A, 0x08, 0x08, - 0x1E, 0x10, 0x10, 0x10, 0x10, - 0x0C, 0x1E, 0x0C, 0x1E, 0x0C, - 0x30, 0x38, 0x3E, 0x38, 0x30, - 0x06, 0x0E, 0x3E, 0x0E, 0x06, - 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x5F, 0x00, 0x00, - 0x00, 0x07, 0x00, 0x07, 0x00, - 0x14, 0x7F, 0x14, 0x7F, 0x14, - 0x24, 0x2A, 0x7F, 0x2A, 0x12, - 0x23, 0x13, 0x08, 0x64, 0x62, - 0x36, 0x49, 0x56, 0x20, 0x50, - 0x00, 0x08, 0x07, 0x03, 0x00, - 0x00, 0x1C, 0x22, 0x41, 0x00, - 0x00, 0x41, 0x22, 0x1C, 0x00, - 0x2A, 0x1C, 0x7F, 0x1C, 0x2A, - 0x08, 0x08, 0x3E, 0x08, 0x08, - 0x00, 0x80, 0x70, 0x30, 0x00, - 0x08, 0x08, 0x08, 0x08, 0x08, - 0x00, 0x00, 0x60, 0x60, 0x00, - 0x20, 0x10, 0x08, 0x04, 0x02, - 0x3E, 0x51, 0x49, 0x45, 0x3E, - 0x00, 0x42, 0x7F, 0x40, 0x00, - 0x72, 0x49, 0x49, 0x49, 0x46, - 0x21, 0x41, 0x49, 0x4D, 0x33, - 0x18, 0x14, 0x12, 0x7F, 0x10, - 0x27, 0x45, 0x45, 0x45, 0x39, - 0x3C, 0x4A, 0x49, 0x49, 0x31, - 0x41, 0x21, 0x11, 0x09, 0x07, - 0x36, 0x49, 0x49, 0x49, 0x36, - 0x46, 0x49, 0x49, 0x29, 0x1E, - 0x00, 0x00, 0x14, 0x00, 0x00, - 0x00, 0x40, 0x34, 0x00, 0x00, - 0x00, 0x08, 0x14, 0x22, 0x41, - 0x14, 0x14, 0x14, 0x14, 0x14, - 0x00, 0x41, 0x22, 0x14, 0x08, - 0x02, 0x01, 0x59, 0x09, 0x06, - 0x3E, 0x41, 0x5D, 0x59, 0x4E, - 0x7C, 0x12, 0x11, 0x12, 0x7C, - 0x7F, 0x49, 0x49, 0x49, 0x36, - 0x3E, 0x41, 0x41, 0x41, 0x22, - 0x7F, 0x41, 0x41, 0x41, 0x3E, - 0x7F, 0x49, 0x49, 0x49, 0x41, - 0x7F, 0x09, 0x09, 0x09, 0x01, - 0x3E, 0x41, 0x41, 0x51, 0x73, - 0x7F, 0x08, 0x08, 0x08, 0x7F, - 0x00, 0x41, 0x7F, 0x41, 0x00, - 0x20, 0x40, 0x41, 0x3F, 0x01, - 0x7F, 0x08, 0x14, 0x22, 0x41, - 0x7F, 0x40, 0x40, 0x40, 0x40, - 0x7F, 0x02, 0x1C, 0x02, 0x7F, - 0x7F, 0x04, 0x08, 0x10, 0x7F, - 0x3E, 0x41, 0x41, 0x41, 0x3E, - 0x7F, 0x09, 0x09, 0x09, 0x06, - 0x3E, 0x41, 0x51, 0x21, 0x5E, - 0x7F, 0x09, 0x19, 0x29, 0x46, - 0x26, 0x49, 0x49, 0x49, 0x32, - 0x03, 0x01, 0x7F, 0x01, 0x03, - 0x3F, 0x40, 0x40, 0x40, 0x3F, - 0x1F, 0x20, 0x40, 0x20, 0x1F, - 0x3F, 0x40, 0x38, 0x40, 0x3F, - 0x63, 0x14, 0x08, 0x14, 0x63, - 0x03, 0x04, 0x78, 0x04, 0x03, - 0x61, 0x59, 0x49, 0x4D, 0x43, - 0x00, 0x7F, 0x41, 0x41, 0x41, - 0x02, 0x04, 0x08, 0x10, 0x20, - 0x00, 0x41, 0x41, 0x41, 0x7F, - 0x04, 0x02, 0x01, 0x02, 0x04, - 0x40, 0x40, 0x40, 0x40, 0x40, - 0x00, 0x03, 0x07, 0x08, 0x00, - 0x20, 0x54, 0x54, 0x78, 0x40, - 0x7F, 0x28, 0x44, 0x44, 0x38, - 0x38, 0x44, 0x44, 0x44, 0x28, - 0x38, 0x44, 0x44, 0x28, 0x7F, - 0x38, 0x54, 0x54, 0x54, 0x18, - 0x00, 0x08, 0x7E, 0x09, 0x02, - 0x18, 0xA4, 0xA4, 0x9C, 0x78, - 0x7F, 0x08, 0x04, 0x04, 0x78, - 0x00, 0x44, 0x7D, 0x40, 0x00, - 0x20, 0x40, 0x40, 0x3D, 0x00, - 0x7F, 0x10, 0x28, 0x44, 0x00, - 0x00, 0x41, 0x7F, 0x40, 0x00, - 0x7C, 0x04, 0x78, 0x04, 0x78, - 0x7C, 0x08, 0x04, 0x04, 0x78, - 0x38, 0x44, 0x44, 0x44, 0x38, - 0xFC, 0x18, 0x24, 0x24, 0x18, - 0x18, 0x24, 0x24, 0x18, 0xFC, - 0x7C, 0x08, 0x04, 0x04, 0x08, - 0x48, 0x54, 0x54, 0x54, 0x24, - 0x04, 0x04, 0x3F, 0x44, 0x24, - 0x3C, 0x40, 0x40, 0x20, 0x7C, - 0x1C, 0x20, 0x40, 0x20, 0x1C, - 0x3C, 0x40, 0x30, 0x40, 0x3C, - 0x44, 0x28, 0x10, 0x28, 0x44, - 0x4C, 0x90, 0x90, 0x90, 0x7C, - 0x44, 0x64, 0x54, 0x4C, 0x44, - 0x00, 0x08, 0x36, 0x41, 0x00, - 0x00, 0x00, 0x77, 0x00, 0x00, - 0x00, 0x41, 0x36, 0x08, 0x00, - 0x02, 0x01, 0x02, 0x04, 0x02, - 0x3C, 0x26, 0x23, 0x26, 0x3C, - 0x1E, 0xA1, 0xA1, 0x61, 0x12, - 0x3A, 0x40, 0x40, 0x20, 0x7A, - 0x38, 0x54, 0x54, 0x55, 0x59, - 0x21, 0x55, 0x55, 0x79, 0x41, - 0x21, 0x54, 0x54, 0x78, 0x41, - 0x21, 0x55, 0x54, 0x78, 0x40, - 0x20, 0x54, 0x55, 0x79, 0x40, - 0x0C, 0x1E, 0x52, 0x72, 0x12, - 0x39, 0x55, 0x55, 0x55, 0x59, - 0x39, 0x54, 0x54, 0x54, 0x59, - 0x39, 0x55, 0x54, 0x54, 0x58, - 0x00, 0x00, 0x45, 0x7C, 0x41, - 0x00, 0x02, 0x45, 0x7D, 0x42, - 0x00, 0x01, 0x45, 0x7C, 0x40, - 0xF0, 0x29, 0x24, 0x29, 0xF0, - 0xF0, 0x28, 0x25, 0x28, 0xF0, - 0x7C, 0x54, 0x55, 0x45, 0x00, - 0x20, 0x54, 0x54, 0x7C, 0x54, - 0x7C, 0x0A, 0x09, 0x7F, 0x49, - 0x32, 0x49, 0x49, 0x49, 0x32, - 0x32, 0x48, 0x48, 0x48, 0x32, - 0x32, 0x4A, 0x48, 0x48, 0x30, - 0x3A, 0x41, 0x41, 0x21, 0x7A, - 0x3A, 0x42, 0x40, 0x20, 0x78, - 0x00, 0x9D, 0xA0, 0xA0, 0x7D, - 0x39, 0x44, 0x44, 0x44, 0x39, - 0x3D, 0x40, 0x40, 0x40, 0x3D, - 0x3C, 0x24, 0xFF, 0x24, 0x24, - 0x48, 0x7E, 0x49, 0x43, 0x66, - 0x2B, 0x2F, 0xFC, 0x2F, 0x2B, - 0xFF, 0x09, 0x29, 0xF6, 0x20, - 0xC0, 0x88, 0x7E, 0x09, 0x03, - 0x20, 0x54, 0x54, 0x79, 0x41, - 0x00, 0x00, 0x44, 0x7D, 0x41, - 0x30, 0x48, 0x48, 0x4A, 0x32, - 0x38, 0x40, 0x40, 0x22, 0x7A, - 0x00, 0x7A, 0x0A, 0x0A, 0x72, - 0x7D, 0x0D, 0x19, 0x31, 0x7D, - 0x26, 0x29, 0x29, 0x2F, 0x28, - 0x26, 0x29, 0x29, 0x29, 0x26, - 0x30, 0x48, 0x4D, 0x40, 0x20, - 0x38, 0x08, 0x08, 0x08, 0x08, - 0x08, 0x08, 0x08, 0x08, 0x38, - 0x2F, 0x10, 0xC8, 0xAC, 0xBA, - 0x2F, 0x10, 0x28, 0x34, 0xFA, - 0x00, 0x00, 0x7B, 0x00, 0x00, - 0x08, 0x14, 0x2A, 0x14, 0x22, - 0x22, 0x14, 0x2A, 0x14, 0x08, - 0xAA, 0x00, 0x55, 0x00, 0xAA, - 0xAA, 0x55, 0xAA, 0x55, 0xAA, - 0x00, 0x00, 0x00, 0xFF, 0x00, - 0x10, 0x10, 0x10, 0xFF, 0x00, - 0x14, 0x14, 0x14, 0xFF, 0x00, - 0x10, 0x10, 0xFF, 0x00, 0xFF, - 0x10, 0x10, 0xF0, 0x10, 0xF0, - 0x14, 0x14, 0x14, 0xFC, 0x00, - 0x14, 0x14, 0xF7, 0x00, 0xFF, - 0x00, 0x00, 0xFF, 0x00, 0xFF, - 0x14, 0x14, 0xF4, 0x04, 0xFC, - 0x14, 0x14, 0x17, 0x10, 0x1F, - 0x10, 0x10, 0x1F, 0x10, 0x1F, - 0x14, 0x14, 0x14, 0x1F, 0x00, - 0x10, 0x10, 0x10, 0xF0, 0x00, - 0x00, 0x00, 0x00, 0x1F, 0x10, - 0x10, 0x10, 0x10, 0x1F, 0x10, - 0x10, 0x10, 0x10, 0xF0, 0x10, - 0x00, 0x00, 0x00, 0xFF, 0x10, - 0x10, 0x10, 0x10, 0x10, 0x10, - 0x10, 0x10, 0x10, 0xFF, 0x10, - 0x00, 0x00, 0x00, 0xFF, 0x14, - 0x00, 0x00, 0xFF, 0x00, 0xFF, - 0x00, 0x00, 0x1F, 0x10, 0x17, - 0x00, 0x00, 0xFC, 0x04, 0xF4, - 0x14, 0x14, 0x17, 0x10, 0x17, - 0x14, 0x14, 0xF4, 0x04, 0xF4, - 0x00, 0x00, 0xFF, 0x00, 0xF7, - 0x14, 0x14, 0x14, 0x14, 0x14, - 0x14, 0x14, 0xF7, 0x00, 0xF7, - 0x14, 0x14, 0x14, 0x17, 0x14, - 0x10, 0x10, 0x1F, 0x10, 0x1F, - 0x14, 0x14, 0x14, 0xF4, 0x14, - 0x10, 0x10, 0xF0, 0x10, 0xF0, - 0x00, 0x00, 0x1F, 0x10, 0x1F, - 0x00, 0x00, 0x00, 0x1F, 0x14, - 0x00, 0x00, 0x00, 0xFC, 0x14, - 0x00, 0x00, 0xF0, 0x10, 0xF0, - 0x10, 0x10, 0xFF, 0x10, 0xFF, - 0x14, 0x14, 0x14, 0xFF, 0x14, - 0x10, 0x10, 0x10, 0x1F, 0x00, - 0x00, 0x00, 0x00, 0xF0, 0x10, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, - 0xFF, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xFF, 0xFF, - 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, - 0x38, 0x44, 0x44, 0x38, 0x44, - 0x7C, 0x2A, 0x2A, 0x3E, 0x14, - 0x7E, 0x02, 0x02, 0x06, 0x06, - 0x02, 0x7E, 0x02, 0x7E, 0x02, - 0x63, 0x55, 0x49, 0x41, 0x63, - 0x38, 0x44, 0x44, 0x3C, 0x04, - 0x40, 0x7E, 0x20, 0x1E, 0x20, - 0x06, 0x02, 0x7E, 0x02, 0x02, - 0x99, 0xA5, 0xE7, 0xA5, 0x99, - 0x1C, 0x2A, 0x49, 0x2A, 0x1C, - 0x4C, 0x72, 0x01, 0x72, 0x4C, - 0x30, 0x4A, 0x4D, 0x4D, 0x30, - 0x30, 0x48, 0x78, 0x48, 0x30, - 0xBC, 0x62, 0x5A, 0x46, 0x3D, - 0x3E, 0x49, 0x49, 0x49, 0x00, - 0x7E, 0x01, 0x01, 0x01, 0x7E, - 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, - 0x44, 0x44, 0x5F, 0x44, 0x44, - 0x40, 0x51, 0x4A, 0x44, 0x40, - 0x40, 0x44, 0x4A, 0x51, 0x40, - 0x00, 0x00, 0xFF, 0x01, 0x03, - 0xE0, 0x80, 0xFF, 0x00, 0x00, - 0x08, 0x08, 0x6B, 0x6B, 0x08, - 0x36, 0x12, 0x36, 0x24, 0x36, - 0x06, 0x0F, 0x09, 0x0F, 0x06, - 0x00, 0x00, 0x18, 0x18, 0x00, - 0x00, 0x00, 0x10, 0x10, 0x00, - 0x30, 0x40, 0xFF, 0x01, 0x01, - 0x00, 0x1F, 0x01, 0x01, 0x1E, - 0x00, 0x19, 0x1D, 0x17, 0x12, - 0x00, 0x3C, 0x3C, 0x3C, 0x3C, - 0x00, 0x00, 0x00, 0x00, 0x00, -}; -#endif
diff -r e5018e5ba340 -r 8a3cf73d7ed3 Config.h --- a/Config.h Thu Jun 16 08:12:33 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,11 +0,0 @@ -#ifndef __CONFIG_H_ -#define __CONFIG_H_ - -// Uncomment this to turn on the OLED -//#define OPEN_OLED - -// Uncomment this to open PM25 -//#define OPEN_PM25 - - -#endif // __CONFIG_H_ \ No newline at end of file
diff -r e5018e5ba340 -r 8a3cf73d7ed3 I2Cdev.cpp --- a/I2Cdev.cpp Thu Jun 16 08:12:33 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,339 +0,0 @@ -#if 0 -#include "I2Cdev.h" - -extern DigitalOut myled; -static uint8_t buffer[24]; -//I2C g_i2c1(P0_11, P0_10); -extern I2C g_i2c; - -uint16_t I2Cdev::readTimeout = I2CDEV_DEFAULT_READ_TIMEOUT; - -void I2Cdev::init() -{ - g_i2c.frequency(267000); -} - -/** Default constructor. - */ -I2Cdev::I2Cdev() -{ - g_i2c.frequency(400000); - //myled = 1; -} - -/** Read a single bit from an 8-bit device register. - * @param devAddr I2C slave device address - * @param regAddr Register regAddr to read from - * @param bitNum Bit position to read (0-7) - * @param data Container for single bit value - * @param timeout Optional read timeout in milliseconds (0 to disable, leave off to use default class value in I2Cdev::readTimeout) - * @return Status of read operation (true = success) - */ -int8_t I2Cdev::readBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t *data, uint16_t timeout) -{ - uint8_t b; - uint8_t count = readByte(devAddr, regAddr, &b, timeout); - *data = b & (1 << bitNum); - return count; -} - -/** Read a single bit from a 16-bit device register. - * @param devAddr I2C slave device address - * @param regAddr Register regAddr to read from - * @param bitNum Bit position to read (0-15) - * @param data Container for single bit value - * @param timeout Optional read timeout in milliseconds (0 to disable, leave off to use default class value in I2Cdev::readTimeout) - * @return Status of read operation (true = success) - */ -int8_t I2Cdev::readBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t *data, uint16_t timeout) -{ - uint16_t b; - uint8_t count = readWord(devAddr, regAddr, &b, timeout); - *data = b & (1 << bitNum); - return count; -} - -/** Read multiple bits from an 8-bit device register. - * @param devAddr I2C slave device address - * @param regAddr Register regAddr to read from - * @param bitStart First bit position to read (0-7) - * @param length Number of bits to read (not more than 8) - * @param data Container for right-aligned value (i.e. '101' read from any bitStart position will equal 0x05) - * @param timeout Optional read timeout in milliseconds (0 to disable, leave off to use default class value in I2Cdev::readTimeout) - * @return Status of read operation (true = success) - */ -int8_t I2Cdev::readBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t *data, uint16_t timeout) -{ - // 01101001 read byte - // 76543210 bit numbers - // xxx args: bitStart=4, length=3 - // 010 masked - // -> 010 shifted - uint8_t count, b; - if ((count = readByte(devAddr, regAddr, &b, timeout)) != 0) { - uint8_t mask = ((1 << length) - 1) << (bitStart - length + 1); - b &= mask; - b >>= (bitStart - length + 1); - *data = b; - } - return count; -} - -/** Read multiple bits from a 16-bit device register. - * @param devAddr I2C slave device address - * @param regAddr Register regAddr to read from - * @param bitStart First bit position to read (0-15) - * @param length Number of bits to read (not more than 16) - * @param data Container for right-aligned value (i.e. '101' read from any bitStart position will equal 0x05) - * @param timeout Optional read timeout in milliseconds (0 to disable, leave off to use default class value in I2Cdev::readTimeout) - * @return Status of read operation (1 = success, 0 = failure, -1 = timeout) - */ -int8_t I2Cdev::readBitsW(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t *data, uint16_t timeout) -{ - // 1101011001101001 read byte - // fedcba9876543210 bit numbers - // xxx args: bitStart=12, length=3 - // 010 masked - // -> 010 shifted - uint8_t count; - uint16_t w; - if ((count = readWord(devAddr, regAddr, &w, timeout)) != 0) { - uint16_t mask = ((1 << length) - 1) << (bitStart - length + 1); - w &= mask; - w >>= (bitStart - length + 1); - *data = w; - } - return count; -} - -/** Read single byte from an 8-bit device register. - * @param devAddr I2C slave device address - * @param regAddr Register regAddr to read from - * @param data Container for byte value read from device - * @param timeout Optional read timeout in milliseconds (0 to disable, leave off to use default class value in I2Cdev::readTimeout) - * @return Status of read operation (true = success) - */ -int8_t I2Cdev::readByte(uint8_t devAddr, uint8_t regAddr, uint8_t *data, uint16_t timeout) -{ - return readBytes(devAddr, regAddr, 1, data, timeout); -} - -/** Read single word from a 16-bit device register. - * @param devAddr I2C slave device address - * @param regAddr Register regAddr to read from - * @param data Container for word value read from device - * @param timeout Optional read timeout in milliseconds (0 to disable, leave off to use default class value in I2Cdev::readTimeout) - * @return Status of read operation (true = success) - */ -int8_t I2Cdev::readWord(uint8_t devAddr, uint8_t regAddr, uint16_t *data, uint16_t timeout) -{ - return readWords(devAddr, regAddr, 1, data, timeout); -} - -/** Read multiple bytes from an 8-bit device register. - * @param devAddr I2C slave device address - * @param regAddr First register regAddr to read from - * @param length Number of bytes to read - * @param data Buffer to store read data in - * @param timeout Optional read timeout in milliseconds (0 to disable, leave off to use default class value in I2Cdev::readTimeout) - * @return Number of bytes read (-1 indicates failure) - */ -int8_t I2Cdev::readBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data, uint16_t timeout) -{ - g_i2c.write(devAddr << 1, (char*)®Addr, 1, false); - uint8_t realReadAddr = (devAddr << 1) | 0x01; - int retRead = g_i2c.read(realReadAddr, (char*)data, length); - if (retRead == 0) { - return length; - } - return -1; -} - -int8_t I2Cdev::readBytesOnly(uint8_t devAddr, uint8_t length, uint8_t *data, uint16_t timeout) -{ - uint8_t realReadAddr = (devAddr << 1) | 0x01; - int retRead = g_i2c.read(realReadAddr, (char*)data, length); - if (retRead == 0) { - return length; - } - return -1; -} - -/** Read multiple words from a 16-bit device register. - * @param devAddr I2C slave device address - * @param regAddr First register regAddr to read from - * @param length Number of words to read - * @param data Buffer to store read data in - * @param timeout Optional read timeout in milliseconds (0 to disable, leave off to use default class value in I2Cdev::readTimeout) - * @return Number of words read (0 indicates failure) - */ -int8_t I2Cdev::readWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data, uint16_t timeout) -{ - g_i2c.write(devAddr << 1, (char*)®Addr, 1, false); - uint8_t realReadAddr = (devAddr << 1) | 0x01; - int retRead = g_i2c.read(realReadAddr, (char*)data, length*2); - if (retRead == 0) { - return length; - } - return 0; -} - -/** write a single bit in an 8-bit device register. - * @param devAddr I2C slave device address - * @param regAddr Register regAddr to write to - * @param bitNum Bit position to write (0-7) - * @param value New bit value to write - * @return Status of operation (true = success) - */ -bool I2Cdev::writeBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t data) -{ - uint8_t b; - readByte(devAddr, regAddr, &b); - b = (data != 0) ? (b | (1 << bitNum)) : (b & ~(1 << bitNum)); - return writeByte(devAddr, regAddr, b); -} - -/** write a single bit in a 16-bit device register. - * @param devAddr I2C slave device address - * @param regAddr Register regAddr to write to - * @param bitNum Bit position to write (0-15) - * @param value New bit value to write - * @return Status of operation (true = success) - */ -bool I2Cdev::writeBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t data) -{ - uint16_t w; - readWord(devAddr, regAddr, &w); - w = (data != 0) ? (w | (1 << bitNum)) : (w & ~(1 << bitNum)); - return writeWord(devAddr, regAddr, w); -} - -/** Write multiple bits in an 8-bit device register. - * @param devAddr I2C slave device address - * @param regAddr Register regAddr to write to - * @param bitStart First bit position to write (0-7) - * @param length Number of bits to write (not more than 8) - * @param data Right-aligned value to write - * @return Status of operation (true = success) - */ -bool I2Cdev::writeBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t data) -{ - // 010 value to write - // 76543210 bit numbers - // xxx args: bitStart=4, length=3 - // 00011100 mask byte - // 10101111 original value (sample) - // 10100011 original & ~mask - // 10101011 masked | value - uint8_t b; - if (readByte(devAddr, regAddr, &b) != 0) { - uint8_t mask = ((1 << length) - 1) << (bitStart - length + 1); - data <<= (bitStart - length + 1); // shift data into correct position - data &= mask; // zero all non-important bits in data - b &= ~(mask); // zero all important bits in existing byte - b |= data; // combine data with existing byte - return writeByte(devAddr, regAddr, b); - } else { - return false; - } -} - -/** Write multiple bits in a 16-bit device register. - * @param devAddr I2C slave device address - * @param regAddr Register regAddr to write to - * @param bitStart First bit position to write (0-15) - * @param length Number of bits to write (not more than 16) - * @param data Right-aligned value to write - * @return Status of operation (true = success) - */ -bool I2Cdev::writeBitsW(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t data) -{ - // 010 value to write - // fedcba9876543210 bit numbers - // xxx args: bitStart=12, length=3 - // 0001110000000000 mask byte - // 1010111110010110 original value (sample) - // 1010001110010110 original & ~mask - // 1010101110010110 masked | value - uint16_t w; - if (readWord(devAddr, regAddr, &w) != 0) { - uint8_t mask = ((1 << length) - 1) << (bitStart - length + 1); - data <<= (bitStart - length + 1); // shift data into correct position - data &= mask; // zero all non-important bits in data - w &= ~(mask); // zero all important bits in existing word - w |= data; // combine data with existing word - return writeWord(devAddr, regAddr, w); - } else { - return false; - } -} - -/** Write single byte to an 8-bit device register. - * @param devAddr I2C slave device address - * @param regAddr Register address to write to - * @param data New byte value to write - * @return Status of operation (true = success) - */ -bool I2Cdev::writeByte(uint8_t devAddr, uint8_t regAddr, uint8_t data) -{ - return writeBytes(devAddr, regAddr, 1, &data); -} - -/** Write single word to a 16-bit device register. - * @param devAddr I2C slave device address - * @param regAddr Register address to write to - * @param data New word value to write - * @return Status of operation (true = success) - */ -bool I2Cdev::writeWord(uint8_t devAddr, uint8_t regAddr, uint16_t data) -{ - return writeWords(devAddr, regAddr, 1, &data); -} - -/** Write multiple bytes to an 8-bit device register. - * @param devAddr I2C slave device address - * @param regAddr First register address to write to - * @param length Number of bytes to write - * @param data Buffer to copy new data from - * @return Status of operation (true = success) - */ -bool I2Cdev::writeBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t* data) -{ - uint8_t i; - uint8_t *p = buffer; - - /* Copy address and data to local buffer for burst write */ - *p++ = regAddr; - for (i = 0; i < length; i++) { - *p++ = *data++; - } - length++; - /* Send address and data */ - int status = g_i2c.write(devAddr << 1, (char*)buffer, length, false); - return status == 0; -} - -/** Write multiple words to a 16-bit device register. - * @param devAddr I2C slave device address - * @param regAddr First register address to write to - * @param length Number of words to write - * @param data Buffer to copy new data from - * @return Status of operation (true = success) - */ -bool I2Cdev::writeWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t* data) -{ - uint16_t i; - uint8_t *p = buffer; - uint16_t realLen = length * 2; - - /* Copy address and data to local buffer for burst write */ - *p++ = regAddr; - for (i = 0; i < realLen; i++) { - *p++ = *data++; - } - realLen++; - /* Send address and data */ - int status = g_i2c.write(devAddr << 1, (char*)buffer, realLen, false); - return status == 0; -} -#endif \ No newline at end of file
diff -r e5018e5ba340 -r 8a3cf73d7ed3 I2Cdev.h --- a/I2Cdev.h Thu Jun 16 08:12:33 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -#ifndef _I2CDEV_H_ -#define _I2CDEV_H_ -#if 0 -#include "mbed.h" - -#define I2CDEV_DEFAULT_READ_TIMEOUT 1000 -class I2Cdev { - public: - I2Cdev(); - - static void init(); - static int8_t readBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout); - static int8_t readBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout); - static int8_t readBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout); - static int8_t readBitsW(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout); - static int8_t readByte(uint8_t devAddr, uint8_t regAddr, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout); - static int8_t readWord(uint8_t devAddr, uint8_t regAddr, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout); - static int8_t readBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout); - static int8_t readBytesOnly(uint8_t devAddr, uint8_t length, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout); - static int8_t readWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout); - - static bool writeBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t data); - static bool writeBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t data); - static bool writeBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t data); - static bool writeBitsW(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t data); - static bool writeByte(uint8_t devAddr, uint8_t regAddr, uint8_t data); - static bool writeWord(uint8_t devAddr, uint8_t regAddr, uint16_t data); - static bool writeBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data); - static bool writeWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data); - - static uint16_t readTimeout; -}; - -#endif /* _I2CDEV_H_ */ -#endif \ No newline at end of file
diff -r e5018e5ba340 -r 8a3cf73d7ed3 MicroduinoPinNames.h --- a/MicroduinoPinNames.h Thu Jun 16 08:12:33 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ - -#define D0 P0_0 -#define D1 P0_4 -#define D2 P0_28 -#define D3 P0_26 -#define D4 P0_25 -#define D5 P0_24 -#define D6 P0_1 -#define D7 P0_20 -#define D8 P0_19 -#define D9 P0_18 -#define D10 P0_17 -#define D11 P0_16 -#define D12 P0_15 -#define D13 P0_13 - -#define A0 P0_7 -#define A1 P0_6 -#define A2 P0_14 -#define A3 P0_23 -#define A6 P0_22 -#define A7 P0_21 - -#define SCL P0_10 -#define SDA P0_11 \ No newline at end of file
diff -r e5018e5ba340 -r 8a3cf73d7ed3 Printable.h --- a/Printable.h Thu Jun 16 08:12:33 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -/* - Printable.h - Interface class that allows printing of complex types - Copyright (c) 2011 Adrian McEwen. All right reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#ifndef Printable_h -#define Printable_h - -#include <stdlib.h> - -class Print; - -/** The Printable class provides a way for new classes to allow themselves to be printed. - By deriving from Printable and implementing the printTo method, it will then be possible - for users to print out instances of this class by passing them into the usual - Print::print and Print::println methods. -*/ - -class Printable -{ - public: - virtual size_t printTo(Print& p) const = 0; -}; - -#endif - -
diff -r e5018e5ba340 -r 8a3cf73d7ed3 Printit.cpp --- a/Printit.cpp Thu Jun 16 08:12:33 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,271 +0,0 @@ -/* - Print.cpp - Base class that provides print() and println() - Copyright (c) 2008 David A. Mellis. All right reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Modified 23 November 2006 by David A. Mellis - Modified 03 August 2015 by Chuck Todd - */ - -//#include <stdlib.h> -//#include <stdio.h> -//#include <string.h> -#include <math.h> -//#include "Arduino.h" - -#include "Printit.h" - -// Public Methods ////////////////////////////////////////////////////////////// - -/* default implementation: may be overridden */ -size_t Print::write(const uint8_t *buffer, size_t size) -{ - size_t n = 0; - while (size--) { - if (write(*buffer++)) n++; - else break; - } - return n; -} - -#if 0 -size_t Print::print(const __FlashStringHelper *ifsh) -{ - PGM_P p = reinterpret_cast<PGM_P>(ifsh); - size_t n = 0; - while (1) { - unsigned char c = pgm_read_byte(p++); - if (c == 0) break; - if (write(c)) n++; - else break; - } - return n; -} - -size_t Print::print(const String &s) -{ - return write(s.c_str(), s.length()); -} -#endif - -size_t Print::print(char *str) -{ - return write(str); -} - -size_t Print::print(char c) -{ - return write(c); -} - -size_t Print::print(unsigned char b, int base) -{ - return print((unsigned long) b, base); -} - -size_t Print::print(int n, int base) -{ - return print((long) n, base); -} - -size_t Print::print(unsigned int n, int base) -{ - return print((unsigned long) n, base); -} - -size_t Print::print(long n, int base) -{ - if (base == 0) { - return write(n); - } else if (base == 10) { - if (n < 0) { - int t = print('-'); - n = -n; - return printNumber(n, 10) + t; - } - return printNumber(n, 10); - } else { - return printNumber(n, base); - } -} - -size_t Print::print(unsigned long n, int base) -{ - if (base == 0) return write(n); - else return printNumber(n, base); -} - -size_t Print::print(double n, int digits) -{ - return printFloat(n, digits); -} - -#if 0 -size_t Print::println(const __FlashStringHelper *ifsh) -{ - size_t n = print(ifsh); - n += println(); - return n; -} -#endif - -size_t Print::print(const Printable& x) -{ - return x.printTo(*this); -} - -size_t Print::println(void) -{ - return write("\r\n"); -} - -#if 0 -size_t Print::println(const String &s) -{ - size_t n = print(s); - n += println(); - return n; -} -#endif - -size_t Print::println(char *c) -{ - size_t n = print(c); - n += println(); - return n; -} - -size_t Print::println(char c) -{ - size_t n = print(c); - n += println(); - return n; -} - -size_t Print::println(unsigned char b, int base) -{ - size_t n = print(b, base); - n += println(); - return n; -} - -size_t Print::println(int num, int base) -{ - size_t n = print(num, base); - n += println(); - return n; -} - -size_t Print::println(unsigned int num, int base) -{ - size_t n = print(num, base); - n += println(); - return n; -} - -size_t Print::println(long num, int base) -{ - size_t n = print(num, base); - n += println(); - return n; -} - -size_t Print::println(unsigned long num, int base) -{ - size_t n = print(num, base); - n += println(); - return n; -} - -size_t Print::println(double num, int digits) -{ - size_t n = print(num, digits); - n += println(); - return n; -} - -size_t Print::println(const Printable& x) -{ - size_t n = print(x); - n += println(); - return n; -} - -// Private Methods ///////////////////////////////////////////////////////////// - -size_t Print::printNumber(unsigned long n, uint8_t base) -{ - char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte. - char *str = &buf[sizeof(buf) - 1]; - - *str = '\0'; - - // prevent crash if called with base == 1 - if (base < 2) base = 10; - - do { - char c = n % base; - n /= base; - - *--str = c < 10 ? c + '0' : c + 'A' - 10; - } while(n); - - return write(str); -} - -size_t Print::printFloat(double number, uint8_t digits) -{ - size_t n = 0; - - if (isnan(number)) return print("nan"); - if (isinf(number)) return print("inf"); - if (number > 4294967040.0) return print ("ovf"); // constant determined empirically - if (number <-4294967040.0) return print ("ovf"); // constant determined empirically - - // Handle negative numbers - if (number < 0.0) { - n += print('-'); - number = -number; - } - - // Round correctly so that print(1.999, 2) prints as "2.00" - double rounding = 0.5; - for (uint8_t i=0; i<digits; ++i) - rounding /= 10.0; - - number += rounding; - - // Extract the integer part of the number and print it - unsigned long int_part = (unsigned long)number; - double remainder = number - (double)int_part; - n += print(int_part); - - // Print the decimal point, but only if there are digits beyond - if (digits > 0) { - n += print("."); - } - - // Extract digits from the remainder one at a time - while (digits-- > 0) { - remainder *= 10.0; - int toPrint = int(remainder); - n += print(toPrint); - remainder -= toPrint; - } - - return n; -} -
diff -r e5018e5ba340 -r 8a3cf73d7ed3 Printit.h --- a/Printit.h Thu Jun 16 08:12:33 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,95 +0,0 @@ -/* - Print.h - Base class that provides print() and println() - Copyright (c) 2008 David A. Mellis. All right reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#ifndef Printit_h -#define Printit_h - -#include <inttypes.h> -//#include <stdio.h> // for size_t - -#include "WString.h" -#include "Printable.h" - -#define DEC 10 -#define HEX 16 -#define OCT 8 -#define BIN 2 - -class Print -{ -public: - Print() : write_error(0) {} - - int getWriteError() { - return write_error; - } - void clearWriteError() { - setWriteError(0); - } - - virtual size_t write(uint8_t) = 0; - size_t write(const char *str) { - if (str == NULL) return 0; - return write((const uint8_t *)str, strlen(str)); - } - virtual size_t write(const uint8_t *buffer, size_t size); - size_t write(const char *buffer, size_t size) { - return write((const uint8_t *)buffer, size); - } -#if 0 - size_t print(const __FlashStringHelper *); -#endif -public: - //size_t print(const String &); - size_t print(char *str); - size_t print(char); - size_t print(unsigned char, int = DEC); - size_t print(int, int = DEC); - size_t print(unsigned int, int = DEC); - size_t print(long, int = DEC); - size_t print(unsigned long, int = DEC); - size_t print(double, int = 2); - size_t print(const Printable&); -#if 0 - size_t println(const __FlashStringHelper *); -#endif - //size_t println(const String &s); - size_t println(char *str); - size_t println(char); - size_t println(unsigned char, int = DEC); - size_t println(int, int = DEC); - size_t println(unsigned int, int = DEC); - size_t println(long, int = DEC); - size_t println(unsigned long, int = DEC); - size_t println(double, int = 2); - size_t println(const Printable&); - size_t println(void); - -//private: - int write_error; - size_t printNumber(unsigned long, uint8_t); - size_t printFloat(double, uint8_t); -//protected: - void setWriteError(int err = 1) { - write_error = err; - } -}; - -#endif -
diff -r e5018e5ba340 -r 8a3cf73d7ed3 U8glib.cpp --- a/U8glib.cpp Thu Jun 16 08:12:33 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,102 +0,0 @@ -/* - - U8glib.cpp - - C++ Interface - - Universal 8bit Graphics Library - - Copyright (c) 2011, olikraus@gmail.com - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this list - of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or other - materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND - CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ -#if 0 -#include "U8glib.h" - - -uint8_t U8GLIB::initSPI(u8g_dev_t *dev, uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset) -{ - #ifdef U8G_WITH_PINLIST - prepare(); - return u8g_InitSPI(&u8g, dev, sck, mosi, cs, a0, reset); - #else - return 1; - #endif -} - -uint8_t U8GLIB::initHWSPI(u8g_dev_t *dev, uint8_t cs, uint8_t a0, uint8_t reset) -{ - #ifdef U8G_WITH_PINLIST - prepare(); - return u8g_InitHWSPI(&u8g, dev, cs, a0, reset); - #else - return 1; - #endif -} - -uint8_t U8GLIB::initI2C(u8g_dev_t *dev, uint8_t options) -{ - #ifdef U8G_WITH_PINLIST - prepare(); - return u8g_InitI2C(&u8g, dev, options); - #else - return 1; - #endif -} - -uint8_t U8GLIB::init8Bit(u8g_dev_t *dev, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, - uint8_t en, uint8_t cs1, uint8_t cs2, uint8_t di, uint8_t rw, uint8_t reset) -{ - #ifdef U8G_WITH_PINLIST - prepare(); - return u8g_Init8Bit(&u8g, dev, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, cs2, di, rw, reset); - #else - return 1; - #endif -} - -uint8_t U8GLIB::init8BitFixedPort(u8g_dev_t *dev, uint8_t en, uint8_t cs, uint8_t di, uint8_t rw, uint8_t reset) -{ - #ifdef U8G_WITH_PINLIST - prepare(); - return u8g_Init8BitFixedPort(&u8g, dev, en, cs, di, rw, reset); - #else - return 1; - #endif -} - -uint8_t U8GLIB::initRW8Bit(u8g_dev_t *dev, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, - uint8_t cs, uint8_t a0, uint8_t wr, uint8_t rd, uint8_t reset) -{ - #ifdef U8G_WITH_PINLIST - prepare(); - return u8g_InitRW8Bit(&u8g, dev, d0, d1, d2, d3, d4, d5, d6, d7, cs, a0, wr, rd, reset); - #else - return 1; - #endif -} -#endif \ No newline at end of file
diff -r e5018e5ba340 -r 8a3cf73d7ed3 U8glib.h --- a/U8glib.h Thu Jun 16 08:12:33 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1443 +0,0 @@ -/* - - U8glib.h - - C++ Interface - - Universal 8bit Graphics Library - - Copyright (c) 2011, olikraus@gmail.com - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this list - of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or other - materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND - CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -#if 0 -#ifndef _CPP_U8GLIB -#define _CPP_U8GLIB -#include "mbed.h" -#include <Printit.h> -//#include "u8g.h" - -extern void log(char *); -extern Serial pc; -class U8GLIB : public Print -{ -private: - u8g_t u8g; - u8g_uint_t tx, ty; // current position for the Print base class procedures - uint8_t is_begin; - - void prepare(void) { - tx = 0; - ty = 0; - is_begin = 0; - } - void cbegin(void) { - if ( is_begin == 0 ) { - is_begin = 1; - u8g_Begin(&u8g); - } - } - uint8_t initSPI(u8g_dev_t *dev, uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE); - uint8_t initHWSPI(u8g_dev_t *dev, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE); - uint8_t initI2C(u8g_dev_t *dev, uint8_t options); -protected: - uint8_t init8BitFixedPort(u8g_dev_t *dev, uint8_t en, uint8_t cs, uint8_t di, uint8_t rw, uint8_t reset); -private: - uint8_t init8Bit(u8g_dev_t *dev, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, - uint8_t en, uint8_t cs1, uint8_t cs2, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE); - uint8_t initRW8Bit(u8g_dev_t *dev, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, - uint8_t cs, uint8_t a0, uint8_t wr, uint8_t rd, uint8_t reset); -public: - - /* constructor */ - U8GLIB(void) - { } - U8GLIB(u8g_dev_t *dev) { - prepare(); - u8g_Init(&u8g, dev); - } - U8GLIB(u8g_dev_t *dev, u8g_com_fnptr com_fn) { - prepare(); - //log("hehe...u8g = %x", &u8g); - //pc.printf("hehe...u8g = 0x%x, dev = 0x%x, com_fn = 0x%x\r\n", &u8g, dev, com_fn); - log("hehe..."); - u8g_InitComFn(&u8g, dev, com_fn); - } - U8GLIB(u8g_dev_t *dev, uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset) { - initSPI(dev, sck, mosi, cs, a0, reset); - } - U8GLIB(u8g_dev_t *dev, uint8_t cs, uint8_t a0, uint8_t reset) { - initHWSPI(dev, cs, a0, reset); - } - U8GLIB(u8g_dev_t *dev, uint8_t options) { - initI2C(dev, options); - } - U8GLIB(u8g_dev_t *dev, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, - uint8_t en, uint8_t cs1, uint8_t cs2, uint8_t di, uint8_t rw, uint8_t reset) { - init8Bit(dev, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, cs2, di, rw, reset); - } - U8GLIB(u8g_dev_t *dev, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, - uint8_t cs, uint8_t a0, uint8_t wr, uint8_t rd, uint8_t reset) { - initRW8Bit(dev, d0, d1, d2, d3, d4, d5, d6, d7, cs, a0, wr, rd, reset); - } - - void init_u8g(void) { - log("Enter init_u8g()"); - u8g_InitComFn(&u8g, &u8g_dev_ssd1306_microduino_128x64_i2c, u8g_com_lpc824_ssd_i2c_fn); - //u8g_dev_ssd1306_microduino_128x64_i2c, u8g_com_lpc824_ssd_i2c_fn - } - uint8_t begin(void) { - is_begin = 1; - return u8g_Begin(&u8g); - } - - void setPrintPos(u8g_uint_t x, u8g_uint_t y) { - tx = x; - ty = y; - } - u8g_t *getU8g(void) { - return &u8g; - } - - - /* implementation of the write interface to the print class */ -#if defined(ARDUINO) && ARDUINO >= 100 - size_t write(uint8_t c) { - tx += u8g_DrawGlyph(&u8g, tx, ty, c); - return 1; - } -#else - size_t write(uint8_t c) { - tx += u8g_DrawGlyph(&u8g, tx, ty, c); - return tx; - } -#endif - - /* screen rotation */ - void undoRotation(void) { - u8g_UndoRotation(&u8g); - } - void setRot90(void) { - u8g_SetRot90(&u8g); - } - void setRot180(void) { - u8g_SetRot180(&u8g); - } - void setRot270(void) { - u8g_SetRot270(&u8g); - } - - /* screen scaling */ - void undoScale(void) { - u8g_UndoScale(&u8g); - } - void setScale2x2(void) { - u8g_SetScale2x2(&u8g); - } - - /* picture loop */ - void firstPage(void) { - cbegin(); - u8g_FirstPage(&u8g); - } - uint8_t nextPage(void) { - return u8g_NextPage(&u8g); - } - - /* system commands */ - uint8_t setContrast(uint8_t contrast) { - cbegin(); - return u8g_SetContrast(&u8g, contrast); - } - void sleepOn(void) { - u8g_SleepOn(&u8g); - } - void sleepOff(void) { - u8g_SleepOff(&u8g); - } - - /* graphic primitives */ - void setColorEntry(uint8_t color_index, uint8_t r, uint8_t g, uint8_t b) { - u8g_SetColorEntry(&u8g, color_index, r, g, b); - } - void setHiColor(uint16_t rgb) { - u8g_SetHiColor(&u8g, rgb); - } - void setHiColorByRGB(uint8_t r, uint8_t g, uint8_t b) { - u8g_SetHiColorByRGB(&u8g, r, g, b); - } - void setRGB(uint8_t r, uint8_t g, uint8_t b) { - u8g_SetRGB(&u8g, r, g, b); - } - - void setColorIndex(uint8_t color_index) { - u8g_SetColorIndex(&u8g, color_index); - } - uint8_t getColorIndex(void) { - return u8g_GetColorIndex(&u8g); - } - - void setDefaultForegroundColor(void) { - u8g_SetDefaultForegroundColor(&u8g); - } - void setDefaultBackgroundColor(void) { - u8g_SetDefaultBackgroundColor(&u8g); - } - void setDefaultMidColor(void) { - u8g_SetDefaultMidColor(&u8g); - } - - u8g_uint_t getWidth(void) { - return u8g_GetWidth(&u8g); - } - u8g_uint_t getHeight(void) { - return u8g_GetHeight(&u8g); - } - uint8_t getMode(void) { - return u8g_GetMode(&u8g); - } - - void drawPixel(u8g_uint_t x, u8g_uint_t y) { - return u8g_DrawPixel(&u8g, x, y); - } - void drawHLine(u8g_uint_t x, u8g_uint_t y, u8g_uint_t w) { - u8g_DrawHLine(&u8g, x, y, w); - } - void drawVLine(u8g_uint_t x, u8g_uint_t y, u8g_uint_t h) { - u8g_DrawVLine(&u8g, x, y, h); - } - void drawLine(u8g_uint_t x1, u8g_uint_t y1, u8g_uint_t x2, u8g_uint_t y2) { - u8g_DrawLine(&u8g, x1, y1, x2, y2); - } - - void drawFrame(u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h) { - u8g_DrawFrame(&u8g, x, y, w, h); - } - void drawRFrame(u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h, u8g_uint_t r) { - u8g_DrawRFrame(&u8g, x, y, w, h,r); - } - void drawBox(u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h) { - u8g_DrawBox(&u8g, x, y, w, h); - } - void drawRBox(u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h, u8g_uint_t r) { - u8g_DrawRBox(&u8g, x, y, w, h,r); - } - - void drawCircle(u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rad, uint8_t opt = U8G_DRAW_ALL) { - u8g_DrawCircle(&u8g, x0, y0, rad, opt); - } - void drawDisc(u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rad, uint8_t opt = U8G_DRAW_ALL) { - u8g_DrawDisc(&u8g, x0, y0, rad, opt); - } - - void drawEllipse(u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rx, u8g_uint_t ry, uint8_t opt = U8G_DRAW_ALL) { - u8g_DrawEllipse(&u8g, x0, y0, rx, ry, opt); - } - void drawFilledEllipse(u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rx, u8g_uint_t ry, uint8_t opt = U8G_DRAW_ALL) { - u8g_DrawFilledEllipse(&u8g, x0, y0, rx, ry, opt); - } - - void drawTriangle(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) { - u8g_DrawTriangle(&u8g, x0, y0, x1, y1, x2, y2); - } - - - - /* bitmap handling */ - void drawBitmap(u8g_uint_t x, u8g_uint_t y, u8g_uint_t cnt, u8g_uint_t h, const uint8_t *bitmap) { - u8g_DrawBitmap(&u8g, x, y, cnt, h, bitmap); - } - void drawBitmapP(u8g_uint_t x, u8g_uint_t y, u8g_uint_t cnt, u8g_uint_t h, const u8g_pgm_uint8_t *bitmap) { - u8g_DrawBitmapP(&u8g, x, y, cnt, h, bitmap); - } - - void drawXBM(u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h, const uint8_t *bitmap) { - u8g_DrawXBM(&u8g, x, y, w, h, bitmap); - } - void drawXBMP(u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h, const u8g_pgm_uint8_t *bitmap) { - u8g_DrawXBMP(&u8g, x, y, w, h, bitmap); - } - - - /* font handling */ - void setFont(const u8g_fntpgm_uint8_t *font) { - u8g_SetFont(&u8g, font); - } - int8_t getFontAscent(void) { - return u8g_GetFontAscent(&u8g); - } - int8_t getFontDescent(void) { - return u8g_GetFontDescent(&u8g); - } - int8_t getFontLineSpacing(void) { - return u8g_GetFontLineSpacing(&u8g); - } - - u8g_uint_t drawStr(u8g_uint_t x, u8g_uint_t y, const char *s) { - return u8g_DrawStr(&u8g, x, y, s); - } - u8g_uint_t drawStr90(u8g_uint_t x, u8g_uint_t y, const char *s) { - return u8g_DrawStr90(&u8g, x, y, s); - } - u8g_uint_t drawStr180(u8g_uint_t x, u8g_uint_t y, const char *s) { - return u8g_DrawStr180(&u8g, x, y, s); - } - u8g_uint_t drawStr270(u8g_uint_t x, u8g_uint_t y, const char *s) { - return u8g_DrawStr270(&u8g, x, y, s); - } - u8g_uint_t drawStrP(u8g_uint_t x, u8g_uint_t y, const u8g_pgm_uint8_t *s) { - return u8g_DrawStrP(&u8g, x, y, s); - } - u8g_uint_t drawStr90P(u8g_uint_t x, u8g_uint_t y, const u8g_pgm_uint8_t *s) { - return u8g_DrawStr90P(&u8g, x, y, s); - } - u8g_uint_t drawStr180P(u8g_uint_t x, u8g_uint_t y, const u8g_pgm_uint8_t *s) { - return u8g_DrawStr180P(&u8g, x, y, s); - } - u8g_uint_t drawStr270P(u8g_uint_t x, u8g_uint_t y, const u8g_pgm_uint8_t *s) { - return u8g_DrawStr270P(&u8g, x, y, s); - } - - void setFontPosBaseline(void) { - u8g_SetFontPosBaseline(&u8g); - } - void setFontPosBottom(void) { - u8g_SetFontPosBottom(&u8g); - } - void setFontPosCenter(void) { - u8g_SetFontPosCenter(&u8g); - } - void setFontPosTop(void) { - u8g_SetFontPosTop(&u8g); - } - - void setFontRefHeightText(void) { - u8g_SetFontRefHeightText(&u8g); - } - void setFontRefHeightExtendedText(void) { - u8g_SetFontRefHeightExtendedText(&u8g); - } - void setFontRefHeightAll(void) { - u8g_SetFontRefHeightAll(&u8g); - } - void setFontLineSpacingFactor(uint8_t factor) { - u8g_SetFontLineSpacingFactor(&u8g, factor); - } - - - u8g_uint_t getStrPixelWidth(const char *s) { - return u8g_GetStrPixelWidth(&u8g, s); - } - u8g_uint_t getStrPixelWidthP(u8g_pgm_uint8_t *s) { - return u8g_GetStrPixelWidthP(&u8g, s); - } - u8g_uint_t getStrWidth(const char *s) { - return u8g_GetStrWidth(&u8g, s); - } - u8g_uint_t getStrWidthP(u8g_pgm_uint8_t *s) { - return u8g_GetStrWidthP(&u8g, s); - } - - void setHardwareBackup(u8g_state_cb backup_cb) { - u8g_SetHardwareBackup(&u8g, backup_cb); - } - -#if defined(ARDUINO) && ARDUINO >= 100 - // support for the F() macro - - u8g_uint_t drawStr(u8g_uint_t x, u8g_uint_t y, const __FlashStringHelper *s) { - return u8g_DrawStrP(&u8g, x, y, (u8g_pgm_uint8_t *)s); - } - u8g_uint_t drawStr90(u8g_uint_t x, u8g_uint_t y, const __FlashStringHelper *s) { - return u8g_DrawStr90P(&u8g, x, y, (u8g_pgm_uint8_t *)s); - } - u8g_uint_t drawStr180(u8g_uint_t x, u8g_uint_t y, const __FlashStringHelper *s) { - return u8g_DrawStr180P(&u8g, x, y, (u8g_pgm_uint8_t *)s); - } - u8g_uint_t drawStr270(u8g_uint_t x, u8g_uint_t y, const __FlashStringHelper *s) { - return u8g_DrawStr270P(&u8g, x, y, (u8g_pgm_uint8_t *)s); - } - - u8g_uint_t getStrPixelWidth(const __FlashStringHelper *s) { - return u8g_GetStrPixelWidthP(&u8g, (u8g_pgm_uint8_t *)s); - } - u8g_uint_t getStrWidth(const __FlashStringHelper *s) { - return u8g_GetStrWidthP(&u8g, (u8g_pgm_uint8_t *)s); - } -#endif - - /* cursor handling */ - void setCursorFont(const u8g_pgm_uint8_t *cursor_font) { - u8g_SetCursorFont(&u8g, cursor_font); - } - void setCursorStyle(uint8_t encoding) { - u8g_SetCursorStyle(&u8g, encoding); - } - void setCursorPos(u8g_uint_t cursor_x, u8g_uint_t cursor_y) { - u8g_SetCursorPos(&u8g, cursor_x, cursor_y); - } - void setCursorColor(uint8_t fg, uint8_t bg) { - u8g_SetCursorColor(&u8g, fg, bg); - } - void enableCursor(void) { - u8g_EnableCursor(&u8g); - } - void disableCursor(void) { - u8g_DisableCursor(&u8g); - } - void drawCursor(void) { - u8g_DrawCursor(&u8g); - } - - /* virtual screen */ - - void setVirtualScreenDimension(u8g_uint_t width, u8g_uint_t height) { - u8g_SetVirtualScreenDimension(&u8g, width, height); - } - uint8_t addToVirtualScreen(u8g_uint_t x, u8g_uint_t y, U8GLIB &child_u8g) { - return u8g_AddToVirtualScreen(&u8g, x, y, &child_u8g.u8g); - } - -}; - - -class U8GLIB_DOGS102 : public U8GLIB -{ -public: - U8GLIB_DOGS102(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_uc1701_dogs102_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_DOGS102(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_uc1701_dogs102_hw_spi, cs, a0, reset) - { } -}; - -class U8GLIB_DOGS102_2X : public U8GLIB -{ -public: - U8GLIB_DOGS102_2X(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_uc1701_dogs102_2x_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_DOGS102_2X(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_uc1701_dogs102_2x_hw_spi, cs, a0, reset) - { } -}; - -class U8GLIB_MINI12864 : public U8GLIB -{ -public: - U8GLIB_MINI12864(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_uc1701_mini12864_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_MINI12864(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_uc1701_mini12864_hw_spi, cs, a0, reset) - { } -}; - -class U8GLIB_MINI12864_2X : public U8GLIB -{ -public: - U8GLIB_MINI12864_2X(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_uc1701_mini12864_2x_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_MINI12864_2X(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_uc1701_mini12864_2x_hw_spi, cs, a0, reset) - { } -}; - -class U8GLIB_DOGM132 : public U8GLIB -{ -public: - U8GLIB_DOGM132(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7565_dogm132_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_DOGM132(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7565_dogm132_hw_spi, cs, a0, reset) - { } -}; - -class U8GLIB_NHD_C12832 : public U8GLIB -{ -public: - U8GLIB_NHD_C12832(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7565_nhd_c12832_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_NHD_C12832(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7565_nhd_c12832_hw_spi, cs, a0, reset) - { } - U8GLIB_NHD_C12832(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, - uint8_t en, uint8_t cs1, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7565_nhd_c12832_parallel, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, U8G_PIN_NONE, di, rw, reset) - { } -}; - -class U8GLIB_NHD_C12832_USART : public U8GLIB -{ -public: - U8GLIB_NHD_C12832_USART(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7565_nhd_c12832_hw_usart_spi, cs, a0, reset) - { } -}; - -class U8GLIB_DOGM128 : public U8GLIB -{ -public: - U8GLIB_DOGM128(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7565_dogm128_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_DOGM128(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7565_dogm128_hw_spi, cs, a0, reset) - { } - U8GLIB_DOGM128(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, - uint8_t en, uint8_t cs1, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7565_dogm128_parallel, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, U8G_PIN_NONE, di, rw, reset) - { } -}; - -class U8GLIB_DOGM128_2X : public U8GLIB -{ -public: - U8GLIB_DOGM128_2X(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7565_dogm128_2x_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_DOGM128_2X(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7565_dogm128_2x_hw_spi, cs, a0, reset) - { } - U8GLIB_DOGM128_2X(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, - uint8_t en, uint8_t cs1, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7565_dogm128_2x_parallel, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, U8G_PIN_NONE, di, rw, reset) - { } -}; - -class U8GLIB_LM6059 : public U8GLIB -{ -public: - U8GLIB_LM6059(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7565_lm6059_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_LM6059(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7565_lm6059_hw_spi, cs, a0, reset) - { } -}; - -class U8GLIB_LM6059_2X : public U8GLIB -{ -public: - U8GLIB_LM6059_2X(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7565_lm6059_2x_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_LM6059_2X(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7565_lm6059_2x_hw_spi, cs, a0, reset) - { } -}; - -class U8GLIB_LM6063 : public U8GLIB -{ -public: - U8GLIB_LM6063(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7565_lm6063_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_LM6063(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7565_lm6063_hw_spi, cs, a0, reset) - { } -}; - -class U8GLIB_LM6063_2X : public U8GLIB -{ -public: - U8GLIB_LM6063_2X(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7565_lm6063_2x_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_LM6063_2X(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7565_lm6063_2x_hw_spi, cs, a0, reset) - { } -}; - -class U8GLIB_64128N : public U8GLIB -{ -public: - U8GLIB_64128N(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7565_64128n_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_64128N(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7565_64128n_hw_spi, cs, a0, reset) - { } - U8GLIB_64128N(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, - uint8_t en, uint8_t cs1, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7565_64128n_parallel, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, U8G_PIN_NONE, di, rw, reset) - { } -}; - -class U8GLIB_64128N_2X : public U8GLIB -{ -public: - U8GLIB_64128N_2X(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7565_64128n_2x_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_64128N_2X(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7565_64128n_2x_hw_spi, cs, a0, reset) - { } - U8GLIB_64128N_2X(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, - uint8_t en, uint8_t cs1, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7565_64128n_2x_parallel, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, U8G_PIN_NONE, di, rw, reset) - { } -}; - -class U8GLIB_NHD_C12864 : public U8GLIB -{ -public: - U8GLIB_NHD_C12864(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7565_nhd_c12864_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_NHD_C12864(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7565_nhd_c12864_hw_spi, cs, a0, reset) - { } -}; - -class U8GLIB_NHD_C12864_2X : public U8GLIB -{ -public: - U8GLIB_NHD_C12864_2X(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7565_nhd_c12864_2x_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_NHD_C12864_2X(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7565_nhd_c12864_2x_hw_spi, cs, a0, reset) - { } -}; - -class U8GLIB_UC1601_C128032 : public U8GLIB -{ -public: - U8GLIB_UC1601_C128032(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_uc1601_c128032_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_UC1601_C128032(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_uc1601_c128032_hw_spi, cs, a0, reset) - { } -}; - -class U8GLIB_UC1601_C128032_2X : public U8GLIB -{ -public: - U8GLIB_UC1601_C128032_2X(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_uc1601_c128032_2x_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_UC1601_C128032_2X(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_uc1601_c128032_2x_hw_spi, cs, a0, reset) - { } -}; - -class U8GLIB_UC1608_240X64 : public U8GLIB -{ -public: - U8GLIB_UC1608_240X64(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_uc1608_240x64_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_UC1608_240X64(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_uc1608_240x64_hw_spi, cs, a0, reset) - { } -}; - -class U8GLIB_UC1608_240X64_2X : public U8GLIB -{ -public: - U8GLIB_UC1608_240X64_2X(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_uc1608_240x64_2x_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_UC1608_240X64_2X(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_uc1608_240x64_2x_hw_spi, cs, a0, reset) - { } -}; - - -class U8GLIB_ST7920_128X64 : public U8GLIB -{ -public: - U8GLIB_ST7920_128X64(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7920_128x64_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_ST7920_128X64(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7920_128x64_hw_spi, cs, a0, reset) - { } - U8GLIB_ST7920_128X64(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, - uint8_t en, uint8_t cs1, uint8_t cs2, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7920_128x64_8bit, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, cs2, di, rw, reset) - { } - // U8GLIB_ST7920_128X64(uint8_t cs) - // : U8GLIB(&u8g_dev_st7920_128x64_sw_spi, cs, U8G_PIN_NONE, U8G_PIN_NONE) - // { } -}; - -class U8GLIB_ST7920_128X64_1X : public U8GLIB -{ -public: - U8GLIB_ST7920_128X64_1X(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7920_128x64_sw_spi, sck, mosi, cs, U8G_PIN_NONE, reset) // a0 = U8G_PIN_NONE - { } - U8GLIB_ST7920_128X64_1X(uint8_t cs, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7920_128x64_hw_spi, cs, U8G_PIN_NONE, reset) // a0 = U8G_PIN_NONE - { } - U8GLIB_ST7920_128X64_1X(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, - uint8_t en, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7920_128x64_8bit, d0, d1, d2, d3, d4, d5, d6, d7, en, U8G_PIN_NONE, U8G_PIN_NONE, di, rw, reset) // cs1 = cs2 = U8G_PIN_NONE - { } -}; - -class U8GLIB_ST7920_128X64_CUSTOM_1X : public U8GLIB -{ -public: - U8GLIB_ST7920_128X64_CUSTOM_1X(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7920_128x64_custom, sck, mosi, cs, U8G_PIN_NONE, reset) // a0 = U8G_PIN_NONE - { } -}; - -class U8GLIB_ST7920_128X64_4X : public U8GLIB -{ -public: - U8GLIB_ST7920_128X64_4X(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7920_128x64_4x_sw_spi, sck, mosi, cs, U8G_PIN_NONE, reset) // a0 = U8G_PIN_NONE - { } - U8GLIB_ST7920_128X64_4X(uint8_t cs, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7920_128x64_4x_hw_spi, cs, U8G_PIN_NONE, reset) // a0 = U8G_PIN_NONE - { } - U8GLIB_ST7920_128X64_4X(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, - uint8_t en, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7920_128x64_4x_8bit, d0, d1, d2, d3, d4, d5, d6, d7, en, U8G_PIN_NONE, U8G_PIN_NONE, di, rw, reset) // cs1 = cs2 = U8G_PIN_NONE - { } -}; - -class U8GLIB_ST7920_128X64_CUSTOM_4X : public U8GLIB -{ -public: - U8GLIB_ST7920_128X64_CUSTOM_4X(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7920_128x64_4x_custom, sck, mosi, cs, U8G_PIN_NONE, reset) // a0 = U8G_PIN_NONE - { } -}; - - -class U8GLIB_ST7920_192X32 : public U8GLIB // OBSOLETE, use U8GLIB_ST7920_192X32_1X instead -{ -public: - U8GLIB_ST7920_192X32(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7920_192x32_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_ST7920_192X32(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7920_192x32_hw_spi, cs, a0, reset) - { } - U8GLIB_ST7920_192X32(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, - uint8_t en, uint8_t cs1, uint8_t cs2, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7920_192x32_8bit, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, cs2, di, rw, reset) - { } -}; - -class U8GLIB_ST7920_192X32_1X : public U8GLIB -{ -public: - U8GLIB_ST7920_192X32_1X(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7920_192x32_sw_spi, sck, mosi, cs, U8G_PIN_NONE, reset) // a0 = U8G_PIN_NONE - { } - U8GLIB_ST7920_192X32_1X(uint8_t cs, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7920_192x32_hw_spi, cs, U8G_PIN_NONE, reset) // a0 = U8G_PIN_NONE - { } - U8GLIB_ST7920_192X32_1X(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, - uint8_t en, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7920_192x32_8bit, d0, d1, d2, d3, d4, d5, d6, d7, en, U8G_PIN_NONE, U8G_PIN_NONE, di, rw, reset) // cs1 = cs2 = U8G_PIN_NONE - { } -}; - -class U8GLIB_ST7920_192X32_4X : public U8GLIB -{ -public: - U8GLIB_ST7920_192X32_4X(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7920_192x32_4x_sw_spi, sck, mosi, cs, U8G_PIN_NONE, reset) // a0 = U8G_PIN_NONE - { } - U8GLIB_ST7920_192X32_4X(uint8_t cs, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7920_192x32_4x_hw_spi, cs, U8G_PIN_NONE, reset) // a0 = U8G_PIN_NONE - { } - U8GLIB_ST7920_192X32_4X(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, - uint8_t en, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7920_192x32_4x_8bit, d0, d1, d2, d3, d4, d5, d6, d7, en, U8G_PIN_NONE, U8G_PIN_NONE, di, rw, reset) // cs1 = cs2 = U8G_PIN_NONE - { } -}; - - -class U8GLIB_ST7920_202X32 : public U8GLIB -{ -public: - U8GLIB_ST7920_202X32(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7920_202x32_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_ST7920_202X32(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7920_202x32_hw_spi, cs, a0, reset) - { } - U8GLIB_ST7920_202X32(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, - uint8_t en, uint8_t cs1, uint8_t cs2, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7920_202x32_8bit, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, cs2, di, rw, reset) - { } -}; - -class U8GLIB_ST7920_202X32_1X : public U8GLIB -{ -public: - U8GLIB_ST7920_202X32_1X(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7920_202x32_sw_spi, sck, mosi, cs, U8G_PIN_NONE, reset) // a0 = U8G_PIN_NONE - { } - U8GLIB_ST7920_202X32_1X(uint8_t cs, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7920_202x32_hw_spi, cs, U8G_PIN_NONE, reset) // a0 = U8G_PIN_NONE - { } - U8GLIB_ST7920_202X32_1X(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, - uint8_t en, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7920_202x32_8bit, d0, d1, d2, d3, d4, d5, d6, d7, en, U8G_PIN_NONE, U8G_PIN_NONE, di, rw, reset) // cs1 = cs2 = U8G_PIN_NONE - { } -}; - -class U8GLIB_ST7920_202X32_4X : public U8GLIB -{ -public: - U8GLIB_ST7920_202X32_4X(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7920_202x32_4x_sw_spi, sck, mosi, cs, U8G_PIN_NONE, reset) // a0 = U8G_PIN_NONE - { } - U8GLIB_ST7920_202X32_4X(uint8_t cs, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7920_202x32_4x_hw_spi, cs, U8G_PIN_NONE, reset) // a0 = U8G_PIN_NONE - { } - U8GLIB_ST7920_202X32_4X(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, - uint8_t en, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7920_202x32_4x_8bit, d0, d1, d2, d3, d4, d5, d6, d7, en, U8G_PIN_NONE, U8G_PIN_NONE, di, rw, reset) // cs1 = cs2 = U8G_PIN_NONE - { } -}; - - -class U8GLIB_LC7981_160X80 : public U8GLIB -{ -public: - U8GLIB_LC7981_160X80(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, - uint8_t en, uint8_t cs1, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_lc7981_160x80_8bit, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, U8G_PIN_NONE, di, rw, reset) - { } -}; - -class U8GLIB_LC7981_240X64 : public U8GLIB -{ -public: - U8GLIB_LC7981_240X64(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, - uint8_t en, uint8_t cs1, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_lc7981_240x64_8bit, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, U8G_PIN_NONE, di, rw, reset) - { } -}; - -class U8GLIB_LC7981_240X128 : public U8GLIB -{ -public: - U8GLIB_LC7981_240X128(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, - uint8_t en, uint8_t cs1, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_lc7981_240x128_8bit, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, U8G_PIN_NONE, di, rw, reset) - { } -}; - -// 16 bit mode required: Remove comment from "#define U8G_16BIT 1" in utility/u8g.h -class U8GLIB_LC7981_320X64 : public U8GLIB -{ -public: - U8GLIB_LC7981_320X64(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, - uint8_t en, uint8_t cs1, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_lc7981_320x64_8bit, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, U8G_PIN_NONE, di, rw, reset) - { } -}; - - - -class U8GLIB_DOGXL160_BW : public U8GLIB -{ -public: - U8GLIB_DOGXL160_BW(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_uc1610_dogxl160_bw_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_DOGXL160_BW(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_uc1610_dogxl160_bw_hw_spi, cs, a0, reset) - { } -}; - -class U8GLIB_DOGXL160_GR : public U8GLIB -{ -public: - U8GLIB_DOGXL160_GR(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_uc1610_dogxl160_gr_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_DOGXL160_GR(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_uc1610_dogxl160_gr_hw_spi, cs, a0, reset) - { } -}; - -class U8GLIB_DOGXL160_2X_BW : public U8GLIB -{ -public: - U8GLIB_DOGXL160_2X_BW(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_uc1610_dogxl160_2x_bw_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_DOGXL160_2X_BW(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_uc1610_dogxl160_2x_bw_hw_spi, cs, a0, reset) - { } -}; - -class U8GLIB_DOGXL160_2X_GR : public U8GLIB -{ -public: - U8GLIB_DOGXL160_2X_GR(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_uc1610_dogxl160_2x_gr_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_DOGXL160_2X_GR(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_uc1610_dogxl160_2x_gr_hw_spi, cs, a0, reset) - { } -}; - - -class U8GLIB_NHD27OLED_BW : public U8GLIB -{ -public: - U8GLIB_NHD27OLED_BW(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1325_nhd27oled_bw_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_NHD27OLED_BW(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1325_nhd27oled_bw_hw_spi, cs, a0, reset) - { } - U8GLIB_NHD27OLED_BW(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, - uint8_t cs, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1325_nhd27oled_bw_parallel, d0, d1, d2, d3, d4, d5, d6, d7, U8G_PIN_NONE, cs, U8G_PIN_NONE, di, rw, reset) - { } -}; - -class U8GLIB_NHD27OLED_2X_BW : public U8GLIB -{ -public: - U8GLIB_NHD27OLED_2X_BW(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1325_nhd27oled_2x_bw_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_NHD27OLED_2X_BW(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1325_nhd27oled_2x_bw_hw_spi, cs, a0, reset) - { } - U8GLIB_NHD27OLED_2X_BW(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, - uint8_t cs, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1325_nhd27oled_2x_bw_parallel, d0, d1, d2, d3, d4, d5, d6, d7, U8G_PIN_NONE, cs, U8G_PIN_NONE, di, rw, reset) - { } -}; - -class U8GLIB_NHD31OLED_BW : public U8GLIB -{ -public: - U8GLIB_NHD31OLED_BW(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1322_nhd31oled_bw_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_NHD31OLED_BW(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1322_nhd31oled_bw_hw_spi, cs, a0, reset) - { } - U8GLIB_NHD31OLED_BW(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, - uint8_t cs, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1322_nhd31oled_bw_parallel, d0, d1, d2, d3, d4, d5, d6, d7, U8G_PIN_NONE, cs, U8G_PIN_NONE, di, rw, reset) - { } -}; - -class U8GLIB_NHD31OLED_2X_BW : public U8GLIB -{ -public: - U8GLIB_NHD31OLED_2X_BW(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1322_nhd31oled_2x_bw_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_NHD31OLED_2X_BW(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1322_nhd31oled_2x_bw_hw_spi, cs, a0, reset) - { } -}; - -class U8GLIB_NHD31OLED_GR : public U8GLIB -{ -public: - U8GLIB_NHD31OLED_GR(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1322_nhd31oled_gr_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_NHD31OLED_GR(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1322_nhd31oled_gr_hw_spi, cs, a0, reset) - { } - U8GLIB_NHD31OLED_GR(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, - uint8_t cs, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1322_nhd31oled_gr_parallel, d0, d1, d2, d3, d4, d5, d6, d7, U8G_PIN_NONE, cs, U8G_PIN_NONE, di, rw, reset) - { } -}; - -class U8GLIB_NHD31OLED_2X_GR : public U8GLIB -{ -public: - U8GLIB_NHD31OLED_2X_GR(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1322_nhd31oled_2x_gr_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_NHD31OLED_2X_GR(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1322_nhd31oled_2x_gr_hw_spi, cs, a0, reset) - { } -}; - - -class U8GLIB_SSD1306_128X64 : public U8GLIB -{ -public: - U8GLIB_SSD1306_128X64(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1306_128x64_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_SSD1306_128X64(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1306_128x64_hw_spi, cs, a0, reset) - { } - U8GLIB_SSD1306_128X64(uint8_t options = U8G_I2C_OPT_NONE) - : U8GLIB(&u8g_dev_ssd1306_128x64_i2c, options) - { } -}; - -class U8GLIB_SSD1306_MICRODUINO_128X64 : public U8GLIB -{ -public: - U8GLIB_SSD1306_MICRODUINO_128X64(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1306_microduino_128x64_sw_spi, (u8g_com_fnptr)u8g_com_lpc824_ssd_i2c_fn) - { } - U8GLIB_SSD1306_MICRODUINO_128X64(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1306_microduino_128x64_hw_spi, (u8g_com_fnptr)u8g_com_lpc824_ssd_i2c_fn) - { } - U8GLIB_SSD1306_MICRODUINO_128X64(uint8_t options = U8G_I2C_OPT_NONE) - : U8GLIB(&u8g_dev_ssd1306_microduino_128x64_i2c, u8g_com_lpc824_ssd_i2c_fn) - { } - #if 0 - U8GLIB_SSD1306_MICRODUINO_128X64(void) - : U8GLIB() - { } - #endif -}; - -class U8GLIB_SSD1306_ADAFRUIT_128X64 : public U8GLIB -{ -public: - U8GLIB_SSD1306_ADAFRUIT_128X64(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1306_adafruit_128x64_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_SSD1306_ADAFRUIT_128X64(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1306_adafruit_128x64_hw_spi, cs, a0, reset) - { } - U8GLIB_SSD1306_ADAFRUIT_128X64(uint8_t options = U8G_I2C_OPT_NONE) - : U8GLIB(&u8g_dev_ssd1306_adafruit_128x64_i2c, options) - { } -}; - - -class U8GLIB_SSD1306_128X64_2X : public U8GLIB -{ -public: - U8GLIB_SSD1306_128X64_2X(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1306_128x64_2x_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_SSD1306_128X64_2X(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1306_128x64_2x_hw_spi, cs, a0, reset) - { } - U8GLIB_SSD1306_128X64_2X(uint8_t options = U8G_I2C_OPT_NONE) - : U8GLIB(&u8g_dev_ssd1306_128x64_2x_i2c, options) - { } -}; - -class U8GLIB_SH1106_128X64 : public U8GLIB -{ -public: - U8GLIB_SH1106_128X64(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_sh1106_128x64_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_SH1106_128X64(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_sh1106_128x64_hw_spi, cs, a0, reset) - { } - U8GLIB_SH1106_128X64(uint8_t options = U8G_I2C_OPT_NONE) - : U8GLIB(&u8g_dev_sh1106_128x64_i2c, options) - { } -}; - -class U8GLIB_SH1106_128X64_2X : public U8GLIB -{ -public: - U8GLIB_SH1106_128X64_2X(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_sh1106_128x64_2x_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_SH1106_128X64_2X(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_sh1106_128x64_2x_hw_spi, cs, a0, reset) - { } - U8GLIB_SH1106_128X64_2X(uint8_t options = U8G_I2C_OPT_NONE) - : U8GLIB(&u8g_dev_sh1106_128x64_2x_i2c, options) - { } -}; - -class U8GLIB_SSD1309_128X64 : public U8GLIB -{ -public: - U8GLIB_SSD1309_128X64(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1309_128x64_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_SSD1309_128X64(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1309_128x64_hw_spi, cs, a0, reset) - { } - U8GLIB_SSD1309_128X64(uint8_t options = U8G_I2C_OPT_NONE) - : U8GLIB(&u8g_dev_ssd1309_128x64_i2c, options) - { } -}; - -class U8GLIB_SSD1306_128X32 : public U8GLIB -{ -public: - U8GLIB_SSD1306_128X32(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1306_128x32_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_SSD1306_128X32(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1306_128x32_hw_spi, cs, a0, reset) - { } - U8GLIB_SSD1306_128X32(uint8_t options = U8G_I2C_OPT_NONE) - : U8GLIB(&u8g_dev_ssd1306_128x32_i2c, options) - { } -}; - -class U8GLIB_SSD1306_128X32_2X : public U8GLIB -{ -public: - U8GLIB_SSD1306_128X32_2X(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1306_128x32_2x_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_SSD1306_128X32_2X(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1306_128x32_2x_hw_spi, cs, a0, reset) - { } - U8GLIB_SSD1306_128X32_2X(uint8_t options = U8G_I2C_OPT_NONE) - : U8GLIB(&u8g_dev_ssd1306_128x32_2x_i2c, options) - { } -}; - - -class U8GLIB_NHD27OLED_GR : public U8GLIB -{ -public: - U8GLIB_NHD27OLED_GR(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1325_nhd27oled_gr_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_NHD27OLED_GR(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1325_nhd27oled_gr_hw_spi, cs, a0, reset) - { } -}; - -class U8GLIB_NHD27OLED_2X_GR : public U8GLIB -{ -public: - U8GLIB_NHD27OLED_2X_GR(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1325_nhd27oled_2x_gr_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_NHD27OLED_2X_GR(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1325_nhd27oled_2x_gr_hw_spi, cs, a0, reset) - { } -}; - -class U8GLIB_SSD1327_96X96_GR : public U8GLIB -{ -public: - U8GLIB_SSD1327_96X96_GR(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1327_96x96_gr_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_SSD1327_96X96_GR(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1327_96x96_gr_hw_spi, cs, a0, reset) - { } - U8GLIB_SSD1327_96X96_GR(uint8_t options = U8G_I2C_OPT_NONE) - : U8GLIB(&u8g_dev_ssd1327_96x96_gr_i2c, options) - { } -}; - -class U8GLIB_SSD1327_96X96_2X_GR : public U8GLIB -{ -public: - U8GLIB_SSD1327_96X96_2X_GR(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1327_96x96_2x_gr_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_SSD1327_96X96_2X_GR(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1327_96x96_2x_gr_hw_spi, cs, a0, reset) - { } - U8GLIB_SSD1327_96X96_2X_GR(uint8_t options = U8G_I2C_OPT_NONE) - : U8GLIB(&u8g_dev_ssd1327_96x96_2x_gr_i2c, options) - { } -}; - - -class U8GLIB_LD7032_60x32 : public U8GLIB -{ -public: - U8GLIB_LD7032_60x32(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ld7032_60x32_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_LD7032_60x32(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ld7032_60x32_hw_spi, cs, a0, reset) - { } - U8GLIB_LD7032_60x32(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, - uint8_t en, uint8_t cs1, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ld7032_60x32_parallel, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, U8G_PIN_NONE, di, rw, reset) - { } -}; - - - -class U8GLIB_HT1632_24X16 : public U8GLIB -{ -public: - U8GLIB_HT1632_24X16(uint8_t wr, uint8_t data, uint8_t cs) - : U8GLIB(&u8g_dev_ht1632_24x16, wr, data, cs, U8G_PIN_NONE, U8G_PIN_NONE) - { } -}; - - - -class U8GLIB_PCF8812 : public U8GLIB -{ -public: - U8GLIB_PCF8812(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_pcf8812_96x65_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_PCF8812(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_pcf8812_96x65_hw_spi, cs, a0, reset) - { } -}; - -class U8GLIB_PCD8544 : public U8GLIB -{ -public: - U8GLIB_PCD8544(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_pcd8544_84x48_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_PCD8544(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_pcd8544_84x48_hw_spi, cs, a0, reset) - { } -}; - -class U8GLIB_TLS8204_84X48 : public U8GLIB -{ -public: - U8GLIB_TLS8204_84X48(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_tls8204_84x48_sw_spi, sck, mosi, cs, a0, reset) - { } -}; - -class U8GLIB_KS0108_128 : public U8GLIB -{ -public: - U8GLIB_KS0108_128(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, - uint8_t en, uint8_t cs1, uint8_t cs2, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ks0108_128x64_fast, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, cs2, di, rw, reset) - { } -}; - -class U8GLIB_SBN1661_122X32 : public U8GLIB -{ -public: - U8GLIB_SBN1661_122X32(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, - uint8_t cs1, uint8_t cs2, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_sbn1661_122x32, d0, d1, d2, d3, d4, d5, d6, d7, U8G_PIN_NONE, cs1, cs2, di, rw, reset) - { } -}; - -class U8GLIB_T6963_240X128 : public U8GLIB -{ -public: - U8GLIB_T6963_240X128(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, - uint8_t cs, uint8_t a0, uint8_t wr, uint8_t rd, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_t6963_240x128_8bit, d0, d1, d2, d3, d4, d5, d6, d7, cs, a0, wr, rd, reset) - { } -}; - -class U8GLIB_T6963_128X128 : public U8GLIB -{ -public: - U8GLIB_T6963_128X128(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, - uint8_t cs, uint8_t a0, uint8_t wr, uint8_t rd, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_t6963_128x128_8bit, d0, d1, d2, d3, d4, d5, d6, d7, cs, a0, wr, rd, reset) - { } -}; - -class U8GLIB_T6963_240X64 : public U8GLIB -{ -public: - U8GLIB_T6963_240X64(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, - uint8_t cs, uint8_t a0, uint8_t wr, uint8_t rd, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_t6963_240x64_8bit, d0, d1, d2, d3, d4, d5, d6, d7, cs, a0, wr, rd, reset) - { } -}; - -class U8GLIB_T6963_128X64 : public U8GLIB -{ -public: - U8GLIB_T6963_128X64(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, - uint8_t cs, uint8_t a0, uint8_t wr, uint8_t rd, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_t6963_128x64_8bit, d0, d1, d2, d3, d4, d5, d6, d7, cs, a0, wr, rd, reset) - { } -}; - - -class U8GLIB_ST7687_C144MVGD: public U8GLIB -{ -public: - U8GLIB_ST7687_C144MVGD(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_st7687_c144mvgd_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_ST7687_C144MVGD(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, - uint8_t en, uint8_t cs, uint8_t a0, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ks0108_128x64_fast, d0, d1, d2, d3, d4, d5, d6, d7, en, cs, U8G_PIN_NONE, a0, rw, reset) - { } -}; - -class U8GLIB_ILI9325D_320x240 : public U8GLIB -{ -public: - /* - U8GLIB_ILI9325D_320x240(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, - uint8_t en, uint8_t cs1, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ili9325d_320x240_8bit, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, U8G_PIN_NONE, di, rw, reset) - { } - */ - U8GLIB_ILI9325D_320x240( uint8_t en, uint8_t cs1, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE) { - init8BitFixedPort(&u8g_dev_ili9325d_320x240_8bit, en, cs1, di, rw, reset); - } -}; - - - -class U8GLIB_SSD1351_128X128_332 : public U8GLIB -{ -public: - U8GLIB_SSD1351_128X128_332(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1351_128x128_332_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_SSD1351_128X128_332(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1351_128x128_332_hw_spi, cs, a0, reset) - { } -}; - -class U8GLIB_SSD1351_128X128_4X_332 : public U8GLIB -{ -public: - U8GLIB_SSD1351_128X128_4X_332(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1351_128x128_4x_332_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_SSD1351_128X128_4X_332(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1351_128x128_4x_332_hw_spi, cs, a0, reset) - { } -}; - -class U8GLIB_SSD1351_128X128GH_332 : public U8GLIB -{ -public: - U8GLIB_SSD1351_128X128GH_332(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1351_128x128gh_332_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_SSD1351_128X128GH_332(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1351_128x128gh_332_hw_spi, cs, a0, reset) - { } -}; - -class U8GLIB_SSD1351_128X128GH_4X_332 : public U8GLIB -{ -public: - U8GLIB_SSD1351_128X128GH_4X_332(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1351_128x128gh_4x_332_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_SSD1351_128X128GH_4X_332(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1351_128x128gh_4x_332_hw_spi, cs, a0, reset) - { } -}; - -class U8GLIB_SSD1351_128X128_IDX : public U8GLIB -{ -public: - U8GLIB_SSD1351_128X128_IDX(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1351_128x128_idx_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_SSD1351_128X128_IDX(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1351_128x128_idx_hw_spi, cs, a0, reset) - { } -}; - -class U8GLIB_SSD1351_128X128_HICOLOR : public U8GLIB -{ -public: - U8GLIB_SSD1351_128X128_HICOLOR(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1351_128x128_hicolor_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_SSD1351_128X128_HICOLOR(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1351_128x128_hicolor_hw_spi, cs, a0, reset) - { } -}; - -class U8GLIB_SSD1351_128X128_4X_HICOLOR : public U8GLIB -{ -public: - U8GLIB_SSD1351_128X128_4X_HICOLOR(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1351_128x128_4x_hicolor_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_SSD1351_128X128_4X_HICOLOR(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1351_128x128_4x_hicolor_hw_spi, cs, a0, reset) - { } -}; - -class U8GLIB_SSD1351_128X128GH_HICOLOR : public U8GLIB -{ -public: - U8GLIB_SSD1351_128X128GH_HICOLOR(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1351_128x128gh_hicolor_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_SSD1351_128X128GH_HICOLOR(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1351_128x128gh_hicolor_hw_spi, cs, a0, reset) - { } -}; - -class U8GLIB_SSD1351_128X128GH_4X_HICOLOR : public U8GLIB -{ -public: - U8GLIB_SSD1351_128X128GH_4X_HICOLOR(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1351_128x128gh_4x_hicolor_sw_spi, sck, mosi, cs, a0, reset) - { } - U8GLIB_SSD1351_128X128GH_4X_HICOLOR(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) - : U8GLIB(&u8g_dev_ssd1351_128x128gh_4x_hicolor_hw_spi, cs, a0, reset) - { } -}; - - -class U8GLIB_FLIPDISC_2X7 : public U8GLIB -{ -public: - U8GLIB_FLIPDISC_2X7(void) : U8GLIB(&u8g_dev_flipdisc_2x7) - { } -}; - -class U8GLIB_VS : public U8GLIB -{ -public: - U8GLIB_VS(void) : U8GLIB(&u8g_dev_vs) - { } -}; - - -#endif /* _CPP_U8GLIB */ - -#endif \ No newline at end of file
diff -r e5018e5ba340 -r 8a3cf73d7ed3 WiFiBlynk.h --- a/WiFiBlynk.h Thu Jun 16 08:12:33 2016 +0000 +++ b/WiFiBlynk.h Tue Jan 26 08:23:29 2021 +0000 @@ -1,30 +1,25 @@ -#include "Config.h" #include "ESP8266_HardSer.h" #include "BlynkSimpleShieldEsp8266_HardSer.h" #include "SimpleTimer.h" -Serial EspSerial(D3, D2);//tx, rx +Serial EspSerial(PA_9, PA_10);//tx, rx ESP8266 wifi(EspSerial); -void senTempHumi() +void notify() { - Blynk.virtualWrite(V2, sensor_tem); - Blynk.virtualWrite(V3, sensor_hum); + Blynk.notify("Alert : DOOR OPENED"); } -BLYNK_READ(V4) -{ - Blynk.virtualWrite(V4, sensor_light); -} -BLYNK_READ(V5) -{ - Blynk.virtualWrite(V5, Sensor_etoh); - //BLYNK_PRINT.println(Sensor_etoh); -} - -BLYNK_READ(V6) -{ - Blynk.virtualWrite(V6, sensorPM25); - //BLYNK_PRINT.println(sensorPM25); +BLYNK_WRITE(V1) { + int a = param.asInt(); + if (a == 1) { + Blynk.notify("BUKAK.."); + + } + else { + Blynk.notify("TUTUP..."); + + + } } \ No newline at end of file
diff -r e5018e5ba340 -r 8a3cf73d7ed3 main.cpp --- a/main.cpp Thu Jun 16 08:12:33 2016 +0000 +++ b/main.cpp Tue Jan 26 08:23:29 2021 +0000 @@ -1,95 +1,45 @@ #include "mbed.h" - -#include "Config.h" -#include "MicroduinoPinNames.h" -DigitalOut myled(P0_20); -I2C g_i2c(P0_11, P0_10);//SDA, SCL #include "SimpleTimer.h" -#include "userDef.h" -#include "sensor.h" -#ifdef OPEN_OLED -#include "oled.h" -#endif +extern Serial pc; #include "WiFiBlynk.h" -Serial pc(P0_4, P0_0); // tx, rx +Serial pc(SERIAL_TX, SERIAL_RX); // tx, rx Timer g_Timer; -Ticker g_Ticker; - -void led_flash() -{ - static int count = 0; - count++; - //pc.printf("count : %d, ms : %d\r\n", count, g_Timer.read_ms()); - myled = 1; - wait_ms(70); - myled = 0; -} +DigitalOut myled(PB_3); -static void led_flash_fast() -{ - myled = !myled; -} +char SSID[] = "OPPO A7"; +char PASS[] = "12345678"; -#ifdef OPEN_OLED -Adafruit_SSD1306_I2c adaf(g_i2c, P0_13, 0x78, 64, 128); -void update_oled() -{ - myled = 1; - wait_ms(70); - myled = 0; - oled(adaf, sensor_tem, sensor_hum, sensor_light, sensorPM25, Sensor_etoh); -} -#endif +char auth[] = "jx8SAPsgpzJ3pJPzI-q6ZhQIo1F4J7ki"; + int main() { - g_Ticker.attach_us(led_flash_fast, 30000); - pc.baud(115200); + pc.baud(9600); pc.printf("Enter main()\r\n"); //myled = 1; g_Timer.start(); SimpleTimer gSimpleTimer(g_Timer); - /* - * Set ESP8266 baud rate - * 在LPC824上,波特率设为115200时,ESP8266是无法工作 - */ EspSerial.baud(9600); - + delay(10); + Blynk.begin(auth, wifi, SSID, PASS); - wait(5.0); - g_Ticker.detach(); - + // Setup a function to be called every second - gSimpleTimer.setInterval(2000L, senTempHumi); - gSimpleTimer.setInterval(1000, updateLight); - gSimpleTimer.setInterval(5000, updateCH4); - gSimpleTimer.setInterval(4000, updateTempHumi); + //gSimpleTimer.setInterval(3000, PM25); - gSimpleTimer.setInterval(4000, led_flash); -#ifdef OPEN_OLED - gSimpleTimer.setInterval(1000, update_oled); -#endif - //PM25_init(); - wait_ms(2000); -#ifdef OPEN_OLED - oled_init(adaf); -#endif + + int pretime = g_Timer.read_ms(); + + while(1) { //pc.printf("Enter while(1)\r\n"); //myled = !myled; Blynk.run(); // All the Blynk Magic happens here... gSimpleTimer.run(); -#if 0 - int curtime = g_Timer.read_ms(); - if (curtime - pretime > 4000) { - //updateTempHumi(); - led_flash(); - pretime = curtime; - } -#endif + } }
diff -r e5018e5ba340 -r 8a3cf73d7ed3 oled.cpp --- a/oled.cpp Thu Jun 16 08:12:33 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,152 +0,0 @@ -#include "mbed.h" -#include "oled.h" - -//I2C g_i2c(P0_11, P0_10);//SDA, SCL -extern I2C g_i2c; -//Adafruit_SSD1306_I2c adaf(g_i2c, P0_13, 0x78, 64, 128); - -//U8GLIB_SSD1306_MICRODUINO_128X64 u8g(U8G_I2C_OPT_NONE); //设置OLED型号 -//-------字体设置,大、中、小 -#if 0 -#define setFont_L u8g.setFont(u8g_font_7x13) -#define setFont_M u8g.setFont(u8g_font_fixed_v0r) -#define setFont_S u8g.setFont(u8g_font_chikitar) -#elif 0 -#define setFont_L adaf.setTextSize(14) -#define setFont_M adaf.setTextSize(10) -#define setFont_S adaf.setTextSize(6) -#else -#define setFont_L -#define setFont_M -#define setFont_S -#endif - -//温度计图案 -unsigned char bmp_tem[] = { - 0xE0,0x81,0x30,0x83,0x10,0x82,0x10,0x82,0x10,0xFA,0x10,0x82, - 0x10,0x82,0x10,0xFA,0x10,0x82,0xD0,0x82,0xD0,0xFA,0xD0,0x82, - 0xD0,0x82,0xD0,0xFA,0xD0,0x82,0xD0,0x82,0xD0,0xFA,0xD0,0x82, - 0xD0,0x82,0xD8,0x86,0xC4,0x88,0xF2,0x93,0xFB,0xB7,0xF9,0xA7, - 0xFD,0xAF,0xFD,0xAF,0xF9,0xA7,0xFA,0x97,0xF2,0x93,0xC4,0x88, - 0x18,0x86,0xF0,0x83 -}; - -//水滴图案 -unsigned char bmp_hum[] = { - 0x00,0x00,0x01,0x00,0x00,0x01,0x00,0x80,0x03,0x08,0x80,0x03,0x18,0x80,0x07,0x1C, - 0xC0,0x07,0x3C,0xC0,0x07,0x3E,0xE0,0x0F,0x3E,0xE0,0x0F,0x7A,0xF0,0x1F,0x7B,0xF8, - 0x1F,0x72,0xF8,0x1F,0x3E,0xF8,0x3F,0x1C,0xFC,0x3F,0x00,0xFC,0x7F,0x00,0xFE,0x7F, - 0x00,0xFE,0x7F,0x00,0xFE,0x7F,0x00,0xFF,0xFF,0x00,0xFF,0xFF,0x00,0xFF,0xFF,0x00, - 0xF3,0xFF,0x00,0xF2,0x7F,0x00,0xE6,0x7F,0x00,0xC6,0x7F,0x00,0x0E,0x3F,0x00,0x3C, - 0x1E,0x00,0xF8,0x1F,0x00,0xE0,0x07,0x00,0x80,0x01 -}; - -void oled_init(Adafruit_SSD1306_I2c &adaf) -{ - adaf.setTextColor(1, 0); - //adaf.setTextColor(0, 1); - adaf.setTextSize(1); -} - -#if 0 -void oled(float temp, float humi, float light, float pm25, float etoh) -//void oled(U8GLIB &u8g, float temp, float humi, float light, float pm25, float etoh) -{ - //gpio_write(&g_LED, 1); - u8g.firstPage(); - do { - u8g.setDefaultForegroundColor(); - - u8g.drawXBMP( 4, 1, 15, 32, bmp_tem); - u8g.drawXBMP( 70, 2, 24, 30, bmp_hum); - - setFont_M; //设置字体为大 - u8g.setPrintPos(20, 16); //设置文字开始坐标 - u8g.print("`C "); - setFont_L; //设置字体为大 - u8g.setPrintPos(20, 32); //设置文字开始坐标 - u8g.print(temp , 1); //温度 - - u8g.setPrintPos(100, 16); //设置文字开始坐标 - u8g.print("%"); - setFont_L; //设置字体为大 - u8g.setPrintPos(100, 32); //设置文字开始坐标 - u8g.print(humi , 0); //湿度 - - setFont_L; //设置字体 - u8g.setPrintPos(4, 49); //设置文字开始坐标 - u8g.print(light , 0); //光照强度 - setFont_M; //设置字体 - u8g.print(" Lux"); - - setFont_L; //设置字体 - u8g.setPrintPos(4, 63); //设置文字开始坐标 - u8g.print(pm25 , 0); //光照强度 - setFont_M; //设置字体 - u8g.print(" ug/m3"); - - - setFont_L; //设置字体 - u8g.setPrintPos(80, 49); //设置文字开始坐标 - u8g.print(etoh , 0); //光照强度 - setFont_M; //设置字体 - u8g.print(" ppm"); - - // setFont_M; //设置字体为大 - // u8g.setPrintPos(80, 63); //设置文字开始坐标 - // u8g.print(" LED:"); - - } while( u8g.nextPage() ); - //gpio_write(&g_LED, 0); -} -#elif 1 -void oled(Adafruit_SSD1306_I2c &adaf, float temp, float humi, float light, float pm25, float etoh) -{ - adaf.clearDisplay(); - - //adaf.drawBitmap(4, 1, bmp_tem, 15, 32, WHITE); - //adaf.drawBitmap(70, 2, bmp_hum, 24, 30, WHITE); - - //temp = 32.2; - adaf.setTextCursor(0, 5); //设置文字开始坐标 - adaf.printf("Temp:%.1f'C", temp); - - //light = 210.0; - adaf.setTextCursor(74, 5); //设置文字开始坐标 - adaf.printf("%.1fLux", light); //光照强度 - - //humi = 90.6; - adaf.setTextCursor(0, 30); //设置文字开始坐标 - adaf.printf("Humi:%.1f%%", humi); - - //pm25 = 9.7; - adaf.printf(" %.1fug/m3", pm25); //PM2.5 - - //etoh = 2.6; - adaf.setTextCursor(1, 52); //设置文字开始坐标 - adaf.printf("%.1f ppm", etoh); //甲醛 - - adaf.drawFastVLine(69, 0, 63, WHITE); - - adaf.display(); -} -#else -void oled(float temp, float humi, float light, float pm25, float etoh) -{ - static int16_t x = 0; - static int16_t y = 0; - adaf.clearDisplay(); - //adaf.setTextColor(0, 1); - adaf.setTextCursor(x, y); - adaf.printf("Lux\r\n"); - adaf.display(); - x += 2; - if (x > 128) { - x = 0; - y += 2; - if (y > 64) { - y = 0; - } - } -} -#endif \ No newline at end of file
diff -r e5018e5ba340 -r 8a3cf73d7ed3 oled.h --- a/oled.h Thu Jun 16 08:12:33 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -#ifndef _OLED_H -#define _OLED_H -#include "Adafruit_SSD1306.h" -extern void oled_init(void); -extern void oled_init(Adafruit_SSD1306_I2c &adaf); -extern void oled(float temp, float humi, float light, float pm25, float etoh); -extern void oled(Adafruit_SSD1306_I2c &adaf, float temp, float humi, float light, float pm25, float etoh); -#endif \ No newline at end of file
diff -r e5018e5ba340 -r 8a3cf73d7ed3 sensor.h --- a/sensor.h Thu Jun 16 08:12:33 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,111 +0,0 @@ -#include "MicroduinoPinNames.h" -#include "Config.h" -#include "AM2321.h" - -extern Serial pc; -#define INTERVAL_pm25 200 - -//SoftwareSerial pmSerial(4,5); //PM2.5传感器通讯软串口 -#ifdef OPEN_PM25 -Serial pmSerial(D5, D4); //tx,rx -#endif -AnalogIn gLight(A0); -AnalogIn gCH4(A2); -AM2321 am2321; - -float sensor_tem,sensor_hum,sensor_light,Sensor_etoh; - -float sensorPM25 = 6.6; - -long map(long x, long in_min, long in_max, long out_min, long out_max) -{ - return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; -} - -#ifdef OPEN_PM25 -void PM25_init(void) -{ - //pc.printf("Enter PM25_init\r\n"); - pmSerial.baud(2400); -} - -// 读取PM2.5传感器 -void PM25() -{ - //pc.printf("Enter PM25()\r\n"); - int data_s = 0; //串口接收数据 - int num = -1; //串口接收数据计数 - int sum = 0; //校验和 - int cal[6]; //接收数据缓存 - float dustDensity = 0; //PM2.5浓度 - - //pmSerial.begin(2400); //首先启动软串口 - //pmSerial.baud(2400); - //pmSerial.flush(); //清空串口缓存 - - while(1) { - //pc.printf("PM25:while(1)\r\n"); - //if(pmSerial.available() > 0) { //串口缓存有数据 - if (pmSerial.readable() > 0) { - //if ((data_s = pmSerial.getc()) != 0) { - //myled = 0; - //pc.printf("readable() > 0\r\n"); - //data_s = pmSerial.read(); //读取串口缓存数据 - data_s = pmSerial.getc(); - if(data_s == 0xAA) { //得到数据帧起始位 - num = 0; //开始计数 - } else if(num >= 0) { - num++; //读到数据,计数+1 - cal[num-1] = data_s; //数据保存到缓存中 - if(num == 6) { //读到数据帧最后一位 - sum = cal[0] + cal[1] + cal[2] + cal[3]; //计算校验和 - if(sum == cal[4] && cal[5] == 0xFF) { //校验和匹配,数据帧最后一位为0xFF,说明接收的数据帧正常 - dustDensity = (cal[0]*256 + cal[1])*(5.0/1024)*550; //计算PM2.5浓度,单位ug/m3 - } else { //接收的数据不正常 - dustDensity = 0; //浓度清零 - } - break; - } - } - } - } - //pmSerial.end(); //关闭软串口 - //return dustDensity; //返回值 - sensorPM25 = dustDensity; - //pc.printf("sensorPM25 = %f\r\n", sensorPM25); -} -#endif - -// 读取光照传感器 -void updateLight() -{ - //sensor_light = map(analogRead(A0), 0, 1023, 0, 255); - //float lvf = gLight; - uint16_t lt = gLight.read_u16(); - //pc.printf("light = %d, lvf = %f\r\n", lt, lvf); - sensor_light = map(lt, 0, 65535, 0, 255);// 这里和Arduino不一样,不知道为什么 -} - -// 读取甲醛传感器 -void updateCH4() -{ - sensorPM25 += 1.0; - //Sensor_etoh = map(analogRead(A2), 0, 1023, 0, 30); - uint16_t ch4 = gCH4.read_u16(); - Sensor_etoh = map(ch4, 0, 65535, 0, 30); - //pc.printf("CH4 = %d\r\n", ch4); -} - -// 读取温湿度传感器 -void updateTempHumi() -{ - static uint32_t cot = 0; - cot++; - - #if 1 - am2321.read(); - sensor_tem = am2321.temperature / 10.0; - sensor_hum = am2321.humidity / 10.0; - #endif - //pc.printf("%u:temp = %.1f, hum = %.1f\r\n",cot, sensor_tem, sensor_hum); -}
diff -r e5018e5ba340 -r 8a3cf73d7ed3 userDef.h --- a/userDef.h Thu Jun 16 08:12:33 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,9 +0,0 @@ -#define SSID "TaiYangGong2.4G" -#define PASS "6hy5BIktT" - -char auth[] = "75709bec06a94d0088fd9382bc825070"; - - - - -